From gitlab at gitlab.haskell.org Sun Oct 1 11:33:32 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 01 Oct 2023 07:33:32 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-hasannotation-class Message-ID: <6519590c1145f_3676e75916f4b4512624@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-hasannotation-class at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-hasannotation-class You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 11:54:32 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 01 Oct 2023 07:54:32 -0400 Subject: [Git][ghc/ghc][wip/az/epa-hasannotation-class] EPA: Introduce HasAnnotation class Message-ID: <65195df8695d3_3676e759cd11b85128fb@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-hasannotation-class at Glasgow Haskell Compiler / GHC Commits: db83b0c1 by Alan Zimmerman at 2023-10-01T12:54:10+01:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 9 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/ThToHs.hs - utils/check-exact/Orphans.hs - utils/check-exact/Utils.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2187,6 +2187,6 @@ type instance Anno FastString = SrcAnn NoEpAnns type instance Anno (DotFieldOcc (GhcPass p)) = SrcAnn NoEpAnns -instance (Anno a ~ SrcSpanAnn' (EpAnn an)) +instance (Anno a ~ SrcSpanAnn' (EpAnn an), NoAnn an) => WrapXRec (GhcPass p) a where wrapXRec = noLocA ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -108,6 +108,7 @@ type instance Anno Name = SrcSpanAnnN type instance Anno Id = SrcSpanAnnN type IsSrcSpanAnn p a = ( Anno (IdGhcP p) ~ SrcSpanAnn' (EpAnn a), + NoAnn a, IsPass p) instance UnXRec (GhcPass p) where ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -232,7 +232,7 @@ mkLamCaseMatchGroup origin lam_variant (L l matches) = mkMatchGroup origin (L l $ map fixCtxt matches) where fixCtxt (L a match) = L a match{m_ctxt = LamAlt lam_variant} -mkLocatedList :: Semigroup a +mkLocatedList :: (Semigroup a, NoAnn an) => [GenLocated (SrcAnn a) e2] -> LocatedAn an [GenLocated (SrcAnn a) e2] mkLocatedList ms = case nonEmpty ms of Nothing -> noLocA [] ===================================== compiler/GHC/Parser.y ===================================== @@ -4120,7 +4120,7 @@ sL1 :: HasLoc a => a -> b -> Located b sL1 x = sL (getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1a #-} -sL1a :: HasLoc a => a -> b -> LocatedAn t b +sL1a :: (HasLoc a, HasAnnotation t) => a -> b -> GenLocated t b sL1a x = sL (noAnnSrcSpan $ getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1n #-} @@ -4132,7 +4132,7 @@ sLL :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c sLL x y = sL (comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLa #-} -sLLa :: (HasLoc a, HasLoc b) => a -> b -> c -> LocatedAn t c +sLLa :: (HasLoc a, HasLoc b, NoAnn t) => a -> b -> c -> LocatedAn t c sLLa x y = sL (noAnnSrcSpan $ comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLl #-} ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -75,9 +75,10 @@ module GHC.Parser.Annotation ( -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. - noLocA, getLocA, + HasAnnotation(..), + noLocA, + getLocA, noSrcSpanA, - noAnnSrcSpan, -- ** Working with comments in annotations noComments, comment, addCommentsToSrcAnn, setCommentsSrcAnn, @@ -994,15 +995,15 @@ la2na l = noAnnSrcSpan (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -la2la :: LocatedAn ann1 a2 -> LocatedAn ann2 a2 +la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 la2la (L la a) = L (noAnnSrcSpan (locA la)) a l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = noAnnSrcSpan (locA l) +l2l l = SrcSpanAnn EpAnnNotUsed (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -na2la :: SrcSpanAnn' a -> SrcAnn ann +na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) reLoc :: LocatedAn a e -> Located e @@ -1022,18 +1023,21 @@ reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- -noLocA :: a -> LocatedAn an a -noLocA = L (SrcSpanAnn EpAnnNotUsed noSrcSpan) +class HasAnnotation e where + noAnnSrcSpan :: SrcSpan -> e + +instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where + noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l + +noLocA :: (HasAnnotation e) => a -> GenLocated e a +noLocA = L (noAnnSrcSpan noSrcSpan) getLocA :: GenLocated (SrcSpanAnn' a) e -> SrcSpan getLocA = getHasLoc -noSrcSpanA :: SrcAnn ann +noSrcSpanA :: (HasAnnotation e) => e noSrcSpanA = noAnnSrcSpan noSrcSpan -noAnnSrcSpan :: SrcSpan -> SrcAnn ann -noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l - -- --------------------------------------------------------------------- class NoAnn a where @@ -1163,7 +1167,7 @@ epAnnComments (EpAnn _ _ cs) = cs sortLocatedA :: [GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e] sortLocatedA = sortBy (leftmost_smallest `on` getLocA) -mapLocA :: (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b +mapLocA :: (NoAnn ann) => (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b mapLocA f (L l a) = L (noAnnSrcSpan l) (f a) -- AZ:TODO: move this somewhere sane @@ -1179,10 +1183,14 @@ combineSrcSpansA (SrcSpanAnn aa la) (SrcSpanAnn ab lb) SrcSpanAnn (EpAnn (widenAnchorR anc (realSrcSpan l)) an cs) l -- | Combine locations from two 'Located' things and add them to a third thing -addCLocA :: GenLocated (SrcSpanAnn' a) e1 -> GenLocated SrcSpan e2 -> e3 -> GenLocated (SrcAnn ann) e3 +addCLocA :: (NoAnn ann) + => GenLocated (SrcSpanAnn' a) e1 -> GenLocated SrcSpan e2 -> e3 + -> GenLocated (SrcAnn ann) e3 addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (getLoc b)) c -addCLocAA :: GenLocated (SrcSpanAnn' a1) e1 -> GenLocated (SrcSpanAnn' a2) e2 -> e3 -> GenLocated (SrcAnn ann) e3 +addCLocAA :: (NoAnn ann) + => GenLocated (SrcSpanAnn' a1) e1 -> GenLocated (SrcSpanAnn' a2) e2 -> e3 + -> GenLocated (SrcAnn ann) e3 addCLocAA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (locA $ getLoc b)) c -- --------------------------------------------------------------------- @@ -1332,26 +1340,33 @@ instance Semigroup EpAnnComments where EpaCommentsBalanced cs1 as1 <> EpaCommentsBalanced cs2 as2 = EpaCommentsBalanced (cs1 ++ cs2) (as1++as2) -instance NoAnn NoEpAnns where - noAnn = NoEpAnns - instance Semigroup AnnListItem where (AnnListItem l1) <> (AnnListItem l2) = AnnListItem (l1 <> l2) -instance NoAnn AnnListItem where - noAnn = AnnListItem [] - - instance Semigroup (AnnSortKey tag) where NoAnnSortKey <> x = x x <> NoAnnSortKey = x AnnSortKey ls1 <> AnnSortKey ls2 = AnnSortKey (ls1 <> ls2) +instance Monoid (AnnSortKey tag) where + mempty = NoAnnSortKey + +-- --------------------------------------------------------------------- +-- NoAnn instances + +instance NoAnn NoEpAnns where + noAnn = NoEpAnns + +instance NoAnn AnnListItem where + noAnn = AnnListItem [] + +instance NoAnn AnnContext where + noAnn = AnnContext Nothing [] [] + instance NoAnn AnnList where noAnn = AnnList Nothing Nothing Nothing [] [] -instance Monoid (AnnSortKey tag) where - mempty = NoAnnSortKey +-- --------------------------------------------------------------------- instance NoAnn NameAnn where noAnn = NameAnnTrailing [] ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -714,7 +714,7 @@ checkCTupSize tup_size * * ********************************************************************* -} -wrapGenSpan :: a -> LocatedAn an a +wrapGenSpan :: (NoAnn an) => a -> LocatedAn an a -- Wrap something in a "generatedSrcSpan" -- See Note [Rebindable syntax and HsExpansion] wrapGenSpan x = L (noAnnSrcSpan generatedSrcSpan) x @@ -742,10 +742,10 @@ genHsVar nm = HsVar noExtField $ wrapGenSpan nm genAppType :: HsExpr GhcRn -> HsType (NoGhcTc GhcRn) -> HsExpr GhcRn genAppType expr ty = HsAppType noExtField (wrapGenSpan expr) noHsTok (mkEmptyWildCardBndrs (wrapGenSpan ty)) -genLHsLit :: HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) +genLHsLit :: (NoAnn an) => HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) genLHsLit = wrapGenSpan . HsLit noAnn -genHsIntegralLit :: IntegralLit -> LocatedAn an (HsExpr GhcRn) +genHsIntegralLit :: (NoAnn an) => IntegralLit -> LocatedAn an (HsExpr GhcRn) genHsIntegralLit = genLHsLit . HsInt noExtField genHsTyLit :: FastString -> HsType GhcRn @@ -767,11 +767,15 @@ genWildPat = wrapGenSpan $ WildPat noExtField genSimpleFunBind :: Name -> [LPat GhcRn] -> LHsExpr GhcRn -> LHsBind GhcRn genSimpleFunBind fun pats expr - = L gen $ genFunBind (L gen fun) - [mkMatch (mkPrefixFunRhs (L gen fun)) pats expr + = L genA $ genFunBind (L genN fun) + [mkMatch (mkPrefixFunRhs (L genN fun)) pats expr emptyLocalBinds] where - gen = noAnnSrcSpan generatedSrcSpan + genA :: SrcSpanAnnA + genA = noAnnSrcSpan generatedSrcSpan + + genN :: SrcSpanAnnN + genN = noAnnSrcSpan generatedSrcSpan genFunBind :: LocatedN Name -> [LMatch GhcRn (LHsExpr GhcRn)] -> HsBind GhcRn ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -142,13 +142,13 @@ getL = CvtM (\_ loc -> Right (loc,loc)) setL :: SrcSpan -> CvtM () setL loc = CvtM (\_ _ -> Right (loc, ())) -returnLA :: e -> CvtM (LocatedAn ann e) +returnLA :: (NoAnn ann) => e -> CvtM (LocatedAn ann e) returnLA x = CvtM (\_ loc -> Right (loc, L (noAnnSrcSpan loc) x)) returnJustLA :: a -> CvtM (Maybe (LocatedA a)) returnJustLA = fmap Just . returnLA -wrapParLA :: (LocatedAn ann a -> b) -> a -> CvtM b +wrapParLA :: (NoAnn ann) => (LocatedAn ann a -> b) -> a -> CvtM b wrapParLA add_par x = CvtM (\_ loc -> Right (loc, add_par (L (noAnnSrcSpan loc) x))) wrapMsg :: ThingBeingConverted -> CvtM' ConversionFailReason a -> CvtM' RunSpliceFailReason a ===================================== utils/check-exact/Orphans.hs ===================================== @@ -62,9 +62,6 @@ instance NoAnn AddEpAnn where instance NoAnn AnnKeywordId where noAnn = Annlarrowtail {- gotta pick one -} -instance NoAnn AnnContext where - noAnn = AnnContext Nothing [] [] - instance NoAnn EpAnnSumPat where noAnn = EpAnnSumPat noAnn noAnn noAnn ===================================== utils/check-exact/Utils.hs ===================================== @@ -371,9 +371,9 @@ setAnchorHsModule hsmod anc cs = hsmod { hsmodExt = (hsmodExt hsmod) {hsmodAnn = -- |Version of l2l that preserves the anchor, immportant if it has an -- updated AnchorOperation -moveAnchor :: Monoid b => SrcAnn a -> SrcAnn b +moveAnchor :: NoAnn b => SrcAnn a -> SrcAnn b moveAnchor (SrcSpanAnn EpAnnNotUsed l) = noAnnSrcSpan l -moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc mempty cs) l +moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc noAnn cs) l -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db83b0c157f5b5c3de6262504cbe58fdec4ff84e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db83b0c157f5b5c3de6262504cbe58fdec4ff84e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 12:54:16 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Sun, 01 Oct 2023 08:54:16 -0400 Subject: [Git][ghc/ghc][wip/T23442] 2 commits: CorePrep: Refactor FloatingBind (#23442) Message-ID: <65196bf886c88_3676e75b70b128517913@gitlab.mail> Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC Commits: 62f9906a by Sebastian Graf at 2023-10-01T14:52:38+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. - - - - - 81510043 by Sebastian Graf at 2023-10-01T14:53:53+02:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 3 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. Flatten nested lets as much as possible. + See Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,48 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Very often (caveat in Wrinkle (FCP1) below), `v` is actually used and the +allocation of the thunk closure was in vain. +Hence we carry around a bunch of floated bindings with us so that we can leave +behind more values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +Floating to top-level can make an asymptotic difference, because `sat` becomes +an SAT; See Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; See Note [wantFloatOutOfRhsOrArg]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's simply like any other ok-for-spec-eval Float (see `mkFloat`) that has + a non-DEFAULT Case alternative to bind the unsafe coercion field of the Refl + constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + +Wrinkles: + (FCP1) + Local floating as above is not necessarily an optimisation if `v` doesn't + up being evaluated. In that case, we allocate a 4 word closure for `v` but + won't need to allocate separate closures for `sat` (2 words) and the `(:)` + conapp (3 words), thus saving at least one word, depending on how much the + set of FVs between `sat` and `(:)` overlap. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,7 +600,7 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float new_float = mkFloat env dmd is_unlifted bndr1 rhs1 @@ -578,15 +621,18 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (top_floats floats) + floats' = floats { top_floats = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { top_floats = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +650,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +667,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -630,7 +678,7 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +688,30 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = FloatSome TopLvlFloatable + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs + +data FloatDecision + = FloatNone + | FloatAll + | FloatSome !FloatInfo -- ^ Float all bindings with <= this info + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + FloatSome info -> partitionFloats info floats + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +797,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +848,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +902,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +925,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1168,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1214,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1226,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1305,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1337,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1450,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1473,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1489,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1475,7 +1504,7 @@ cpeArg env dmd arg -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1537,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1791,159 +1806,291 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it is a (let-bound) value +(`BoundVal`), or otherwise whether it will be `CaseBound` or `LetBound`. +We want to case-bind iff the binding is either ok-for-spec-eval, unlifted, +strictly used (and perhaps lifted), or a literal string (Wrinkle (FI1) below). + +The `FloatInfo` of a `Float` describes how far it will float. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> ...`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> ...`. + +All lazy (and hence lifted) bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Wrinkles: + (FI1) + String literals are a somewhat weird outlier; they qualify as + 'TopLvlFloatable' and will be floated quite aggressively, but the code + generator expects unboxed values to be case-bound (in contrast to boxed + values). This requires a special case in 'mkFloat'. + See also Wrinkle (FS1) of Note [ANF-ising literal string arguments]. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind`. +It has one `OrdList` per class of `FloatInfo` with the following meaning: + + * Any binding in `top_floats` is at least `TopLvlFloatable`; + any binding in `lzy_floats` is at least `LazyContextFloatable`; + any binding in `str_floats` is at least `StrictContextFloatable`. + + * `str_floats` is nested inside `lzy_floats`, is nested inside `top_floats`. + No binding in a "higher" `FloatInfo` class may scope over bindings in + a "lower" class; for example, no binding in `top_floats` may scope over a + binding in `str_floats`. + +(It is always safe to put the whole telescope in `str_floats`.) +There are several operations for creating and combining `Floats` that maintain +these properties. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the `FloatInfo` of the `Floats` (e.g., the highest class of non-empty +`OrdList`): + + * If we want to float to the top-level (`x = <>; ...`), we may take all + bindings that are `TopLvlFloatable` and leave the rest inside the binding. + This is encoded in a `FloatDecision` of `FloatSome TopLvlFloatable`. + * If we want to float locally (let or app), then the floating decision is + `FloatAll` or `FloatNone`; see Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + | BoundVal -- ^ A value binding (E.g., a 'LetBound' that is an HNF) + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving (Eq, Ord) + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + ppr BoundVal = text "Letv" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { top_floats :: !(OrdList FloatingBind) + , lzy_floats :: !(OrdList FloatingBind) + , str_floats :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings + ppr (Floats top lzy str) = text "Floats" <> braces (vcat (map ppr [top, lzy, str])) mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] +mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ + Float (NonRec bndr' rhs) bound info where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- See Note [BindInfo and FloatInfo], Wrinkle (FI1) + -- for why it's not BoundVal + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted is_hnf = exprIsHNF rhs + is_boxed = isBoxedType (idType bndr) is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats nilOL nilOL nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats b1 b2 b3) = isNilOL b1 && isNilOL b2 && isNilOL b3 -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats (Floats top lzy str) = top `appOL` lzy `appOL` str unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats +unitFloat = snocFloat emptyFloats -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Computes the \"worst\" 'FloatInfo' for a 'Floats', e.g., the 'FloatInfo' +-- of the innermost 'OrdList' which is non-empty. +floatsInfo :: Floats -> FloatInfo +floatsInfo floats + | not (isNilOL (str_floats floats)) = StrictContextFloatable + | not (isNilOL (lzy_floats floats)) = LazyContextFloatable + | otherwise = TopLvlFloatable + +-- | Append a 'FloatingBind' `b` to a 'Floats' telescope `bs` that may reference any +-- binding of the 'Floats'. +-- This function picks the appropriate 'OrdList' in `bs` that `b` is appended to, +-- respecting its 'FloatInfo' and scoping. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb@(Float bind bound info) + | CaseBound <- bound + , TopLvlFloatable <- info + , NonRec _ rhs <- bind + , exprIsTickedString rhs + -- Always insert Literal (strings) at the front. + -- They won't scope over any existing binding in `floats`. + = floats { top_floats = fb `consOL` top_floats floats } + | otherwise + = snoc_at floats fb (max (floatsInfo floats) info) + -- max: Respect scoping, hence `floatsInfo`, and respect info of `fb` +snocFloat floats fb at UnsafeEqualityCase{} -- treat it like an ok-for-spec Float + = snoc_at floats fb (max (floatsInfo floats) LazyContextFloatable) +snocFloat floats fb at FloatTick{} + = snoc_at floats fb (floatsInfo floats) -- Ticks are simply snoced + +snoc_at :: Floats -> FloatingBind -> FloatInfo -> Floats +snoc_at floats fb info = case info of + TopLvlFloatable -> floats { top_floats = top_floats floats `snocOL` fb } + LazyContextFloatable -> floats { lzy_floats = lzy_floats floats `snocOL` fb } + StrictContextFloatable -> floats { str_floats = str_floats floats `snocOL` fb } + +-- | Put all floats with 'FloatInfo' less than or equal to the given one in the +-- left partition, the rest in the right. Morally, +-- +-- > partitionFloats info fs = partition (<= info) fs +-- +partitionFloats :: FloatInfo -> Floats -> (Floats, Floats) +partitionFloats info (Floats top lzy str) = case info of + TopLvlFloatable -> (Floats top nilOL nilOL, Floats nilOL lzy str) + LazyContextFloatable -> (Floats top lzy nilOL, Floats nilOL nilOL str) + StrictContextFloatable -> (Floats top lzy str, Floats nilOL nilOL nilOL) + +push_down_floats :: FloatInfo -> Floats -> Floats +push_down_floats info fs@(Floats top lzy str) = case info of + TopLvlFloatable -> fs + LazyContextFloatable -> Floats nilOL (top `appOL` lzy) str + StrictContextFloatable -> Floats nilOL nilOL (getFloats fs) + +-- | Cons a 'FloatingBind' `b` to a 'Floats' telescope `bs` which scopes over +-- `b`. This function appropriately pushes around bindings in the 'OrdList's of +-- `bs` so that `b` is the very first binding in the resulting telescope. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb at FloatTick{} floats = + floats { top_floats = fb `consOL` top_floats floats } +consFloat fb@(Float _ _ info) floats = case info of + TopLvlFloatable -> floats' { top_floats = fb `consOL` top_floats floats' } + LazyContextFloatable -> floats' { lzy_floats = fb `consOL` lzy_floats floats' } + StrictContextFloatable -> floats' { str_floats = fb `consOL` str_floats floats' } + where + floats' = push_down_floats info floats +consFloat fb at UnsafeEqualityCase{} floats = -- like the LazyContextFloatable Float case + floats' { lzy_floats = fb `consOL` lzy_floats floats' } + where + floats' = push_down_floats LazyContextFloatable floats + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + -- After having pushed down floats in inner, we can simply zip with up. + zipFloats outer (push_down_floats (floatsInfo outer) inner) + +-- | Zip up two telescopes which don't scope over each other. +zipFloats :: Floats -> Floats -> Floats +zipFloats floats1 floats2 + = Floats + { top_floats = top_floats floats1 `appOL` top_floats floats2 + , lzy_floats = lzy_floats floats1 `appOL` lzy_floats floats2 + , str_floats = str_floats floats1 `appOL` str_floats floats2 + } -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- For top level only; we don't expect any Strict or LazyContextFloatable 'FloatInfo' +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2098,80 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Do we want to float out `y` out of `x`? +(Similarly for `(\x. e) (let y = e1 in e2)`.) +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec) + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + 2. ... `e2` becomes a value in doing so, in which case we won`t need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value, so we return `FloatNone` + if there are any float is `StrictContextFloatable`, and return `FloatAll` + otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = f (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> f r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and in so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + + + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (floatsInfo floats <= max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatOutOfRhsOrArg] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatOutOfRhsOrArg], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2426,33 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (top, ticks1) = foldlOL f (nilOL,nilOL) (top_floats floats) + (lzy, ticks2) = foldlOL f (nilOL,ticks1) (lzy_floats floats) + (str, ticks3) = foldlOL f (nilOL,ticks2) (str_floats floats) + in (Floats top lzy str, ticks3) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f@(Float _ BoundVal _) + -- don't need to wrap the tick around a value; nothing to execute. + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/676b816f0edcfade0d3267eea51f1a1e201b55d7...81510043c7093b4df558aa4dd19bfc35542be02d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/676b816f0edcfade0d3267eea51f1a1e201b55d7...81510043c7093b4df558aa4dd19bfc35542be02d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 13:12:11 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Sun, 01 Oct 2023 09:12:11 -0400 Subject: [Git][ghc/ghc][wip/T23442] 2 commits: CorePrep: Refactor FloatingBind (#23442) Message-ID: <6519702bcc4e2_3676e75bf315285229d7@gitlab.mail> Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC Commits: 13e857ba by Sebastian Graf at 2023-10-01T15:11:56+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. - - - - - 814ed90f by Sebastian Graf at 2023-10-01T15:11:56+02:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 3 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. Flatten nested lets as much as possible. + See Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,48 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Very often (caveat in Wrinkle (FCP1) below), `v` is actually used and the +allocation of the thunk closure was in vain. +Hence we carry around a bunch of floated bindings with us so that we can leave +behind more values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +Floating to top-level can make an asymptotic difference, because `sat` becomes +an SAT; See Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; See Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's simply like any other ok-for-spec-eval Float (see `mkFloat`) that has + a non-DEFAULT Case alternative to bind the unsafe coercion field of the Refl + constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + +Wrinkles: + (FCP1) + Local floating as above is not necessarily an optimisation if `v` doesn't + up being evaluated. In that case, we allocate a 4 word closure for `v` but + won't need to allocate separate closures for `sat` (2 words) and the `(:)` + conapp (3 words), thus saving at least one word, depending on how much the + set of FVs between `sat` and `(:)` overlap. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,7 +600,7 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float new_float = mkFloat env dmd is_unlifted bndr1 rhs1 @@ -578,15 +621,18 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (top_floats floats) + floats' = floats { top_floats = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { top_floats = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +650,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +667,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -630,7 +678,7 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +688,30 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = FloatSome TopLvlFloatable + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs + +data FloatDecision + = FloatNone + | FloatAll + | FloatSome !FloatInfo -- ^ Float all bindings with <= this info + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + FloatSome info -> partitionFloats info floats + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +797,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +848,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +902,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +925,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1168,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1214,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1226,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1305,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1337,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1450,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1473,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1489,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1475,7 +1504,7 @@ cpeArg env dmd arg -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1537,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1791,159 +1806,291 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it is a (let-bound) value +(`BoundVal`), or otherwise whether it will be `CaseBound` or `LetBound`. +We want to case-bind iff the binding is either ok-for-spec-eval, unlifted, +strictly used (and perhaps lifted), or a literal string (Wrinkle (FI1) below). + +The `FloatInfo` of a `Float` describes how far it will float. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> ...`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> ...`. + +All lazy (and hence lifted) bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Wrinkles: + (FI1) + String literals are a somewhat weird outlier; they qualify as + 'TopLvlFloatable' and will be floated quite aggressively, but the code + generator expects unboxed values to be case-bound (in contrast to boxed + values). This requires a special case in 'mkFloat'. + See also Wrinkle (FS1) of Note [ANF-ising literal string arguments]. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind`. +It has one `OrdList` per class of `FloatInfo` with the following meaning: + + * Any binding in `top_floats` is at least `TopLvlFloatable`; + any binding in `lzy_floats` is at least `LazyContextFloatable`; + any binding in `str_floats` is at least `StrictContextFloatable`. + + * `str_floats` is nested inside `lzy_floats`, is nested inside `top_floats`. + No binding in a "higher" `FloatInfo` class may scope over bindings in + a "lower" class; for example, no binding in `top_floats` may scope over a + binding in `str_floats`. + +(It is always safe to put the whole telescope in `str_floats`.) +There are several operations for creating and combining `Floats` that maintain +these properties. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the `FloatInfo` of the `Floats` (e.g., the highest class of non-empty +`OrdList`): + + * If we want to float to the top-level (`x = <>; ...`), we may take all + bindings that are `TopLvlFloatable` and leave the rest inside the binding. + This is encoded in a `FloatDecision` of `FloatSome TopLvlFloatable`. + * If we want to float locally (let or app), then the floating decision is + `FloatAll` or `FloatNone`; see Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + | BoundVal -- ^ A value binding (E.g., a 'LetBound' that is an HNF) + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving (Eq, Ord) + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + ppr BoundVal = text "Letv" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { top_floats :: !(OrdList FloatingBind) + , lzy_floats :: !(OrdList FloatingBind) + , str_floats :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings + ppr (Floats top lzy str) = text "Floats" <> braces (vcat (map ppr [top, lzy, str])) mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] +mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ + Float (NonRec bndr' rhs) bound info where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- See Note [BindInfo and FloatInfo], Wrinkle (FI1) + -- for why it's not BoundVal + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted is_hnf = exprIsHNF rhs + is_boxed = isBoxedType (idType bndr) is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats nilOL nilOL nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats b1 b2 b3) = isNilOL b1 && isNilOL b2 && isNilOL b3 -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats (Floats top lzy str) = top `appOL` lzy `appOL` str unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats +unitFloat = snocFloat emptyFloats -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Computes the \"worst\" 'FloatInfo' for a 'Floats', e.g., the 'FloatInfo' +-- of the innermost 'OrdList' which is non-empty. +floatsInfo :: Floats -> FloatInfo +floatsInfo floats + | not (isNilOL (str_floats floats)) = StrictContextFloatable + | not (isNilOL (lzy_floats floats)) = LazyContextFloatable + | otherwise = TopLvlFloatable + +-- | Append a 'FloatingBind' `b` to a 'Floats' telescope `bs` that may reference any +-- binding of the 'Floats'. +-- This function picks the appropriate 'OrdList' in `bs` that `b` is appended to, +-- respecting its 'FloatInfo' and scoping. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb@(Float bind bound info) + | CaseBound <- bound + , TopLvlFloatable <- info + , NonRec _ rhs <- bind + , exprIsTickedString rhs + -- Always insert Literal (strings) at the front. + -- They won't scope over any existing binding in `floats`. + = floats { top_floats = fb `consOL` top_floats floats } + | otherwise + = snoc_at floats fb (max (floatsInfo floats) info) + -- max: Respect scoping, hence `floatsInfo`, and respect info of `fb` +snocFloat floats fb at UnsafeEqualityCase{} -- treat it like an ok-for-spec Float + = snoc_at floats fb (max (floatsInfo floats) LazyContextFloatable) +snocFloat floats fb at FloatTick{} + = snoc_at floats fb (floatsInfo floats) -- Ticks are simply snoced + +snoc_at :: Floats -> FloatingBind -> FloatInfo -> Floats +snoc_at floats fb info = case info of + TopLvlFloatable -> floats { top_floats = top_floats floats `snocOL` fb } + LazyContextFloatable -> floats { lzy_floats = lzy_floats floats `snocOL` fb } + StrictContextFloatable -> floats { str_floats = str_floats floats `snocOL` fb } + +-- | Put all floats with 'FloatInfo' less than or equal to the given one in the +-- left partition, the rest in the right. Morally, +-- +-- > partitionFloats info fs = partition (<= info) fs +-- +partitionFloats :: FloatInfo -> Floats -> (Floats, Floats) +partitionFloats info (Floats top lzy str) = case info of + TopLvlFloatable -> (Floats top nilOL nilOL, Floats nilOL lzy str) + LazyContextFloatable -> (Floats top lzy nilOL, Floats nilOL nilOL str) + StrictContextFloatable -> (Floats top lzy str, Floats nilOL nilOL nilOL) + +push_down_floats :: FloatInfo -> Floats -> Floats +push_down_floats info fs@(Floats top lzy str) = case info of + TopLvlFloatable -> fs + LazyContextFloatable -> Floats nilOL (top `appOL` lzy) str + StrictContextFloatable -> Floats nilOL nilOL (getFloats fs) + +-- | Cons a 'FloatingBind' `b` to a 'Floats' telescope `bs` which scopes over +-- `b`. This function appropriately pushes around bindings in the 'OrdList's of +-- `bs` so that `b` is the very first binding in the resulting telescope. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb at FloatTick{} floats = + floats { top_floats = fb `consOL` top_floats floats } +consFloat fb@(Float _ _ info) floats = case info of + TopLvlFloatable -> floats' { top_floats = fb `consOL` top_floats floats' } + LazyContextFloatable -> floats' { lzy_floats = fb `consOL` lzy_floats floats' } + StrictContextFloatable -> floats' { str_floats = fb `consOL` str_floats floats' } + where + floats' = push_down_floats info floats +consFloat fb at UnsafeEqualityCase{} floats = -- like the LazyContextFloatable Float case + floats' { lzy_floats = fb `consOL` lzy_floats floats' } + where + floats' = push_down_floats LazyContextFloatable floats + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + -- After having pushed down floats in inner, we can simply zip with up. + zipFloats outer (push_down_floats (floatsInfo outer) inner) + +-- | Zip up two telescopes which don't scope over each other. +zipFloats :: Floats -> Floats -> Floats +zipFloats floats1 floats2 + = Floats + { top_floats = top_floats floats1 `appOL` top_floats floats2 + , lzy_floats = lzy_floats floats1 `appOL` lzy_floats floats2 + , str_floats = str_floats floats1 `appOL` str_floats floats2 + } -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- For top level only; we don't expect any Strict or LazyContextFloatable 'FloatInfo' +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2098,80 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Do we want to float out `y` out of `x`? +(Similarly for `(\x. e) (let y = e1 in e2)`.) +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec) + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + 2. ... `e2` becomes a value in doing so, in which case we won`t need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value, so we return `FloatNone` + if there are any float is `StrictContextFloatable`, and return `FloatAll` + otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = f (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> f r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and in so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + + + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (floatsInfo floats <= max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2426,33 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (top, ticks1) = foldlOL f (nilOL,nilOL) (top_floats floats) + (lzy, ticks2) = foldlOL f (nilOL,ticks1) (lzy_floats floats) + (str, ticks3) = foldlOL f (nilOL,ticks2) (str_floats floats) + in (Floats top lzy str, ticks3) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f@(Float _ BoundVal _) + -- don't need to wrap the tick around a value; nothing to execute. + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81510043c7093b4df558aa4dd19bfc35542be02d...814ed90f0ca8b829d12a714f1bd8e603d1699095 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81510043c7093b4df558aa4dd19bfc35542be02d...814ed90f0ca8b829d12a714f1bd8e603d1699095 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 13:12:37 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Sun, 01 Oct 2023 09:12:37 -0400 Subject: [Git][ghc/ghc][wip/T23442] 2 commits: CorePrep: Refactor FloatingBind (#23442) Message-ID: <6519704569b4b_3676e75bf6e73452338d@gitlab.mail> Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC Commits: 81bd91e3 by Sebastian Graf at 2023-10-01T15:12:24+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. - - - - - 9cd0892a by Sebastian Graf at 2023-10-01T15:12:24+02:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 3 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. Flatten nested lets as much as possible. + See Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,48 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Very often (caveat in Wrinkle (FCP1) below), `v` is actually used and the +allocation of the thunk closure was in vain. +Hence we carry around a bunch of floated bindings with us so that we can leave +behind more values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +Floating to top-level can make an asymptotic difference, because `sat` becomes +an SAT; See Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; See Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's simply like any other ok-for-spec-eval Float (see `mkFloat`) that has + a non-DEFAULT Case alternative to bind the unsafe coercion field of the Refl + constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + +Wrinkles: + (FCP1) + Local floating as above is not necessarily an optimisation if `v` doesn't + up being evaluated. In that case, we allocate a 4 word closure for `v` but + won't need to allocate separate closures for `sat` (2 words) and the `(:)` + conapp (3 words), thus saving at least one word, depending on how much the + set of FVs between `sat` and `(:)` overlap. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,7 +600,7 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float new_float = mkFloat env dmd is_unlifted bndr1 rhs1 @@ -578,15 +621,18 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (top_floats floats) + floats' = floats { top_floats = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { top_floats = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +650,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +667,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -630,7 +678,7 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +688,30 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = FloatSome TopLvlFloatable + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs + +data FloatDecision + = FloatNone + | FloatAll + | FloatSome !FloatInfo -- ^ Float all bindings with <= this info + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + FloatSome info -> partitionFloats info floats + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +797,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +848,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +902,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +925,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1168,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1214,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1226,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1305,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1337,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1450,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1473,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1489,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1475,7 +1504,7 @@ cpeArg env dmd arg -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1537,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1791,159 +1806,290 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it is a (let-bound) value +(`BoundVal`), or otherwise whether it will be `CaseBound` or `LetBound`. +We want to case-bind iff the binding is either ok-for-spec-eval, unlifted, +strictly used (and perhaps lifted), or a literal string (Wrinkle (FI1) below). + +The `FloatInfo` of a `Float` describes how far it will float. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> ...`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> ...`. + +All lazy (and hence lifted) bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Wrinkles: + (FI1) + String literals are a somewhat weird outlier; they qualify as + 'TopLvlFloatable' and will be floated quite aggressively, but the code + generator expects unboxed values to be case-bound (in contrast to boxed + values). This requires a special case in 'mkFloat'. + See also Wrinkle (FS1) of Note [ANF-ising literal string arguments]. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind`. +It has one `OrdList` per class of `FloatInfo` with the following meaning: + + * Any binding in `top_floats` is at least `TopLvlFloatable`; + any binding in `lzy_floats` is at least `LazyContextFloatable`; + any binding in `str_floats` is at least `StrictContextFloatable`. + + * `str_floats` is nested inside `lzy_floats`, is nested inside `top_floats`. + No binding in a "higher" `FloatInfo` class may scope over bindings in + a "lower" class; for example, no binding in `top_floats` may scope over a + binding in `str_floats`. + +(It is always safe to put the whole telescope in `str_floats`.) +There are several operations for creating and combining `Floats` that maintain +these properties. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the `FloatInfo` of the `Floats` (e.g., the highest class of non-empty +`OrdList`): + + * If we want to float to the top-level (`x = <>; ...`), we may take all + bindings that are `TopLvlFloatable` and leave the rest inside the binding. + This is encoded in a `FloatDecision` of `FloatSome TopLvlFloatable`. + * If we want to float locally (let or app), then the floating decision is + `FloatAll` or `FloatNone`; see Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + | BoundVal -- ^ A value binding (E.g., a 'LetBound' that is an HNF) + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving (Eq, Ord) + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + ppr BoundVal = text "Letv" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { top_floats :: !(OrdList FloatingBind) + , lzy_floats :: !(OrdList FloatingBind) + , str_floats :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings + ppr (Floats top lzy str) = text "Floats" <> braces (vcat (map ppr [top, lzy, str])) mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] +mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ + Float (NonRec bndr' rhs) bound info where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- See Note [BindInfo and FloatInfo], Wrinkle (FI1) + -- for why it's not BoundVal + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted is_hnf = exprIsHNF rhs is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats nilOL nilOL nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats b1 b2 b3) = isNilOL b1 && isNilOL b2 && isNilOL b3 -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats (Floats top lzy str) = top `appOL` lzy `appOL` str unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats +unitFloat = snocFloat emptyFloats -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Computes the \"worst\" 'FloatInfo' for a 'Floats', e.g., the 'FloatInfo' +-- of the innermost 'OrdList' which is non-empty. +floatsInfo :: Floats -> FloatInfo +floatsInfo floats + | not (isNilOL (str_floats floats)) = StrictContextFloatable + | not (isNilOL (lzy_floats floats)) = LazyContextFloatable + | otherwise = TopLvlFloatable + +-- | Append a 'FloatingBind' `b` to a 'Floats' telescope `bs` that may reference any +-- binding of the 'Floats'. +-- This function picks the appropriate 'OrdList' in `bs` that `b` is appended to, +-- respecting its 'FloatInfo' and scoping. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb@(Float bind bound info) + | CaseBound <- bound + , TopLvlFloatable <- info + , NonRec _ rhs <- bind + , exprIsTickedString rhs + -- Always insert Literal (strings) at the front. + -- They won't scope over any existing binding in `floats`. + = floats { top_floats = fb `consOL` top_floats floats } + | otherwise + = snoc_at floats fb (max (floatsInfo floats) info) + -- max: Respect scoping, hence `floatsInfo`, and respect info of `fb` +snocFloat floats fb at UnsafeEqualityCase{} -- treat it like an ok-for-spec Float + = snoc_at floats fb (max (floatsInfo floats) LazyContextFloatable) +snocFloat floats fb at FloatTick{} + = snoc_at floats fb (floatsInfo floats) -- Ticks are simply snoced + +snoc_at :: Floats -> FloatingBind -> FloatInfo -> Floats +snoc_at floats fb info = case info of + TopLvlFloatable -> floats { top_floats = top_floats floats `snocOL` fb } + LazyContextFloatable -> floats { lzy_floats = lzy_floats floats `snocOL` fb } + StrictContextFloatable -> floats { str_floats = str_floats floats `snocOL` fb } + +-- | Put all floats with 'FloatInfo' less than or equal to the given one in the +-- left partition, the rest in the right. Morally, +-- +-- > partitionFloats info fs = partition (<= info) fs +-- +partitionFloats :: FloatInfo -> Floats -> (Floats, Floats) +partitionFloats info (Floats top lzy str) = case info of + TopLvlFloatable -> (Floats top nilOL nilOL, Floats nilOL lzy str) + LazyContextFloatable -> (Floats top lzy nilOL, Floats nilOL nilOL str) + StrictContextFloatable -> (Floats top lzy str, Floats nilOL nilOL nilOL) + +push_down_floats :: FloatInfo -> Floats -> Floats +push_down_floats info fs@(Floats top lzy str) = case info of + TopLvlFloatable -> fs + LazyContextFloatable -> Floats nilOL (top `appOL` lzy) str + StrictContextFloatable -> Floats nilOL nilOL (getFloats fs) + +-- | Cons a 'FloatingBind' `b` to a 'Floats' telescope `bs` which scopes over +-- `b`. This function appropriately pushes around bindings in the 'OrdList's of +-- `bs` so that `b` is the very first binding in the resulting telescope. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb at FloatTick{} floats = + floats { top_floats = fb `consOL` top_floats floats } +consFloat fb@(Float _ _ info) floats = case info of + TopLvlFloatable -> floats' { top_floats = fb `consOL` top_floats floats' } + LazyContextFloatable -> floats' { lzy_floats = fb `consOL` lzy_floats floats' } + StrictContextFloatable -> floats' { str_floats = fb `consOL` str_floats floats' } + where + floats' = push_down_floats info floats +consFloat fb at UnsafeEqualityCase{} floats = -- like the LazyContextFloatable Float case + floats' { lzy_floats = fb `consOL` lzy_floats floats' } + where + floats' = push_down_floats LazyContextFloatable floats + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + -- After having pushed down floats in inner, we can simply zip with up. + zipFloats outer (push_down_floats (floatsInfo outer) inner) + +-- | Zip up two telescopes which don't scope over each other. +zipFloats :: Floats -> Floats -> Floats +zipFloats floats1 floats2 + = Floats + { top_floats = top_floats floats1 `appOL` top_floats floats2 + , lzy_floats = lzy_floats floats1 `appOL` lzy_floats floats2 + , str_floats = str_floats floats1 `appOL` str_floats floats2 + } -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- For top level only; we don't expect any Strict or LazyContextFloatable 'FloatInfo' +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2097,80 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Do we want to float out `y` out of `x`? +(Similarly for `(\x. e) (let y = e1 in e2)`.) +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec) + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + 2. ... `e2` becomes a value in doing so, in which case we won`t need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value, so we return `FloatNone` + if there are any float is `StrictContextFloatable`, and return `FloatAll` + otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = f (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> f r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and in so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + + + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (floatsInfo floats <= max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2425,33 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (top, ticks1) = foldlOL f (nilOL,nilOL) (top_floats floats) + (lzy, ticks2) = foldlOL f (nilOL,ticks1) (lzy_floats floats) + (str, ticks3) = foldlOL f (nilOL,ticks2) (str_floats floats) + in (Floats top lzy str, ticks3) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f@(Float _ BoundVal _) + -- don't need to wrap the tick around a value; nothing to execute. + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/814ed90f0ca8b829d12a714f1bd8e603d1699095...9cd0892a61d7daf1a5feeede442e54ccfb516688 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/814ed90f0ca8b829d12a714f1bd8e603d1699095...9cd0892a61d7daf1a5feeede442e54ccfb516688 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 15:17:55 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Sun, 01 Oct 2023 11:17:55 -0400 Subject: [Git][ghc/ghc][wip/T20749] 5 commits: CorePrep: Refactor FloatingBind (#23442) Message-ID: <65198da3b2a_3676e75ed036545324f3@gitlab.mail> Sebastian Graf pushed to branch wip/T20749 at Glasgow Haskell Compiler / GHC Commits: 81bd91e3 by Sebastian Graf at 2023-10-01T15:12:24+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. - - - - - 9cd0892a by Sebastian Graf at 2023-10-01T15:12:24+02:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - cb48d34f by Sebastian Graf at 2023-10-01T15:52:54+02:00 Make DataCon workers strict in strict fields (#20749) This patch tweaks `exprIsConApp_maybe`, `exprIsHNF` and friends, and Demand Analysis so that they exploit and maintain strictness of DataCon workers. See `Note [Strict fields in Core]` for details. Very little needed to change, and it puts field seq insertion done by Tag Inference into a new perspective: That of *implementing* strict field semantics. Before Tag Inference, DataCon workers are strict. Afterwards they are effectively lazy and field seqs happen around use sites. History has shown that there is no other way to guarantee taggedness and thus the STG Strict Field Invariant. Knock-on changes: * `exprIsHNF` previously used `exprOkForSpeculation` on unlifted arguments instead of recursing into `exprIsHNF`. That regressed the termination analysis in CPR analysis (which simply calls out to `exprIsHNF`), so I made it call `exprOkForSpeculation`, too. * There's a small regression in Demand Analysis, visible in the changed test output of T16859: Previously, a field seq on a variable would give that variable a "used exactly once" demand, now it's "used at least once", because `dmdTransformDataConSig` accounts for future uses of the field that actually all go through the case binder (and hence won't re-enter the potential thunk). The difference should hardly be observable. * The Simplifier's fast path for data constructors only applies to lazy data constructors now. I observed regressions involving Data.Binary.Put's `Pair` data type. * Unfortunately, T21392 does no longer reproduce after this patch, so I marked it as "not broken" in order to track whether we regress again in the future. Fixes #20749, the satisfying conclusion of an annoying saga (cf. the ideas in #21497 and #22475). - - - - - dffbd39a by Jaro Reinders at 2023-10-01T15:52:54+02:00 Try fixing allocation regressions - - - - - 3f334d12 by Sebastian Graf at 2023-10-01T17:17:06+02:00 CorePrep: Attach evaldUnfolding to floats to detect more values - - - - - 26 changed files: - .ghcid - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Stg/InferTags.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Tc/TyCl/Build.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Utils/Misc.hs - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/simplStg/should_compile/inferTags002.stderr - testsuite/tests/stranal/sigs/T16859.stderr Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -636,6 +636,8 @@ pcDataConWithFixity' declared_infix dc_name wrk_key rri -- See Note [Constructor tag allocation] and #14657 data_con = mkDataCon dc_name declared_infix prom_info (map (const no_bang) arg_tys) + (map (const HsLazy) arg_tys) + (map (const NotMarkedStrict) arg_tys) [] -- No labelled fields tyvars ex_tyvars conc_tyvars ===================================== compiler/GHC/Core.hs ===================================== @@ -42,7 +42,7 @@ module GHC.Core ( foldBindersOfBindStrict, foldBindersOfBindsStrict, collectBinders, collectTyBinders, collectTyAndValBinders, collectNBinders, collectNValBinders_maybe, - collectArgs, stripNArgs, collectArgsTicks, flattenBinds, + collectArgs, collectValArgs, stripNArgs, collectArgsTicks, flattenBinds, collectFunSimple, exprToType, @@ -1005,6 +1005,60 @@ tail position: A cast changes the type, but the type must be the same. But operationally, casts are vacuous, so this is a bit unfortunate! See #14610 for ideas how to fix this. +Note [Strict fields in Core] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Evaluating a data constructor worker evaluates its strict fields. + +In other words, if `MkT` is strict in its first field and `xs` reduces to +`error "boom"`, then `MkT xs b` will throw that error. +Conversely, it is sound to seq the field before the call to the constructor, +e.g., with `case xs of xs' { __DEFAULT -> MkT xs' b }`. +Let's call this transformation "field seq insertion". + +Note in particular that the data constructor application `MkT xs b` above is +*not* a value, unless `xs` is! + +This has pervasive effect on the Core pipeline: + + * `exprIsHNF`/`exprIsConLike`/`exprOkForSpeculation` need to assert that the + strict arguments of a DataCon worker are values/ok-for-spec themselves. + + * `exprIsConApp_maybe` inserts field seqs in the `FloatBind`s it returns, so + that the Simplifier, Constant-folding, the pattern-match checker, etc. + all see the insert field seqs when they match on strict workers. Often this + is just to emphasise strict semantics, but for case-of-known constructor + and case-to-let field insertion is *vital*, otherwise these transformations + would lose field seqs. + + * The demand signature of a data constructor is strict in strict field + position, whereas is it's normally lazy. Likewise the demand *transformer* + of a DataCon worker can add stricten up demands on strict field args. + See Note [Demand transformer for data constructors]. + + * In the absence of `-fpedantic-bottoms`, it is still possible that some seqs + are ultimately dropped or delayed due to eta-expansion. + See Note [Dealing with bottom]. + +Strict field semantics is exploited in STG by Note [Tag Inference]: +It performs field seq insertion to statically guarantee *taggedness* of strict +fields, establishing the Note [STG Strict Field Invariant]. (Happily, most +of those seqs are immediately detected as redundant by tag inference and are +omitted.) From then on, DataCon worker semantics are actually lazy, hence it is +important that STG passes maintain the Strict Field Invariant. + + +Historical Note: +The delightfully simple description of strict field semantics is the result of +a long saga (#20749, the bits about strict data constructors in #21497, #22475), +where we tried a more lenient (but actually not) semantics first that would +allow both strict and lazy implementations of DataCon workers. This was favoured +because the "pervasive effect" throughout the compiler was deemed too large +(when it really turned out to be very modest). +Alas, this semantics would require us to implement `exprIsHNF` in *exactly* the +same way as above, otherwise the analysis would not be conservative wrt. the +lenient semantics (which includes the strict one). It is also much harder to +explain and maintain, as it turned out. + ************************************************************************ * * In/Out type synonyms @@ -2091,6 +2145,17 @@ collectArgs expr go (App f a) as = go f (a:as) go e as = (e, as) +-- | Takes a nested application expression and returns the function +-- being applied and the arguments to which it is applied +collectValArgs :: Expr b -> (Expr b, [Arg b]) +collectValArgs expr + = go expr [] + where + go (App f a) as + | isValArg a = go f (a:as) + | otherwise = go f as + go e as = (e, as) + -- | Takes a nested application expression and returns the function -- being applied. Looking through casts and ticks to find it. collectFunSimple :: Expr b -> Expr b ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -49,7 +49,8 @@ module GHC.Core.DataCon ( dataConIsInfix, dataConWorkId, dataConWrapId, dataConWrapId_maybe, dataConImplicitTyThings, - dataConRepStrictness, dataConImplBangs, dataConBoxer, + dataConRepStrictness, dataConRepStrictness_maybe, + dataConImplBangs, dataConBoxer, splitDataProductType_maybe, @@ -60,7 +61,7 @@ module GHC.Core.DataCon ( isVanillaDataCon, isNewDataCon, isTypeDataCon, classDataCon, dataConCannotMatch, dataConUserTyVarsNeedWrapper, checkDataConTyVars, - isBanged, isMarkedStrict, cbvFromStrictMark, eqHsBang, isSrcStrict, isSrcUnpacked, + isBanged, isUnpacked, isMarkedStrict, cbvFromStrictMark, eqHsBang, isSrcStrict, isSrcUnpacked, specialPromotedDc, -- ** Promotion related functions @@ -97,6 +98,7 @@ import GHC.Types.Unique.FM ( UniqFM ) import GHC.Types.Unique.Set import GHC.Builtin.Uniques( mkAlphaTyVarUnique ) import GHC.Data.Graph.UnVar -- UnVarSet and operations +import GHC.Data.Maybe (orElse) import {-# SOURCE #-} GHC.Tc.Utils.TcType ( ConcreteTyVars ) @@ -524,6 +526,18 @@ data DataCon -- Matches 1-1 with dcOrigArgTys -- Hence length = dataConSourceArity dataCon + dcImplBangs :: [HsImplBang], + -- The actual decisions made (including failures) + -- about the original arguments; 1-1 with orig_arg_tys + -- See Note [Bangs on data constructor arguments] + + dcStricts :: [StrictnessMark], + -- One mark for every field of the DataCon worker; + -- if it's empty, then all fields are lazy, + -- otherwise it has the same length as dataConRepArgTys. + -- See also Note [Strict fields in Core] in GHC.Core + -- for the effect on the strictness signature + dcFields :: [FieldLabel], -- Field labels for this constructor, in the -- same order as the dcOrigArgTys; @@ -826,13 +840,6 @@ data DataConRep -- after unboxing and flattening, -- and *including* all evidence args - , dcr_stricts :: [StrictnessMark] -- 1-1 with dcr_arg_tys - -- See also Note [Data-con worker strictness] - - , dcr_bangs :: [HsImplBang] -- The actual decisions made (including failures) - -- about the original arguments; 1-1 with orig_arg_tys - -- See Note [Bangs on data constructor arguments] - } type DataConEnv a = UniqFM DataCon a -- Keyed by DataCon @@ -901,43 +908,8 @@ eqSpecPreds spec = [ mkPrimEqPred (mkTyVarTy tv) ty instance Outputable EqSpec where ppr (EqSpec tv ty) = ppr (tv, ty) -{- Note [Data-con worker strictness] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Notice that we do *not* say the worker Id is strict even if the data -constructor is declared strict - e.g. data T = MkT ![Int] Bool -Even though most often the evals are done by the *wrapper* $WMkT, there are -situations in which tag inference will re-insert evals around the worker. -So for all intents and purposes the *worker* MkT is strict, too! - -Unfortunately, if we exposed accurate strictness of DataCon workers, we'd -see the following transformation: - - f xs = case xs of xs' { __DEFAULT -> ... case MkT xs b of x { __DEFAULT -> [x] } } -- DmdAnal: Strict in xs - ==> { drop-seq, binder swap on xs' } - f xs = case MkT xs b of x { __DEFAULT -> [x] } -- DmdAnal: Still strict in xs - ==> { case-to-let } - f xs = let x = MkT xs' b in [x] -- DmdAnal: No longer strict in xs! - -I.e., we are ironically losing strictness in `xs` by dropping the eval on `xs` -and then doing case-to-let. The issue is that `exprIsHNF` currently says that -every DataCon worker app is a value. The implicit assumption is that surrounding -evals will have evaluated strict fields like `xs` before! But now that we had -just dropped the eval on `xs`, that assumption is no longer valid. - -Long story short: By keeping the demand signature lazy, the Simplifier will not -drop the eval on `xs` and using `exprIsHNF` to decide case-to-let and others -remains sound. - -Similarly, during demand analysis in dmdTransformDataConSig, we bump up the -field demand with `C_01`, *not* `C_11`, because the latter exposes too much -strictness that will drop the eval on `xs` above. - -This issue is discussed at length in -"Failed idea: no wrappers for strict data constructors" in #21497 and #22475. - -Note [Bangs on data constructor arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Bangs on data constructor arguments] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider data T = MkT !Int {-# UNPACK #-} !Int Bool @@ -963,8 +935,8 @@ Terminology: the flag settings in the importing module. Also see Note [Bangs on imported data constructors] in GHC.Types.Id.Make -* The dcr_bangs field of the dcRep field records the [HsImplBang] - If T was defined in this module, Without -O the dcr_bangs might be +* The dcImplBangs field records the [HsImplBang] + If T was defined in this module, Without -O the dcImplBangs might be [HsStrict _, HsStrict _, HsLazy] With -O it might be [HsStrict _, HsUnpack _, HsLazy] @@ -973,6 +945,17 @@ Terminology: With -XStrictData it might be [HsStrict _, HsUnpack _, HsStrict _] +* Core passes will often need to know whether the DataCon worker or wrapper in + an application is strict in some (lifted) field or not. This is tracked in the + demand signature attached to a DataCon's worker resp. wrapper Id. + + So if you've got a DataCon dc, you can get the demand signature by + `idDmdSig (dataConWorkId dc)` and make out strict args by testing with + `isStrictDmd`. Similarly, `idDmdSig <$> dataConWrapId_maybe dc` gives + you the demand signature of the wrapper, if it exists. + + These demand signatures are set in GHC.Types.Id.Make. + Note [Detecting useless UNPACK pragmas] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want to issue a warning when there's an UNPACK pragma in the source code, @@ -1008,7 +991,6 @@ we consult HsImplBang: The boolean flag is used only for this warning. See #11270 for motivation. - ************************************************************************ * * \subsection{Instances} @@ -1110,6 +1092,11 @@ isBanged (HsUnpack {}) = True isBanged (HsStrict {}) = True isBanged HsLazy = False +isUnpacked :: HsImplBang -> Bool +isUnpacked (HsUnpack {}) = True +isUnpacked (HsStrict {}) = False +isUnpacked HsLazy = False + isSrcStrict :: SrcStrictness -> Bool isSrcStrict SrcStrict = True isSrcStrict _ = False @@ -1135,13 +1122,15 @@ cbvFromStrictMark MarkedStrict = MarkedCbv -- | Build a new data constructor mkDataCon :: Name - -> Bool -- ^ Is the constructor declared infix? - -> TyConRepName -- ^ TyConRepName for the promoted TyCon - -> [HsSrcBang] -- ^ Strictness/unpack annotations, from user - -> [FieldLabel] -- ^ Field labels for the constructor, - -- if it is a record, otherwise empty - -> [TyVar] -- ^ Universals. - -> [TyCoVar] -- ^ Existentials. + -> Bool -- ^ Is the constructor declared infix? + -> TyConRepName -- ^ TyConRepName for the promoted TyCon + -> [HsSrcBang] -- ^ Strictness/unpack annotations, from user + -> [HsImplBang] -- ^ Strictness/unpack annotations, as inferred by the compiler + -> [StrictnessMark] -- ^ Strictness marks for the DataCon worker's fields in Core + -> [FieldLabel] -- ^ Field labels for the constructor, + -- if it is a record, otherwise empty + -> [TyVar] -- ^ Universals. + -> [TyCoVar] -- ^ Existentials. -> ConcreteTyVars -- ^ TyVars which must be instantiated with -- concrete types @@ -1163,7 +1152,9 @@ mkDataCon :: Name -- Can get the tag from the TyCon mkDataCon name declared_infix prom_info - arg_stricts -- Must match orig_arg_tys 1-1 + arg_stricts -- Must match orig_arg_tys 1-1 + impl_bangs -- Must match orig_arg_tys 1-1 + str_marks -- Must be empty or match dataConRepArgTys 1-1 fields univ_tvs ex_tvs conc_tvs user_tvbs eq_spec theta @@ -1180,6 +1171,8 @@ mkDataCon name declared_infix prom_info = con where is_vanilla = null ex_tvs && null eq_spec && null theta + str_marks' | not $ any isMarkedStrict str_marks = [] + | otherwise = str_marks con = MkData {dcName = name, dcUnique = nameUnique name, dcVanilla = is_vanilla, dcInfix = declared_infix, @@ -1192,7 +1185,8 @@ mkDataCon name declared_infix prom_info dcStupidTheta = stupid_theta, dcOrigArgTys = orig_arg_tys, dcOrigResTy = orig_res_ty, dcRepTyCon = rep_tycon, - dcSrcBangs = arg_stricts, + dcSrcBangs = arg_stricts, dcImplBangs = impl_bangs, + dcStricts = str_marks', dcFields = fields, dcTag = tag, dcRepType = rep_ty, dcWorkId = work_id, dcRep = rep, @@ -1436,19 +1430,27 @@ isNullaryRepDataCon :: DataCon -> Bool isNullaryRepDataCon dc = dataConRepArity dc == 0 dataConRepStrictness :: DataCon -> [StrictnessMark] --- ^ Give the demands on the arguments of a --- Core constructor application (Con dc args) -dataConRepStrictness dc = case dcRep dc of - NoDataConRep -> [NotMarkedStrict | _ <- dataConRepArgTys dc] - DCR { dcr_stricts = strs } -> strs +-- ^ Give the demands on the runtime arguments of a Core DataCon worker +-- application. +-- The length of the list matches `dataConRepArgTys` (e.g., the number +-- of runtime arguments). +dataConRepStrictness dc + = dataConRepStrictness_maybe dc + `orElse` map (const NotMarkedStrict) (dataConRepArgTys dc) + +dataConRepStrictness_maybe :: DataCon -> Maybe [StrictnessMark] +-- ^ Give the demands on the runtime arguments of a Core DataCon worker +-- application or `Nothing` if all of them are lazy. +-- The length of the list matches `dataConRepArgTys` (e.g., the number +-- of runtime arguments). +dataConRepStrictness_maybe dc + | null (dcStricts dc) = Nothing + | otherwise = Just (dcStricts dc) dataConImplBangs :: DataCon -> [HsImplBang] -- The implementation decisions about the strictness/unpack of each -- source program argument to the data constructor -dataConImplBangs dc - = case dcRep dc of - NoDataConRep -> replicate (dcSourceArity dc) HsLazy - DCR { dcr_bangs = bangs } -> bangs +dataConImplBangs dc = dcImplBangs dc dataConBoxer :: DataCon -> Maybe DataConBoxer dataConBoxer (MkData { dcRep = DCR { dcr_boxer = boxer } }) = Just boxer ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1463,7 +1463,7 @@ myExprIsCheap (AE { am_opts = opts, am_sigs = sigs }) e mb_ty -- See Note [Eta expanding through dictionaries] -- See Note [Eta expanding through CallStacks] - cheap_fun e = exprIsCheapX (myIsCheapApp sigs) e + cheap_fun e = exprIsCheapX (myIsCheapApp sigs) False e -- | A version of 'isCheapApp' that considers results from arity analysis. -- See Note [Arity analysis] for what's in the signature environment and why ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -47,7 +47,7 @@ import GHC.Core import GHC.Core.Make import GHC.Core.SimpleOpt ( exprIsConApp_maybe, exprIsLiteral_maybe ) import GHC.Core.DataCon ( DataCon,dataConTagZ, dataConTyCon, dataConWrapId, dataConWorkId ) -import GHC.Core.Utils ( cheapEqExpr, exprIsHNF +import GHC.Core.Utils ( cheapEqExpr, exprOkForSpeculation , stripTicksTop, stripTicksTopT, mkTicks ) import GHC.Core.Multiplicity import GHC.Core.Rules.Config @@ -2101,7 +2101,7 @@ Things to note Implementing seq#. The compiler has magic for SeqOp in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) - GHC.StgToCmm.Expr.cgExpr, and cgCase: special case for seq# @@ -2113,7 +2113,7 @@ Implementing seq#. The compiler has magic for SeqOp in seqRule :: RuleM CoreExpr seqRule = do [Type _ty_a, Type _ty_s, a, s] <- getArgs - guard $ exprIsHNF a + guard $ exprOkForSpeculation a return $ mkCoreUnboxedTuple [s, a] -- spark# :: forall a s . a -> State# s -> (# State# s, a #) ===================================== compiler/GHC/Core/Opt/CprAnal.hs ===================================== @@ -296,9 +296,16 @@ data TermFlag -- Better than using a Bool -- See Note [Nested CPR] exprTerminates :: CoreExpr -> TermFlag +-- ^ A /very/ simple termination analysis. exprTerminates e - | exprIsHNF e = Terminates -- A /very/ simple termination analysis. - | otherwise = MightDiverge + | exprIsHNF e = Terminates + | exprOkForSpeculation e = Terminates + | otherwise = MightDiverge + -- Annyingly, we have to check both for HNF and ok-for-spec. + -- * `I# (x# *# 2#)` is ok-for-spec, but not in HNF. Still worth CPR'ing! + -- * `lvl` is an HNF if its unfolding is evaluated + -- (perhaps `lvl = I# 0#` at top-level). But, tiresomely, it is never + -- ok-for-spec due to Note [exprOkForSpeculation and evaluated variables]. cprAnalApp :: AnalEnv -> CoreExpr -> [(CprType, CoreArg)] -> (CprType, CoreExpr) -- Main function that takes care of /nested/ CPR. See Note [Nested CPR] ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -824,6 +824,10 @@ to the Divergence lattice, but in practice it turned out to be hard to untaint from 'topDiv' to 'conDiv', leading to bugs, performance regressions and complexity that didn't justify the single fixed testcase T13380c. +You might think that we should check for side-effects rather than just for +precise exceptions. Right you are! See Note [Side-effects and strictness] +for why we unfortunately do not. + Note [Demand analysis for recursive data constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ T11545 features a single-product, recursive data type ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -8,14 +8,13 @@ module GHC.Core.Opt.Simplify.Env ( -- * The simplifier mode - SimplMode(..), updMode, - smPedanticBottoms, smPlatform, + SimplMode(..), updMode, smPlatform, -- * Environments SimplEnv(..), pprSimplEnv, -- Temp not abstract seArityOpts, seCaseCase, seCaseFolding, seCaseMerge, seCastSwizzle, seDoEtaReduction, seEtaExpand, seFloatEnable, seInline, seNames, - seOptCoercionOpts, sePedanticBottoms, sePhase, sePlatform, sePreInline, + seOptCoercionOpts, sePhase, sePlatform, sePreInline, seRuleOpts, seRules, seUnfoldingOpts, mkSimplEnv, extendIdSubst, extendTvSubst, extendCvSubst, @@ -219,9 +218,6 @@ seNames env = sm_names (seMode env) seOptCoercionOpts :: SimplEnv -> OptCoercionOpts seOptCoercionOpts env = sm_co_opt_opts (seMode env) -sePedanticBottoms :: SimplEnv -> Bool -sePedanticBottoms env = smPedanticBottoms (seMode env) - sePhase :: SimplEnv -> CompilerPhase sePhase env = sm_phase (seMode env) @@ -276,9 +272,6 @@ instance Outputable SimplMode where where pp_flag f s = ppUnless f (text "no") <+> s -smPedanticBottoms :: SimplMode -> Bool -smPedanticBottoms opts = ao_ped_bot (sm_arity_opts opts) - smPlatform :: SimplMode -> Platform smPlatform opts = roPlatform (sm_rule_opts opts) ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -33,7 +33,7 @@ import GHC.Core.Reduction import GHC.Core.Coercion.Opt ( optCoercion ) import GHC.Core.FamInstEnv ( FamInstEnv, topNormaliseType_maybe ) import GHC.Core.DataCon - ( DataCon, dataConWorkId, dataConRepStrictness + ( DataCon, dataConWorkId, dataConRepStrictness, dataConRepStrictness_maybe , dataConRepArgTys, isUnboxedTupleDataCon , StrictnessMark (..) ) import GHC.Core.Opt.Stats ( Tick(..) ) @@ -2102,14 +2102,14 @@ zap the SubstEnv. This is VITAL. Consider We'll clone the inner \x, adding x->x' in the id_subst Then when we inline y, we must *not* replace x by x' in the inlined copy!! -Note [Fast path for data constructors] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Fast path for lazy data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For applications of a data constructor worker, the full glory of rebuildCall is a waste of effort; * They never inline, obviously * They have no rewrite rules -* They are not strict (see Note [Data-con worker strictness] - in GHC.Core.DataCon) +* Though they might be strict (see Note [Strict fields in Core] in GHC.Core), + we will exploit that strictness through their demand signature So it's fine to zoom straight to `rebuild` which just rebuilds the call in a very straightforward way. @@ -2133,7 +2133,8 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont - | isDataConWorkId var -- See Note [Fast path for data constructors] + | Just dc <- isDataConWorkId_maybe var -- See Note [Fast path for lazy data constructors] + , Nothing <- dataConRepStrictness_maybe dc = rebuild env (Var var) cont | otherwise = case substId env var of @@ -3318,7 +3319,7 @@ a case pattern. This is *important*. Consider We really must record that b is already evaluated so that we don't go and re-evaluate it when constructing the result. -See Note [Data-con worker strictness] in GHC.Core.DataCon +See Note [Strict fields in Core] in GHC.Core. NB: simplLamBndrs preserves this eval info ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1263,11 +1263,8 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr -- simplifier produces rhs[exp/a], changing semantics if exp is not ok-for-spec -- Good: returning (Mk#, [x]) with a float of case exp of x { DEFAULT -> [] } -- simplifier produces case exp of a { DEFAULT -> exp[x/a] } - = let arg' = subst_expr subst arg - bndr = uniqAway (subst_in_scope subst) (mkWildValBinder ManyTy arg_type) - float = FloatCase arg' bndr DEFAULT [] - subst' = subst_extend_in_scope subst bndr - in go subst' (float:floats) fun (CC (Var bndr : args) co) + , (subst', float, bndr) <- case_bind subst arg arg_type + = go subst' (float:floats) fun (CC (Var bndr : args) co) | otherwise = go subst floats fun (CC (subst_expr subst arg : args) co) @@ -1306,8 +1303,9 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr | Just con <- isDataConWorkId_maybe fun , count isValArg args == idArity fun - = succeedWith in_scope floats $ - pushCoDataCon con args co + , (in_scope', seq_floats, args') <- mkFieldSeqFloats in_scope con args + = succeedWith in_scope' (seq_floats ++ floats) $ + pushCoDataCon con args' co -- Look through data constructor wrappers: they inline late (See Note -- [Activation for data constructor wrappers]) but we want to do @@ -1393,6 +1391,36 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr extend (Left in_scope) v e = Right (extendSubst (mkEmptySubst in_scope) v e) extend (Right s) v e = Right (extendSubst s v e) + case_bind :: Either InScopeSet Subst -> CoreExpr -> Type -> (Either InScopeSet Subst, FloatBind, Id) + case_bind subst expr expr_ty = (subst', float, bndr) + where + bndr = setCaseBndrEvald MarkedStrict $ + uniqAway (subst_in_scope subst) $ + mkWildValBinder ManyTy expr_ty + subst' = subst_extend_in_scope subst bndr + expr' = subst_expr subst expr + float = FloatCase expr' bndr DEFAULT [] + + mkFieldSeqFloats :: InScopeSet -> DataCon -> [CoreExpr] -> (InScopeSet, [FloatBind], [CoreExpr]) + mkFieldSeqFloats in_scope dc args + | Nothing <- dataConRepStrictness_maybe dc + = (in_scope, [], args) + | otherwise + = (in_scope', floats', ty_args ++ val_args') + where + (ty_args, val_args) = splitAtList (dataConUnivAndExTyCoVars dc) args + (in_scope', floats', val_args') = foldr do_one (in_scope, [], []) $ zipEqual "mkFieldSeqFloats" str_marks val_args + str_marks = dataConRepStrictness dc + do_one (str, arg) (in_scope,floats,args) + | NotMarkedStrict <- str = (in_scope, floats, arg:args) + | Var v <- arg, is_evald v = (in_scope, floats, arg:args) + | otherwise = (in_scope', float:floats, Var bndr:args) + where + is_evald v = isId v && isEvaldUnfolding (idUnfolding v) + (in_scope', float, bndr) = + case case_bind (Left in_scope) arg (exprType arg) of + (Left in_scope', float, bndr) -> (in_scope', float, bndr) + (right, _, _) -> pprPanic "case_bind did not preserve Left" (ppr in_scope $$ ppr arg $$ ppr right) -- See Note [exprIsConApp_maybe on literal strings] dealWithStringLiteral :: Var -> BS.ByteString -> Coercion ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -55,7 +55,7 @@ module GHC.Core.Type ( splitForAllForAllTyBinders, splitForAllForAllTyBinder_maybe, splitForAllTyCoVar_maybe, splitForAllTyCoVar, splitForAllTyVar_maybe, splitForAllCoVar_maybe, - splitPiTy_maybe, splitPiTy, splitPiTys, + splitPiTy_maybe, splitPiTy, splitPiTys, collectPiTyBinders, getRuntimeArgTys, mkTyConBindersPreferAnon, mkPiTy, mkPiTys, @@ -292,6 +292,7 @@ import GHC.Data.FastString import Control.Monad ( guard ) import GHC.Data.Maybe ( orElse, isJust ) +import GHC.List (build) -- $type_classification -- #type_classification# @@ -2004,6 +2005,18 @@ splitPiTys ty = split ty ty [] split orig_ty ty bs | Just ty' <- coreView ty = split orig_ty ty' bs split orig_ty _ bs = (reverse bs, orig_ty) +collectPiTyBinders :: Type -> [PiTyBinder] +collectPiTyBinders ty = build $ \c n -> + let + split (ForAllTy b res) = Named b `c` split res + split (FunTy { ft_af = af, ft_mult = w, ft_arg = arg, ft_res = res }) + = Anon (Scaled w arg) af `c` split res + split ty | Just ty' <- coreView ty = split ty' + split _ = n + in + split ty +{-# INLINE collectPiTyBinders #-} + -- | Extracts a list of run-time arguments from a function type, -- looking through newtypes to the right of arrows. -- ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -1269,18 +1269,23 @@ in this (which it previously was): in \w. v True -} --------------------- -exprIsWorkFree :: CoreExpr -> Bool -- See Note [exprIsWorkFree] -exprIsWorkFree e = exprIsCheapX isWorkFreeApp e - -exprIsCheap :: CoreExpr -> Bool -exprIsCheap e = exprIsCheapX isCheapApp e +------------------------------------- +type CheapAppFun = Id -> Arity -> Bool + -- Is an application of this function to n *value* args + -- always cheap, assuming the arguments are cheap? + -- True mainly of data constructors, partial applications; + -- but with minor variations: + -- isWorkFreeApp + -- isCheapApp + -- isExpandableApp -exprIsCheapX :: CheapAppFun -> CoreExpr -> Bool +exprIsCheapX :: CheapAppFun -> Bool -> CoreExpr -> Bool {-# INLINE exprIsCheapX #-} --- allow specialization of exprIsCheap and exprIsWorkFree +-- allow specialization of exprIsCheap, exprIsWorkFree and exprIsExpandable -- instead of having an unknown call to ok_app -exprIsCheapX ok_app e +-- expandable: Only True for exprIsExpandable, where Case and Let are never +-- expandable. +exprIsCheapX ok_app expandable e = ok e where ok e = go 0 e @@ -1291,7 +1296,7 @@ exprIsCheapX ok_app e go _ (Type {}) = True go _ (Coercion {}) = True go n (Cast e _) = go n e - go n (Case scrut _ _ alts) = ok scrut && + go n (Case scrut _ _ alts) = not expandable && ok scrut && and [ go n rhs | Alt _ _ rhs <- alts ] go n (Tick t e) | tickishCounts t = False | otherwise = go n e @@ -1299,90 +1304,26 @@ exprIsCheapX ok_app e | otherwise = go n e go n (App f e) | isRuntimeArg e = go (n+1) f && ok e | otherwise = go n f - go n (Let (NonRec _ r) e) = go n e && ok r - go n (Let (Rec prs) e) = go n e && all (ok . snd) prs + go n (Let (NonRec _ r) e) = not expandable && go n e && ok r + go n (Let (Rec prs) e) = not expandable && go n e && all (ok . snd) prs -- Case: see Note [Case expressions are work-free] -- App, Let: see Note [Arguments and let-bindings exprIsCheapX] +-------------------- +exprIsWorkFree :: CoreExpr -> Bool +-- See Note [exprIsWorkFree] +exprIsWorkFree e = exprIsCheapX isWorkFreeApp False e -{- Note [exprIsExpandable] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -An expression is "expandable" if we are willing to duplicate it, if doing -so might make a RULE or case-of-constructor fire. Consider - let x = (a,b) - y = build g - in ....(case x of (p,q) -> rhs)....(foldr k z y).... - -We don't inline 'x' or 'y' (see Note [Lone variables] in GHC.Core.Unfold), -but we do want - - * the case-expression to simplify - (via exprIsConApp_maybe, exprIsLiteral_maybe) - - * the foldr/build RULE to fire - (by expanding the unfolding during rule matching) - -So we classify the unfolding of a let-binding as "expandable" (via the -uf_expandable field) if we want to do this kind of on-the-fly -expansion. Specifically: - -* True of constructor applications (K a b) - -* True of applications of a "CONLIKE" Id; see Note [CONLIKE pragma] in GHC.Types.Basic. - (NB: exprIsCheap might not be true of this) - -* False of case-expressions. If we have - let x = case ... in ...(case x of ...)... - we won't simplify. We have to inline x. See #14688. - -* False of let-expressions (same reason); and in any case we - float lets out of an RHS if doing so will reveal an expandable - application (see SimplEnv.doFloatFromRhs). - -* Take care: exprIsExpandable should /not/ be true of primops. I - found this in test T5623a: - let q = /\a. Ptr a (a +# b) - in case q @ Float of Ptr v -> ...q... - - q's inlining should not be expandable, else exprIsConApp_maybe will - say that (q @ Float) expands to (Ptr a (a +# b)), and that will - duplicate the (a +# b) primop, which we should not do lightly. - (It's quite hard to trigger this bug, but T13155 does so for GHC 8.0.) --} +-------------------- +exprIsCheap :: CoreExpr -> Bool +-- See Note [exprIsCheap] +exprIsCheap e = exprIsCheapX isCheapApp False e -------------------------------------- +-------------------- exprIsExpandable :: CoreExpr -> Bool -- See Note [exprIsExpandable] -exprIsExpandable e - = ok e - where - ok e = go 0 e - - -- n is the number of value arguments - go n (Var v) = isExpandableApp v n - go _ (Lit {}) = True - go _ (Type {}) = True - go _ (Coercion {}) = True - go n (Cast e _) = go n e - go n (Tick t e) | tickishCounts t = False - | otherwise = go n e - go n (Lam x e) | isRuntimeVar x = n==0 || go (n-1) e - | otherwise = go n e - go n (App f e) | isRuntimeArg e = go (n+1) f && ok e - | otherwise = go n f - go _ (Case {}) = False - go _ (Let {}) = False - - -------------------------------------- -type CheapAppFun = Id -> Arity -> Bool - -- Is an application of this function to n *value* args - -- always cheap, assuming the arguments are cheap? - -- True mainly of data constructors, partial applications; - -- but with minor variations: - -- isWorkFreeApp - -- isCheapApp +exprIsExpandable e = exprIsCheapX isExpandableApp True e isWorkFreeApp :: CheapAppFun isWorkFreeApp fn n_val_args @@ -1402,7 +1343,7 @@ isCheapApp fn n_val_args | isDeadEndId fn = True -- See Note [isCheapApp: bottoming functions] | otherwise = case idDetails fn of - DataConWorkId {} -> True -- Actually handled by isWorkFreeApp + -- DataConWorkId {} -> _ -- Handled by isWorkFreeApp RecSelId {} -> n_val_args == 1 -- See Note [Record selection] ClassOpId {} -> n_val_args == 1 PrimOpId op _ -> primOpIsCheap op @@ -1417,6 +1358,7 @@ isExpandableApp fn n_val_args | isWorkFreeApp fn n_val_args = True | otherwise = case idDetails fn of + -- DataConWorkId {} -> _ -- Handled by isWorkFreeApp RecSelId {} -> n_val_args == 1 -- See Note [Record selection] ClassOpId {} -> n_val_args == 1 PrimOpId {} -> False @@ -1448,6 +1390,50 @@ isExpandableApp fn n_val_args I'm not sure why we have a special case for bottoming functions in isCheapApp. Maybe we don't need it. +Note [exprIsExpandable] +~~~~~~~~~~~~~~~~~~~~~~~ +An expression is "expandable" if we are willing to duplicate it, if doing +so might make a RULE or case-of-constructor fire. Consider + let x = (a,b) + y = build g + in ....(case x of (p,q) -> rhs)....(foldr k z y).... + +We don't inline 'x' or 'y' (see Note [Lone variables] in GHC.Core.Unfold), +but we do want + + * the case-expression to simplify + (via exprIsConApp_maybe, exprIsLiteral_maybe) + + * the foldr/build RULE to fire + (by expanding the unfolding during rule matching) + +So we classify the unfolding of a let-binding as "expandable" (via the +uf_expandable field) if we want to do this kind of on-the-fly +expansion. Specifically: + +* True of constructor applications (K a b) + +* True of applications of a "CONLIKE" Id; see Note [CONLIKE pragma] in GHC.Types.Basic. + (NB: exprIsCheap might not be true of this) + +* False of case-expressions. If we have + let x = case ... in ...(case x of ...)... + we won't simplify. We have to inline x. See #14688. + +* False of let-expressions (same reason); and in any case we + float lets out of an RHS if doing so will reveal an expandable + application (see SimplEnv.doFloatFromRhs). + +* Take care: exprIsExpandable should /not/ be true of primops. I + found this in test T5623a: + let q = /\a. Ptr a (a +# b) + in case q @ Float of Ptr v -> ...q... + + q's inlining should not be expandable, else exprIsConApp_maybe will + say that (q @ Float) expands to (Ptr a (a +# b)), and that will + duplicate the (a +# b) primop, which we should not do lightly. + (It's quite hard to trigger this bug, but T13155 does so for GHC 8.0.) + Note [isExpandableApp: bottoming functions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's important that isExpandableApp does not respond True to bottoming @@ -1628,7 +1614,7 @@ expr_ok fun_ok primop_ok other_expr _ -> False ----------------------------- -app_ok :: (Id -> Bool) -> (PrimOp -> Bool) -> Id -> [CoreExpr] -> Bool +app_ok :: (Id -> Bool) -> (PrimOp -> Bool) -> Id -> [CoreArg] -> Bool app_ok fun_ok primop_ok fun args | not (fun_ok fun) = False -- This code path is only taken for Note [Speculative evaluation] @@ -1643,13 +1629,11 @@ app_ok fun_ok primop_ok fun args -- DFuns terminate, unless the dict is implemented -- with a newtype in which case they may not - DataConWorkId {} -> args_ok - -- The strictness of the constructor has already - -- been expressed by its "wrapper", so we don't need - -- to take the arguments into account - -- Well, we thought so. But it's definitely wrong! - -- See #20749 and Note [How untagged pointers can - -- end up in strict fields] in GHC.Stg.InferTags + DataConWorkId dc + | Just str_marks <- dataConRepStrictness_maybe dc + -> fields_ok str_marks + | otherwise + -> args_ok ClassOpId _ is_terminating_result | is_terminating_result -- See Note [exprOkForSpeculation and type classes] @@ -1699,7 +1683,7 @@ app_ok fun_ok primop_ok fun args -- Even if a function call itself is OK, any unlifted -- args are still evaluated eagerly and must be checked - args_ok = and (zipWith arg_ok arg_tys args) + args_ok = all2Prefix arg_ok arg_tys args arg_ok :: PiTyVarBinder -> CoreExpr -> Bool arg_ok (Named _) _ = True -- A type argument arg_ok (Anon ty _) arg -- A term argument @@ -1708,6 +1692,17 @@ app_ok fun_ok primop_ok fun args | otherwise = expr_ok fun_ok primop_ok arg + -- Used for DataCon worker arguments + fields_ok str_marks = all3Prefix field_ok str_marks arg_tys args + field_ok :: StrictnessMark -> PiTyVarBinder -> CoreExpr -> Bool + field_ok _ (Named _) _ = True + field_ok str (Anon ty _) arg + | NotMarkedStrict <- str -- iff it's a lazy field + , definitelyLiftedType (scaledThing ty) -- and its type is lifted + = True -- then the worker app does not eval + | otherwise + = expr_ok fun_ok primop_ok arg + ----------------------------- altsAreExhaustive :: [Alt b] -> Bool -- True <=> the case alternatives are definitely exhaustive @@ -1933,12 +1928,14 @@ exprIsConLike = exprIsHNFlike isConLikeId isConLikeUnfolding -- or PAPs. -- exprIsHNFlike :: HasDebugCallStack => (Var -> Bool) -> (Unfolding -> Bool) -> CoreExpr -> Bool -exprIsHNFlike is_con is_con_unf = is_hnf_like +exprIsHNFlike is_con is_con_unf e + = -- pprTraceWith "hnf" (\r -> ppr r <+> ppr e) $ + is_hnf_like e where is_hnf_like (Var v) -- NB: There are no value args at this point - = id_app_is_value v 0 -- Catches nullary constructors, - -- so that [] and () are values, for example - -- and (e.g.) primops that don't have unfoldings + = id_app_is_value v [] -- Catches nullary constructors, + -- so that [] and () are values, for example + -- and (e.g.) primops that don't have unfoldings || is_con_unf (idUnfolding v) -- Check the thing's unfolding; it might be bound to a value -- or to a guaranteed-evaluated variable (isEvaldUnfolding) @@ -1962,7 +1959,7 @@ exprIsHNFlike is_con is_con_unf = is_hnf_like -- See Note [exprIsHNF Tick] is_hnf_like (Cast e _) = is_hnf_like e is_hnf_like (App e a) - | isValArg a = app_is_value e 1 + | isValArg a = app_is_value e [a] | otherwise = is_hnf_like e is_hnf_like (Let _ e) = is_hnf_like e -- Lazy let(rec)s don't affect us is_hnf_like (Case e b _ as) @@ -1970,26 +1967,53 @@ exprIsHNFlike is_con is_con_unf = is_hnf_like = is_hnf_like rhs is_hnf_like _ = False - -- 'n' is the number of value args to which the expression is applied - -- And n>0: there is at least one value argument - app_is_value :: CoreExpr -> Int -> Bool - app_is_value (Var f) nva = id_app_is_value f nva - app_is_value (Tick _ f) nva = app_is_value f nva - app_is_value (Cast f _) nva = app_is_value f nva - app_is_value (App f a) nva - | isValArg a = - app_is_value f (nva + 1) && - not (needsCaseBinding (exprType a) a) - -- For example f (x /# y) where f has arity two, and the first - -- argument is unboxed. This is not a value! - -- But f 34# is a value. - -- NB: Check app_is_value first, the arity check is cheaper - | otherwise = app_is_value f nva - app_is_value _ _ = False - - id_app_is_value id n_val_args - = is_con id - || idArity id > n_val_args + -- Collect arguments through Casts and Ticks and call id_app_is_value + app_is_value :: CoreExpr -> [CoreArg] -> Bool + app_is_value (Var f) as = id_app_is_value f as + app_is_value (Tick _ f) as = app_is_value f as + app_is_value (Cast f _) as = app_is_value f as + app_is_value (App f a) as | isValArg a = app_is_value f (a:as) + | otherwise = app_is_value f as + app_is_value _ _ = False + + id_app_is_value id val_args + -- First handle saturated applications of DataCons with strict fields + | Just dc <- isDataConWorkId_maybe id -- DataCon + , Just str_marks <- dataConRepStrictness_maybe dc -- with strict fields + , assert (val_args `leLength` str_marks) True + , val_args `equalLength` str_marks -- in a saturated app + = all3Prefix check_field str_marks (mapMaybe anonPiTyBinderType_maybe (collectPiTyBinders (idType id))) val_args + + -- Now all applications except saturated DataCon apps with strict fields + | idArity id > length val_args + -- PAP: Check unlifted val_args + || is_con id && isNothing (isDataConWorkId_maybe id >>= dataConRepStrictness_maybe) + -- Either a lazy DataCon or a CONLIKE. + -- Hence we only need to check unlifted val_args here. + -- NB: We assume that CONLIKEs are lazy, which is their entire + -- point. + = all2Prefix check_arg (mapMaybe anonPiTyBinderType_maybe (collectPiTyBinders (idType id))) val_args + + | otherwise + = False + where + -- fun_ty = idType id + -- arg_tys = collectPiTyBinders fun_ty + -- val_arg_tys = mapMaybe anonPiTyBinderType_maybe arg_tys + -- val_arg_tys = map exprType val_args, but much less costly. + -- The obvious definition regresses T16577 by 30% so we don't do it. + + check_arg a_ty a = mightBeUnliftedType a_ty ==> is_hnf_like a + -- Check unliftedness; for example f (x /# 12#) where f has arity two, + -- and the first argument is unboxed. This is not a value! + -- But f 34# is a value, so check args for HNFs. + -- NB: We check arity (and CONLIKEness) first because it's cheaper + -- and we reject quickly on saturated apps. + check_field str a_ty a + = isMarkedStrict str || mightBeUnliftedType a_ty ==> is_hnf_like a + a ==> b = not a || b + infixr 1 ==> +{-# INLINE exprIsHNFlike #-} {- Note [exprIsHNF Tick] @@ -2551,7 +2575,7 @@ This means the seqs on x and y both become no-ops and compared to the first vers The downside is that the caller of $wfoo potentially has to evaluate `y` once if we can't prove it isn't already evaluated. But y coming out of a strict field is in WHNF so safe to evaluated. And most of the time it will be properly tagged+evaluated -already at the call site because of the Strict Field Invariant! See Note [Strict Field Invariant] for more in this. +already at the call site because of the Strict Field Invariant! See Note [STG Strict Field Invariant] for more in this. This makes GHC itself around 1% faster despite doing slightly more work! So this is generally quite good. We only apply this when we think there is a benefit in doing so however. There are a number of cases in which ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. Flatten nested lets as much as possible. + See Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,48 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Very often (caveat in Wrinkle (FCP1) below), `v` is actually used and the +allocation of the thunk closure was in vain. +Hence we carry around a bunch of floated bindings with us so that we can leave +behind more values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +Floating to top-level can make an asymptotic difference, because `sat` becomes +an SAT; See Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; See Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's simply like any other ok-for-spec-eval Float (see `mkFloat`) that has + a non-DEFAULT Case alternative to bind the unsafe coercion field of the Refl + constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + +Wrinkles: + (FCP1) + Local floating as above is not necessarily an optimisation if `v` doesn't + up being evaluated. In that case, we allocate a 4 word closure for `v` but + won't need to allocate separate closures for `sat` (2 words) and the `(:)` + conapp (3 words), thus saving at least one word, depending on how much the + set of FVs between `sat` and `(:)` overlap. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,7 +600,7 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float new_float = mkFloat env dmd is_unlifted bndr1 rhs1 @@ -578,15 +621,18 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (top_floats floats) + floats' = floats { top_floats = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { top_floats = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +650,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +667,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,9 +677,11 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float - , cpeEtaExpand arity (Var v)) }) + ; let float@(Float (NonRec v' _) _ _) = + mkFloat env topDmd False v rhs2 + -- v' has demand info and possibly evaldUnfolding + ; return ( snocFloat floats2 float + , cpeEtaExpand arity (Var v')) }) -- Wrap floating ticks ; let (floats4, rhs4) = wrapTicks floats3 rhs3 @@ -640,35 +690,30 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = FloatSome TopLvlFloatable + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs + +data FloatDecision + = FloatNone + | FloatAll + | FloatSome !FloatInfo -- ^ Float all bindings with <= this info + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + FloatSome info -> partitionFloats info floats + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +799,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +850,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +904,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +927,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1170,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1216,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1228,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1307,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1339,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1452,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1475,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1491,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1505,10 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float@(Float (NonRec v' _) _ _) = + mkFloat env dmd is_unlifted v arg3 + -- v' has demand info and possibly evaldUnfolding + ; return (snocFloat floats2 arg_float, varToCoreExpr v') } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1541,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1791,159 +1810,299 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it is a (let-bound) value +(`BoundVal`), or otherwise whether it will be `CaseBound` or `LetBound`. +We want to case-bind iff the binding is either ok-for-spec-eval, unlifted, +strictly used (and perhaps lifted), or a literal string (Wrinkle (FI1) below). + +The `FloatInfo` of a `Float` describes how far it will float. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> ...`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> ...`. + +All lazy (and hence lifted) bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Wrinkles: + (FI1) + String literals are a somewhat weird outlier; they qualify as + 'TopLvlFloatable' and will be floated quite aggressively, but the code + generator expects unboxed values to be case-bound (in contrast to boxed + values). This requires a special case in 'mkFloat'. + See also Wrinkle (FS1) of Note [ANF-ising literal string arguments]. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind`. +It has one `OrdList` per class of `FloatInfo` with the following meaning: + + * Any binding in `top_floats` is at least `TopLvlFloatable`; + any binding in `lzy_floats` is at least `LazyContextFloatable`; + any binding in `str_floats` is at least `StrictContextFloatable`. + + * `str_floats` is nested inside `lzy_floats`, is nested inside `top_floats`. + No binding in a "higher" `FloatInfo` class may scope over bindings in + a "lower" class; for example, no binding in `top_floats` may scope over a + binding in `str_floats`. + +(It is always safe to put the whole telescope in `str_floats`.) +There are several operations for creating and combining `Floats` that maintain +these properties. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the `FloatInfo` of the `Floats` (e.g., the highest class of non-empty +`OrdList`): + + * If we want to float to the top-level (`x = <>; ...`), we may take all + bindings that are `TopLvlFloatable` and leave the rest inside the binding. + This is encoded in a `FloatDecision` of `FloatSome TopLvlFloatable`. + * If we want to float locally (let or app), then the floating decision is + `FloatAll` or `FloatNone`; see Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + | BoundVal -- ^ A value binding (E.g., a 'LetBound' that is an HNF) + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving (Eq, Ord) + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + ppr BoundVal = text "Letv" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { top_floats :: !(OrdList FloatingBind) + , lzy_floats :: !(OrdList FloatingBind) + , str_floats :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings + ppr (Floats top lzy str) = text "Floats" <> braces (vcat (map ppr [top, lzy, str])) mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] +mkFloat env dmd is_unlifted bndr rhs = pprTraceWith "mkFloat" ppr $ + Float (NonRec bndr2 rhs) bound info where + (bound,info) + | is_hnf, is_boxed = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unboxed values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- See Note [BindInfo and FloatInfo], Wrinkle (FI1) + -- for why it's not BoundVal + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_boxed = isBoxedType (idType bndr) is_hnf = exprIsHNF rhs is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + bndr1 = bndr `setIdDemandInfo` dmd -- See Note [Pin demand info on floats] + bndr2 + | is_hnf + -- Otherwise, exprIsHNF must be conservative when bndr occurs as a strict + -- field arg. Result: More allocation in $walexGetByte. + = bndr1 `setIdUnfolding` evaldUnfolding + | otherwise + = bndr1 + emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats nilOL nilOL nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats b1 b2 b3) = isNilOL b1 && isNilOL b2 && isNilOL b3 -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats (Floats top lzy str) = top `appOL` lzy `appOL` str unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats +unitFloat = snocFloat emptyFloats -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Computes the \"worst\" 'FloatInfo' for a 'Floats', e.g., the 'FloatInfo' +-- of the innermost 'OrdList' which is non-empty. +floatsInfo :: Floats -> FloatInfo +floatsInfo floats + | not (isNilOL (str_floats floats)) = StrictContextFloatable + | not (isNilOL (lzy_floats floats)) = LazyContextFloatable + | otherwise = TopLvlFloatable + +-- | Append a 'FloatingBind' `b` to a 'Floats' telescope `bs` that may reference any +-- binding of the 'Floats'. +-- This function picks the appropriate 'OrdList' in `bs` that `b` is appended to, +-- respecting its 'FloatInfo' and scoping. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb@(Float bind bound info) + | CaseBound <- bound + , TopLvlFloatable <- info + , NonRec _ rhs <- bind + , exprIsTickedString rhs + -- Always insert Literal (strings) at the front. + -- They won't scope over any existing binding in `floats`. + = floats { top_floats = fb `consOL` top_floats floats } + | otherwise + = snoc_at floats fb (max (floatsInfo floats) info) + -- max: Respect scoping, hence `floatsInfo`, and respect info of `fb` +snocFloat floats fb at UnsafeEqualityCase{} -- treat it like an ok-for-spec Float + = snoc_at floats fb (max (floatsInfo floats) LazyContextFloatable) +snocFloat floats fb at FloatTick{} + = snoc_at floats fb (floatsInfo floats) -- Ticks are simply snoced + +snoc_at :: Floats -> FloatingBind -> FloatInfo -> Floats +snoc_at floats fb info = case info of + TopLvlFloatable -> floats { top_floats = top_floats floats `snocOL` fb } + LazyContextFloatable -> floats { lzy_floats = lzy_floats floats `snocOL` fb } + StrictContextFloatable -> floats { str_floats = str_floats floats `snocOL` fb } + +-- | Put all floats with 'FloatInfo' less than or equal to the given one in the +-- left partition, the rest in the right. Morally, +-- +-- > partitionFloats info fs = partition (<= info) fs +-- +partitionFloats :: FloatInfo -> Floats -> (Floats, Floats) +partitionFloats info (Floats top lzy str) = case info of + TopLvlFloatable -> (Floats top nilOL nilOL, Floats nilOL lzy str) + LazyContextFloatable -> (Floats top lzy nilOL, Floats nilOL nilOL str) + StrictContextFloatable -> (Floats top lzy str, Floats nilOL nilOL nilOL) + +push_down_floats :: FloatInfo -> Floats -> Floats +push_down_floats info fs@(Floats top lzy str) = case info of + TopLvlFloatable -> fs + LazyContextFloatable -> Floats nilOL (top `appOL` lzy) str + StrictContextFloatable -> Floats nilOL nilOL (getFloats fs) + +-- | Cons a 'FloatingBind' `b` to a 'Floats' telescope `bs` which scopes over +-- `b`. This function appropriately pushes around bindings in the 'OrdList's of +-- `bs` so that `b` is the very first binding in the resulting telescope. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb at FloatTick{} floats = + floats { top_floats = fb `consOL` top_floats floats } +consFloat fb@(Float _ _ info) floats = case info of + TopLvlFloatable -> floats' { top_floats = fb `consOL` top_floats floats' } + LazyContextFloatable -> floats' { lzy_floats = fb `consOL` lzy_floats floats' } + StrictContextFloatable -> floats' { str_floats = fb `consOL` str_floats floats' } + where + floats' = push_down_floats info floats +consFloat fb at UnsafeEqualityCase{} floats = -- like the LazyContextFloatable Float case + floats' { lzy_floats = fb `consOL` lzy_floats floats' } + where + floats' = push_down_floats LazyContextFloatable floats + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + -- After having pushed down floats in inner, we can simply zip with up. + zipFloats outer (push_down_floats (floatsInfo outer) inner) + +-- | Zip up two telescopes which don't scope over each other. +zipFloats :: Floats -> Floats -> Floats +zipFloats floats1 floats2 + = Floats + { top_floats = top_floats floats1 `appOL` top_floats floats2 + , lzy_floats = lzy_floats floats1 `appOL` lzy_floats floats2 + , str_floats = str_floats floats1 `appOL` str_floats floats2 + } -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- For top level only; we don't expect any Strict or LazyContextFloatable 'FloatInfo' +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2110,80 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Do we want to float out `y` out of `x`? +(Similarly for `(\x. e) (let y = e1 in e2)`.) +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec) + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + 2. ... `e2` becomes a value in doing so, in which case we won`t need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value, so we return `FloatNone` + if there are any float is `StrictContextFloatable`, and return `FloatAll` + otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = f (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> f r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and in so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + + + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (floatsInfo floats <= max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2438,33 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (top, ticks1) = foldlOL f (nilOL,nilOL) (top_floats floats) + (lzy, ticks2) = foldlOL f (nilOL,ticks1) (lzy_floats floats) + (str, ticks3) = foldlOL f (nilOL,ticks2) (str_floats floats) + in (Floats top lzy str, ticks3) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f@(Float _ BoundVal _) + -- don't need to wrap the tick around a value; nothing to execute. + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== compiler/GHC/Stg/InferTags.hs ===================================== @@ -64,8 +64,8 @@ With nofib being ~0.3% faster as well. See Note [Tag inference passes] for how we proceed to generate and use this information. -Note [Strict Field Invariant] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [STG Strict Field Invariant] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As part of tag inference we introduce the Strict Field Invariant. Which consists of us saying that: @@ -124,15 +124,33 @@ Note that there are similar constraints around Note [CBV Function Ids]. Note [How untagged pointers can end up in strict fields] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Since the resolution of #20749 where Core passes assume that DataCon workers +evaluate their strict fields, it is pretty simple to see how the Simplifier +might exploit that knowledge to drop evals. Example: + + data MkT a = MkT !a + f :: [Int] -> T [Int] + f xs = xs `seq` MkT xs + +in Core we will have + + f = \xs -> MkT @[Int] xs + +No eval left there. + Consider data Set a = Tip | Bin !a (Set a) (Set a) We make a wrapper for Bin that evaluates its arguments $WBin x a b = case x of xv -> Bin xv a b Here `xv` will always be evaluated and properly tagged, just as the -Strict Field Invariant requires. +Note [STG Strict Field Invariant] requires. + +But alas, the Simplifier can destroy the invariant: see #15696. +Indeed, as Note [Strict fields in Core] explains, Core passes +assume that Data constructor workers evaluate their strict fields, +so the Simplifier will drop seqs freely. -But alas the Simplifier can destroy the invariant: see #15696. We start with thk = f () g x = ...(case thk of xv -> Bin xv Tip Tip)... @@ -153,7 +171,7 @@ Now you can see that the argument of Bin, namely thk, points to the thunk, not to the value as it did before. In short, although it may be rare, the output of optimisation passes -cannot guarantee to obey the Strict Field Invariant. For this reason +cannot guarantee to obey the Note [STG Strict Field Invariant]. For this reason we run tag inference. See Note [Tag inference passes]. Note [Tag inference passes] @@ -163,7 +181,7 @@ Tag inference proceeds in two passes: The result is then attached to /binders/. This is implemented by `inferTagsAnal` in GHC.Stg.InferTags * The second pass walks over the AST checking if the Strict Field Invariant is upheld. - See Note [Strict Field Invariant]. + See Note [STG Strict Field Invariant]. If required this pass modifies the program to uphold this invariant. Tag information is also moved from /binders/ to /occurrences/ during this pass. This is done by `GHC.Stg.InferTags.Rewrite (rewriteTopBinds)`. ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -65,7 +65,7 @@ The work of this pass is simple: * For any strict field we check if the argument is known to be properly tagged. * If it's not known to be properly tagged, we wrap the whole thing in a case, which will force the argument before allocation. -This is described in detail in Note [Strict Field Invariant]. +This is described in detail in Note [STG Strict Field Invariant]. The only slight complication is that we have to make sure not to invalidate free variable analysis in the process. @@ -218,7 +218,7 @@ When compiling bytecode we call myCoreToStg to get STG code first. myCoreToStg in turn calls out to stg2stg which runs the STG to STG passes followed by free variables analysis and the tag inference pass including it's rewriting phase at the end. -Running tag inference is important as it upholds Note [Strict Field Invariant]. +Running tag inference is important as it upholds Note [STG Strict Field Invariant]. While code executed by GHCi doesn't take advantage of the SFI it can call into compiled code which does. So it must still make sure that the SFI is upheld. See also #21083 and #22042. ===================================== compiler/GHC/Tc/TyCl/Build.hs ===================================== @@ -183,14 +183,15 @@ buildDataCon fam_envs dc_bang_opts src_name declared_infix prom_info src_bangs tag = lookupNameEnv_NF tag_map src_name -- See Note [Constructor tag allocation], fixes #14657 data_con = mkDataCon src_name declared_infix prom_info - src_bangs field_lbls + src_bangs impl_bangs str_marks field_lbls univ_tvs ex_tvs noConcreteTyVars user_tvbs eq_spec ctxt arg_tys res_ty NoPromInfo rep_tycon tag stupid_ctxt dc_wrk dc_rep dc_wrk = mkDataConWorkId work_name data_con - dc_rep = initUs_ us (mkDataConRep dc_bang_opts fam_envs wrap_name data_con) + (dc_rep, impl_bangs, str_marks) = + initUs_ us (mkDataConRep dc_bang_opts fam_envs wrap_name data_con) ; traceIf (text "buildDataCon 2" <+> ppr src_name) ; return data_con } ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -1385,33 +1385,8 @@ arguments. That is the job of dmdTransformDataConSig. More precisely, * it returns the demands on the arguments; in the above example that is [SL, A] -Nasty wrinkle. Consider this code (#22475 has more realistic examples but -assume this is what the demand analyser sees) - - data T = MkT !Int Bool - get :: T -> Bool - get (MkT _ b) = b - - foo = let v::Int = I# 7 - t::T = MkT v True - in get t - -Now `v` is unused by `get`, /but/ we can't give `v` an Absent demand, -else we'll drop the binding and replace it with an error thunk. -Then the code generator (more specifically GHC.Stg.InferTags.Rewrite) -will add an extra eval of MkT's argument to give - foo = let v::Int = error "absent" - t::T = case v of v' -> MkT v' True - in get t - -Boo! Because of this extra eval (added in STG-land), the truth is that `MkT` -may (or may not) evaluate its arguments (as established in #21497). Hence the -use of `bump` in dmdTransformDataConSig, which adds in a `C_01` eval. The -`C_01` says "may or may not evaluate" which is absolutely faithful to what -InferTags.Rewrite does. - -In particular it is very important /not/ to make that a `C_11` eval, -see Note [Data-con worker strictness]. +When the data constructor worker has strict fields, they act as additional +seqs; hence we add an additional `C_11` eval. -} {- ********************************************************************* @@ -1611,6 +1586,29 @@ a bad fit because expression may not throw a precise exception (increasing precision of the analysis), but that's just a favourable guess. +Note [Side-effects and strictness] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Due to historic reasons and the continued effort not to cause performance +regressions downstream, Strictness Analysis is currently prone to discarding +observable side-effects (other than precise exceptions, see +Note [Precise exceptions and strictness analysis]) in some cases. For example, + f :: MVar () -> Int -> IO Int + f mv x = putMVar mv () >> (x `seq` return x) +The call to `putMVar` is an observable side-effect. Yet, Strictness Analysis +currently concludes that `f` is strict in `x` and uses call-by-value. +That means `f mv (error "boom")` will error out with the imprecise exception +rather performing the side-effect. + +This is a conscious violation of the semantics described in the paper +"a semantics for imprecise exceptions"; so it would be great if we could +identify the offending primops and extend the idea in +Note [Which scrutinees may throw precise exceptions] to general side-effects. + +Unfortunately, the existing has-side-effects classification for primops is +too conservative, listing `writeMutVar#` and even `readMutVar#` as +side-effecting. That is due to #3207. A possible way forward is described in +#17900, but no effort has been so far towards a resolution. + Note [Exceptions and strictness] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to smart about catching exceptions, but we aren't anymore. @@ -2327,7 +2325,7 @@ dmdTransformDataConSig str_marks sd = case viewProd arity body_sd of mk_body_ty n dmds = DmdType nopDmdEnv (zipWith (bump n) str_marks dmds) bump n str dmd | isMarkedStrict str = multDmd n (plusDmd str_field_dmd dmd) | otherwise = multDmd n dmd - str_field_dmd = C_01 :* seqSubDmd -- Why not C_11? See Note [Data-con worker strictness] + str_field_dmd = C_11 :* seqSubDmd -- See Note [Strict fields in Core] -- | A special 'DmdTransformer' for dictionary selectors that feeds the demand -- on the result into the indicated dictionary component (if saturated). ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -260,7 +260,7 @@ The invariants around the arguments of call by value function like Ids are then: * Any `WorkerLikeId` * Some `JoinId` bindings. -This works analogous to the Strict Field Invariant. See also Note [Strict Field Invariant]. +This works analogous to the Strict Field Invariant. See also Note [STG Strict Field Invariant]. To make this work what we do is: * During W/W and SpecConstr any worker/specialized binding we introduce ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Core.Coercion import GHC.Core.Reduction import GHC.Core.Make import GHC.Core.FVs ( mkRuleInfo ) -import GHC.Core.Utils ( exprType, mkCast, mkDefaultCase, coreAltsType ) +import GHC.Core.Utils ( exprType, mkCast, coreAltsType ) import GHC.Core.Unfold.Make import GHC.Core.SimpleOpt import GHC.Core.TyCon @@ -594,8 +594,12 @@ mkDataConWorkId wkr_name data_con = mkGlobalId (DataConWorkId data_con) wkr_name wkr_ty alg_wkr_info where - tycon = dataConTyCon data_con -- The representation TyCon - wkr_ty = dataConRepType data_con + tycon = dataConTyCon data_con -- The representation TyCon + wkr_ty = dataConRepType data_con + univ_tvs = dataConUnivTyVars data_con + ex_tcvs = dataConExTyCoVars data_con + arg_tys = dataConRepArgTys data_con -- Should be same as dataConOrigArgTys + str_marks = dataConRepStrictness data_con ----------- Workers for data types -------------- alg_wkr_info = noCafIdInfo @@ -603,12 +607,19 @@ mkDataConWorkId wkr_name data_con `setInlinePragInfo` wkr_inline_prag `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated, -- even if arity = 0 + `setDmdSigInfo` wkr_sig + -- Workers eval their strict fields + -- See Note [Strict fields in Core] `setLFInfo` wkr_lf_info - -- No strictness: see Note [Data-con worker strictness] in GHC.Core.DataCon wkr_inline_prag = defaultInlinePragma { inl_rule = ConLike } wkr_arity = dataConRepArity data_con + wkr_sig = mkClosedDmdSig wkr_dmds topDiv + wkr_dmds = map mk_dmd str_marks + mk_dmd MarkedStrict = evalDmd + mk_dmd NotMarkedStrict = topDmd + -- See Note [LFInfo of DataCon workers and wrappers] wkr_lf_info | wkr_arity == 0 = LFCon data_con @@ -616,9 +627,6 @@ mkDataConWorkId wkr_name data_con -- LFInfo stores post-unarisation arity ----------- Workers for newtypes -------------- - univ_tvs = dataConUnivTyVars data_con - ex_tcvs = dataConExTyCoVars data_con - arg_tys = dataConRepArgTys data_con -- Should be same as dataConOrigArgTys nt_work_info = noCafIdInfo -- The NoCaf-ness is set by noCafIdInfo `setArityInfo` 1 -- Arity 1 `setInlinePragInfo` dataConWrapperInlinePragma @@ -786,10 +794,10 @@ mkDataConRep :: DataConBangOpts -> FamInstEnvs -> Name -> DataCon - -> UniqSM DataConRep + -> UniqSM (DataConRep, [HsImplBang], [StrictnessMark]) mkDataConRep dc_bang_opts fam_envs wrap_name data_con | not wrapper_reqd - = return NoDataConRep + = return (NoDataConRep, arg_ibangs, rep_strs) | otherwise = do { wrap_args <- mapM (newLocal (fsLit "conrep")) wrap_arg_tys @@ -853,11 +861,8 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con ; return (DCR { dcr_wrap_id = wrap_id , dcr_boxer = mk_boxer boxers - , dcr_arg_tys = rep_tys - , dcr_stricts = rep_strs - -- For newtypes, dcr_bangs is always [HsLazy]. - -- See Note [HsImplBangs for newtypes]. - , dcr_bangs = arg_ibangs }) } + , dcr_arg_tys = rep_tys } + , arg_ibangs, rep_strs) } where (univ_tvs, ex_tvs, eq_spec, theta, orig_arg_tys, _orig_res_ty) @@ -907,8 +912,8 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con -- (Most) newtypes have only a worker, with the exception -- of some newtypes written with GADT syntax. -- See dataConUserTyVarsNeedWrapper below. - && (any isBanged (ev_ibangs ++ arg_ibangs))) - -- Some forcing/unboxing (includes eq_spec) + && (any isUnpacked (ev_ibangs ++ arg_ibangs))) + -- Some unboxing (includes eq_spec) || isFamInstTyCon tycon -- Cast result || (dataConUserTyVarsNeedWrapper data_con -- If the data type was written with GADT syntax and @@ -1185,7 +1190,7 @@ dataConArgRep arg_ty HsLazy = ([(arg_ty, NotMarkedStrict)], (unitUnboxer, unitBoxer)) dataConArgRep arg_ty (HsStrict _) - = ([(arg_ty, MarkedStrict)], (seqUnboxer, unitBoxer)) + = ([(arg_ty, MarkedStrict)], (unitUnboxer, unitBoxer)) -- Seqs are inserted in STG dataConArgRep arg_ty (HsUnpack Nothing) = dataConArgUnpack arg_ty @@ -1215,9 +1220,6 @@ wrapCo co rep_ty (unbox_rep, box_rep) -- co :: arg_ty ~ rep_ty ; return (rep_ids, rep_expr `Cast` mkSymCo sco) } ------------------------ -seqUnboxer :: Unboxer -seqUnboxer v = return ([v], mkDefaultCase (Var v) v) - unitUnboxer :: Unboxer unitUnboxer v = return ([v], \e -> e) ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -27,7 +27,7 @@ module GHC.Utils.Misc ( dropWhileEndLE, spanEnd, last2, lastMaybe, onJust, - List.foldl1', foldl2, count, countWhile, all2, + List.foldl1', foldl2, count, countWhile, all2, all2Prefix, all3Prefix, lengthExceeds, lengthIs, lengthIsNot, lengthAtLeast, lengthAtMost, lengthLessThan, @@ -663,6 +663,29 @@ all2 _ [] [] = True all2 p (x:xs) (y:ys) = p x y && all2 p xs ys all2 _ _ _ = False +all2Prefix :: (a -> b -> Bool) -> [a] -> [b] -> Bool +-- ^ `all2Prefix p xs ys` is a fused version of `and $ zipWith2 p xs ys`. +-- So if one list is shorter than the other, `p` is assumed to be `True` for the +-- suffix. +all2Prefix p = foldr (\x go ys' -> case ys' of (y:ys'') -> p x y && go ys''; _ -> True) (\_ -> True) +{-# INLINE all2Prefix #-} +-- all2Prefix p xs ys = go xs ys +-- where go (x:xs) (y:ys) = p x y && go xs ys +-- go _ _ = True +-- {-# INLINABLE all2Prefix #-} + +all3Prefix :: (a -> b -> c -> Bool) -> [a] -> [b] -> [c] -> Bool +-- ^ `all3Prefix p xs ys zs` is a fused version of `and $ zipWith3 p xs ys zs`. +-- So if one list is shorter than the others, `p` is assumed to be `True` for +-- the suffix. +all3Prefix p xs ys zs = foldr (\y go xs' zs' -> case (xs',zs') of (x:xs'',z:zs'') -> p x y z && go xs'' zs''; _ -> False) (\_ _ -> True) ys xs zs +{-# INLINE all3Prefix #-} +-- all3Prefix p xs ys zs = go xs ys zs +-- where +-- go (x:xs) (y:ys) (z:zs) = p x y z && go xs ys zs +-- go _ _ _ = True +-- {-# INLINABLE all3Prefix #-} + -- Count the number of times a predicate is true count :: (a -> Bool) -> [a] -> Int ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -17,6 +17,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op . (BUILTIN) @@ -25,6 +27,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Arrow (BUILTIN) Rule fired: Class op $p1Arrow (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) @@ -38,6 +42,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op first (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op >>= (BUILTIN) @@ -48,6 +54,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @(_, ()) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op . (BUILTIN) @@ -56,6 +64,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op . (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) @@ -70,6 +80,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Arrow (BUILTIN) Rule fired: Class op $p1Arrow (BUILTIN) Rule fired: Class op id (BUILTIN) @@ -83,6 +95,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op ||| (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op $p1Applicative (BUILTIN) @@ -98,6 +112,8 @@ Rule fired: Class op $p1Applicative (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) +Rule fired: mkRule @((), _) (T18013a) +Rule fired: Class op fmap (BUILTIN) Rule fired: Class op $p1Monad (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: Class op . (BUILTIN) @@ -108,22 +124,6 @@ Rule fired: Class op >>= (BUILTIN) Rule fired: Class op pure (BUILTIN) Rule fired: mkRule @((), _) (T18013a) Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @(_, ()) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) -Rule fired: mkRule @((), _) (T18013a) -Rule fired: Class op fmap (BUILTIN) Rule fired: mkRule @(_, ()) (T18013a) Rule fired: Class op fmap (BUILTIN) Rule fired: mkRule @(_, ()) (T18013a) @@ -138,9 +138,9 @@ mapMaybeRule [InlPrag=[2]] :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b) [GblId, Arity=1, - Str=<1!P(L,LC(S,C(1,C(1,P(L,1L)))))>, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Str=<1!P(SL,LC(S,C(1,C(1,P(L,1L)))))>, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (@a) (@b) (f [Occ=Once1!] :: Rule IO a b) -> case f of { Rule @s ww ww1 [Occ=OnceL1!] -> @@ -219,36 +219,41 @@ mapMaybeRule -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18013.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] T18013.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18013.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18013.$trModule3 = GHC.Types.TrNameS T18013.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18013.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] T18013.$trModule2 = "T18013"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18013.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18013.$trModule1 = GHC.Types.TrNameS T18013.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18013.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18013.$trModule = GHC.Types.Module T18013.$trModule3 T18013.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -418,7 +418,10 @@ test('T21391', normal, compile, ['-O -dcore-lint']) test('T22112', [ grep_errmsg('never matches') ], compile, ['-O -dsuppress-uniques -dno-typeable-binds -fexpose-all-unfoldings -ddump-simpl']) test('T21391a', normal, compile, ['-O -dcore-lint']) # We don't want to see a thunk allocation for the insertBy expression after CorePrep. -test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]'), expect_broken(21392) ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) +# Unfortunately, this test is no longer broken after we made workers strict in strict fields, +# so it is no longer a reproducer for T21392. Still, it doesn't hurt if we test that we don't +# regress again. +test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]') ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) test('T21689', [extra_files(['T21689a.hs'])], multimod_compile, ['T21689', '-v0 -O']) test('T21801', normal, compile, ['-O -dcore-lint']) test('T21848', [grep_errmsg(r'SPEC wombat') ], compile, ['-O -ddump-spec']) ===================================== testsuite/tests/simplStg/should_compile/inferTags002.stderr ===================================== @@ -1,88 +1,30 @@ -==================== Output Cmm ==================== -[M.$WMkT_entry() { // [R3, R2] - { info_tbls: [(cym, - label: block_cym_info - rep: StackRep [False] - srt: Nothing), - (cyp, - label: M.$WMkT_info - rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } - srt: Nothing), - (cys, - label: block_cys_info - rep: StackRep [False] - srt: Nothing)] - stack_info: arg_space: 8 - } - {offset - cyp: // global - if ((Sp + -16) < SpLim) (likely: False) goto cyv; else goto cyw; - cyv: // global - R1 = M.$WMkT_closure; - call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; - cyw: // global - I64[Sp - 16] = cym; - R1 = R2; - P64[Sp - 8] = R3; - Sp = Sp - 16; - if (R1 & 7 != 0) goto cym; else goto cyn; - cyn: // global - call (I64[R1])(R1) returns to cym, args: 8, res: 8, upd: 8; - cym: // global - I64[Sp] = cys; - _sy8::P64 = R1; - R1 = P64[Sp + 8]; - P64[Sp + 8] = _sy8::P64; - call stg_ap_0_fast(R1) returns to cys, args: 8, res: 8, upd: 8; - cys: // global - Hp = Hp + 24; - if (Hp > HpLim) (likely: False) goto cyA; else goto cyz; - cyA: // global - HpAlloc = 24; - call stg_gc_unpt_r1(R1) returns to cys, args: 8, res: 8, upd: 8; - cyz: // global - I64[Hp - 16] = M.MkT_con_info; - P64[Hp - 8] = P64[Sp + 8]; - P64[Hp] = R1; - R1 = Hp - 15; - Sp = Sp + 16; - call (P64[Sp])(R1) args: 8, res: 0, upd: 8; - } - }, - section ""data" . M.$WMkT_closure" { - M.$WMkT_closure: - const M.$WMkT_info; - }] - - - ==================== Output Cmm ==================== [M.f_entry() { // [R2] - { info_tbls: [(cyK, - label: block_cyK_info + { info_tbls: [(cAs, + label: block_info rep: StackRep [] srt: Nothing), - (cyN, + (cAv, label: M.f_info rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cyN: // global - if ((Sp + -8) < SpLim) (likely: False) goto cyO; else goto cyP; - cyO: // global + _lbl_: // global + if ((Sp + -8) < SpLim) (likely: False) goto cAw; else goto cAx; + _lbl_: // global R1 = M.f_closure; call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; - cyP: // global - I64[Sp - 8] = cyK; + _lbl_: // global + I64[Sp - 8] = cAs; R1 = R2; Sp = Sp - 8; - if (R1 & 7 != 0) goto cyK; else goto cyL; - cyL: // global - call (I64[R1])(R1) returns to cyK, args: 8, res: 8, upd: 8; - cyK: // global + if (R1 & 7 != 0) goto cAs; else goto cAt; + _lbl_: // global + call (I64[R1])(R1) returns to cAs, args: 8, res: 8, upd: 8; + _lbl_: // global R1 = P64[R1 + 15]; Sp = Sp + 8; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; @@ -97,47 +39,47 @@ ==================== Output Cmm ==================== [M.MkT_entry() { // [R3, R2] - { info_tbls: [(cz1, - label: block_cz1_info + { info_tbls: [(cAJ, + label: block_info rep: StackRep [False] srt: Nothing), - (cz4, + (cAM, label: M.MkT_info rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } srt: Nothing), - (cz7, - label: block_cz7_info + (cAP, + label: block_info rep: StackRep [False] srt: Nothing)] stack_info: arg_space: 8 } {offset - cz4: // global - if ((Sp + -16) < SpLim) (likely: False) goto cza; else goto czb; - cza: // global + _lbl_: // global + if ((Sp + -16) < SpLim) (likely: False) goto cAS; else goto cAT; + _lbl_: // global R1 = M.MkT_closure; call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; - czb: // global - I64[Sp - 16] = cz1; + _lbl_: // global + I64[Sp - 16] = cAJ; R1 = R2; P64[Sp - 8] = R3; Sp = Sp - 16; - if (R1 & 7 != 0) goto cz1; else goto cz2; - cz2: // global - call (I64[R1])(R1) returns to cz1, args: 8, res: 8, upd: 8; - cz1: // global - I64[Sp] = cz7; - _tyf::P64 = R1; + if (R1 & 7 != 0) goto cAJ; else goto cAK; + _lbl_: // global + call (I64[R1])(R1) returns to cAJ, args: 8, res: 8, upd: 8; + _lbl_: // global + I64[Sp] = cAP; + __locVar_::P64 = R1; R1 = P64[Sp + 8]; - P64[Sp + 8] = _tyf::P64; - call stg_ap_0_fast(R1) returns to cz7, args: 8, res: 8, upd: 8; - cz7: // global + P64[Sp + 8] = __locVar_::P64; + call stg_ap_0_fast(R1) returns to cAP, args: 8, res: 8, upd: 8; + _lbl_: // global Hp = Hp + 24; - if (Hp > HpLim) (likely: False) goto czf; else goto cze; - czf: // global + if (Hp > HpLim) (likely: False) goto cAX; else goto cAW; + _lbl_: // global HpAlloc = 24; - call stg_gc_unpt_r1(R1) returns to cz7, args: 8, res: 8, upd: 8; - cze: // global + call stg_gc_unpt_r1(R1) returns to cAP, args: 8, res: 8, upd: 8; + _lbl_: // global I64[Hp - 16] = M.MkT_con_info; P64[Hp - 8] = P64[Sp + 8]; P64[Hp] = R1; @@ -155,14 +97,14 @@ ==================== Output Cmm ==================== [M.MkT_con_entry() { // [] - { info_tbls: [(czl, + { info_tbls: [(cB3, label: M.MkT_con_info rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - czl: // global + _lbl_: // global R1 = R1 + 1; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } ===================================== testsuite/tests/stranal/sigs/T16859.stderr ===================================== @@ -4,7 +4,7 @@ T16859.bar: <1!A> T16859.baz: <1L><1!P(L)><1C(1,L)> T16859.buz: <1!P(L,L)> T16859.foo: <1L> -T16859.mkInternalName: <1!P(L)><1L><1L> +T16859.mkInternalName: <1!P(L)> T16859.n_loc: <1!P(A,A,A,1L)> T16859.n_occ: <1!P(A,1!P(L,L),A,A)> T16859.n_sort: <1!P(1L,A,A,A)> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69c44754f3136fb0cba4ba01b66c349c6ec470ee...3f334d12b35c33794fd38a91574a1091b2d9e992 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69c44754f3136fb0cba4ba01b66c349c6ec470ee...3f334d12b35c33794fd38a91574a1091b2d9e992 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 15:18:39 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Sun, 01 Oct 2023 11:18:39 -0400 Subject: [Git][ghc/ghc][wip/T20749] CorePrep: Attach evaldUnfolding to floats to detect more values Message-ID: <65198dcf64c45_3676e75e7a9244533228@gitlab.mail> Sebastian Graf pushed to branch wip/T20749 at Glasgow Haskell Compiler / GHC Commits: 2403009c by Sebastian Graf at 2023-10-01T17:18:24+02:00 CorePrep: Attach evaldUnfolding to floats to detect more values - - - - - 1 changed file: - compiler/GHC/CoreToStg/Prep.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -677,9 +677,11 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 + ; let float@(Float (NonRec v' _) _ _) = + mkFloat env topDmd False v rhs2 + -- v' has demand info and possibly evaldUnfolding ; return ( snocFloat floats2 float - , cpeEtaExpand arity (Var v)) }) + , cpeEtaExpand arity (Var v')) }) -- Wrap floating ticks ; let (floats4, rhs4) = wrapTicks floats3 rhs3 @@ -1503,8 +1505,10 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (snocFloat floats2 arg_float, varToCoreExpr v) } + arg_float@(Float (NonRec v' _) _ _) = + mkFloat env dmd is_unlifted v arg3 + -- v' has demand info and possibly evaldUnfolding + ; return (snocFloat floats2 arg_float, varToCoreExpr v') } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1937,12 +1941,11 @@ instance Outputable Floats where mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ - Float (NonRec bndr' rhs) bound info + Float (NonRec bndr2 rhs) bound info where - bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] (bound,info) - | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) - -- is_lifted: We currently don't allow unlifted values at the + | is_hnf, is_boxed = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unboxed values at the -- top-level or inside letrecs -- (but SG thinks that in principle, we should) | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) @@ -1961,11 +1964,21 @@ mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ -- And these float freely but can't be speculated, hence LetBound is_lifted = not is_unlifted + is_boxed = isBoxedType (idType bndr) is_hnf = exprIsHNF rhs is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + bndr1 = bndr `setIdDemandInfo` dmd -- See Note [Pin demand info on floats] + bndr2 + | is_hnf + -- Otherwise, exprIsHNF must be conservative when bndr occurs as a strict + -- field arg. Result: More allocation in $walexGetByte. + = bndr1 `setIdUnfolding` evaldUnfolding + | otherwise + = bndr1 + emptyFloats :: Floats emptyFloats = Floats nilOL nilOL nilOL View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2403009c6d12882197ae015a6c72d129236e7606 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2403009c6d12882197ae015a6c72d129236e7606 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 15:30:24 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Sun, 01 Oct 2023 11:30:24 -0400 Subject: [Git][ghc/ghc][wip/T23442] 2 commits: Fix restarts in .ghcid Message-ID: <6519909060996_3676e75edcf9d45362c6@gitlab.mail> Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC Commits: 6f4ed718 by Sebastian Graf at 2023-10-01T17:29:57+02:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 89ed2051 by Sebastian Graf at 2023-10-01T17:29:57+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. - - - - - 3 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. Flatten nested lets as much as possible. + See Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,48 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Very often (caveat in Wrinkle (FCP1) below), `v` is actually used and the +allocation of the thunk closure was in vain. +Hence we carry around a bunch of floated bindings with us so that we can leave +behind more values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +Floating to top-level can make an asymptotic difference, because `sat` becomes +an SAT; See Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; See Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's simply like any other ok-for-spec-eval Float (see `mkFloat`) that has + a non-DEFAULT Case alternative to bind the unsafe coercion field of the Refl + constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + +Wrinkles: + (FCP1) + Local floating as above is not necessarily an optimisation if `v` doesn't + up being evaluated. In that case, we allocate a 4 word closure for `v` but + won't need to allocate separate closures for `sat` (2 words) and the `(:)` + conapp (3 words), thus saving at least one word, depending on how much the + set of FVs between `sat` and `(:)` overlap. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,7 +600,7 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float new_float = mkFloat env dmd is_unlifted bndr1 rhs1 @@ -578,15 +621,18 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (top_floats floats) + floats' = floats { top_floats = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { top_floats = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +650,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +667,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -630,7 +678,7 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +688,30 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = FloatSome TopLvlFloatable + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs + +data FloatDecision + = FloatNone + | FloatAll + | FloatSome !FloatInfo -- ^ Float all bindings with <= this info + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + FloatSome info -> partitionFloats info floats + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +797,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +848,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +902,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +925,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1168,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1214,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1226,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1305,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1337,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1450,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1473,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1489,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1475,7 +1504,7 @@ cpeArg env dmd arg -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1537,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1791,159 +1806,294 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it is a (let-bound) value +(`BoundVal`), or otherwise whether it will be `CaseBound` or `LetBound`. +We want to case-bind iff the binding is either ok-for-spec-eval, unlifted, +strictly used (and perhaps lifted), or a literal string (Wrinkle (FI1) below). + +The `FloatInfo` of a `Float` describes how far it will float. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> ...`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> ...`. + +All lazy (and hence lifted) bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Wrinkles: + (FI1) + String literals are a somewhat weird outlier; they qualify as + 'TopLvlFloatable' and will be floated quite aggressively, but the code + generator expects unboxed values to be case-bound (in contrast to boxed + values). This requires a special case in 'mkFloat'. + See also Wrinkle (FS1) of Note [ANF-ising literal string arguments]. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind`. +It has one `OrdList` per class of `FloatInfo` with the following meaning: + + * Any binding in `top_floats` is at least `TopLvlFloatable`; + any binding in `lzy_floats` is at least `LazyContextFloatable`; + any binding in `str_floats` is at least `StrictContextFloatable`. + + * `str_floats` is nested inside `lzy_floats`, is nested inside `top_floats`. + No binding in a "higher" `FloatInfo` class may scope over bindings in + a "lower" class; for example, no binding in `top_floats` may scope over a + binding in `str_floats`. + +(It is always safe to put the whole telescope in `str_floats`.) +There are several operations for creating and combining `Floats` that maintain +these properties. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the `FloatInfo` of the `Floats` (e.g., the highest class of non-empty +`OrdList`): + + * If we want to float to the top-level (`x = <>; ...`), we may take all + bindings that are `TopLvlFloatable` and leave the rest inside the binding. + This is encoded in a `FloatDecision` of `FloatSome TopLvlFloatable`. + * If we want to float locally (let or app), then the floating decision is + `FloatAll` or `FloatNone`; see Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + | BoundVal -- ^ A value binding (E.g., a 'LetBound' that is an HNF) + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving (Eq, Ord) + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + ppr BoundVal = text "Letv" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { top_floats :: !(OrdList FloatingBind) + , lzy_floats :: !(OrdList FloatingBind) + , str_floats :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings + ppr (Floats top lzy str) = text "Floats" <> braces (vcat (map ppr [top, lzy, str])) mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] +mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ + Float (NonRec bndr' rhs) bound info where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (BoundVal, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- See Note [BindInfo and FloatInfo], Wrinkle (FI1) + -- for why it's not BoundVal + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted is_hnf = exprIsHNF rhs is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats nilOL nilOL nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats b1 b2 b3) = isNilOL b1 && isNilOL b2 && isNilOL b3 -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats (Floats top lzy str) = top `appOL` lzy `appOL` str unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats +unitFloat = snocFloat emptyFloats -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Computes the \"worst\" 'FloatInfo' for a 'Floats', e.g., the 'FloatInfo' +-- of the innermost 'OrdList' which is non-empty. +floatsInfo :: Floats -> FloatInfo +floatsInfo floats + | not (isNilOL (str_floats floats)) = StrictContextFloatable + | not (isNilOL (lzy_floats floats)) = LazyContextFloatable + | otherwise = TopLvlFloatable + +-- | Append a 'FloatingBind' `b` to a 'Floats' telescope `bs` that may reference any +-- binding of the 'Floats'. +-- This function picks the appropriate 'OrdList' in `bs` that `b` is appended to, +-- respecting its 'FloatInfo' and scoping. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb@(Float bind bound info) + | CaseBound <- bound + , TopLvlFloatable <- info + , NonRec _ rhs <- bind + , exprIsTickedString rhs + -- Always insert Literal (strings) at the front. + -- They won't scope over any existing binding in `floats`. + = floats { top_floats = fb `consOL` top_floats floats } + | otherwise + = snoc_at floats fb (max (floatsInfo floats) info) + -- max: Respect scoping, hence `floatsInfo`, and respect info of `fb` +snocFloat floats fb at UnsafeEqualityCase{} -- treat it like an ok-for-spec Float + = snoc_at floats fb (max (floatsInfo floats) LazyContextFloatable) +snocFloat floats fb at FloatTick{} + = snoc_at floats fb (floatsInfo floats) -- Ticks are simply snoced + +snoc_at :: Floats -> FloatingBind -> FloatInfo -> Floats +snoc_at floats fb info = case info of + TopLvlFloatable -> floats { top_floats = top_floats floats `snocOL` fb } + LazyContextFloatable -> floats { lzy_floats = lzy_floats floats `snocOL` fb } + StrictContextFloatable -> floats { str_floats = str_floats floats `snocOL` fb } + +-- | Put all floats with 'FloatInfo' less than or equal to the given one in the +-- left partition, the rest in the right. Morally, +-- +-- > partitionFloats info fs = partition (<= info) fs +-- +partitionFloats :: FloatInfo -> Floats -> (Floats, Floats) +partitionFloats info (Floats top lzy str) = case info of + TopLvlFloatable -> (Floats top nilOL nilOL, Floats nilOL lzy str) + LazyContextFloatable -> (Floats top lzy nilOL, Floats nilOL nilOL str) + StrictContextFloatable -> (Floats top lzy str, Floats nilOL nilOL nilOL) + +push_down_floats :: FloatInfo -> Floats -> Floats +push_down_floats info fs@(Floats top lzy str) = case info of + TopLvlFloatable -> fs + LazyContextFloatable -> Floats nilOL (top `appOL` lzy) str + StrictContextFloatable -> Floats nilOL nilOL (getFloats fs) + +-- | Cons a 'FloatingBind' `b` to a 'Floats' telescope `bs` which scopes over +-- `b`. This function appropriately pushes around bindings in the 'OrdList's of +-- `bs` so that `b` is the very first binding in the resulting telescope. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb at FloatTick{} floats = + floats { top_floats = fb `consOL` top_floats floats } +consFloat fb@(Float _ _ info) floats = case info of + TopLvlFloatable -> floats' { top_floats = fb `consOL` top_floats floats' } + LazyContextFloatable -> floats' { lzy_floats = fb `consOL` lzy_floats floats' } + StrictContextFloatable -> floats' { str_floats = fb `consOL` str_floats floats' } + where + floats' = push_down_floats info floats +consFloat fb at UnsafeEqualityCase{} floats = -- like the LazyContextFloatable Float case + floats' { lzy_floats = fb `consOL` lzy_floats floats' } + where + floats' = push_down_floats LazyContextFloatable floats + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + -- After having pushed down floats in inner, we can simply zip with up. + zipFloats outer (push_down_floats (floatsInfo outer) inner) + +-- | Zip up two telescopes which don't scope over each other. +zipFloats :: Floats -> Floats -> Floats +zipFloats floats1 floats2 + = Floats + { top_floats = top_floats floats1 `appOL` top_floats floats2 + , lzy_floats = lzy_floats floats1 `appOL` lzy_floats floats2 + , str_floats = str_floats floats1 `appOL` str_floats floats2 + } -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- For top level only; we don't expect any Strict or LazyContextFloatable 'FloatInfo' +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2101,80 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Do we want to float out `y` out of `x`? +(Similarly for `(\x. e) (let y = e1 in e2)`.) +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec) + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + 2. ... `e2` becomes a value in doing so, in which case we won`t need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value, so we return `FloatNone` + if there are any float is `StrictContextFloatable`, and return `FloatAll` + otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = f (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> f r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and in so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + + + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (floatsInfo floats <= max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2429,33 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (top, ticks1) = foldlOL f (nilOL,nilOL) (top_floats floats) + (lzy, ticks2) = foldlOL f (nilOL,ticks1) (lzy_floats floats) + (str, ticks3) = foldlOL f (nilOL,ticks2) (str_floats floats) + in (Floats top lzy str, ticks3) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f@(Float _ BoundVal _) + -- don't need to wrap the tick around a value; nothing to execute. + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9cd0892a61d7daf1a5feeede442e54ccfb516688...89ed20510a3ff8fdbd03e5915acc5ca303740acc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9cd0892a61d7daf1a5feeede442e54ccfb516688...89ed20510a3ff8fdbd03e5915acc5ca303740acc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 17:42:47 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 01 Oct 2023 13:42:47 -0400 Subject: [Git][ghc/ghc][wip/int-index/t2t-expr] 12 commits: Fix several mistakes around free variables in iface breakpoints Message-ID: <6519af97a4f26_3676e76212b3285492b1@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/t2t-expr at Glasgow Haskell Compiler / GHC Commits: d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - f7f6bf11 by Vladislav Zavialov at 2023-10-01T17:42:41+00:00 WIP: T2T in Expressions - - - - - dae92690 by Vladislav Zavialov at 2023-10-01T17:42:41+00:00 WIP: T2T corner cases - - - - - 1d3d14fa by Vladislav Zavialov at 2023-10-01T17:42:41+00:00 WIP: T2T reject punned variables - - - - - bed62c35 by Vladislav Zavialov at 2023-10-01T17:42:41+00:00 attempt a fix - - - - - 19ab6ef5 by Vladislav Zavialov at 2023-10-01T17:42:41+00:00 update comment - - - - - 6fe2b021 by Vladislav Zavialov at 2023-10-01T17:42:41+00:00 Test suite wibbles - - - - - 30 changed files: - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Pmc/Utils.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8af6f95c2478b29c1cd8df0ed8290d8a97d39a4...6fe2b0217738642b7166a5800dc06eb006ee22bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8af6f95c2478b29c1cd8df0ed8290d8a97d39a4...6fe2b0217738642b7166a5800dc06eb006ee22bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 18:21:06 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 01 Oct 2023 14:21:06 -0400 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 87 commits: Use Cabal 3.10 for Hadrian Message-ID: <6519b892ba6d3_3676e7630c2d2c555668@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC Commits: fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - 63c84042 by Alan Zimmerman at 2023-10-01T12:32:14+01:00 EPA: Instroduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - b3627f06 by Alan Zimmerman at 2023-10-01T13:15:13+01:00 EPA: Fix span for GRHS Tests all pass [2023-08-13 Sun] - - - - - 254491f2 by Alan Zimmerman at 2023-10-01T13:15:13+01:00 EPA: Move TrailingAnns from last match to FunBind All tests pass [2023-08-13 Sun] - - - - - 3c27f4e7 by Alan Zimmerman at 2023-10-01T13:15:14+01:00 EPA: Fix GADT where clause span Include the final '}' if there is one. Note: Makes no difference to a test, need to add one. - - - - - 3699cc23 by Alan Zimmerman at 2023-10-01T13:15:14+01:00 EPA: Capture full range for a CaseAlt Match All tests pass [2023-08-30 Wed] And check-exact no warnings - - - - - 0cad2bcd by Alan Zimmerman at 2023-10-01T13:15:14+01:00 EPA Use full range for Anchor, and do not widen for [TrailingAnn] Known failures at the end of this Ppr023 Ppr034 TestBoolFormula Fixed in subsequent commits - - - - - 741f9620 by Alan Zimmerman at 2023-10-01T13:15:14+01:00 EPA: Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. [2023-08-14 Mon] 121 unexpected failures - - - - - 7222562c by Alan Zimmerman at 2023-10-01T13:15:14+01:00 EPA: Add DArrow to TrailingAnn - - - - - 964b0c02 by Alan Zimmerman at 2023-10-01T13:15:14+01:00 [EPA] Introduce HasTrailing in ExactPrint 29 Failing tests by 4600 processed info: patch template saved to `-` - - - - - c38c20ed by Alan Zimmerman at 2023-10-01T13:15:15+01:00 EPA use [TrailingAnn] in enterAnn And remove it from ExactPrint (LocatedN RdrName) - - - - - 649f2870 by Alan Zimmerman at 2023-10-01T13:15:15+01:00 Summary: Patch: epa-in-hsdo-put-trailinganns Author: Alan Zimmerman <alan.zimm at gmail.com> Date: 2023-07-03 22:33:49 +0100 EPA: In HsDo, put TrailingAnns at top of LastStmt Failures 5300 of 9700 [0, 103, 0] - - - - - b1306571 by Alan Zimmerman at 2023-10-01T13:15:15+01:00 EPA: do not convert comments to deltas when balancing. It seems its not needed with the new approach [2023-08-15 Tue] 104 unexpected failures - - - - - b838da69 by Alan Zimmerman at 2023-10-01T13:15:15+01:00 EPA: deal with fallout from getMonoBind - - - - - 8fe170ab by Alan Zimmerman at 2023-10-01T13:15:15+01:00 EPA fix captureLineSpacing - - - - - 19ef08e8 by Alan Zimmerman at 2023-10-01T13:15:15+01:00 EPA print any comments in the span before exiting it - - - - - 45b7bda4 by Alan Zimmerman at 2023-10-01T13:15:15+01:00 EPA: getting rid of tweakDelta WIP at present - - - - - 57349a46 by Alan Zimmerman at 2023-10-01T13:15:16+01:00 EPA: tweaks to ExactPrint - - - - - 68452736 by Alan Zimmerman at 2023-10-01T13:15:16+01:00 EPA: Fix warnings in check-exact - - - - - 64aabffc by Alan Zimmerman at 2023-10-01T14:02:53+01:00 EPA: Add comments to AnchorOperation 6000 of 9700 [0, 14, 0] Failures seem to be mainly in transform tests - - - - - bbac2ad2 by Alan Zimmerman at 2023-10-01T14:02:54+01:00 EPA: remove AnnEofComment It is no longer used At this point just failures HsDocTy [2023-08-31 Thu] And no warnings in check-exact - - - - - 6895a387 by Alan Zimmerman at 2023-10-01T14:02:54+01:00 EPA: make locA a function, not a field name - - - - - 8993e2ca by Alan Zimmerman at 2023-10-01T14:45:02+01:00 EPA: generalise reLoc [2023-10-01 Sun] Failures HsDocTy - - - - - b5938052 by Alan Zimmerman at 2023-10-01T14:47:35+01:00 EPA: get rid of l2l and friends - - - - - 806125e9 by Alan Zimmerman at 2023-10-01T14:47:35+01:00 EPA: get rid of l2l and friends - - - - - d128d91a by Alan Zimmerman at 2023-10-01T15:32:40+01:00 EPA: harmonise acsa and acsA [2023-10-01 Sun] Failing tests HsDocTy - - - - - 2542d46d by Alan Zimmerman at 2023-10-01T17:40:52+01:00 EPA: Replace Anchor with EpaLocation [2023-09-21 Thu] Only test failing is HsDocTy - - - - - 92227d86 by Alan Zimmerman at 2023-10-01T17:40:52+01:00 EPA: get rid of AnchorOperation [2023-09-21 Thu] Only error is HsDocTy - - - - - 363cc668 by Alan Zimmerman at 2023-10-01T17:40:52+01:00 EPA: splitLHsForAllTyInvis no ann returned - - - - - d4343b92 by Alan Zimmerman at 2023-10-01T17:40:53+01:00 EPA: Replace Monoid with NoAnn [2023-08-19 Sat] AddClassMethod fails - - - - - d182fe08 by Alan Zimmerman at 2023-10-01T17:40:53+01:00 EPA: Use SrcSpan in EpaSpan [2023-09-04 Mon] No errors or warnings in check-exact [2023-09-21 Thu] Test failures HsDocTy - - - - - 1323b36a by Alan Zimmerman at 2023-10-01T17:40:53+01:00 EPA: Present no longer has annotation - - - - - f183c5eb by Alan Zimmerman at 2023-10-01T17:40:53+01:00 EPA: empty tup_tail has no ann Parser.y: tup_tail rule was | {- empty -} %shift { return [Left noAnn] } This means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - 5199856e by Alan Zimmerman at 2023-10-01T17:40:53+01:00 EPA: Remove parenthesizeHsType - - - - - 1a193fac by Alan Zimmerman at 2023-10-01T18:07:52+01:00 EPA: Remove EpAnnNotUsed [2023-10-01 Sun] Failures HsDocTy T15242 - - - - - 56b212bb by Alan Zimmerman at 2023-10-01T18:33:43+01:00 EPA: Remove SrcSpanAnn - - - - - 78ad4054 by Alan Zimmerman at 2023-10-01T18:33:43+01:00 EPA: Remove SrcSpanAnn completely - - - - - 3a0871c0 by Alan Zimmerman at 2023-10-01T18:33:43+01:00 Clean up mkScope - - - - - 70f046cf by Alan Zimmerman at 2023-10-01T18:33:43+01:00 EPA: Clean up TC Monad Utils - - - - - 2cffd697 by Alan Zimmerman at 2023-10-01T19:20:34+01:00 EPA: EpaDelta for comment has no comments [2023-09-23 Sat] Current failures HsDocTy T15242 - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/07311243b18e385111677876ca686bbe4e96fa0d...2cffd697d8198920a4262b612d4d892dbc4b78ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/07311243b18e385111677876ca686bbe4e96fa0d...2cffd697d8198920a4262b612d4d892dbc4b78ce You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 1 18:51:00 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 01 Oct 2023 14:51:00 -0400 Subject: [Git][ghc/ghc][wip/az/ghc-cpp] 5 commits: Make cppTokens extend to end of line, and process CPP comments Message-ID: <6519bf945186b_3676e763c064405578af@gitlab.mail> Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: d26981dd by Alan Zimmerman at 2023-09-30T18:06:07+01:00 Make cppTokens extend to end of line, and process CPP comments - - - - - 6bdc7e7e by Alan Zimmerman at 2023-10-01T15:57:56+01:00 Remove unused ITcppDefined - - - - - 8a6c7c89 by Alan Zimmerman at 2023-10-01T16:11:31+01:00 Allow spaces between # and keyword for preprocessor directive - - - - - 9cd8aa1b by Alan Zimmerman at 2023-10-01T17:49:19+01:00 Process CPP continuation lines They are emited as separate ITcppContinue tokens. Perhaps the processing should be more like a comment, and keep on going to the end. BUT, the last line needs to be slurped as a whole. - - - - - 89aaf286 by Alan Zimmerman at 2023-10-01T19:50:06+01:00 Accumulate CPP continuations, process when ready Can be simplified further, we only need one CPP token - - - - - 5 changed files: - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PreProcess.hs - utils/check-cpp/Main.hs Changes: ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -19,7 +19,7 @@ import GHC.Prelude import GHC.Cmm.Expr -import GHC.Parser.Lexer hiding (lexToken) +import GHC.Parser.Lexer import GHC.Cmm.Parser.Monad import GHC.Types.SrcLoc import GHC.Types.Unique.FM ===================================== compiler/GHC/Parser.y ===================================== @@ -745,17 +745,16 @@ TH_QUASIQUOTE { L _ (ITquasiQuote _) } TH_QQUASIQUOTE { L _ (ITqQuasiQuote _) } -- Ghc CPP -'#define' { L _ ITcppDefine } -'#include' { L _ ITcppInclude } -'#undef' { L _ ITcppUndef } -'#error' { L _ ITcppError } -'#if' { L _ ITcppIf } -'#ifdef' { L _ ITcppIfdef } -'#ifndef' { L _ ITcppIfndef } -'#elif' { L _ ITcppElif } -'#else' { L _ ITcppElse } -'#endif' { L _ ITcppEndif } -'defined' { L _ ITcppDefined } +-- '#define' { L _ (ITcppDefine _) } +-- '#include' { L _ (ITcppInclude _) } +-- '#undef' { L _ (ITcppUndef _) } +-- '#error' { L _ (ITcppError _) } +-- '#if' { L _ (ITcppIf _) } +-- '#ifdef' { L _ (ITcppIfdef _) } +-- '#ifndef' { L _ (ITcppIfndef _) } +-- '#elif' { L _ (ITcppElif _) } +-- '#else' { L _ ITcppElse } +-- '#endif' { L _ ITcppEndif } %monad { P } { >>= } { return } %lexer { (lexer True) } { L _ ITeof } ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -222,6 +222,9 @@ $docsym = [\| \^ \* \$] -- not explicitly positive (contrast @exponent) @negative = \- +-- recognise any of the GhcCPP keywords introduced by a leading # + at cppkeyword = "define" | "include" | "undef" | "error" | "ifdef" + | "ifndef" | "if" | "elif" | "else" | "endif" -- ----------------------------------------------------------------------------- -- Alex "Identifier" @@ -243,7 +246,8 @@ $tab { warnTab } -- are). We also rule out nested Haddock comments, if the -haddock flag is -- set. -"{-" / { isNormalComment } { nested_comment } +"{-" / { isNormalComment } { nested_comment } +"/*" / { ifExtension GhcCppBit } { nested_comment } -- Single-line comments are a bit tricky. Haskell 98 says that two or -- more dashes followed by a symbol should be parsed as a varsym, so we @@ -298,29 +302,7 @@ $unigraphic / { isSmartQuote } { smart_quote_error } { \n ; -- Ghc CPP symbols - ^"#define" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppDefine) } - ^"#include" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppInclude) } - ^"#undef" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppUndef) } - ^"#error" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppError) } - ^"#if" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppIf) } - ^"#ifdef" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppIfdef) } - ^"#ifndef" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppIfndef) } - ^"#elif" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppElif) } - ^"#else" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppElse) } - ^"#endif" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppEndif) } - -- "defined" { token (ITcppDefined) } - - -- ^\# "define" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppDefine) } - -- ^\# "include" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppInclude) } - -- ^\# "undef" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppUndef) } - -- ^\# "error" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppError) } - -- ^\# "if" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppIf) } - -- ^\# "ifdef" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppIfdef) } - -- ^\# "ifndef" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppIfndef) } - -- ^\# "elif" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppElif) } - -- ^\# "else" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppElse) } - -- ^\# "endif" / { ifExtension GhcCppBit } { cppToken cpp_prag (ITcppEndif) } - -- -- "defined" { token (ITcppDefined) } + ^\# \ * @cppkeyword .* \n / { ifExtension GhcCppBit } { cppToken cpp_prag } ^\# line { begin line_prag1 } ^\# / { followedByDigit } { begin line_prag1 } @@ -337,6 +319,8 @@ $unigraphic / { isSmartQuote } { smart_quote_error } \{ / { notFollowedBy '-' } { hopefully_open_brace } -- we might encounter {-# here, but {- has been handled already \n ; + ^\# \ * @cppkeyword .* \n / { ifExtension GhcCppBit } { cppToken cpp_prag } + ^\# (line)? { begin line_prag1 } } @@ -360,9 +344,11 @@ $unigraphic / { isSmartQuote } { smart_quote_error } "{-#" $whitechar* $pragmachar+ / { known_pragma linePrags } { dispatch_pragmas linePrags } --- CPP pragmas +-- CPP continuation lines. Keep concatenating, or exit { - () { pop } + .* \\ \n { cppTokenCont (ITcppContinue True) } + .* \n { cppTokenPop (ITcppContinue False) } + -- () { popCpp } } -- single-line line pragmas, of the form @@ -1043,20 +1029,10 @@ data Token | ITlineComment String PsSpan -- ^ comment starting by "--" | ITblockComment String PsSpan -- ^ comment in {- -} - -- GHC CPP extension - | ITcppDefine -- ^ #define - | ITcppInclude -- ^ #include - | ITcppUndef -- ^ #undef - | ITcppError -- ^ #error - | ITcppIf -- ^ #if - | ITcppIfdef -- ^ #ifdef - | ITcppIfndef -- ^ #ifndef - | ITcppElif -- ^ #elif - | ITcppElse -- ^ #else - | ITcppEndif -- ^ #endif - | ITcppDefined -- ^ defined (in conditional) - | ITcppIgnored [Located Token] -- TODO: push into comments instead - + -- GHC CPP extension. Each contains an entire line of source code, + -- possibly joining up ones ending in backslash + | ITcppStart Bool FastString -- ^ Start of a CPP #-prefixed line. Flag for continuation + | ITcppContinue Bool FastString -- ^ Continuation after a trailing backslash. Flag for continuation deriving Show @@ -1291,12 +1267,34 @@ pop _span _buf _len _buf2 = lexToken -- trace "pop" $ do lexToken -cppToken :: Int -> Token -> Action -cppToken code t span _buf _len _buf2 = - do pushLexState code - return (L span t) +cppToken :: Int -> Action +cppToken code span buf len _buf2 = + do + let tokStr = lexemeToFastString buf len + -- check if the string ends with backslash and newline + -- NOTE: performance likely sucks, make it work for now + continue <- case (reverse $ unpackFS tokStr) of + -- ('\n':'\\':_) -> pushLexState code >> return True + ('\n':'\\':_) -> pushLexState (trace ("cppToken: push state") code) >> return True + _ -> return False + return (L span (ITcppStart continue $! tokStr)) -- trace ("cppToken:" ++ show (code, t)) $ do return (L span t) +cppTokenCont :: (FastString -> Token)-> Action +cppTokenCont t span buf len _buf2 = return (L span (t $! lexemeToFastString buf len)) + +cppTokenPop :: (FastString -> Token)-> Action +cppTokenPop t span buf len _buf2 = + do _ <- popLexState + -- return (L span (t $! lexemeToFastString buf len)) + return (L span (t $! lexemeToFastString buf (trace "cppTokenPop" len))) + +popCpp :: Action +popCpp _span _buf _len _buf2 = + do _ <- popLexState + -- lexToken + trace "pop" $ do lexToken + -- See Note [Nested comment line pragmas] failLinePrag1 :: Action failLinePrag1 span _buf _len _buf2 = do @@ -1468,6 +1466,9 @@ It holds simply because we immediately lex a literal after the minus. ifExtension :: ExtBits -> AlexAccPred ExtsBitmap ifExtension extBits bits _ _ _ = extBits `xtest` bits +ifNotExtension :: ExtBits -> AlexAccPred ExtsBitmap +ifNotExtension extBits bits _ _ _ = not (extBits `xtest` bits) + alexNotPred p userState in1 len in2 = not (p userState in1 len in2) @@ -1570,23 +1571,36 @@ nested_comment_logic endComment commentAcc input span = go commentAcc (1::Int) i cspan = mkSrcSpanPs $ mkPsSpan (psSpanStart span) end_loc lcomment = L cspan comment endComment input lcomment - go commentAcc n input = case alexGetChar' input of - Nothing -> errBrace input (psRealSpan span) - Just ('-',input) -> case alexGetChar' input of + go commentAcc n input = ghcCppSet >>= \ghcCppSet -> case (ghcCppSet, alexGetChar' input) of + (_, Nothing) -> errBrace input (psRealSpan span) + (_, Just ('-',input)) -> case alexGetChar' input of Nothing -> errBrace input (psRealSpan span) Just ('\125',input) -> go ('\125':'-':commentAcc) (n-1) input -- '}' Just (_,_) -> go ('-':commentAcc) n input - Just ('\123',input) -> case alexGetChar' input of -- '{' char + (_, Just ('\123',input)) -> case alexGetChar' input of -- '{' char Nothing -> errBrace input (psRealSpan span) Just ('-',input) -> go ('-':'\123':commentAcc) (n+1) input Just (_,_) -> go ('\123':commentAcc) n input + (True, Just ('*',input)) -> case alexGetChar' input of + Nothing -> errBrace input (psRealSpan span) + Just ('/',input) -> go ('/':'*':commentAcc) (n-1) input -- '/' + Just (_,_) -> go ('-':commentAcc) n input + (True, Just ('/',input)) -> case alexGetChar' input of -- '/' char + Nothing -> errBrace input (psRealSpan span) + Just ('*',input) -> go ('*':'/':commentAcc) (n+1) input + Just (_,_) -> go ('/':commentAcc) n input -- See Note [Nested comment line pragmas] - Just ('\n',input) -> case alexGetChar' input of + (_, Just ('\n',input)) -> case alexGetChar' input of Nothing -> errBrace input (psRealSpan span) Just ('#',_) -> do (parsedAcc,input) <- parseNestedPragma input go (parsedAcc ++ '\n':commentAcc) n input Just (_,_) -> go ('\n':commentAcc) n input - Just (c,input) -> go (c:commentAcc) n input + (_, Just (c,input)) -> go (c:commentAcc) n input + +ghcCppSet :: P Bool +ghcCppSet = do + exts <- getExts + return $ xtest GhcCppBit exts -- See Note [Nested comment line pragmas] parseNestedPragma :: AlexInput -> P (String,AlexInput) @@ -2745,9 +2759,10 @@ data PState = PState { -- correctly? -- | Use for emulating (limited) CPP preprocessing in GHC. +-- TODO: move this into PreProcess, and make a param on PState data PpState = PpState { pp_defines :: !(Set String), - pp_pushed_back :: !(Maybe (Located Token)), + pp_continuation :: ![Located Token], -- pp_context :: ![PpContext], pp_context :: ![Token], -- What preprocessor directive we are currently processing pp_accepting :: !Bool @@ -2760,7 +2775,7 @@ data PpContext = PpContextIf [Located Token] initPpState :: PpState initPpState = PpState { pp_defines = Set.empty - , pp_pushed_back = Nothing + , pp_continuation = [] , pp_context = [] , pp_accepting = True } @@ -3206,6 +3221,8 @@ mkParserOpts extensionFlags diag_opts supported .|. OverloadedRecordUpdateBit `xoptBit` LangExt.OverloadedRecordUpdate -- Enable testing via 'getBit OverloadedRecordUpdateBit' in the parser (RecordDotSyntax parsing uses that information). .|. ExtendedLiteralsBit `xoptBit` LangExt.ExtendedLiterals .|. GhcCppBit `xoptBit` LangExt.GhcCpp + -- .|. (trace ("GhcCppBit:" ++ show (GhcCppBit `xoptBit` LangExt.GhcCpp)) + -- GhcCppBit `xoptBit` LangExt.GhcCpp) optBits = HaddockBit `setBitIf` isHaddock .|. RawTokenStreamBit `setBitIf` rawTokStream @@ -3426,7 +3443,7 @@ getOffside = P $ \s at PState{last_loc=loc, context=stk} -> let offs = srcSpanStartCol (psRealSpan loc) in let ord = case stk of Layout n gen_semic : _ -> - --trace ("layout: " ++ show n ++ ", offs: " ++ show offs) $ + -- trace ("layout: " ++ show n ++ ", offs: " ++ show offs) $ (compare offs n, gen_semic) _ -> (GT, dontGenerateSemic) @@ -3967,7 +3984,6 @@ commentToAnnotation (L l (ITdocComment s ll)) = mkLEpaComment l ll (EpaDocComm commentToAnnotation (L l (ITdocOptions s ll)) = mkLEpaComment l ll (EpaDocOptions s) commentToAnnotation (L l (ITlineComment s ll)) = mkLEpaComment l ll (EpaLineComment s) commentToAnnotation (L l (ITblockComment s ll)) = mkLEpaComment l ll (EpaBlockComment s) -commentToAnnotation (L l (ITblockComment s ll)) = mkLEpaComment l ll (EpaBlockComment s) commentToAnnotation _ = panic "commentToAnnotation" -- see Note [PsSpan in Comments] ===================================== compiler/GHC/Parser/PreProcess.hs ===================================== @@ -4,15 +4,16 @@ {-# LANGUAGE BangPatterns #-} module GHC.Parser.PreProcess ( - ppLexer, - ppLexerDbg, + -- ppLexer, + -- ppLexerDbg, lexer, lexerDbg, ) where --- import Data.List () +import Data.Char import qualified Data.Set as Set import Debug.Trace (trace) +import GHC.Data.FastString import qualified GHC.Data.Strict as Strict import GHC.Parser.Errors.Ppr () import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), PpState (..), Token (..)) @@ -23,119 +24,122 @@ import GHC.Types.SrcLoc -- --------------------------------------------------------------------- lexer, lexerDbg :: Bool -> (Located Token -> P a) -> P a -lexer = ppLexer -lexerDbg = ppLexerDbg - -ppLexer, ppLexerDbg :: Bool -> (Located Token -> P a) -> P a --- Use this instead of 'lexer' in GHC.Parser to dump the tokens for debugging. -ppLexerDbg queueComments cont = ppLexer queueComments contDbg - where - contDbg tok = trace ("pptoken: " ++ show (unLoc tok)) (cont tok) -ppLexer queueComments cont = - Lexer.lexer - queueComments - ( \tk -> - let - contInner t = (trace ("ppLexer: tk=" ++ show (unLoc tk, unLoc t)) cont) t - -- contPush = pushContext (unLoc tk) >> contInner (L lt (ITcppIgnored [tk])) - contPush = pushContext (unLoc tk) >> contIgnoreTok tk - contIgnoreTok (L l tok) = do - case l of - RealSrcSpan r (Strict.Just b) -> Lexer.queueIgnoredToken (L (PsSpan r b) tok) - _ -> return () - ppLexer queueComments cont - in - case tk of - L _ ITcppDefine -> contPush - L _ ITcppIf -> contPush - L _ ITcppIfdef -> contPush - L _ ITcppIfndef -> contPush - L _ ITcppElse -> do - preprocessElse - contIgnoreTok tk - L _ ITcppEndif -> do - preprocessEnd - contIgnoreTok tk - L _ tok -> do - state <- getCppState - case (trace ("CPP state:" ++ show state) state) of - CppIgnoring -> contIgnoreTok tk - CppInDefine -> do - ppDefine (trace ("ppDefine:" ++ show tok) (show tok)) - popContext - contIgnoreTok tk - CppInIfdef -> do - defined <- ppIsDefined (show tok) - setAccepting defined - popContext - contIgnoreTok tk - CppInIfndef -> do - defined <- ppIsDefined (show tok) - setAccepting (not defined) - popContext - contIgnoreTok tk - _ -> contInner tk - ) - -preprocessElse :: P () -preprocessElse = do - accepting <- getAccepting - setAccepting (not accepting) - -preprocessEnd :: P () -preprocessEnd = do - -- TODO: nested context - setAccepting True - --- --------------------------------------------------------------------- --- Preprocessor state functions - -data CppState - = CppIgnoring - | CppInDefine - | CppInIfdef - | CppInIfndef - | CppNormal - deriving (Show) - -getCppState :: P CppState -getCppState = do - context <- peekContext - accepting <- getAccepting - case context of - ITcppDefine -> return CppInDefine - ITcppIfdef -> return CppInIfdef - ITcppIfndef -> return CppInIfndef - _ -> - if accepting - then return CppNormal - else return CppIgnoring +-- bypass for now, work in ghci +lexer = Lexer.lexer +lexerDbg = Lexer.lexerDbg + +-- lexer = ppLexer +-- -- lexer = ppLexerDbg +-- lexerDbg = ppLexerDbg + +-- ppLexer, ppLexerDbg :: Bool -> (Located Token -> P a) -> P a +-- -- Use this instead of 'lexer' in GHC.Parser to dump the tokens for debugging. +-- ppLexerDbg queueComments cont = ppLexer queueComments contDbg +-- where +-- contDbg tok = trace ("pptoken: " ++ show (unLoc tok)) (cont tok) +-- ppLexer queueComments cont = +-- Lexer.lexer +-- queueComments +-- ( \tk -> +-- let +-- -- contInner t = (trace ("ppLexer: tk=" ++ show (unLoc tk, unLoc t)) cont) t +-- contInner t = cont t +-- contPush = pushContext (unLoc tk) >> contIgnoreTok tk +-- contIgnoreTok (L l tok) = do +-- case l of +-- RealSrcSpan r (Strict.Just b) -> Lexer.queueIgnoredToken (L (PsSpan r b) tok) +-- _ -> return () +-- ppLexer queueComments cont +-- in +-- case tk of +-- L _ (ITcppDefine s) -> do +-- ppDefine (trace ("ppDefine:" ++ show s) s) +-- popContext +-- contIgnoreTok tk +-- L _ (ITcppIf _) -> contPush +-- L _ (ITcppIfdef s) -> do +-- defined <- ppIsDefined s +-- -- setAccepting defined +-- setAccepting (trace ("ifdef:" ++ show (s, defined)) defined) +-- contIgnoreTok tk +-- L _ (ITcppIfndef s) -> do +-- defined <- ppIsDefined s +-- -- setAccepting (not defined) +-- setAccepting (trace ("ifdef:" ++ show (s, defined)) (not defined)) +-- contIgnoreTok tk +-- L _ ITcppElse -> do +-- preprocessElse +-- contIgnoreTok tk +-- L _ ITcppEndif -> do +-- preprocessEnd +-- contIgnoreTok tk +-- _ -> do +-- state <- getCppState +-- -- case (trace ("CPP state:" ++ show state) state) of +-- case state of +-- CppIgnoring -> contIgnoreTok tk +-- _ -> contInner tk +-- ) + +-- preprocessElse :: P () +-- preprocessElse = do +-- accepting <- getAccepting +-- setAccepting (not accepting) + +-- preprocessEnd :: P () +-- preprocessEnd = do +-- -- TODO: nested context +-- setAccepting True + +-- -- --------------------------------------------------------------------- +-- -- Preprocessor state functions + +-- data CppState +-- = CppIgnoring +-- | CppInDefine +-- | CppInIfdef +-- | CppInIfndef +-- | CppNormal +-- deriving (Show) + +-- getCppState :: P CppState +-- getCppState = do +-- context <- peekContext +-- accepting <- getAccepting +-- case context of +-- ITcppDefine _ -> return CppInDefine +-- ITcppIfndef _ -> return CppInIfndef +-- ITcppIfdef _ -> return CppInIfdef +-- _ -> +-- if accepting +-- then return CppNormal +-- else return CppIgnoring -- pp_context stack start ----------------- -pushContext :: Token -> P () -pushContext new = - P $ \s -> POk s{pp = (pp s){pp_context = new : pp_context (pp s)}} () - -popContext :: P () -popContext = - P $ \s -> - let - new_context = case pp_context (pp s) of - [] -> [] - (_ : t) -> t - in - POk s{pp = (pp s){pp_context = new_context}} () - -peekContext :: P Token -peekContext = - P $ \s -> - let - r = case pp_context (pp s) of - [] -> ITeof -- Anthing really, for now, except a CPP one - (h : _) -> h - in - POk s r +-- pushContext :: Token -> P () +-- pushContext new = +-- P $ \s -> POk s{pp = (pp s){pp_context = new : pp_context (pp s)}} () + +-- popContext :: P () +-- popContext = +-- P $ \s -> +-- let +-- new_context = case pp_context (pp s) of +-- [] -> [] +-- (_ : t) -> t +-- in +-- POk s{pp = (pp s){pp_context = (trace ("pop:new_context:" ++ show new_context) new_context)}} () + +-- peekContext :: P Token +-- peekContext = +-- P $ \s -> +-- let +-- r = case pp_context (pp s) of +-- [] -> ITeof -- Anthing really, for now, except a CPP one +-- (h : _) -> h +-- in +-- POk s r setAccepting :: Bool -> P () setAccepting on = @@ -148,12 +152,21 @@ getAccepting = P $ \s -> POk s (pp_accepting (pp s)) -- definitions start -------------------- -ppDefine :: String -> P () +ppDefine :: FastString -> P () ppDefine def = P $ \s -> - POk s{pp = (pp s){pp_defines = Set.insert def (pp_defines (pp s))}} () + -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () + POk s{pp = (pp s){pp_defines = Set.insert (trace ("ppDefine:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))}} () -ppIsDefined :: String -> P Bool +ppIsDefined :: FastString -> P Bool ppIsDefined def = P $ \s -> - POk s (Set.member def (pp_defines (pp s))) + -- POk s (Set.member def (pp_defines (pp s))) + POk s (Set.member (trace ("ppIsDefined:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))) + +-- | Take a @FastString@ of the form "#define FOO\n" and strip off all but "FOO" +cleanTokenString :: FastString -> String +cleanTokenString fs = r + where + ss = dropWhile (\c -> not $ isSpace c) (unpackFS fs) + r = init ss -- definitions end -------------------- ===================================== utils/check-cpp/Main.hs ===================================== @@ -2,10 +2,11 @@ {-# LANGUAGE BangPatterns #-} import Control.Monad.IO.Class +import Data.Char import Data.Data hiding (Fixity) import Data.List import qualified Data.Set as Set -import Debug.Trace (trace) +import Debug.Trace import GHC import qualified GHC.Data.EnumSet as EnumSet import GHC.Data.FastString @@ -26,6 +27,19 @@ import GHC.Types.SrcLoc import GHC.Utils.Error import GHC.Utils.Outputable +import qualified Text.Parsec as Parsec +import Text.Parsec.Char as PS +import Text.Parsec.Combinator as PS +import Text.Parsec.Prim as PS + +-- import qualified Text.Parsec as Parsec +import Text.Parsec.String (Parser) + +-- import Text.Parsec.Char +-- import FunctionsAndTypesForParsing (regularParse, parseWithEof, parseWithLeftOver) +-- import Text.Parsec.String.Combinator (many1) +-- import Text.Parsec.Combinator (many1) + -- --------------------------------------------------------------------- showAst :: (Data a) => a -> String @@ -46,7 +60,6 @@ ppLexer queueComments cont = ( \tk -> let contInner t = (trace ("ppLexer: tk=" ++ show (unLoc tk, unLoc t)) cont) t - -- contPush = pushContext (unLoc tk) >> contInner (L lt (ITcppIgnored [tk])) contPush = pushContext (unLoc tk) >> contIgnoreTok tk contIgnoreTok (L l tok) = do case l of @@ -54,35 +67,50 @@ ppLexer queueComments cont = _ -> return () ppLexer queueComments cont in - case tk of - L _ ITcppDefine -> contPush - L _ ITcppIf -> contPush - L _ ITcppIfdef -> contPush - L _ ITcppIfndef -> contPush - L _ ITcppElse -> do - preprocessElse - contIgnoreTok tk - L _ ITcppEndif -> do - preprocessEnd - contIgnoreTok tk - L _ tok -> do - state <- getCppState - case (trace ("CPP state:" ++ show state) state) of - CppIgnoring -> contIgnoreTok tk - CppInDefine -> do - ppDefine (trace ("ppDefine:" ++ show tok) (show tok)) - popContext + -- case tk of + case (trace ("M.ppLexer:tk=" ++ show (unLoc tk)) tk) of + L _ (ITcppStart continuation s) -> do + if continuation + then do + pushContinuation tk + contIgnoreTok tk + else do + processCppToks s contIgnoreTok tk - CppInIfdef -> do - defined <- ppIsDefined (show tok) - setAccepting defined - popContext + L _ (ITcppContinue continuation s) -> do + if continuation + then do + pushContinuation tk contIgnoreTok tk - CppInIfndef -> do - defined <- ppIsDefined (show tok) - setAccepting (not defined) - popContext + else do + processCppToks s contIgnoreTok tk + -- L _ (ITcppDefine s) -> do + -- -- ppDefine (trace ("ppDefine:" ++ show s) s) + -- ppDefine s + -- popContext + -- contIgnoreTok tk + -- L _ (ITcppIf _) -> contPush + -- L _ (ITcppIfdef s) -> do + -- defined <- ppIsDefined s + -- -- setAccepting defined + -- setAccepting (trace ("ifdef:" ++ show (s, defined)) defined) + -- contIgnoreTok tk + -- L _ (ITcppIfndef s) -> do + -- defined <- ppIsDefined s + -- -- setAccepting (not defined) + -- setAccepting (trace ("ifdef:" ++ show (s, defined)) (not defined)) + -- contIgnoreTok tk + -- L _ ITcppElse -> do + -- preprocessElse + -- contIgnoreTok tk + -- L _ ITcppEndif -> do + -- preprocessEnd + -- contIgnoreTok tk + _ -> do + state <- getCppState + case (trace ("CPP state:" ++ show state) state) of + CppIgnoring -> contIgnoreTok tk _ -> contInner tk ) @@ -96,6 +124,23 @@ preprocessEnd = do -- TODO: nested context setAccepting True +processCppToks :: FastString -> P () +processCppToks fs = do + let str = unpackFS fs + let + get (L _ (ITcppStart _ s)) = s + get (L _ (ITcppContinue _ s)) = s + get _ = error "should not" + -- Combine any prior continuation tokens + cs <- popContinuation + processCpp (reverse $ fs : map get cs) + return () + +processCpp :: [FastString] -> P () +processCpp fs = do + traceM $ "processCpp: fs=" ++ show fs + return () + -- --------------------------------------------------------------------- -- Preprocessor state functions @@ -112,9 +157,9 @@ getCppState = do context <- peekContext accepting <- getAccepting case context of - ITcppDefine -> return CppInDefine - ITcppIfdef -> return CppInIfdef - ITcppIfndef -> return CppInIfndef + -- ITcppDefine _ -> return CppInDefine + -- ITcppIfdef _ -> return CppInIfdef + -- ITcppIfndef _ -> return CppInIfndef _ -> if accepting then return CppNormal @@ -153,17 +198,90 @@ setAccepting on = getAccepting :: P Bool getAccepting = P $ \s -> POk s (pp_accepting (pp s)) +-- ------------------------------------- + +pushContinuation :: Located Token -> P () +pushContinuation new = + P $ \s -> POk s{pp = (pp s){pp_continuation = new : pp_continuation (pp s)}} () + +popContinuation :: P [Located Token] +popContinuation = + P $ \s -> POk s{pp = (pp s){pp_continuation = []}} (pp_continuation (pp s)) + -- pp_context stack end ------------------- -- definitions start -------------------- -ppDefine :: String -> P () +ppDefine :: FastString -> P () ppDefine def = P $ \s -> - POk s{pp = (pp s){pp_defines = Set.insert def (pp_defines (pp s))}} () + -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () + POk s{pp = (pp s){pp_defines = Set.insert (trace ("ppDefine:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))}} () -ppIsDefined :: String -> P Bool +ppIsDefined :: FastString -> P Bool ppIsDefined def = P $ \s -> - POk s (Set.member def (pp_defines (pp s))) + -- POk s (Set.member (cleanTokenString def) (pp_defines (pp s))) + POk s (Set.member (trace ("ppIsDefined:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))) + +-- | Take a @FastString@ of the form "#define FOO\n" and strip off all but "FOO" +cleanTokenString :: FastString -> String +cleanTokenString fs = r + where + ss = dropWhile (\c -> not $ isSpace c) (unpackFS fs) + r = init ss + +parseDefine :: FastString -> Maybe (String, String) +parseDefine s = r + where + r = Just (cleanTokenString s, "") + +-- ===================================================================== +-- Parsec parsing +type CppParser = Parsec String () + +regularParse :: Parser a -> String -> Either Parsec.ParseError a +regularParse p = PS.parse p "" + +cppComment :: CppParser () +cppComment = do + _ <- PS.string "/*" + _ <- PS.manyTill PS.anyChar (PS.try (PS.string "*/")) + return () + +whiteSpace :: CppParser () +whiteSpace = do + _ <- PS.many (PS.choice [cppComment, PS.space >> return ()]) + return () + +lexeme :: CppParser a -> CppParser a +lexeme p = p <* whiteSpace + +cppToken :: CppParser String +cppToken = lexeme (PS.many1 (PS.satisfy (\c -> not (isSpace c)))) + +{- | Do cpp initial processing, as per https://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html +See Note [GhcCPP Initial Processing] +-} +cppInitial :: FastString -> String +cppInitial fs = r + where + r = unpackFS fs + +{- +Note [GhcCPP Initial Processing] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This processing is based on the description at +https://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html + +It is only done for lines starting with a preprocessor +directive. + +1. Broken into lines. We rely on the GHC Lexer to do this +2. Trigraphs are not processed +3. Continued lines are merged into a single line + and is handled in the Lexer. +4. All comments are replaced with a single space + +-} -- ===================================================================== -- Emulate the parser @@ -330,13 +448,9 @@ happyError = Lexer.srcParseFail -- ===================================================================== -- --------------------------------------------------------------------- -printToks :: Int -> [Located Token] -> IO () -printToks indent toks = mapM_ go toks +printToks :: [Located Token] -> IO () +printToks toks = mapM_ go toks where - go (L _ (ITcppIgnored ts)) = do - putStr "ITcppIgnored [" - printToks (indent + 4) ts - putStrLn "]" go (L _ tk) = putStrLn (show tk) -- Testing @@ -349,13 +463,13 @@ doTest strings = do let test = intercalate "\n" strings !tks <- parseString libdirNow test putStrLn "-----------------------------------------" - printToks 0 (reverse tks) + printToks (reverse tks) t0 :: IO () t0 = do doTest - [ "#define FOO" - , "#ifdef FOO" + [ "# define FOO" + , "# ifdef FOO" , "x = 1" , "#endif" , "" @@ -379,3 +493,87 @@ t2 = do , "#endif" , "" ] + +t3 :: IO () +t3 = do + doTest + [ "{-# LANGUAGE GhcCPP #-}" + , "module Example1 where" + , "" + , "y = 1" + , "" + , "#define FOO" + , "" + , "x =" + , "#ifdef FOO" + , " \" hello \"" + , "#else" + , " \" bye now \"" + , "#endif" + , "" + , "foo = putStrLn x" + ] + +t3a :: IO () +t3a = do + doTest + [ "{-# LANGUAGE GhcCPP #-}" + , "module Example1 where" + , "" + , "#define FOO" + , "" + , "x =" + , "#ifdef FOO" + , " \" hello \"" + , "#else" + , " \" bye now \"" + , "#endif" + , "" + , "foo = putStrLn x" + ] + +t4 :: IO () +t4 = do + doTest + [ "/* package ghc-exactprint-1.7.0.1 */" + , "#ifndef VERSION_ghc_exactprint" + , "#define VERSION_ghc_exactprint \"1.7.0.1\"" + , "#endif /* VERSION_ghc_exactprint */" + , "#ifndef MIN_VERSION_ghc_exactprint" + , -- , "#define MIN_VERSION_ghc_exactprint(major1,major2,minor) (\\" + -- , " (major1) < 1 || \\" + -- , " (major1) == 1 && (major2) < 7 || \\" + -- , " (major1) == 1 && (major2) == 7 && (minor) <= 0)" + "#endif /* MIN_VERSION_ghc_exactprint */" + , "" + , "#ifdef VERSION_ghc_exactprint" + , "x = \"got version\"" + , "#else" + , "x = \"no version\"" + , "#endif" + ] + +t5 :: IO () +t5 = do + doTest + [ "#define MIN_VERSION_ghc_exactprint(major1,major2,minor) (\\" + , " (major1) < 1 || \\" + , " (major1) == 1 && (major2) < 7 || \\" + , " (major1) == 1 && (major2) == 7 && (minor) <= 0)" + , "x = x" + ] + +t6 :: IO () +t6 = do + doTest + [ "#define VERSION_ghc_exactprint \"1.7.0.1\"" + , "" + , "#ifdef VERSION_ghc_exactprint" + , "x = \"got version\"" + , "#else" + , "x = \"no version\"" + , "#endif" + ] + +t7 :: Maybe (String, String) +t7 = parseDefine (mkFastString "#define VERSION_ghc_exactprint \"1.7.0.1\"\n") View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8134209e4092556edb7b0d324157db0ea5a468af...89aaf2869980802922f676c0d3f391d0db568b17 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8134209e4092556edb7b0d324157db0ea5a468af...89aaf2869980802922f676c0d3f391d0db568b17 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 01:32:39 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sun, 01 Oct 2023 21:32:39 -0400 Subject: [Git][ghc/ghc][wip/expand-do] 33 commits: Move lib{numa,dw} defines to RTS configure Message-ID: <651a1db7c43_364e0430550c295e5@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - a53f6318 by Apoorv Ingle at 2023-09-28T14:15:01-05:00 Fixes #18324 #23147 #20020 Expands do notation before typechecking using `HsExpansion` - Adds testcases T18324, T18324b, DoubleMatch Expands - Do statements - Monadic do statements - monadic fix blocks - make sure fail is used for pattern match failures in bind statments - Makes sure unused binds generate warnings - runs the pattern match check in generated lambda exprs to avoid getting suprious pattern match failures. c.f. pmcheck/should_compile/DoubleMatch.hs - PopSrcSpan in HsExpr to pop error context - Discards default monad fail alternatives that are spuriously generated - Make sure we check for generated loc span for checking if the (>>) is user written or expanded for /do/ purposes - Add PopSrcSpan (XXExprGhcRn) in appropriate places while expanding statements - correct source spans displayed for warnDiscardedDoBindings - use `mkExpandStmt` to store original stmts along with expanded expr for using the right context for error message printing - improves error messages for applicative do - remove special case from isMatchContextPmChecked (long distance info is now properly propogated) - set correct src spans to statement expansions - Match ctxt while type checking HsLam is different if the lambda match is due to an expression generated from a do block - call tcExpr and not tcApp in PopSrcSpan so make sure impredicativity works fine - look into XExprs in tcInferAppHead_maybe for infering the type to make T18324 typecheck and run - make the ExpandedStmt generated expression location-less - Introduce ExpansionStmt for proper `hsSplitApps` - Introduce `VAExpansionStmt` that is just like `VAExpansion` but for statements - Aligning expand stmt context pushing on error stack. - Pop error context while checking do expansion generated GRHSs inside HsLam so that we do not print the previous statement error context - makes template haskell happy - some fix for let expansions - refactor tcExpr into tcExpr and tcXExpr - adding Note and references - make monad fail errors normal again - - - - - 0a4f83ed by Apoorv Ingle at 2023-09-28T14:15:05-05:00 cleanup - - - - - ffbb1090 by Apoorv Ingle at 2023-09-28T14:15:05-05:00 Generated Origin now carries HsStmtContext so that we don't have to recreate it - - - - - 4f08bfb4 by Apoorv Ingle at 2023-09-28T14:15:05-05:00 trying to fix ghci-debugger issues - - - - - 1962b801 by Apoorv Ingle at 2023-09-28T14:15:05-05:00 fixes for Note [Expanding HsDo with HsExpansion] - - - - - e9c414b0 by Apoorv Ingle at 2023-09-28T14:15:05-05:00 some more trials for debugger - - - - - bfa57420 by Apoorv Ingle at 2023-10-01T20:32:20-05:00 do not duplicate ExpansionStmt argument applications - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Linker/Deps.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToByteCode.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a529583a96ce9028b1a35710c1abb76efe1c3903...bfa57420cc168814481c90c801037bc1639b0b81 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a529583a96ce9028b1a35710c1abb76efe1c3903...bfa57420cc168814481c90c801037bc1639b0b81 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 02:21:35 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sun, 01 Oct 2023 22:21:35 -0400 Subject: [Git][ghc/ghc][wip/expand-do] 14 commits: Fix several mistakes around free variables in iface breakpoints Message-ID: <651a292f36cad_364e0438129c30550@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - 8de38d59 by Apoorv Ingle at 2023-10-01T20:41:29-05:00 Fixes #18324 #23147 #20020 Expands do notation before typechecking using `HsExpansion` - Adds testcases T18324, T18324b, DoubleMatch Expands - Do statements - Monadic do statements - monadic fix blocks - make sure fail is used for pattern match failures in bind statments - Makes sure unused binds generate warnings - runs the pattern match check in generated lambda exprs to avoid getting suprious pattern match failures. c.f. pmcheck/should_compile/DoubleMatch.hs - PopSrcSpan in HsExpr to pop error context - Discards default monad fail alternatives that are spuriously generated - Make sure we check for generated loc span for checking if the (>>) is user written or expanded for /do/ purposes - Add PopSrcSpan (XXExprGhcRn) in appropriate places while expanding statements - correct source spans displayed for warnDiscardedDoBindings - use `mkExpandStmt` to store original stmts along with expanded expr for using the right context for error message printing - improves error messages for applicative do - remove special case from isMatchContextPmChecked (long distance info is now properly propogated) - set correct src spans to statement expansions - Match ctxt while type checking HsLam is different if the lambda match is due to an expression generated from a do block - call tcExpr and not tcApp in PopSrcSpan so make sure impredicativity works fine - look into XExprs in tcInferAppHead_maybe for infering the type to make T18324 typecheck and run - make the ExpandedStmt generated expression location-less - Introduce ExpansionStmt for proper `hsSplitApps` - Introduce `VAExpansionStmt` that is just like `VAExpansion` but for statements - Aligning expand stmt context pushing on error stack. - Pop error context while checking do expansion generated GRHSs inside HsLam so that we do not print the previous statement error context - makes template haskell happy - some fix for let expansions - refactor tcExpr into tcExpr and tcXExpr - adding Note and references - make monad fail errors normal again - - - - - 607619f0 by Apoorv Ingle at 2023-10-01T20:41:34-05:00 cleanup - - - - - 06ea9b68 by Apoorv Ingle at 2023-10-01T20:41:34-05:00 Generated Origin now carries HsStmtContext so that we don't have to recreate it - - - - - 9ebf262e by Apoorv Ingle at 2023-10-01T20:41:34-05:00 trying to fix ghci-debugger issues - - - - - fe0d09f0 by Apoorv Ingle at 2023-10-01T20:41:34-05:00 fixes for Note [Expanding HsDo with HsExpansion] - - - - - b5b8ed9b by Apoorv Ingle at 2023-10-01T20:41:35-05:00 some more trials for debugger - - - - - 2b85751d by Apoorv Ingle at 2023-10-01T20:42:35-05:00 do not duplicate ExpansionStmt argument applications - - - - - 59829bc0 by Apoorv Ingle at 2023-10-01T21:18:17-05:00 rebase with HsLam changes - - - - - 30 changed files: - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Utils.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bfa57420cc168814481c90c801037bc1639b0b81...59829bc098a014d5a8702d3355fb11a29e816c86 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bfa57420cc168814481c90c801037bc1639b0b81...59829bc098a014d5a8702d3355fb11a29e816c86 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 04:26:10 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 02 Oct 2023 00:26:10 -0400 Subject: [Git][ghc/ghc][wip/expand-do] do not tick body stmts and inside lambdas for do expansions, except last stmt Message-ID: <651a466264c13_364e04401a6e03376a@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: eda7b3a1 by Apoorv Ingle at 2023-10-01T23:25:41-05:00 do not tick body stmts and inside lambdas for do expansions, except last stmt - - - - - 1 changed file: - compiler/GHC/HsToCore/Ticks.hs Changes: ===================================== compiler/GHC/HsToCore/Ticks.hs ===================================== @@ -304,7 +304,7 @@ addTickLHsBind (L pos (pat@(PatBind { pat_lhs = lhs -- TODO: better name for rhs's for non-simple patterns? let name = maybe "(...)" getOccString simplePatId - (fvs, rhs') <- getFreeVars $ addPathEntry name $ addTickGRHSs False False rhs + (fvs, rhs') <- getFreeVars $ addPathEntry name $ addTickGRHSs False False False rhs let pat' = pat { pat_rhs = rhs'} -- Should create ticks here? @@ -447,8 +447,10 @@ isCallSite HsApp{} = True isCallSite HsAppType{} = True isCallSite (XExpr (ExpansionExpr (HsExpanded _ e))) = isCallSite e -isCallSite (XExpr (ExpansionStmt{})) - = True +isCallSite (XExpr (ExpansionStmt (HsExpanded (L _ stmt) _))) + | BodyStmt{} <- stmt = False + | otherwise = True + -- NB: OpApp, SectionL, SectionR are all expanded out isCallSite _ = False @@ -528,20 +530,13 @@ addTickHsExpr (HsIf x e1 e2 e3) = (addTickLHsExprOptAlt True e3) addTickHsExpr (HsMultiIf ty alts) = do { let isOneOfMany = case alts of [_] -> False; _ -> True - ; alts' <- mapM (traverse $ addTickGRHS isOneOfMany False) alts + ; alts' <- mapM (traverse $ addTickGRHS isOneOfMany False False) alts ; return $ HsMultiIf ty alts' } addTickHsExpr (HsLet x tkLet binds tkIn e) = bindLocals (collectLocalBinders CollNoDictBinders binds) $ do binds' <- addTickHsLocalBinds binds -- to think about: !patterns. e' <- addTickLHsExprLetBody e return (HsLet x tkLet binds' tkIn e') -addTickHsExpr (HsDo srcloc cxt (L l stmts)) - = do { (stmts', _) <- addTickLStmts' forQual stmts (return ()) - ; return (HsDo srcloc cxt (L l stmts')) } - where - forQual = case cxt of - ListComp -> Just $ BinBox QualBinBox - _ -> Nothing addTickHsExpr (ExplicitList ty es) = liftM2 ExplicitList (return ty) (mapM (addTickLHsExpr) es) @@ -610,6 +605,15 @@ addTickHsExpr (XExpr (HsTick t e)) = addTickHsExpr (XExpr (HsBinTick t0 t1 e)) = liftM (XExpr . HsBinTick t0 t1) (addTickLHsExprNever e) + +addTickHsExpr (HsDo srcloc cxt (L l stmts)) + = do { (stmts', _) <- addTickLStmts' forQual stmts (return ()) + ; return (HsDo srcloc cxt (L l stmts')) } + where + forQual = case cxt of + ListComp -> Just $ BinBox QualBinBox + _ -> Nothing + addTickTupArg :: HsTupArg GhcTc -> TM (HsTupArg GhcTc) addTickTupArg (Present x e) = do { e' <- addTickLHsExpr e ; return (Present x e') } @@ -618,40 +622,44 @@ addTickTupArg (Missing ty) = return (Missing ty) addTickMatchGroup :: Bool{-is lambda-} -> MatchGroup GhcTc (LHsExpr GhcTc) -> TM (MatchGroup GhcTc (LHsExpr GhcTc)) -addTickMatchGroup is_lam mg@(MG { mg_alts = L l matches }) = do +addTickMatchGroup is_lam mg@(MG { mg_alts = L l matches, mg_ext = ctxt }) = do let isOneOfMany = matchesOneOfMany matches - matches' <- mapM (traverse (addTickMatch isOneOfMany is_lam)) matches + isDoExpansionStmt = isJust (isDoExpansionGenerated $ mg_origin ctxt) + matches' <- mapM (traverse (addTickMatch isOneOfMany is_lam isDoExpansionStmt)) matches return $ mg { mg_alts = L l matches' } -addTickMatch :: Bool -> Bool -> Match GhcTc (LHsExpr GhcTc) +addTickMatch :: Bool -> Bool -> Bool -> Match GhcTc (LHsExpr GhcTc) -> TM (Match GhcTc (LHsExpr GhcTc)) -addTickMatch isOneOfMany isLambda match@(Match { m_pats = pats - , m_grhss = gRHSs }) = +addTickMatch isOneOfMany isLambda isDoExp match@(Match { m_pats = pats + , m_grhss = gRHSs }) = bindLocals (collectPatsBinders CollNoDictBinders pats) $ do - gRHSs' <- addTickGRHSs isOneOfMany isLambda gRHSs + gRHSs' <- addTickGRHSs isOneOfMany isLambda isDoExp gRHSs return $ match { m_grhss = gRHSs' } -addTickGRHSs :: Bool -> Bool -> GRHSs GhcTc (LHsExpr GhcTc) +addTickGRHSs :: Bool -> Bool -> Bool -> GRHSs GhcTc (LHsExpr GhcTc) -> TM (GRHSs GhcTc (LHsExpr GhcTc)) -addTickGRHSs isOneOfMany isLambda (GRHSs x guarded local_binds) = +addTickGRHSs isOneOfMany isLambda isDoExp (GRHSs x guarded local_binds) = bindLocals binders $ do local_binds' <- addTickHsLocalBinds local_binds - guarded' <- mapM (traverse (addTickGRHS isOneOfMany isLambda)) guarded + guarded' <- mapM (traverse (addTickGRHS isOneOfMany isLambda isDoExp)) guarded return $ GRHSs x guarded' local_binds' where binders = collectLocalBinders CollNoDictBinders local_binds -addTickGRHS :: Bool -> Bool -> GRHS GhcTc (LHsExpr GhcTc) +addTickGRHS :: Bool -> Bool -> Bool -> GRHS GhcTc (LHsExpr GhcTc) -> TM (GRHS GhcTc (LHsExpr GhcTc)) -addTickGRHS isOneOfMany isLambda (GRHS x stmts expr) = do +addTickGRHS isOneOfMany isLambda isDoExp (GRHS x stmts expr) = do (stmts',expr') <- addTickLStmts' (Just $ BinBox $ GuardBinBox) stmts - (addTickGRHSBody isOneOfMany isLambda expr) + (addTickGRHSBody isOneOfMany isLambda isDoExp expr) return $ GRHS x stmts' expr' -addTickGRHSBody :: Bool -> Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc) -addTickGRHSBody isOneOfMany isLambda expr@(L pos e0) = do +addTickGRHSBody :: Bool -> Bool -> Bool -> LHsExpr GhcTc -> TM (LHsExpr GhcTc) +addTickGRHSBody isOneOfMany isLambda isDoExp expr@(L pos e0) = do d <- getDensity case d of + TickForBreakPoints + | XExpr (ExpansionStmt (HsExpanded (L _ LastStmt{}) _)) <- e0 -> addTickLHsExprRHS expr + | isDoExp -> addTickLHsExprNever expr TickForCoverage -> addTickLHsExprOptAlt isOneOfMany expr TickAllFunctions | isLambda -> addPathEntry "\\" $ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eda7b3a1a4212da729df9cd5e0dcb63d9bee3959 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eda7b3a1a4212da729df9cd5e0dcb63d9bee3959 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 05:28:08 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 02 Oct 2023 01:28:08 -0400 Subject: [Git][ghc/ghc][wip/expand-do] break at HsCase as it may occur inside a body stmt Message-ID: <651a54e823d93_364e0456bdc0836311@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: eaa104f7 by Apoorv Ingle at 2023-10-02T00:27:46-05:00 break at HsCase as it may occur inside a body stmt - - - - - 1 changed file: - compiler/GHC/HsToCore/Ticks.hs Changes: ===================================== compiler/GHC/HsToCore/Ticks.hs ===================================== @@ -445,11 +445,13 @@ isGoodBreakExpr e = isCallSite e isCallSite :: HsExpr GhcTc -> Bool isCallSite HsApp{} = True isCallSite HsAppType{} = True +isCallSite HsCase{} = True isCallSite (XExpr (ExpansionExpr (HsExpanded _ e))) = isCallSite e -isCallSite (XExpr (ExpansionStmt (HsExpanded (L _ stmt) _))) +isCallSite (XExpr (ExpansionStmt (HsExpanded (L _ stmt) e))) | BodyStmt{} <- stmt = False - | otherwise = True + | LastStmt{} <- stmt = True + | otherwise = isCallSite e -- NB: OpApp, SectionL, SectionR are all expanded out isCallSite _ = False @@ -523,6 +525,7 @@ addTickHsExpr (HsCase x e mgs) = (addTickLHsExpr e) -- not an EvalInner; e might not necessarily -- be evaluated. (addTickMatchGroup False mgs) + addTickHsExpr (HsIf x e1 e2 e3) = liftM3 (HsIf x) (addBinTickLHsExpr (BinBox CondBinBox) e1) @@ -624,11 +627,11 @@ addTickMatchGroup :: Bool{-is lambda-} -> MatchGroup GhcTc (LHsExpr GhcTc) -> TM (MatchGroup GhcTc (LHsExpr GhcTc)) addTickMatchGroup is_lam mg@(MG { mg_alts = L l matches, mg_ext = ctxt }) = do let isOneOfMany = matchesOneOfMany matches - isDoExpansionStmt = isJust (isDoExpansionGenerated $ mg_origin ctxt) - matches' <- mapM (traverse (addTickMatch isOneOfMany is_lam isDoExpansionStmt)) matches + isDoExp = isJust (isDoExpansionGenerated $ mg_origin ctxt) + matches' <- mapM (traverse (addTickMatch isOneOfMany is_lam isDoExp)) matches return $ mg { mg_alts = L l matches' } -addTickMatch :: Bool -> Bool -> Bool -> Match GhcTc (LHsExpr GhcTc) +addTickMatch :: Bool -> Bool -> Bool {-Is Do Expanion-} -> Match GhcTc (LHsExpr GhcTc) -> TM (Match GhcTc (LHsExpr GhcTc)) addTickMatch isOneOfMany isLambda isDoExp match@(Match { m_pats = pats , m_grhss = gRHSs }) = View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eaa104f7c5b082a3c3275049c651e58c051071d0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eaa104f7c5b082a3c3275049c651e58c051071d0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 09:06:45 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 02 Oct 2023 05:06:45 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24029 Message-ID: <651a8825975b5_364e04aa8d554651cd@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/T24029 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24029 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 09:14:19 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 02 Oct 2023 05:14:19 -0400 Subject: [Git][ghc/ghc][wip/T23964] Stricter Binary.get in GHC.Types.Unit (#23964) Message-ID: <651a89eb9b8e_364e04acffc88752a7@gitlab.mail> Sebastian Graf pushed to branch wip/T23964 at Glasgow Haskell Compiler / GHC Commits: d1177220 by Sebastian Graf at 2023-10-02T11:13:05+02:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - 1 changed file: - compiler/GHC/Unit/Types.hs Changes: ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -149,7 +149,8 @@ instance Uniquable Module where instance Binary a => Binary (GenModule a) where put_ bh (Module p n) = put_ bh p >> put_ bh n - get bh = do p <- get bh; n <- get bh; return (Module p n) + -- Module has strict fields, so use $! in order not to allocate a thunk + get bh = do p <- get bh; n <- get bh; return $! Module p n instance NFData (GenModule a) where rnf (Module unit name) = unit `seq` name `seq` () @@ -317,13 +318,14 @@ instance Binary InstantiatedUnit where cid <- get bh insts <- get bh let fs = mkInstantiatedUnitHash cid insts - return InstantiatedUnit { - instUnitInstanceOf = cid, - instUnitInsts = insts, - instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), - instUnitFS = fs, - instUnitKey = getUnique fs - } + -- InstantiatedUnit has strict fields, so use $! in order not to allocate a thunk + return $! InstantiatedUnit { + instUnitInstanceOf = cid, + instUnitInsts = insts, + instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), + instUnitFS = fs, + instUnitKey = getUnique fs + } instance IsUnitId u => Eq (GenUnit u) where uid1 == uid2 = unitUnique uid1 == unitUnique uid2 @@ -369,10 +371,12 @@ instance Binary Unit where put_ bh HoleUnit = putByte bh 2 get bh = do b <- getByte bh - case b of + u <- case b of 0 -> fmap RealUnit (get bh) 1 -> fmap VirtUnit (get bh) _ -> pure HoleUnit + -- Unit has strict fields that need forcing; otherwise we allocate a thunk. + pure $! u -- | Retrieve the set of free module holes of a 'Unit'. unitFreeModuleHoles :: GenUnit u -> UniqDSet ModuleName View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1177220330a2432190d55f4f0c037f41c871ee6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1177220330a2432190d55f4f0c037f41c871ee6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 10:29:30 2023 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Mon, 02 Oct 2023 06:29:30 -0400 Subject: [Git][ghc/ghc][wip/or-pats] 82 commits: Fix numa auto configure Message-ID: <651a9b8a2d115_364e04cfbc1cc962b0@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - e901b6b4 by David Knothe at 2023-10-02T12:29:11+02:00 Implement Or Patterns (Proposal 0522) This commit introduces a language extension, `OrPatterns`, as described in proposal 0522. It extends the syntax by the production `pat -> (one of pat1, ..., patk)`. The or-pattern `pat` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order. Currently, or-patterns cannot bind variables. They are still of great use as they discourage the use of wildcard patterns in favour of writing out all "default" cases explicitly: ``` isIrrefutableHsPat pat = case pat of ... (one of WildPat{}, VarPat{}, LazyPat{}) = True (one of PArrPat{}, ConPatIn{}, LitPat{}, NPat{}, NPlusKPat{}, ListPat{}) = False ``` This makes code safer where data types are extended now and then - just like GHC's `Pat` in the example when adding the new `OrPat` constructor. This would be catched by `-fwarn-incomplete-patterns`, but not when a wildcard pattern was used. - Update submodule haddock. stuff Implement empty one of Prohibit TyApps Remove unused update submodule haddock Update tests Parser.y - - - - - 6dca0c12 by David Knothe at 2023-10-02T12:29:12+02:00 infixpat - - - - - b70036a3 by David Knothe at 2023-10-02T12:29:12+02:00 ppr&tests - - - - - 151aa178 by David Knothe at 2023-10-02T12:29:12+02:00 Fix PatSyn tests - - - - - b0d61735 by David Knothe at 2023-10-02T12:29:13+02:00 Revert "Fix PatSyn tests" This reverts commit af82f8db8f7e03e130c28ef09a2a2c9c5fffaa5a. - - - - - 8fb611a1 by David Knothe at 2023-10-02T12:29:13+02:00 Nonbreaking parser change - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/DynFlags.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/553054b9b1071cbb46040e8b85603823e9b4da3d...8fb611a120ed20a2b6fae7c93b9940d66db0c49b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/553054b9b1071cbb46040e8b85603823e9b4da3d...8fb611a120ed20a2b6fae7c93b9940d66db0c49b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 10:41:35 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 02 Oct 2023 06:41:35 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24026 Message-ID: <651a9e5ff156a_364e04d178a88106857@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/T24026 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24026 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 10:42:01 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 02 Oct 2023 06:42:01 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/T24026 Message-ID: <651a9e792ef43_364e04d0df2481070ac@gitlab.mail> Krzysztof Gogolewski deleted branch wip/T24026 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 10:43:58 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 02 Oct 2023 06:43:58 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24026 Message-ID: <651a9eeeb1ea8_364e04d19596c110944@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/T24026 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24026 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 10:44:08 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 02 Oct 2023 06:44:08 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/T24026 Message-ID: <651a9ef852f74_364e04d526e28111133@gitlab.mail> Krzysztof Gogolewski deleted branch wip/T24026 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 10:44:18 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 02 Oct 2023 06:44:18 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24024 Message-ID: <651a9f0233b5c_364e04d0e36b811132b@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/T24024 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24024 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 12:51:52 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 02 Oct 2023 08:51:52 -0400 Subject: [Git][ghc/ghc][wip/T21062] 2555 commits: Improve "Glomming" note Message-ID: <651abce869771_364e041065e96413601@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/T21062 at Glasgow Haskell Compiler / GHC Commits: 50347ded by Gergő Érdi at 2022-05-10T11:43:33+00:00 Improve "Glomming" note Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order references, and thus needing to glom, is not a cause for concern when its root cause is rewrite rules. - - - - - df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00 update INSTALL - - - - - dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00 driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode It seems like it was just an oversight to use the incorrect DynFlags (global rather than local) when implementing these two options. Using the local flags allows users to request these intermediate files get cleaned up, which works fine in --make mode because 1. Interface files are stored in memory 2. Object files are only cleaned at the end of session (after link) Fixes #21349 - - - - - 35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00 configure: Check for ffi.h As noted in #21485, we checked for ffi.h yet then failed to throw an error if it is missing. Fixes #21485. - - - - - bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00 Check for uninferrable variables in tcInferPatSynDecl This fixes #21479 See Note [Unquantified tyvars in a pattern synonym] While doing this, I found that some error messages pointed at the pattern synonym /name/, rather than the /declaration/ so I widened the SrcSpan to encompass the declaration. - - - - - 142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00 hadrian: Fix split-sections transformer The splitSections transformer has been broken since -dynamic-too support was implemented in hadrian. This is because we actually build the dynamic way when building the dynamic way, so the predicate would always fail. The fix is to just always pass `split-sections` even if it doesn't do anything for a particular way. Fixes #21138 - - - - - 699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. Closes #21135 - - - - - 21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00 Use the wrapper for an unlifted binding We assumed the wrapper for an unlifted binding is the identity, but as #21516 showed, that is no always true. Solution is simple: use it. - - - - - 68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00 docs: Fix path to GHC API docs in index.html In the make bindists we generate documentation in docs/ghc-<VER> but the hadrian bindists generate docs/ghc/ so the path to the GHC API docs was wrong in the index.html file. Rather than make the hadrian and make bindists the same it was easier to assume that if you're using the mkDocs script that you're using hadrian bindists. Fixes #21509 - - - - - 9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00 hadrian: Don't pass -j to haddock This has high potential for oversubcribing as many haddock jobs can be spawned in parralel which will each request the given number of capabilities. Once -jsem is implemented (#19416, !5176) we can expose that haddock via haddock and use that to pass a semaphore. Ticket #21136 - - - - - fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00 hadrian: Only copy and install libffi headers when using in-tree libffi When passed `--use-system-libffi` then we shouldn't copy and install the headers from the system package. Instead the headers are expected to be available as a runtime dependency on the users system. Fixes #21485 #21487 - - - - - 5b791ed3 by mikael at 2022-05-11T08:22:13-04:00 FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10. - - - - - 8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00 Make floating-point abs IEEE 754 compliant The old code used by via-C backend didn't handle the sign bit of NaN. See #21043. - - - - - 4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00 EPA: do statement with leading semicolon has wrong anchor The code do; a <- doAsync; b Generated an incorrect Anchor for the statement list that starts after the first semicolon. This commit fixes it. Closes #20256 - - - - - e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00 Specialiser: saturate DFuns correctly Ticket #21489 showed that the saturation mechanism for DFuns (see Note Specialising DFuns) should use both UnspecType and UnspecArg. We weren't doing that; but this MR fixes that problem. No test case because it's hard to tickle, but it showed up in Gergo's work with GHC-as-a-library. - - - - - fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00 gitlab-ci: Check for dynamic msys2 dependencies Both #20878 and #21196 were caused by unwanted dynamic dependencies being introduced by boot libraries. Ensure that we catch this in CI by attempting to run GHC in an environment with a minimal PATH. - - - - - 3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00 Add back Debian9 CI jobs We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 not being at EOL until April 2023 and they still need tinfo5. Fixes #21469 - - - - - dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00 rts: Drop setExecutable Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been dead code. Drop it. - - - - - 32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00 Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat This missing guard gave rise to #21519. - - - - - 2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00 Add mention of -hi to RTS --help Fixes #21546 - - - - - a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00 Decouple dynflags in Cmm parser (related to #17957) - - - - - 3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00 Remove Module argument from initCmmParserConfig - - - - - 2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00 Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config - - - - - b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00 Decouple dynflags in GHC.Core.Opt.Arity (related to #17957) Metric Decrease: T16875 - - - - - 3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00 Update extending_ghc for TcPlugin changes The documentation still mentioned Derived constraints and an outdated datatype TcPluginResult. - - - - - 668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00 Fix printing of brackets in multiplicities (#20315) Change mulArrow to allow for printing of correct application precedence where necessary and update callers of mulArrow to reflect this. As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type. Fixes #20315 - - - - - 30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00 rts: Add debug output on ocResolve failure This makes it easier to see how resolution failures nest. - - - - - 53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00 rts/PEi386: Fix handling of weak symbols Previously we would flag the symbol as weak but failed to set its address, which must be computed from an "auxiliary" symbol entry the follows the weak symbol. Fixes #21556. - - - - - 5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00 testsuite: Add tests for #21556 - - - - - 49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00 Re-export augment and build from GHC.List Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127 - - - - - aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00 Comments only around HsWrapper - - - - - 27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00 hadrian: Introduce linting flavour transformer (+lint) The linting flavour enables -dlint uniformly across anything build by the stage1 compiler. -dcmm-lint is not currently enabled because it fails on i386 (see #21563) - - - - - 3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00 hadrian: Uniformly enable -dlint with enableLinting transformer This fixes some bugs where * -dcore-lint was being passed when building stage1 libraries with the boot compiler * -dcore-lint was not being passed when building executables. Fixes #20135 - - - - - 3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00 Make closure macros EXTERN_INLINE to make debugging easier Implements #21424. The RTS macros get_itbl and friends are extremely helpful during debugging. However only a select few of those were available in the compiled RTS as actual symbols as the rest were INLINE macros. This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites but allow us to use their compiled counterparts during debugging. This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell since `get_fun_itbl` will now be available as symbol! - - - - - 93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00 packaging: Introduce CI job for generating hackage documentation This adds a CI job (hackage-doc-tarball) which generates the necessary tarballs for uploading libraries and documentation to hackage. The release script knows to download this folder and the upload script will also upload the release to hackage as part of the release. The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs There are two modes, preparation and upload. * The `prepare` mode takes a link to a bindist and creates a folder containing the source and doc tarballs ready to upload to hackage. * The `upload` mode takes the folder created by prepare and performs the upload to hackage. Fixes #21493 Related to #21512 - - - - - 65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00 Add arity to the INLINE pragmas for pattern synonyms The lack of INLNE arity was exposed by #21531. The fix is simple enough, if a bit clumsy. - - - - - 43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00 Misc cleanup - Remove groupWithName (unused) - Use the RuntimeRepType synonym where possible - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM No functional changes. - - - - - 8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00 TcPlugin: access to irreducible givens + fix passed ev_binds_var - - - - - fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00 driver: Introduce pgmcxx Here we introduce proper support for compilation of C++ objects. This includes: * logic in `configure` to detect the C++ toolchain and propagating this information into the `settings` file * logic in the driver to use the C++ toolchain when compiling C++ sources - - - - - 43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Build T20918 with HC, not CXX - - - - - 0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00 Introduce package to capture dependency on C++ stdlib Here we introduce a new "virtual" package into the initial package database, `system-cxx-std-lib`. This gives users a convenient, platform agnostic way to link against C++ libraries, addressing #20010. Fixes #20010. - - - - - 03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Add tests for system-cxx-std-lib package Test that we can successfully link against C++ code both in GHCi and batch compilation. See #20010 - - - - - 5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00 OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420) - - - - - eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00 Adjust flags for pprTrace We were using defaultSDocContext for pprTrace, which suppresses lots of useful infomation. This small MR adds GHC.Utils.Outputable.traceSDocContext and uses it for pprTrace and pprTraceUserWarning. traceSDocContext is a global, and hence not influenced by flags, but that seems unavoidable. But I made the sdocPprDebug bit controlled by unsafeHasPprDebug, since we have the latter for exactly this purpose. Fixes #21569 - - - - - d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00 Fix bad interaction between withDict and the Specialiser This MR fixes a bad bug, where the withDict was inlined too vigorously, which in turn made the type-class Specialiser generate a bogus specialisation, because it saw the same overloaded function applied to two /different/ dictionaries. Solution: inline `withDict` later. See (WD8) of Note [withDict] in GHC.HsToCore.Expr See #21575, which is fixed by this change. - - - - - 70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00 Bump time submodule to 1.12.2 This bumps the time submodule to the 1.12.2 release. Fixes #21571 - - - - - 2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00 Remove unused test files (#21582) Those files were moved to the perf/ subtree in 11c9a469, and then accidentally reintroduced in 680ef2c8. - - - - - cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00 CafAnal: Improve code clarity Here we implement a few measures to improve the clarity of the CAF analysis implementation. Specifically: * Use CafInfo instead of Bool since the former is more descriptive * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact CAFs * Add numerous comments - - - - - b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00 codeGen: Ensure that static datacon apps are included in SRTs When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT filters out recursive references, as described in Note [recursive SRTs]. However, doing so for static functions would be unsound, for the reason described in Note [Invalid optimisation: shortcutting]. However, the same argument applies to static data constructor applications, as we discovered in #20959. Fix this by ensuring that static data constructor applications are included in recursive SRTs. The approach here is not entirely satisfactory, but it is a starting point. Fixes #20959. - - - - - 0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00 Add test for #21558 This is now fixed on master and 9.2 branch. Closes #21558 - - - - - ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00 Don't store LlvmConfig into DynFlags LlvmConfig contains information read from llvm-passes and llvm-targets files in GHC's top directory. Reading these files is done only when needed (i.e. when the LLVM backend is used) and cached for the whole compiler session. This patch changes the way this is done: - Split LlvmConfig into LlvmConfig and LlvmConfigCache - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no good reason to store it in DynFlags. As it is fixed per session, we store it in the session state instead (HscEnv). - Initializing LlvmConfigCache required some changes to driver functions such as newHscEnv. I've used the opportunity to untangle initHscEnv from initGhcMonad (in top-level GHC module) and to move it to GHC.Driver.Main, close to newHscEnv. - I've also made `cmmPipeline` independent of HscEnv in order to remove the call to newHscEnv in regalloc_unit_tests. - - - - - 828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00 Give all EXTERN_INLINE closure macros prototypes - - - - - cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Introduce [sg]etFinalizerExceptionHandler This introduces a global hook which is called when an exception is thrown during finalization. - - - - - 372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Throw exceptions raised while closing finalized Handles Fixes #21336. - - - - - 3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00 testsuite: Add tests for #21336 - - - - - 297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00 Add release flavour and use it for the release jobs The release flavour is essentially the same as the perf flavour currently but also enables `-haddock`. I have hopefully updated all the relevant places where the `-perf` flavour was hardcoded. Fixes #21486 - - - - - a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Don't build sphinx documentation on centos The centos docker image lacks the sphinx builder so we disable building sphinx docs for these jobs. Fixes #21580 - - - - - 209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Use correct syntax when args list is empty This seems to fail on the ancient version of bash present on CentOS - - - - - 02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00 hadrian: Don't attempt to build dynamic profiling libraries We only support building static profiling libraries, the transformer was requesting things like a dynamic, threaded, debug, profiling RTS, which we have never produced nor distributed. Fixes #21567 - - - - - 35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00 configure: Check CC_STAGE0 for --target support We previously only checked the stage 1/2 compiler for --target support. We got away with this for quite a while but it eventually caught up with us in #21579, where `bytestring`'s new NEON implementation was unbuildable on Darwin due to Rosetta's seemingly random logic for determining which executable image to execute. This lead to a confusing failure to build `bytestring`'s cbits, when `clang` tried to compile NEON builtins while targetting x86-64. Fix this by checking CC_STAGE0 for --target support. Fixes #21579. - - - - - 0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator analysis of `CmmGraph` This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper around two existing algorithms in GHC: the Lengauer-Tarjan dominator analysis from the X86 back end and the reverse postorder ordering from the Cmm Dataflow framework. Issue #20726 proposes that we evaluate some alternatives for dominator analysis, but for the time being, the best path forward is simply to use the existing analysis on `CmmGraph`s. This commit addresses a bullet in #21200. - - - - - 54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator-tree function - - - - - 05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add HasDebugCallStack; remove unneeded extensions - - - - - 0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00 document fields of `DominatorSet` - - - - - 8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00 nonmoving: Fix documentation of GC statistics fields These were previously incorrect. Fixes #21553. - - - - - c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00 Remove pprTrace from pushCoercionIntoLambda (#21555) This firstly caused spurious output to be emitted (as evidenced by #21555) but even worse caused a massive coercion to be attempted to be printed (> 200k terms) which would invariably eats up all the memory of your computer. The good news is that removing this trace allows the program to compile to completion, the bad news is that the program exhibits a core lint error (on 9.0.2) but not any other releases it seems. Fixes #21577 and #21555 - - - - - a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00 docs: Fix LlvmVersion in manpage (#21280) - - - - - 36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00 validate: Use $make rather than make In the validate script we are careful to use the $make variable as this stores whether we are using gmake, make, quiet mode etc. There was just this one place where we failed to use it. Fixes #21598 - - - - - 4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00 Change `Backend` type and remove direct dependencies With this change, `Backend` becomes an abstract type (there are no more exposed value constructors). Decisions that were formerly made by asking "is the current back end equal to (or different from) this named value constructor?" are now made by interrogating the back end about its properties, which are functions exported by `GHC.Driver.Backend`. There is a description of how to migrate code using `Backend` in the user guide. Clients using the GHC API can find a backdoor to access the Backend datatype in GHC.Driver.Backend.Internal. Bumps haddock submodule. Fixes #20927 - - - - - ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00 Respect DESTDIR in hadrian bindist Makefile, fixes #19646 - - - - - 7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00 Test DESTDIR in test_hadrian() - - - - - ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00 Consider the stage of typeable evidence when checking stage restriction We were considering all Typeable evidence to be "BuiltinInstance"s which meant the stage restriction was going unchecked. In-fact, typeable has evidence and so we need to apply the stage restriction. This is complicated by the fact we don't generate typeable evidence and the corresponding DFunIds until after typechecking is concluded so we introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which records whether the evidence is going to be local or not. Fixes #21547 - - - - - ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00 Modularize GHC.Core.Opt.LiberateCase Progress towards #17957 - - - - - bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00 Improve FloatOut and SpecConstr This patch addresses a relatively obscure situation that arose when chasing perf regressions in !7847, which itself is fixing It does two things: * SpecConstr can specialise on ($df d1 d2) dictionary arguments * FloatOut no longer checks argument strictness See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr. A test case is difficult to construct, but it makes a big difference in nofib/real/eff/VSM, at least when we have the patch for #21286 installed. (The latter stops worker/wrapper for dictionary arguments). There is a spectacular, but slightly illusory, improvement in runtime perf on T15426. I have documented the specifics in T15426 itself. Metric Decrease: T15426 - - - - - 1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00 Make debug a `Bool` not an `Int` in `StgToCmmConfig` We don't need any more resolution than this. Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer conveying any "level" information. - - - - - e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00 EPA : Remove duplicate comments in DataFamInstD The code data instance Method PGMigration = MigrationQuery Query -- ^ Run a query against the database | MigrationCode (Connection -> IO (Either String ())) -- ^ Run any arbitrary IO code Resulted in two instances of the "-- ^ Run a query against the database" comment appearing in the Exact Print Annotations when it was parsed. Ensure only one is kept. Closes #20239 - - - - - e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00 EPA: Comment Order Reversed Make sure comments captured in the exact print annotations are in order of increasing location Closes #20718 - - - - - 4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Add test for T21455 - - - - - e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Allow passing -po outside profiling way Resolves #21455 - - - - - 3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00 Fix haddock_*_perf tests on non-GNU-grep systems Using regexp pattern requires `egrep` and straight up `+`. The haddock_parser_perf and haddock_renamer_perf tests now pass on OpenBSD. They previously incorrectly parsed the files and awk complained about invalid syntax. - - - - - 1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00 hadrian/bindist: Drop redundant include of install.mk `install.mk` is already included by `config.mk`. Moreover, `install.mk` depends upon `config.mk` to set `RelocatableBuild`, making this first include incorrect. - - - - - f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00 Remove -z wxneeded for OpenBSD With all the recent W^X fixes in the loader this workaround is not necessary any longer. I verified that the only tests failing for me on OpenBSD 7.1-current are the same (libc++ related) before and after this commit (with --fast). - - - - - 7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00 Use UnionListsOrd instead of UnionLists in most places. This should get rid of most, if not all "Overlong lists" errors and fix #20016 - - - - - 81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00 Fix #21563 by using Word64 for 64bit shift code. We use the 64bit shifts only on 64bit platforms. But we compile the code always so compiling it on 32bit caused a lint error. So use Word64 instead. - - - - - 2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00 Fix compilation with -haddock on GHC <= 8.10 -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors when it encounters invalid haddock syntax. This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b enabled -haddock by default on many flavours. Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem managed to slip throught the cracks. - - - - - cfb9faff by sheaf at 2022-05-24T22:15:12-04:00 Hadrian: don't add "lib" for relocatable builds The conditional in hadrian/bindist/Makefile depended on the target OS, but it makes more sense to use whether we are using a relocatable build. (Currently this only gets set to true on Windows, but this ensures that the logic stays correctly coupled.) - - - - - 9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00 Remove HscEnv from GHC.HsToCore.Usage (related to #17957) Metric Decrease: T16875 - - - - - 2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00 SimpleOpt: beta-reduce through casts The simple optimiser would sometimes fail to beta-reduce a lambda when there were casts in between the lambda and its arguments. This can cause problems because we rely on representation-polymorphic lambdas getting beta-reduced away (for example, those that arise from newtype constructors with representation-polymorphic arguments, with UnliftedNewtypes). - - - - - e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00 Desugar RecordUpd in `tcExpr` This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule - - - - - 2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00 update README - - - - - 3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00 Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602) - - - - - ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00 Add Haddocks for `WwOpts` - - - - - da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00 Avoid global compiler state for `GHC.Core.Opt.WorkWrap` Progress towards #17957 - - - - - 3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00 Optimiser: avoid introducing bad rep-poly The functions `pushCoValArg` and `pushCoercionIntoLambda` could introduce bad representation-polymorphism. Example: type RR :: RuntimeRep type family RR where { RR = IntRep } type F :: TYPE RR type family F where { F = Int# } co = GRefl F (TYPE RR[0]) :: (F :: TYPE RR) ~# (F |> TYPE RR[0] :: TYPE IntRep) f :: F -> () `pushCoValArg` would transform the unproblematic application (f |> (co -> <()>)) (arg :: F |> TYPE RR[0]) into an application in which the argument does not have a fixed `RuntimeRep`: f ((arg |> sym co) :: (F :: TYPE RR)) - - - - - b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00 executablePath test: fix file extension treatment The executablePath test strips the file extension (if any) when comparing the query result with the expected value. This is to handle platforms where GHC adds a file extension to the output program file (e.g. .exe on Windows). After the initial check, the file gets deleted (if supported). However, it tries to delete the *stripped* filename, which is incorrect. The test currently passes only because Windows does not allow deleting the program while any process created from it is alive. Make the test program correct in general by deleting the *non-stripped* executable filename. - - - - - afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00 fix executablePath test for NetBSD executablePath support for NetBSD was added in a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not updated. Update the test so that it works for NetBSD. This requires handling some quirks: - The result of getExecutablePath could include "./" segments. Therefore use System.FilePath.equalFilePath to compare paths. - The sysctl(2) call returns the original executable name even after it was deleted. Add `canQueryAfterDelete :: [FilePath]` and adjust expectations for the post-delete query accordingly. Also add a note to the `executablePath` haddock to advise that NetBSD behaves differently from other OSes when the file has been deleted. Also accept a decrease in memory usage for T16875. On Windows, the metric is -2.2% of baseline, just outside the allowed ±2%. I don't see how this commit could have influenced this metric, so I suppose it's something in the CI environment. Metric Decrease: T16875 - - - - - d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00 Factor out `initArityOps` to `GHC.Driver.Config.*` module We want `DynFlags` only mentioned in `GHC.Driver`. - - - - - 44bb7111 by romes at 2022-05-26T16:27:57+00:00 TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs - - - - - 88e58600 by sheaf at 2022-05-26T17:38:43-04:00 Add tests for eta-expansion of data constructors This patch adds several tests relating to the eta-expansion of data constructors, including UnliftedNewtypes and DataTypeContexts. - - - - - d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00 Generalize breakTyVarCycle to work with TyFamLHS The function breakTyVarCycle_maybe has been installed in a dark corner of GHC to catch some gremlins (a.k.a. occurs-check failures) who lurk there. But it previously only caught gremlins of the form (a ~ ... F a ...), where some of our intrepid users have spawned gremlins of the form (G a ~ ... F (G a) ...). This commit improves breakTyVarCycle_maybe (and renames it to breakTyEqCycle_maybe) to catch the new gremlins. Happily, the change is remarkably small. The gory details are in Note [Type equality cycles]. Test cases: typecheck/should_compile/{T21515,T21473}. - - - - - ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00 [base] Fix the links in the Data.Data module fix #21658 fix #21657 fix #21657 - - - - - 3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00 Use a class to check validity of withDict This moves handling of the magic 'withDict' function from the desugarer to the typechecker. Details in Note [withDict]. I've extracted a part of T16646Fail to a separate file T16646Fail2, because the new error in 'reify' hides the errors from 'f' and 'g'. WithDict now works with casts, this fixes #21328. Part of #19915 - - - - - b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00 Fix FreeVars computation for mdo Commit acb188e0 introduced a regression in the computation of free variables in mdo statements, as the logic in GHC.Rename.Expr.segmentRecStmts was slightly different depending on whether the recursive do block corresponded to an mdo statement or a rec statment. This patch restores the previous computation for mdo blocks. Fixes #21654 - - - - - 0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00 T16875: Stabilise (temporarily) by increasing acceptance threshold The theory is that on windows there is some difference in the environment between pipelines on master and merge requests which affects all tests equally but because T16875 barely allocates anything it is the test which is affected the most. See #21557 - - - - - 6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00 make: Fix make maintainer-clean deleting a file tracked by source control Fixes #21659 - - - - - fbf2f254 by Andrew Lelechenko at 2022-05-28T21:01:58-04:00 Expand documentation of hIsTerminalDevice - - - - - 0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00 export IsList from GHC.IsList it is still re-exported from GHC.Exts - - - - - 91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00 MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR ARM64_RELOC_SUBTRACTOR relocations are paired with an AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2 The linker was doing it in two steps, basically: *addend <- *addend - sym2 *addend <- *addend + sym1 The first operation was likely to overflow. For example when the relocation target was 32-bit and both sym1/sym2 were 64-bit addresses. With the small memory model, (sym1-sym2) would fit in 32 bits but (*addend-sym2) may not. Now the linker does it in one step: *addend <- *addend + sym1 - sym2 - - - - - acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Some fixes to SRT documentation - reordered the 3 SRT implementation cases from the most general to the most specific one: USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD - added requirements for each - found and documented a confusion about "SRT inlining" not supported with MachO. (It is fixed in the following commit) - - - - - 5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Enable USE_INLINE_SRT_FIELD on ARM64 It was previously disabled because of: - a confusion about "SRT inlining" (see removed comment in this commit) - a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR relocation: fixed by a previous commit. - - - - - 59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00 ci: Make sure to exit promptly if `make install` fails. Due to the vageries of bash, you have to explicitly handle the failure and exit when in a function. This failed to exit promptly when !8247 was failing. See #21358 for the general issue - - - - - 5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00 Split GHC.HsToCore.Foreign.Decl This is preliminary work for JavaScript support. It's better to put the code handling the desugaring of Prim, C and JavaScript declarations into separate modules. - - - - - 6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00 Bump hadrian to LTS-19.8 (GHC 9.0.2) - - - - - f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00 Hadrian: remove unused code - - - - - 2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Eta reduction with casted function We want to be able to eta-reduce \x y. ((f x) |> co) y by pushing 'co' inwards. A very small change accommodates this See Note [Eta reduction with casted function] - - - - - f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Do arity trimming at bindings, rather than in exprArity Sometimes there are very large casts, and coercionRKind can be slow. - - - - - 610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make findRhsArity take RecFlag This avoids a fixpoint iteration for the common case of non-recursive bindings. - - - - - 80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Comments and white space - - - - - 0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make PrimOpId record levity This patch concerns #20155, part (1) The general idea is that since primops have curried bindings (currently in PrimOpWrappers.hs) we don't need to eta-expand them. But we /do/ need to eta-expand the levity-polymorphic ones, because they /don't/ have bindings. This patch makes a start in that direction, by identifying the levity-polymophic primops in the PrimOpId IdDetails constructor. For the moment, I'm still eta-expanding all primops (by saying that hasNoBinding returns True for all primops), because of the bug reported in #20155. But I hope that before long we can tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding. - - - - - 6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: * Move state-hack stuff from GHC.Types.Id (where it never belonged) to GHC.Core.Opt.Arity (which seems much more appropriate). * Add a crucial mkCast in the Cast case of GHC.Core.Opt.Arity.eta_expand; helps with T18223 * Add clarifying notes about eta-reducing to PAPs. See Note [Do not eta reduce PAPs] * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity, where it properly belongs. See Note [Eta reduce PAPs] * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for when eta-expansion is wanted, to make wantEtaExpansion, and all that same function in GHC.Core.Opt.Simplify.simplStableUnfolding. It was previously inconsistent, but it's doing the same thing. * I did a substantial refactor of ArityType; see Note [ArityType]. This allowed me to do away with the somewhat mysterious takeOneShots; more generally it allows arityType to describe the function, leaving its clients to decide how to use that information. I made ArityType abstract, so that clients have to use functions to access it. * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called mkLam before) aware of the floats that the simplifier builds up, so that it can still do eta-reduction even if there are some floats. (Previously that would not happen.) That means passing the floats to rebuildLam, and an extra check when eta-reducting (etaFloatOk). * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info in the idDemandInfo of the binder, as well as the CallArity info. The occurrence analyser did this but we were failing to take advantage here. In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity; see Note [Combining arityType with demand info], and functions idDemandOneShots and combineWithDemandOneShots. (These changes partly drove my refactoring of ArityType.) * In GHC.Core.Opt.Arity.findRhsArity * I'm now taking account of the demand on the binder to give extra one-shot info. E.g. if the fn is always called with two args, we can give better one-shot info on the binders than if we just look at the RHS. * Don't do any fixpointing in the non-recursive case -- simple short cut. * Trim arity inside the loop. See Note [Trim arity inside the loop] * Make SimpleOpt respect the eta-reduction flag (Some associated refactoring here.) * I made the CallCtxt which the Simplifier uses distinguish between recursive and non-recursive right-hand sides. data CallCtxt = ... | RhsCtxt RecFlag | ... It affects only one thing: - We call an RHS context interesting only if it is non-recursive see Note [RHS of lets] in GHC.Core.Unfold * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification. See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep. Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg Metrics: compile_time/bytes allocated Test Metric Baseline New value Change --------------------------------------------------------------------------------------- MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,743,297,692 2,619,762,992 -4.5% GOOD T18223(normal) ghc/alloc 1,103,161,360 972,415,992 -11.9% GOOD T3064(normal) ghc/alloc 201,222,500 184,085,360 -8.5% GOOD T8095(normal) ghc/alloc 3,216,292,528 3,254,416,960 +1.2% T9630(normal) ghc/alloc 1,514,131,032 1,557,719,312 +2.9% BAD parsing001(normal) ghc/alloc 530,409,812 525,077,696 -1.0% geo. mean -0.1% Nofib: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- banner +0.0% +0.4% -8.9% -8.7% 0.0% exact-reals +0.0% -7.4% -36.3% -37.4% 0.0% fannkuch-redux +0.0% -0.1% -1.0% -1.0% 0.0% fft2 -0.1% -0.2% -17.8% -19.2% 0.0% fluid +0.0% -1.3% -2.1% -2.1% 0.0% gg -0.0% +2.2% -0.2% -0.1% 0.0% spectral-norm +0.1% -0.2% 0.0% 0.0% 0.0% tak +0.0% -0.3% -9.8% -9.8% 0.0% x2n1 +0.0% -0.2% -3.2% -3.2% 0.0% -------------------------------------------------------------------------------- Min -3.5% -7.4% -58.7% -59.9% 0.0% Max +0.1% +2.2% +32.9% +32.9% 0.0% Geometric Mean -0.0% -0.1% -14.2% -14.8% -0.0% Metric Decrease: MultiLayerModulesTH_OneShot T18223 T3064 T15185 T14766 Metric Increase: T9630 - - - - - cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00 hadrian: Fix building from source-dist without alex/happy This fixes two bugs which were adding dependencies on alex/happy when building from a source dist. * When we try to pass `--with-alex` and `--with-happy` to cabal when configuring but the builders are not set. This is fixed by making them optional. * When we configure, cabal requires alex/happy because of the build-tool-depends fields. These are now made optional with a cabal flag (build-tool-depends) for compiler/hpc-bin/genprimopcode. Fixes #21627 - - - - - a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test the bootstrap without ALEX/HAPPY on path - - - - - 0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test bootstrapping in release jobs - - - - - d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label - - - - - 18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00 rts: Remove explicit timescale for deprecating -h flag We originally planned to remove the flag in 9.4 but there's actually no great rush to do so and it's probably less confusing (forever) to keep the message around suggesting an explicit profiling option. Fixes #21545 - - - - - eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00 Enable -dlint in hadrian lint transformer Now #21563 is fixed we can properly enable `-dlint` in CI rather than a subset of the flags. - - - - - 0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00 upload-ghc-libs: Allow candidate-only upload - - - - - 83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00 Avoid using DynFlags in GHC.Linker.Unit (#17957) - - - - - 5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00 hadrian: Introduce new package database for executables needed to build stage0 These executables (such as hsc2hs) are built using the boot compiler and crucially, most libraries from the global package database. We also move other build-time executables to be built in this stage such as linters which also cleans up which libraries end up in the global package database. This allows us to remove hacks where linters-common is removed from the package database when a bindist is created. This fixes issues caused by infinite recursion due to bytestring adding a dependency on template-haskell. Fixes #21634 - - - - - 0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00 Build stage1 with -V as well This helps tracing errors which happen when building stage1 - - - - - 15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00 Revert "packaging: Build perf builds with -split-sections" This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f. Split sections causes segfaults in profiling way with old toolchains (deb9) and on windows (#21670) Fixes #21670 - - - - - d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00 Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard Progress towards #17957 Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other modules as thoroughly as I usually do. This does mean that risk of `DynFlags` "creeping back in" is higher than it usually is. After we do the same process to the other Core passes, and then figure out what we want to do about `CoreM`, we can finish the job started here. That is a good deal more work, however, so it certainly makes sense to land this now. - - - - - a720322f by romes at 2022-06-01T07:44:44-04:00 Restore Note [Quasi-quote overview] - - - - - 392ce3fc by romes at 2022-06-01T07:44:44-04:00 Move UntypedSpliceFlavour from L.H.S to GHC.Hs UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr` but was defined in the client-independent L.H.S.Expr. - - - - - 7975202b by romes at 2022-06-01T07:44:44-04:00 TTG: Rework and improve splices This commit redefines the structure of Splices in the AST. We get rid of `HsSplice` which used to represent typed and untyped splices, quasi quotes, and the result of splicing either an expression, a type or a pattern. Instead we have `HsUntypedSplice` which models an untyped splice or a quasi quoter, which works in practice just like untyped splices. The `HsExpr` constructor `HsSpliceE` which used to be constructed with an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The former is directly constructed with an `HsExpr` and the latter now takes an `HsUntypedSplice`. Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now take an `HsUntypedSplice` instead of a `HsSplice` (remember only /untyped splices/ can be spliced as types or patterns). The result of splicing an expression, type, or pattern is now comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`, `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult (HsExpr GhcRn)` Overall the TTG extension points are now better used to make invalid states unrepresentable and model the progression between stages better. See Note [Lifecycle of an untyped splice, and PendingRnSplice] and Note [Lifecycle of an typed splice, and PendingTcSplice] for more details. Updates haddock submodule Fixes #21263 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - 320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00 Add test for #21619 Fixes #21619 - - - - - ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00 Pure Haskell implementation of GHC.Unicode Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/). Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691. - Remove current Unicode cbits. - Add generator for Unicode property files from Unicode Character Database. - Generate internal modules. - Update GHC.Unicode. - Add unicode003 test for general categories and case mappings. - Add Python scripts to check 'base' Unicode tests outputs and characters properties. Fixes #21375 ------------------------- Metric Decrease: T16875 Metric Increase: T4029 T18304 haddock.base ------------------------- - - - - - 514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00 typos - - - - - 9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00 source-dist: Copy in files created by ./boot Since we started producing source dists with hadrian we stopped copying in the files created by ./boot which adds a dependency on python3 and autoreconf. This adds back in the files which were created by running configure. Fixes #21673 #21672 and #21626 - - - - - a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00 ci: Don't try to run ./boot when testing bootstrap of source dist - - - - - e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00 Language.Haskell.Syntax: Fix docs for PromotedConsT etc. Fixes ghc/ghc#21675. - - - - - 87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump bytestring, process, and text submodules Metric Decrease: T5631 Metric Increase: T18223 (cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af) - - - - - 24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump Cabal submodule To current `master`. (cherry picked from commit fbb59c212415188486aafd970eafef170516356a) - - - - - 5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00 hadrian/tool-args: Write output to intermediate file rather than via stdout This allows us to see the output of hadrian while it is doing the setup. - - - - - 468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00 Make -fcompact-unwind the default This is a follow-up to !7247 (closed) making the inclusion of compact unwinding sections the default. Also a slight refactoring/simplification of the flag handling to add -fno-compact-unwind. - - - - - 819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00 hadrian bootstrap: add plans for 9.0.2 and 9.2.3 - - - - - 9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00 ci: Add matrix for bootstrap sources - - - - - ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00 HsToCore.Coverage: Improve haddocks - - - - - f065804e by John Ericson at 2022-06-02T15:42:59+00:00 Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller No need to inline traversing a maybe for `mkModBreaks`. And better to make each function do one thing and let the caller deside when than scatter the decision making and make the caller seem more imperative. - - - - - d550d907 by John Ericson at 2022-06-02T15:42:59+00:00 Rename `HsToCore.{Coverage -> Ticks}` The old name made it confusing why disabling HPC didn't disable the entire pass. The name makes it clear --- there are other reasons to add ticks in addition. - - - - - 6520da95 by John Ericson at 2022-06-02T15:42:59+00:00 Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq` As proposed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676, `GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and backend-specific (only for the bytecode interpreter), and mix entry writing is just for HPC. With this split we separate out those interpreter- and HPC-specific its, and keep the main `GHC.HsToCore.Ticks` agnostic. Also, instead of passing the reversed list and count around, we use `SizedSeq` which abstracts over the algorithm. This is much nicer to avoid noise and prevents bugs. (The bugs are not just hypothetical! I missed up the reverses on an earlier draft of this commit.) - - - - - 1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00 GHC.HsToCore.Breakpoints: Slightly improve perf We have the length already, so we might as well use that rather than O(n) recomputing it. - - - - - 5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00 HsToCore.Coverage: Purge DynFlags Finishes what !7467 (closed) started. Progress towards #17957 - - - - - 9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00 Deprecate TypeInType extension This commit fixes #20312 It deprecates "TypeInType" extension according to the following proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst It has been already implemented. The migration strategy: 1. Disable TypeInType 2. Enable both DataKinds and PolyKinds extensions Metric Decrease: T16875 - - - - - f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00 Diagnostics conversions, part 6 (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and `GHC.Tc.Gen.Sig`. - - - - - 04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00 Ensure floated dictionaries are in scope (again) In the Specialiser, we missed one more call to bringFloatedDictsIntoScope (see #21391). This omission led to #21689. The problem is that the call to `rewriteClassOps` needs to have in scope any dictionaries floated out of the arguments we have just specialised. Easy fix. - - - - - a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00 Don't print the number of deps in count-deps tests It is redundant information and a source of needless version control conflicts when multiple MRs are changing the deps list. Just printing the list and not also its length is fine. - - - - - a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00 Core.Lint: Reduce `DynFlags` and `HscEnv` Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com> - - - - - 56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00 Fix a CSE shadowing bug. We used to process the rhs of non-recursive bindings and their body using the same env. If we had something like let x = ... x ... this caused trouble because the two xs refer to different binders but we would substitute both for a new binder x2 causing out of scope errors. We now simply use two different envs for the rhs and body in cse_bind. It's all explained in the Note [Separate envs for let rhs and body] Fixes #21685 - - - - - 28880828 by sheaf at 2022-06-09T09:12:19-04:00 Typecheck remaining ValArgs in rebuildHsApps This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it to tcRemainingValArgs. The logic is moved to rebuildHsApps, which ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg. This patch also refactors the treatment of stupid theta for data constructors, changing the place we drop stupid theta arguments from dsConLike to mkDataConRep (now the datacon wrapper drops these arguments). We decided not to implement PHASE 2 of the FixedRuntimeRep plan for these remaining ValArgs. Future directions are outlined on the wiki: https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs Fixes #21544 and #21650 - - - - - 1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00 Add test for T21682 Fixes #21682 - - - - - 8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00 Document dataToTag# primop - - - - - 7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00 Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115 - - - - - 46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00 Fix TcRnPragmaWarning meaning - - - - - 69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00 getProcessCPUTime: Fix the getrusage fallback to account for system CPU time clock_gettime reports the combined total or user AND system time so in order to replicate it with getrusage we need to add both system and user time together. See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime Some sample measurements when building Cabal with this patch t1: rusage t2: clock_gettime t1: 62347518000; t2: 62347520873 t1: 62395687000; t2: 62395690171 t1: 62432435000; t2: 62432437313 t1: 62478489000; t2: 62478492465 t1: 62514990000; t2: 62514992534 t1: 62515479000; t2: 62515480327 t1: 62515485000; t2: 62515486344 Fixes #21656 - - - - - 722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00 Use <br> instead of newline character - - - - - dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00 Use (fixed_lev = True) in mkDataTyConRhs - - - - - ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00 hadrian: Fix testing stage1 compiler There were various issues with testing the stage1 compiler.. 1. The wrapper was not being built 2. The wrapper was picking up the stage0 package database and trying to load prelude from that. 3. The wrappers never worked on windows so just don't support that for now. Fixes #21072 - - - - - ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00 validate: Ensure that $make variable is set Currently the `$make` variable is used without being set in `validate`'s Hadrian path, which uses make to install the binary distribution. Fix this. Fixes #21687. - - - - - 59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00 CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv` The call sites in `Driver.Main` are duplicative, but this is good, because the next step is to remove `InteractiveContext` from `Core.Lint` into `Core.Lint.Interactive`. Also further clean up `Core.Lint` to use a better configuration record than the one we initially added. - - - - - aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00 hadrian: Run xattr -rc . on bindist tarball Fixes #21506. - - - - - cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00 configure: Hide spurious warning from ld Previously the check_for_gold_t22266 configure check could result in spurious warnings coming from the linker being blurted to stderr. Suppress these by piping stderr to /dev/null. - - - - - e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00 cmm: Add surface syntax for MO_MulMayOflo - - - - - bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00 configure: Don't attempt to override linker on Darwin Configure's --enable-ld-override functionality is intended to ensure that we don't rely on ld.bfd, which tends to be slow and buggy, on Linux and Windows. However, on Darwin the lack of sensible package management makes it extremely easy for users to have awkward mixtures of toolchain components from, e.g., XCode, the Apple Command-Line Tools package, and homebrew. This leads to extremely confusing problems like #21712. Here we avoid this by simply giving up on linker selection on Darwin altogether. This isn't so bad since the Apple ld64 linker has decent performance and AFAICT fairly reliable. Closes #21712. - - - - - 25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00 replace quadratic nub to fight byte code gen perf explosion Despite this code having been present in the core-to-bytecode implementation, I have observed it in the wild starting with 9.2, causing enormous slowdown in certain situations. My test case produces the following profiles: Before: ``` total time = 559.77 secs (559766 ticks @ 1000 us, 1 processor) total alloc = 513,985,665,640 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes elem_by Data.OldList libraries/base/Data/OldList.hs:429:1-7 67.6 92.9 378282 477447404296 eqInt GHC.Classes libraries/ghc-prim/GHC/Classes.hs:275:8-14 12.4 0.0 69333 32 $c>>= GHC.Data.IOEnv <no location info> 6.9 0.6 38475 3020371232 ``` After: ``` total time = 89.83 secs (89833 ticks @ 1000 us, 1 processor) total alloc = 39,365,306,360 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes $c>>= GHC.Data.IOEnv <no location info> 43.6 7.7 39156 3020403424 doCase GHC.StgToByteCode compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53) 2.5 7.4 2246 2920777088 ``` - - - - - aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00 hadrian: Don't install `include/` directory in bindist. The install_includes for the RTS package used to be put in the top-level ./include folder but this would lead to confusing things happening if you installed multiple GHC versions side-by-side. We don't need this folder anymore because install-includes is honoured properly by cabal and the relevant header files already copied in by the cabal installation process. If you want to depend on the header files for the RTS in a Haskell project then you just have to depend on the `rts` package and the correct include directories will be provided for you. If you want to depend on the header files in a standard C project then you should query ghc-pkg to get the right paths. ``` ghc-pkg field rts include-dirs --simple-output ``` Fixes #21609 - - - - - 03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00 Enable eventlogs on nightly perf job - - - - - ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00 Repair dead link in TH haddocks Closes #21724 - - - - - 99ff3818 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian: allow configuring Hsc2Hs This patch adds the ability to pass options to Hsc2Hs as Hadrian key/value settings, in the same way as cabal configure options, using the syntax: *.*.hsc2hs.run.opts += ... - - - - - 9c575f24 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian bootstrap: look up hsc2hs Hadrian bootstrapping looks up where to find ghc_pkg, but the same logic was not in place for hsc2hs which meant we could fail to find the appropriate hsc2hs executabe when bootstrapping Hadrian. This patch adds that missing logic. - - - - - 229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Add (broken) test for #21622 - - - - - cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Don't Box NULL pointers Previously we could construct a `Box` of a NULL pointer from the `link` field of `StgWeak`. Now we take care to avoid ever introducing such pointers in `collect_pointers` and ensure that the `link` field is represented as a `Maybe` in the `Closure` type. Fixes #21622 - - - - - 31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00 winio: Add support to console handles to handleToHANDLE - - - - - 711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Add SMUL[LH] instructions These will be needed to fix #21624. - - - - - d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Fix syntax of OpRegShift operands Previously this produced invalid assembly containing a redundant comma. - - - - - a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00 ncg/aarch64: Fix implementation of IntMulMayOflo The code generated for IntMulMayOflo was previously wrong as it depended upon the overflow flag, which the AArch64 MUL instruction does not set. Fix this. Fixes #21624. - - - - - 26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00 testsuite: Add test for #21624 Ensuring that mulIntMayOflo# behaves as expected. - - - - - 94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00 CprAnal: Set signatures of DFuns to top The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal that is observable in a debug build. The CPR signature of a recursive DFunId was never updated and hence the optimistic arity 0 bottom signature triggered a mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any code because WW doesn't exploit bottom CPR signatures. - - - - - b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00 CorePrep: Don't speculatively evaluate recursive calls (#20836) In #20836 we have optimised a terminating program into an endless loop, because we speculated the self-recursive call of a recursive DFun. Now we track the set of enclosing recursive binders in CorePrep to prevent speculation of such self-recursive calls. See the updates to Note [Speculative evaluation] for details. Fixes #20836. - - - - - 49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00 Simplify: Take care with eta reduction in recursive RHSs (#21652) Similar to the fix to #20836 in CorePrep, we now track the set of enclosing recursive binders in the SimplEnv and SimpleOptEnv. See Note [Eta reduction in recursive RHSs] for details. I also updated Note [Arity robustness] with the insights Simon and I had in a call discussing the issue. Fixes #21652. Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation of a large list literal at the top-level that didn't happen before (presumably because it was too interesting to float to the top-level). There's not much we can do about that. Metric Increase: T16577 - - - - - 2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00 Ignore .hie-bios - - - - - e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00 Instantiate top level foralls in partial type signatures The main fix for #21667 is the new call to tcInstTypeBnders in tcHsPartialSigType. It was really a simple omission before. I also moved the decision about whether we need to apply the Monomorphism Restriction, from `decideGeneralisationPlan` to `tcPolyInfer`. That removes a flag from the InferGen constructor, which is good. But more importantly, it allows the new function, checkMonomorphismRestriction called from `tcPolyInfer`, to "see" the `Types` involved rather than the `HsTypes`. And that in turn matters because we invoke the MR for partial signatures if none of the partial signatures in the group have any overloading context; and we can't answer that question for HsTypes. See Note [Partial type signatures and the monomorphism restriction] in GHC.Tc.Gen.Bind. This latter is really a pre-existing bug. - - - - - 262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00 Make Outputable instance for InlineSig print the InlineSpec Fix ghc/ghc#21739 Squash fix ghc/ghc#21739 - - - - - b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00 Add NO_BOOT to hackage_doc_tarball job We were attempting to boot a src-tarball which doesn't work as ./boot is not included in the source tarball. This slipped through as the job is only run on nightly. - - - - - d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00 HsToken for @-patterns and TypeApplications (#19623) One more step towards the new design of EPA. - - - - - 159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00 linker: only keep rtl exception tables if they have been relocated - - - - - da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00 Ticky:Make json info a separate field. - - - - - 1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00 Revert "Ticky:Make json info a separate field." This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862. This was pushed directly without review. - - - - - f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00 Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags These flags affect the behaviour of local let floating. If `-flocal-float-out` is disabled (the default) then we disable all local floating. ``` …(let x = let y = e in (a,b) in body)... ===> …(let y = e; x = (a,b) in body)... ``` Further to this, top-level local floating can be disabled on it's own by passing -fno-local-float-out-top-level. ``` x = let y = e in (a,b) ===> y = e; x = (a,b) ``` Note that this is only about local floating, ie, floating two adjacent lets past each other and doesn't say anything about the global floating pass which is controlled by `-fno-float`. Fixes #13663 - - - - - 4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00 Check for Int overflows in Data.Array.Byte - - - - - 2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00 Add a basic test for ByteArray's Monoid instance - - - - - fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00 Rename `copyByteArray` to `unsafeCopyByteArray` - - - - - ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00 testsuite: Add test for #21719 Happily, this has been fixed since 9.2. - - - - - 19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Use lookupNameCache instead of lookupOrigIO - - - - - 4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Break out thNameToGhcNameIO (ref. #21730) - - - - - eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00 Add laws for 'toInteger' and 'toRational' CLC discussion here: https://github.com/haskell/core-libraries-committee/issues/58 - - - - - c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00 Correct documentation of defaults of the `-V` RTS option - - - - - b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00 Transcribe discussion from #21483 into a Note In #21483 I had a discussion with Simon Marlow about the memory retention behaviour of -Fd. I have just transcribed that conversation here as it elucidates the potentially subtle assumptions which led to the design of the memory retention behaviours of -Fd. Fixes #21483 - - - - - 980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00 eventlog: Don't leave dangling pointers hanging around Previously we failed to reset pointers to various eventlog buffers to NULL after freeing them. In principle we shouldn't look at them after they are freed but nevertheless it is good practice to set them to a well-defined value. - - - - - 575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00 runhaskell - - - - - e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00 re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45 - - - - - 5d45aa97 by Gergő Érdi at 2022-06-22T22:00:46-04:00 When specialising, look through floatable ticks. Fixes #21697. - - - - - 531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00 TagCheck.hs: Properly check if arguments are boxed types. For one by mistake I had been checking against the kind of runtime rep instead of the boxity. This uncovered another bug, namely that we tried to generate the checking code before we had associated the function arguments with a register, so this could never have worked to begin with. This fixes #21729 and both of the above issues. - - - - - c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00 Use correct arch for the FreeBSD triple in gen-data-layout.sh Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798 Relevant upstream issue: #15718 - - - - - 75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00 Bump nofib submodule. Allows the shake runner to build with 9.2.3 among other things. Fixes #21772 - - - - - 0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00 Bump ghc-prim and base versions To 0.9.0 and 4.17.0 respectively. Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm, terminfo, text, unix, haddock, and hsc2hs submodules. (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095) - - - - - 4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00 testsuite: Use normalise_version more consistently Previously several tests' output were unnecessarily dependent on version numbers, particularly of `base`. Fix this. - - - - - d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00 linters: Fix lint-submodule-refs when crashing trying to find plausible branches - - - - - 38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 hadrian: Improve haddocks for ghcDebugAssertions - - - - - ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 Don't mark lambda binders as OtherCon We used to put OtherCon unfoldings on lambda binders of workers and sometimes also join points/specializations with with the assumption that since the wrapper would force these arguments once we execute the RHS they would indeed be in WHNF. This was wrong for reasons detailed in #21472. So now we purge evaluated unfoldings from *all* lambda binders. This fixes #21472, but at the cost of sometimes not using as efficient a calling convention. It can also change inlining behaviour as some occurances will no longer look like value arguments when they did before. As consequence we also change how we compute CBV information for arguments slightly. We now *always* determine the CBV convention for arguments during tidy. Earlier in the pipeline we merely mark functions as candidates for having their arguments treated as CBV. As before the process is described in the relevant notes: Note [CBV Function Ids] Note [Attaching CBV Marks to ids] Note [Never put `OtherCon` unfoldigns on lambda binders] ------------------------- Metric Decrease: T12425 T13035 T18223 T18223 T18923 MultiLayerModulesTH_OneShot Metric Increase: WWRec ------------------------- - - - - - 06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00 Add suggestions for unrecognised pragmas (#21589) In case of a misspelled pragma, offer possible corrections as to what the user could have meant. Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589 - - - - - 3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00 Remove the traces of i386-*-openbsd, long live amd64 OpenBSD will not ship any ghc packages on i386 starting with 7.2 release. This means there will not be a bootstrap compiler easily available. The last available binaries are ghc-8.10.6 which is already not supported as bootstrap for HEAD. See here for more information: https://marc.info/?l=openbsd-ports&m=165060700222580&w=2 - - - - - 58530271 by Andrew Lelechenko at 2022-06-27T08:03:34-04:00 Add Foldable1 and Bifoldable1 type classes Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9 Instances roughly follow https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1 but the API of `Foldable1` was expanded in comparison to `semigroupoids`. Compatibility shim is available from https://github.com/phadej/foldable1 (to be released). Closes #13573. - - - - - a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00 add levity polymorphism to addrToAny# - - - - - f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00 add tests for addrToAny# levity - - - - - 07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00 hadrian: Update main README page This README had some quite out-of-date content about the build system so I did a complete pass deleting old material. I also made the section about flavours more prominent and mentioned flavour transformers. - - - - - 79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00 testsuite: Hide output from test compilations with verbosity==2 Previously the output from test compilations used to determine whether, e.g., profiling libraries are available was shown with verbosity levels >= 2. However, the default level is 2, meaning that most users were often spammed with confusing errors. Fix this by bumping the verbosity threshold for this output to >=3. Fixes #21760. - - - - - 995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00 configure: Only probe for LD in FIND_LD Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD rather early in `configure`. However, it turns out that this breaks `configure`'s `ld`-override logic, which assumes that `LD` was set by the user and aborts. Fixes #21778. - - - - - b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00 `.hs-boot` make rules: add missing order-only dependency on target directory Noticed missing target directory dependency as a build failure in `make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100): "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254 make: *** [Makefile:128: all] Error 2 shuffle=1656129254 Note that `cp` complains about inability to create target file. The change adds order-only dependency on a target directory (similar to the rest of rules in that file). The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build system megapatch`.) where upfront directory creation was never added to `.hs-boot` files. - - - - - 57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00 Mark AArch64/Darwin as requiring sign-extension Apple's AArch64 ABI requires that the caller sign-extend small integer arguments. Set platformCConvNeedsExtension to reflect this fact. Fixes #21773. - - - - - df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00 -ddump-llvm shouldn't imply -fllvm Previously -ddump-llvm would change the backend used, which contrasts with all other dump flags. This is quite surprising and cost me quite a bit of time. Dump flags should not change compiler behavior. Fixes #21776. - - - - - 70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Re-format argument handling logic Previously there were very long, hard to parse lines. Fix this. - - - - - 696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Sign-extend narrow C arguments The AArch64/Darwin ABI requires that function arguments narrower than 32-bits must be sign-extended by the caller. We neglected to do this, resulting in #20735. Fixes #20735. - - - - - c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00 testsuite: Add test for #20735 - - - - - 16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00 integer-gmp: Fix cabal file Evidently fields may not come after sections in a cabal file. - - - - - 03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00 ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist) before the change `make install` was failing as: ``` "mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc" make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'. Stop. ``` I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf` is created (somewhat manually), but not the .install varianlt of it. The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere. Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784 - - - - - eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00 Comments only, about join points This MR just adds some documentation about why casts destroy join points, following #21716. - - - - - 251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00 Cleanup BuiltInSyntax vs UserSyntax There was some confusion about whether FUN/TYPE/One/Many should be BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as BuiltInSyntax is for things which are directly constructed by the parser rather than going through normal renaming channels. I fixed all the obviously wrong places I could find and added a test for the original bug which was caused by this (#21752) Fixes #21752 #20695 #18302 - - - - - 0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00 template-haskell: Bump version to 2.19.0.0 Bumps text and exceptions submodules due to bounds. - - - - - bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00 Tiny tweak to `IOPort#` documentation The exclamation mark and bracket don’t seem to make sense here. I’ve looked through the history, and I don’t think they’re deliberate – possibly a copy-and-paste error. - - - - - 70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00 Remove `CoreOccurAnal` constructor of the `CoreToDo` type It was dead code since the last occurence in an expression context got removed in 71916e1c018dded2e68d6769a2dbb8777da12664. - - - - - d0722170 by nineonine at 2022-07-01T08:15:56-04:00 Fix panic with UnliftedFFITypes+CApiFFI (#14624) When declaring foreign import using CAPI calling convention, using unlifted unboxed types would result in compiler panic. There was an attempt to fix the situation in #9274, however it only addressed some of the ByteArray cases. This patch fixes other missed cases for all prims that may be used as basic foreign types. - - - - - eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00 rts: gc stats: account properly for copied bytes in sequential collections We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow] counters during sequential collections. As well, we were double counting for parallel collections. To fix this we add an `else` clause to the `if (is_par_gc())`. The par_* counters do not need to be updated in the sequential case because they must be 0. - - - - - f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00 desugar: Look through ticks when warning about possible literal overflow Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up between the appliation of `neg` to its argument. This defeated the special logic which looks for `NegApp ... (HsOverLit` to warn about possible overflow if a user writes a negative literal (without out NegativeLiterals) in their code. Fixes #21701 - - - - - f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00 ci: Fix definition of slow-validate flavour (so that -dlint) is passed In this embarassing sequence of events we were running slow-validate without -dlint. - - - - - bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00 Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411 - - - - - 9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00 Data.Foldable1: Remove references to Foldable-specific note ...as discussed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455. - - - - - 3a8970ac by romes at 2022-07-03T14:11:31-04:00 TTG: Move HsModule to L.H.S Move the definition of HsModule defined in GHC.Hs to Language.Haskell.Syntax with an added TTG parameter and corresponding extension fields. This is progress towards having the haskell-syntax package, as described in #21592 - - - - - f9f80995 by romes at 2022-07-03T14:11:31-04:00 TTG: Move ImpExp client-independent bits to L.H.S.ImpExp Move the GHC-independent definitions from GHC.Hs.ImpExp to Language.Haskell.Syntax.ImpExp with the required TTG extension fields such as to keep the AST independent from GHC. This is progress towards having the haskell-syntax package, as described in #21592 Bumps haddock submodule - - - - - c43dbac0 by romes at 2022-07-03T14:11:31-04:00 Refactor ModuleName to L.H.S.Module.Name ModuleName used to live in GHC.Unit.Module.Name. In this commit, the definition of ModuleName and its associated functions are moved to Language.Haskell.Syntax.Module.Name according to the current plan towards making the AST GHC-independent. The instances for ModuleName for Outputable, Uniquable and Binary were moved to the module in which the class is defined because these instances depend on GHC. The instance of Eq for ModuleName is slightly changed to no longer depend on unique explicitly and instead uses FastString's instance of Eq. - - - - - 2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00 Expand `Ord` instance for `Down` Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610 - - - - - 36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00 Add applyWhen to Data.Function per CLC prop Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233 - - - - - 3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00 hadrian: Don't read package environments in ghc-stage1 wrapper The stage1 compiler may be on the brink of existence and not have even a working base library. You may have installed packages globally with a similar stage2 compiler which will then lead to arguments such as --show-iface not even working because you are passing too many package flags. The solution is simple, don't read these implicit files. Fixes #21803 - - - - - aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00 Ticky:Make json info a separate field. Fixes #21233 - - - - - 74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00 Add docs:<pkg> command to hadrian to build docs for just one package - - - - - 418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00 upload-docs: propagate publish correctly in upload_sdist - - - - - ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00 docs-upload: Fix upload script when no packages are listed - - - - - d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00 hadrian: Add --haddock-base-url option for specifying base-url when generating docs The motiviation for this flag is to be able to produce documentation which is suitable for uploading for hackage, ie, the cross-package links work correctly. There are basically three values you want to set this to: * off - default, base_url = ../%pkg% which works for local browsing * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation. The `%pkg%` string is a template variable which is replaced with the package identifier for the relevant package. This is one step towards fixing #21749 - - - - - 41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00 Add nightly job for generating docs suitable for hackage upload - - - - - 620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00 ghci: Support :set prompt in multi repl This adds supports for various :set commands apart from `:set <FLAG>` in multi repl, this includes `:set prompt` and so-on. Fixes #21796 - - - - - b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00 Vendor filepath inside template-haskell Adding filepath as a dependency of template-haskell means that it can't be reinstalled if any build-plan depends on template-haskell. This is a temporary solution for the 9.4 release. A longer term solution is to split-up the template-haskell package into the wired-in part and a non-wired-in part which can be reinstalled. This was deemed quite risky on the 9.4 release timescale. Fixes #21738 - - - - - c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00 Factor fields of `CoreDoSimplify` into separate data type This avoids some partiality. The work @mmhat is doing cleaning up and modularizing `Core.Opt` will build on this nicely. - - - - - d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00 https urls - - - - - 803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00 options and typos - - - - - 5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00 grammar - - - - - 4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00 sources - - - - - c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00 Fix lint warnings in bootstrap.py - - - - - 86ced2ad by romes at 2022-07-06T01:36:23-04:00 Restore Eq instance of ImportDeclQualifiedStyle Fixes #21819 - - - - - 3547e264 by romes at 2022-07-06T13:50:27-04:00 Prune L.H.S modules of GHC dependencies Move around datatypes, functions and instances that are GHC-specific out of the `Language.Haskell.Syntax.*` modules to reduce the GHC dependencies in them -- progressing towards #21592 Creates a module `Language.Haskell.Syntax.Basic` to hold basic definitions required by the other L.H.S modules (and don't belong in any of them) - - - - - e4eea07b by romes at 2022-07-06T13:50:27-04:00 TTG: Move CoreTickish out of LHS.Binds Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and move them to the extension point instance, according to the plan outlined in #21592 to separate the base AST from the GHC specific bits. - - - - - acc1816b by romes at 2022-07-06T13:50:27-04:00 TTG for ForeignImport/Export Add a TTG parameter to both `ForeignImport` and `ForeignExport` and, according to #21592, move the GHC-specific bits in them and in the other AST data types related to foreign imports and exports to the TTG extension point. - - - - - 371c5ecf by romes at 2022-07-06T13:50:27-04:00 TTG for HsTyLit Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText` fields to the extension point and out of the base AST. Progress towards #21592 - - - - - fd379d1b by romes at 2022-07-06T13:50:27-04:00 Remove many GHC dependencies from L.H.S Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC imports according to the plan in the linked issue. Moves more GHC-specific declarations to `GHC.*` and brings more required GHC-independent declarations to `Language.Haskell.Syntax.*` (extending e.g. `Language.Haskell.Syntax.Basic`). Progress towards #21592 Bump haddock submodule for !8308 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00 Fix exact printing of the HsRule name Prior to this branch, the HsRule name was XRec pass (SourceText,RuleName) and there is an ExactPrint instance for (SourceText, RuleName). The SourceText has moved to a different location, so synthesise the original to trigger the correct instance when printing. We need both the SourceText and RuleName when exact printing, as it is possible to have a NoSourceText variant, in which case we fall back to the FastString. - - - - - 665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00 driver: Fix issue with module loops and multiple home units We were attempting to rehydrate all dependencies of a particular module, but we actually only needed to rehydrate those of the current package (as those are the ones participating in the loop). This fixes loading GHC into a multi-unit session. Fixes #21814 - - - - - bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00 Remove a bogus #define from ClosureMacros.h - - - - - fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00 winio: make consoleReadNonBlocking not wait for any events at all. - - - - - 42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00 rts: allow NULL to be used as an invalid StgStablePtr - - - - - 3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00 RTS: Add stack marker to StgCRunAsm.S Every object file must be properly marked for non-executable stack, even if it contains no code. - - - - - a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00 Bump unix submodule Adds `config.sub` to unix's `.gitignore`, fixing #19574. - - - - - 3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00 ghci: Fix most calls to isLoaded to work in multi-mode The most egrarious thing this fixes is the report about the total number of loaded modules after starting a session. Ticket #20889 - - - - - fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00 Enable :edit command in ghci multi-mode. This works after the last change to isLoaded. Ticket #20888 - - - - - 46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00 Fix a scoping bug in the Specialiser In the call to `specLookupRule` in `already_covered`, in `specCalls`, we need an in-scope set that includes the free vars of the arguments. But we simply were not guaranteeing that: did not include the `rule_bndrs`. Easily fixed. I'm not sure how how this bug has lain for quite so long without biting us. Fixes #21828. - - - - - 6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Edit Note [idArity varies independently of dmdTypeDepth] ...and refer to it in GHC.Core.Lint.lintLetBind. Fixes #21452 - - - - - 89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Tiny documentation wibbles (comments only) - - - - - 61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix readme - - - - - 61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix bootstrap - - - - - 8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00 tarball - - - - - e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Fix scopes for deriving clauses and instance signatures (#18425) - - - - - c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Record location of filled in default method bindings This is useful for hie files to reconstruct the evidence that default methods depend on. - - - - - 9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00 testsuite: Factor out common parts from hiefile tests - - - - - 6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00 Hadrian: update documentation of settings The documentation for key-value settings was a bit out of date. This patch updates it to account for `cabal.configure.opts` and `hsc2hs.run.opts`. The user-settings document was also re-arranged, to make the key-value settings more prominent (as it doesn't involve changing the Hadrian source code, and thus doesn't require any recompilation of Hadrian). - - - - - a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00 Fix potential space leak that arise from ModuleGraphs retaining references to previous ModuleGraphs, in particular the lazy `mg_non_boot` field. This manifests in `extendMG`. Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which is only called in two places in the compiler, and should only be called at most once for every home unit: GHC.Driver.Make: mainModuleSrcPath :: Maybe String mainModuleSrcPath = do ms <- mgLookupModule mod_graph (mainModIs hue) ml_hs_file (ms_location ms) GHCI.UI: listModuleLine modl line = do graph <- GHC.getModuleGraph let this = GHC.mgLookupModule graph modl Instead `mgLookupModule` can be a linear function that looks through the entire list of `ModuleGraphNodes` Fixes #21816 - - - - - dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00 rts: Fix AdjustorPool bitmap manipulation Previously the implementation of bitmap_first_unset assumed that `__builtin_clz` would accept `uint8_t` however it apparently rather extends its argument to `unsigned int`. To fix this we simply revert to a naive implementation since handling the various corner cases with `clz` is quite tricky. This should be fine given that AdjustorPool isn't particularly hot. Ideally we would have a single, optimised bitmap implementation in the RTS but I'll leave this for future work. Fixes #21838. - - - - - ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00 Change GHCi bytecode return convention for unlifted datatypes. This changes the bytecode return convention for unlifted algebraic datatypes to be the same as for lifted types, i.e. ENTER/PUSH_ALTS instead of RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED Fixes #20849 - - - - - 5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00 Compute record-dot-syntax types Ensures type information for record-dot-syntax is included in HieASTs. See #21797 - - - - - 89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00 Add record-dot-syntax test - - - - - 4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00 Document RuntimeRep polymorphism limitations of catch#, et al As noted in #21868, several primops accepting continuations producing RuntimeRep-polymorphic results aren't nearly as polymorphic as their types suggest. Document this limitation and adapt the `UnliftedWeakPtr` test to avoid breaking this limitation in `keepAlive#`. - - - - - 4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00 Make keepAlive# out-of-line This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203 - - - - - 1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00 Suppress extra output from configure check for c++ libraries - - - - - 3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00 rel-notes: Drop mention of #21745 fix Since we have backported the fix to 9.4.1. - - - - - b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00 Align the behaviour of `dopt` and `log_dopt` Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying function `log_dopt`) were different as the latter did not take the verbosity level into account. This led to problems during the refactoring as we cannot simply replace calls to `dopt` with calls to `logHasDumpFlag`. In addition to that a subtle bug in the GHC module was fixed: `setSessionDynFlags` did not update the logger and as a consequence the verbosity value of the logger was not set appropriately. Fixes #21861 - - - - - 28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00 rts: forkOn context switches the target capability Fixes #21824 - - - - - f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Eliminate orphan Outputable instances Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and `OutputableP` instances for the Cmm AST. This makes it significantly easier to use the Cmm pretty-printers in tracing output without incurring module import cycles. - - - - - f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Move toBlockList to GHC.Cmm - - - - - fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00 compiler: Add haddock sections to GHC.Utils.Panic - - - - - 097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00 configure: Don't override Windows CXXFLAGS At some point we used the clang distribution from msys2's `MINGW64` environment for our Windows toolchain. This defaulted to using libgcc and libstdc++ for its runtime library. However, we found for a variety of reasons that compiler-rt, libunwind, and libc++ were more reliable, consequently we explicitly overrode the CXXFLAGS to use these. However, since then we have switched to use the `CLANG64` packaging, which default to these already. Consequently we can drop these arguments, silencing some redundant argument warnings from clang. Fixes #21669. - - - - - e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Check that there are no NULL ctors - - - - - 616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Introduce support for invoking finalizers on unload Addresses #20494. - - - - - cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add T20494 - - - - - 03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Rename finit field to fini fini is short for "finalizer", which does not contain a "t". - - - - - 033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Refactor handling of oc->info Previously we would free oc->info after running initializers. However, we can't do this is we want to also run finalizers. Moreover, freeing oc->info so early was wrong for another reason: we will need it in order to unregister the exception tables (see the call to `RtlDeleteFunctionTable`). In service of #20494. - - - - - f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Add finalization support This implements #20494 for the PEi386 linker. Happily, this also appears to fix `T9405`, resolving #21361. - - - - - 2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00 Loader: Implement gnu-style -l:$path syntax Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic. - - - - - 5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00 Statically-link against libc++ on Windows Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435. - - - - - 8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run It turns out that PE objects may have multiple `.ctors`/`.dtors` sections but the RTS linker had assumed that there was only one. Fix this. Fixes #21618. - - - - - fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Respect dtor/ctor priority Previously we would run constructors and destructors in arbitrary order despite explicit priorities. Fixes #21847. - - - - - 1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add test for #21618 and #21847 - - - - - 6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Fix exception unwind unregistration RtlDeleteFunctionTable expects a pointer to the .pdata section yet we passed it the .xdata section. Happily, this fixes #21354. - - - - - d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Drop dead code - - - - - d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Use section flags to identify initializers - - - - - fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Introduce finalizer support - - - - - 5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl - - - - - 6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker/Elf: Work around GCC 6 init/fini behavior It appears that GCC 6t (at least on i386) fails to give init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY section types, instead marking them as SHT_PROGBITS. This caused T20494 to fail on Debian. - - - - - 5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Mark T13366Cxx as unbroken on Darwin - - - - - 1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Fix resolution of __dso_handle on Darwin Darwin expects a leading underscore. - - - - - a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Clean up section kinds - - - - - aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Ensure that __cxa_finalize is called on code unload - - - - - 028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00 testsuite: Fix T11829 on Centos 7 It appears that Centos 7 has a more strict C++ compiler than most distributions since std::runtime_error is defined in <stdexcept> rather than <exception>. In T11829 we mistakenly imported the latter. - - - - - a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00 hadrian: Rename documentation directories for consistency with make * Rename `docs` to `doc` * Place pdf documentation in `doc/` instead of `doc/pdfs/` Fixes #21164. - - - - - b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00 Fix incorrect proof of applyWhen’s properties - - - - - eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00 hadrian: Add multi:<pkg> and multi targets for starting a multi-repl This patch adds support to hadrian for starting a multi-repl containing all the packages which stage0 can build. In particular, there is the new user-facing command: ``` ./hadrian/ghci-multi ``` which when executed will start a multi-repl containing the `ghc` package and all it's dependencies. This is implemented by two new hadrian targets: ``` ./hadrian/build multi:<pkg> ``` Construct the arguments for a multi-repl session where the top-level package is <pkg>. For example, `./hadrian/ghci-multi` is implemented using `multi:ghc` target. There is also the `multi` command which constructs a repl for everything in stage0 which we can build. - - - - - 19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00 changelog typo - - - - - af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00 typos - - - - - 415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00 Refactor SpecConstr to use treat bindings uniformly This patch, provoked by #21457, simplifies SpecConstr by treating top-level and nested bindings uniformly (see the new scBind). * Eliminates the mysterious scTopBindEnv * Refactors scBind to handle top-level and nested definitions uniformly. * But, for now at least, continues the status quo of not doing SpecConstr for top-level non-recursive bindings. (In contrast we do specialise nested non-recursive bindings, although the original paper did not; see Note [Local let bindings].) I tried the effect of specialising top-level non-recursive bindings (which is now dead easy to switch on, unlike before) but found some regressions, so I backed off. See !8135. It's a pure refactoring. I think it'll do a better job in a few cases, but there is no regression test. - - - - - d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00 Rule matching: Don't compute the FVs if we don't look at them. - - - - - 5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 White space only in FamInstEnv - - - - - ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make transferPolyIdInfo work for CPR I don't know why this hasn't bitten us before, but it was plain wrong. - - - - - 9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Inline mapAccumLM This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically. - - - - - d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make SetLevels honour floatConsts This fix, in the definition of profitableFloat, is just for consistency. `floatConsts` should do what it says! I don't think it'll affect anything much, though. - - - - - d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Refactor wantToUnboxArg a bit * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg and similarly wantToUnboxResult to canUnboxResult. * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg, avoiding some yukky duplication. I decided it was clearer to give it a new data type for its return type, because I nedeed the FD_RecBox case which was not otherwise readiliy expressible. * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload * Get rid of the Unlift constructor of UnboxingDecision, eliminate two panics, and two arguments to canUnboxArg (new name). Much nicer now. - - - - - 6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00 Allow running memInventory when the concurrent nonmoving gc is enabled If the nonmoving gc is enabled and we are using a threaded RTS, we now try to grab the collector mutex to avoid memInventory and the collection racing. Before memInventory was disabled. - - - - - aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00 gitignore: don't ignore all aclocal.m4 files While GHC's own aclocal.m4 is generated by the aclocal tool, other packages' aclocal.m4 are committed in the repository. Previously `.gitignore` included an entry which covered *any* file named `aclocal.m4`, which lead to quite some confusion (e.g. see #21740). Fix this by modifying GHC's `.gitignore` to only cover GHC's own `aclocal.m4`. - - - - - 4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00 Add mapAccumM, forAccumM to Data.Traversable Approved by Core Libraries Committee in https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433 - - - - - bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00 configure: Use AC_PATH_TOOL to detect tools Previously we used AC_PATH_PROG which, as noted by #21601, does not look for tools with a target prefix, breaking cross-compilation. Fixes #21601. - - - - - e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00 driver: Fix implementation of -S We were failing to stop before running the assembler so the object file was also created. Fixes #21869 - - - - - e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00 rts/ProfHeap: Ensure new Censuses are zeroed When growing the Census array ProfHeap previously neglected to zero the new part of the array. Consequently `freeEra` would attempt to free random words that often looked suspiciously like pointers. Fixes #21880. - - - - - 81d65f7f by sheaf at 2022-07-21T15:37:22+02:00 Make withDict opaque to the specialiser As pointed out in #21575, it is not sufficient to set withDict to inline after the typeclass specialiser, because we might inline withDict in one module and then import it in another, and we run into the same problem. This means we could still end up with incorrect runtime results because the typeclass specialiser would assume that distinct typeclass evidence terms at the same type are equal, when this is not necessarily the case when using withDict. Instead, this patch introduces a new magicId, 'nospec', which is only inlined in CorePrep. We make use of it in the definition of withDict to ensure that the typeclass specialiser does not common up distinct typeclass evidence terms. Fixes #21575 - - - - - 9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00 Refactored Simplify pass * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify namespace and GHC.Core.Opt.Stats. Also removed services from configuration records. * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration. * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm` and moved the Simplify driver to GHC.Core.Opt.Simplify. * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env. * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment in GHC.Core.Opt.Simplify.Monad. * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions for those in a new module GHC.Driver.Config.Core.Opt.Simplify. Also added initialization functions for `SimplMode` to that module. * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types and the counting types and functions (`SimplCount` and `Tick`) to new module GHC.Core.Opt.Stats. * Added getter functions for the fields of `SimplMode`. The pedantic bottoms option and the platform are retrieved from the ArityOpts and RuleOpts and the getter functions allow us to retrieve values from `SpecEnv` without the knowledge where the data is stored exactly. * Moved the coercion optimization options from the top environment to `SimplMode`. This way the values left in the top environment are those dealing with monadic functionality, namely logging, IO related stuff and counting. Added a note "The environments of the Simplify pass". * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead. * Prep work before removing `InteractiveContext` from `HscEnv`. - - - - - 2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00 Make the specialiser deal better with specialised methods This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368. - - - - - ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00 ghc-boot: Clean up UTF-8 codecs In preparation for moving the UTF-8 codecs into `base`: * Move them to GHC.Utils.Encoding.UTF8 * Make names more consistent * Add some Haddocks - - - - - e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00 base: Introduce GHC.Encoding.UTF8 Here we copy a subset of the UTF-8 implementation living in `ghc-boot` into `base`, with the intent of dropping the former in the future. For this reason, the `ghc-boot` copy is now CPP-guarded on `MIN_VERSION_base(4,18,0)`. Naturally, we can't copy *all* of the functions defined by `ghc-boot` as some depend upon `bytestring`; we rather just copy those which only depend upon `base` and `ghc-prim`. Further consolidation? ---------------------- Currently GHC ships with at least five UTF-8 implementations: * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this can be used at a number of types including `Addr#`, `ByteArray#`, `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this can be removed in GHC 9.6+2, when the copies in `base` will become available to `ghc-boot`. * the copy of the `ghc-boot` definition now exported by `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`, `ByteArray#`, and `ForeignPtr` * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`; this is specialised at `Addr#`. * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`; this is specialised at `Addr#` but, unlike the above, supports recovery in the presence of partial codepoints (since in IO contexts codepoints may be broken across buffers) * the implementation provided by the `text` library This does seem a tad silly. On the other hand, these implementations *do* materially differ from one another (e.g. in the types they support, the detail in errors they can report, and the ability to recover from partial codepoints). Consequently, it's quite unclear that further consolidate would be worthwhile. - - - - - f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00 Add a Note summarising GHC's UTF-8 implementations GHC has a somewhat dizzying array of UTF-8 implementations. This note describes why this is the case. - - - - - 72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00 upload_ghc_libs: Fix path to documentation The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35 but this one occurrence was note updated. Finally closes #21164. - - - - - a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00 Add test for #21871 This adds a test for #21871, which was fixed by the No Skolem Info rework (MR !7105). Fixes #21871 - - - - - 6379f942 by sheaf at 2022-07-22T08:18:46-04:00 Add test for #21360 The way record updates are typechecked/desugared changed in MR !7981. Because we desugar in the typechecker to a simple case expression, the pattern match checker becomes able to spot the long-distance information and avoid emitting an incorrect pattern match warning. Fixes #21360 - - - - - ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00 Hadrian: don't try to build "unix" on Windows - - - - - dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Implement DeepSubsumption This MR adds the language extension -XDeepSubsumption, implementing GHC proposal #511. This change mitigates the impact of GHC proposal The changes are highly localised, by design. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. The main changes are: * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010, but off in Haskell2021. -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change. -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds: it makes type inference more complicated and less predictable, but it may be convenient in practice. * The main changes are in: * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result type. Without deep subsumption, unifyExpectedType would be sufficent. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. * There are no changes to Quick Look at all. * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to GHC.Magic.Dict * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where we'd forgotten to take the free vars of the multiplicity of an Id. * I also had to fix tcSplitNestedSigmaTys When I did the shallow-subsumption patch commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f Date: Sun Feb 2 18:23:11 2020 +0000 Simple subsumption I changed tcSplitNestedSigmaTys to not look through function arrows any more. But that was actually an un-forced change. This function is used only in * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect All to do with validity checking and error messages. Acutally its fine to look under function arrows here, and quite useful a test DeepSubsumption05 (a test motivated by a build failure in the `lens` package) shows. The fix is easy. I added Note [tcSplitNestedSigmaTys]. - - - - - e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption - - - - - 67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add DeepSubsumption08 - - - - - 5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Fix the interaction of operator sections and deep subsumption Fixes DeepSubsumption08 - - - - - 918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00 Add DeepSubsumption09 - - - - - 2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00 Default implementation for mempty/(<>) Approved by: https://github.com/haskell/core-libraries-committee/issues/61 This adds a default implementation for `mempty` and `(<>)` along with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid` instances can be defined in terms of `sconcat` / `mconcat`. The description for each class has also been updated to include the equivalent set of laws for the `sconcat`-only / `mconcat`-only instances. - - - - - 73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00 ci: Disable (broken) perf-nofib See #21859 - - - - - c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00 Docs: clarify ConstraintKinds infelicity GHC doesn't consistently require the ConstraintKinds extension to be enabled, as it allows programs such as type families returning a constraint without this extension. MR !7784 fixes this infelicity, but breaking user programs was deemed to not be worth it, so we document it instead. Fixes #21061. - - - - - 5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00 More improvements to worker/wrapper This patch fixes #21888, and simplifies finaliseArgBoxities by eliminating the (recently introduced) data type FinalDecision. A delicate interaction meant that this patch commit d1c25a48154236861a413e058ea38d1b8320273f Date: Tue Jul 12 16:33:46 2022 +0100 Refactor wantToUnboxArg a bit make worker/wrapper go into an infinite loop. This patch fixes it by narrowing the handling of case (B) of Note [Boxity for bottoming functions], to deal only the arguemnts that are type variables. Only then do we drop the trimBoxity call, which is what caused the bug. I also * Added documentation of case (B), which was previously completely un-mentioned. And a regression test, T21888a, to test it. * Made unboxDeeplyDmd stop at lazy demands. It's rare anyway for a bottoming function to have a lazy argument (mainly when the data type is recursive and then we don't want to unbox deeply). Plus there is Note [No lazy, Unboxed demands in demand signature] * Refactored the Case equation for dmdAnal a bit, to do less redundant pattern matching. - - - - - b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00 Fix a small buglet in tryEtaReduce Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was making an ill-formed cast. It didn't matter, because the subsequent guard discarded it; but still worth fixing. Spurious warnings are distracting. - - - - - 3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00 Fix #21889, GHCi misbehaves with Ctrl-C on Windows On Windows, we create multiple levels of wrappers for GHCi which ultimately execute ghc --interactive. In order to handle console events properly, each of these wrappers must call FreeConsole() in order to hand off event processing to the child process. See #14150. In addition to this, FreeConsole must only be called from interactive processes (#13411). This commit makes two changes to fix this situation: 1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole` if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi. 2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`: Before: ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe After: ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe - - - - - 79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00 docs: Fix documentation of \cases Fixes #21902. - - - - - e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00 ghc-cabal: allow Cabal 3.8 to unbreak make build When bootstrapping GHC 9.4.*, the build will fail when configuring ghc-cabal as part of the make based build system due to this upper bound, as Cabal has been updated to a 3.8 release. Reference #21914, see especially https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699 - - - - - 726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Fix isEvaldUnfolding and isValueUnfolding This fixes (1) in #21831. Easy, obviously correct. - - - - - 5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Switch off eta-expansion in rules and unfoldings I think this change will make little difference except to reduce clutter. But that's it -- if it causes problems we can switch it on again. - - - - - d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Teach SpecConstr about typeDeterminesValue This patch addresses #21831, point 2. See Note [generaliseDictPats] in SpecConstr I took the opportunity to refactor the construction of specialisation rules a bit, so that the rule name says what type we are specialising at. Surprisingly, there's a 20% decrease in compile time for test perf/compiler/T18223. I took a look at it, and the code size seems the same throughout. I did a quick ticky profile which seemed to show a bit less substitution going on. Hmm. Maybe it's the "don't do eta-expansion in stable unfoldings" patch, which is part of the same MR as this patch. Anyway, since it's a move in the right direction, I didn't think it was worth looking into further. Metric Decrease: T18223 - - - - - 65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Add a 'notes' file in testsuite/tests/perf/compiler This file is just a place to accumlate notes about particular benchmarks, so that I don't keep re-inventing the wheel. - - - - - 61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00 Get the in-scope set right in FamInstEnv.injectiveBranches There was an assert error, as Gergo pointed out in #21896. I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs. And also to GHC.Core.Unify.niFixTCvSubst. I also took the opportunity to get a couple more InScopeSets right, and to change some substTyUnchecked into substTy. This MR touches a lot of other files, but only because I also took the opportunity to introduce mkInScopeSetList, and use it. - - - - - 4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00 Add location to cc phase - - - - - 96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00 Avoid as pipeline when compiling c - - - - - 2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00 testsuite: Skip test cases involving -S when testing unregisterised GHC We no longer generate .s files anyway. Metric Decrease: MultiLayerModules T10421 T13035 T13701 T14697 T16875 T18140 T18304 T18923 T9198 - - - - - 82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00 testsuite: introduce nonmoving_thread_sanity way (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae) - - - - - 4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Track segment state It can often be useful during debugging to be able to determine the state of a nonmoving segment. Introduce some state, enabled by DEBUG, to track this. (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f) - - - - - 54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Don't scavenge objects which weren't evacuated This fixes a rather subtle bug in the logic responsible for scavenging objects evacuated to the non-moving generation. In particular, objects can be allocated into the non-moving generation by two ways: a. evacuation out of from-space by the garbage collector b. direct allocation by the mutator Like all evacuation, objects moved by (a) must be scavenged, since they may contain references to other objects located in from-space. To accomplish this we have the following scheme: * each nonmoving segment's block descriptor has a scan pointer which points to the first object which has yet to be scavenged * the GC tracks a set of "todo" segments which have pending scavenging work * to scavenge a segment, we scavenge each of the unmarked blocks between the scan pointer and segment's `next_free` pointer. We skip marked blocks since we know the allocator wouldn't have allocated into marked blocks (since they contain presumably live data). We can stop at `next_free` since, by definition, the GC could not have evacuated any objects to blocks above `next_free` (otherwise `next_free wouldn't be the first free block). However, this neglected to consider objects allocated by path (b). In short, the problem is that objects directly allocated by the mutator may become unreachable (but not swept, since the containing segment is not yet full), at which point they may contain references to swept objects. Specifically, we observed this in #21885 in the following way: 1. the mutator (specifically in #21885, a `lockCAF`) allocates an object (specifically a blackhole, which here we will call `blkh`; see Note [Static objects under the nonmoving collector] for the reason why) on the non-moving heap. The bitmap of the allocated block remains 0 (since allocation doesn't affect the bitmap) and the containing segment's (which we will call `blkh_seg`) `next_free` is advanced. 2. We enter the blackhole, evaluating the blackhole to produce a result (specificaly a cons cell) in the nursery 3. The blackhole gets updated into an indirection pointing to the cons cell; it is pushed to the generational remembered set 4. we perform a GC, the cons cell is evacuated into the nonmoving heap (into segment `cons_seg`) 5. the cons cell is marked 6. the GC concludes 7. the CAF and blackhole become unreachable 8. `cons_seg` is filled 9. we start another GC; the cons cell is swept 10. we start a new GC 11. something is evacuated into `blkh_seg`, adding it to the "todo" list 12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks between `scan` and `next_free`, which includes `blkh`). We attempt to evacuate `blkh`'s indirectee, which is the previously-swept cons cell. This is unsafe, since the indirectee is no longer a valid heap object. The problem here was that the scavenging logic *assumed* that (a) was the only source of allocations into the non-moving heap and therefore *all* unmarked blocks between `scan` and `next_free` were evacuated. However, due to (b) this is not true. The solution is to ensure that that the scanned region only encompasses the region of objects allocated during evacuation. We do this by updating `scan` as we push the segment to the todo-segment list to point to the block which was evacuated into. Doing this required changing the nonmoving scavenging implementation's update of the `scan` pointer to bump it *once*, instead of after scavenging each block as was done previously. This is because we may end up evacuating into the segment being scavenged as we scavenge it. This was quite tricky to discover but the result is quite simple, demonstrating yet again that global mutable state should be used exceedingly sparingly. Fixes #21885 (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060) - - - - - 25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00 testsuite: Skip a few tests as in the nonmoving collector Residency monitoring under the non-moving collector is quite conservative (e.g. the reported value is larger than reality) since otherwise we would need to block on concurrent collection. Skip a few tests that are sensitive to residency. (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70) - - - - - 42147534 by sternenseemann at 2022-07-26T16:26:53-04:00 hadrian: add flag disabling selftest rules which require QuickCheck The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699. - - - - - 9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00 Regression test for #21848 - - - - - ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00 driver: Don't create LinkNodes when -no-link is enabled Fixes #21866 - - - - - fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00 Docs: fix mistaken claim about kind signatures This patch fixes #21806 by rectifying an incorrect claim about the usage of kind variables in the header of a data declaration with a standalone kind signature. It also adds some clarifications about the number of parameters expected in GADT declarations and in type family declarations. - - - - - 2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00 testsuite: Correctly set withNativeCodeGen Fixes #21918 - - - - - f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00 Fix since annotations in GHC.Stack.CloneStack Fixes #21894 - - - - - aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00 Add -dsuppress-coercion-types to make coercions even smaller. Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)`` simply print `` `cast` <Co:11> :: ... `` - - - - - 97655ad8 by sheaf at 2022-08-02T19:27:29-04:00 User's guide: fix typo in hasfield.rst Fixes #21950 - - - - - 35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00 Remove TCvSubst and use Subst for both term and type-level subst This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types). - - - - - b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00 Fix TH + defer-type-errors interaction (#21920) Previously, we had to disable defer-type-errors in splices because of #7276. But this fix is no longer necessary, the test T7276 no longer segfaults and is now correctly deferred. - - - - - fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00 Add a note about about W/W for unlifting strict arguments This fixes #21236. - - - - - fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force safeInferred to avoid retaining extra copy of DynFlags This will only have a (very) modest impact on memory but we don't want to retain old copies of DynFlags hanging around so best to force this value. - - - - - 0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force name selectors to ensure no reference to Ids enter the NameCache I observed some unforced thunks in the NameCache which were retaining a whole Id, which ends up retaining a Type.. which ends up retaining old copies of HscEnv containing stale HomeModInfo. - - - - - 0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Fix leaks in --make mode when there are module loops This patch fixes quite a tricky leak where we would end up retaining stale ModDetails due to rehydrating modules against non-finalised interfaces. == Loops with multiple boot files It is possible for a module graph to have a loop (SCC, when ignoring boot files) which requires multiple boot files to break. In this case we must perform the necessary hydration steps before and after compiling modules which have boot files which are described above for corectness but also perform an additional hydration step at the end of the SCC to remove space leaks. Consider the following example: ┌───────┐ ┌───────┐ │ │ │ │ │ A │ │ B │ │ │ │ │ └─────┬─┘ └───┬───┘ │ │ ┌────▼─────────▼──┐ │ │ │ C │ └────┬─────────┬──┘ │ │ ┌────▼──┐ ┌───▼───┐ │ │ │ │ │ A-boot│ │ B-boot│ │ │ │ │ └───────┘ └───────┘ A, B and C live together in a SCC. Say we compile the modules in order A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps (because A has a boot file). Therefore C will be hydrated relative to A, and the ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again, and so B will reference C/A,B, its interface will be hydrated relative to both A and B. Now there is a space leak because say C is a very big module, there are now two different copies of ModDetails kept alive by modules A and B. The way to avoid this space leak is to rehydrate an entire SCC together at the end of compilation so that all the ModDetails point to interfaces for .hs files. In this example, when we hydrate A, B and C together then both A and B will refer to C/A,B. See #21900 for some more discussion. ------------------------------------------------------- In addition to this simple case, there is also the potential for a leak during parallel upsweep which is also fixed by this patch. Transcibed is Note [ModuleNameSet, efficiency and space leaks] Note [ModuleNameSet, efficiency and space leaks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During unsweep the results of compiling modules are placed into a MVar, to find the environment the module needs to compile itself in the MVar is consulted and the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking module dependencies and recreating the HUG from scratch each time is very expensive. In serial mode (-j1), this all works out fine because a module can only be compiled after its dependencies have finished compiling and not interleaved with compiling module loops. Therefore when we create the finalised or no loop interfaces, the HUG only contains finalised interfaces. In parallel mode, we have to be more careful because the HUG variable can contain non-finalised interfaces which have been started by another thread. In order to avoid a space leak where a finalised interface is compiled against a HPT which contains a non-finalised interface we have to restrict the HUG to only the visible modules. The visible modules is recording in the ModuleNameSet, this is propagated upwards whilst compiling and explains which transitive modules are visible from a certain point. This set is then used to restrict the HUG before the module is compiled to only the visible modules and thus avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance because a union occurs for each edge in the module graph. Therefore the set is represented directly as an IntSet which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. See test "jspace" for an example which used to trigger this problem. Fixes #21900 - - - - - 1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Store interfaces in ModIfaceCache more directly I realised hydration was completely irrelavant for this cache because the ModDetails are pruned from the result. So now it simplifies things a lot to just store the ModIface and Linkable, which we can put into the cache straight away rather than wait for the final version of a HomeModInfo to appear. - - - - - 6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00 cmm: Remove unused ReadOnlyData16 We don't actually emit rodata16 sections anywhere. - - - - - 16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00 findExternalRules: Don't needlessly traverse the list of rules. - - - - - 52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00 Remove backported items from 9.6 release notes They have been backported to 9.4 in commits 5423d84bd9a28f, 13c81cb6be95c5, 67ccbd6b2d4b9b. - - - - - 78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00 ci: Fix pages job The job has been failing because we don't bundle haddock docs anymore in the docs dist created by hadrian. Fixes #21789 - - - - - 037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00 codeGen/X86: Don't clobber switch variable in switch generation Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was safe to clobber the switch variable when generating code for a jump table since we were at the end of a block. However, this assumption is wrong; the register could be live in the jump target. Fixes #21968. - - - - - 50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00 Fix equality operator in jspace test - - - - - e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Improve BUILD_PAP comments - - - - - 41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Make dropTail comment a haddock comment - - - - - ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Add one more sanity check in stg_restore_cccs - - - - - 1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00 StgToCmm: Fix isSimpleScrut when profiling is enabled. When profiling is enabled we must enter functions that might represent thunks in order for their sccs to show up in the profile. We might allocate even if the function is already evaluated in this case. So we can't consider any potential function thunk to be a simple scrut when profiling. Not doing so caused profiled binaries to segfault. - - - - - fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Change `-fprof-late` to insert cost centres after unfolding creation. The former behaviour of adding cost centres after optimization but before unfoldings are created is not available via the flag `prof-late-inline` instead. I also reduced the overhead of -fprof-late* by pushing the cost centres into lambdas. This means the cost centres will only account for execution of functions and not their partial application. Further I made LATE_CC cost centres it's own CC flavour so they now won't clash with user defined ones if a user uses the same string for a custom scc. LateCC: Don't put cost centres inside constructor workers. With -fprof-late they are rarely useful as the worker is usually inlined. Even if the worker is not inlined or we use -fprof-late-linline they are generally not helpful but bloat compile and run time significantly. So we just don't add sccs inside constructor workers. ------------------------- Metric Decrease: T13701 ------------------------- - - - - - f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00 gitlab-ci: Fix hadrian bootstrapping of release pipelines Previously we would attempt to test hadrian bootstrapping in the `validate` build flavour. However, `ci.sh` refuses to run validation builds during release pipelines, resulting in job failures. Fix this by testing bootstrapping in the `release` flavour during release pipelines. We also attempted to record perf notes for these builds, which is redundant work and undesirable now since we no longer build in a consistent flavour. - - - - - c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00 compiler: Eliminate two uses of foldr in favor of foldl' These two uses constructed maps, which is a case where foldl' is generally more efficient since we avoid constructing an intermediate O(n)-depth stack. - - - - - d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00 rts: Fix code style - - - - - 57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00 genprimopcode: Drop ArrayArray# references As ArrayArray# no longer exists - - - - - 7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00 base: Organize Haddocks in GHC.Conc.Sync - - - - - aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00 Add primop to list threads A user came to #ghc yesterday wondering how best to check whether they were leaking threads. We ended up using the eventlog but it seems to me like it would be generally useful if Haskell programs could query their own threads. - - - - - 6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00 rts: Move thread labels into TSO This eliminates the thread label HashTable and instead tracks this information in the TSO, allowing us to use proper StgArrBytes arrays for backing the label and greatly simplifying management of object lifetimes when we expose them to the user with the coming `threadLabel#` primop. - - - - - 1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00 Add a primop to query the label of a thread - - - - - 43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00 base: Share finalization thread label For efficiency's sake we float the thread label assigned to the finalization thread to the top-level, ensuring that we only need to encode the label once. - - - - - 1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00 users-guide: Add release notes entry for thread introspection support - - - - - 09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix binary distribution install attributes Previously we would use plain `cp` to install various parts of the binary distribution. However, `cp`'s behavior w.r.t. file attributes is quite unclear; for this reason it is much better to rather use `install`. Fixes #21965. - - - - - 2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix installation of system-cxx-std-lib package conf - - - - - 7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00 gitlab-ci: Bump Docker images To give the ARMv7 job access to lld, fixing #21875. - - - - - afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Don't use mk/config.mk.in Ultimately we want to drop mk/config.mk so here I extract the bits needed by the Hadrian bindist installation logic into a Hadrian-specific file. While doing this I fixed binary distribution installation, #21901. - - - - - b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Fix naming of cross-compiler wrappers - - - - - 78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00 hadrian: Extend xattr Darwin hack to cover /lib As noted in #21506, it is now necessary to remove extended attributes from `/lib` as well as `/bin` to avoid SIP issues on Darwin. Fixes #21506. - - - - - 20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00 NCG(x86): Compile add+shift as lea if possible. - - - - - 742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00 dataToTag#: Skip runtime tag check if argument is infered tagged This addresses one part of #21710. - - - - - 1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00 rts: remove redundant stg_traceCcszh This out-of-line primop has no Haskell wrapper and hasn't been used anywhere in the tree. Furthermore, the code gets in the way of !7632, so it should be garbage collected. - - - - - a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00 Document a divergence from the report in parsing function lhss. GHC is happy to parse `(f) x y = x + y` when it should be a parse error based on the Haskell report. Seems harmless enough so we won't fix it but it's documented now. Fixes #19788 - - - - - 5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00 gitlab-ci: Add release job for aarch64/debian 11 - - - - - 5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Introduce validation job for aarch64 cross-compilation Begins to address #11958. - - - - - e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00 Bump process submodule - - - - - ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Add basic support for cross-compiler testiing Here we add a simple qemu-based test for cross-compilers. - - - - - 50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00 rts: Ensure that Array# card arrays are initialized In #19143 I noticed that newArray# failed to initialize the card table of newly-allocated arrays. However, embarrassingly, I then only fixed the issue in newArrayArray# and, in so doing, introduced the potential for an integer underflow on zero-length arrays (#21962). Here I fix the issue in newArray#, this time ensuring that we do not underflow in pathological cases. Fixes #19143. - - - - - e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00 testsuite: Add test for #21962 - - - - - c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00 gitlab-ci: Don't use coreutils on Darwin In general we want to ensure that the tested environment is as similar as possible to the environment the user will use. In the case of Darwin, this means we want to use the system's BSD command-line utilities, not coreutils. This would have caught #21974. - - - - - 1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00 hadrian: Fix bindist installation on Darwin It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does. - - - - - 681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00 hadrian: Fix access mode of installed package registration files Previously hadrian's bindist Makefile would modify package registrations placed by `install` via a shell pipeline and `mv`. However, the use of `mv` means that if umask is set then the user may otherwise end up with package registrations which are inaccessible. Fix this by ensuring that the mode is 0644. - - - - - e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00 Cleanups around pretty-printing * Remove hack when printing OccNames. No longer needed since e3dcc0d5 * Remove unused `pprCmms` and `instance Outputable Instr` * Simplify `pprCLabel` (no need to pass platform) * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by ImmLit, but that can take just a String instead. * Remove instance `Outputable CLabel` - proper output of labels needs a platform, and is done by the `OutputableP` instance - - - - - 66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00 rts/linker: Resolve iconv_* on FreeBSD FreeBSD's libiconv includes an implementation of the iconv_* functions in libc. Unfortunately these can only be resolved using dlvsym, which is how the RTS linker usually resolves such functions. To fix this we include an ad-hoc special case for iconv_*. Fixes #20354. - - - - - 5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00 system-cxx-std-lib: Add support for FreeBSD libcxxrt - - - - - ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00 gitlab-ci: Bump to use freebsd13 runners - - - - - d71a2051 by sheaf at 2022-08-09T13:47:28-04:00 Fix size_up_alloc to account for UnliftedDatatypes The size_up_alloc function mistakenly considered any type that isn't lifted to not allocate anything, which is wrong. What we want instead is to check the type isn't boxed. This accounts for (BoxedRep Unlifted). Fixes #21939 - - - - - 76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. - - - - - 7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. - - - - - dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00 Updates language extension documentation Adding a 'Status' field with a few values: - Deprecated - Experimental - InternalUseOnly - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98' Those values are pulled from the existing descriptions or elsewhere in the documentation. While at it, include the :implied by: where appropriate, to provide more detail. Fixes #21475 - - - - - 823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00 hadrian RunRest: add type signature for stageNumber avoids warning seen on 9.4.1: src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults] • Defaulting the following constraints to type ‘Integer’ (Show a0) arising from a use of ‘show’ at src/Settings/Builders/RunTest.hs:264:53-84 (Num a0) arising from a use of ‘stageNumber’ at src/Settings/Builders/RunTest.hs:264:59-83 • In the second argument of ‘(++)’, namely ‘show (stageNumber (C.stage ctx))’ In the second argument of ‘($)’, namely ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’ In the expression: arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | 264 | , arg "-e", arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compilation tested locally - - - - - f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00 Add support for external static plugins (#20964) This patch adds a new command-line flag: -fplugin-library=<file-path>;<unit-id>;<module>;<args> used like this: -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"] It allows a plugin to be loaded directly from a shared library. With this approach, GHC doesn't compile anything for the plugin and doesn't load any .hi file for the plugin and its dependencies. As such GHC doesn't need to support two environments (one for plugins, one for target code), which was the more ambitious approach tracked in #14335. Fix #20964 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Fix ARMv7 build It appears that the CI refactoring carried out in 5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some critical configuration: setting the build/host/target platforms and forcing use of a non-broken linker. - - - - - 596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Run ARMv7 jobs when ~ARM label is used - - - - - 7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00 hadrian: Don't attempt to install documentation if doc/ doesn't exist Previously we would attempt to install documentation even if the `doc` directory doesn't exist (e.g. due to `--docs=none`). This would result in the surprising side-effect of the entire contents of the bindist being installed in the destination documentation directory. Fix this. Fixes #21976. - - - - - 67575f20 by normalcoder at 2022-08-10T15:38:34-04:00 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - - - - - 45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00 Note [Trimming auto-rules]: State that this improves compiler perf. - - - - - 5c24b1b3 by Andrew Lelechenko at 2022-08-10T22:41:50-04:00 Document that threadDelay / timeout are susceptible to overflows on 32-bit machines - - - - - ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule - - - - - dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00 Revert "gitlab-ci: Add release job for aarch64/debian 11" This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46. The job was not tested before being merged and fails CI (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392) Ticket #22005 - - - - - ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00 typo - - - - - cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00 CmmToLlvm: Don't aliasify builtin LLVM variables Our aliasification logic would previously turn builtin LLVM variables into aliases, which apparently confuses LLVM. This manifested in initializers failing to be emitted, resulting in many profiling failures with the LLVM backend. Fixes #22019. - - - - - dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00 run_ci: remove monoidal-containers Fixes #21492 MonoidalMap is inlined and used to implement Variables, as before. The top-level value "jobs" is reimplemented as a regular Map, since it doesn't use the monoidal union anyway. - - - - - 64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00 CmmToAsm/AArch64: correct a typo - - - - - f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00 Fix #21979 - compact-share failing with -O I don't have good reason to believe the optimization level should affect if sharing works or not here. So limit the test to the normal way. - - - - - 68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix reference to dead llvm-version substitution Fixes #22052. - - - - - 28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix incorrect reference to `:extension: role - - - - - 71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Add :ghc-flag: reference - - - - - 385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00 hadrian: Place manpage in docroot This relocates it from docs/ to doc/ - - - - - 84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00 Bump haddock submodule Includes merge of `main` into `ghc-head` as well as some Haddock users guide fixes. - - - - - 59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00 base: Add changelog entries from ghc-9.2 Closes #21922. - - - - - a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00 relnotes: Add "included libraries" section As noted in #21988, some users rely on this. - - - - - a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Rephrase the rewrite rule documentation Previously the wording was a tad unclear. Fix this. Closes #21114. - - - - - 3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00 Implement Response File support for HPC This is an improvement to HPC authored by Richard Wallace (https://github.com/purefn) and myself. I have received permission from him to attempt to upstream it. This improvement was originally implemented as a patch to HPC via input-output-hk/haskell.nix: https://github.com/input-output-hk/haskell.nix/pull/1464 Paraphrasing Richard, HPC currently requires all inputs as command line arguments. With large projects this can result in an argument list too long error. I have only seen this error in Nix, but I assume it can occur is a plain Unix environment. This MR adds the standard response file syntax support to HPC. For example you can now pass a file to the command line which contains the arguments. ``` hpc @response_file_1 @response_file_2 ... The contents of a Response File must have this format: COMMAND ... example: report my_library.tix --include=ModuleA --include=ModuleB ``` Updates hpc submodule Co-authored-by: Richard Wallace <rwallace at thewallacepack.net> Fixes #22050 - - - - - 436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00 ghc-heap: Fix decoding of TSO closures An extra field was added to the TSO structure in 6d1700b6 but the decoding logic in ghc-heap was not updated for this new field. Fixes #22046 - - - - - a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00 driver: Honour -x option The -x option is used to manually specify which phase a file should be started to be compiled from (even if it lacks the correct extension). I just failed to implement this when refactoring the driver. In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to preprocess source files using GHC. I added a test to exercise this case. Fixes #22044 - - - - - e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00 Be more careful in chooseInferredQuantifiers This fixes #22065. We were failing to retain a quantifier that was mentioned in the kind of another retained quantifier. Easy to fix. - - - - - 714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00 testsuite: Add test for #21583 - - - - - 989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00 compiler: Drop --build-id=none hack Since 2011 the object-joining implementation has had a hack to pass `--build-id=none` to `ld` when supported, seemingly to work around a linker bug. This hack is now unnecessary and may break downstream users who expect objects to have valid build-ids. Remove it. Closes #22060. - - - - - 519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00 Make ru_fn field strict to avoid retaining Ids It's better to perform this projection from Id to Name strictly so we don't retain an old Id (hence IdInfo, hence Unfolding, hence everything etc) - - - - - 7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force `getOccFS bndr` to avoid retaining reference to Bndr. This is another symptom of #19619 - - - - - 4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force unfoldings when they are cleaned-up in Tidy and CorePrep If these thunks are not forced then the entire unfolding for the binding is live throughout the whole of CodeGen despite the fact it should have been discarded. Fixes #22071 - - - - - 2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00 haddock docs: Fix links from identifiers to dependent packages When implementing the base_url changes I made the pretty bad mistake of zipping together two lists which were in different orders. The simpler thing to do is just modify `haddockDependencies` to also return the package identifier so that everything stays in sync. Fixes #22001 - - - - - 9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00 Revert "Refactor SpecConstr to use treat bindings uniformly" This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729. This refactoring introduced quite a severe residency regression (900MB live from 650MB live when compiling mmark), see #21993 for a reproducer and more discussion. Ticket #21993 - - - - - 9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00 tc: warn about lazy annotations on unlifted arguments (fixes #21951) - - - - - e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00 Fix #22048 where we failed to drop rules for -fomit-interface-pragmas. Now we also filter the local rules (again) which fixes the issue. - - - - - 51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00 Print constraints in quotes (#21167) This patch improves the uniformity of error message formatting by printing constraints in quotes, as we do for types. Fix #21167 - - - - - ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00 19217 Implicitly quantify type variables in :kind command - - - - - 9939e95f by MorrowM at 2022-08-21T16:51:38-04:00 Recognize file-header pragmas in GHCi (#21507) - - - - - fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00 hadrian: Fix bootstrapping with ghc-9.4 The error was that we were trying to link together containers from boot package library (which depends template-haskell in boot package library) template-haskell from in-tree package database So the fix is to build containers in stage0 (and link against template-haskell built in stage0). Fixes #21981 - - - - - b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00 Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942. * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence * `ParensT` constructor is now always printed parenthesized * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down * using `>=` instead of former `>` to match the Core type printing logic * some test outputs have changed, losing extraneous parentheses - - - - - fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00 Fix and test for issue #21723 - - - - - 33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00 Test for issue #21942 - - - - - c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00 Updated the changelog - - - - - 80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00 hadrian: Don't duplicate binaries on installation Previously we used `install` on symbolic links, which ended up copying the target file rather than installing a symbolic link. Fixes #22062. - - - - - b929063e by Matthew Farkas-Dyck at 2022-08-24T02:37:01-04:00 Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Closes #22092. - - - - - 112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00 driver: don't actually merge objects when ar -L works - - - - - a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00 rts: Consistently use MiB in stats output Previously we would say `MB` even where we meant `MiB`. - - - - - a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223 - - - - - 909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00 upload_ghc_libs: Add means of passing Hackage credentials - - - - - 28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00 Scrub some partiality in `CommonBlockElim`. - - - - - 54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00 hadrian: Fix whitespace Previously this region of Settings.Packages was incorrectly indented. - - - - - c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00 validate: Drop --legacy flag In preparation for removal of the legacy `make`-based build system. - - - - - 822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00 gitlab-ci: Drop make build validation jobs In preparation for removal of the `make`-based build system - - - - - 6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop make build system Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html - - - - - dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00 Remove testsuite/tests/perf/haddock/.gitignore As noted in #16802, this is no longer needed. Closes #16802. - - - - - fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop hc-build script This has not worked for many, many years and relied on the now-removed `make`-based build system. - - - - - 659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mkdirhier This is only used by nofib's dead `dist` target - - - - - 4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mk/{build,install,config}.mk.in - - - - - 46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00 compiler: Drop comment references to make - - - - - d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add inits1 and tails1 to Data.List.NonEmpty See https://github.com/haskell/core-libraries-committee/issues/67 - - - - - 8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add since annotations and changelog entries - - - - - 6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00 Fix redundant import This fixes a build error on x86_64-linux-alpine3_12-validate. See the function 'loadExternalPlugins' defined in this file. - - - - - 4786acf7 by sheaf at 2022-08-26T15:05:23-04:00 Pmc: consider any 2 dicts of the same type equal This patch massages the keys used in the `TmOracle` `CoreMap` to ensure that dictionaries of coherent classes give the same key. That is, whenever we have an expression we want to insert or lookup in the `TmOracle` `CoreMap`, we first replace any dictionary `$dict_abcd :: ct` with a value of the form `error @ct`. This allows us to common-up view pattern functions with required constraints whose arguments differed only in the uniques of the dictionaries they were provided, thus fixing #21662. This is a rather ad-hoc change to the keys used in the `TmOracle` `CoreMap`. In the long run, we would probably want to use a different representation for the keys instead of simply using `CoreExpr` as-is. This more ambitious plan is outlined in #19272. Fixes #21662 Updates unix submodule - - - - - f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00 Remove label style from printing context Previously, the SDocContext used for code generation contained information whether the labels should use Asm or C style. However, at every individual call site, this is known statically. This removes the parameter to 'PprCode' and replaces every 'pdoc' used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'. The OutputableP instance is now used only for dumps. The output of T15155 changes, it now uses the Asm style (which is faithful to what actually happens). - - - - - 1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00 boot: cleanup legacy args Cleanup legacy boot script args, following removal of the legacy make build system. - - - - - 95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00 Improve SpecConstr for evals As #21763 showed, we were over-specialising in some cases, when the function involved was doing a simple 'eval', but not taking the value apart, or branching on it. This MR fixes the problem. See Note [Do not specialise evals]. Nofib barely budges, except that spectral/cichelli allocates about 3% less. Compiler bytes-allocated improves a bit geo. mean -0.1% minimum -0.5% maximum +0.0% The -0.5% is on T11303b, for what it's worth. - - - - - 565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Revert "Revert "Refactor SpecConstr to use treat bindings uniformly"" This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8. This commit was originally reverted due to an increase in space usage. This was diagnosed as because the SCE increased in size and that was being retained by another leak. See #22102 - - - - - 82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Avoid retaining bindings via ModGuts held on the stack It's better to overwrite the bindings fields of the ModGuts before starting an iteration as then all the old bindings can be collected as soon as the simplifier has processed them. Otherwise we end up with the old bindings being alive until right at the end of the simplifier pass as the mg_binds field is only modified right at the end. - - - - - 64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00 Force imposs_deflt_cons in filterAlts This fixes a pretty serious space leak as the forced thunk would retain `Alt b` values which would then contain reference to a lot of old bindings and other simplifier gunk. The OtherCon unfolding was not forced on subsequent simplifier runs so more and more old stuff would be retained until the end of simplification. Fixing this has a drastic effect on maximum residency for the mmark package which goes from ``` 45,005,401,056 bytes allocated in the heap 17,227,721,856 bytes copied during GC 818,281,720 bytes maximum residency (33 sample(s)) 9,659,144 bytes maximum slop 2245 MiB total memory in use (0 MB lost due to fragmentation) ``` to ``` 45,039,453,304 bytes allocated in the heap 13,128,181,400 bytes copied during GC 331,546,608 bytes maximum residency (40 sample(s)) 7,471,120 bytes maximum slop 916 MiB total memory in use (0 MB lost due to fragmentation) ``` See #21993 for some more discussion. - - - - - a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Use Solo to avoid retaining the SCE but to avoid performing the substitution The use of Solo here allows us to force the selection into the SCE to obtain the Subst but without forcing the substitution to be applied. The resulting thunk is placed into a lazy field which is rarely forced, so forcing it regresses peformance. - - - - - 161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00 Fix a nasty loop in Tidy As the remarkably-simple #22112 showed, we were making a black hole in the unfolding of a self-recursive binding. Boo! It's a bit tricky. Documented in GHC.Iface.Tidy, Note [tidyTopUnfolding: avoiding black holes] - - - - - 68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnIllegalHsigDefaultMethods TcRnBadGenericMethod TcRnWarningMinimalDefIncomplete TcRnDefaultMethodForPragmaLacksBinding TcRnIgnoreSpecialisePragmaOnDefMethod TcRnBadMethodErr TcRnNoExplicitAssocTypeOrDefaultDeclaration - - - - - cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00 Fix a bug in anyInRnEnvR This bug was a subtle error in anyInRnEnvR, introduced by commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06 Author: Andreas Klebinger <klebinger.andreas at gmx.at> Date: Sat Jul 9 01:19:52 2022 +0200 Rule matching: Don't compute the FVs if we don't look at them. The net result was #22028, where a rewrite rule would wrongly match on a lambda. The fix to that function is easy. - - - - - 0154bc80 by sheaf at 2022-08-30T06:05:41-04:00 Various Hadrian bootstrapping fixes - Don't always produce a distribution archive (#21629) - Use correct executable names for ghc-pkg and hsc2hs on windows (we were missing the .exe file extension) - Fix a bug where we weren't using the right archive format on Windows when unpacking the bootstrap sources. Fixes #21629 - - - - - 451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00 ci: Attempt using normal submodule cloning strategy We do not use any recursively cloned submodules, and this protects us from flaky upstream remotes. Fixes #22121 - - - - - 9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: stray "--" - - - - - 3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: syntatic -> syntactic - - - - - 7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00 Add a missing trimArityType This buglet was exposed by #22114, a consequence of my earlier refactoring of arity for join points. - - - - - e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump binary submodule to 0.8.9.1 - - - - - 4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump stm submodule to 2.5.1.0 - - - - - 837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00 users-guide: Document system-cxx-std-lib - - - - - f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00 Update submodule containers to 0.6.6 - - - - - 4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00 Update submodule process to 1.6.15.0 - - - - - 1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00 Bump directory submodule to 1.3.7.1 - - - - - 7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00 Bump text submodule to 2.0.1 - - - - - fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00 Bump deepseq submodule to 1.4.8.0 - - - - - a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00 Add dates to base, ghc-prim changelogs - - - - - 2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00 Update autoconf scripts Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983 - - - - - e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00 Bump bytestring submodule to 0.11.3.1 - - - - - f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00 Update submodule Cabal to tag Cabal-v3.8.1.0 closes #21931 - - - - - e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00 Refine in-tree compiler args for --test-compiler=stage1 Some of the logic to calculate in-tree arguments was not correct for the stage1 compiler. Namely we were not correctly reporting whether we were building static or dynamic executables and whether debug assertions were enabled. Fixes #22096 - - - - - 6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00 Make ghcDebugAssertions into a Stage predicate (Stage -> Bool) We also care whether we have debug assertions enabled for a stage one compiler, but the way which we turned on the assertions was quite different from the stage2 compiler. This makes the logic for turning on consistent across both and has the advantage of being able to correct determine in in-tree args whether a flavour enables assertions or not. Ticket #22096 - - - - - 15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00 Add regression test for #21550 This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5 "Use local instances with least superclass depth" - - - - - 7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00 Minor cleanup - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused), isCoVar_maybe (duplicated by getCoVar_maybe) - Replace a few occurrences of voidPrimId with (# #). void# is a deprecated synonym for the unboxed tuple. - Use showSDoc in :show linker. This makes it consistent with the other :show commands - - - - - 31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00 Fix bootstrap with ghc-9.0 It turns out Solo is a very recent addition to base, so for older GHC versions we just defined it inline here the one place we use it in the compiler. - - - - - d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00 DmdAnal: Don't panic in addCaseBndrDmd (#22039) Rather conservatively return Top. See Note [Untyped demand on case-alternative binders]. I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and `fieldBndrDmds`. Fixes #22039. - - - - - 25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00 gitlab-ci: Ensure that ghc derivation is in scope Previously the lint-ci job attempted to use cabal-install (specifically `cabal update`) without a GHC in PATH. However, cabal-install-3.8 appears to want GHC, even for `cabal update`. - - - - - f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00 typo - - - - - fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00 typos - - - - - a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00 whitespace - - - - - 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Andrew Lelechenko at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by Matthew Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Andrew Lelechenko at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Andrew Lelechenko at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Andrew Lelechenko at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Andrew Lelechenko at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Andrew Lelechenko at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Andrew Lelechenko at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Andrew Lelechenko at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergő Érdi at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Andrew Lelechenko at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by Matthew Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Andrew Lelechenko at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Andrew Lelechenko at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Andrew Lelechenko at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Andrew Lelechenko at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Andrew Lelechenko at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Andrew Lelechenko at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Andrew Lelechenko at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Andrew Lelechenko at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 75855643 by Ben Gamari at 2022-12-15T03:54:02-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - da7b51d8 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm: Introduce blockConcat - - - - - 34f6b09c by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm: Introduce MemoryOrderings - - - - - 43beaa7b by Ben Gamari at 2022-12-15T03:54:02-05:00 llvm: Respect memory specified orderings - - - - - 8faf74fc by Ben Gamari at 2022-12-15T03:54:02-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 6cc3944a by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Reduce some repetition - - - - - 6c9862c4 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 748490d2 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 28c6781a by Ben Gamari at 2022-12-15T03:54:02-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - d97aa311 by Ben Gamari at 2022-12-15T03:54:02-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 86974ef1 by Ben Gamari at 2022-12-15T03:54:02-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 93723290 by Ben Gamari at 2022-12-15T03:54:02-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-05:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-05:00 compiler: Ensure that MutVar operations have necessary barriers Here we add acquire and release barriers in readMutVar# and writeMutVar#, which are necessary for soundness. Fixes #22468. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-05:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Introduce getNumCapabilities And ensure accesses to n_capabilities are atomic (although with relaxed ordering). This is necessary as RTS API callers may concurrently call into the RTS without holding a capability. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts/Timer: Always use atomic operations As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Andrew Lelechenko at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Andrew Lelechenko at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05:00 packaging: Fix upload_ghc_libs.py script This change reflects the changes where .cabal files are now generated by hadrian rather than ./configure. Fixes #22518 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Andrew Lelechenko at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05:00 Abstract over the right free vars Fix #22459, in two ways: (1) Make the Specialiser not create a bogus specialisation if it is presented by strangely polymorphic dictionary. See Note [Weird special case in SpecDict] in GHC.Core.Opt.Specialise (2) Be more careful in abstractFloats See Note [Which type variables to abstract over] in GHC.Core.Opt.Simplify.Utils. So (2) stops creating the excessively polymorphic dictionary in abstractFloats, while (1) stops crashing if some other pass should nevertheless create a weirdly polymorphic dictionary. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05:00 Don't consider large byte arrays/compact regions pinned. Workaround for #22255 which showed how treating large/compact regions as pinned could cause segfaults. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Eliminate race in bump_static_flag To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix races in collector status tracking Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make bitmap accesses atomic This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix benign race in update remembered set check Relaxed load is fine here since we will take the lock before looking at the list. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in shortcutting We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-05:00 compiler: Ensure that GHC toolchain is first in search path As noted in #22561, it is important that GHC's toolchain look first for its own headers and libraries to ensure that the system's are not found instead. If this happens things can break in surprising ways (e.g. see #22561). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Andrew Lelechenko at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+00:00 Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Involves adding many new NFData instances. Without forcing Docs, references to the TcGblEnv for each module are retained by the Docs structure. Usually these are forced when the ModIface is serialised but not when we aren't writing the interface. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00:00 compiler: Add -f[no-]split-sections flags Here we add a `-fsplit-sections` flag which may some day replace `-split-sections`. This has the advantage of automatically providing a `-fno-split-sections` flag, which is useful for our packaging because we enable `-split-sections` by default but want to disable it in certain configurations. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add no_split_sections tranformer This transformer reverts the effect of `split_sections`, which we intend to use for platforms which don't support split sections. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+00:00 ci: Build all test dependencies with in-tree compiler This means that these executables will honour flavour transformers such as "werror". Fixes #22555 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+00:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 6e6adbe3 by Jade Lovelace at 2023-01-11T00:55:30-05:00 Fix tcPluginRewrite example - - - - - faa57138 by Jade Lovelace at 2023-01-11T00:55:31-05:00 fix missing haddock pipe - - - - - 0470ea7c by Florian Weimer at 2023-01-11T00:56:10-05:00 m4/fp_leading_underscore.m4: Avoid implicit exit function declaration And switch to a new-style function definition. Fixes build issues with compilers that do not accept implicit function declarations. - - - - - b2857df4 by HaskellMouse at 2023-01-11T00:56:52-05:00 Added a new warning about compatibility with RequiredTypeArguments This commit introduces a new warning that indicates code incompatible with future extension: RequiredTypeArguments. Enabling this extension may break some code and the warning will help to make it compatible in advance. - - - - - 5f17e21a by Ben Gamari at 2023-01-11T00:57:27-05:00 testsuite: Drop testheapalloced.c As noted in #22414, this file (which appears to be a benchmark for characterising the one-step allocator's MBlock cache) is currently unreferenced. Remove it. Closes #22414. - - - - - bc125775 by Vladislav Zavialov at 2023-01-11T00:58:03-05:00 Introduce the TypeAbstractions language flag GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 083f7015 by Krzysztof Gogolewski at 2023-01-11T00:58:38-05:00 Misc cleanup - Remove unused mkWildEvBinder - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - aed1974e by Richard Eisenberg at 2023-01-11T08:30:42+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666 and #19690 The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. * Treat the head of a Wanted quantified constraint in the same way as the superclass of an instance decl; this is what fixes #19690. See GHC.Tc.Solver.Canonical Note [Solving a Wanted forall-constraint] (Thanks to Matthew Craven for this insight.) This entailed refactoring the GivenSc constructor of CtOrigin a bit, to say whether it comes from an instance decl or quantified constraint. * Some refactoring way in which redundant constraints are reported; we don't want to complain about the extra, apparently-redundant constraints that we must add to an instance decl because of the loopy-superclass thing. I moved some work from GHC.Tc.Errors to GHC.Tc.Solver. * Add a new section to the user manual to describe the loopy superclass issue and what rules it follows. - - - - - 300bcc15 by HaskellMouse at 2023-01-11T13:43:36-05:00 Parse qualified terms in type signatures This commit allows qualified terms in type signatures to pass the parser and to be cathced by renamer with more informative error message. Adds a few tests. Fixes #21605 - - - - - 964284fc by Simon Peyton Jones at 2023-01-11T13:44:12-05:00 Fix void-arg-adding mechanism for worker/wrapper As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo. - - - - - f7ceafc9 by Krzysztof Gogolewski at 2023-01-11T22:36:59-05:00 Add 'docWithStyle' to improve codegen This new combinator docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc let us remove the need for code to be polymorphic in HDoc when not used in code style. Metric Decrease: ManyConstructors T13035 T1969 - - - - - b3be0d18 by Simon Peyton Jones at 2023-01-11T22:37:35-05:00 Fix finaliseArgBoxities for OPAQUE function We never do worker wrapper for OPAQUE functions, so we must zap the unboxing info during strictness analysis. This patch fixes #22502 - - - - - db11f358 by Ben Gamari at 2023-01-12T07:49:04-05:00 Revert "rts: Drop racy assertion" The logic here was inverted. Reverting the commit to avoid confusion when examining the commit history. This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1. - - - - - 3242139f by Ben Gamari at 2023-01-12T07:49:04-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - 9ffd5d57 by Ben Gamari at 2023-01-12T07:49:41-05:00 configure: Fix escaping of `$tooldir` In !9547 I introduced `$tooldir` directories into GHC's default link and compilation flags to ensure that our C toolchain finds its own headers and libraries before others on the system. However, the patch was subtly wrong in the escaping of `$tooldir`. Fix this. Fixes #22561. - - - - - 905d0b6e by Sebastian Graf at 2023-01-12T15:51:47-05:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. The refactoring seems to have quite beneficial effect on ghc/alloc performance: ``` CoOpt_Read(normal) ghc/alloc 784,778,420 768,091,176 -2.1% GOOD T12150(optasm) ghc/alloc 77,762,270 75,986,720 -2.3% GOOD T12425(optasm) ghc/alloc 85,740,186 84,641,712 -1.3% GOOD T13056(optasm) ghc/alloc 306,104,656 299,811,632 -2.1% GOOD T13253(normal) ghc/alloc 350,233,952 346,004,008 -1.2% T14683(normal) ghc/alloc 2,800,514,792 2,754,651,360 -1.6% T15304(normal) ghc/alloc 1,230,883,318 1,215,978,336 -1.2% T15630(normal) ghc/alloc 153,379,590 151,796,488 -1.0% T16577(normal) ghc/alloc 7,356,797,056 7,244,194,416 -1.5% T17516(normal) ghc/alloc 1,718,941,448 1,692,157,288 -1.6% T19695(normal) ghc/alloc 1,485,794,632 1,458,022,112 -1.9% T21839c(normal) ghc/alloc 437,562,314 431,295,896 -1.4% GOOD T21839r(normal) ghc/alloc 446,927,580 440,615,776 -1.4% GOOD geo. mean -0.6% minimum -2.4% maximum -0.0% ``` Metric Decrease: CoOpt_Read T10421 T12150 T12425 T13056 T18698a T18698b T21839c T21839r T9961 - - - - - a1491c87 by Andreas Klebinger at 2023-01-12T15:52:23-05:00 Only gc sparks locally when we can ensure marking is done. When performing GC without work stealing there was no guarantee that spark pruning was happening after marking of the sparks. This could cause us to GC live sparks under certain circumstances. Fixes #22528. - - - - - 8acfe930 by Cheng Shao at 2023-01-12T15:53:00-05:00 Change MSYSTEM to CLANG64 uniformly - - - - - 73bc162b by M Farkas-Dyck at 2023-01-12T15:53:42-05:00 Make `GHC.Tc.Errors.Reporter` take `NonEmpty ErrorItem` rather than `[ErrorItem]`, which lets us drop some panics. Also use the `BasicMismatch` constructor rather than `mkBasicMismatchMsg`, which lets us drop the "-Wno-incomplete-record-updates" flag. - - - - - 1b812b69 by Oleg Grenrus at 2023-01-12T15:54:21-05:00 Fix #22728: Not all diagnostics in safe check are fatal Also add tests for the issue and -Winferred-safe-imports in general - - - - - c79b2b65 by Matthew Pickering at 2023-01-12T15:54:58-05:00 Don't run hadrian-multi on fast-ci label Fixes #22667 - - - - - 9a3d6add by Andrew Lelechenko at 2023-01-13T00:46:36-05:00 Bump submodule bytestring to 0.11.4.0 Metric Decrease: T21839c T21839r - - - - - df33c13c by Ben Gamari at 2023-01-13T00:47:12-05:00 gitlab-ci: Bump Darwin bootstrap toolchain This updates the bootstrap compiler on Darwin from 8.10.7 to 9.2.5, ensuring that we have the fix for #21964. - - - - - 756a66ec by Ben Gamari at 2023-01-13T00:47:12-05:00 gitlab-ci: Pass -w to cabal update Due to cabal#8447, cabal-install 3.8.1.0 requires a compiler to run `cabal update`. - - - - - 1142f858 by Cheng Shao at 2023-01-13T11:04:00+00:00 Bump hsc2hs submodule - - - - - d4686729 by Cheng Shao at 2023-01-13T11:04:00+00:00 Bump process submodule - - - - - 84ae6573 by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: Bump DOCKER_REV - - - - - d53598c5 by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: enable xz parallel compression for x64 jobs - - - - - d31fcbca by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: use in-image emsdk for js jobs - - - - - 93b9bbc1 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: improve nix-shell for gen_ci.hs and fix some ghc/hlint warnings - Add a ghc environment including prebuilt dependencies to the nix-shell. Get rid of the ad hoc cabal cache and all dependencies are now downloaded from the nixos binary cache. - Make gen_ci.hs a cabal package with HLS integration, to make future hacking of gen_ci.hs easier. - Fix some ghc/hlint warnings after I got HLS to work. - For the lint-ci-config job, do a shallow clone to save a few minutes of unnecessary git checkout time. - - - - - 8acc56c7 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: source the toolchain env file in wasm jobs - - - - - 87194df0 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: add wasm ci jobs via gen_ci.hs - There is one regular wasm job run in validate pipelines - Additionally, int-native/unreg wasm jobs run in nightly/release pipelines Also, remove the legacy handwritten wasm ci jobs in .gitlab-ci.yml. - - - - - b6eb9bcc by Matthew Pickering at 2023-01-13T11:52:16+00:00 wasm ci: Remove wasm release jobs This removes the wasm release jobs, as we do not yet intend to distribute these binaries. - - - - - 496607fd by Simon Peyton Jones at 2023-01-13T16:52:07-05:00 Add a missing checkEscapingKind Ticket #22743 pointed out that there is a missing check, for type-inferred bindings, that the inferred type doesn't have an escaping kind. The fix is easy. - - - - - 7a9a1042 by Andreas Klebinger at 2023-01-16T20:48:19-05:00 Separate core inlining logic from `Unfolding` type. This seems like a good idea either way, but is mostly motivated by a patch where this avoids a module loop. - - - - - 33b58f77 by sheaf at 2023-01-16T20:48:57-05:00 Hadrian: generalise &%> to avoid warnings This patch introduces a more general version of &%> that works with general traversable shapes, instead of lists. This allows us to pass along the information that the length of the list of filepaths passed to the function exactly matches the length of the input list of filepath patterns, avoiding pattern match warnings. Fixes #22430 - - - - - 8c7a991c by Andreas Klebinger at 2023-01-16T20:49:34-05:00 Add regression test for #22611. A case were a function used to fail to specialize, but now does. - - - - - 6abea760 by Andreas Klebinger at 2023-01-16T20:50:10-05:00 Mark maximumBy/minimumBy as INLINE. The RHS was too large to inline which often prevented the overhead of the Maybe from being optimized away. By marking it as INLINE we can eliminate the overhead of both the maybe and are able to unpack the accumulator when possible. Fixes #22609 - - - - - 99d151bb by Matthew Pickering at 2023-01-16T20:50:50-05:00 ci: Bump CACHE_REV so that ghc-9.6 branch and HEAD have different caches Having the same CACHE_REV on both branches leads to issues where the darwin toolchain is different on ghc-9.6 and HEAD which leads to long darwin build times. In general we should ensure that each branch has a different CACHE_REV. - - - - - 6a5845fb by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Change owner of files in source-tarball job This fixes errors of the form: ``` fatal: detected dubious ownership in repository at '/builds/ghc/ghc' To add an exception for this directory, call: git config --global --add safe.directory /builds/ghc/ghc inferred 9.7.20230113 checking for GHC Git commit id... fatal: detected dubious ownership in repository at '/builds/ghc/ghc' To add an exception for this directory, call: git config --global --add safe.directory /builds/ghc/ghc ``` - - - - - 4afb952c by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Don't build aarch64-deb10-llvm job on release pipelines Closes #22721 - - - - - 8039feb9 by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Change owner of files in test-bootstrap job - - - - - 0b358d0c by Matthew Pickering at 2023-01-16T20:51:25-05:00 rel_eng: Add release engineering scripts into ghc tree It is better to keep these scripts in the tree as they depend on the CI configuration and so on. By keeping them in tree we can keep them up-to-date as the CI config changes and also makes it easier to backport changes to the release script between release branches in future. The final motivation is that it makes generating GHCUp metadata possible. - - - - - 28cb2ed0 by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Don't use complicated image or clone in not-interruptible job This job exists only for the meta-reason of not allowing nightly pipelines to be cancelled. It was taking two minutes to run as in order to run "true" we would also clone the whole GHC repo. - - - - - eeea59bb by Matthew Pickering at 2023-01-16T20:51:26-05:00 Add scripts to generate ghcup metadata on nightly and release pipelines 1. A python script in .gitlab/rel_eng/mk-ghcup-metadata which generates suitable metadata for consumption by GHCUp for the relevant pipelines. - The script generates the metadata just as the ghcup maintainers want, without taking into account platform/library combinations. It is updated manually when the mapping changes. - The script downloads the bindists which ghcup wants to distribute, calculates the hash and generates the yaml in the correct structure. - The script is documented in the .gitlab/rel_eng/mk-ghcup-metadata/README.mk file 1a. The script requires us to understand the mapping from platform -> job. To choose the preferred bindist for each platform the .gitlab/gen_ci.hs script is modified to allow outputting a metadata file which answers the question about which job produces the bindist which we want to distribute to users for a specific platform. 2. Pipelines to run on nightly and release jobs to generate metadata - ghcup-metadata-nightly: Generates metadata which points directly to artifacts in the nightly job. - ghcup-metadata-release: Generates metadata suitable for inclusion directly in ghcup by pointing to the downloads folder where the bindist will be uploaded to. 2a. Trigger jobs which test the generated metadata in the downstream `ghccup-ci` repo. See that repo for documentation about what is tested and how but essentially we test in a variety of clean images that ghcup can download and install the bindists we say exist in our metadata. - - - - - 97bd4d8c by Andrew Lelechenko at 2023-01-16T20:52:04-05:00 Bump submodule parsec to 3.1.16.1 - - - - - 97ac8230 by Alan Zimmerman at 2023-01-16T20:52:39-05:00 EPA: Add annotation for 'type' in DataDecl Closes #22765 - - - - - dbbab95d by Ben Gamari at 2023-01-17T06:36:06-05:00 compiler: Small optimisation of assertM In #22739 @AndreasK noticed that assertM performed the action to compute the asserted predicate regardless of whether DEBUG is enabled. This is inconsistent with the other assertion operations and general convention. Fix this. Closes #22739. - - - - - fc02f3bb by Viktor Dukhovni at 2023-01-17T06:36:47-05:00 Avoid unnecessary printf warnings in EventLog.c Fixes #22778 - - - - - 003b6d44 by Simon Peyton Jones at 2023-01-17T16:33:05-05:00 Document the semantics of pattern bindings a bit better This MR is in response to the discussion on #22719 - - - - - f4d50baf by Vladislav Zavialov at 2023-01-17T16:33:41-05:00 Hadrian: fix warnings (#22783) This change fixes the following warnings when building Hadrian: src/Hadrian/Expression.hs:38:10: warning: [-Wredundant-constraints] src/Hadrian/Expression.hs:84:13: warning: [-Wtype-equality-requires-operators] src/Hadrian/Expression.hs:84:21: warning: [-Wtype-equality-requires-operators] src/Hadrian/Haskell/Cabal/Parse.hs:67:1: warning: [-Wunused-imports] - - - - - 06036d93 by Sylvain Henry at 2023-01-18T01:55:10-05:00 testsuite: req_smp --> req_target_smp, req_ghc_smp See #22630 and !9552 This commit: - splits req_smp into req_target_smp and req_ghc_smp - changes the testsuite driver to calculate req_ghc_smp - changes a handful of tests to use req_target_smp instead of req_smp - changes a handful of tests to use req_host_smp when needed The problem: - the problem this solves is the ambiguity surrounding req_smp - on master req_smp was used to express the constraint that the program being compiled supports smp _and_ that the host RTS (i.e., the RTS used to compile the program) supported smp. Normally that is fine, but in cross compilation this is not always the case as was discovered in #22630. The solution: - Differentiate the two constraints: - use req_target_smp to say the RTS the compiled program is linked with (and the platform) supports smp - use req_host_smp to say the RTS the host is linked with supports smp WIP: fix req_smp (target vs ghc) add flag to separate bootstrapper split req_smp -> req_target_smp and req_ghc_smp update tests smp flags cleanup and add some docstrings only set ghc_with_smp to bootstrapper on S1 or CC Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1 and cross compiling test the RTS in config/ghc not hadrian re-add ghc_with_smp fix and align req names fix T11760 to use req_host_smp test the rts directly, avoid python 3.5 limitation test the compiler in a try block align out of tree and in tree withSMP flags mark failing tests as host req smp testsuite: req_host_smp --> req_ghc_smp Fix ghc vs host, fix ghc_with_smp leftover - - - - - ee9b78aa by Krzysztof Gogolewski at 2023-01-18T01:55:45-05:00 Use -Wdefault when running Python testdriver (#22727) - - - - - e9c0537c by Vladislav Zavialov at 2023-01-18T01:56:22-05:00 Enable -Wstar-is-type by default (#22759) Following the plan in GHC Proposal #143 "Remove the * kind syntax", which states: In the next release (or 3 years in), enable -fwarn-star-is-type by default. The "next release" happens to be 9.6.1 I also moved the T21583 test case from should_fail to should_compile, because the only reason it was failing was -Werror=compat in our test suite configuration. - - - - - 4efee43d by Ryan Scott at 2023-01-18T01:56:59-05:00 Add missing parenthesizeHsType in cvtSigTypeKind We need to ensure that the output of `cvtSigTypeKind` is parenthesized (at precedence `sigPrec`) so that any type signatures with an outermost, explicit kind signature can parse correctly. Fixes #22784. - - - - - f891a442 by Ben Gamari at 2023-01-18T07:28:00-05:00 Bump ghc-tarballs to fix #22497 It turns out that gmp 6.2.1 uses the platform-reserved `x18` register on AArch64/Darwin. This was fixed in upstream changeset 18164:5f32dbc41afc, which was merged in 2020. Here I backport this patch although I do hope that a new release is forthcoming soon. Bumps gmp-tarballs submodule. Fixes #22497. - - - - - b13c6ea5 by Ben Gamari at 2023-01-18T07:28:00-05:00 Bump gmp-tarballs submodule This backports the upstream fix for CVE-2021-43618, fixing #22789. - - - - - c45a5fff by Cheng Shao at 2023-01-18T07:28:37-05:00 Fix typo in recent darwin tests fix Corrects a typo in !9647. Otherwise T18623 will still fail on darwin and stall other people's work. - - - - - b4c14c4b by Luite Stegeman at 2023-01-18T14:21:42-05:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - d0a63ef8 by Adam Gundry at 2023-01-18T14:22:26-05:00 Refactor warning flag parsing to add missing flags This adds `-Werror=<group>` and `-fwarn-<group>` flags for warning groups as well as individual warnings. Previously these were defined on an ad hoc basis so for example we had `-Werror=compat` but not `-Werror=unused-binds`, whereas we had `-fwarn-unused-binds` but not `-fwarn-compat`. Fixes #22182. - - - - - 7ed1b8ef by Adam Gundry at 2023-01-18T14:22:26-05:00 Minor corrections to comments - - - - - 5389681e by Adam Gundry at 2023-01-18T14:22:26-05:00 Revise warnings documentation in user's guide - - - - - ab0d5cda by Adam Gundry at 2023-01-18T14:22:26-05:00 Move documentation of deferred type error flags out of warnings section - - - - - eb5a6b91 by John Ericson at 2023-01-18T22:24:10-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - 32ab07bf by Andrew Lelechenko at 2023-01-18T22:24:51-05:00 ghc package does not have to depend on terminfo - - - - - 981ff7c4 by Andrew Lelechenko at 2023-01-18T22:24:51-05:00 ghc-pkg does not have to depend on terminfo - - - - - f058e367 by Ben Gamari at 2023-01-18T22:25:27-05:00 nativeGen/X86: MFENCE is unnecessary for release semantics In #22764 a user noticed that a program implementing a simple atomic counter via an STRef regressed significantly due to the introduction of necessary atomic operations in the MutVar# primops (#22468). This regression was caused by a bug in the NCG, which emitted an unnecessary MFENCE instruction for a release-ordered atomic write. MFENCE is rather only needed to achieve sequentially consistent ordering. Fixes #22764. - - - - - 154889db by Ryan Scott at 2023-01-18T22:26:03-05:00 Add regression test for #22151 Issue #22151 was coincidentally fixed in commit aed1974e92366ab8e117734f308505684f70cddf (`Refactor the treatment of loopy superclass dicts`). This adds a regression test to ensure that the issue remains fixed. Fixes #22151. - - - - - 14b5982a by Andrei Borzenkov at 2023-01-18T22:26:43-05:00 Fix printing of promoted MkSolo datacon (#22785) Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo, and Solo was turned into a pattern synonym for backwards compatibility. Since pattern synonyms can not be promoted, the old code that pretty-printed promoted single-element tuples started producing ill-typed code: t :: Proxy ('Solo Int) This fails with "Pattern synonym ‘Solo’ used as a type" The solution is to track the distinction between type constructors and data constructors more carefully when printing single-element tuples. - - - - - 1fe806d3 by Cheng Shao at 2023-01-23T04:48:47-05:00 hadrian: add hi_core flavour transformer The hi_core flavour transformer enables -fwrite-if-simplified-core for stage1 libraries, which emit core into interface files to make it possible to restart code generation. Building boot libs with it makes it easier to use GHC API to prototype experimental backends that needs core/stg at link time. - - - - - 317cad26 by Cheng Shao at 2023-01-23T04:48:47-05:00 hadrian: add missing docs for recently added flavour transformers - - - - - 658f4446 by Ben Gamari at 2023-01-23T04:49:23-05:00 gitlab-ci: Add Rocky8 jobs Addresses #22268. - - - - - a83ec778 by Vladislav Zavialov at 2023-01-23T04:49:58-05:00 Set "since: 9.8" for TypeAbstractions and -Wterm-variable-capture These flags did not make it into the 9.6 release series, so the "since" annotations must be corrected. - - - - - fec7c2ea by Alan Zimmerman at 2023-01-23T04:50:33-05:00 EPA: Add SourceText to HsOverLabel To be able to capture string literals with possible escape codes as labels. Close #22771 - - - - - 3efd1e99 by Ben Gamari at 2023-01-23T04:51:08-05:00 template-haskell: Bump version to 2.20.0.0 Updates `text` and `exceptions` submodules for bounds bumps. Addresses #22767. - - - - - 0900b584 by Cheng Shao at 2023-01-23T04:51:45-05:00 hadrian: disable alloca for in-tree GMP on wasm32 When building in-tree GMP for wasm32, disable its alloca usage, since it may potentially cause stack overflow (e.g. #22602). - - - - - db0f1bfd by Cheng Shao at 2023-01-23T04:52:21-05:00 Bump process submodule Includes a critical fix for wasm32, see https://github.com/haskell/process/pull/272 for details. Also changes the existing cross test to include process stuff and avoid future regression here. - - - - - 9222b167 by Matthew Pickering at 2023-01-23T04:52:57-05:00 ghcup metadata: Fix subdir for windows bindist - - - - - 9a9bec57 by Matthew Pickering at 2023-01-23T04:52:57-05:00 ghcup metadata: Remove viPostRemove field from generated metadata This has been removed from the downstream metadata. - - - - - 82884ce0 by Simon Peyton Jones at 2023-01-23T04:53:32-05:00 Fix #22742 runtimeRepLevity_maybe was panicing unnecessarily; and the error printing code made use of the case when it should return Nothing rather than panicing. For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime peak-megagbytes-used, on a single architecture (alpine). See !9753 for commentary, but I'm going to accept it. Metric Increase: T21839r - - - - - 2c6deb18 by Bryan Richter at 2023-01-23T14:12:22+02:00 codeowners: Add Ben, Matt, and Bryan to CI - - - - - eee3bf05 by Matthew Craven at 2023-01-23T21:46:41-05:00 Do not collect compile-time metrics for T21839r ...the testsuite doesn't handle this properly since it also collects run-time metrics. Compile-time metrics for this test are already tracked via T21839c. Metric Decrease: T21839r - - - - - 1d1dd3fb by Matthew Pickering at 2023-01-24T05:37:52-05:00 Fix recompilation checking for multiple home units The key part of this change is to store a UnitId in the `UsageHomeModule` and `UsageHomeModuleInterface`. * Fine-grained dependency tracking is used if the dependency comes from any home unit. * We actually look up the right module when checking whether we need to recompile in the `UsageHomeModuleInterface` case. These scenarios are both checked by the new tests ( multipleHomeUnits_recomp and multipleHomeUnits_recomp_th ) Fixes #22675 - - - - - 7bfb30f9 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Augment target filepath by working directory when checking if module satisfies target This fixes a spurious warning in -Wmissing-home-modules. This is a simple oversight where when looking for the target in the first place we augment the search by the -working-directory flag but then fail to do so when checking this warning. Fixes #22676 - - - - - 69500dd4 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Use NodeKey rather than ModuleName in pruneCache The `pruneCache` function assumes that the list of `CachedInfo` all have unique `ModuleName`, this is not true: * In normal compilation, the same module name can appear for a file and it's boot file. * In multiple home unit compilation the same ModuleName can appear in different units The fix is to use a `NodeKey` as the actual key for the interfaces which includes `ModuleName`, `IsBoot` and `UnitId`. Fixes #22677 - - - - - 336b2b1c by Matthew Pickering at 2023-01-24T05:37:52-05:00 Recompilation checking: Don't try to find artefacts for Interactive & hs-boot combo In interactive mode we don't produce any linkables for hs-boot files. So we also need to not going looking for them when we check to see if we have all the right objects needed for recompilation. Ticket #22669 - - - - - 6469fea7 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Don't write o-boot files in Interactive mode We should not be producing object files when in interactive mode but we still produced the dummy o-boot files. These never made it into a `Linkable` but then confused the recompilation checker. Fixes #22669 - - - - - 06cc0a95 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Improve driver diagnostic messages by including UnitId in message Currently the driver diagnostics don't give any indication about which unit they correspond to. For example `-Wmissing-home-modules` can fire multiple times for each different home unit and gives no indication about which unit it's actually reporting about. Perhaps a longer term fix is to generalise the providence information away from a SrcSpan so that these kind of whole project errors can be reported with an accurate provenance. For now we can just include the `UnitId` in the error message. Fixes #22678 - - - - - 4fe9eaff by Matthew Pickering at 2023-01-24T05:37:52-05:00 Key ModSummary cache by UnitId as well as FilePath Multiple units can refer to the same files without any problem. Just another assumption which needs to be updated when we may have multiple home units. However, there is the invariant that within each unit each file only maps to one module, so as long as we also key the cache by UnitId then we are all good. This led to some confusing behaviour in GHCi when reloading, multipleHomeUnits_shared distils the essence of what can go wrong. Fixes #22679 - - - - - ada29f5c by Matthew Pickering at 2023-01-24T05:37:52-05:00 Finder: Look in current unit before looking in any home package dependencies In order to preserve existing behaviour it's important to look within the current component before consideirng a module might come from an external component. This already happened by accident in `downsweep`, (because roots are used to repopulated the cache) but in the `Finder` the logic was the wrong way around. Fixes #22680 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp -------------------------p - - - - - be701cc6 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Debug: Print full NodeKey when pretty printing ModuleGraphNode This is helpful when debugging multiple component issues. - - - - - 34d2d463 by Krzysztof Gogolewski at 2023-01-24T05:38:32-05:00 Fix Lint check for duplicate external names Lint was checking for duplicate external names by calling removeDups, which needs a comparison function that is passed to Data.List.sortBy. But the comparison was not a valid ordering - it returned LT if one of the names was not external. For example, the previous implementation won't find a duplicate in [M.x, y, M.x]. Instead, we filter out non-external names before looking for duplicates. - - - - - 1c050ed2 by Matthew Pickering at 2023-01-24T05:39:08-05:00 Add test for T22671 This was fixed by b13c6ea5 Closes #22671 - - - - - 05e6a2d9 by Tom Ellis at 2023-01-24T12:10:52-05:00 Clarify where `f` is defined - - - - - d151546e by Cheng Shao at 2023-01-24T12:11:29-05:00 CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target We used to print the offset value to a platform word sized integer. This is incorrect when the offset is negative (e.g. output of cmm constant folding) and the register is 64-bit but on a 32-bit target, and may lead to incorrect runtime result (e.g. #22607). The fix is simple: just treat it as a proper MO_Add, with the correct width info inferred from the register itself. Metric Increase: T12707 T13379 T4801 T5321FD T5321Fun - - - - - e5383a29 by Wander Hillen at 2023-01-24T20:02:26-05:00 Allow waiting for timerfd to be interrupted during rts shutdown - - - - - 1957eda1 by Ryan Scott at 2023-01-24T20:03:01-05:00 Restore Compose's Read/Show behavior to match Read1/Show1 instances Fixes #22816. - - - - - 30972827 by Matthew Pickering at 2023-01-25T03:54:14-05:00 docs: Update INSTALL.md Removes references to make. Fixes #22480 - - - - - bc038c3b by Cheng Shao at 2023-01-25T03:54:50-05:00 compiler: fix handling of MO_F_Neg in wasm NCG In the wasm NCG, we used to compile MO_F_Neg to 0.0-x. It was an oversight, there actually exists f32.neg/f64.neg opcodes in the wasm spec and those should be used instead! The old behavior almost works, expect when GHC compiles the -0.0 literal, which will incorrectly become 0.0. - - - - - e987e345 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Hadrian: correctly detect AR at-file support Stage0's ar may not support at-files. Take it into account. Found while cross-compiling from Darwin to Windows. - - - - - 48131ee2 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Hadrian: fix Windows cross-compilation Decision to build either unix or Win32 package must be stage specific for cross-compilation to be supported. - - - - - 288fa017 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Fix RTS build on Windows This change fixes a cross-compilation issue from ArchLinux to Windows because these symbols weren't found. - - - - - 2fdf22ae by Sylvain Henry at 2023-01-25T14:47:41-05:00 configure: support "windows" as an OS - - - - - 13a0566b by Simon Peyton Jones at 2023-01-25T14:48:16-05:00 Fix in-scope set in specImports Nothing deep here; I had failed to bring some floated dictionary binders into scope. Exposed by -fspecialise-aggressively Fixes #22715. - - - - - b7efdb24 by Matthew Pickering at 2023-01-25T14:48:51-05:00 ci: Disable HLint job due to excessive runtime The HLint jobs takes much longer to run (20 minutes) after "Give the RTS it's own configure script" eb5a6b91 Now the CI job will build the stage0 compiler before it generates the necessary RTS headers. We either need to: * Fix the linting rules so they take much less time * Revert the commit * Remove the linting of base from the hlint job * Remove the hlint job This is highest priority as it is affecting all CI pipelines. For now I am just disabling the job because there are many more pressing matters at hand. Ticket #22830 - - - - - 1bd32a35 by Sylvain Henry at 2023-01-26T12:34:21-05:00 Factorize hptModulesBelow Create and use moduleGraphModulesBelow in GHC.Unit.Module.Graph that doesn't need anything from the driver to be used. - - - - - 1262d3f8 by Matthew Pickering at 2023-01-26T12:34:56-05:00 Store dehydrated data structures in CgModBreaks This fixes a tricky leak in GHCi where we were retaining old copies of HscEnvs when reloading. If not all modules were recompiled then these hydrated fields in break points would retain a reference to the old HscEnv which could double memory usage. Fixes #22530 - - - - - e27eb80c by Matthew Pickering at 2023-01-26T12:34:56-05:00 Force more in NFData Name instance Doesn't force the lazy `OccName` field (#19619) which is already known as a really bad source of leaks. When we slam the hammer storing Names on disk (in interface files or the like), all this should be forced as otherwise a `Name` can easily retain an `Id` and hence the entire world. Fixes #22833 - - - - - 3d004d5a by Matthew Pickering at 2023-01-26T12:34:56-05:00 Force OccName in tidyTopName This occname has just been derived from an `Id`, so need to force it promptly so we can release the Id back to the world. Another symptom of the bug caused by #19619 - - - - - f2a0fea0 by Matthew Pickering at 2023-01-26T12:34:56-05:00 Strict fields in ModNodeKey (otherwise retains HomeModInfo) Towards #22530 - - - - - 5640cb1d by Sylvain Henry at 2023-01-26T12:35:36-05:00 Hadrian: fix doc generation Was missing dependencies on files generated by templates (e.g. ghc.cabal) - - - - - 3e827c3f by Richard Eisenberg at 2023-01-26T20:06:53-05:00 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. Close #22519. - - - - - b3ef5c89 by doyougnu at 2023-01-26T20:07:48-05:00 tryFillBuffer: strictify more speculative bangs - - - - - d0d7ba0f by Vladislav Zavialov at 2023-01-26T20:08:25-05:00 base: NoImplicitPrelude in Data.Void and Data.Kind This change removes an unnecessary dependency on Prelude from two modules in the base package. - - - - - fa1db923 by Matthew Pickering at 2023-01-26T20:09:00-05:00 ci: Add ubuntu18_04 nightly and release jobs This adds release jobs for ubuntu18_04 which uses glibc 2.27 which is older than the 2.28 which is used by Rocky8 bindists. Ticket #22268 - - - - - 807310a1 by Matthew Pickering at 2023-01-26T20:09:00-05:00 rel-eng: Add missing rocky8 bindist We intend to release rocky8 bindist so the fetching script needs to know about them. - - - - - c7116b10 by Ben Gamari at 2023-01-26T20:09:35-05:00 base: Make changelog proposal references more consistent Addresses #22773. - - - - - 6932cfc7 by Sylvain Henry at 2023-01-26T20:10:27-05:00 Fix spurious change from !9568 - - - - - e480fbc2 by Ben Gamari at 2023-01-27T05:01:24-05:00 rts: Use C11-compliant static assertion syntax Previously we used `static_assert` which is only available in C23. By contrast, C11 only provides `_Static_assert`. Fixes #22777 - - - - - 2648c09c by Andrei Borzenkov at 2023-01-27T05:02:07-05:00 Replace errors from badOrigBinding with new one (#22839) Problem: in 02279a9c the type-level [] syntax was changed from a built-in name to an alias for the GHC.Types.List constructor. badOrigBinding assumes that if a name is not built-in then it must have come from TH quotation, but this is not necessarily the case with []. The outdated assumption in badOrigBinding leads to incorrect error messages. This code: data [] Fails with "Cannot redefine a Name retrieved by a Template Haskell quote: []" Unfortunately, there is not enough information in RdrName to directly determine if the name was constructed via TH or by the parser, so this patch changes the error message instead. It unifies TcRnIllegalBindingOfBuiltIn and TcRnNameByTemplateHaskellQuote into a new error TcRnBindingOfExistingName and changes its wording to avoid guessing the origin of the name. - - - - - 545bf8cf by Matthew Pickering at 2023-01-27T14:58:53+00:00 Revert "base: NoImplicitPrelude in Data.Void and Data.Kind" Fixes CI errors of the form. ``` ===> Command failed with error code: 1 ghc: panic! (the 'impossible' happened) GHC version 9.7.20230127: lookupGlobal Failed to load interface for ‘GHC.Num.BigNat’ There are files missing in the ‘ghc-bignum’ package, try running 'ghc-pkg check'. Use -v (or `:set -v` in ghci) to see a list of the files searched for. Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic pprPanic, called at compiler/GHC/Tc/Utils/Env.hs:154:32 in ghc:GHC.Tc.Utils.Env CallStack (from HasCallStack): panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` This reverts commit d0d7ba0fb053ebe7f919a5932066fbc776301ccd. The module now lacks a dependency on GHC.Num.BigNat which it implicitly depends on. It is causing all CI jobs to fail so we revert without haste whilst the patch can be fixed. Fixes #22848 - - - - - 638277ba by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Detect family instance orphans correctly We were treating a type-family instance as a non-orphan if there was a type constructor on its /right-hand side/ that was local. Boo! Utterly wrong. With this patch, we correctly check the /left-hand side/ instead! Fixes #22717 - - - - - 46a53bb2 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Report family instance orphans correctly This fixes the fact that we were not reporting orphan family instances at all. The fix here is easy, but touches a bit of code. I refactored the code to be much more similar to the way that class instances are done: - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst - Make newFamInst initialise this field, just like newClsInst - And make newFamInst report a warning for an orphan, just like newClsInst - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate, just like newClsInst. - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv - TcRnOrphanInstance and SuggestFixOrphanInstance are now parametrised over class instances vs type/data family instances. Fixes #19773 - - - - - faa300fb by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Avoid orphans in STG This patch removes some orphan instances in the STG namespace by introducing the GHC.Stg.Lift.Types module, which allows various type family instances to be moved to GHC.Stg.Syntax, avoiding orphan instances. - - - - - 0f25a13b by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Avoid orphans in the parser This moves Anno instances for PatBuilder from GHC.Parser.PostProcess to GHC.Parser.Types to avoid orphans. - - - - - 15750d33 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Accept an orphan declaration (sadly) This accepts the orphan type family instance type instance DsForeignHook = ... in GHC.HsToCore.Types. See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks - - - - - c9967d13 by Zubin Duggal at 2023-01-27T23:55:31-05:00 bindist configure: Fail if find not found (#22691) - - - - - ad8cfed4 by John Ericson at 2023-01-27T23:56:06-05:00 Put hadrian bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. - - - - - d0ddc01b by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Introduce threaded2_sanity way Incredibly, we previously did not have a single way which would test the threaded RTS with multiple capabilities and the sanity-checker enabled. - - - - - 38ad8351 by Ben Gamari at 2023-01-27T23:56:42-05:00 rts: Relax Messages assertion `doneWithMsgThrowTo` was previously too strict in asserting that the `Message` is locked. Specifically, it failed to consider that the `Message` may not be locked if we are deleting all threads during RTS shutdown. - - - - - a9fe81af by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Fix race in UnliftedTVar2 Previously UnliftedTVar2 would fail when run with multiple capabilities (and possibly even with one capability) as it would assume that `killThread#` would immediately kill the "increment" thread. Also, refactor the the executable to now succeed with no output and fails with an exit code. - - - - - 8519af60 by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Make listThreads more robust Previously it was sensitive to the labels of threads which it did not create (e.g. the IO manager event loop threads). Fix this. - - - - - 55a81995 by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix non-atomic mutation of enabled_capabilities - - - - - b5c75f1d by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix C++ compilation issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - c261b62f by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix typo "tracingAddCapabilities" was mis-named - - - - - 77fdbd3f by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Drop long-dead fallback definitions for INFINITY & NAN These are no longer necessary since we now compile as C99. - - - - - 56c1bd98 by Ben Gamari at 2023-01-28T02:57:59-05:00 Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)" This reverts commit 99aca26b652603bc62953157a48e419f737d352d. - - - - - b3a3534b by nineonine at 2023-01-28T02:57:59-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043. - - - - - 082b7d43 by Oleg Grenrus at 2023-01-28T02:58:38-05:00 Add Foldable1 Solo instance - - - - - 50b1e2e8 by Andrei Borzenkov at 2023-01-28T02:59:18-05:00 Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115) I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind module. Instead, these TcRnMessage messages were introduced: TcRnMultipleFixityDecls TcRnIllegalPatternSynonymDecl TcRnIllegalClassBiding TcRnOrphanCompletePragma TcRnEmptyCase TcRnNonStdGuards TcRnDuplicateSigDecl TcRnMisplacedSigDecl TcRnUnexpectedDefaultSig TcRnBindInBootFile TcRnDuplicateMinimalSig - - - - - 3330b819 by Matthew Pickering at 2023-01-28T02:59:54-05:00 hadrian: Fix library-dirs, dynamic-library-dirs and static-library-dirs in inplace .conf files Previously we were just throwing away the contents of the library-dirs fields but really we have to do the same thing as for include-dirs, relativise the paths into the current working directory and maintain any extra libraries the user has specified. Now the relevant section of the rts.conf file looks like: ``` library-dirs: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib library-dirs-static: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib dynamic-library-dirs: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib ``` Fixes #22209 - - - - - c9ad8852 by Andrew Lelechenko at 2023-01-28T03:00:33-05:00 Document differences between Data.{Monoid,Semigroup}.{First,Last} - - - - - 7e11c6dc by Cheng Shao at 2023-01-28T03:01:09-05:00 compiler: fix subword literal narrowing logic in the wasm NCG This patch fixes the W8/W16 literal narrowing logic in the wasm NCG, which used to lower it to something like i32.const -1, without properly zeroing-out the unused higher bits. Fixes #22608. - - - - - 6ea2aa02 by Cheng Shao at 2023-01-28T03:01:46-05:00 compiler: fix lowering of CmmBlock in the wasm NCG The CmmBlock datacon was not handled in lower_CmmLit, since I thought it would have been eliminated after proc-point splitting. Turns out it still occurs in very rare occasions, and this patch is needed to fix T9329 for wasm. - - - - - 2b62739d by Andrew Lelechenko at 2023-01-28T17:16:11-05:00 Assorted changes to avoid Data.List.{head,tail} - - - - - 78c07219 by Cheng Shao at 2023-01-28T17:16:48-05:00 compiler: properly handle ForeignHints in the wasm NCG Properly handle ForeignHints of ccall arguments/return value, insert sign extends and truncations when handling signed subwords. Fixes #22852. - - - - - 8bed166b by Ben Gamari at 2023-01-30T05:06:26-05:00 nativeGen: Disable asm-shortcutting on Darwin Asm-shortcutting may produce relative references to symbols defined in other compilation units. This is not something that MachO relocations support (see #21972). For this reason we disable the optimisation on Darwin. We do so without a warning since this flag is enabled by `-O2`. Another way to address this issue would be to rather implement a PLT-relocatable jump-table strategy. However, this would only benefit Darwin and does not seem worth the effort. Closes #21972. - - - - - da468391 by Cheng Shao at 2023-01-30T05:07:03-05:00 compiler: fix data section alignment in the wasm NCG Previously we tried to lower the alignment requirement as far as possible, based on the section kind inferred from the CLabel. For info tables, .p2align 1 was applied given the GC should only need the lowest bit to tag forwarding pointers. But this would lead to unaligned loads/stores, which has a performance penalty even if the wasm spec permits it. Furthermore, the test suite has shown memory corruption in a few cases when compacting gc is used. This patch takes a more conservative approach: all data sections except C strings align to word size. - - - - - 08ba8720 by Andreas Klebinger at 2023-01-30T21:18:45-05:00 ghc-the-library: Retain cafs in both static in dynamic builds. We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a __attribute__((constructor)) function. This broke for static builds where the linker discarded the object file since it was not reverenced from any exported code. We fix this by asserting that the flag is enabled using a function in the same module as the constructor. Which causes the object file to be retained by the linker, which in turn causes the constructor the be run in static builds. This changes nothing for dynamic builds using the ghc library. But causes static to also retain CAFs (as we expect them to). Fixes #22417. ------------------------- Metric Decrease: T21839r ------------------------- - - - - - 20598ef6 by Ryan Scott at 2023-01-30T21:19:20-05:00 Handle `type data` properly in tyThingParent_maybe Unlike most other data constructors, data constructors declared with `type data` are represented in `TyThing`s as `ATyCon` rather than `ADataCon`. The `ATyCon` case in `tyThingParent_maybe` previously did not consider the possibility of the underlying `TyCon` being a promoted data constructor, which led to the oddities observed in #22817. This patch adds a dedicated special case in `tyThingParent_maybe`'s `ATyCon` case for `type data` data constructors to fix these oddities. Fixes #22817. - - - - - 2f145052 by Ryan Scott at 2023-01-30T21:19:56-05:00 Fix two bugs in TypeData TH reification This patch fixes two issues in the way that `type data` declarations were reified with Template Haskell: * `type data` data constructors are now properly reified using `DataConI`. This is accomplished with a special case in `reifyTyCon`. Fixes #22818. * `type data` type constructors are now reified in `reifyTyCon` using `TypeDataD` instead of `DataD`. Fixes #22819. - - - - - d0f34f25 by Simon Peyton Jones at 2023-01-30T21:20:35-05:00 Take account of loop breakers in specLookupRule The key change is that in GHC.Core.Opt.Specialise.specLookupRule we were using realIdUnfolding, which ignores the loop-breaker flag. When given a loop breaker, rule matching therefore looped infinitely -- #22802. In fixing this I refactored a bit. * Define GHC.Core.InScopeEnv as a data type, and use it. (Previously it was a pair: hard to grep for.) * Put several functions returning an IdUnfoldingFun into GHC.Types.Id, namely idUnfolding alwaysActiveUnfoldingFun, whenActiveUnfoldingFun, noUnfoldingFun and use them. (The are all loop-breaker aware.) - - - - - de963cb6 by Matthew Pickering at 2023-01-30T21:21:11-05:00 ci: Remove FreeBSD job from release pipelines We no longer attempt to build or distribute this release - - - - - f26d27ec by Matthew Pickering at 2023-01-30T21:21:11-05:00 rel_eng: Add check to make sure that release jobs are downloaded by fetch-gitlab This check makes sure that if a job is a prefixed by "release-" then the script downloads it and understands how to map the job name to the platform. - - - - - 7619c0b4 by Matthew Pickering at 2023-01-30T21:21:11-05:00 rel_eng: Fix the name of the ubuntu-* jobs These were not uploaded for alpha1 Fixes #22844 - - - - - 68eb8877 by Matthew Pickering at 2023-01-30T21:21:11-05:00 gen_ci: Only consider release jobs for job metadata In particular we do not have a release job for FreeBSD so the generation of the platform mapping was failing. - - - - - b69461a0 by Jason Shipman at 2023-01-30T21:21:50-05:00 User's guide: Clarify overlapping instance candidate elimination This commit updates the user's guide section on overlapping instance candidate elimination to use "or" verbiage instead of "either/or" in regards to the current pair of candidates' being overlappable or overlapping. "Either IX is overlappable, or IY is overlapping" can cause confusion as it suggests "Either IX is overlappable, or IY is overlapping, but not both". This was initially discussed on this Discourse topic: https://discourse.haskell.org/t/clarification-on-overlapping-instance-candidate-elimination/5677 - - - - - 7cbdaad0 by Matthew Pickering at 2023-01-31T07:53:53-05:00 Fixes for cabal-reinstall CI job * Allow filepath to be reinstalled * Bump some version bounds to allow newer versions of libraries * Rework testing logic to avoid "install --lib" and package env files Fixes #22344 - - - - - fd8f32bf by Cheng Shao at 2023-01-31T07:54:29-05:00 rts: prevent potential divide-by-zero when tickInterval=0 This patch fixes a few places in RtsFlags.c that may result in divide-by-zero error when tickInterval=0, which is the default on wasm. Fixes #22603. - - - - - 085a6db6 by Joachim Breitner at 2023-01-31T07:55:05-05:00 Update note at beginning of GHC.Builtin.NAmes some things have been renamed since it was written, it seems. - - - - - 7716cbe6 by Cheng Shao at 2023-01-31T07:55:41-05:00 testsuite: use tgamma for cg007 gamma is a glibc-only deprecated function, use tgamma instead. It's required for fixing cg007 when testing the wasm unregisterised codegen. - - - - - 19c1fbcd by doyougnu at 2023-01-31T13:08:03-05:00 InfoTableProv: ShortText --> ShortByteString - - - - - 765fab98 by doyougnu at 2023-01-31T13:08:03-05:00 FastString: add fastStringToShorText - - - - - a83c810d by Simon Peyton Jones at 2023-01-31T13:08:38-05:00 Improve exprOkForSpeculation for classops This patch fixes #22745 and #15205, which are about GHC's failure to discard unnecessary superclass selections that yield coercions. See GHC.Core.Utils Note [exprOkForSpeculation and type classes] The main changes are: * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and refer to it * Define new function isTerminatingType, to identify those guaranteed-terminating dictionary types. * exprOkForSpeculation has a new (very simple) case for ClassOpId * ClassOpId has a new field that says if the return type is an unlifted type, or a terminating type. This was surprisingly tricky to get right. In particular note that unlifted types are not terminating types; you can write an expression of unlifted type, that diverges. Not so for dictionaries (or, more precisely, for the dictionaries that GHC constructs). Metric Decrease: LargeRecord - - - - - f83374f8 by Krzysztof Gogolewski at 2023-01-31T13:09:14-05:00 Support "unusable UNPACK pragma" warning with -O0 Fixes #11270 - - - - - a2d814dc by Ben Gamari at 2023-01-31T13:09:50-05:00 configure: Always create the VERSION file Teach the `configure` script to create the `VERSION` file. This will serve as the stable interface to allow the user to determine the version number of a working tree. Fixes #22322. - - - - - 5618fc21 by sheaf at 2023-01-31T15:51:06-05:00 Cmm: track the type of global registers This patch tracks the type of Cmm global registers. This is needed in order to lint uses of polymorphic registers, such as SIMD vector registers that can be used both for floating-point and integer values. This changes allows us to refactor VanillaReg to not store VGcPtr, as that information is instead stored in the type of the usage of the register. Fixes #22297 - - - - - 78b99430 by sheaf at 2023-01-31T15:51:06-05:00 Revert "Cmm Lint: relax SIMD register assignment check" This reverts commit 3be48877, which weakened a Cmm Lint check involving SIMD vectors. Now that we keep track of the type a global register is used at, we can restore the original stronger check. - - - - - be417a47 by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen/AArch64: Fix debugging output Previously various panics would rely on a half-written Show instance, leading to very unhelpful errors. Fix this. See #22798. - - - - - 30989d13 by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen: Teach graph-colouring allocator that x18 is unusable Previously trivColourable for AArch64 claimed that at 18 registers were trivially-colourable. This is incorrect as x18 is reserved by the platform on AArch64/Darwin. See #22798. - - - - - 7566fd9d by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen/AArch64: Fix graph-colouring allocator Previously various `Instr` queries used by the graph-colouring allocator failed to handle a few pseudo-instructions. This manifested in compiler panicks while compiling `SHA`, which uses `-fregs-graph`. Fixes #22798. - - - - - 2cb500a5 by Ben Gamari at 2023-01-31T15:51:45-05:00 testsuite: Add regression test for #22798 - - - - - 03d693b2 by Ben Gamari at 2023-01-31T15:52:32-05:00 Revert "Hadrian: fix doc generation" This is too large of a hammer. This reverts commit 5640cb1d84d3cce4ce0a9e90d29b2b20d2b38c2f. - - - - - f838815c by Ben Gamari at 2023-01-31T15:52:32-05:00 hadrian: Sphinx docs require templated cabal files The package-version discovery logic in `doc/users_guide/package_versions.py` uses packages' cabal files to determine package versions. Teach Sphinx about these dependencies in cases where the cabal files are generated by templates. - - - - - 2e48c19a by Ben Gamari at 2023-01-31T15:52:32-05:00 hadrian: Refactor templating logic This refactors Hadrian's autoconf-style templating logic to be explicit about which interpolation variables should be substituted in which files. This clears the way to fix #22714 without incurring rule cycles. - - - - - 93f0e3c4 by Ben Gamari at 2023-01-31T15:52:33-05:00 hadrian: Substitute LIBRARY_*_VERSION variables This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables in `libraries/prologue.txt`, fixing #22714. Fixes #22714. - - - - - 22089f69 by Ben Gamari at 2023-01-31T20:46:27-05:00 Bump transformers submodule to 0.6.0.6 Fixes #22862. - - - - - f0eefa3c by Cheng Shao at 2023-01-31T20:47:03-05:00 compiler: properly handle non-word-sized CmmSwitch scrutinees in the wasm NCG Currently, the wasm NCG has an implicit assumption: all CmmSwitch scrutinees are 32-bit integers. This is not always true; #22864 is one counter-example with a 64-bit scrutinee. This patch fixes the logic by explicitly converting the scrutinee to a word that can be used as a br_table operand. Fixes #22871. Also includes a regression test. - - - - - 9f95db54 by Simon Peyton Jones at 2023-02-01T08:55:08+00:00 Improve treatment of type applications in patterns This patch fixes a subtle bug in the typechecking of type applications in patterns, e.g. f (MkT @Int @a x y) = ... See Note [Type applications in patterns] in GHC.Tc.Gen.Pat. This fixes #19847, #22383, #19577, #21501 - - - - - 955a99ea by Simon Peyton Jones at 2023-02-01T12:31:23-05:00 Treat existentials correctly in dubiousDataConInstArgTys Consider (#22849) data T a where MkT :: forall k (t::k->*) (ix::k). t ix -> T @k a Then dubiousDataConInstArgTys MkT [Type, Foo] should return [Foo (ix::Type)] NOT [Foo (ix::k)] A bit of an obscure case, but it's an outright bug, and the fix is easy. - - - - - 0cc16aaf by Matthew Pickering at 2023-02-01T12:31:58-05:00 Bump supported LLVM range from 10 through 15 to 11 through 16 LLVM 15 turns on the new pass manager by default, which we have yet to migrate to so for new we pass the `-enable-new-pm-0` flag in our llvm-passes flag. LLVM 11 was the first version to support the `-enable-new-pm` flag so we bump the lowest supported version to 11. Our CI jobs are using LLVM 12 so they should continue to work despite this bump to the lower bound. Fixes #21936 - - - - - f94f1450 by Matthew Pickering at 2023-02-01T12:31:58-05:00 Bump DOCKER_REV to use alpine image without LLVM installed alpine_3_12 only supports LLVM 10, which is now outside the supported version range. - - - - - 083e26ed by Matthew Pickering at 2023-02-01T17:43:21-05:00 Remove tracing OPTIONS_GHC These were accidentally left over from !9542 - - - - - 354aa47d by Teo Camarasu at 2023-02-01T17:44:00-05:00 doc: fix gcdetails_block_fragmentation_bytes since annotation - - - - - 61ce5bf6 by Jaro Reinders at 2023-02-02T00:15:30-05:00 compiler: Implement higher order patterns in the rule matcher This implements proposal 555 and closes ticket #22465. See the proposal and ticket for motivation. The core changes of this patch are in the GHC.Core.Rules.match function and they are explained in the Note [Matching higher order patterns]. - - - - - 394b91ce by doyougnu at 2023-02-02T00:16:10-05:00 CI: JavaScript backend runs testsuite This MR runs the testsuite for the JS backend. Note that this is a temporary solution until !9515 is merged. Key point: The CI runs hadrian on the built cross compiler _but not_ on the bindist. Other Highlights: - stm submodule gets a bump to mark tests as broken - several tests are marked as broken or are fixed by adding more - conditions to their test runner instance. List of working commit messages: CI: test cross target _and_ emulator CI: JS: Try run testsuite with hadrian JS.CI: cleanup and simplify hadrian invocation use single bracket, print info JS CI: remove call to test_compiler from hadrian don't build haddock JS: mark more tests as broken Tracked in https://gitlab.haskell.org/ghc/ghc/-/issues/22576 JS testsuite: don't skip sum_mod test Its expected to fail, yet we skipped it which automatically makes it succeed leading to an unexpected success, JS testsuite: don't mark T12035j as skip leads to an unexpected pass JS testsuite: remove broken on T14075 leads to unexpected pass JS testsuite: mark more tests as broken JS testsuite: mark T11760 in base as broken JS testsuite: mark ManyUnbSums broken submodules: bump process and hpc for JS tests Both submodules has needed tests skipped or marked broken for th JS backend. This commit now adds these changes to GHC. See: HPC: https://gitlab.haskell.org/hpc/hpc/-/merge_requests/21 Process: https://github.com/haskell/process/pull/268 remove js_broken on now passing tests separate wasm and js backend ci test: T11760: add threaded, non-moving only_ways test: T10296a add req_c T13894: skip for JS backend tests: jspace, T22333: mark as js_broken(22573) test: T22513i mark as req_th stm submodule: mark stm055, T16707 broken for JS tests: js_broken(22374) on unpack_sums_6, T12010 dont run diff on JS CI, cleanup fixup: More CI cleanup fix: align text to master fix: align exceptions submodule to master CI: Bump DOCKER_REV Bump to ci-images commit that has a deb11 build with node. Required for !9552 testsuite: mark T22669 as js_skip See #22669 This test tests that .o-boot files aren't created when run in using the interpreter backend. Thus this is not relevant for the JS backend. testsuite: mark T22671 as broken on JS See #22835 base.testsuite: mark Chan002 fragile for JS see #22836 revert: submodule process bump bump stm submodule New hash includes skips for the JS backend. testsuite: mark RnPatternSynonymFail broken on JS Requires TH: - see !9779 - and #22261 compiler: GHC.hs ifdef import Utils.Panic.Plain - - - - - 1ffe770c by Cheng Shao at 2023-02-02T09:40:38+00:00 docs: 9.6 release notes for wasm backend - - - - - 0ada4547 by Matthew Pickering at 2023-02-02T11:39:44-05:00 Disable unfolding sharing for interface files with core definitions Ticket #22807 pointed out that the RHS sharing was not compatible with -fignore-interface-pragmas because the flag would remove unfoldings from identifiers before the `extra-decls` field was populated. For the 9.6 timescale the only solution is to disable this sharing, which will make interface files bigger but this is acceptable for the first release of `-fwrite-if-simplified-core`. For 9.8 it would be good to fix this by implementing #20056 due to the large number of other bugs that would fix. I also improved the error message in tc_iface_binding to avoid the "no match in record selector" error but it should never happen now as the entire sharing logic is disabled. Also added the currently broken test for #22807 which could be fixed by !6080 Fixes #22807 - - - - - 7e2d3eb5 by lrzlin at 2023-02-03T05:23:27-05:00 Enable tables next to code for LoongArch64 - - - - - 2931712a by Wander Hillen at 2023-02-03T05:24:06-05:00 Move pthread and timerfd ticker implementations to separate files - - - - - 41c4baf8 by Ben Gamari at 2023-02-03T05:24:44-05:00 base: Fix Note references in GHC.IO.Handle.Types - - - - - 31358198 by Andrew Lelechenko at 2023-02-03T05:25:22-05:00 Bump submodule containers to 0.6.7 Metric Decrease: ManyConstructors T10421 T12425 T12707 T13035 T13379 T15164 T1969 T783 T9198 T9961 WWRec - - - - - 8feb9301 by Ben Gamari at 2023-02-03T05:25:59-05:00 gitlab-ci: Eliminate redundant ghc --info output Previously ci.sh would emit the output of `ghc --info` every time it ran when using the nix toolchain. This produced a significant amount of noise. See #22861. - - - - - de1d1512 by Ryan Scott at 2023-02-03T14:07:30-05:00 Windows: Remove mingwex dependency The clang based toolchain uses ucrt as its math library and so mingwex is no longer needed. In fact using mingwex will cause incompatibilities as the default routines in both have differing ULPs and string formatting modifiers. ``` $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe [1 of 2] Compiling Main ( Bug.hs, Bug.o ) ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info' ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above. <no location info>: error: GHC.ByteCode.Linker.lookupCE During interactive linking, GHCi couldn't find the following symbol: templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` - - - - - 48e39195 by Tamar Christina at 2023-02-03T14:07:30-05:00 linker: Fix BFD import libraries This commit fixes the BFD style import library support in the runtime linker. This was accidentally broken during the refactoring to clang and went unnoticed because clang itself is unable to generate the BFD style import libraries. With this change we can not link against both GCC or Clang produced libraries again and intermix code produced by both compilers. - - - - - b2bb3e62 by Ben Gamari at 2023-02-03T14:07:30-05:00 Bump Windows toolchain Updates to LLVM 14, hopefully fixing #21964. - - - - - bf3f88a1 by Andreas Klebinger at 2023-02-03T14:08:07-05:00 Fix CallerCC potentially shadowing other cost centres. Add a CallerCC cost centre flavour for cost centres added by the CallerCC pass. This avoids potential accidental shadowing between CCs added by user annotations and ones added by CallerCC. - - - - - faea4bcd by j at 2023-02-03T14:08:47-05:00 Disable several ignore-warning flags in genapply. - - - - - 25537dfd by Ben Gamari at 2023-02-04T04:12:57-05:00 Revert "Use fix-sized bit-fiddling primops for fixed size boxed types" This reverts commit 4512ad2d6a8e65ea43c86c816411cb13b822f674. This was never applied to master/9.6 originally. (cherry picked from commit a44bdc2720015c03d57f470b759ece7fab29a57a) - - - - - 7612dc71 by Krzysztof Gogolewski at 2023-02-04T04:13:34-05:00 Minor refactor * Introduce refactorDupsOn f = refactorDups (comparing f) * Make mkBigTupleCase and coreCaseTuple monadic. Every call to those functions was preceded by calling newUniqueSupply. * Use mkUserLocalOrCoVar, which is equivalent to combining mkLocalIdOrCoVar with mkInternalName. - - - - - 5a54ac0b by Andrew Lelechenko at 2023-02-04T18:48:32-05:00 Fix colors in emacs terminal - - - - - 3c0f0c6d by Andrew Lelechenko at 2023-02-04T18:49:11-05:00 base changelog: move entries which were not backported to ghc-9.6 to base-4.19 section - - - - - b18fbf52 by Josh Meredith at 2023-02-06T07:47:57+00:00 Update JavaScript fileStat to match Emscripten layout - - - - - 6636b670 by Sylvain Henry at 2023-02-06T09:43:21-05:00 JS: replace "js" architecture with "javascript" Despite Cabal supporting any architecture name, `cabal --check` only supports a few built-in ones. Sadly `cabal --check` is used by Hackage hence using any non built-in name in a package (e.g. `arch(js)`) is rejected and the package is prevented from being uploaded on Hackage. Luckily built-in support for the `javascript` architecture was added for GHCJS a while ago. In order to allow newer `base` to be uploaded on Hackage we make the switch from `js` to `javascript` architecture. Fixes #22740. Co-authored-by: Ben Gamari <ben at smart-cactus.org> - - - - - 77a8234c by Luite Stegeman at 2023-02-06T09:43:59-05:00 Fix marking async exceptions in the JS backend Async exceptions are posted as a pair of the exception and the thread object. This fixes the marking pass to correctly follow the two elements of the pair. Potentially fixes #22836 - - - - - 3e09cf82 by Jan Hrček at 2023-02-06T09:44:38-05:00 Remove extraneous word in Roles user guide - - - - - b17fb3d9 by sheaf at 2023-02-07T10:51:33-05:00 Don't allow . in overloaded labels This patch removes . from the list of allowed characters in a non-quoted overloaded label, as it was realised this steals syntax, e.g. (#.). Users who want this functionality will have to add quotes around the label, e.g. `#"17.28"`. Fixes #22821 - - - - - 5dce04ee by romes at 2023-02-07T10:52:10-05:00 Update kinds in comments in GHC.Core.TyCon Use `Type` instead of star kind (*) Fix comment with incorrect kind * to have kind `Constraint` - - - - - 92916194 by Ben Gamari at 2023-02-07T10:52:48-05:00 Revert "Use fix-sized equality primops for fixed size boxed types" This reverts commit 024020c38126f3ce326ff56906d53525bc71690c. This was never applied to master/9.6 originally. See #20405 for why using these primops is a bad idea. (cherry picked from commit b1d109ad542e4c37ae5af6ace71baf2cb509d865) - - - - - c1670c6b by Sylvain Henry at 2023-02-07T21:25:18-05:00 JS: avoid head/tail and unpackFS - - - - - a9912de7 by Krzysztof Gogolewski at 2023-02-07T21:25:53-05:00 testsuite: Fix Python warnings (#22856) - - - - - 9ee761bf by sheaf at 2023-02-08T14:40:40-05:00 Fix tyvar scoping within class SPECIALISE pragmas Type variables from class/instance headers scope over class/instance method type signatures, but DO NOT scope over the type signatures in SPECIALISE and SPECIALISE instance pragmas. The logic in GHC.Rename.Bind.rnMethodBinds correctly accounted for SPECIALISE inline pragmas, but forgot to apply the same treatment to method SPECIALISE pragmas, which lead to a Core Lint failure with an out-of-scope type variable. This patch makes sure we apply the same logic for both cases. Fixes #22913 - - - - - 7eac2468 by Matthew Pickering at 2023-02-08T14:41:17-05:00 Revert "Don't keep exit join points so much" This reverts commit caced75765472a1a94453f2e5a439dba0d04a265. It seems the patch "Don't keep exit join points so much" is causing wide-spread regressions in the bytestring library benchmarks. If I revert it then the 9.6 numbers are better on average than 9.4. See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T12150 T13386 T13719 T21839c T3294 parsing001 ------------------------- - - - - - 633f2799 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: remove config.use_threads This patch simplifies the testsuite driver by removing the use_threads config field. It's just a degenerate case of threads=1. - - - - - ca6673e3 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: use concurrent.futures.ThreadPoolExecutor in the driver The testsuite driver used to create one thread per test case, and explicitly use semaphore and locks for rate limiting and synchronization. This is a bad practice in any language, and occasionally may result in livelock conditions (e.g. #22889). This patch uses concurrent.futures.ThreadPoolExecutor for scheduling test case runs, which is simpler and more robust. - - - - - f22cce70 by Alan Zimmerman at 2023-02-08T18:42:51-05:00 EPA: Comment between module and where should be in header comments Do not apply the heuristic to associate a comment with a prior declaration for the first declaration in the file. Closes #22919 - - - - - d69ecac2 by Josh Meredith at 2023-02-09T03:24:05-05:00 JS generated refs: update testsuite conditions - - - - - 2ea1a6bc by sheaf at 2023-02-09T03:24:44-05:00 Bump transformers to 0.6.1.0 This allows us to avoid orphans for Foldable1 instances, fixing #22898. Updates transformers submodule. - - - - - d9d0c28d by konsumlamm at 2023-02-09T14:07:48-05:00 Update `Data.List.singleton` doc comment - - - - - fe9cd6ef by Ben Gamari at 2023-02-09T14:08:23-05:00 gitlab-template: Emphasize `user facing` label My sense is that the current mention of the ~"user facing" label is overlooked by many MR authors. Let's move this point up in the list to make it more likely that it is seen. Also rephrase some of the points. - - - - - e45eb828 by Simon Peyton Jones at 2023-02-10T06:51:28-05:00 Refactor the simplifier a bit to fix #22761 The core change in this commit, which fixes #22761, is that * In a Core rule, ru_rhs is always occ-analysed. This means adding a couple of calls to occurAnalyseExpr when building a Rule, in * GHC.Core.Rules.mkRule * GHC.Core.Opt.Simplify.Iteration.simplRules But diagosing the bug made me stare carefully at the code of the Simplifier, and I ended up doing some only-loosely-related refactoring. * I think that RULES could be lost because not every code path did addBndrRules * The code around lambdas was very convoluted It's mainly moving deck chairs around, but I like it more now. - - - - - 11e0cacb by Rebecca Turner at 2023-02-10T06:52:09-05:00 Detect the `mold` linker Enables support for the `mold` linker by rui314. - - - - - 59556235 by parsonsmatt at 2023-02-10T09:53:11-05:00 Add Lift instance for Fixed - - - - - c44e5f30 by Sylvain Henry at 2023-02-10T09:53:51-05:00 Testsuite: decrease length001 timeout for JS (#22921) - - - - - 133516af by Zubin Duggal at 2023-02-10T09:54:27-05:00 compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData` instances This is a minor refactor that makes it easy to add and remove fields from `ModIface_` and `ModIfaceBackend`. Also change the formatting to make it clear exactly which fields are fully forced with `rnf` - - - - - 1e9eac1c by Matthew Pickering at 2023-02-13T11:36:41+01:00 Refresh profiling docs I went through the whole of the profiling docs and tried to amend them to reflect current best practices and tooling. In particular I removed some old references to tools such as hp2any and replaced them with references to eventlog2html. - - - - - da208b9a by Matthew Pickering at 2023-02-13T11:36:41+01:00 docs: Add section about profiling and foreign calls Previously there was no documentation for how foreign calls interacted with the profiler. This can be quite confusing for users so getting it into the user guide is the first step to a potentially better solution. See the ticket for more insightful discussion. Fixes #21764 - - - - - 081640f1 by Andrew Lelechenko at 2023-02-13T12:51:52-05:00 Document that -fproc-alignment was introduced only in GHC 8.6 - - - - - 16adc349 by Sven Tennie at 2023-02-14T11:26:31-05:00 Add clangd flag to include generated header files This enables clangd to correctly check C files that import Rts.h. (The added include directory contains ghcautoconf.h et. al.) - - - - - c399ccd9 by amesgen at 2023-02-14T11:27:14-05:00 Mention new `Foreign.Marshal.Pool` implementation in User's Guide - - - - - b9282cf7 by Ben Gamari at 2023-02-14T11:27:50-05:00 upload_ghc_libs: More control over which packages to operate on Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to limit which packages to upload. This is often necessary when one package is not uploadable (e.g. see #22740). - - - - - aa3a262d by PHO at 2023-02-14T11:28:29-05:00 Assume platforms support rpaths if they use either ELF or Mach-O Not only Linux, Darwin, and FreeBSD support rpaths. Determine the usability of rpaths based on the object format, not on OS. - - - - - 47716024 by PHO at 2023-02-14T11:29:09-05:00 RTS linker: Improve compatibility with NetBSD 1. Hint address to NetBSD mmap(2) has a different semantics from that of Linux. When a hint address is provided, mmap(2) searches for a free region at or below the hint but *never* above it. This means we can't reliably search for free regions incrementally on the userland, especially when ASLR is enabled. Let the kernel do it for us if we don't care where the mapped address is going to be. 2. NetBSD not only hates to map pages as rwx, but also disallows to switch pages from rw- to r-x unless the intention is declared when pages are initially requested. This means we need a new MemoryAccess mode for pages that are going to be changed to r-x. - - - - - 11de324a by Li-yao Xia at 2023-02-14T11:29:49-05:00 base: Move changelog entry to its place - - - - - 75930424 by Ben Gamari at 2023-02-14T11:30:27-05:00 nativeGen/AArch64: Emit Atomic{Read,Write} inline Previously the AtomicRead and AtomicWrite operations were emitted as out-of-line calls. However, these tend to be very important for performance, especially the RELAXED case (which only exists for ThreadSanitizer checking). Fixes #22115. - - - - - d6411d6c by Andreas Klebinger at 2023-02-14T11:31:04-05:00 Fix some correctness issues around tag inference when targeting the bytecode generator. * Let binders are now always assumed untagged for bytecode. * Imported referenced are now always assumed to be untagged for bytecode. Fixes #22840 - - - - - 9fb4ca89 by sheaf at 2023-02-14T11:31:49-05:00 Introduce warning for loopy superclass solve Commit aed1974e completely re-engineered the treatment of loopy superclass dictionaries in instance declarations. Unfortunately, it has the potential to break (albeit in a rather minor way) user code. To alleviate migration concerns, this commit re-introduces the old behaviour. Any reliance on this old behaviour triggers a warning, controlled by `-Wloopy-superclass-solve`. The warning text explains that GHC might produce bottoming evidence, and provides a migration strategy. This allows us to provide a graceful migration period, alerting users when they are relying on this unsound behaviour. Fixes #22912 #22891 #20666 #22894 #22905 - - - - - 1928c7f3 by Cheng Shao at 2023-02-14T11:32:26-05:00 rts: make it possible to change mblock size on 32-bit targets The MBLOCK_SHIFT macro must be the single source of truth for defining the mblock size, and changing it should only affect performance, not correctness. This patch makes it truly possible to reconfigure mblock size, at least on 32-bit targets, by fixing places which implicitly relied on the previous MBLOCK_SHIFT constant. Fixes #22901. - - - - - 78aa3b39 by Simon Hengel at 2023-02-14T11:33:06-05:00 Update outdated references to notes - - - - - e8baecd2 by meooow25 at 2023-02-14T11:33:49-05:00 Documentation: Improve Foldable1 documentation * Explain foldrMap1, foldlMap1, foldlMap1', and foldrMap1' in greater detail, the text is mostly adapted from documentation of Foldable. * Describe foldr1, foldl1, foldl1' and foldr1' in terms of the above functions instead of redoing the full explanation. * Small updates to documentation of fold1, foldMap1 and toNonEmpty, again adapting from Foldable. * Update the foldMap1 example to lists instead of Sum since this is recommended for lazy right-associative folds. Fixes #22847 - - - - - 85a1a575 by romes at 2023-02-14T11:34:25-05:00 fix: Mark ghci Prelude import as implicit Fixes #22829 In GHCi, we were creating an import declaration for Prelude but we were not setting it as an implicit declaration. Therefore, ghci's import of Prelude triggered -Wmissing-import-lists. Adds regression test T22829 to testsuite - - - - - 3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05:00 compiler: fix generateCgIPEStub for no-tables-next-to-code builds generateCgIPEStub already correctly implements the CmmTick finding logic for when tables-next-to-code is on/off, but it used the wrong predicate to decide when to switch between the two. Previously it switches based on whether the codegen is unregisterised, but there do exist registerised builds that disable tables-next-to-code! This patch corrects that problem. Fixes #22896. - - - - - 08c0822c by doyougnu at 2023-02-15T00:16:39-05:00 docs: release notes, user guide: add js backend Follow up from #21078 - - - - - 79d8fd65 by Bryan Richter at 2023-02-15T00:17:15-05:00 Allow failure in nightly-x86_64-linux-deb10-no_tntc-validate See #22343 - - - - - 9ca51f9e by Cheng Shao at 2023-02-15T00:17:53-05:00 rts: add the rts_clearMemory function This patch adds the rts_clearMemory function that does its best to zero out unused RTS memory for a wasm backend use case. See the comment above rts_clearMemory() prototype declaration for more detailed explanation. Closes #22920. - - - - - 26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00 Add -single-threaded flag to force single threaded rts This is the small part of implementing https://github.com/ghc-proposals/ghc-proposals/pull/240 - - - - - 631c6c72 by Cheng Shao at 2023-02-16T06:43:09-05:00 docs: add a section for the wasm backend Fixes #22658 - - - - - 1878e0bd by Bryan Richter at 2023-02-16T06:43:47-05:00 tests: Mark T12903 fragile everywhere See #21184 - - - - - b9420eac by Bryan Richter at 2023-02-16T06:43:47-05:00 Mark all T5435 variants as fragile See #22970. - - - - - df3d94bd by Sylvain Henry at 2023-02-16T06:44:33-05:00 Testsuite: mark T13167 as fragile for JS (#22921) - - - - - 324e925b by Sylvain Henry at 2023-02-16T06:45:15-05:00 JS: disable debugging info for heap objects - - - - - 518af814 by Josh Meredith at 2023-02-16T10:16:32-05:00 Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name caching - - - - - 34cd308e by Ben Gamari at 2023-02-16T10:17:08-05:00 base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog Fixes #22883. - - - - - 12965aba by Simon Peyton Jones at 2023-02-16T10:17:46-05:00 Narrow the dont-decompose-newtype test Following #22924 this patch narrows the test that stops us decomposing newtypes. The key change is the use of noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp. We went to and fro on the solution, as you can see in #22924. The result is carefully documented in Note [Decomoposing newtype equalities] On the way I had revert most of commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90 Author: Richard Eisenberg <rae at cs.brynmawr.edu> Date: Mon Dec 5 10:14:02 2022 -0500 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. It turns out that (a) 3e827c3f makes GHC behave worse on some recursive newtypes (see one of the tests on this commit) (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders 3e827c3f unnecessary - - - - - 5b038888 by Andrew Lelechenko at 2023-02-16T10:18:24-05:00 Documentation: add an example of SPEC usage - - - - - 681e0e8c by sheaf at 2023-02-16T14:09:56-05:00 No default finalizer exception handler Commit cfc8e2e2 introduced a mechanism for handling of exceptions that occur during Handle finalization, and 372cf730 set the default handler to print out the error to stderr. However, #21680 pointed out we might not want to set this by default, as it might pollute users' terminals with unwanted information. So, for the time being, the default handler discards the exception. Fixes #21680 - - - - - b3ac17ad by Matthew Pickering at 2023-02-16T14:10:31-05:00 unicode: Don't inline bitmap in generalCategory generalCategory contains a huge literal string but is marked INLINE, this will duplicate the string into any use site of generalCategory. In particular generalCategory is used in functions like isSpace and the literal gets inlined into this function which makes it massive. https://github.com/haskell/core-libraries-committee/issues/130 Fixes #22949 ------------------------- Metric Decrease: T4029 T18304 ------------------------- - - - - - 8988eeef by sheaf at 2023-02-16T20:32:27-05:00 Expand synonyms in RoughMap We were failing to expand type synonyms in the function GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the RoughMap infrastructure crucially relies on type synonym expansion to work. This patch adds the missing type-synonym expansion. Fixes #22985 - - - - - 3dd50e2f by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Add test artifact Add the released testsuite tarball to the generated ghcup metadata. - - - - - c6a967d9 by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Use Ubuntu and Rocky bindists Prefer to use the Ubuntu 20.04 and 18.04 binary distributions on Ubuntu and Linux Mint. Prefer to use the Rocky 8 binary distribution on unknown distributions. - - - - - be0b7209 by Matthew Pickering at 2023-02-17T09:37:16+00:00 Add INLINABLE pragmas to `generic*` functions in Data.OldList These functions are * recursive * overloaded So it's important to add an `INLINABLE` pragma to each so that they can be specialised at the use site when the specific numeric type is known. Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020) https://github.com/haskell/core-libraries-committee/issues/129 - - - - - a203ad85 by Sylvain Henry at 2023-02-17T15:59:16-05:00 Merge libiserv with ghci `libiserv` serves no purpose. As it depends on `ghci` and doesn't have more dependencies than the `ghci` package, its code could live in the `ghci` package too. This commit also moves most of the code from the `iserv` program into the `ghci` package as well so that it can be reused. This is especially useful for the implementation of TH for the JS backend (#22261, !9779). - - - - - 7080a93f by Simon Peyton Jones at 2023-02-20T12:06:32+01:00 Improve GHC.Tc.Gen.App.tcInstFun It wasn't behaving right when inst_final=False, and the function had no type variables f :: Foo => Int Rather a corner case, but we might as well do it right. Fixes #22908 Unexpectedly, three test cases (all using :type in GHCi) got slightly better output as a result: T17403, T14796, T12447 - - - - - 2592ab69 by Cheng Shao at 2023-02-20T10:35:30-05:00 compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping The wasm NCG used to map CCCS to a wasm global, based on the observation that CCCS is a transient register that's already handled by thread state load/store logic, so it doesn't need to be backed by the rCCCS field in the register table. Unfortunately, this is wrong, since even when Cmm execution hasn't yielded back to the scheduler, the Cmm code may call enterFunCCS, which does use rCCCS. This breaks cost centre profiling in a subtle way, resulting in inaccurate stack traces in some test cases. The fix is simple though: just remove the CCCS mapping. - - - - - 26243de1 by Alexis King at 2023-02-20T15:27:17-05:00 Handle top-level Addr# literals in the bytecode compiler Fixes #22376. - - - - - 0196cc2b by romes at 2023-02-20T15:27:52-05:00 fix: Explicitly flush stdout on plugin Because of #20791, the plugins tests often fail. This is a temporary fix to stop the tests from failing due to unflushed outputs on windows and the explicit flush should be removed when #20791 is fixed. - - - - - 4327d635 by Ryan Scott at 2023-02-20T20:44:34-05:00 Don't generate datacon wrappers for `type data` declarations Data constructor wrappers only make sense for _value_-level data constructors, but data constructors for `type data` declarations only exist at the _type_ level. This patch does the following: * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data constructor receives a wrapper now consider whether or not its parent data type was declared with `type data`, omitting a wrapper if this is the case. * Now that `type data` data constructors no longer receive wrappers, there is a spot of code in `refineDefaultAlt` that panics when it encounters a value headed by a `type data` type constructor. I've fixed this with a special case in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]` to explain why we do this. Fixes #22948. - - - - - 96dc58b9 by Ryan Scott at 2023-02-20T20:44:35-05:00 Treat type data declarations as empty when checking pattern-matching coverage The data constructors for a `type data` declaration don't exist at the value level, so we don't want GHC to warn users to match on them. Fixes #22964. - - - - - ff8e99f6 by Ryan Scott at 2023-02-20T20:44:35-05:00 Disallow `tagToEnum#` on `type data` types We don't want to allow users to conjure up values of a `type data` type using `tagToEnum#`, as these simply don't exist at the value level. - - - - - 8e765aff by Andrew Lelechenko at 2023-02-21T12:03:24-05:00 Bump submodule text to 2.0.2 - - - - - 172ff88f by Georgi Lyubenov at 2023-02-21T18:35:56-05:00 GHC proposal 496 - Nullary record wildcards This patch implements GHC proposal 496, which allows record wildcards to be used for nullary constructors, e.g. data A = MkA1 | MkA2 { fld1 :: Int } f :: A -> Int f (MkA1 {..}) = 0 f (MkA2 {..}) = fld1 To achieve this, we add arity information to the record field environment, so that we can accept a constructor which has no fields while continuing to reject non-record constructors with more than 1 field. See Note [Nullary constructors and empty record wildcards], as well as the more general overview in Note [Local constructor info in the renamer], both in the newly introduced GHC.Types.ConInfo module. Fixes #22161 - - - - - f70a0239 by sheaf at 2023-02-21T18:36:35-05:00 ghc-prim: levity-polymorphic array equality ops This patch changes the pointer-equality comparison operations in GHC.Prim.PtrEq to work with arrays of unlifted values, e.g. sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int# Fixes #22976 - - - - - 9296660b by Andreas Klebinger at 2023-02-21T23:58:05-05:00 base: Correct @since annotation for FP<->Integral bit cast operations. Fixes #22708 - - - - - f11d9c27 by romes at 2023-02-21T23:58:42-05:00 fix: Update documentation links Closes #23008 Additionally batches some fixes to pointers to the Note [Wired-in units], and a typo in said note. - - - - - fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00 Propagate failure if unable to push notes - - - - - 8e170f86 by Alexis King at 2023-02-23T16:59:22-05:00 rts: Fix `prompt#` when profiling is enabled This commit also adds a new -Dk RTS option to the debug RTS to assist debugging continuation captures. Currently, the printed information is quite minimal, but more can be added in the future if it proves to be useful when debugging future issues. fixes #23001 - - - - - e9e7a00d by sheaf at 2023-02-23T17:00:01-05:00 Explicit migration timeline for loopy SC solving This patch updates the warning message introduced in commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit migration timeline: GHC will no longer support this constraint solving mechanism starting from GHC 9.10. Fixes #22912 - - - - - 4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00 JS: make some arithmetic primops faster (#22835) Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump terminfo submodule to 0.4.1.6 - - - - - f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump unix submodule to 2.8.1.0 - - - - - 47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump deepseq submodule to 1.4.8.1 - - - - - d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump directory submodule to 1.3.8.1 - - - - - df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump process submodule to v1.6.17.0 - - - - - 4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump hsc2hs submodule to 0.68.8 - - - - - 81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump array submodule to 0.5.4.0 - - - - - 6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump Cabal submodule to 3.9 pre-release - - - - - 4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump filepath submodule to 1.4.100.1 - - - - - 2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump haskeline submodule to 0.8.2.1 - - - - - fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00 gitlab-ci: Run nix-build with -v0 This significantly cuts down on the amount of noise in the job log. Addresses #22861. - - - - - 69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00 Fix ParallelListComp out of scope suggestion This patch makes it so vars from one block of a parallel list comprehension are not in scope in a subsequent block during type checking. This was causing GHC to emit a faulty suggestion when an out of scope variable shared the occ name of a var from a different block. Fixes #22940 - - - - - ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-05:00 Fix shadowing bug in prepareAlts As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was using an OutType to construct an InAlt. When shadowing is in play, this is outright wrong. See Note [Shadowing in prepareAlts]. - - - - - 7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00 JS: Store CI perf results (fix #22923) - - - - - b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00 Don't specialise incoherent instance applications Using incoherent instances, there can be situations where two occurrences of the same overloaded function at the same type use two different instances (see #22448). For incoherently resolved instances, we must mark them with `nospec` to avoid the specialiser rewriting one to the other. This marking is done during the desugaring of the `WpEvApp` wrapper. Fixes #22448 Metric Increase: T15304 - - - - - d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00 Fix SCC grouping example - - - - - f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00 Mark setnumcapabilities001 fragile - - - - - 29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00 Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail See #22520 - - - - - 9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00 ghc-prim: fix hs_cmpxchg64 function prototype hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised builds, which go unnoticed at compile-time due to C implicit casting in .hc files. - - - - - 0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-05:00 Account for local rules in specImports As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were generating specialisations (a locally-define function) for imported functions; and then generating specialisations for those locally-defined functions. The RULE for the latter should be attached to the local Id, not put in the rules-for-imported-ids set. Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules - - - - - 8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-05:00 JS: fix for overlap with copyMutableByteArray# (#23033) The code wasn't taking into account some kind of overlap. cgrun070 has been extended to test the missing case. - - - - - 239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00 Testsuite: replace some js_skip with req_cmm req_cmm is more informative than js_skip - - - - - 7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-05:00 Take more care with unlifted bindings in the specialiser As #22998 showed, we were floating an unlifted binding to top level, which breaks a Core invariant. The fix is easy, albeit a little bit conservative. See Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise - - - - - bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-05:00 Account for TYPE vs CONSTRAINT in mkSelCo As #23018 showed, in mkRuntimeRepCo we need to account for coercions between TYPE and COERCION. See Note [mkRuntimeRepCo] in GHC.Core.Coercion. - - - - - 79ffa170 by Ben Gamari at 2023-03-01T04:17:20-05:00 hadrian: Add dependency from lib/settings to mk/config.mk In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253 by adding logic to the bindist Makefile to regenerate the `settings` file from information gleaned by the bindist `configure` script. However, this fix had no effect as `lib/settings` is shipped in the binary distribution (to allow in-place use of the binary distribution). As `lib/settings` already existed and its rule declared no dependencies, `make` would fail to use the added rule to regenerate it. Fix this by explicitly declaring a dependency from `lib/settings` on `mk/config.mk`. Fixes #22982. - - - - - a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-05:00 Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)" This reverts the bits affecting fusion of `drop` and `dropWhile` of commit 0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`. It also adds a new test for #23021 (which was the reason for reverting) as well as adds a clarifying comment to T18964. Fixes #23021, unfixes #18964. Metric Increase: T18964 Metric Decrease: T18964 - - - - - cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-05:00 Refine the test for naughty record selectors The test for naughtiness in record selectors is surprisingly subtle. See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils. Fixes #23038. - - - - - 86f240ca by romes at 2023-03-01T04:19:10-05:00 fix: Consider strictness annotation in rep_bind Fixes #23036 - - - - - 1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00 Don't suppress *all* Wanteds Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its rewriters have unfilled coercion holes; see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint. But if we thereby suppress *all* errors that's really confusing, and as #22707 shows, GHC goes on without even realising that the program is broken. Disaster. This MR arranges to un-suppress them all if they all get suppressed. Close #22707 - - - - - 8919f341 by Luite Stegeman at 2023-03-02T22:42:45-05:00 Check for platform support for JavaScript foreign imports GHC was accepting `foreign import javascript` declarations on non-JavaScript platforms. This adds a check so that these are only supported on an platform that supports the JavaScript calling convention. Fixes #22774 - - - - - db83f8bb by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Statically assert alignment of Capability In #22965 we noticed that changes in the size of `Capability` can result in unsound behavior due to the `align` pragma claiming an alignment which we don't in practice observe. Avoid this by statically asserting that the size is a multiple of the alignment. - - - - - 5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Introduce stgMallocAlignedBytes - - - - - 8a6f745d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Correctly align Capability allocations Previously we failed to tell the C allocator that `Capability`s needed to be aligned, resulting in #22965. Fixes #22965. Fixes #22975. - - - - - 5464c73f by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Drop no-alignment special case for Windows For reasons that aren't clear, we were previously not giving Capability the same favorable alignment on Windows that we provided on other platforms. Fix this. - - - - - a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-05:00 constant folding: Correct type of decodeDouble_Int64 rule The first argument is Int64# unconditionally, so we better produce something of that type. This fixes a core lint error found in the ad package. Fixes #23019 - - - - - 68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-05:00 ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and didn't completly fix the compiler panics when compiling with `-fregs-graph`. Fixes #23002 - - - - - 2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00 Get the right in-scope set in etaBodyForJoinPoint Fixes #23026 - - - - - 45af8482 by David Feuer at 2023-03-03T11:40:47-05:00 Export getSolo from Data.Tuple Proposed in [CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113) and [approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191) - - - - - 0c694895 by David Feuer at 2023-03-03T11:40:47-05:00 Document getSolo - - - - - bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00 More fixes for `type data` declarations This MR fixes #23022 and #23023. Specifically * Beef up Note [Type data declarations] in GHC.Rename.Module, to make invariant (I1) explicit, and to name the several wrinkles. And add references to these specific wrinkles. * Add a Lint check for invariant (I1) above. See GHC.Core.Lint.checkTypeDataConOcc * Disable the `caseRules` for dataToTag# for `type data` values. See Wrinkle (W2c) in the Note above. Fixes #23023. * Refine the assertion in dataConRepArgTys, so that it does not complain about the absence of a wrapper for a `type data` constructor Fixes #23022. Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00 Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT These all type-level equality decision procedures. Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98 - - - - - bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00 Add test for T22793 - - - - - c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00 Fix typo in docs referring to threadLabel - - - - - 232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00 Add regression test for #22328 - - - - - 5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Enable response files for linker if supported - - - - - 1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Synchronize `configure.ac` and `distrib/configure.ac.in` - - - - - 70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix `hadrian/bindist/config.mk.in` … as suggested by @bgamari - - - - - b042b125 by sheaf at 2023-03-06T17:06:50-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Try to create somewhat portable `ld` command I cannot figure out a good way to generate an `ld` command that works on both Linux and macOS. Normally you'd use something like `AC_LINK_IFELSE` for this purpose (I think), but that won't let us test response file support. - - - - - 83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Quote variables … as suggested by @bgamari - - - - - 845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix configure failure on alpine linux - - - - - c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Small fixes to configure script - - - - - cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00 Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115) I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnIllegalInstanceHeadDecl TcRnUnexpectedStandaloneDerivingDecl TcRnUnusedVariableInRuleDecl TcRnUnexpectedStandaloneKindSig TcRnIllegalRuleLhs TcRnBadAssocRhs TcRnDuplicateRoleAnnot TcRnDuplicateKindSig TcRnIllegalDerivStrategy TcRnIllegalMultipleDerivClauses TcRnNoDerivStratSpecified TcRnStupidThetaInGadt TcRnBadImplicitSplice TcRnShadowedTyVarNameInFamResult TcRnIncorrectTyVarOnLhsOfInjCond TcRnUnknownTyVarsOnRhsOfInjCond Was introduced one helper type: RuleLhsErrReason - - - - - c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00 Constraint simplification loop now depends on `ExpansionFuel` instead of a boolean flag for `CDictCan.cc_pend_sc`. Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1. This helps pending given constraints to keep up with pending wanted constraints in case of `UndecidableSuperClasses` and superclass expansions while simplifying the infered type. Adds 3 dynamic flags for controlling the fuels for each type of constraints `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints Fixes #21909 Added Tests T21909, T21909b Added Note [Expanding Recursive Superclasses and ExpansionFuel] - - - - - a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00 Documentation: describe laziness of several function from Data.List - - - - - fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00 Add `Data.Functor.unzip` This function is currently present in `Data.List.NonEmpty`, but `Data.Functor` is a better home for it. This change was discussed and approved by the CLC at https://github.com/haskell/core-libraries-committee/issues/88. - - - - - 2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00 Fix documentation for traceWith and friends - - - - - f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00 Remove utils/hpc subdirectory and its contents - - - - - cf98e286 by David Binder at 2023-03-08T01:24:17-05:00 Add git submodule for utils/hpc - - - - - 605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 606793d4 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 4158722a by Sylvain Henry at 2023-03-08T01:24:58-05:00 linker: fix linking with aligned sections (#23066) Take section alignment into account instead of assuming 16 bytes (which is wrong when the section requires 32 bytes, cf #23066). - - - - - 1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00 Change hostSupportsRPaths to report False on OpenBSD OpenBSD does support -rpath but ghc build process relies on some related features that don't work there. See ghc/ghc#23011 - - - - - bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00 bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args fixes #23068 - - - - - 321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Drop redundant prototype - - - - - abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix style - - - - - be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Deduplicate assertion - - - - - b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Use release ordering when storing thread labels Since this makes the ByteArray# visible from other cores. - - - - - 5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/BlockAlloc: Allow disabling of internal assertions These can be quite expensive and it is sometimes useful to compile a DEBUG RTS without them. - - - - - 6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - 9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - 0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00 Evac: Squash data race in eval_selector_chain - - - - - 7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify comment - - - - - bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't push empty arrays to update remembered set Previously the write barrier of resizeSmallArray# incorrectly handled resizing of zero-sized arrays, pushing an invalid pointer to the update remembered set. Fixes #22931. - - - - - 92227b60 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. - - - - - ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 71b038a1 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check mutable list Assert that entries in the nonmoving generation's generational remembered set (a.k.a. mutable list) live in nonmoving generation. - - - - - 99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix tracking of FILLED_SWEEPING segments Previously we only updated the state of the segment at the head of each allocator's filled list. - - - - - 58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Assert state of swept segments - - - - - 2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive We must conservatively assume that new closures are reachable since we are not guaranteed to mark such blocks. - - - - - e4c3249f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. Fixes #22927. - - - - - 1b069671 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. See the inline comments for details. Fixes #22930. - - - - - d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Post-sweep sanity checking - - - - - 0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Avoid n_caps race - - - - - 5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Be more paranoid in segment tracking Previously we left various segment link pointers dangling. None of this wrong per se, but it did make it harder than necessary to debug. - - - - - 7c817c0a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Sync-phase mark budgeting Here we significantly improve the bound on sync phase pause times by imposing a limit on the amount of work that we can perform during the sync. If we find that we have exceeded our marking budget then we allow the mutators to resume, return to concurrent marking, and try synchronizing again later. Fixes #22929. - - - - - ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Allow pinned gen0 objects to be WEAK keys - - - - - 78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Reenable assertion - - - - - b500867a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move current segment array into Capability The current segments are conceptually owned by the mutator, not the collector. Consequently, it was quite tricky to prove that the mutator would not race with the collect due to this shared state. It turns out that such races are possible: when resizing the current segment array we may concurrently try to take a heap census. This will attempt to walk the current segment array, causing a data race. Fix this by moving the current segment array into `Capability`, where it belongs. Fixes #22926. - - - - - 56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix Note references Some references to Note [Deadlock detection under the non-moving collector] were missing an article. - - - - - 4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts/Sanity: Fix block count assertion with non-moving collector The nonmoving collector does not use `oldest_gen->blocks` to track its block list. However, it nevertheless updates `oldest_gen->n_blocks` to ensure that its size is accounted for by the storage manager. Consequently, we must not attempt to assert consistency between the two. - - - - - 96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't call prepareUnloadCheck When the nonmoving GC is in use we do not call `checkUnload` (since we don't unload code) and therefore should not call `prepareUnloadCheck`, lest we run into assertions. - - - - - 6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Encapsulate block allocator spinlock This makes it a bit easier to add instrumentation on this spinlock while debugging. - - - - - e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip some tests when sanity checking is enabled - - - - - 3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix unregisterised build - - - - - 4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Ensure that sanity checker accounts for saved_filled segments - - - - - f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00 hadrian: Add +boot_nonmoving_gc flavour transformer For using GHC bootstrapping to validate the non-moving GC. - - - - - 581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00 gitlab-ci: Add job bootstrapping with nonmoving GC - - - - - 487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move allocator into new source file - - - - - 8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Split out nonmovingAllocateGC - - - - - 662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Only run T22795* in the normal way It doesn't make sense to run these in multiple ways as they merely test whether `-threaded`/`-single-threaded` flags. - - - - - 0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Rename clear_segment(_free_blocks)? To reflect the fact that these are to do with the nonmoving collector, now since they are exposed no longer static. - - - - - 7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Fix incorrect STATIC_INLINE This should be INLINE_HEADER lest we get unused declaration warnings. - - - - - f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Mark ffi023 as broken due to #23089 - - - - - a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip T7160 in the nonmoving way Finalization order is different under the nonmoving collector. - - - - - f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Capture GC configuration in a struct The number of distinct arguments passed to GarbageCollect was getting a bit out of hand. - - - - - ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Non-concurrent collection - - - - - 7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00 hadrian: Fix flavour compiler stage options off-by-one error !9193 pointed out that ghcDebugAssertions was supposed to be a predicate on the stage of the built compiler, but in practice it was a predicate on the stage of the compiler used to build. Unfortunately, while it fixed that issue for ghcDebugAssertions, it documented every other similar option as behaving the same way when in fact they all used the old behavior. The new behavior of ghcDebugAssertions seems more intuitive, so this commit changes the interpretation of every other option to match. It also improves the enableProfiledGhc and debugGhc flavour transformers by making them more selective about which stages in which they build additional library/RTS ways. - - - - - f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00 Delete created temporary subdirectories at end of session. This patch adds temporary subdirectories to the list of paths do clean up at the end of the GHC session. This fixes warnings about non-empty temporary directories. Fixes #22952 - - - - - 9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00 Fixes #19627. Previously the solver failed with an unhelpful "solver reached too may iterations" error. With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up. This commit adds: * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel] * Test `typecheck/should_fail/T19627.hs` for regression purposes - - - - - ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00 DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997) We should not panic in `add_demands` (now `set_lam_dmds`), because that code path is legimitely taken for OPAQUE PAP bindings, as in T22997. Fixes #22997. - - - - - 5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00 JS: remove dead code for old integer-gmp - - - - - bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00 JS: Fix implementation of MK_JSVAL - - - - - ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00 Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf. - - - - - 047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00 JS: fix implementation of forceBool to use JS backend syntax - - - - - 559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00 Simplifier: `countValArgs` should not count Type args (#23102) I observed miscompilations while working on !10088 caused by this. Fixes #23102. Metric Decrease: T10421 - - - - - 536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00 Bump Win32 to 2.13.4.0 Updates Win32 submodule - - - - - ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00 ghc-bignum: Drop redundant include-dirs field - - - - - c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00 Fix BCO creation setting caps when -j > -N * Remove calls to 'setNumCapabilities' in 'createBCOs' These calls exist to ensure that 'createBCOs' can benefit from parallelism. But this is not the right place to call `setNumCapabilities`. Furthermore the logic differs from that in the driver causing the capability count to be raised and lowered at each TH call if -j > -N. * Remove 'BCOOpts' No longer needed as it was only used to thread the job count down to `createBCOs` Resolves #23049 - - - - - 5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00 Add changelog entry for #23049 - - - - - 6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00 configure: Fix FIND_CXX_STD_LIB test on Darwin Annoyingly, Darwin's <cstddef> includes <version> and APFS is case-insensitive. Consequently, it will end up #including the `VERSION` file generated by the `configure` script on the second and subsequent runs of the `configure` script. See #23116. - - - - - 19d6d039 by sheaf at 2023-03-16T21:31:22+01:00 ghci: only keep the GlobalRdrEnv in ModInfo The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo, which includes a TypeEnv. This can easily cause space leaks as we have no way of forcing everything in a type environment. In GHC, we only use the GlobalRdrEnv, which we can force completely. So we only store that instead of a fully-fledged ModuleInfo. - - - - - 73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00 Add structured error messages for GHC.Tc.Utils.Backpack Tracking ticket: #20119 MR: !10127 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. One occurrence, when handing a nested error from the interface loading machinery, was omitted. It will be handled by a subsequent changeset that addresses interface errors. - - - - - a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00 Rename () into Unit, (,,...,,) into Tuple<n> (#21294) This patch implements a part of GHC Proposal #475. The key change is in GHC.Tuple.Prim: - data () = () - data (a,b) = (a,b) - data (a,b,c) = (a,b,c) ... + data Unit = () + data Tuple2 a b = (a,b) + data Tuple3 a b c = (a,b,c) ... And the rest of the patch makes sure that Unit and Tuple<n> are pretty-printed as () and (,,...,,) in various contexts. Updates the haddock submodule. Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - 23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: fix some wrongs in the eventlog format documentation - - - - - 90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: explain the BLOCK_MARKER event - - - - - ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add BlockedOnMVarRead thread status in eventlog encodings - - - - - 898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add TASK_DELETE event in eventlog encodings - - - - - bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add WALL_CLOCK_TIME event in eventlog encodings - - - - - eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00 Add structured error messages for GHC.Tc.Utils.Env Tracking ticket: #20119 MR: !10129 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00 Document pdep / pext primops - - - - - e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00 Allow LLVM backend to use HDoc for faster file generation. Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement. Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045) - - - - - ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00 Compute LambdaFormInfo when using JavaScript backend. CmmCgInfos is needed to write interface files, but the JavaScript backend does not generate it, causing "Name without LFInfo" warnings. This patch adds a conservative but always correct CmmCgInfos when the JavaScript backend is used. Fixes #23053 - - - - - 926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00 Be more careful about quantification This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole - - - - - 0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00 Testsuite: use appropriate predicate for ManyUbxSums test (#22576) - - - - - 048c881e by romes at 2023-03-22T01:04:24-04:00 fix: Incorrect @since annotations in GHC.TypeError Fixes #23128 - - - - - a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T16318 (#22370) - - - - - ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T20214 - - - - - e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00 Refactor the constraint solver pipeline The big change is to put the entire type-equality solver into GHC.Tc.Solver.Equality, rather than scattering it over Canonical and Interact. Other changes * EqCt becomes its own data type, a bit like QCInst. This is great because EqualCtList is then just [EqCt] * New module GHC.Tc.Solver.Dict has come of the class-contraint solver. In due course it will be all. One step at a time. This MR is intended to have zero change in behaviour: it is a pure refactor. It opens the way to subsequent tidying up, we believe. - - - - - cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00 Add structured error messages for GHC.Tc.Utils.TcMType Tracking ticket: #20119 MR: !10138 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00 Testsuite: use js_skip for T2615 (#22374) - - - - - 8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00 Optimized Foldable methods for Data.Functor.Compose Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/57 - - - - - bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00 Additional optimized versions - - - - - 80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Simplify minimum/maximum in instance Foldable (Compose f g) - - - - - 8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Update changelog to mention changes to instance Foldable (Compose f g) - - - - - e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00 Add structured error messages for GHC.Tc.TyCl.PatSyn Tracking ticket: #20117 MR: !10158 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00 Allow WARNING pragmas to be controlled with custom categories Closes #17209. This implements GHC Proposal 541, allowing a WARNING pragma to be annotated with a category like so: {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-} The user can then enable, disable and set the severity of such warnings using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on. There is a new warning group `-Wextended-warnings` containing all these warnings. Warnings without a category are treated as if the category was `deprecations`, and are (still) controlled by the flags `-Wdeprecations` and `-Wwarnings-deprecations`. Updates Haddock submodule. - - - - - 0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00 Move mention of warning groups change to 9.8.1 release notes - - - - - b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00 nativeGen/AArch64: Fix bitmask immediate predicate Previously the predicate for determining whether a logical instruction operand could be encoded as a bitmask immediate was far too conservative. This meant that, e.g., pointer untagged required five instructions whereas it should only require one. Fixes #23030. - - - - - 46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00 User's guide: Improve docs for -Wall previously it would list the warnings _not_ enabled by -Wall. That’s unnecessary round-about and was out of date. So let's just name the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`). - - - - - 509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00 codeGen/tsan: Disable instrumentation of unaligned stores There is some disagreement regarding the prototype of `__tsan_unaligned_write` (specifically whether it takes just the written address, or the address and the value as an argument). Moreover, I have observed crashes which appear to be due to it. Disable instrumentation of unaligned stores as a temporary mitigation. Fixes #23096. - - - - - 6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00 base: Document GHC versions associated with past base versions in the changelog - - - - - 43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00 Add regression test for #17574 This test currently fails in the nonmoving way - - - - - f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00 fix: account for large and compact object stats with nonmoving gc Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap. We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap. Resolves #17574 - - - - - 7131b705 by David Feuer at 2023-03-25T00:04:04-04:00 Modify ThreadId documentation and comments For a long time, `GHC.Conc.Sync` has said ```haskell -- ToDo: data ThreadId = ThreadId (Weak ThreadId#) -- But since ThreadId# is unlifted, the Weak type must use open -- type variables. ``` We are now actually capable of using `Weak# ThreadId#`, but the world has moved on. To support the `Show` and `Ord` instances, we'd need to store the thread ID number in the `ThreadId`. And it seems very difficult to continue to support `threadStatus` in that regime, since it needs to be able to explain how threads died. In addition, garbage collection of weak references can be quite expensive, and it would be hard to evaluate the cost over he whole ecosystem. As discussed in [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125), it doesn't seem very likely that we'll actually switch to weak references here. - - - - - c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00 rts: Fix barriers of IND and IND_STATIC Previously IND and IND_STATIC lacked the acquire barriers enjoyed by BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers], this barrier is critical to ensure that the indirectee is visible to the entering core. Fixes #22872. - - - - - 62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00 Improve documentation of atomicModifyMutVar2# - - - - - b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00 rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023 This patch does a few things: - Add the missing RtsSymbols.c entry of performBlockingMajorGC - Make hs_perform_gc call performBlockingMajorGC, which restores previous behavior - Use hs_perform_gc in ffi023 - Remove rts_clearMemory() call in ffi023, it now works again in some test ways previously marked as broken. Fixes #23089 - - - - - d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00 testsuite: add the rts_clearMemory test case This patch adds a standalone test case for rts_clearMemory that mimics how it's typically used by wasm backend users and ensures this RTS API isn't broken by future RTS refactorings. Fixes #23901. - - - - - 80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00 Improve documentation for resizing of byte arrays - - - - - c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00 rts: Don't rely on EXTERN_INLINE for slop-zeroing logic Previously we relied on calling EXTERN_INLINE functions defined in ClosureMacros.h from Cmm to zero slop. However, as far as I can tell, this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted in each compilation unit. Fix this by explicitly declaring a new set of non-inline functions in ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h definitions as INLINE_HEADER. In the future we should try to eliminate EXTERN_INLINE. - - - - - c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00 rts: Fix capability-count check in zeroSlop Previously `zeroSlop` examined `RtsFlags` to determine whether the program was single-threaded. This is wrong; a program may be started with `+RTS -N1` yet the process may later increase the capability count with `setNumCapabilities`. This lead to quite subtle and rare crashes. Fixes #23088. - - - - - 656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00 Add Eq/Ord instances for SSymbol, SChar, and SNat This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148). - - - - - 4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00 Update and expand atomic modification Haddocks * The documentation for `atomicModifyIORef` and `atomicModifyIORef'` were incomplete, and the documentation for `atomicModifyIORef` was out of date. Update and expand. * Remove a useless lazy pattern match in the definition of `atomicModifyIORef`. The pair it claims to match lazily was already forced by `atomicModifyIORef2`. - - - - - e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00 Document the constructor name for lists Derived `Data` instances use raw infix constructor names when applicable. The `Data.Data [a]` instance, if derived, would have a constructor name of `":"`. However, it actually uses constructor name `"(:)"`. Document this peculiarity. See https://github.com/haskell/core-libraries-committee/issues/147 - - - - - c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00 Make exprIsConApp_maybe a bit cleverer Addresses #23159. See Note Note [Exploit occ-info in exprIsConApp_maybe] in GHC.Core.SimpleOpt. Compile times go down very slightly, but always go down, never up. Good! Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -1.8% T15703(normal) -1.2% GOOD geo. mean -0.1% minimum -1.8% maximum +0.0% Metric Decrease: CoOpt_Singletons T15703 - - - - - 76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00 Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat This implements [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149). - - - - - 3f374399 by sheaf at 2023-03-29T13:57:33+02:00 Handle records in the renamer This patch moves the field-based logic for disambiguating record updates to the renamer. The type-directed logic, scheduled for removal, remains in the typechecker. To do this properly (and fix the myriad of bugs surrounding the treatment of duplicate record fields), we took the following main steps: 1. Create GREInfo, a renamer-level equivalent to TyThing which stores information pertinent to the renamer. This allows us to uniformly treat imported and local Names in the renamer, as described in Note [GREInfo]. 2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which distinguished between normal names and field names, we now store simple Names in GlobalRdrElt, along with the new GREInfo information which allows us to recover the FieldLabel for record fields. 3. Add namespacing for record fields, within the OccNames themselves. This allows us to remove the mangling of duplicate field selectors. This change ensures we don't print mangled names to the user in error messages, and allows us to handle duplicate record fields in Template Haskell. 4. Move record disambiguation to the renamer, and operate on the level of data constructors instead, to handle #21443. The error message text for ambiguous record updates has also been changed to reflect that type-directed disambiguation is on the way out. (3) means that OccEnv is now a bit more complex: we first key on the textual name, which gives an inner map keyed on NameSpace: OccEnv a ~ FastStringEnv (UniqFM NameSpace a) Note that this change, along with (2), both increase the memory residency of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to regress somewhat in compile-time allocation. Even though (3) simplified a lot of code (in particular the treatment of field selectors within Template Haskell and in error messages), it came with one important wrinkle: in the situation of -- M.hs-boot module M where { data A; foo :: A -> Int } -- M.hs module M where { data A = MkA { foo :: Int } } we have that M.hs-boot exports a variable foo, which is supposed to match with the record field foo that M exports. To solve this issue, we add a new impedance-matching binding to M foo{var} = foo{fld} This mimics the logic that existed already for impedance-binding DFunIds, but getting it right was a bit tricky. See Note [Record field impedance matching] in GHC.Tc.Module. We also needed to be careful to avoid introducing space leaks in GHCi. So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in ModIface. This means stubbing out all the GREInfo fields, with the function forceGlobalRdrEnv. When we read it back in, we rehydrate with rehydrateGlobalRdrEnv. This robustly avoids any space leaks caused by retaining old type environments. Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063 Updates haddock submodule ------------------------- Metric Increase: MultiComponentModules MultiLayerModules MultiLayerModulesDefsGhci MultiLayerModulesNoCode T13701 T14697 hard_hole_fits ------------------------- - - - - - 4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00 Avoid repeatedly shadowing in shadowNames This commit refactors GHC.Type.Name.Reader.shadowNames to first accumulate all the shadowing arising from the introduction of a new set of GREs, and then applies all the shadowing to the old GlobalRdrEnv in one go. - - - - - d246049c by sheaf at 2023-03-29T13:57:34+02:00 igre_prompt_env: discard "only-qualified" names We were unnecessarily carrying around names only available qualified in igre_prompt_env, violating the icReaderEnv invariant. We now get rid of these, as they aren't needed for the shadowing computation that igre_prompt_env exists for. Fixes #23177 ------------------------- Metric Decrease: T14052 T14052Type ------------------------- - - - - - 41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00 hadrian: Fix path to HpcParser.y The source for this project has been moved into a src/ folder so we also need to update this path. Fixes #23187 - - - - - b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00 js: split JMacro into JS eDSL and JS syntax This commit: Splits JExpr and JStat into two nearly identical DSLs: - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a value cannot be unsaturated, or, a value of this DSL is a witness that a value of GHC.JS.Unsat has been saturated - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation. Then all binary and outputable instances are changed to use GHC.JS.Syntax. This moves us closer to closing out #22736 and #22352. See #22736 for roadmap. ------------------------- Metric Increase: CoOpt_Read LargeRecord ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T10858 T11195 T11374 T11822 T12227 T12707 T13035 T13253 T13253-spj T13379 T14683 T15164 T15703 T16577 T17096 T17516 T17836 T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T4801 T5321FD T5321Fun T5631 T5642 T783 T9198 T9233 T9630 TcPlugin_RewritePerf WWRec ------------------------- - - - - - f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. Also used the opportunity to reenable 64-bit Word/Int tests - - - - - a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00 testsuite: Fix racing prints in T21465 As noted in #23155, we previously failed to add flushes necessary to ensure predictable output. Fixes #23155. - - - - - 98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00 Revert "ghc-heap: remove wrong Addr# coercion (#23181)" This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02. This fails to build with GHC-9.2 as a boot compiler. See #23195 for tracking this issue. - - - - - 61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Add {-# WARNING #-} to Data.List.{head,tail} - - - - - 8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-} - - - - - 7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Bump submodules - - - - - d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fix tests - - - - - 3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00 Proxies for head and tail: review suggestions - - - - - 930edcfd by sheaf at 2023-03-30T14:36:33-04:00 docs: move RecordUpd changelog entry to 9.8 This was accidentally included in the 9.6 changelog instead of the 9.6 changelog. - - - - - 6f885e65 by sheaf at 2023-03-30T14:37:09-04:00 Add LANGUAGE GADTs to GHC.Rename.Env We need to enable this extension for the file to compile with ghc 9.2, as we are pattern matching on a GADT and this required the GADT extension to be enabled until 9.4. - - - - - 6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: make lint-ci-config job fast again We don't pin our nixpkgs revision and tracks the default nixpkgs-unstable channel anyway. Instead of using haskell.packages.ghc924, we should be using haskell.packages.ghc92 to maximize the binary cache hit rate and make lint-ci-config job fast again. Also bumps the nix docker image to the latest revision. - - - - - ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: ensure that all non-i386 pipelines do parallel xz compression We can safely enable parallel xz compression for non-i386 pipelines. However, previously we didn't export XZ_OPT, so the xz process won't see it if XZ_OPT hasn't already been set in the current job. - - - - - 20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: unset CROSS_EMULATOR for js job - - - - - 4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: fix lint-testsuite job The list_broken make target will transitively depend on the calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It really should be TEST_HC since that's what get passed in the gitlab CI config. - - - - - cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: use alpine3_17-wasm image for wasm jobs Bump the ci-images dependency and use the new alpine3_17-wasm docker image for wasm jobs. - - - - - 79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Add basic support for testing cross-compilers - - - - - e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Normalize away differences in ghc executable name - - - - - ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00 hadrian: Pass CROSS_EMULATOR to runtests.py - - - - - 30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: don't add optllvm way for wasm32 - - - - - f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: normalize the .wasm extension - - - - - a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: strip the cross ghc prefix in output and error message - - - - - f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: handle target executable extension - - - - - 8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: mypy typing error fixes This patch fixes some mypy typing errors which weren't caught in previous linting jobs. - - - - - 0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: use context variable instead of thread-local variable This patch changes a thread-local variable to context variable instead, which works as intended when the testsuite transitions to use asyncio & coroutines instead of multi-threading to concurrently run test cases. Note that this also raises the minimum Python version to 3.7. - - - - - ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: asyncify the testsuite driver This patch refactors the testsuite driver, gets rid of multi-threading logic for running test cases concurrently, and uses asyncio & coroutines instead. This is not yak shaving for its own sake; the previous multi-threading logic is prone to livelock/deadlock conditions for some reason, even if the total number of threads is bounded to a thread pool's capacity. The asyncify change is an internal implementation detail of the testsuite driver and does not impact most GHC maintainers out there. The patch does not touch the .T files, test cases can be added/modified the exact same way as before. - - - - - 0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00 Add test for T23184 There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch: ``` commit 6656f0165a30fc2a22208532ba384fc8e2f11b46 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Jul 23 23:57:01 2021 +0100 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: ...lots of lines omitted... Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. ``` Note this "Fix a fairly longstanding outright bug". This is the specific fix ``` @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds -- let a = ...arg... -- in [...hole...] a -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable - do { let (dmd:_) = dmds -- Never fails - ; (floats1, cont') <- mkDupableContWithDmds env dmds cont + do { let (dmd:cont_dmds) = dmds -- Never fails + ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 ; (_, se', arg') <- simplArg env' dup se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ``` Ticket #23184 is a report of the bug that this diff fixes. - - - - - 62d25071 by mangoiv at 2023-04-01T04:20:01-04:00 [feat] make ($) representation polymorphic - this change was approved by the CLC in [1] following a CLC proposal [2] - make ($) representation polymorphic (adjust the type signature) - change ($) implementation to allow additional polymorphism - adjust the haddock of ($) to reflect these changes - add additional documentation to document these changes - add changelog entry - adjust tests (move now succeeding tests and adjust stdout of some tests) [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854 [2] https://github.com/haskell/core-libraries-committee/issues/132 - - - - - 77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00 User Guide: update copyright year: 2020->2023 - - - - - 3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00 driver: Unit State Data.Map -> GHC.Unique.UniqMap In pursuit of #22426. The driver and unit state are major contributors. This commit also bumps the haddock submodule to reflect the API changes in UniqMap. ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp T10421 T10547 T12150 T12234 T12425 T13035 T16875 T18140 T18304 T18698a T18698b T18923 T20049 T5837 T6048 T9198 ------------------------- - - - - - a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00 Add structured error messages for GHC.Tc.TyCl Tracking ticket: #20117 MR: !10183 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00 JS: Linker: use saturated JExpr Follow on to MR!10142 in pursuit of #22736 - - - - - 3da69346 by sheaf at 2023-04-01T18:28:37-04:00 Improve haddocks of template-haskell Con datatype This adds a bit more information, in particular about the lists of constructors in the GadtC and RecGadtC cases. - - - - - 3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00 TH: revert changes to GadtC & RecGadtC Commit 3f374399 included a breaking-change to the template-haskell library when it made the GadtC and RecGadtC constructors take non-empty lists of names. As this has the potential to break many users' packages, we decided to revert these changes for now. - - - - - f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00 Rework documentation for data Char - - - - - 43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00 cmm: implement parsing of MO_AtomicRMW from hand-written CMM files Fixes #23206 - - - - - ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. - - - - - 2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00 hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1 Also fixes the ./generate_bootstrap_plans script which was recently broken We can hopefully drop the 9.2 plans soon but they still work so kept them around for now. - - - - - c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00 ci: Add job to test 9.6 bootstrapping - - - - - 53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00 hadrian: Improve option parsing Several options in Hadrian had their argument marked as optional (`OptArg`), but if the argument wasn't there they were just giving an error. It's more idiomatic to mark the argument as required instead; the code uses less Maybes, the parser can enforce that the argument is present, --help gives better output. - - - - - a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00 JS: fix issues with FD api support - Add missing implementations for fcntl_read/write/lock - Fix fdGetMode These were found while implementing TH in !9779. These functions must be used somehow by the external interpreter code. - - - - - 8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00 Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnDataKindsError TcRnUnusedQuantifiedTypeVar TcRnIllegalKindSignature TcRnUnexpectedPatSigType TcRnSectionPrecedenceError TcRnPrecedenceParsingError TcRnIllegalKind TcRnNegativeNumTypeLiteral TcRnUnexpectedKindVar TcRnBindMultipleVariables TcRnBindVarAlreadyInScope - - - - - 220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00 Fixes around unsafeCoerce# 1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul in 74ad75e87317, `unsafeCoerce#` is no longer defined there. I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module. 2. The documentation of `unsafeCoerce#` stated that you should not cast a function to an algebraic type, even if you later cast it back before applying it. But ghci was doing that type of cast, as can be seen with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any following the documentation. - - - - - 9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00 Add a few more memcpy-ish primops * copyMutableByteArrayNonOverlapping# * copyAddrToAddr# * copyAddrToAddrNonOverlapping# * setAddrRange# The implementations of copyBytes, moveBytes, and fillBytes in base:Foreign.Marshal.Utils now use these new primops, which can cause us to work a bit harder generating code for them, resulting in the metric increase in T21839c observed by CI on some architectures. But in exchange, we get better code! Metric Increase: T21839c - - - - - f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00 StgToCmm: Upgrade -fcheck-prim-bounds behavior Fixes #21054. Additionally, we can now check for range overlap when generating Cmm for primops that use memcpy internally. - - - - - cd00e321 by sheaf at 2023-04-04T01:04:50-04:00 Relax assertion in varToRecFieldOcc When using Template Haskell, it is possible to re-parent a field OccName belonging to one data constructor to another data constructor. The lsp-types package did this in order to "extend" a data constructor with additional fields. This ran into an assertion in 'varToRecFieldOcc'. This assertion can simply be relaxed, as the resulting splices are perfectly sound. Fixes #23220 - - - - - eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00 GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201) - - - - - 071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00 Make INLINE pragmas for pattern synonyms work with TH Previously, the code for converting `INLINE <name>` pragmas from TH splices used `vNameN`, which assumed that `<name>` must live in the variable namespace. Pattern synonyms, on the other hand, live in the constructor namespace. I've fixed the issue by switching to `vcNameN` instead, which works for both the variable and constructor namespaces. Fixes #23203. - - - - - 7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00 Fix unification with oversaturated type families unify_ty was incorrectly saying that F x y ~ T x are surely apart, where F x y is an oversaturated type family and T x is a tyconapp. As a result, the simplifier dropped a live case alternative (#23134). - - - - - c165f079 by sheaf at 2023-04-04T17:13:40-04:00 Add testcase for #23192 This issue around solving of constraints arising from superclass expansion using other constraints also borned from superclass expansion was the topic of commit aed1974e. That commit made sure we don't emit a "redundant constraint" warning in a situation in which removing the constraint would cause errors. Fixes #23192 - - - - - d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00 nonmoving: Disable slop-zeroing As noted in #23170, the nonmoving GC can race with a mutator zeroing the slop of an updated thunk (in much the same way that two mutators would race). Consequently, we must disable slop-zeroing when the nonmoving GC is in use. Closes #23170 - - - - - 04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00 Fix reverse flag for -Wunsupported-llvm-version - - - - - 0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00 Add release note for GHC.Unicode refactor in base-4.18. Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in base-4.18 and add proper release date. - - - - - cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00 Improve documentation for ($) (#22963) - - - - - 5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00 Remove trailing whitespace from ($) commentary - - - - - b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00 Adjust wording wrt representation polymorphism of ($) - - - - - 6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00 Add structured error messages for GHC.Tc.TyCl.Utils Tracking ticket: #20117 MR: !10251 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00 Renamer: don't call addUsedGRE on an exact Name When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc, we could end up calling addUsedGRE on an exact Name, which would then lead to a panic in the bestImport function: it would be incapable of processing a GRE which is not local but also not brought into scope by any imports (as it is referred to by its unique instead). Fixes #23240 - - - - - bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add support for -debug in the testsuite Confusingly, GhcDebugged referred to GhcDebugAssertions. - - - - - b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add missing cases in -Di prettyprinter Fixes #23142 - - - - - 6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: make WasmCodeGenM an instance of MonadUnique - - - - - 05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: apply cmm node-splitting for wasm backend This patch applies cmm node-splitting for wasm32 NCG, which is required when handling irreducible CFGs. Fixes #23237. - - - - - f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00 Set base 'maintainer' field to CLC - - - - - ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00 Clarify a couple of Notes about 'nospec' - - - - - ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00 Allow generation of TTH syntax with TH In other words allow generation of typed splices and brackets with Untyped Template Haskell. That is useful in cases where a library is build with TTH in mind, but we still want to generate some auxiliary declarations, where TTH cannot help us, but untyped TH can. Such example is e.g. `staged-sop` which works with TTH, but we would like to derive `Generic` declarations with TH. An alternative approach is to use `unsafeCodeCoerce`, but then the derived `Generic` instances would be type-checked only at use sites, i.e. much later. Also `-ddump-splices` output is quite ugly: user-written instances would use TTH brackets, not `unsafeCodeCoerce`. This commit doesn't allow generating of untyped template splices and brackets with untyped TH, as I don't know why one would want to do that (instead of merging the splices, e.g.) - - - - - 690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00 Add regression test for #23229 - - - - - 59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quotRem rules (#22152) case quotRemInt# x y of (# q, _ #) -> body ====> case quotInt# x y of q -> body case quotRemInt# x y of (# _, r #) -> body ====> case remInt# x y of r -> body - - - - - 4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quot folding rule (#22152) (x / l1) / l2 l1 and l2 /= 0 l1*l2 doesn't overflow ==> x / (l1 * l2) - - - - - 1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make Int64/Word64 division ok for speculation too. Only when the divisor is definitely non-zero. - - - - - 8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make WordQuotRem2Op ok-for-speculation too - - - - - 27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00 Base/JS: GHC.JS.Foreign.Callback module (issue 23126) * Add the Callback module for "exporting" Haskell functions to be available to plain JavaScript code * Fix some primitives defined in GHC.JS.Prim * Add a JavaScript section to the user guide with instructions on how to use the JavaScript FFI, building up to using Callbacks to interact with the browser * Add tests for the JavaScript FFI and Callbacks - - - - - a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00 rts: improve memory ordering and add some comments in the StablePtr implementation - - - - - d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00 docs: Generate docs/index.html with version number * Generate docs/index.html to include the version of the ghc library * This also fixes the packageVersions interpolations which were - Missing an interpolation for `LIBRARY_ghc_VERSION` - Double quoting the version so that "9.7" was being inserted. Fixes #23121 - - - - - d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00 Stop if type constructors have kind errors Otherwise we get knock-on errors, such as #23252. This makes GHC fail a bit sooner, and I have not attempted to add recovery code, to add a fake TyCon place of the erroneous one, in an attempt to get more type errors in one pass. We could do that (perhaps) if there was a call for it. - - - - - 2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Major refactor in the handling of equality constraints This MR substantially refactors the way in which the constraint solver deals with equality constraints. The big thing is: * Intead of a pipeline in which we /first/ canonicalise and /then/ interact (the latter including performing unification) the two steps are more closely integreated into one. That avoids the current rather indirect communication between the two steps. The proximate cause for this refactoring is fixing #22194, which involve solving [W] alpha[2] ~ Maybe (F beta[4]) by doing this: alpha[2] := Maybe delta[2] [W] delta[2] ~ F beta[4] That is, we don't promote beta[4]! This is very like introducing a cycle breaker, and was very awkward to do before, but now it is all nice. See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and Note [Family applications in canonical constraints]. The big change is this: * Several canonicalisation checks (occurs-check, cycle-breaking, checking for concreteness) are combined into one new function: GHC.Tc.Utils.Unify.checkTyEqRhs This function is controlled by `TyEqFlags`, which says what to do for foralls, type families etc. * `canEqCanLHSFinish` now sees if unification is possible, and if so, actually does it: see `canEqCanLHSFinish_try_unification`. There are loads of smaller changes: * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a cheap-and-cheerful version of `checkTyEqRhs`, called `simpleUnifyCheck`. If `simpleUnifyCheck` succeeds, it can unify, otherwise it defers by emitting a constraint. This is simpler than before. * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`. Especially the nasty stuff involving `swap_for_occurs` and `canEqTyVarFunEq`. Much nicer now. See Note [Orienting TyVarLHS/TyFamLHS] Note [Orienting TyFamLHS/TyFamLHS] * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the problems that can be discovered by `checkTyEqRhs`. * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to to accept both cases in #22194 rather than rejecting both. Yet smaller: * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`) to reduce the need for synonym expansion when checking concreteness. Use it in `isConcreteType`. * Renamed `isConcrete` to `isConcreteType` * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient way to find if a particular type variable is used injectively than finding all the injective variables. It is called in `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a lot. * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the constraint solver. Fixes #22194, #23199 Compile times decrease by an average of 0.1%; but there is a 7.4% drop in compiler allocation on T15703. Metric Decrease: T15703 - - - - - 99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Add some documentation about redundant constraints - - - - - 3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Improve partial signatures This MR fixes #23223. The changes are in two places: * GHC.Tc.Bind.checkMonomorphismRestriction See the new `Note [When the MR applies]` We now no longer stupidly attempt to apply the MR when the user specifies a context, e.g. f :: Eq a => _ -> _ * GHC.Tc.Solver.decideQuantification See rewritten `Note [Constraints in partial type signatures]` Fixing this bug apparently breaks three tests: * partial-sigs/should_compile/T11192 * partial-sigs/should_fail/Defaulting1MROff * partial-sigs/should_fail/T11122 However they are all symptoms of #23232, so I'm marking them as expect_broken(23232). I feel happy about this MR. Nice. - - - - - 23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Make approximateWC a bit cleverer This MR fixes #23224: making approximateWC more clever See the long `Note [ApproximateWC]` in GHC.Tc.Solver All this is delicate and ad-hoc -- but it /has/ to be: we are talking about inferring a type for a binding in the presence of GADTs, type families and whatnot: known difficult territory. We just try as hard as we can. - - - - - 2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00 docs: Update template-haskell docs to use Code Q a rather than Q (TExp a) Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a rather than Q (TExp a). The documentation in the `template-haskell` library wasn't updated to reflect this change. Fixes #23148 - - - - - 0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00 Show an error when we cannot default a concrete tyvar Fixes #23153 - - - - - bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00 Handle ConcreteTvs in inferResultToType inferResultToType was discarding the ir_frr information, which meant some metavariables ended up being MetaTvs instead of ConcreteTvs. This function now creates new ConcreteTvs as necessary, instead of always creating MetaTvs. Fixes #23154 - - - - - 3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00 Transfer DFunId_ness onto specialised bindings Whether a binding is a DFunId or not has consequences for the `-fdicts-strict` flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does not apply because the constraint solver can create recursive groups of dictionaries. In #22549 this was fixed for the "normal" case, see Note [Do not strictify the argument dictionaries of a dfun]. However the loop still existed if the DFunId was being specialised. The problem was that the specialiser would specialise a DFunId and turn it into a VanillaId and so the demand analyser didn't know to apply special treatment to the binding anymore and the whole recursive group was optimised to bottom. The solution is to transfer over the DFunId-ness of the binding in the specialiser so that the demand analyser knows not to apply the `-fstrict-dicts`. Fixes #22549 - - - - - a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00 Add import lists to few GHC.Driver.Session imports Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261. There are a lot of GHC.Driver.Session which only use DynFlags, but not the parsing code. - - - - - 51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00 Account for special GHC.Prim import in warnUnusedPackages The GHC.Prim import is treated quite specially primarily because there isn't an interface file for GHC.Prim. Therefore we record separately in the ModSummary if it's imported or not so we don't go looking for it. This logic hasn't made it's way to `-Wunused-packages` so if you imported GHC.Prim then the warning would complain you didn't use `-package ghc-prim`. Fixes #23212 - - - - - 1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00 Add regression test for #23199 - - - - - 0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00 validDerivPred: Reject exotic constraints in IrredPreds This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely, we should reject `IrredPred`s that are inferred from `deriving` clauses whose arguments contain other type constructors, as described in `(VD2) Reject exotic constraints` of that Note. This has the nice property that `deriving` clauses whose inferred instance context mention `TypeError` will now emit the type error in the resulting error message, which better matches existing intuitions about how `TypeError` should work. While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]` was duplicated in a separate `Note [Exotic derived instance contexts]` in `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that there is a single authority on describing the conditions under which an inferred `deriving` constraint can be considered valid. This changes the behavior of `deriving` in a way that existing code might break, so I have made a mention of this in the GHC User's Guide. It seems very, very unlikely that much code is relying on this strange behavior, however, and even if there is, there is a clear, backwards-compatible migration path using `StandaloneDeriving`. Fixes #22696. - - - - - 10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00 Misc cleanup - Use dedicated list functions - Make cloneBndrs and cloneRecIdBndrs monadic - Fix invalid haddock comments in libraries/base - - - - - 5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00 Convert interface file loading errors into proper diagnostics This patch converts all the errors to do with loading interface files into proper structured diagnostics. * DriverMessage: Sometimes in the driver we attempt to load an interface file so we embed the IfaceMessage into the DriverMessage. * TcRnMessage: Most the time we are loading interface files during typechecking, so we embed the IfaceMessage This patch also removes the TcRnInterfaceLookupError constructor which is superceded by the IfaceMessage, which is now structured compared to just storing an SDoc before. - - - - - df1a5811 by sheaf at 2023-04-18T10:31:43-04:00 Don't panic in ltPatersonSize The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it encountered a type family on the RHS, as usually these are not allowed (type families are not allowed on the RHS of class instances or of quantified constraints). However, it is possible to still encounter type families on the RHS after doing a bit of constraint solving, as seen in test case T23171. This could trigger the panic in the call to ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which is involved in avoiding loopy superclass constraints. This patch simply changes ltPatersonSize to return "I don't know, because there's a type family involved" in these cases. Fixes #23171 - - - - - d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00 JS: fix thread-related primops - - - - - 7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00 CI: Disable abi-test-nightly See #23269 - - - - - ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00 Testsuite: don't use obsolescent egrep (#22351) Recent egrep displays the following message, breaking golden tests: egrep: warning: egrep is obsolescent; using grep -E Switch to using "grep -E" instead - - - - - f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00 hadrian: Pass haddock file arguments in a response file In !10119 CI was failing on windows because the command line was too long. We can mitigate this by passing the file arguments to haddock in a response file. We can't easily pass all the arguments in a response file because the `+RTS` arguments can't be placed in the response file. Fixes #23273 - - - - - 7012ec2f by tocic at 2023-04-20T11:01:42-04:00 Fix doc typo in GHC.Read.readList - - - - - 5c873124 by sheaf at 2023-04-20T18:33:34-04:00 Implement -jsem: parallelism controlled by semaphores See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a complete description for the motivation for this feature. The `-jsem` option allows a build tool to pass a semaphore to GHC which GHC can use in order to control how much parallelism it requests. GHC itself acts as a client in the GHC jobserver protocol. ``` GHC Jobserver Protocol ~~~~~~~~~~~~~~~~~~~~~~ This proposal introduces the GHC Jobserver Protocol. This protocol allows a server to dynamically invoke many instances of a client process, while restricting all of those instances to use no more than <n> capabilities. This is achieved by coordination over a system semaphore (either a POSIX semaphore [6]_ in the case of Linux and Darwin, or a Win32 semaphore [7]_ in the case of Windows platforms). There are two kinds of participants in the GHC Jobserver protocol: - The *jobserver* creates a system semaphore with a certain number of available tokens. Each time the jobserver wants to spawn a new jobclient subprocess, it **must** first acquire a single token from the semaphore, before spawning the subprocess. This token **must** be released once the subprocess terminates. Once work is finished, the jobserver **must** destroy the semaphore it created. - A *jobclient* is a subprocess spawned by the jobserver or another jobclient. Each jobclient starts with one available token (its *implicit token*, which was acquired by the parent which spawned it), and can request more tokens through the Jobserver Protocol by waiting on the semaphore. Each time a jobclient wants to spawn a new jobclient subprocess, it **must** pass on a single token to the child jobclient. This token can either be the jobclient's implicit token, or another token which the jobclient acquired from the semaphore. Each jobclient **must** release exactly as many tokens as it has acquired from the semaphore (this does not include the implicit tokens). ``` Build tools such as cabal act as jobservers in the protocol and are responsibile for correctly creating, cleaning up and managing the semaphore. Adds a new submodule (semaphore-compat) for managing and interacting with semaphores in a cross-platform way. Fixes #19349 - - - - - 52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00 rts: Initialize Array# header in listThreads# Previously the implementation of listThreads# failed to initialize the header of the created array, leading to various nastiness. Fixes #23071 - - - - - 1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00 testsuite: Add test for #23071 - - - - - dae514f9 by tocic at 2023-04-21T13:31:21-04:00 Fix doc typos in libraries/base/GHC - - - - - 113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00 Testsuite: replace some js_broken/js_skip predicates with req_c Using req_c is more precise. - - - - - 038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00 Minor doc fixes - Add docs/index.html to .gitignore. It is created by ./hadrian/build docs, and it was the only file in Hadrian's templateRules not present in .gitignore. - Mention that MultiWayIf supports non-boolean guards - Remove documentation of optdll - removed in 2007, 763daed95 - Fix markdown syntax - - - - - e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00 User's guide: DeepSubsumption is implied by Haskell{98,2010} - - - - - 499a1c20 by PHO at 2023-04-23T13:39:32-04:00 Implement executablePath for Solaris and make getBaseDir less platform-dependent Use base-4.17 executablePath when possible, and fall back on getExecutablePath when it's not available. The sole reason why getBaseDir had #ifdef's was apparently that getExecutablePath wasn't reliable, and we could reduce the number of CPP conditionals by making use of executablePath instead. Also export executablePath on js_HOST_ARCH. - - - - - 97a6f7bc by tocic at 2023-04-23T13:40:08-04:00 Fix doc typos in libraries/base - - - - - 787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00 testsuite/T20137: Avoid impl.-defined behavior Previously we would cast pointers to uint64_t. However, implementations are allowed to either zero- or sign-extend such casts. Instead cast to uintptr_t to avoid this. Fixes #23247. - - - - - 87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00 rts: always build 64-bit atomic ops This patch does a few things: - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit platforms - Remove legacy "64bit" cabal flag of rts package - Fix hs_xchg64 function prototype for 32-bit platforms - Fix AtomicFetch test for wasm32 - - - - - 2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00 compiler: don't install signal handlers when the host platform doesn't have signals Previously, large parts of GHC API will transitively invoke withSignalHandlers, which doesn't work on host platforms without signal functionality at all (e.g. wasm32-wasi). By making withSignalHandlers a no-op on those platforms, we can make more parts of GHC API work out of the box when signals aren't supported. - - - - - 1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00 hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC - - - - - 1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00 Add since pragma to Data.Functor.unzip - - - - - 0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00 More informative errors for bad imports (#21826) - - - - - ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00 JS/base: provide implementation for mkdir (issue 22374) - - - - - 8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00 JS: Fix h$base_access implementation (issue 22576) - - - - - 74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00 Give more guarntees about ImplicitParams (#23289) - Added new section in the GHC user's guide that legends behavior of nested implicit parameter bindings in these two cases: let ?f = 1 in let ?f = 2 in ?f and data T where MkT :: (?f :: Int) => T f :: T -> T -> Int f MkT MkT = ?f - Added new test case to examine this behavior. - - - - - c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00 DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208. - - - - - 77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00 Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364) Carry the actual type of an expression through the PreStgRhs and into GenStgRhs for use in later stages. Currently this is used in the JavaScript backend to fix some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2, T13822, T14749. - - - - - 052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00 EPA: Use ExplicitBraces only in HsModule !9018 brought in exact print annotations in LayoutInfo for open and close braces at the top level. But it retained them in the HsModule annotations too. Remove the originals, so exact printing uses LayoutInfo - - - - - d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: update ci.sh to actually run the entire testsuite for wasm backend For the time being, we still need to use in-tree mode and can't test the bindist yet. - - - - - 533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: additional wasm32 manual jobs in validate pipelines This patch enables bignum native & unregisterised wasm32 jobs as manual jobs in validate pipelines, which can be useful to prevent breakage when working on wasm32 related patches. - - - - - b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix cross prefix stripping This patch fixes cross prefix stripping in the testsuite driver. The normalization logic used to only handle prefixes of the triple form <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens in the prefix tuple, so the cross prefix stripping logic would work when ghc is configured with something like --target=wasm32-wasi. - - - - - 6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: include target exe extension in heap profile filenames This patch fixes hp2ps related framework failures when testing the wasm backend by including target exe extension in heap profile filenames. - - - - - e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: exclude ghci ways if no rts linker is present This patch implements logic to automatically exclude ghci ways when there is no rts linker. It's way better than having to annotate individual test cases. - - - - - 791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix permission bits in copy_files When the testsuite driver copy files instead of symlinking them, it should also copy the permission bits, otherwise there'll be permission denied errors. Also, enforce file copying when testing wasm32, since wasmtime doesn't handle host symlinks quite well (https://github.com/bytecodealliance/wasmtime/issues/6227). - - - - - aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_ghc_with_threaded_rts predicate This patch adds the req_ghc_with_threaded_rts predicate to the testsuite to assert the platform has threaded RTS, and mark some tests as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a config field instead of a global variable. - - - - - ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. - - - - - cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_host_target_ghc predicate This patch adds the req_host_target_ghc predicate to the testsuite to assert the ghc compiler being tested can compile both host/target code. When testing cross GHCs this is not supported yet, but it may change in the future. - - - - - b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add missing annotations for some tests This patch adds missing annotations (req_th, req_dynamic_lib_support, req_rts_linker) to some tests. They were discovered when testing wasm32, though it's better to be explicit about what features they require, rather than simply adding when(arch('wasm32'), skip). - - - - - bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: wasm32-specific fixes This patch includes all wasm32-specific testsuite fixes. - - - - - 4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00 JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304) - - - - - 57277662 by sheaf at 2023-04-29T20:23:06+02:00 Add the Unsatisfiable class This commit implements GHC proposal #433, adding the Unsatisfiable class to the GHC.TypeError module. This provides an alternative to TypeError for which error reporting is more predictable: we report it when we are reporting unsolved Wanted constraints. Fixes #14983 #16249 #16906 #18310 #20835 - - - - - 00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00 Add structured error messages for GHC.Rename.Names Tracking ticket: #20115 MR: !10336 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00 Add sized primitive literal syntax Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining unboxed numeric literals such as `0xFF#Word8 :: Word8#`. Implements GHC proposal 0451: https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst Fixes #21422. Bumps haddock submodule. Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00 Document instances of Double - - - - - 1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00 Bump Cabal submodule (#22356) - - - - - 4eafb52a by sheaf at 2023-05-03T20:18:16-04:00 Don't forget to check the parent in an export list Commit 3f374399 introduced a bug which caused us to forget to include the parent of an export item of the form T(..) (that is, IEThingAll) when checking for duplicate exports. Fixes #23318 - - - - - 8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00 Fix unlit path in cross bindists - - - - - 8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00 hadrian: Flavour: Change args -> extraArgs Previously in a flavour definition you could override all the flags which were passed to GHC. This causes issues when needed to compute a package hash because we need to know what these extra arguments are going to be before computing the hash. The solution is to modify flavour so that the arguments you pass here are just extra ones rather than all the arguments that you need to compile something. This makes things work more like how cabal.project files work when you give extra arguments to a package and also means that flavour transformers correctly affect the hash. - - - - - 3fdb18f8 by romes at 2023-05-04T14:58:14-04:00 Hardwire a better unit-id for ghc Previously, the unit-id of ghc-the-library was fixed as `ghc`. This was done primarily because the compiler must know the unit-id of some packages (including ghc) a-priori to define wired-in names. However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed to `ghc` might result in subtle bugs when different ghc's interact. A good example of this is having GHC_A load a plugin compiled by GHC_B, where GHC_A and GHC_B are linked to ghc-libraries that are ABI incompatible. Without a distinction between the unit-id of the ghc library GHC_A is linked against and the ghc library the plugin it is loading was compiled against, we can't check compatibility. This patch gives a slightly better unit-id to ghc (ghc-version) by (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0) (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id. (2.1) `GHC.Settings.Config` is generated by Hadrian (2.2) and also by cabal through `compiler/Setup.hs` This unit-id definition is imported by `GHC.Unit.Types` and used to set the wired-in unit-id of "ghc", which was previously fixed to "ghc" The commits following this one will improve the unit-id with a cabal-style package hash and check compatibility when loading plugins. Note that we also ensure that ghc's unit key matches unit id both when hadrian or cabal builds ghc, and in this way we no longer need to add `ghc` to the WiringMap. - - - - - 6689c9c6 by romes at 2023-05-04T14:58:14-04:00 Validate compatibility of ghcs when loading plugins Ensure, when loading plugins, that the ghc the plugin depends on is the ghc loading the plugin -- otherwise fail to load the plugin. Progress towards #20742. - - - - - db4be339 by romes at 2023-05-04T14:58:14-04:00 Add hashes to unit-ids created by hadrian This commit adds support for computing an inputs hash for packages compiled by hadrian. The result is that ABI incompatible packages should be given different hashes and therefore be distinct in a cabal store. Hashing is enabled by the `--flag`, and is off by default as the hash contains a hash of the source files. We enable it when we produce release builds so that the artifacts we distribute have the right unit ids. - - - - - 944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00 Use hash-unit-ids in release jobs Includes fix upload_ghc_libs glob - - - - - 116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00 JS: fix bounds checking (Issue 23123) * For ByteArray-based bounds-checking, the JavaScript backend must use the `len` field, instead of the inbuild JavaScript `length` field. * Range-based operations must also check both the start and end of the range for bounds * All indicies are valid for ranges of size zero, since they are essentially no-ops * For cases of ByteArray accesses (e.g. read as Int), the end index is (i * sizeof(type) + sizeof(type) - 1), while the previous implementation uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3) * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike the previous point), but now check both start and end indicies * Byte array copies now check if the arrays are the same by identity and then if the ranges overlap. - - - - - 2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00 Fix remaining issues with bound checking (#23123) While fixing these I've also changed the way we store addresses into ByteArray#. Addr# are composed of two parts: a JavaScript array and an offset (32-bit number). Suppose we want to store an Addr# in a ByteArray# foo at offset i. Before this patch, we were storing both fields as a tuple in the "arr" array field: foo.arr[i] = [addr_arr, addr_offset]; Now we only store the array part in the "arr" field and the offset directly in the array: foo.dv.setInt32(i, addr_offset): foo.arr[i] = addr_arr; It avoids wasting space for the tuple. - - - - - 98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00 JavaScript: Correct arguments to h$appendToHsStringA fixes #23278 - - - - - ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00 base/encoding: add an allocations performance test (#22946) - - - - - e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00 linear types: Don't add external names to the usage env This has no observable effect, but avoids storing useless data. - - - - - b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00 Improved documentation for the Data.OldList.nub function There was recomentation to use map head . group . sort instead of nub function, but containers library has more suitable and efficient analogue - - - - - e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00 Fix type variable substitution in gen_Newtype_fam_insts Previously, `gen_Newtype_fam_insts` was substituting the type variable binders of a type family instance using `substTyVars`, which failed to take type variable dependencies into account. There is similar code in `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly, so this patch: 1. Factors out this code into a top-level `substATBndrs` function, and 2. Uses `substATBndrs` in `gen_Newtype_fam_insts`. Fixes #23329. - - - - - 275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00 Add structured error messages for GHC.Rename.Utils Tracking ticket: #20115 MR: !10350 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00 Use TemplateHaskellQuotes in TH.Syntax to construct Names - - - - - a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00 driver: Use hooks from plugin_hsc_env This fixes a bug in oneshot mode where hooks modified in a plugin wouldn't be used in oneshot mode because we neglected to use the right hsc_env. This was observed by @csabahruska. - - - - - 18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00 Rework plugin initialisation points In general this patch pushes plugin initialisation points to earlier in the pipeline. As plugins can modify the `HscEnv`, it's imperative that the plugins are initialised as soon as possible and used thereafter. For example, there are some new tests which modify hsc_logger and other hooks which failed to fire before (and now do) One consequence of this change is that the error for specifying the usage of a HPT plugin from the command line has changed, because it's now attempted to be loaded at initialisation rather than causing a cyclic module import. Closes #21279 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00 docs: Add Note [Timing of plugin initialization] - - - - - e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00 Incrementally update ghcup metadata in ghc/ghcup-metadata This job paves the way for distributing nightly builds * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the metadata on the "updates" branch. * Each night this metadata is downloaded and the nightly builds are appended to the end of the metadata. * The update job only runs on the scheduled nightly pipeline, not just when NIGHTLY=1. Things which are not done yet * Modify the retention policy for nightly jobs * Think about building release flavour compilers to distribute nightly. Fixes #23334 - - - - - 8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00 docs: Remove mentions of ArrayArray# from unlifted FFI section Fixes #23277 - - - - - 994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00 Add structured error messages for GHC.Rename.Module Tracking ticket: #20115 MR: !10361 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. Only addresses the single warning missing from the previous MR. - - - - - 3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00 rts: Fix data-race in hs_init_ghc As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic increment/decrement on the RTS's initialization count. This may go wrong in a multithreaded program which initializes the runtime multiple times. Closes #22756. - - - - - 78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00 Add structured error messages for GHC.IfaceToCore Tracking ticket: #20114 MR: !10390 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00 Fix up rules for ghcup-metadata-nightly-push - - - - - b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00 testsuite: Add test for atomicSwapIORef - - - - - 81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00 compiler: Implement atomicSwapIORef with xchg As requested by @treeowl in CLC#139. - - - - - 6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00 Make atomicSwapMutVar# an inline primop - - - - - 64064cfe by doyougnu at 2023-05-09T18:40:01-04:00 JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt This MR changes some simple optimizations and is a first step in re-architecting the JS backend pipeline to add the optimizer. In particular it: - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module - adds module `GHC.JS.Optimizer` - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations - hooks the optimizer into code gen - adds FuncStat and ForStat constructors to the backend. Working Ticket: - #22736 Related MRs: - MR !10142 - MR !10000 ------------------------- Metric Decrease: CoOpt_Read ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T12707 T13253 T13253-spj T15164 T17516 T18140 T18282 T18698a T18698b T18923 T1969 T19695 T20049 T3064 T5321FD T5321Fun T783 T9198 T9233 T9630 ------------------------- - - - - - 6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00 Add a regression test for #21050 - - - - - b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00 nonmoving: Account for mutator allocations in bytes_allocated Previously we failed to account direct mutator allocations into the nonmoving heap against the mutator's allocation limit and `cap->total_allocated`. This only manifests during CAF evaluation (since we allocate the CAF's blackhole directly into the nonmoving heap). Fixes #23312. - - - - - 0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00 Adjust AArch64 stackFrameHeaderSize The prologue of each stack frame are the saved LR and FP registers, 8 byte each. I.e. the size of the stack frame header is 2 * 8 byte. - - - - - 7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00 Make `(&)` representation polymorphic in the return type - - - - - b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00 ghc-prim: Generalize keepAlive#/touch# in state token type Closes #23163. - - - - - 1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00 Bump hsc2hs submodule Fixes #22981. - - - - - 0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00 base: Export GHC.Conc.Sync.fromThreadId Closes #22706. - - - - - 29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00 Build vanilla alpine bindists We currently attempt to build and distribute fully static alpine bindists (ones which could be used on any linux platform) but most people who use the alpine bindists want to use alpine to build their own static applications (for which a fully static bindist is not necessary). We should build and distribute these bindists for these users whilst the fully-static bindist is still unusable. Fixes #23349 - - - - - 40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00 Look both ways when looking for quantified equalities When looking up (t1 ~# t2) in the quantified constraints, check both orientations. Forgetting this led to #23333. - - - - - c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00 Move "target has RTS linker" out of settings We move the "target has RTS linker" information out of configure into a predicate in GHC, and remove this option from the settings file where it is unnecessary -- it's information statically known from the platform. Note that previously we would consider `powerpc`s and `s390x`s other than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker, but the RTS linker supports neither platform. Closes #23361 - - - - - bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00 Add a test for #17284 Since !10123 we now reject this program. - - - - - 630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00 Document unlawfulness of instance Num Fixed Fixes #22712 - - - - - 87eebf98 by sheaf at 2023-05-11T11:55:22-04:00 Add fused multiply-add instructions This patch adds eight new primops that fuse a multiplication and an addition or subtraction: - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#` fmadd x y z is x * y + z, computed with a single rounding step. This patch implements code generation for these primops in the following backends: - X86, AArch64 and PowerPC NCG, - LLVM - C WASM uses the C implementation. The primops are unsupported in the JavaScript backend. The following constant folding rules are also provided: - compute a * b + c when a, b, c are all literals, - x * y + 0 ==> x * y, - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x. NB: the constant folding rules incorrectly handle signed zero. This is a known limitation with GHC's floating-point constant folding rules (#21227), which we hope to resolve in the future. - - - - - ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00 Add a test for #21278 - - - - - 05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00 rts: Refine memory retention behaviour to account for pinned/compacted objects When using the copying collector there is still a lot of data which isn't copied (such as pinned, compacted, large objects etc). The logic to decide how much memory to retain didn't take into account that these wouldn't be copied. Therefore we pessimistically retained 2* the amount of memory for these blocks even though they wouldn't be copied by the collector. The solution is to split up the heap into two parts, the parts which will be copied and the parts which won't be copied. Then the appropiate factor is applied to each part individually (2 * for copying and 1.2 * for not copying). The T23221 test demonstrates this improvement with a program which first allocates many unpinned ByteArray# followed by many pinned ByteArray# and observes the difference in the ultimate memory baseline between the two. There are some charts on #23221. Fixes #23221 - - - - - 1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00 hadrian: fix no_dynamic_libs flavour transformer This patch fixes the no_dynamic_libs flavour transformer and make fully_static reuse it. Previously building with no_dynamic_libs fails since ghc program is still dynamic and transitively brings in dyn ways of rts which are produced by no rules. - - - - - 0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00 JS: refactor jsSaturate to return a saturated JStat (#23328) - - - - - a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00 Doc: Fix out-of-sync using-optimisation page - Make explicit that default flag values correspond to their -O0 value. - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction, -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper. - - - - - c176ad18 by sheaf at 2023-05-12T06:10:57-04:00 Don't panic in mkNewTyConRhs This function could come across invalid newtype constructors, as we only perform validity checking of newtypes once we are outside the knot-tied typechecking loop. This patch changes this function to fake up a stub type in the case of an invalid newtype, instead of panicking. This patch also changes "checkNewDataCon" so that it reports as many errors as possible at once. Fixes #23308 - - - - - ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00 Allow Core optimizations when interpreting bytecode Tracking ticket: #23056 MR: !10399 This adds the flag `-funoptimized-core-for-interpreter`, permitting use of the `-O` flag to enable optimizations when compiling with the interpreter backend, like in ghci. - - - - - c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00 hadrian: Fix mention of non-existent removeFiles function Previously Hadrian's bindist Makefile referred to a `removeFiles` function that was previously defined by the `make` build system. Since the `make` build system is no longer around, this function is now undefined. Naturally, make being make, this appears to be silently ignored instead of producing an error. Fix this by rewriting it to `rm -f`. Closes #23373. - - - - - eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00 Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog - - - - - aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Ensure non-moving gc is not running when pausing - - - - - 5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Teach listAllBlocks about nonmoving heap List all blocks on the non-moving heap. Resolves #22627 - - - - - d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00 Fix coercion optimisation for SelCo (#23362) setNominalRole_maybe is supposed to output a nominal coercion. In the SelCo case, it was not updating the stored role to Nominal, causing #23362. - - - - - 59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00 hadrian: Fix linker script flag for MergeObjects builder This fixes what appears to have been a typo in !9530. The `-t` flag just enables tracing on all versions of `ld` I’ve looked at, while `-T` is used to specify a linker script. It seems that this worked anyway for some reason on some `ld` implementations (perhaps because they automatically detect linker scripts), but the missing `-T` argument causes `gold` to complain. - - - - - 4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00 Less coercion optimization for non-newtype axioms See Note [Push transitivity inside newtype axioms only] for an explanation of the change here. This change substantially improves the performance of coercion optimization for programs involving transitive type family reductions. ------------------------- Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12545 T13386 T15703 T5030 T8095 ------------------------- - - - - - dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00 Move checkAxInstCo to GHC.Core.Lint A consequence of the previous change is that checkAxInstCo is no longer called during coercion optimization, so it can be moved back where it belongs. Also includes some edits to Note [Conflict checking with AxiomInstCo] as suggested by @simonpj. - - - - - 8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00 Use the eager unifier in the constraint solver This patch continues the refactoring of the constraint solver described in #23070. The Big Deal in this patch is to call the regular, eager unifier from the constraint solver, when we want to create new equalities. This replaces the existing, unifyWanted which amounted to yet-another-unifier, so it reduces duplication of a rather subtle piece of technology. See * Note [The eager unifier] in GHC.Tc.Utils.Unify * GHC.Tc.Solver.Monad.wrapUnifierTcS I did lots of other refactoring along the way * I simplified the treatment of right hand sides that contain CoercionHoles. Now, a constraint that contains a hetero-kind CoercionHole is non-canonical, and cannot be used for rewriting or unification alike. This required me to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in GHC.Tc.Solver.Equality. * I refactored the StopOrContinue type to add StartAgain, so that after a fundep improvement (for example) we can simply start the pipeline again. * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions. With Richard I concluded that they are never needed. * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities. Quite a few error messages change, I think always for the better. Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836 Metric Decrease: T17836 T18223 - - - - - 5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00 Cleanup of dynflags override in export renaming The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean. - - - - - d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00 Use a uniform return convention in bytecode for unary results fixes #22958 - - - - - 8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00 Add more instances for Compose: Enum, Bounded, Num, Real, Integral See https://github.com/haskell/core-libraries-committee/issues/160 for discussion - - - - - 902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00 Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the table, failing to unpack arguments that are perfectly unpackable. The fix is pretty easy; see Note [Recursive unboxing] - - - - - a5451438 by sheaf at 2023-05-13T14:59:13-04:00 Fix bad multiplicity role in tyConAppFunCo_maybe The function tyConAppFunCo_maybe produces a multiplicity coercion for the multiplicity argument of the function arrow, except that it could be at the wrong role if asked to produce a representational coercion. We fix this by using the 'funRole' function, which computes the right roles for arguments to the function arrow TyCon. Fixes #23386 - - - - - 5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00 Turn "ambiguous import" error into a panic This error should never occur, as a lookup of a type or data constructor should never be ambiguous. This is because a single module cannot export multiple Names with the same OccName, as per item (1) of Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export. This code path was intended to handle duplicate record fields, but the rest of the code had since been refactored to handle those in a different way. We also remove the AmbiguousImport constructor of IELookupError, as it is no longer used. Fixes #23302 - - - - - e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00 Unbreak some tests with latest GNU grep, which now warns about stray '\'. Confusingly, the testsuite mangled the error to say "stray /". We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex. Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default). - - - - - 5ae81842 by sheaf at 2023-05-15T14:49:17-04:00 Improve "ambiguous occurrence" error messages This error was sometimes a bit confusing, especially when data families were involved. This commit improves the general presentation of the "ambiguous occurrence" error, and adds a bit of extra context in the case of data families. Fixes #23301 - - - - - 2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00 Fix GHCJS OS platform (fix #23346) - - - - - 86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00 Split DynFlags structure into own module This will allow to make command line parsing to depend on diagnostic system (which depends on dynflags) - - - - - fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00 Replace the implementation of CodeBuffers with unboxed types - - - - - 21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00 Use unboxed codebuffers in base Metric Decrease: encodingAllocations - - - - - 18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Weak pointer cleanups Various stylistic cleanups. No functional changes. - - - - - c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't force debug output to stderr Previously `+RTS -Dw -l` would emit debug output to the eventlog while `+RTS -l -Dw` would emit it to stderr. This was because the parser for `-D` would unconditionally override the debug output target. Now we instead only do so if no it is currently `TRACE_NONE`. - - - - - a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Forcibly flush eventlog on barf Previously we would attempt to flush via `endEventLogging` which can easily deadlock, e.g., if `barf` fails during GC. Using `flushEventLog` directly may result in slightly less consistent eventlog output (since we don't take all capabilities before flushing) but avoids deadlocking. - - - - - 73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Assert that pointers aren't cleared by -DZ This turns many segmentation faults into much easier-to-debug assertion failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns produced by `+RTS -DZ` clearing as invalid pointers. This is a bit ad-hoc but this is the debug runtime. - - - - - 37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Introduce printGlobalThreads - - - - - 451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't sanity-check StgTSO.global_link See Note [Avoid dangling global_link pointers]. Fixes #19146. - - - - - d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00 Split up tyThingToIfaceDecl from GHC.Iface.Make This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl from GHC.Iface.Make into GHC.Iface.Decl. This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl, transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad. - - - - - 4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00 Migrate errors to diagnostics in GHC.Tc.Module This commit migrates the errors in GHC.Tc.Module to use the new diagnostic infrastructure. It required a significant overhaul of the compatibility checks between an hs-boot or signature module and its implementation; we now use a Writer monad to accumulate errors; see the BootMismatch datatype in GHC.Tc.Errors.Types, with its panoply of subtypes. For the sake of readability, several local functions inside the 'checkBootTyCon' function were split off into top-level functions. We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file" datatype, as this mirrors the logic in several other places where we want to treat hs-boot and hsig files in a similar fashion. This commit also refactors the Backpack checks for type synonyms implementing abstract data, to correctly reject implementations that contain qualified or quantified types (this fixes #23342 and #23344). - - - - - d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00 configure: Drop unused AC_PROG_CPP In configure, we were calling `AC_PROG_CPP` but never making use of the $CPP variable it sets or reads. The issue is $CPP will show up in the --help output of configure, falsely advertising a configuration option that does nothing. The reason we don't use the $CPP variable is because HS_CPP_CMD is expected to be a single command (without flags), but AC_PROG_CPP, when CPP is unset, will set said variable to something like `/usr/bin/gcc -E`. Instead, we configure HS_CPP_CMD through $CC. - - - - - a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00 rts: fix --disable-large-address-space This patch moves ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from Storage.h to HeapAlloc.h. When --disable-large-address-space is passed to configure, the code in HeapAlloc.h makes use of these two macros. Fixes #23385. - - - - - bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00 Add -Wmissing-role-annotations Implements #22702 - - - - - 41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00 base: Export {get,set}ExceptionFinalizer from System.Mem.Weak As proposed in CLC Proposal #126 [1]. [1]: https://github.com/haskell/core-libraries-committee/issues/126 - - - - - 67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00 base: Introduce printToHandleFinalizerExceptionHandler - - - - - 5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00 JS: Implement h$clock_gettime in the JavaScript RTS (#23360) - - - - - 90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for SourceText SourceText is serialized along with INLINE pragmas into interface files. Many of these SourceTexts are identical, for example "{-# INLINE#". When deserialized, each such SourceText was previously expanded out into a [Char], which is highly wasteful of memory, and each such instance of the text would allocate an independent list with its contents as deserializing breaks any sharing that might have existed. Instead, we use a `FastString` to represent these, so that each instance unique text will be interned and stored in a memory efficient manner. - - - - - b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation/FastStrings for `SourceNote`s `SourceNote`s should not be stored as [Char] as this is highly wasteful and in certain scenarios can be highly duplicated. Metric Decrease: hard_hole_fits - - - - - 6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for UsageFile (#22744) Use FastString to store filepaths in interface files, as this data is highly redundant so we want to share all instances of filepaths in the compiler session. - - - - - 47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00 testsuite: add test for T22744 This test checks for #22744 by compiling 100 modules which each have a dependency on 1000 distinct external files. Previously, when loading these interfaces from disk, each individual instance of a filepath in the interface will would be allocated as an individual object on the heap, meaning we have heap objects for 100*1000 files, when there are only 1000 distinct files we care about. This test checks this by first compiling the module normally, then measuring the peak memory usage in a no-op recompile, as the recompilation checking will force the allocation of all these filepaths. - - - - - 0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00 users guide: Add glossary Currently this merely explains the meaning of "technology preview" in the context of released features. - - - - - 0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00 Update glossary.rst - - - - - 3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00 Use glossary directive - - - - - 2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00 JS: fix getpid (fix #23399) - - - - - 5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00 Use setSrcSpan rather than setLclEnv in solveForAll In subsequent MRs (#23409) we want to remove the TcLclEnv argument from a CtLoc. This MR prepares us for that by removing the one place where the entire TcLclEnv is used, by using it more precisely to just set the contexts source location. Fixes #23390 - - - - - 385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00 Update the users guide paragraph on -O in GHCi In relation to #23056 - - - - - 87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Add test for #13660 - - - - - 9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Move implementation of GHC.Foreign to GHC.Internal - - - - - 174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Introduce {new,with}CStringLen0 These are useful helpers for implementing the internal-NUL code unit check needed to fix #13660. - - - - - a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Clean up documentation - - - - - b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Ensure that FilePaths don't contain NULs POSIX filepaths may not contain the NUL octet but previously we did not reject such paths. This could be exploited by untrusted input to cause discrepancies between various `FilePath` queries and the opened filename. For instance, `readFile "hello.so\x00.txt"` would open the file `"hello.so"` yet `takeFileExtension` would return `".txt"`. The same argument applies to Windows FilePaths Fixes #13660. - - - - - 7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00 Allow the demand analyser to unpack tuple and equality dictionaries Addresses #23398. The demand analyser usually does not unpack class dictionaries: see Note [Do not unbox class dictionaries] in GHC.Core.Opt.DmdAnal. This patch makes an exception for tuple dictionaries and equality dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of the above Note. Compile times fall by 0.1% for some reason (max 0.7% on T18698b). - - - - - b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00 Use a simpler and more portable construct in ld.ldd check printf '%q\n' is a bash extension which led to incorrectly failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh - - - - - dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00 Update the warning about interpreter optimizations to reflect that they're not incompatible anymore, but guarded by a flag - - - - - 4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00 Remove stray dump flags in GHC.Rename.Names - - - - - 4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00 Make Warn = Located DriverMessage This change makes command line argument parsing use diagnostic framework for producing warnings. - - - - - 525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00 Type inference for data family newtype instances This patch addresses #23408, a tricky case with data family newtype instances. Consider type family TF a where TF Char = Bool data family DF a newtype instance DF Bool = MkDF Int and [W] Int ~R# DF (TF a), with a Given (a ~# Char). We must fully rewrite the Wanted so the tpye family can fire; that wasn't happening. - - - - - c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00 testsuite: fix predicate on rdynamic test Test rdynamic requires dynamic linking support, which is orthogonal to RTS linker support. Change the predicate accordingly. Fixes #23316 - - - - - 735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00 docs: Use ghc-ticket directive where appropiate in users guide Using the directive automatically formats and links the ticket appropiately. - - - - - b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00 NCG: remove useless .align directive (#20758) - - - - - 15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00 Add test for #23156 This program had exponential typechecking time in GHC 9.4 and 9.6 - - - - - 2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00 Revert "Change hostSupportsRPaths to report False on OpenBSD" This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2. - - - - - 882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00 Disable T17414 on OpenBSD Like on other systems it's not guaranteed that there's sufficient space in /tmp to write 2G out. - - - - - 9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00 Bring back getExecutablePath to getBaseDir on OpenBSD Fix #18173 - - - - - 9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00 Add an error origin for impedance matching (#23427) - - - - - 33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00 testsuite: Add tests for #23146 Both lifted and unlifted variants. - - - - - 76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Fix some Haddocks - - - - - 33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Give proper LFInfo to datacon wrappers As noted in `Note [Conveying CAF-info and LFInfo between modules]`, when importing a binding from another module we must ensure that it gets the appropriate `LambdaFormInfo` if it is in WHNF to ensure that references to it are tagged correctly. However, the implementation responsible for doing this, `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and not wrappers. This lead to the crash of this program in #23146: module B where type NP :: [UnliftedType] -> UnliftedType data NP xs where UNil :: NP '[] module A where import B fieldsSam :: NP xs -> NP xs -> Bool fieldsSam UNil UNil = True x = fieldsSam UNil UNil Due to its GADT nature, `UNil` produces a trivial wrapper $WUNil :: NP '[] $WUNil = UNil @'[] @~(<co:1>) which is referenced in the RHS of `A.x`. Due to the above-mentioned bug in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were not tagged. This is problematic as `fieldsSam` expected its arguments to be tagged as they are unlifted. The fix is straightforward: extend the logic in `mkLFImported` to cover (nullary) datacon wrappers as well as workers. This is safe because we know that the wrapper of a nullary datacon will be in WHNF, even if it includes equalities evidence (since such equalities are not runtime relevant). Thanks to @MangoIV for the great ticket and @alt-romes for his minimization and help debugging. Fixes #23146. - - - - - 2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 codeGen: Fix LFInfo of imported datacon wrappers As noted in #23231 and in the previous commit, we were failing to give a an LFInfo of LFCon to a nullary datacon wrapper from another module, failing to properly tag pointers which ultimately led to the segmentation fault in #23146. On top of the previous commit which now considers wrappers where we previously only considered workers, we change the order of the guards so that we check for the arity of the binding before we check whether it is a constructor. This allows us to (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was nullary, which we previously would fail to do (2) Remove the `isNullaryRepDataCon` predicate: (a) which was previously wrong, since it considered wrappers whose workers had zero-width arguments to be non-nullary and would fail to give `LFCon` to them (b) is now unnecessary, since arity == 0 guarantees - that the worker takes no arguments at all - and the wrapper takes no arguments and its RHS must be an application of the worker to zero-width-args only. - we lint these two items with an assertion that the datacon `hasNoNonZeroWidthArgs` We also update `isTagged` to use the new logic in determining the LFInfos of imported Ids. The creation of LFInfos for imported Ids and this detail are explained in Note [The LFInfo of Imported Ids]. Note that before the patch to those issues we would already consider these nullary wrappers to have `LFCon` lambda form info; but failed to re-construct that information in `mkLFImported` Closes #23231, #23146 (I've additionally batched some fixes to documentation I found while investigating this issue) - - - - - 0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Make LFInfos for DataCons on construction As a result of the discussion in !10165, we decided to amend the previous commit which fixed the logic of `mkLFImported` with regard to datacon workers and wrappers. Instead of having the logic for the LFInfo of datacons be in `mkLFImported`, we now construct an LFInfo for all data constructors on GHC.Types.Id.Make and store it in the `lfInfo` field. See the new Note [LFInfo of DataCon workers and wrappers] and ammendments to Note [The LFInfo of Imported Ids] - - - - - 12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Update Note [Core letrec invariant] Authored by @simonpj - - - - - e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Rename mkLFImported to importedIdLFInfo The `mkLFImported` sounded too much like a constructor of sorts, when really it got the `LFInfo` of an imported Id from its `lf_info` field when this existed, and otherwise returned a conservative estimate of that imported Id's LFInfo. This in contrast to functions such as `mkLFReEntrant` which really are about constructing an `LFInfo`. - - - - - e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Enforce invariant on typePrimRepArgs in the types As part of the documentation effort in !10165 I came across this invariant on 'typePrimRepArgs' which is easily expressed at the type-level through a NonEmpty list. It allowed us to remove one panic. - - - - - b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Merge outdated Note [Data con representation] into Note [Data constructor representation] Introduce new Note [Constructor applications in STG] to better support the merge, and reference it from the relevant bits in the STG syntax. - - - - - e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Add the SolverStage monad This refactoring makes a substantial improvement in the structure of the type-checker's constraint solver: #23070. Specifically: * Introduced the SolverStage monad. See GHC.Tc.Solver.Monad Note [The SolverStage monad] * Make each solver pipeline (equalities, dictionaries, irreds etc) deal with updating the inert set, as a separate SolverStage. There is sometimes special stuff to do, and it means that each full pipeline can have type SolverStage Void, indicating that they never return anything. * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage. Much nicer. * Combined the remnants of GHC.Tc.Solver.Canonical and GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve. (Interact and Canonical are removed.) * Gave the same treatment to dictionary and irred constraints as I have already done for equality constraints: * New types (akin to EqCt): IrredCt and DictCt * Ct is now just a simple sum type data Ct = CDictCan DictCt | CIrredCan IrredCt | CEqCan EqCt | CQuantCan QCInst | CNonCanonical CtEvidence * inert_dicts can now have the better type DictMap DictCt, instead of DictMap Ct; and similarly inert_irreds. * Significantly simplified the treatment of implicit parameters. Previously we had a number of special cases * interactGivenIP, an entire function * special case in maybeKickOut * special case in findDict, when looking up dictionaries But actually it's simpler than that. When adding a new Given, implicit parameter constraint to the InertSet, we just need to kick out any existing inert constraints that mention that implicit parameter. The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with its auxiliary GHC.Core.Predicate.mentionsIP. See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict. * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit. See Note [Fast path for tcCheckHoleFit]. This is a big win in some cases: test hard_hole_fits gets nearly 40% faster (at compile time). * Add a new fast-path for solving /boxed/ equality constraints (t1 ~ t2). See Note [Solving equality classes] in GHC.Tc.Solver.Dict. This makes a big difference too: test T17836 compiles 40% faster. * Implement the PermissivePlan of #23413, which concerns what happens with insoluble Givens. Our previous treatment was wildly inconsistent as that ticket pointed out. A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply don't run the ambiguity check at all if -XAllowAmbiguousTypes is on. Smaller points: * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for insoluble /occurs/ checks, broaden in to all insouluble constraints. Just generally better. See Note [Insoluble mis-match] in that module. As noted above, compile time perf gets better. Here are the changes over 0.5% on Fedora. (The figures are slightly larger on Windows for some reason.) Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -0.9% MultiLayerModulesTH_OneShot(normal) +0.5% T11822(normal) -0.6% T12227(normal) -1.8% GOOD T12545(normal) -0.5% T13035(normal) -0.6% T15703(normal) -1.4% GOOD T16875(normal) -0.5% T17836(normal) -40.7% GOOD T17836b(normal) -12.3% GOOD T17977b(normal) -0.5% T5837(normal) -1.1% T8095(normal) -2.7% GOOD T9020(optasm) -1.1% hard_hole_fits(normal) -37.0% GOOD geo. mean -1.3% minimum -40.7% maximum +0.5% Metric Decrease: T12227 T15703 T17836 T17836b T8095 hard_hole_fits LargeRecord T9198 T13035 - - - - - 6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Avoid an assertion failure in abstractFloats The function GHC.Core.Opt.Simplify.Utils.abstractFloats was carelessly calling lookupIdSubst_maybe on a CoVar; but a precondition of the latter is being given an Id. In fact it's harmless to call it on a CoVar, but still, the precondition on lookupIdSubst_maybe makes sense, so I added a test for CoVars. This avoids a crash in a DEBUG compiler, but otherwise has no effect. Fixes #23426. - - - - - 838aaf4b by hainq at 2023-05-24T12:41:19-04:00 Migrate errors in GHC.Tc.Validity This patch migrates the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It adds the constructors: - TcRnSimplifiableConstraint - TcRnArityMismatch - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors and fundep coverage condition errors. - - - - - 8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00 linear lint: Add missing processing of DEFAULT In this correct program f :: a %1 -> a f x = case x of x { _DEFAULT -> x } after checking the alternative we weren't popping the case binder 'x' from the usage environment, which meant that the lambda-bound 'x' was counted twice: in the scrutinee and (incorrectly) in the alternative. In fact, we weren't checking the usage of 'x' at all. Now the code for handling _DEFAULT is similar to the one handling data constructors. Fixes #23025. - - - - - ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00 Remove outdated "Don't check hs-boot type family instances too early" note This note was introduced in 25b70a29f623 which delayed performing some consistency checks for type families. However, the change was reverted later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not removed. I found it confusing when reading to code to try and work out what special behaviour there was for hs-boot files (when in-fact there isn't any). - - - - - 44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: Define ticky macro stubs These macros have long been undefined which has meant we were missing reporting these allocations in ticky profiles. The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was missing all the RTS calls to allocate, this leads to a the overall ALLOC_RTS_tot number to be severaly underreported. Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot counters which are useful to tracking stack allocations. Fixes #23421 - - - - - b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes more sense to name it after that rather than the suffix NOCTR, whose meaning has been lost to the mists of time. - - - - - eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00 users guide: A few small mark-up fixes - - - - - a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00 configure: Fix support check for response files. In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument to printf, the writing of the arguments response file always failed. The fix is to pass the arguments after `--` so that they are treated positional arguments rather than flags to printf. Closes #23435 - - - - - f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00 [feat] add .direnv to the .gitignore file - - - - - 36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00 Add Data.List.unsnoc See https://github.com/haskell/core-libraries-committee/issues/165 for discussion - - - - - c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00 Fix crash in backpack signature merging with -ddump-rn-trace In some cases, backpack signature merging could crash in addUsedGRE when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause unavailable interfaces to be loaded. This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE when -ddump-rn-trace is enabled. Fixes #23424 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - 5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00 Add a regression test for #13981 The panic was fixed by 6998772043a7f0b. Fixes #13981. - - - - - 182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00 Add a test for #23355 It was fixed by !10061, so I'm adding it in the same group. - - - - - 1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00 Migrate errors in GHC.Rename.Splice GHC.Rename.Pat This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat to use the new diagnostic infrastructure. - - - - - 56abe494 by sheaf at 2023-05-25T12:09:55+02:00 Common up Template Haskell errors in TcRnMessage This commit commons up the various Template Haskell errors into a single constructor, TcRnTHError, of TcRnMessage. - - - - - a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00 Enable ghci tests for unboxed tuples The tests were originally skipped because ghci used not to support unboxed tuples/sums. - - - - - dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00 rts: Build ticky GHC with single-threaded RTS The threaded RTS allows you to use ticky profiling but only for the counters in the generated code. The counters used in the C portion of the RTS are disabled. Updating the counters is also racy using the threaded RTS which can lead to misleading or incorrect ticky results. Therefore we change the hadrian flavour to build using the single-threaded RTS (mainly in order to get accurate C code counter increments) Fixes #23430 - - - - - fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00 Propagate long-distance info in generated code When desugaring generated pattern matches, we skip pattern match checks. However, this ended up also discarding long-distance information, which might be needed for user-written sub-expressions. Example: ```haskell okay (GADT di) cd = let sr_field :: () sr_field = case getFooBar di of { Foo -> () } in case cd of { SomeRec _ -> SomeRec sr_field } ``` With sr_field a generated FunBind, we still want to propagate the outer long-distance information from the GADT pattern match into the checks for the user-written RHS of sr_field. Fixes #23445 - - - - - f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00 Introduce GHCiMessage to wrap GhcMessage By introducing a wrapped message type we can control how certain messages are printed in GHCi (to add extra information for example) - - - - - 58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00 Generalise UnknownDiagnostic to allow embedded diagnostics to access parent diagnostic options. * Split default diagnostic options from Diagnostic class into HasDefaultDiagnosticOpts class. * Generalise UnknownDiagnostic to allow embedded diagnostics to access options. The principle idea here is that when wrapping an error message (such as GHCMessage to make GHCiMessage) then we need to also be able to lift the configuration when overriding how messages are printed (see load' for an example). - - - - - b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00 Allow API users to wrap error messages created during 'load' This allows API users to configure how messages are rendered when they are emitted from the load function. For an example see how 'loadWithCache' is used in GHCi. - - - - - 2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00 Abstract cantFindError and turn Opt_BuildingCabal into a print-time option * cantFindError is abstracted so that the parts which mention specific things about ghc/ghci are parameters. The intention being that GHC/GHCi can specify the right values to put here but otherwise display the same error message. * The BuildingCabalPackage argument from GenericMissing is removed and turned into a print-time option. The reason for the error is not dependent on whether `-fbuilding-cabal-package` is passed, so we don't want to store that in the error message. - - - - - 34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00 error messages: Don't display ghci specific hints for missing packages Tickets like #22884 suggest that it is confusing that GHC used on the command line can suggest options which only work in GHCi. This ticket uses the error message infrastructure to override certain error messages which displayed GHCi specific information so that this information is only showed when using GHCi. The main annoyance is that we mostly want to display errors in the same way as before, but with some additional information. This means that the error rendering code has to be exported from the Iface/Errors/Ppr.hs module. I am unsure about whether the approach taken here is the best or most maintainable solution. Fixes #22884 - - - - - 05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't override existing metadata if version already exists. If a nightly pipeline runs twice for some reason for the same version then we really don't want to override an existing entry with new bindists. This could cause ABI compatability issues for users or break ghcup's caching logic. - - - - - fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Use proper API url for bindist download Previously we were using links from the web interface, but it's more robust and future-proof to use the documented links to the artifacts. https://docs.gitlab.com/ee/api/job_artifacts.html - - - - - 5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Set Nightly and LatestNightly tags The latest nightly release needs the LatestNightly tag, and all other nightly releases need the Nightly tag. Therefore when the metadata is updated we need to replace all LatestNightly with Nightly.` - - - - - 914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download nightly metadata for correct date The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata with one metadata file per year. When we update the metadata we download and update the right file for the current year. - - - - - 16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download metadata and update for correct year something about pipeline date - - - - - 14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't skip CI On a push we now have a CI job which updates gitlab pages with the metadata files. - - - - - 1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add --date flag to specify the release date The ghcup-metadata now has a viReleaseDay field which needs to be populated with the day of the release. - - - - - bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add dlOutput field ghcup now requires us to add this field which specifies where it should download the bindist to. See https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more discussion. - - - - - 2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00 JS: Convert rendering to use HLine instead of SDoc (#22455) - - - - - abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00 testsuite: add WasmControlFlow test This patch adds the WasmControlFlow test to test the wasm backend's relooper component. - - - - - 07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00 Factorize getLinkDeps Prepare reuse of getLinkDeps for TH implementation in the JS backend (cf #22261 and review of !9779). - - - - - fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00 Change GHC.Driver.Session import to .DynFlags Also move targetPlatform selector Plenty of GHC needs just DynFlags. Even more can be made to use .DynFlags if more selectors is migrated. This is a low hanging fruit. - - - - - 69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00 EPA: Better fix for #22919 The original fix for #22919 simply removed the ability to match up prior comments with the first declaration in the file. Restore it, but add a check that the comment is on a single line, by ensuring that it comes immediately prior to the next thing (comment or start of declaration), and that the token preceding it is not on the same line. closes #22919 - - - - - 0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00 Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214) - - - - - b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00 testsuite: Pass -kb16k -kc128k for performance tests Setting a larger stack chunk size gives a greater protection from stack thrashing (where the repeated overflow/underflow allocates a lot of stack chunks which sigificantly impact allocations). This stabilises some tests against differences cause by more things being pushed onto the stack. The performance tests are generally testing work done by the compiler, using allocation as a proxy, so removing/stabilising the allocations due to the stack gives us more stable tests which are also more sensitive to actual changes in compiler performance. The tests which increase are ones where we compile a lot of modules, and for each module we spawn a thread to compile the module in. Therefore increasing these numbers has a multiplying effect on these tests because there are many more stacks which we can increase in size. The most significant improvements though are cases such as T8095 which reduce significantly in allocations (30%). This isn't a performance improvement really but just helps stabilise the test against this threshold set by the defaults. Fixes #23439 ------------------------- Metric Decrease: InstanceMatching T14683 T8095 T9872b_defer T9872d T9961 hie002 T19695 T3064 Metric Increase: MultiLayerModules T13701 T14697 ------------------------- - - - - - 6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00 Move via-C flags into GHC These were previously hardcoded in configure (with no option for overriding them) and simply passed onto ghc through the settings file. Since configure already guarantees gcc supports those flags, we simply move them into GHC. - - - - - 981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Allow CPR on unrestricted constructors Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will allow CPR to handle `Ur`, in particular. - - - - - bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Push coercions across multiplicity boundaries Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will avoid preventing inlinings and reductions and make linear programs more efficient. - - - - - d56dd695 by sheaf at 2023-05-31T11:37:12-04:00 Data.Bag: add INLINEABLE to polymorphic functions This commit allows polymorphic methods in GHC.Data.Bag to be specialised, avoiding having to pass explicit dictionaries when they are instantiated with e.g. a known monad. - - - - - 5366cd35 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcBinderStack into its own module This commit splits off TcBinderStack into its own module, to avoid module cycles: we might want to refer to it without also pulling in the TcM monad. - - - - - 09d4d307 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcRef into its own module This helps avoid pull in the full TcM monad when we just want access to mutable references in the typechecker. This facilitates later patches which introduce a slimmed down TcM monad for zonking. - - - - - 88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00 Introduce Codensity monad The Codensity monad is useful to write state-passing computations in continuation-passing style, e.g. to implement a State monad as continuation-passing style over a Reader monad. - - - - - f62d8195 by sheaf at 2023-05-31T11:37:12-04:00 Restructure the zonker This commit splits up the zonker into a few separate components, described in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`. 1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`, which has enough information for zonking types. This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`, which guarantees we don't throw an error while reporting an error. 2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines two zonking monad transformers, `ZonkT` and `ZonkBndrT`. `ZonkT` is a reader monad transformer over `ZonkEnv`. `ZonkBndrT m` is the codensity monad over `ZonkT m`. `ZonkBndrT` is used for computations that accumulate binders in the `ZonkEnv`. 3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use in the typechecker. It uses the `ZonkM` monad. 4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`, which has been refactored to use `ZonkTcM = ZonkT TcM` and `ZonkBndrTcM = ZonkBndrT TcM`. Allocations slightly decrease on the whole due to using continuation-passing style instead of manual state passing of ZonkEnv in the final zonking to Type. ------------------------- Metric Decrease: T4029 T8095 T14766 T15304 hard_hole_fits RecordUpdPerf Metric Increase: T10421 ------------------------- - - - - - 70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00 Update rdt-theme to latest upstream version Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444 - - - - - f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Restructure IPE buffer layout Reference ticket #21766 This commit restructures IPE buffer list entries to not contain references to their corresponding info tables. IPE buffer list nodes now point to two lists of equal length, one holding the list of info table pointers and one holding the corresponding entries for each info table. This will allow the entry data to be compressed without losing the references to the info tables. - - - - - 5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE compression to configure Reference ticket #21766 Adds an `--enable-ipe-data-compreesion` flag to the configure script which will check for libzstd and set the appropriate flags to allow for IPE data compression in the compiler - - - - - b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00 IPE data compression Reference ticket #21766 When IPE data compression is enabled, compress the emitted IPE buffer entries and decompress them in the RTS. - - - - - 5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix libzstd detection in configure and RTS Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases and properly check that before IPE data decompression in the RTS. See ticket #21766. - - - - - 69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add note describing IPE data compression See ticket #21766 - - - - - 7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix byte order of IPE data, fix IPE tests Make sure byte order of written IPE buffer entries matches target. Make sure the IPE-related tests properly access the fields of IPE buffer entry nodes with the new IPE layout. This commit also introduces checks to avoid importing modules if IPE compression is not enabled. See ticket #21766. - - - - - 0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix IPE data decompression buffer allocation Capacity of buffers allocated for decompressed IPE data was incorrect due to a misuse of the `ZSTD_findFrameCompressedSize` function. Fix by always storing decompressed size of IPE data in IPE buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine the size of the compressed data. See ticket #21766 - - - - - a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add optional dependencies to ./configure output Changes the configure script to indicate whether libnuma, libzstd, or libdw are being used as dependencies due to their optional features being enabled. - - - - - 09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE-enabled builds to CI - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label - Introduces CI logic to enable IPE data compression - Enables uncompressed IPE data on debug CI job - Regenerates jobs.yaml MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the images repository is meant to ensure that the proper images have libzstd-dev installed. - - - - - 3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Update user's guide and release notes, small fixes Add mention of IPE data compression to user's guide and the release notes for 9.8.1. Also note the impact compression has on binary size in both places. Change IpeBufferListNode compression check so only the value `1` indicates compression. See ticket #21766 - - - - - 41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Remove IPE enabled builds from CI We don't need to explicitly specify the +ipe transformer to test IPE data since there are tests which manually enable IPE information. This commit does leave zstd IPE data compression enabled on the debian CI jobs. - - - - - 982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00 Fix build with 9.2 GHC.Tc.Zonk.Type uses an equality constraint. ghc.nix currently provides 9.2. - - - - - 1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00 Output Lint errors to stderr instead of stdout This is a continuation of 7b095b99, which fixed warnings but not errors. Refs #13342 - - - - - 8e81f140 by sheaf at 2023-06-01T10:56:51-04:00 Refactor lookupExactOrOrig & friends This refactors the panoply of renamer lookup functions relating to lookupExactOrOrig to more graciously handle Exact and Orig names. In particular, we avoid the situation in which we would add Exact/Orig GREs to the tcg_used_gres field, which could cause a panic in bestImport like in #23240. Fixes #23428 - - - - - 5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00 Use the one-shot trick for UM and RewriteM functors As described in Note [The one-shot state monad trick], we shouldn't use derived Functor instances for monads using one-shot. This was done for most of them, but UM and RewriteM were missed. - - - - - 2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00 Fix testsuite skipping Lint setTestOpts() is used to modify the test options for an entire .T file, rather than a single test. If there was a test using collect_compiler_stats, all of the tests in the same file had lint disabled. Fixes #21247 - - - - - 00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00 Add testcases for already fixed #16432 They were fixed by 40c7daed0. Fixes #16432 - - - - - f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00 cleanup: Remove unused field from SelfBoot It is no longer needed since Note [Extra dependencies from .hs-boot files] was deleted in 6998772043. I've also added tildes to Note headers, otherwise they're not detected by the linter. - - - - - 82eacab6 by sheaf at 2023-06-02T09:08:01-04:00 Delete GHC.Tc.Utils.Zonk This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType in commit f62d8195, but I forgot to delete the original module - - - - - 4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00 base: Add build-order import of GHC.Types in GHC.IO.Handle.Types For reasons similar to those described in Note [Depend on GHC.Num.Integer]. Fixes #23411. - - - - - f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00 JS: fix and enhance non-minimized code generation (#22455) Flag -ddisable-js-minimizer was producing invalid code. Fix that and also a few other things to generate nicer JS code for debugging. The added test checks that we don't regress when using the flag. - - - - - f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00 [hadrian] Fix multiline synopsis rendering - - - - - b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00 Elaborate on performance properties of Data.List.++ - - - - - 7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00 Big TcLclEnv and CtLoc refactoring The overall goal of this refactoring is to reduce the dependency footprint of the parser and syntax tree. Good reasons include: - Better module graph parallelisability - Make it easier to migrate error messages without introducing module loops - Philosophically, there's not reason for the AST to depend on half the compiler. One of the key edges which added this dependency was > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv) As this in turn depending on TcM which depends on HscEnv and so on. Therefore the goal of this patch is to move `TcLclEnv` out of `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without incurring a huge dependency chain. The changes in this patch are: * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv * Create new smaller modules for the types used in TcLclEnv New Modules: - GHC.Tc.Types.ErrCtxt - GHC.Tc.Types.BasicTypes - GHC.Tc.Types.TH - GHC.Tc.Types.LclEnv - GHC.Tc.Types.CtLocEnv - GHC.Tc.Errors.Types.PromotionErr Removed Boot File: - {-# SOURCE #-} GHC.Tc.Types * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't participate in restoreLclEnv. * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the location of the implication and constraint. By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no longer depend on the TcM monad and all that entails. Fixes #23389 #23409 - - - - - 3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session This removes the usage of DynFlags from Tc.Utils.TcType so that it no longer depends on GHC.Driver.Session. In general we don't want anything which is a dependency of Language.Haskell.Syntax to depend on GHC.Driver.Session and removing this edge gets us closer to that goal. - - - - - 18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00 Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes Language.Haskell.Syntax end up depending on GHC.Driver.Session. - - - - - 12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session - - - - - eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00 hole fit plugins: Split definition into own module The hole fit plugins are defined in terms of TcM, a type we want to avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own module we can remove this dependency. It also simplifies the necessary boot file. - - - - - 9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Move GHC.Core.Opt.CallerCC Types into separate module This allows `GHC.Driver.DynFlags` to depend on these types without depending on CoreM and hence the entire simplifier pipeline. We can also remove a hs-boot file with this change. - - - - - 52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Remove unecessary SOURCE import - - - - - 698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00 testsuite: Accept new output for CountDepsAst and CountDepsParser tests These are in a separate commit as the improvement to these tests is the cumulative effect of the previous set of patches rather than just the responsibility of the last one in the patchset. - - - - - 58ccf02e by sheaf at 2023-06-05T16:00:47-04:00 TTG: only allow VarBind at GhcTc The VarBind constructor of HsBind is only used at the GhcTc stage. This commit makes that explicit by setting the extension field of VarBind to be DataConCantHappen at all other stages. This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind, and remove some panics. - - - - - 54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00 Generate Addr# access ops programmatically The existing utils/genprimopcode/gen_bytearray_ops.py was relocated and extended for this purpose. Additionally, hadrian now knows about this script and uses it when generating primops.txt - - - - - ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00 ghcup-metadata: Only add Nightly tag when replacing LatestNightly Previously we were always adding the Nightly tag, but this led to all the previous builds getting an increasing number of nightly tags over time. Now we just add it once, when we remove the LatestNightly tag. - - - - - 4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00 Invisible binders in type declarations (#22560) This patch implements @k-binders introduced in GHC Proposal #425 and guarded behind the TypeAbstractions extension: type D :: forall k j. k -> j -> Type data D @k @j a b = ... ^^ ^^ To represent the new syntax, we modify LHsQTyVars as follows: - hsq_explicit :: [LHsTyVarBndr () pass] + hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass] HsBndrVis is a new data type that records the distinction between type variable binders written with and without the @ sign: data HsBndrVis pass = HsBndrRequired | HsBndrInvisible (LHsToken "@" pass) The rest of the patch updates GHC, template-haskell, and haddock to handle the new syntax. Parser: The PsErrUnexpectedTypeAppInDecl error message is removed. The syntax it used to reject is now permitted. Renamer: The @ sign does not affect the scope of a binder, so the changes to the renamer are minimal. See rnLHsTyVarBndrVisFlag. Type checker: There are three code paths that were updated to deal with the newly introduced invisible type variable binders: 1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl 2. checking CUSK: see kcCheckDeclHeader_cusk 3. inference: see kcInferDeclHeader, rejectInvisibleBinders Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv are generalized to work with HsBndrVis. Updates the haddock submodule. Metric Increase: MultiLayerModulesTH_OneShot Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00 JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481) - - - - - e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00 Update CODEOWNERS - - - - - 960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Remove IPE enabled builds from CI" This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951. - - - - - bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Update user's guide and release notes, small fixes" This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7. - - - - - 12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE-enabled builds to CI" This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f. - - - - - dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add optional dependencies to ./configure output" This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58. - - - - - 240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix IPE data decompression buffer allocation" This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a. - - - - - 9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix byte order of IPE data, fix IPE tests" This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327. - - - - - 3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add note describing IPE data compression" This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0. - - - - - fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix libzstd detection in configure and RTS" This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0. - - - - - 1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "IPE data compression" This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553. - - - - - fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE compression to configure" This reverts commit 5d1f2411f4becea8650d12d168e989241edee186. - - - - - 2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Restructure IPE buffer layout" This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91. - - - - - 2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00 Don't report redundant Givens from quantified constraints This fixes #23323 See (RC4) in Note [Tracking redundant constraints] - - - - - 567b32e1 by David Binder at 2023-06-08T18:41:29-04:00 Update the outdated instructions in HACKING.md on how to compile GHC - - - - - 2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00 Restore mingwex dependency on Windows This partially reverts some of the changes in !9475 to make `base` and `ghc-prim` depend on the `mingwex` library on Windows. It also restores the RTS's stubs for `mingwex`-specific symbols such as `_lock_file`. This is done because the C runtime provides `libmingwex` nowadays, and moreoever, not linking against `mingwex` requires downstream users to link against it explicitly in difficult-to-predict circumstances. Better to always link against `mingwex` and prevent users from having to do the guesswork themselves. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for the discussion that led to this. - - - - - 28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00 RtsSymbols.c: Remove mingwex symbol stubs As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows, which means that the RTS no longer needs to declare stubs for the `__mingw_*` family of symbols. Let's remove these stubs to avoid confusion. Fixes #23309. - - - - - 3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00 Consistently use validity checks for TH conversion of data constructors We were checking that TH-spliced data declarations do not look like this: ```hs data D :: Type = MkD Int ``` But we were only doing so for `data` declarations' data constructors, not for `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out the necessary validity checks into its own `cvtDataDefnCons` function and uses it in all of the places where it needs to be. Fixes #22559. - - - - - a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00 Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC pragma for files with module level scope. Instead of simple not deleting the files, we also need to remove them from the TmpFs so they are not deleted later on when all the other files are deleted. There are additional complications because you also need to remove the directory where these files live from the TmpFs so we don't try to delete those later either. I added two tests. 1. Tests simply that -keep-tmp-files works at all with a single module and --make mode. 2. The other tests that temporary files are deleted for other modules which don't enable -keep-tmp-files. Fixes #23339 - - - - - dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00 withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free. Ticket #23305 reports an error where we were attempting to use the logger which was created by withDeferredDiagnostics after its scope had ended. This problem would have been caught by this patch and a validate build: ``` +*** Exception: Use after free +CallStack (from HasCallStack): + error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make ``` This general issue is tracked by #20981 - - - - - 432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00 Don't return complete HscEnv from upsweep By returning a complete HscEnv from upsweep the logger (as introduced by withDeferredDiagnostics) was escaping the scope of withDeferredDiagnostics and hence we were losing error messages. This is reminiscent of #20981, which also talks about writing errors into messages after their scope has ended. See #23305 for details. - - - - - 26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00 Dump `SpecConstr` specialisations separately Introduce a `-ddump-spec-constr` flag which debugs specialisations from `SpecConstr`. These are no longer shown when you use `-ddump-spec`. - - - - - 4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00 Add role annotations to SNat, SSymbol and SChar Ticket #23454 explained it was possible to implement unsafeCoerce because SNat was lacking a role annotation. As these are supposed to be singleton types but backed by an efficient representation the correct annotation is nominal to ensure these kinds of coerces are forbidden. These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85 which was implemented in 532de36870ed9e880d5f146a478453701e9db25d. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170 Fixes #23454 - - - - - 9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00 Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in This broke the sdist generation. Fixes #23489 - - - - - 273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00 Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver. - - - - - b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00 Fix -Wterm-variable-capture scope (#23434) -Wterm-variable-capture wasn't accordant with type variable scoping in associated types, in type classes. For example, this code produced the warning: k = 12 class C k a where type AT a :: k -> Type I solved this issue by reusing machinery of newTyVarNameRn function that is accordand with associated types: it does lookup for each free type variable when we are in the type class context. And in this patch I use result of this work to make sure that -Wterm-variable-capture warns only on implicitly quantified type variables. - - - - - 9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00 Remove redundant case statement in rts/js/mem.js. - - - - - a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00 Change WarningWithFlag to plural WarningWithFlags Resolves #22825 Now each diagnostic can name multiple different warning flags for its reason. There is currently one use case: missing signatures. Currently we need to check which warning flags are enabled when generating the diagnostic, which is against the declarative nature of the diagnostic framework. This patch allows a warning diagnostic to have multiple warning flags, which makes setup more declarative. The WarningWithFlag pattern synonym is added for backwards compatibility The 'msgEnvReason' field is added to MsgEnvelope to store the `ResolvedDiagnosticReason`, which accounts for the enabled flags, and then that is used for pretty printing the diagnostic. - - - - - ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00 Add a test Way for running ghci with Core optimizations Tracking ticket: #23059 This runs compile_and_run tests with optimised code with bytecode interpreter Changed submodules: hpc, process Co-authored-by: Torsten Schmits <git at tryp.io> - - - - - c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00 Configure -Qunused-arguments instead of hardcoding it When GHC invokes clang, it currently passes -Qunused-arguments to discard warnings resulting from GHC using multiple options that aren't used. In this commit, we configure -Qunused-arguments into the Cc options instead of checking if the compiler is clang at runtime and hardcoding the flag into GHC. This is part of the effort to centralise toolchain information in toolchain target files at configure time with the end goal of a runtime retargetable GHC. This also means we don't need to call getCompilerInfo ever, which improves performance considerably (see !10589). Metric Decrease: PmSeriesG T10421 T11303b T12150 T12227 T12234 T12425 T13035 T13253-spj T13386 T15703 T16875 T17836b T17977 T17977b T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T3064 T5030 T5321FD T5321Fun T5837 T6048 T9020 T9198 T9872d T9961 - - - - - 0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00 Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion between different precisions. - - - - - 95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00 Add regression test for #23143 !10541, the fix for #23323, also fixes #23143. Let's add a regression test to ensure that it stays fixed. Fixes #23143. - - - - - ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00 delete GHCi.UI.Tags module and remove remaining references Co-authored-by: Tilde Rose <t1lde at protonmail.com> - - - - - c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Add regression test for 17328 - - - - - de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Skip checking whether constructors are in scope when deriving newtype instances. Fixes #17328 - - - - - 5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00 Don't suggest `DeriveAnyClass` when instance can't be derived. Fixes #19692. Prototypical cases: class C1 a where x1 :: a -> Int data G1 = G1 deriving C1 class C2 a where x2 :: a -> Int x2 _ = 0 data G2 = G2 deriving C2 Both of these used to give this suggestion, but for C1 the suggestion would have failed (generated code with undefined methods, which compiles but warns). Now C2 still gives the suggestion but C1 doesn't. - - - - - 80a0b099 by David Binder at 2023-06-13T09:47:49-04:00 Add testcase for error GHC-00711 to testsuite - - - - - e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00 Add -Wmissing-poly-kind-signatures Implements #22826 This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types. - - - - - f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00 ci: special case in req_host_target_ghc for JS - - - - - b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00 When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions Fixes #23486 - - - - - c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00 Add a testcase for #20076 Remove 'recursive' in the error message, since the error can arise without recursion. - - - - - b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00 Use tcInferFRR to prevent bad generalisation Fixes #23176 - - - - - bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00 ci: Add dependenices on necessary aarch64 jobs for head.hackage ci These need to be added since we started testing aarch64 on head.hackage CI. The jobs will sometimes fail because they will start before the relevant aarch64 job has finished. Fixes #23511 - - - - - a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00 Add standalone kind signatures for Code and TExp CodeQ and TExpQ already had standalone kind signatures even before this change: type TExpQ :: TYPE r -> Kind.Type type CodeQ :: TYPE r -> Kind.Type Now Code and TExp have signatures too: type TExp :: TYPE r -> Kind.Type type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type This is a stylistic change. - - - - - e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeLits.Internal should not be used - - - - - 100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeNats.Internal should not be used - - - - - 078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add more flags for dumping core passes (#23491) - - - - - 1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add tests for dumping flags (#23491) - - - - - 42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00 Provide a demand signature for atomicModifyMutVar.# (#23047) Fixes #23047 - - - - - 8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00 compiler: Cross-reference Note [StgToJS design] In particular, the numeric representations are quite useful context in a few places. - - - - - a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00 Implement the -Wimplicit-rhs-quantification warning (#23510) GHC Proposal #425 "Invisible binders in type declarations" forbids implicit quantification of type variables that occur free on the right-hand side of a type synonym but are not mentioned on the left-hand side. The users are expected to rewrite this using invisible binders: type T1 :: forall a . Maybe a type T1 = 'Nothing :: Maybe a -- old type T1 @a = 'Nothing :: Maybe a -- new Since the @k-binders are a new feature, we need to wait for three releases before we require the use of the new syntax. In the meantime, we ought to provide users with a new warning, -Wimplicit-rhs-quantification, that would detect when such implicit quantification takes place, and include it in -Wcompat. - - - - - 0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00 Minor refactorings to mkSpillInstr and mkLoadInstr Better error messages. And, use the existing `off` constant to reduce duplication. - - - - - 1792b57a by doyougnu at 2023-06-15T03:12:17-04:00 JS: merge util modules Merge Core and StgUtil modules for StgToJS pass. Closes: #23473 - - - - - 469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00 Check visibility of nested foralls in can_eq_nc (#18863) Prior to this change, `can_eq_nc` checked the visibility of the outermost layer of foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here Then it delegated the rest of the work to `can_eq_nc_forall`, which split off all foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here This meant that some visibility flags were completely ignored. We fix this oversight by moving the check to `can_eq_nc_forall`. - - - - - 59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: use regular mask for blocking IO Blocking IO used uninterruptibleMask which should make any thread blocked on IO unreachable by async exceptions (such as those from timeout). This changes it to a regular mask. It's important to note that the nodejs runtime does not actually interrupt the blocking IO when the Haskell thread receives an async exception, and that file positions may be updated and buffers may be written after the Haskell thread has already resumed. Any file descriptor affected by an async exception interruption should therefore be used with caution. - - - - - 907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: nodejs: do not set 'readable' handler on stdin at startup The Haskell runtime used to install a 'readable' handler on stdin at startup in nodejs. This would cause the nodejs system to start buffering the stream, causing data loss if the stdin file descriptor is passed to another process. This change delays installation of the 'readable' handler until the first read of stdin by Haskell code. - - - - - a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: reserve one more virtual (negative) file descriptor This is needed for upcoming support of the process package - - - - - 78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00 Report scoped kind variables at the type-checking phase (#16635) This patch modifies the renamer to respect ScopedTypeVariables in kind signatures. This means that kind variables bound by the outermost `forall` now scope over the type: type F = '[Right @a @() () :: forall a. Either a ()] -- ^^^^^^^^^^^^^^^ ^^^ -- in scope here bound here However, any use of such variables is a type error, because we don't have type-level lambdas to bind them in Core. This is described in the new Note [Type variable scoping errors during type check] in GHC.Tc.Types. - - - - - 4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00 JS: testsuite: use correct ticket number Replace #22356 with #22349 for these tests because #22356 has been fixed but now these tests fail because of #22349. - - - - - 15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: testsuite: update ticket numbers - - - - - 08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: more triage - - - - - e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00 Fix test T18522-deb-ppr Fixes #23509 - - - - - 62c56416 by Ben Price at 2023-06-16T05:52:39-04:00 Lint: more details on "Occurrence is GlobalId, but binding is LocalId" This is helpful when debugging a pass which accidentally shadowed a binder. - - - - - d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00 Clean a stray bit of text in user guide - - - - - 93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00 testsuite: Add forall visibility test cases The added tests ensure that the type checker does not confuse visible and invisible foralls. VisFlag1: kind-checking type applications and inferred type variable instantiations VisFlag1_ql: kind-checking Quick Look instantiations VisFlag2: kind-checking type family instances VisFlag3: checking kind annotations on type parameters of associated type families VisFlag4: checking kind annotations on type parameters in type declarations with SAKS VisFlag5: checking the result kind annotation of data family instances - - - - - a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00 JS: factorize SaneDouble into its own module Follow-up of b159e0e9 whose ticket is #22736 - - - - - 0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00 Add tests for #21973 - - - - - 640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation for `<**>` - - - - - 2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00 Update text - - - - - 1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00 Update examples - - - - - 7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation to actually display code correctly - - - - - 800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00 Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512) GHC Proposal #425 "Invisible binders in type declarations" restricts the scope of type and data family instances as follows: In type family and data family instances, require that every variable mentioned on the RHS must also occur on the LHS. For example, here are three equivalent type instance definitions accepted before this patch: type family F1 a :: k type instance F1 Int = Any :: j -> j type family F2 a :: k type instance F2 @(j -> j) Int = Any :: j -> j type family F3 a :: k type instance forall j. F3 Int = Any :: j -> j - In F1, j is implicitly quantified and it occurs only on the RHS; - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS; - In F3, j is explicitly quantified. Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted. - - - - - 9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: testsuite: use correct ticket numbers - - - - - c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: don't dump eventlog to stderr by default Fix T16707 Bump stm submodule - - - - - 89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00 Fix TH name lookup for symbolic tycons (#23525) - - - - - cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00 IPE data compression IPE data resulting from the `-finfo-table-map` flag may now be compressed by configuring the GHC build with the `--enable-ipe-data-compression` flag. This results in about a 20% reduction in the size of IPE-enabled build results. The compression library, zstd, may optionally be statically linked by configuring with the `--enabled-static-libzstd` flag (on non-darwin platforms) libzstd version 1.4.0 or greater is required. - - - - - 0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00 Add `IfaceWarnings` to represent the `ModIface`-storable parts of a `Warnings GhcRn`. Fixes #23516 - - - - - 3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00 Avoid desugaring non-recursive lets into recursive lets This prepares for having linear let expressions in the frontend. When desugaring lets, SPECIALISE statements create more copies of a let binding. Because of the rewrite rules attached to the bindings, there are dependencies between the generated binds. Before this commit, we simply wrapped all these in a mutually recursive let block, and left it to the simplified to sort it out. With this commit: we are careful to generate the bindings in dependency order, so that we can wrap them in consecutive lets (if the source is non-recursive). - - - - - 9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00 rts: Do not call exit() from SIGINT handler Previously `shutdown_handler` would call `stg_exit` if the scheduler was Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However, `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit` handlers). The only safe thing to do in this situation is to call `_exit`, which terminates with minimal cleanup. Fixes #23417. - - - - - 7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00 Bump Cabal submodule This requires changing the recomp007 test because now cabal passes `this-unit-id` to executable components, and that unit-id contains a hash which includes the ABI of the dependencies. Therefore changing the dependencies means that -this-unit-id changes and recompilation is triggered. The spririt of the test is to test GHC's recompilation logic assuming that `-this-unit-id` is constant, so we explicitly pass `-ipid` to `./configure` rather than letting `Cabal` work it out. - - - - - 1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00 [feat] add a hint to `HasField` error message - add a hint that indicates that the record that the record dot is used on might just be missing a field - as the intention of the programmer is not entirely clear, it is only shown if the type is known - This addresses in part issue #22382 - - - - - b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00 rts/ipe: Fix unused lock warning - - - - - 6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00 rts/ProfilerReportJson: Fix memory leak - - - - - 1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Various warnings fixes - - - - - 471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix printf format mismatch - - - - - 80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect #include <sys/poll.h> According to Alpine's warnings and poll(2), <poll.h> should be preferred. - - - - - ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00 nonmoving: Fix unused definition warrnings - - - - - 6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00 Disable futimens on Darwin. See #22938 - - - - - b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect CPP guard - - - - - 94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00 hadrian: Ensure that -Werror is passed when compiling the RTS. Previously the `+werror` transformer would only pass `-Werror` to GHC, which does not ensure that the same is passed to the C compiler when building the RTS. Arguably this is itself a bug but for now we will just work around this by passing `-optc-Werror` to GHC. I tried to enable `-Werror` in all C compilations but the boot libraries are something of a portability nightmare. - - - - - 5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Disable `#pragma GCC`s on clang compilers Otherwise the build fails due to warnings. See #23530. - - - - - cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix capitalization of prototype - - - - - 17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect format specifier - - - - - 0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00 JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576) - - - - - 3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Memory usage fixes for Haddock - Do not include `mi_globals` in the `NoBackend` backend. It was only included for Haddock, but Haddock does not actually need it. This causes a 200MB reduction in max residency when generating haddocks on the Agda codebase (roughly 1GB to 800MB). - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to be written to interface files using `-fwrite-interface` Bumps haddock submodule. Metric Decrease: haddock.base - - - - - 8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Fix associated data family doc structure items Associated data families were being given their own export DocStructureItems, which resulted in them being documented separately from their classes in haddocks. This commit fixes it. - - - - - 4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: implement TH support - Add ghc-interp.js bootstrap script for the JS interpreter - Interactively link and execute iserv code from the ghci package - Incrementally load and run JS code for splices into the running iserv Co-authored-by: Luite Stegeman <stegeman at gmail.com> - - - - - 3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Don't use getKey - - - - - f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Stg: return imported FVs This is used to determine what to link when using the interpreter. For now it's only used by the JS interpreter but it could easily be used by the native interpreter too (instead of extracting names from compiled BCOs). - - - - - fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Fix some recompilation avoidance tests - - - - - a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00 TH_import_loop is now broken as expected - - - - - dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: always recompile when TH is enabled (cf #23013) - - - - - 711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00 Add support for deprecating exported items (proposal #134) This is an implementation of the deprecated exports proposal #134. The proposal introduces an ability to introduce warnings to exports. This allows for deprecating a name only when it is exported from a specific module, rather than always depreacting its usage. In this example: module A ({-# DEPRECATED "do not use" #-} x) where x = undefined --- module B where import A(x) `x` will emit a warning when it is explicitly imported. Like the declaration warnings, export warnings are first accumulated within the `Warnings` struct, then passed into the ModIface, from which they are then looked up and warned about in the importing module in the `lookup_ie` helpers of the `filterImports` function (for the explicitly imported names) and in the `addUsedGRE(s)` functions where they warn about regular usages of the imported name. In terms of the AST information, the custom warning is stored in the extension field of the variants of the `IE` type (see Trees that Grow for more information). The commit includes a bump to the haddock submodule added in MR #28 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00 configure: Bump version to 9.8 Bumps Haddock submodule - - - - - 4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00 configure: Bump version to 9.9 Bumps haddock submodule. - - - - - 5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00 rts: Work around missing prototypes errors Darwin's toolchain inexpliciably claims that `write_barrier` and friends have declarations without prototypes, despite the fact that (a) they are definitions, and (b) the prototypes appear only a few lines above. Work around this by making the definitions proper prototypes. - - - - - 43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00 ghcup-metadata: Fix date modifier (M = minutes, m = month) Fixes #23552 - - - - - 564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00 Support large stack frames/offsets in GHCi bytecode interpreter Bytecode instructions like PUSH_L (push a local variable) contain an operand that refers to the stack slot. Before this patch, the operand type was SmallOp (Word16), limiting the maximum stack offset to 65535 words. This could cause compiler panics in some cases (See #22888). This patch changes the operand type for stack offsets from SmallOp to Op, removing the stack offset limit. Fixes #22888 - - - - - 8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00 JS: support levity-polymorphic datatypes (#22360,#22291) - thread knowledge about levity into PrimRep instead of panicking - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.) Doing this also fixes #22291 (test added). There is a small performance hit (~1% more allocations). Metric Increase: T18698a T18698b - - - - - 5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00 MR Review Template: Mention "Blocked on Review" label In order to improve our MR review processes we now have the label "Blocked on Review" which allows people to signal that a MR is waiting on a review to happen. See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html - - - - - 4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00 Move MR template to Default.md This makes it more obvious what you have to modify to affect the default template rather than looking in the project settings. - - - - - 522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00 Revert "Avoid desugaring non-recursive lets into recursive lets" This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef. Fixes #23550 - - - - - c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00 Propagate breakpoint information when inlining across modules Tracking ticket: #23394 MR: !10448 * Add constructor `IfaceBreakpoint` to `IfaceTickish` * Store breakpoint data in interface files * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's state * Allocate module name in `ModBreaks`, like `BreakArray` * Lookup breakpoint by module name in GHCi * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the linker when breakpoints are enabled, and panicking when `ModBreaks` is missing - - - - - 6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00 Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's - - - - - e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00 Remove arity inference in type declarations (#23514) Arity inference in type declarations was introduced as a workaround for the lack of @k-binders. They were added in 4aea0a72040, so I simplified all of this by simply removing arity inference altogether. This is part of GHC Proposal #425 "Invisible binders in type declarations". - - - - - 459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00 Relax defaulting of RuntimeRep/Levity when printing Fixes #16468 MR: !10702 Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall - - - - - 151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00 Remove duplicate link label in linear types docs - - - - - ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00 Stop configuring unused Ld command in `settings` GHC has no direct dependence on the linker. Rather, we depend upon the C compiler for linking and an object-merging program (which is typically `ld`) for production of GHCi objects and merging of C stubs into final object files. Despite this, for historical reasons we still recorded information about the linker into `settings`. Remove these entries from `settings`, `hadrian/cfg/system.config`, as well as the `configure` logic responsible for this information. Closes #23566. - - - - - bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00 Remove extraneous debug output - - - - - 7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00 Work with unset vars in -e mode - - - - - 49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00 Pass positional arguments in their positions By quoting $cmd, the default "bash -i" is a single argument to run, and no file named "bash -i" actually exists to be run. - - - - - 887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00 Handle unset value in -e context - - - - - 5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00 Configure CPP into settings There is a distinction to be made between the Haskell Preprocessor and the C preprocessor. The former is used to preprocess Haskell files, while the latter is used in C preprocessing such as Cmm files. In practice, they are both the same program (usually the C compiler) but invoked with different flags. Previously we would, at configure time, configure the haskell preprocessor and save the configuration in the settings file, but, instead of doing the same for CPP, we had hardcoded in GHC that the CPP program was either `cc -E` or `cpp`. This commit fixes that asymmetry by also configuring CPP at configure time, and tries to make more explicit the difference between HsCpp and Cpp (see Note [Preprocessing invocations]). Note that we don't use the standard CPP and CPPFLAGS to configure Cpp, but instead use the non-standard --with-cpp and --with-cpp-flags. The reason is that autoconf sets CPP to "$CC -E", whereas we expect the CPP command to be configured as a standalone executable rather than a command. These are symmetrical with --with-hs-cpp and --with-hs-cpp-flags. Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP to be C99 compatible through -optP, since we now configure that into settings. Closes #23422 - - - - - 5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00 hadrian: Always canonicalize topDirectory Hadrian's `topDirectory` is intended to provide an absolute path to the root of the GHC tree. However, if the tree is reached via a symlink this One question here is whether the `canonicalizePath` call is expensive enough to warrant caching. In a quick microbenchmark I observed that `canonicalizePath "."` takes around 10us per call; this seems sufficiently low not to worry. Alternatively, another approach here would have been to rather move the canonicalization into `m4/fp_find_root.m4`. This would have avoided repeated canonicalization but sadly path canonicalization is a hard problem in POSIX shell. Addresses #22451. - - - - - b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00 Optimise ELF linker (#23464) - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF` - cache shndx table in ObjectCode - run `checkProddableBlock` only with debug rts - - - - - 30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE - - - - - b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Drop MO_WriteBarrier rts: Drop write_barrier - - - - - 7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00 rts: Drop load_store_barrier() This is no longer used. - - - - - d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop last instances of prim_{write,read}_barrier - - - - - 965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Eliminate remaining uses of load_load_barrier - - - - - 0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00 compiler: Drop MO_ReadBarrier - - - - - 7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop load_load_barrier This is no longer used. - - - - - 9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00 Delete write_barrier function - - - - - bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Make collectFreshWeakPtrs definition a prototype x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs needs to be a prototype. - - - - - ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00 Fix number of free double regs D1..D4 are defined for aarch64 and thus not free. - - - - - c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00 Fix typechecking of promoted empty lists The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of `'[]` (see the newly added `T23543` test case for an example), but the `'[]` case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type checker]`. There are some benign changes to test cases' expected output due to the new code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`. Fixes #23543. - - - - - fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00 Configure MergeObjs supports response files rather than Ld The previous configuration script to test whether Ld supported response files was * Incorrect (see #23542) * Used, in practice, to check if the *merge objects tool* supported response files. This commit modifies the macro to run the merge objects tool (rather than Ld), using a response file, and checking the result with $NM Fixes #23542 - - - - - 78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00 JS: fix JS stack printing (#23565) - - - - - 9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00 Add -fpolymorphic-specialisation flag (off by default at all optimisation levels) Polymorphic specialisation has led to a number of hard to diagnose incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so this commit introduces a flag `-fpolymorhphic-specialisation` which allows users to turn on this experimental optimisation if they are willing to buy into things going very wrong. Ticket #23469 - - - - - b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00 Rip out runtime linker/compiler checks We used to choose flags to pass to the toolchain at runtime based on the platform running GHC, and in this commit we drop all of those runtime linker checks Ultimately, this represents a change in policy: We no longer adapt at runtime to the toolchain being used, but rather make final decisions about the toolchain used at /configure time/ (we have deleted Note [Run-time linker info] altogether!). This works towards the goal of having all toolchain configuration logic living in the same place, which facilities the work towards a runtime-retargetable GHC (see #19877). As of this commit, the runtime linker/compiler logic was moved to autoconf, but soon it, and the rest of the existing toolchain configuration logic, will live in the standalone ghc-toolchain program (see !9263) In particular, what used to be done at runtime is now as follows: * The flags -Wl,--no-as-needed for needed shared libs are configured into settings * The flag -fstack-check is configured into settings * The check for broken tables-next-to-code was outdated * We use the configured c compiler by default as the assembler program * We drop `asmOpts` because we already configure -Qunused-arguments flag into settings (see !10589) Fixes #23562 Co-author: Rodrigo Mesquita (@alt-romes) - - - - - 8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00 Define FFI_GO_CLOSURES The libffi shipped with Apple's XCode toolchain does not contain a definition of the FFI_GO_CLOSURES macro, despite containing references to said macro. Work around this by defining the macro, following the model of a similar workaround in OpenJDK [1]. [1] https://github.com/openjdk/jdk17u-dev/pull/741/files - - - - - d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00 base: Fix incorrect CPP guard This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`. - - - - - 7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00 rts/Trace: Ensure that debugTrace arguments are used As debugTrace is a macro we must take care to ensure that the fact is clear to the compiler lest we see warnings. - - - - - cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00 rts: Various warnings fixes - - - - - dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00 hadrian: Ignore warnings in unix and semaphore-compat - - - - - d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00 hadrian: Fix dependencies of docs:* rule For the docs:* rule we need to actually build the package rather than just the haddocks for the dependent packages. Therefore we depend on the .conf files of the packages we are trying to build documentation for as well as the .haddock files. Fixes #23472 - - - - - cec90389 by sheaf at 2023-06-30T12:39:27-04:00 Add tests for #22106 Fixes #22106 - - - - - 083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 - - - - - fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00 rts: Ensure that pinned allocations respect block size Previously, it was possible for pinned, aligned allocation requests to allocate beyond the end of the pinned accumulator block. Specifically, we failed to account for the padding needed to achieve the requested alignment in the "large object" check. With large alignment requests, this can result in the allocator using the capability's pinned object accumulator block to service a request which is larger than `PINNED_EMPTY_SIZE`. To fix this we reorganize `allocatePinned` to consistently account for the alignment padding in all large object checks. This is a bit subtle as we must handle the case of a small allocation request filling the accumulator block, as well as large requests. Fixes #23400. - - - - - 98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00 testsuite: Add test for #23400 - - - - - 4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00 ghc-heap: Support for BLOCKING_QUEUE closures - - - - - 03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00 Add some structured diagnostics in Tc/Validity.hs This addresses the work of ticket #20118 Created the following constructors for TcRnMessage - TcRnInaccessibleCoAxBranch - TcRnPatersonCondFailure - - - - - 6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Add failing test case for #23492 - - - - - 356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Use generated src span for catch-all case of record selector functions This fixes #23492. The problem was that we used the real source span of the field declaration for the generated catch-all case in the selector function, in particular in the generated call to `recSelError`, which meant it was included in the HIE output. Using `generatedSrcSpan` instead means that it is not included. - - - - - 3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils - - - - - dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Construct catch-all default case using helpers GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors - - - - - 0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00 Add regression test for #23549 - - - - - 32741743 by Alexis King at 2023-07-03T03:31:36-04:00 perf tests: Increase default stack size for MultiLayerModules An unhelpfully small stack size appears to have been the real culprit behind the metric fluctuations in #19293. Debugging metric decreases triggered by !10729 helped to finally identify the problem. Metric Decrease: MultiLayerModules MultiLayerModulesTH_Make T13701 T14697 - - - - - 82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00 Add missing void prototypes to rts functions See #23561. - - - - - 6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00 gitlab-ci: Refactor compilation of gen_ci Flakify and document it, making it far less sensitive to the build environment. - - - - - aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00 testsuite: Update documentation - - - - - 924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00 Better error for data deriving of type synonym/family. Closes #23522 - - - - - 4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00 Fix some broken links and typos - - - - - de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00 configure: Rip out Solaris dyld check Solaris 11 was released over a decade ago and, moreover, I doubt we have any Solaris users - - - - - 59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00 CI: add JS release and debug builds, regen CI jobs - - - - - 679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00 testsuite: Do not require CUSKs Numerous tests make use of CUSKs (complete user-supplied kinds), a legacy feature scheduled for deprecation. In order to proceed with the said deprecation, the tests have been updated to use SAKS instead (standalone kind signatures). This also allows us to remove the Haskell2010 language pragmas that were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021. - - - - - 945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00 gitlab: Drop backport-for-8.8 MR template Its usefulness has long passed. - - - - - 66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00 EPA: Simplify GHC/Parser.y comb2 Use the HasLoc instance from Ast.hs to allow comb2 to work with anything with a SrcSpan This gets rid of the custom comb2A, comb2Al, comb2N functions, and removes various reLoc calls. - - - - - 2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00 Fix deprecation warning when deprecated identifier is from another module A stray 'Just' was being printed in the deprecation message. Fixes #23573 - - - - - 46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00 rts: Don't rely on initializers for sigaction_t As noted in #23577, CentOS's ancient toolchain throws spurious missing-field-initializer warnings. - - - - - ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Don't treat -Winline warnings as fatal Such warnings are highly dependent upon the toolchain, platform, and build configuration. It's simply too fragile to rely on these. - - - - - 3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Only pass -Wno-nonportable-include-path on Darwin This flag, which was introduced due to #17798, is only understood by Clang and consequently throws warnings on platforms using gcc. Sadly, there is no good way to treat such warnings as non-fatal with `-Werror` so for now we simply make this flag specific to platforms known to use Clang and case-insensitive filesystems (Darwin and Windows). See #23577. - - - - - 4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00 Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals - - - - - 2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00 compiler: Make OccSet opaque - - - - - cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00 Add Note about why we need forall in Code to be on the right - - - - - fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00 Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall. - - - - - 9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00 Improve the situation with the stimes cycle Currently the Semigroup stimes cycle is resolved in GHC.Base by importing stimes implementations from a hs-boot file. Resolve the cycle using hs-boot files for required classes (Num, Integral) instead. Now stimes can be defined directly in GHC.Base, making inlining and specialization possible. This leads to some new boot files for `GHC.Num` and `GHC.Real`, the methods for those are only used to implement `stimes` so it doesn't appear that these boot files will introduce any new performance traps. Metric Decrease: T13386 T8095 Metric Increase: T13253 T13386 T18698a T18698b T19695 T8095 - - - - - 9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00 Refactor Unique to be represented by Word64 In #22010 we established that Int was not always sufficient to store all the uniques we generate during compilation on 32-bit platforms. This commit addresses that problem by using Word64 instead of Int for uniques. The core of the change is in GHC.Core.Types.Unique and GHC.Core.Types.Unique.Supply. However, the representation of uniques is used in many other places, so those needed changes too. Additionally, the RTS has been extended with an atomic_inc64 operation. One major change from this commit is the introduction of the Word64Set and Word64Map data types. These are adapted versions of IntSet and IntMap from the containers package. These are planned to be upstreamed in the future. As a natural consequence of these changes, the compiler will be a bit slower and take more space on 32-bit platforms. Our CI tests indicate around a 5% residency increase. Metric Increase: CoOpt_Read CoOpt_Singletons LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot RecordUpdPerf T10421 T10547 T12150 T12227 T12234 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T13386 T13719 T14683 T14697 T14766 T15164 T15703 T16577 T16875 T17516 T18140 T18223 T18282 T18304 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T3294 T4801 T5030 T5321FD T5321Fun T5631 T5642 T5837 T6048 T783 T8095 T9020 T9198 T9233 T9630 T9675 T9872a T9872b T9872b_defer T9872c T9872d T9961 TcPlugin_RewritePerf UniqLoop WWRec hard_hole_fits - - - - - 6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00 Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro - - - - - 40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00 Substitute free variables captured by breakpoints in SpecConstr Fixes #23267 - - - - - 2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00 Reinstate untouchable variable error messages This extra bit of information was accidentally being discarded after a refactoring of the way we reported problems when unifying a type variable with another type. This patch rectifies that. - - - - - 53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00 configure: Drop Clang command from settings Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the `runClang` function, and no longer need to configure into settings the Clang command. We used to determine options at runtime to pass clang when it was used as an assembler, but now that we configure at configure time we no longer need to. - - - - - 6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00 Filter out nontrivial substituted expressions in substTickish Fixes #23272 - - - - - 41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: testsuite: use req_c predicate instead of js_broken - - - - - 74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: implement some file primitives (lstat,rmdir) (#22374) - Implement lstat and rmdir. - Implement base_c_s_is* functions (testing a file type) - Enable passing tests - - - - - 7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: cleanup utils (#23314) - Removed unused code - Don't export unused functions - Move toTypeList to Closure module - - - - - f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: rename VarType/Vt into JSRep - - - - - 19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: remove custom PrimRep conversion (#23314) We use the usual conversion to PrimRep and then we convert these PrimReps to JSReps. - - - - - d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: don't use isRuntimeRepKindedTy in JS FFI - - - - - 8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file Fixes #23600 - - - - - e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Use dynamically linked alpine bindists In theory these will work much better on alpine to allow people to build statically linked applications there. We don't need to distribute a statically linked application ourselves in order to allow that. Fixes #23602 - - - - - b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00 Drop circle-ci-job.sh - - - - - 9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00 testsuite: Allow preservation of unexpected output Here we introduce a new flag to the testsuite driver, --unexpected-output-dir=<dir>, which allows the user to ask the driver to preserve unexpected output from tests. The intent is for this to be used in CI to allow users to more easily fix unexpected platform-dependent output. - - - - - 48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00 gitlab-ci: Preserve unexpected output Here we enable use of the testsuite driver's `--unexpected-output-dir` flag by CI, preserving the result as an artifact for use by users. - - - - - 76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00 driver: Fix -S with .cmm files There was an oversight in the driver which assumed that you would always produce a `.o` file when compiling a .cmm file. Fixes #23610 - - - - - 6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00 Update Hadrian's stack.yaml - - - - - 1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00 compiler: Rework ShowSome Previously the field used to filter the sub-declarations to show was rather ad-hoc and was only able to show at most one sub-declaration. - - - - - 8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00 testsuite: Add test to catch changes in core libraries This adds testing infrastructure to ensure that changes in core libraries (e.g. `base` and `ghc-prim`) are caught in CI. - - - - - ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00 Deprecate Data.List.NonEmpty.unzip - - - - - 5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00 Drop latent mentions of -split-objs Closes #21134. - - - - - a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00 Add warn_and_run test kind This is a compile_and_run variant which also captures the GHC's stderr. The warn_and_run name is best I can come up with, as compile_and_run is taken. This is useful specifically for testing warnings. We want to test that when warning triggers, and it's not a false positive, i.e. that the runtime behaviour is indeed "incorrect". As an example a single test is altered to use warn_and_run - - - - - c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00 configure: Don't use ld.gold on i386 ld.gold appears to produce invalid static constructor tables on i386. While ideally we would add an autoconf check to check for this brokenness, sadly such a check isn't easy to compose. Instead to summarily reject such linkers on i386. Somewhat hackily closes #23579. - - - - - 054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00 Add since annotations for Data.Foldable1 - - - - - 550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00 JS: support -this-unit-id for programs in the linker (#23613) - - - - - d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00 Bump text submodule - - - - - 8e11630e by jade at 2023-07-10T16:58:40-04:00 Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007) As suggested in #20007 and implemented in !8895, trying to import type operators will suggest a fix to use the 'type' keyword, without considering whether ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled, alongside the suggestion of adding the 'type' keyword. - - - - - 61b1932e by sheaf at 2023-07-10T16:59:26-04:00 tyThingLocalGREs: include all DataCons for RecFlds The GREInfo for a record field should include the collection of all the data constructors of the parent TyCon that have this record field. This information was being incorrectly computed in the tyThingLocalGREs function for a DataCon, as we were not taking into account other DataCons with the same parent TyCon. Fixes #23546 - - - - - e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00 EPA: Simplify GHC/Parser.y comb3 A follow up to !10743 - - - - - ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00 Document that compareByteArrays# is available since ghc-prim-0.5.2.0 - - - - - 4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00 Revert "Bump text submodule" This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a. This commit requires that we bootstrap with ghc-9.4, which we do not require until #23195 has been completed. Subsequently this has broken nighty jobs such as the rocky8 job which in turn has broken nightly releases. - - - - - d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Fingerprint more code generation flags Previously our recompilation check was quite inconsistent in its coverage of non-optimisation code generation flags. Specifically, we failed to account for most flags that would affect the behavior of generated code in ways that might affect the result of a program's execution (e.g. `-feager-blackholing`, `-fstrict-dicts`) Closes #23369. - - - - - eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Record original thunk info tables on stack Here we introduce a new code generation option, `-forig-thunk-info`, which ensures that an `stg_orig_thunk_info` frame is pushed before every update frame. This can be invaluable when debugging thunk cycles and similar. See Note [Original thunk info table frames] for details. Closes #23255. - - - - - 4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00 Fix wrong MIN_VERSION_GLASGOW_HASKELL macros I forgot to change these after rebasing. - - - - - dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00 Hadrian: enable GHCi support on riscv64 - - - - - 09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00 JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628) - - - - - 29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00 Remove references to make build system in mk/build.mk Fixes #23636 - - - - - 630e3026 by sheaf at 2023-07-12T11:26:43-04:00 Valid hole fits: don't panic on a Given The function GHC.Tc.Errors.validHoleFits would end up panicking when encountering a Given constraint. To fix this, it suffices to filter out the Givens before continuing. Fixes #22684 - - - - - c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00 Use deb10 for i386 bindists deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10 Fixes #23585 - - - - - bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00 Fix #23567, a specializer bug Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834 The testcase isn't ideal because it doesn't detect the bug in master, unless doNotUnbox is removed as in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692. But I have confirmed that with that modification, it fails before and passes afterwards. - - - - - 84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 Comments - - - - - b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 updates to comments - - - - - 2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 changes - - - - - 6143838a by sheaf at 2023-07-13T08:02:17-04:00 Fix deprecation of record fields Commit 3f374399 inadvertently broke the deprecation/warning mechanism for record fields due to its introduction of record field namespaces. This patch ensures that, when a top-level deprecation is applied to an identifier, it applies to all the record fields as well. This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of NameSpaces but to look up all NameSpaces and filter out the irrelevant ones. - - - - - 6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00 Introduce greInfo, greParent These are simple helper functions that wrap the internal field names gre_info, gre_par. - - - - - 7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00 Refactor lookupGRE_... functions This commit consolidates all the logic for looking up something in the Global Reader Environment into the single function lookupGRE. This allows us to declaratively specify all the different modes of looking up in the GlobalRdrEnv, and avoids manually passing around filtering functions as was the case in e.g. the function GHC.Rename.Env.lookupSubBndrOcc_helper. ------------------------- Metric Decrease: T8095 ------------------------- ------------------------- Metric Increase: T8095 ------------------------- - - - - - 5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00 configure: Drop DllWrap command We used to configure into settings a DllWrap command for windows builds and distributions, however, we no longer do, and dllwrap is effectively unused. This simplification is motivated in part by the larger toolchain-selection project (#19877, !9263) - - - - - e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00 base: fix haddock syntax in GHC.Profiling - - - - - 0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00 Revert "CI: add JS release and debug builds, regen CI jobs" This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af. This commit added two duplicate jobs on all validate pipelines, so we are reverting for now whilst we work out what the best way forward is. Ticket #23618 - - - - - 54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00 EPA: Simplify GHC/Parser.y sLL Follow up to !10743 - - - - - c8863828 by sheaf at 2023-07-15T03:24:06-04:00 Configure: canonicalise PythonCmd on Windows This change makes PythonCmd resolve to a canonical absolute path on Windows, which prevents HLS getting confused (now that we have a build-time dependency on python). fixes #23652 - - - - - ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00 Improve Note [Binder-swap during float-out] - - - - - cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00 Equality of forall-types is visibility aware This patch finally (I hope) nails the question of whether (forall a. ty) and (forall a -> ty) are `eqType`: they aren't! There is a long discussion in #22762, plus useful Notes: * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare * Note [Comparing visiblities] in GHC.Core.TyCo.Compare * Note [ForAllCo] in GHC.Core.TyCo.Rep It also establishes a helpful new invariant for ForAllCo, and ForAllTy, when the bound variable is a CoVar:in that case the visibility must be coreTyLamForAllTyFlag. All this is well documented in revised Notes. - - - - - 7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00 List and Tuple<n>: update documentation Add the missing changelog.md entries and @since-annotations. - - - - - 2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00 Type patterns (#22478, #18986) Improved name resolution and type checking of type patterns in constructors: 1. HsTyPat: a new dedicated data type that represents type patterns in HsConPatDetails instead of reusing HsPatSigType 2. rnHsTyPat: a new function that renames a type pattern and collects its binders into three groups: - explicitly bound type variables, excluding locally bound variables - implicitly bound type variables from kind signatures (only if ScopedTypeVariables are enabled) - named wildcards (only from kind signatures) 2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat 2b. rnImplcitTvBndrs: removed because no longer needed 3. collect_pat: updated to collect type variable binders from type patterns (this means that types and terms use the same infrastructure to detect conflicting bindings, unused variables and name shadowing) 3a. CollVarTyVarBinders: a new CollectFlag constructor that enables collection of type variables 4. tcHsTyPat: a new function that typechecks type patterns, capable of handling polymorphic kinds. See Note [Type patterns: binders and unifiers] Examples of code that is now accepted: f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing g :: forall a. Proxy a -> ... g (P @a) = ... -- also triggers -Wname-shadowing h (P @($(TH.varT (TH.mkName "t")))) = ... -- t is bound at splice time j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected data T where MkT :: forall (f :: forall k. k -> Type). f Int -> f Maybe -> T k :: T -> () k (MkT @f (x :: f Int) (y :: f Maybe)) = () -- f :: forall k. k -> Type Examples of code that is rejected with better error messages: f (Left @a @a _) = ... -- new message: -- • Conflicting definitions for ‘a’ -- Bound at: Test.hs:1:11 -- Test.hs:1:14 Examples of code that is now rejected: {-# OPTIONS_GHC -Werror=unused-matches #-} f (P @a) = () -- Defined but not used: type variable ‘a’ - - - - - eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00 Don't use substTyUnchecked in newMetaTyVar There were some comments that explained that we needed to use an unchecked substitution function because of issue #12931, but that has since been fixed, so we should be able to use substTy instead now. - - - - - c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00 rnImports: var shouldn't import NoFldSelectors In an import declaration such as import M ( var ) the import of the variable "var" should **not** bring into scope record fields named "var" which are defined with NoFieldSelectors. Doing so can cause spurious "unused import" warnings, as reported in ticket #23557. Fixes #23557 - - - - - 1af2e773 by sheaf at 2023-07-17T02:48:19-04:00 Suggest similar names in imports This commit adds similar name suggestions when importing. For example module A where { spelling = 'o' } module B where { import B ( speling ) } will give rise to the error message: Module ‘A’ does not export ‘speling’. Suggested fix: Perhaps use ‘spelling’ This also provides hints when users try to import record fields defined with NoFieldSelectors. - - - - - 654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00 EPA: Store leading AnnSemi for decllist in al_rest This simplifies the markAnnListA implementation in ExactPrint - - - - - 22565506 by sheaf at 2023-07-17T21:12:59-04:00 base: add COMPLETE pragma to BufferCodec PatSyn This implements CLC proposal #178, rectifying an oversight in the implementation of CLC proposal #134 which could lead to spurious pattern match warnings. https://github.com/haskell/core-libraries-committee/issues/178 https://github.com/haskell/core-libraries-committee/issues/134 - - - - - 860f6269 by sheaf at 2023-07-17T21:13:00-04:00 exactprint: silence incomplete record update warnings - - - - - df706de3 by sheaf at 2023-07-17T21:13:00-04:00 Re-instate -Wincomplete-record-updates Commit e74fc066 refactored the handling of record updates to use the HsExpanded mechanism. This meant that the pattern matching inherent to a record update was considered to be "generated code", and thus we stopped emitting "incomplete record update" warnings entirely. This commit changes the "data Origin = Source | Generated" datatype, adding a field to the Generated constructor to indicate whether we still want to perform pattern-match checking. We also have to do a bit of plumbing with HsCase, to record that the HsCase arose from an HsExpansion of a RecUpd, so that the error message continues to mention record updates as opposed to a generic "incomplete pattern matches in case" error. Finally, this patch also changes the way we handle inaccessible code warnings. Commit e74fc066 was also a regression in this regard, as we were emitting "inaccessible code" warnings for case statements spuriously generated when desugaring a record update (remember: the desugaring mechanism happens before typechecking; it thus can't take into account e.g. GADT information in order to decide which constructors to include in the RHS of the desugaring of the record update). We fix this by changing the mechanism through which we disable inaccessible code warnings: we now check whether we are in generated code in GHC.Tc.Utils.TcMType.newImplication in order to determine whether to emit inaccessible code warnings. Fixes #23520 Updates haddock submodule, to avoid incomplete record update warnings - - - - - 1d05971e by sheaf at 2023-07-17T21:13:00-04:00 Propagate long-distance information in do-notation The preceding commit re-enabled pattern-match checking inside record updates. This revealed that #21360 was in fact NOT fixed by e74fc066. This commit makes sure we correctly propagate long-distance information in do blocks, e.g. in ```haskell data T = A { fld :: Int } | B f :: T -> Maybe T f r = do a at A{} <- Just r Just $ case a of { A _ -> A 9 } ``` we need to propagate the fact that "a" is headed by the constructor "A" to see that the case expression "case a of { A _ -> A 9 }" cannot fail. Fixes #21360 - - - - - bea0e323 by sheaf at 2023-07-17T21:13:00-04:00 Skip PMC for boring patterns Some patterns introduce no new information to the pattern-match checker (such as plain variable or wildcard patterns). We can thus skip doing any pattern-match checking on them when the sole purpose for doing so was introducing new long-distance information. See Note [Boring patterns] in GHC.Hs.Pat. Doing this avoids regressing in performance now that we do additional pattern-match checking inside do notation. - - - - - ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00 Split GHC.Platform.ArchOS from ghc-boot into ghc-platform Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package into this reinstallable standalone package which abides by the PVP, in part motivated by the ongoing work on `ghc-toolchain` towards runtime retargetability. - - - - - b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00 JS: better implementation for plusWord64 (#23597) - - - - - 889c2bbb by sheaf at 2023-07-18T06:37:32-04:00 Do primop rep-poly checks when instantiating This patch changes how we perform representation-polymorphism checking for primops (and other wired-in Ids such as coerce). When instantiating the primop, we check whether each type variable is required to instantiated to a concrete type, and if so we create a new concrete metavariable (a ConcreteTv) instead of a simple MetaTv. (A little subtlety is the need to apply the substitution obtained from instantiating to the ConcreteTvOrigins, see Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.) This allows us to prevent representation-polymorphism in non-argument position, as that is required for some of these primops. We can also remove the logic in tcRemainingValArgs, except for the part concerning representation-polymorphic unlifted newtypes. The function has been renamed rejectRepPolyNewtypes; all it does now is reject unsaturated occurrences of representation-polymorphic newtype constructors when the representation of its argument isn't a concrete RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check). The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head gives more explanation about a possible path to PHASE 2, which would be in line with the treatment for primops taken in this patch. We also update the Core Lint check to handle this new framework. This means Core Lint now checks representation-polymorphism in continuation position like needed for catch#. Fixes #21906 ------------------------- Metric Increase: LargeRecord ------------------------- - - - - - 00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00 Core Lint: distinguish let and letrec in locations Lint messages were saying "in the body of letrec" even for non-recursive let. I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no separate letrec. - - - - - 787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00 Use extended literals when deriving Show This implements GHC proposal https://github.com/ghc-proposals/ghc-proposals/pull/596 Also add support for Int64# and Word64#; see testcase ShowPrim. - - - - - 257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00 Add StgFromCore and StgCodeGen linting - - - - - 34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Strictness - - - - - c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Don't repeatedly construct UniqSets - - - - - b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00 compiler/Types: Ensure that fromList-type operations can fuse In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing it to do so makes a considerable difference in allocations due to the backend. Metric Decrease: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 Codegen: Implement MO_S_MulMayOflo for W16 - - - - - 5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64 It's useful to see which value made the pattern match fail. (If it ever occurs.) - - - - - e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: Implement MO_S_MulMayOflo for W8 This case wasn't handled before. But, the test-primops test suite showed that it actually might appear. - - - - - a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00 Add test for %mulmayoflo primop The test expects a perfect implementation with no false positives. - - - - - 38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00 lint-ci-config: Generate jobs-metadata.json We also now save the jobs-metadata.json and jobs.yaml file as artifacts as: * It might be useful for someone who is modifying CI to copy jobs.yaml if they are having trouble regenerating locally. * jobs-metadata.json is very useful for downstream pipelines to work out the right job to download. Fixes #23654 - - - - - 1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00 Initialize 9.10.1-notes.rst Create new release notes for the next GHC release (GHC 9.10) - - - - - 3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00 Prioritise Parent when looking up class sub-binder When we look up children GlobalRdrElts of a given Parent, we sometimes would rather prioritise those GlobalRdrElts which have the right Parent, and sometimes prioritise those that have the right NameSpace: - in export lists, we should prioritise NameSpace - for class/instance binders, we should prioritise Parent See Note [childGREPriority] in GHC.Types.Name.Reader. fixes #23664 - - - - - 9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00 EPA: Improve annotation management in getMonoBind Ensure the LHsDecl for a FunBind has the correct leading comments and trailing annotations. See the added note for details. - - - - - ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00 Remove unused files in .gitlab These were left over after 6078b429 - - - - - 29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00 gen_ci: Add hie.yaml file This allows you to load `gen_ci.hs` into HLS, and now it is a huge module, that is quite useful. - - - - - 808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00 ci: Make "fast-ci" the default validate configuration We are trying out a lighter weight validation pipeline where by default we just test on 5 platforms: * x86_64-deb10-slow-validate * windows * x86_64-fedora33-release * aarch64-darwin * aarch64-linux-deb10 In order to enable the "full" validation pipeline you can apply the `full-ci` label which will enable all the validation pipelines. All the validation jobs are still run on a marge batch. The goal is to reduce the overall CI capacity so that pipelines start faster for MRs and marge bot batches are faster. Fixes #23694 - - - - - 0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00 EPA: Simplify GHC/Parser.y sL1 This is the next patch in a series simplifying location management in GHC/Parser.y This one simplifies sL1, to use the HasLoc instances introduced in !10743 (closed) - - - - - 3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. - - - - - db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Set explicit section types on all platforms - - - - - b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00 Insert documentation into parsed signature modules Causes haddock comments in signature modules to be properly inserted into the AST (just as they are for regular modules) if the `-haddock` flag is given. Also adds a test that compares `-ddump-parsed-ast` output for a signature module to prevent further regressions. Fixes #23315 - - - - - c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00 primops: Introduce unsafeThawByteArray# This addresses an odd asymmetry in the ByteArray# primops, which previously provided unsafeFreezeByteArray# but no corresponding thaw operation. Closes #22710 - - - - - 87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00 testsuite: Elaborate in interface stability README This discussion didn't make it into the original MR. - - - - - e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00 Allow users to override non-essential haddock options in a Flavour We now supply the non-essential options to haddock using the `extraArgs` field, which can be specified in a Flavour so that if an advanced user wants to change how documentation is generated then they can use something other than the `defaultHaddockExtraArgs`. This does have the potential to regress some packaging if a user has overridden `extraArgs` themselves, because now they also need to add the haddock options to extraArgs. This can easily be done by appending `defaultHaddockExtraArgs` to their extraArgs invocation but someone might not notice this behaviour has changed. In any case, I think passing the non-essential options in this manner is the right thing to do and matches what we do for the "ghc" builder, which by default doesn't pass any optmisation levels, and would likewise be very bad if someone didn't pass suitable `-O` levels for builds. Fixes #23625 - - - - - fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00 ghc-prim: Link against libatomic Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures. Unfortunately this made GHC to fail to build on armel, since armel needs libatomic to support atomic operations on 64-bit word sizes. Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic, the same way as we do in rts/rts.cabal. - - - - - 4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00 simplifier: Correct InScopeSet in rule matching The in-scope set passedto the `exprIsLambda_maybe` call lacked all the in-scope binders. @simonpj suggests this fix where we augment the in-scope set with the free variables of expression which fixes this failure mode in quite a direct way. Fixes #23630 - - - - - 5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00 Add a test for #23413 It was fixed by commit e1590ddc661d6: Add the SolverStage monad. - - - - - 7e05f6df by sheaf at 2023-07-21T23:26:56-04:00 Finish migration of diagnostics in GHC.Tc.Validity This patch finishes migrating the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It also refactors the error message datatypes for class and family instances, to common them up under a single datatype as much as possible. - - - - - 4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00 ci: Enable some more jobs to run in a marge batch In !10907 I made the majority of jobs not run on a validate pipeline but then forgot to renable a select few jobs on the marge batch MR. - - - - - 026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00 user_guide/flags.py: python-3.12 no longer includes distutils packaging.version seems able to handle this fine - - - - - b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00 ci: Mention ~full-ci label in MR template We mention that if you need a full validation pipeline then you can apply the ~full-ci label to your MR in order to test against the full validation pipeline (like we do for marge). - - - - - 42b05e9b by sheaf at 2023-07-22T12:36:00-04:00 RTS: declare setKeepCAFs symbol Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on the symbol setKeepCAFs in the RTS, which led to undefined symbol errors on Windows, as exhibited by the testcase frontend001. Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix. Fixes #22961 - - - - - a72015d6 by sheaf at 2023-07-22T12:36:01-04:00 Mark plugins-external as broken on Windows This test is broken on Windows, so we explicitly mark it as such now that we stop skipping plugin tests on Windows. - - - - - cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00 Stop marking plugin tests as fragile on Windows Now that b2bb3e62 has landed we are in a better situation with regards to plugins on Windows, allowing us to unmark many plugin tests as fragile. Fixes #16405 - - - - - a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00 Misc cleanup - Remove unused RDR names - Fix typos in comments - Deriving: simplify boxConTbl and remove unused litConTbl - chmod -x GHC/Exts.hs, this seems accidental - - - - - 33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00 Visible forall in types of terms: Part 1 (#22326) This patch implements part 1 of GHC Proposal #281, introducing explicit `type` patterns and `type` arguments. Summary of the changes: 1. New extension flag: RequiredTypeArguments 2. New user-facing syntax: `type p` patterns (represented by EmbTyPat) `type e` expressions (represented by HsEmbTy) 3. Functions with required type arguments (visible forall) can now be defined and applied: idv :: forall a -> a -> a -- signature (relevant change: checkVdqOK in GHC/Tc/Validity.hs) idv (type a) (x :: a) = x -- definition (relevant change: tcPats in GHC/Tc/Gen/Pat.hs) x = idv (type Int) 42 -- usage (relevant change: tcInstFun in GHC/Tc/Gen/App.hs) 4. template-haskell support: TH.TypeE corresponds to HsEmbTy TH.TypeP corresponds to EmbTyPat 5. Test cases and a new User's Guide section Changes *not* included here are the t2t (term-to-type) transformation and term variable capture; those belong to part 2. - - - - - 73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00 Add test for #22424 This is a simple Template Haskell test in which we refer to record selectors by their exact Names, in two different ways. Fixes #22424 - - - - - 83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00 ghc-toolchain: Initial commit - - - - - 31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 ghc-toolchain: Toolchain Selection This commit integrates ghc-toolchain, the brand new way of configuring toolchains for GHC, with the Hadrian build system, with configure, and extends and improves the first iteration of ghc-toolchain. The general overview is * We introduce a program invoked `ghc-toolchain --triple=...` which, when run, produces a file with a `Target`. A `GHC.Toolchain.Target.Target` describes the properties of a target and the toolchain (executables and configured flags) to produce code for that target * Hadrian was modified to read Target files, and will both * Invoke the toolchain configured in the Target file as needed * Produce a `settings` file for GHC based on the Target file for that stage * `./configure` will invoke ghc-toolchain to generate target files, but it will also generate target files based on the flags configure itself configured (through `.in` files that are substituted) * By default, the Targets generated by configure are still (for now) the ones used by Hadrian * But we additionally validate the Target files generated by ghc-toolchain against the ones generated by configure, to get a head start on catching configuration bugs before we transition completely. * When we make that transition, we will want to drop a lot of the toolchain configuration logic from configure, but keep it otherwise. * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine) * We just have a HOST target file, which we use as the target for stage0 * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling) * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST * (for more details on cross-compilation see discussion on !9263) See also * Note [How we configure the bundled windows toolchain] * Note [ghc-toolchain consistency checking] * Note [ghc-toolchain overview] Ticket: #19877 MR: !9263 - - - - - a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Add flag to enable/disable ghc-toolchain based configurations This flag is disabled by default, and we'll use the configure-generated-toolchains by default until we remove the toolchain configuration logic from configure. - - - - - 61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Split ghc-toolchain executable to new packge In light of #23690, we split the ghc-toolchain executable out of the library package to be able to ship it in the bindist using Hadrian. Ideally, we eventually revert this commit. - - - - - 38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Ship ghc-toolchain in the bindist Add the ghc-toolchain binary to the binary distribution we ship to users, and teach the bindist configure to use the existing ghc-toolchain. - - - - - 32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00 Kill off gen_bytearray_addr_access_ops.py The relevant primop descriptions are now generated directly by genprimopcode. This makes progress toward fixing #23490, but it is not a complete fix since there is more than one way in which cabal-reinstall (hadrian/build build-cabal) is broken. - - - - - 02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00 compiler: Remove unused `containers.h` include Fixes #23712 - - - - - 822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00 Fix pretty printing of WARNING pragmas There is still something quite unsavoury going on with WARNING pragma printing because the printing relies on the fact that for decl deprecations the SourceText of WarningTxt is empty. However, I let that lion sleep and just fixed things directly. Fixes #23465 - - - - - e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00 ci-images: Bump to commit which has 9.6 image The test-bootstrap job has been failing for 9.6 because we accidentally used a non-master commit. - - - - - bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00 Update bootstrap plans for 9.6.2 and 9.4.5 - - - - - 355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00 EPA: Simplify GHC/Parser.y comb4/comb5 Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with anything with a SrcSpan Also get rid of some more now unnecessary reLoc calls. - - - - - 9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00 compiler: make -ddump-asm work with wasm backend NCG Fixes #23503. Now the `-ddump-asm` flag is respected in the wasm backend NCG, so developers can directly view the generated ASM instead of needing to pass `-S` or `-keep-tmp-files` and manually find & open the assembly file. Ideally, we should be able to output the assembly files in smaller chunks like in other NCG backends. This would also make dumping assembly stats easier. However, this would require a large refactoring, so for short-term debugging purposes I think the current approach works fine. Signed-off-by: Gavin Zhao <git at gzgz.dev> - - - - - 79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00 llvm: Restore accidentally deleted code in 0fc5cb97 Fixes #23711 - - - - - 20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00 configure: Default missing options to False when preparing ghc-toolchain Targets This commit fixes building ghc with 9.2 as the boostrap compiler. The ghc-toolchain patch assumed all _STAGE0 options were available, and forgot to account for this missing information in 9.2. Ghc 9.2 does not have in settings whether ar supports -l, hence can't report it with --info (unliked 9.4 upwards). The fix is to default the missing information (we default "ar supports -l" and other missing options to False) - - - - - fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00 docs: Fix typo - - - - - 503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00 This MR is an implementation of the proposal #516. It adds a warning -Wincomplete-record-selectors for usages of a record field access function (either a record selector or getField @"rec"), while trying to silence the warning whenever it can be sure that a constructor without the record field would not be invoked (which would otherwise cause the program to fail). For example: data T = T1 | T2 {x :: Bool} f a = x a -- this would throw an error g T1 = True g a = x a -- this would not throw an error h :: HasField "x" r Bool => r -> Bool h = getField @"x" j :: T -> Bool j = h -- this would throw an error because of the `HasField` -- constraint being solved See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning. See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details - - - - - af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00 Fix user-facing label in MR template - - - - - 5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00 ci: Test bootstrapping configurations with full-ci and on marge batches There have been two incidents recently where bootstrapping has been broken by removing support for building with 9.2.*. The process for bumping the minimum required version starts with bumping the configure version and then other CI jobs such as the bootstrap jobs have to be updated. We must not silently bump the minimum required version. Now we are running a slimmed down validate pipeline it seems worthwile to test these bootstrap configurations in the full-ci pipeline. - - - - - 25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Remove ghc-9_2_* plans We are anticipating shortly making it necessary to use ghc-9.4 to boot the compiler. - - - - - 2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00 Update bootstrap plans for ghc-platform and ghc-toolchain dependencies Fixes #23735 - - - - - c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Disable -selftest flag from bootstrap plans This saves on building one dependency (QuickCheck) which is unecessary for bootstrapping. - - - - - a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00 Link reference paper and package from System.Mem.{StableName,Weak} - - - - - a5319358 by David Knothe at 2023-07-28T13:13:10-04:00 Update Match Datatype EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation. All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list. We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows: data EquationInfo = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo } | EqnDone { eqn_rhs = MatchResult CoreExpr } An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated. - - - - - 86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00 Improve documentation for Data.Fixed - - - - - f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00 ghc-prim: Use C11 atomics Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*` family of C builtins. Here we refactor these to rather use the appropriate C11 atomic equivalents, allowing us to be more explicit about the expected ordering semantics. - - - - - 0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00 Include -haddock in DynFlags fingerprint The -haddock flag determines whether or not the resulting .hi files contain haddock documentation strings. If the existing .hi files do not contain haddock documentation strings and the user requests them, we should recompile. - - - - - 40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00 Bump filepath submodule to 1.4.100.4 Resolves #23741 Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T12234 T12425 T13035 T13701 T13719 T16875 T18304 T18698a T18698b T21839c T9198 TcPlugin_RewritePerf hard_hole_fits Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183 - - - - - ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00 Add since pragmas to GHC.IO.Handle.FD - - - - - d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00 Make the occurrence analyser smarter about join points This MR addresses #22404. There is a big Note Note [Occurrence analysis for join points] that explains it all. Significant changes * New field occ_join_points in OccEnv * The NonRec case of occAnalBind splits into two cases: one for existing join points (which does the special magic for Note [Occurrence analysis for join points], and one for other bindings. * mkOneOcc adds in info from occ_join_points. * All "bring into scope" activity is centralised in the new function `addInScope`. * I made a local data type LocalOcc for use inside the occurrence analyser It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn makes computationns over it simpler and more efficient. * I found quite a bit of allocation in GHC.Core.Rules.getRules so I optimised it a bit. More minor changes * I found I was using (Maybe Arity) a lot, so I defined a new data type JoinPointHood and used it everwhere. This touches a lot of non-occ-anal files, but it makes everything more perspicuous. * Renamed data constructor WithUsageDetails to WUD, and WithTailUsageDetails to WTUD This also fixes #21128, on the way. --------- Compiler perf ----------- I spent quite a time on performance tuning, so even though it does more than before, the occurrence analyser runs slightly faster on average. Here are the compile-time allocation changes over 0.5% CoOpt_Read(normal) ghc/alloc 766,025,520 754,561,992 -1.5% CoOpt_Singletons(normal) ghc/alloc 759,436,840 762,925,512 +0.5% LargeRecord(normal) ghc/alloc 1,814,482,440 1,799,530,456 -0.8% PmSeriesT(normal) ghc/alloc 68,159,272 67,519,720 -0.9% T10858(normal) ghc/alloc 120,805,224 118,746,968 -1.7% T11374(normal) ghc/alloc 164,901,104 164,070,624 -0.5% T11545(normal) ghc/alloc 79,851,808 78,964,704 -1.1% T12150(optasm) ghc/alloc 73,903,664 71,237,544 -3.6% GOOD T12227(normal) ghc/alloc 333,663,200 331,625,864 -0.6% T12234(optasm) ghc/alloc 52,583,224 52,340,344 -0.5% T12425(optasm) ghc/alloc 81,943,216 81,566,720 -0.5% T13056(optasm) ghc/alloc 294,517,928 289,642,512 -1.7% T13253-spj(normal) ghc/alloc 118,271,264 59,859,040 -49.4% GOOD T15164(normal) ghc/alloc 1,102,630,352 1,091,841,296 -1.0% T15304(normal) ghc/alloc 1,196,084,000 1,166,733,000 -2.5% T15630(normal) ghc/alloc 148,729,632 147,261,064 -1.0% T15703(normal) ghc/alloc 379,366,664 377,600,008 -0.5% T16875(normal) ghc/alloc 32,907,120 32,670,976 -0.7% T17516(normal) ghc/alloc 1,658,001,888 1,627,863,848 -1.8% T17836(normal) ghc/alloc 395,329,400 393,080,248 -0.6% T18140(normal) ghc/alloc 71,968,824 73,243,040 +1.8% T18223(normal) ghc/alloc 456,852,568 453,059,088 -0.8% T18282(normal) ghc/alloc 129,105,576 131,397,064 +1.8% T18304(normal) ghc/alloc 71,311,712 70,722,720 -0.8% T18698a(normal) ghc/alloc 208,795,112 210,102,904 +0.6% T18698b(normal) ghc/alloc 230,320,736 232,697,976 +1.0% BAD T19695(normal) ghc/alloc 1,483,648,128 1,504,702,976 +1.4% T20049(normal) ghc/alloc 85,612,024 85,114,376 -0.6% T21839c(normal) ghc/alloc 415,080,992 410,906,216 -1.0% GOOD T4801(normal) ghc/alloc 247,590,920 250,726,272 +1.3% T6048(optasm) ghc/alloc 95,699,416 95,080,680 -0.6% T783(normal) ghc/alloc 335,323,384 332,988,120 -0.7% T9233(normal) ghc/alloc 709,641,224 685,947,008 -3.3% GOOD T9630(normal) ghc/alloc 965,635,712 948,356,120 -1.8% T9675(optasm) ghc/alloc 444,604,152 428,987,216 -3.5% GOOD T9961(normal) ghc/alloc 303,064,592 308,798,800 +1.9% BAD WWRec(normal) ghc/alloc 503,728,832 498,102,272 -1.1% geo. mean -1.0% minimum -49.4% maximum +1.9% In fact these figures seem to vary between platforms; generally worse on i386 for some reason. The Windows numbers vary by 1% espec in benchmarks where the total allocation is low. But the geom mean stays solidly negative, which is good. The "increase/decrease" list below covers all platforms. The big win on T13253-spj comes because it has a big nest of join points, each occurring twice in the next one. The new occ-anal takes only one iteration of the simplifier to do the inlining; the old one took four. Moreover, we get much smaller code with the new one: New: Result size of Tidy Core = {terms: 429, types: 84, coercions: 0, joins: 14/14} Old: Result size of Tidy Core = {terms: 2,437, types: 304, coercions: 0, joins: 10/10} --------- Runtime perf ----------- No significant changes in nofib results, except a 1% reduction in compiler allocation. Metric Decrease: CoOpt_Read T13253-spj T9233 T9630 T9675 T12150 T21839c LargeRecord MultiComponentModulesRecomp T10421 T13701 T10421 T13701 T12425 Metric Increase: T18140 T9961 T18282 T18698a T18698b T19695 - - - - - 42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00 Improve documentation around IOException and ioe_filename See: * https://github.com/haskell/core-libraries-committee/issues/189 * https://github.com/haskell/unix/pull/279 * https://github.com/haskell/unix/pull/289 - - - - - 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 20 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - − .gitlab/circle-ci-job.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - + .gitlab/generate-ci/LICENSE - + .gitlab/generate-ci/README.mkd - + .gitlab/generate-ci/flake.lock - + .gitlab/generate-ci/flake.nix - .gitlab/gen_ci.hs → .gitlab/generate-ci/gen_ci.hs - + .gitlab/generate-ci/generate-ci.cabal - + .gitlab/generate-ci/generate-job-metadata - + .gitlab/generate-ci/generate-jobs - + .gitlab/generate-ci/hie.yaml - − .gitlab/generate_jobs - + .gitlab/hello.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5cb4384036ed14d62a1b8113fc93c31f79119b5e...bc2047834c8e6fb5041d257b5bfe0f1402e3ef28 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5cb4384036ed14d62a1b8113fc93c31f79119b5e...bc2047834c8e6fb5041d257b5bfe0f1402e3ef28 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 12:52:52 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 02 Oct 2023 08:52:52 -0400 Subject: [Git][ghc/ghc][wip/andreask/zero_reg] rts: Split up rts/include/stg/MachRegs.h by arch Message-ID: <651abd24c3eac_364e041065ee641395ab@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/zero_reg at Glasgow Haskell Compiler / GHC Commits: 3609031c by Andreas Klebinger at 2023-10-02T14:52:26+02:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 15 changed files: - .gitignore - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/ghc.cabal.in - configure.ac - rts/include/stg/MachRegs.h - + rts/include/stg/MachRegs/arm32.h - + rts/include/stg/MachRegs/arm64.h - + rts/include/stg/MachRegs/loongarch64.h - + rts/include/stg/MachRegs/ppc.h - + rts/include/stg/MachRegs/riscv64.h - + rts/include/stg/MachRegs/s390x.h - + rts/include/stg/MachRegs/wasm32.h - + rts/include/stg/MachRegs/x86.h - rts/rts.cabal.in Changes: ===================================== .gitignore ===================================== @@ -111,6 +111,7 @@ _darcs/ /compiler/ClosureTypes.h /compiler/FunTypes.h /compiler/MachRegs.h +/compiler/MachRegs /compiler/ghc-llvm-version.h /compiler/ghc.cabal /compiler/ghc.cabal.old ===================================== compiler/CodeGen.Platform.h ===================================== @@ -480,6 +480,7 @@ import GHC.Platform.Reg #endif +-- See also Note [Caller saves and callee-saves regs.] callerSaves :: GlobalReg -> Bool #if defined(CALLER_SAVES_Base) callerSaves BaseReg = True ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -15,7 +15,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnboxedTuples #-} --- | Native code generator +-- | Note [Native code generator] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- The native-code generator has machine-independent and -- machine-dependent modules. @@ -23,45 +24,39 @@ -- This module ("GHC.CmmToAsm") is the top-level machine-independent -- module. Before entering machine-dependent land, we do some -- machine-independent optimisations (defined below) on the --- 'CmmStmts's. +-- 'CmmStmts's. (Which ideally would be folded into CmmOpt ...) -- -- We convert to the machine-specific 'Instr' datatype with -- 'cmmCodeGen', assuming an infinite supply of registers. We then use --- a machine-independent register allocator ('regAlloc') to rejoin +-- a (mostly) machine-independent register allocator to rejoin -- reality. Obviously, 'regAlloc' has machine-specific helper --- functions (see about "RegAllocInfo" below). +-- functions (see the used register allocator for details). -- -- Finally, we order the basic blocks of the function so as to minimise -- the number of jumps between blocks, by utilising fallthrough wherever -- possible. -- --- The machine-dependent bits break down as follows: +-- The machine-dependent bits are generally contained under +-- GHC/CmmToAsm//* and generally breaks down as follows: -- --- * ["MachRegs"] Everything about the target platform's machine +-- * "Regs": Everything about the target platform's machine -- registers (and immediate operands, and addresses, which tend to -- intermingle/interact with registers). -- --- * ["MachInstrs"] Includes the 'Instr' datatype (possibly should --- have a module of its own), plus a miscellany of other things +-- * "Instr": Includes the 'Instr' datatype plus a miscellany of other things -- (e.g., 'targetDoubleSize', 'smStablePtrTable', ...) -- --- * ["MachCodeGen"] is where 'Cmm' stuff turns into +-- * "CodeGen": is where 'Cmm' stuff turns into -- machine instructions. -- --- * ["PprMach"] 'pprInstr' turns an 'Instr' into text (well, really +-- * "Ppr": 'pprInstr' turns an 'Instr' into text (well, really -- a 'SDoc'). -- --- * ["RegAllocInfo"] In the register allocator, we manipulate --- 'MRegsState's, which are 'BitSet's, one bit per machine register. --- When we want to say something about a specific machine register --- (e.g., ``it gets clobbered by this instruction''), we set/unset --- its bit. Obviously, we do this 'BitSet' thing for efficiency --- reasons. +-- The register allocators lives under GHC.CmmToAsm.Reg.*, there is both a Linear and a Graph +-- based register allocator. Both of which have their own notes describing them. They +-- are mostly platform independent but there are some platform specific files +-- encoding architecture details under Reg// -- --- The 'RegAllocInfo' module collects together the machine-specific --- info needed to do register allocation. --- --- * ["RegisterAlloc"] The (machine-independent) register allocator. -- -} -- module GHC.CmmToAsm ===================================== compiler/ghc.cabal.in ===================================== @@ -34,6 +34,14 @@ extra-source-files: ClosureTypes.h FunTypes.h MachRegs.h + MachRegs/arm32.h + MachRegs/arm64.h + MachRegs/loongarch64.h + MachRegs/ppc.h + MachRegs/riscv64.h + MachRegs/s390x.h + MachRegs/wasm32.h + MachRegs/x86.h ghc-llvm-version.h ===================================== configure.ac ===================================== @@ -578,6 +578,15 @@ ln -f rts/include/rts/Bytecodes.h compiler/ ln -f rts/include/rts/storage/ClosureTypes.h compiler/ ln -f rts/include/rts/storage/FunTypes.h compiler/ ln -f rts/include/stg/MachRegs.h compiler/ +mkdir -p compiler/MachRegs +ln -f rts/include/stg/MachRegs/arm32.h compiler/MachRegs/arm32.h +ln -f rts/include/stg/MachRegs/arm64.h compiler/MachRegs/arm64.h +ln -f rts/include/stg/MachRegs/loongarch64.h compiler/MachRegs/loongarch64.h +ln -f rts/include/stg/MachRegs/ppc.h compiler/MachRegs/ppc.h +ln -f rts/include/stg/MachRegs/riscv64.h compiler/MachRegs/riscv64.h +ln -f rts/include/stg/MachRegs/s390x.h compiler/MachRegs/s390x.h +ln -f rts/include/stg/MachRegs/wasm32.h compiler/MachRegs/wasm32.h +ln -f rts/include/stg/MachRegs/x86.h compiler/MachRegs/x86.h AC_MSG_NOTICE([done.]) dnl ** Copy the files from the "fs" utility into the right folders. ===================================== rts/include/stg/MachRegs.h ===================================== @@ -51,637 +51,54 @@ #elif MACHREGS_NO_REGS == 0 /* ---------------------------------------------------------------------------- - Caller saves and callee-saves regs. - + Note [Caller saves and callee-saves regs.] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Caller-saves regs have to be saved around C-calls made from STG land, so this file defines CALLER_SAVES_ for each that is designated caller-saves in that machine's C calling convention. + NB: Caller-saved registers not mapped to a STG register don't + require a CALLER_SAVES_ define. As it stands, the only registers that are ever marked caller saves - are the RX, FX, DX and USER registers; as a result, if you + are the RX, FX, DX, XMM and USER registers; as a result, if you decide to caller save a system register (e.g. SP, HP, etc), note that this code path is completely untested! -- EZY See Note [Register parameter passing] for details. -------------------------------------------------------------------------- */ -/* ----------------------------------------------------------------------------- - The x86 register mapping - - Ok, we've only got 6 general purpose registers, a frame pointer and a - stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, - hence they get trashed across ccalls and are caller saves. \tr{%ebx}, - \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. - - Reg STG-Reg - --------------- - ebx Base - ebp Sp - esi R1 - edi Hp - - Leaving SpLim out of the picture. - -------------------------------------------------------------------------- */ - -#if defined(MACHREGS_i386) - -#define REG(x) __asm__("%" #x) - -#if !defined(not_doing_dynamic_linking) -#define REG_Base ebx -#endif -#define REG_Sp ebp - -#if !defined(STOLEN_X86_REGS) -#define STOLEN_X86_REGS 4 -#endif - -#if STOLEN_X86_REGS >= 3 -# define REG_R1 esi -#endif - -#if STOLEN_X86_REGS >= 4 -# define REG_Hp edi -#endif -#define REG_MachSp esp - -#define REG_XMM1 xmm0 -#define REG_XMM2 xmm1 -#define REG_XMM3 xmm2 -#define REG_XMM4 xmm3 - -#define REG_YMM1 ymm0 -#define REG_YMM2 ymm1 -#define REG_YMM3 ymm2 -#define REG_YMM4 ymm3 - -#define REG_ZMM1 zmm0 -#define REG_ZMM2 zmm1 -#define REG_ZMM3 zmm2 -#define REG_ZMM4 zmm3 - -#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ -#define MAX_REAL_FLOAT_REG 0 -#define MAX_REAL_DOUBLE_REG 0 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 4 -#define MAX_REAL_YMM_REG 4 -#define MAX_REAL_ZMM_REG 4 - -/* ----------------------------------------------------------------------------- - The x86-64 register mapping - - %rax caller-saves, don't steal this one - %rbx YES - %rcx arg reg, caller-saves - %rdx arg reg, caller-saves - %rsi arg reg, caller-saves - %rdi arg reg, caller-saves - %rbp YES (our *prime* register) - %rsp (unavailable - stack pointer) - %r8 arg reg, caller-saves - %r9 arg reg, caller-saves - %r10 caller-saves - %r11 caller-saves - %r12 YES - %r13 YES - %r14 YES - %r15 YES - - %xmm0-7 arg regs, caller-saves - %xmm8-15 caller-saves - - Use the caller-saves regs for Rn, because we don't always have to - save those (as opposed to Sp/Hp/SpLim etc. which always have to be - saved). - - --------------------------------------------------------------------------- */ - -#elif defined(MACHREGS_x86_64) - -#define REG(x) __asm__("%" #x) - -#define REG_Base r13 -#define REG_Sp rbp -#define REG_Hp r12 -#define REG_R1 rbx -#define REG_R2 r14 -#define REG_R3 rsi -#define REG_R4 rdi -#define REG_R5 r8 -#define REG_R6 r9 -#define REG_SpLim r15 -#define REG_MachSp rsp - -/* -Map both Fn and Dn to register xmmn so that we can pass a function any -combination of up to six Float# or Double# arguments without touching -the stack. See Note [Overlapping global registers] for implications. -*/ - -#define REG_F1 xmm1 -#define REG_F2 xmm2 -#define REG_F3 xmm3 -#define REG_F4 xmm4 -#define REG_F5 xmm5 -#define REG_F6 xmm6 - -#define REG_D1 xmm1 -#define REG_D2 xmm2 -#define REG_D3 xmm3 -#define REG_D4 xmm4 -#define REG_D5 xmm5 -#define REG_D6 xmm6 - -#define REG_XMM1 xmm1 -#define REG_XMM2 xmm2 -#define REG_XMM3 xmm3 -#define REG_XMM4 xmm4 -#define REG_XMM5 xmm5 -#define REG_XMM6 xmm6 - -#define REG_YMM1 ymm1 -#define REG_YMM2 ymm2 -#define REG_YMM3 ymm3 -#define REG_YMM4 ymm4 -#define REG_YMM5 ymm5 -#define REG_YMM6 ymm6 - -#define REG_ZMM1 zmm1 -#define REG_ZMM2 zmm2 -#define REG_ZMM3 zmm3 -#define REG_ZMM4 zmm4 -#define REG_ZMM5 zmm5 -#define REG_ZMM6 zmm6 - -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_R3 -#define CALLER_SAVES_R4 -#endif -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 - -#define CALLER_SAVES_F1 -#define CALLER_SAVES_F2 -#define CALLER_SAVES_F3 -#define CALLER_SAVES_F4 -#define CALLER_SAVES_F5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_F6 -#endif - -#define CALLER_SAVES_D1 -#define CALLER_SAVES_D2 -#define CALLER_SAVES_D3 -#define CALLER_SAVES_D4 -#define CALLER_SAVES_D5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_D6 -#endif - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 -#define CALLER_SAVES_XMM3 -#define CALLER_SAVES_XMM4 -#define CALLER_SAVES_XMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_XMM6 -#endif - -#define CALLER_SAVES_YMM1 -#define CALLER_SAVES_YMM2 -#define CALLER_SAVES_YMM3 -#define CALLER_SAVES_YMM4 -#define CALLER_SAVES_YMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_YMM6 -#endif - -#define CALLER_SAVES_ZMM1 -#define CALLER_SAVES_ZMM2 -#define CALLER_SAVES_ZMM3 -#define CALLER_SAVES_ZMM4 -#define CALLER_SAVES_ZMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_ZMM6 -#endif - -#define MAX_REAL_VANILLA_REG 6 -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 6 -#define MAX_REAL_YMM_REG 6 -#define MAX_REAL_ZMM_REG 6 - -/* ----------------------------------------------------------------------------- - The PowerPC register mapping - - 0 system glue? (caller-save, volatile) - 1 SP (callee-save, non-volatile) - 2 AIX, powerpc64-linux: - RTOC (a strange special case) - powerpc32-linux: - reserved for use by system +/* Define STG <-> machine register mappings. */ +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) - 3-10 args/return (caller-save, volatile) - 11,12 system glue? (caller-save, volatile) - 13 on 64-bit: reserved for thread state pointer - on 32-bit: (callee-save, non-volatile) - 14-31 (callee-save, non-volatile) - - f0 (caller-save, volatile) - f1-f13 args/return (caller-save, volatile) - f14-f31 (callee-save, non-volatile) - - \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. - \tr{0}--\tr{12} are caller-save registers. - - \tr{%f14}--\tr{%f31} are callee-save floating-point registers. - - We can do the Whole Business with callee-save registers only! - -------------------------------------------------------------------------- */ +#include "MachRegs/x86.h" #elif defined(MACHREGS_powerpc) -#define REG(x) __asm__(#x) - -#define REG_R1 r14 -#define REG_R2 r15 -#define REG_R3 r16 -#define REG_R4 r17 -#define REG_R5 r18 -#define REG_R6 r19 -#define REG_R7 r20 -#define REG_R8 r21 -#define REG_R9 r22 -#define REG_R10 r23 - -#define REG_F1 fr14 -#define REG_F2 fr15 -#define REG_F3 fr16 -#define REG_F4 fr17 -#define REG_F5 fr18 -#define REG_F6 fr19 - -#define REG_D1 fr20 -#define REG_D2 fr21 -#define REG_D3 fr22 -#define REG_D4 fr23 -#define REG_D5 fr24 -#define REG_D6 fr25 - -#define REG_Sp r24 -#define REG_SpLim r25 -#define REG_Hp r26 -#define REG_Base r27 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 - -/* ----------------------------------------------------------------------------- - The ARM EABI register mapping - - Here we consider ARM mode (i.e. 32bit isns) - and also CPU with full VFPv3 implementation - - ARM registers (see Chapter 5.1 in ARM IHI 0042D and - Section 9.2.2 in ARM Software Development Toolkit Reference Guide) - - r15 PC The Program Counter. - r14 LR The Link Register. - r13 SP The Stack Pointer. - r12 IP The Intra-Procedure-call scratch register. - r11 v8/fp Variable-register 8. - r10 v7/sl Variable-register 7. - r9 v6/SB/TR Platform register. The meaning of this register is - defined by the platform standard. - r8 v5 Variable-register 5. - r7 v4 Variable register 4. - r6 v3 Variable register 3. - r5 v2 Variable register 2. - r4 v1 Variable register 1. - r3 a4 Argument / scratch register 4. - r2 a3 Argument / scratch register 3. - r1 a2 Argument / result / scratch register 2. - r0 a1 Argument / result / scratch register 1. - - VFPv2/VFPv3/NEON registers - s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers - s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across - subroutine calls) - - VFPv3/NEON registers (added to the VFPv2 registers set) - d16-d31/q8-q15 Argument / result/ scratch registers - ----------------------------------------------------------------------------- */ +#include "MachRegs/ppc.h" #elif defined(MACHREGS_arm) -#define REG(x) __asm__(#x) - -#define REG_Base r4 -#define REG_Sp r5 -#define REG_Hp r6 -#define REG_R1 r7 -#define REG_R2 r8 -#define REG_R3 r9 -#define REG_R4 r10 -#define REG_SpLim r11 - -#if !defined(arm_HOST_ARCH_PRE_ARMv6) -/* d8 */ -#define REG_F1 s16 -#define REG_F2 s17 -/* d9 */ -#define REG_F3 s18 -#define REG_F4 s19 - -#define REG_D1 d10 -#define REG_D2 d11 -#endif - -/* ----------------------------------------------------------------------------- - The ARMv8/AArch64 ABI register mapping - - The AArch64 provides 31 64-bit general purpose registers - and 32 128-bit SIMD/floating point registers. - - General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) - - Register | Special | Role in the procedure call standard - ---------+---------+------------------------------------ - SP | | The Stack Pointer - r30 | LR | The Link Register - r29 | FP | The Frame Pointer - r19-r28 | | Callee-saved registers - r18 | | The Platform Register, if needed; - | | or temporary register - r17 | IP1 | The second intra-procedure-call temporary register - r16 | IP0 | The first intra-procedure-call scratch register - r9-r15 | | Temporary registers - r8 | | Indirect result location register - r0-r7 | | Parameter/result registers - - - FPU/SIMD registers - - s/d/q/v0-v7 Argument / result/ scratch registers - s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, - but only bottom 64-bit value needs to be preserved) - s/d/q/v16-v31 temporary registers - - ----------------------------------------------------------------------------- */ +#include "MachRegs/arm32.h" #elif defined(MACHREGS_aarch64) -#define REG(x) __asm__(#x) - -#define REG_Base r19 -#define REG_Sp r20 -#define REG_Hp r21 -#define REG_R1 r22 -#define REG_R2 r23 -#define REG_R3 r24 -#define REG_R4 r25 -#define REG_R5 r26 -#define REG_R6 r27 -#define REG_SpLim r28 - -#define REG_F1 s8 -#define REG_F2 s9 -#define REG_F3 s10 -#define REG_F4 s11 - -#define REG_D1 d12 -#define REG_D2 d13 -#define REG_D3 d14 -#define REG_D4 d15 - -#define REG_XMM1 q4 -#define REG_XMM2 q5 - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 - -/* ----------------------------------------------------------------------------- - The s390x register mapping - - Register | Role(s) | Call effect - ------------+-------------------------------------+----------------- - r0,r1 | - | caller-saved - r2 | Argument / return value | caller-saved - r3,r4,r5 | Arguments | caller-saved - r6 | Argument | callee-saved - r7...r11 | - | callee-saved - r12 | (Commonly used as GOT pointer) | callee-saved - r13 | (Commonly used as literal pool pointer) | callee-saved - r14 | Return address | caller-saved - r15 | Stack pointer | callee-saved - f0 | Argument / return value | caller-saved - f2,f4,f6 | Arguments | caller-saved - f1,f3,f5,f7 | - | caller-saved - f8...f15 | - | callee-saved - v0...v31 | - | caller-saved - - Each general purpose register r0 through r15 as well as each floating-point - register f0 through f15 is 64 bits wide. Each vector register v0 through v31 - is 128 bits wide. - - Note, the vector registers v0 through v15 overlap with the floating-point - registers f0 through f15. - - -------------------------------------------------------------------------- */ +#include "MachRegs/arm64.h" #elif defined(MACHREGS_s390x) -#define REG(x) __asm__("%" #x) - -#define REG_Base r7 -#define REG_Sp r8 -#define REG_Hp r10 -#define REG_R1 r11 -#define REG_R2 r12 -#define REG_R3 r13 -#define REG_R4 r6 -#define REG_R5 r2 -#define REG_R6 r3 -#define REG_R7 r4 -#define REG_R8 r5 -#define REG_SpLim r9 -#define REG_MachSp r15 - -#define REG_F1 f8 -#define REG_F2 f9 -#define REG_F3 f10 -#define REG_F4 f11 -#define REG_F5 f0 -#define REG_F6 f1 - -#define REG_D1 f12 -#define REG_D2 f13 -#define REG_D3 f14 -#define REG_D4 f15 -#define REG_D5 f2 -#define REG_D6 f3 - -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 -#define CALLER_SAVES_R7 -#define CALLER_SAVES_R8 - -#define CALLER_SAVES_F5 -#define CALLER_SAVES_F6 - -#define CALLER_SAVES_D5 -#define CALLER_SAVES_D6 - -/* ----------------------------------------------------------------------------- - The riscv64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - sp | Stack pointer | callee-saved - gp | Global pointer | callee-saved - tp | Thread pointer | callee-saved - t0,t1,t2 | - | caller-saved - s0 | Frame pointer | callee-saved - s1 | - | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - s2..s11 | - | callee-saved - t3..t6 | - | caller-saved - ft0..ft7 | - | caller-saved - fs0,fs1 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - fs2..fs11 | - | callee-saved - ft8..ft11 | - | caller-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide. - - -------------------------------------------------------------------------- */ +#include "MachRegs/s390x.h" #elif defined(MACHREGS_riscv64) -#define REG(x) __asm__(#x) - -#define REG_Base s1 -#define REG_Sp s2 -#define REG_Hp s3 -#define REG_R1 s4 -#define REG_R2 s5 -#define REG_R3 s6 -#define REG_R4 s7 -#define REG_R5 s8 -#define REG_R6 s9 -#define REG_R7 s10 -#define REG_SpLim s11 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 -#define REG_F5 fs4 -#define REG_F6 fs5 - -#define REG_D1 fs6 -#define REG_D2 fs7 -#define REG_D3 fs8 -#define REG_D4 fs9 -#define REG_D5 fs10 -#define REG_D6 fs11 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 +#include "MachRegs/riscv64.h" #elif defined(MACHREGS_wasm32) -#define REG_R1 1 -#define REG_R2 2 -#define REG_R3 3 -#define REG_R4 4 -#define REG_R5 5 -#define REG_R6 6 -#define REG_R7 7 -#define REG_R8 8 -#define REG_R9 9 -#define REG_R10 10 - -#define REG_F1 11 -#define REG_F2 12 -#define REG_F3 13 -#define REG_F4 14 -#define REG_F5 15 -#define REG_F6 16 - -#define REG_D1 17 -#define REG_D2 18 -#define REG_D3 19 -#define REG_D4 20 -#define REG_D5 21 -#define REG_D6 22 - -#define REG_L1 23 - -#define REG_Sp 24 -#define REG_SpLim 25 -#define REG_Hp 26 -#define REG_HpLim 27 -#define REG_CCCS 28 - -/* ----------------------------------------------------------------------------- - The loongarch64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - tp | Thread pointer | - - sp | Stack pointer | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - t0..t8 | - | caller-saved - u0 | Reserve | - - fp | Frame pointer | callee-saved - s0..s8 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - ft0..ft15 | - | caller-saved - fs0..fs7 | - | callee-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide, also, the u0 register is called r21 in some cases. +#include "MachRegs/wasm32.h" - -------------------------------------------------------------------------- */ #elif defined(MACHREGS_loongarch64) -#define REG(x) __asm__("$" #x) - -#define REG_Base s0 -#define REG_Sp s1 -#define REG_Hp s2 -#define REG_R1 s3 -#define REG_R2 s4 -#define REG_R3 s5 -#define REG_R4 s6 -#define REG_R5 s7 -#define REG_SpLim s8 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 - -#define REG_D1 fs4 -#define REG_D2 fs5 -#define REG_D3 fs6 -#define REG_D4 fs7 - -#define MAX_REAL_FLOAT_REG 4 -#define MAX_REAL_DOUBLE_REG 4 +#include "MachRegs/loongarch64.h" #else ===================================== rts/include/stg/MachRegs/arm32.h ===================================== @@ -0,0 +1,60 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The ARM EABI register mapping + + Here we consider ARM mode (i.e. 32bit isns) + and also CPU with full VFPv3 implementation + + ARM registers (see Chapter 5.1 in ARM IHI 0042D and + Section 9.2.2 in ARM Software Development Toolkit Reference Guide) + + r15 PC The Program Counter. + r14 LR The Link Register. + r13 SP The Stack Pointer. + r12 IP The Intra-Procedure-call scratch register. + r11 v8/fp Variable-register 8. + r10 v7/sl Variable-register 7. + r9 v6/SB/TR Platform register. The meaning of this register is + defined by the platform standard. + r8 v5 Variable-register 5. + r7 v4 Variable register 4. + r6 v3 Variable register 3. + r5 v2 Variable register 2. + r4 v1 Variable register 1. + r3 a4 Argument / scratch register 4. + r2 a3 Argument / scratch register 3. + r1 a2 Argument / result / scratch register 2. + r0 a1 Argument / result / scratch register 1. + + VFPv2/VFPv3/NEON registers + s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers + s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across + subroutine calls) + + VFPv3/NEON registers (added to the VFPv2 registers set) + d16-d31/q8-q15 Argument / result/ scratch registers + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r4 +#define REG_Sp r5 +#define REG_Hp r6 +#define REG_R1 r7 +#define REG_R2 r8 +#define REG_R3 r9 +#define REG_R4 r10 +#define REG_SpLim r11 + +#if !defined(arm_HOST_ARCH_PRE_ARMv6) +/* d8 */ +#define REG_F1 s16 +#define REG_F2 s17 +/* d9 */ +#define REG_F3 s18 +#define REG_F4 s19 + +#define REG_D1 d10 +#define REG_D2 d11 +#endif \ No newline at end of file ===================================== rts/include/stg/MachRegs/arm64.h ===================================== @@ -0,0 +1,64 @@ +#pragma once + + +/* ----------------------------------------------------------------------------- + The ARMv8/AArch64 ABI register mapping + + The AArch64 provides 31 64-bit general purpose registers + and 32 128-bit SIMD/floating point registers. + + General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) + + Register | Special | Role in the procedure call standard + ---------+---------+------------------------------------ + SP | | The Stack Pointer + r30 | LR | The Link Register + r29 | FP | The Frame Pointer + r19-r28 | | Callee-saved registers + r18 | | The Platform Register, if needed; + | | or temporary register + r17 | IP1 | The second intra-procedure-call temporary register + r16 | IP0 | The first intra-procedure-call scratch register + r9-r15 | | Temporary registers + r8 | | Indirect result location register + r0-r7 | | Parameter/result registers + + + FPU/SIMD registers + + s/d/q/v0-v7 Argument / result/ scratch registers + s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, + but only bottom 64-bit value needs to be preserved) + s/d/q/v16-v31 temporary registers + + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r19 +#define REG_Sp r20 +#define REG_Hp r21 +#define REG_R1 r22 +#define REG_R2 r23 +#define REG_R3 r24 +#define REG_R4 r25 +#define REG_R5 r26 +#define REG_R6 r27 +#define REG_SpLim r28 + +#define REG_F1 s8 +#define REG_F2 s9 +#define REG_F3 s10 +#define REG_F4 s11 + +#define REG_D1 d12 +#define REG_D2 d13 +#define REG_D3 d14 +#define REG_D4 d15 + +#define REG_XMM1 q4 +#define REG_XMM2 q5 + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 + ===================================== rts/include/stg/MachRegs/loongarch64.h ===================================== @@ -0,0 +1,51 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The loongarch64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + tp | Thread pointer | - + sp | Stack pointer | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + t0..t8 | - | caller-saved + u0 | Reserve | - + fp | Frame pointer | callee-saved + s0..s8 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + ft0..ft15 | - | caller-saved + fs0..fs7 | - | callee-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide, also, the u0 register is called r21 in some cases. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__("$" #x) + +#define REG_Base s0 +#define REG_Sp s1 +#define REG_Hp s2 +#define REG_R1 s3 +#define REG_R2 s4 +#define REG_R3 s5 +#define REG_R4 s6 +#define REG_R5 s7 +#define REG_SpLim s8 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 + +#define REG_D1 fs4 +#define REG_D2 fs5 +#define REG_D3 fs6 +#define REG_D4 fs7 + +#define MAX_REAL_FLOAT_REG 4 +#define MAX_REAL_DOUBLE_REG 4 ===================================== rts/include/stg/MachRegs/ppc.h ===================================== @@ -0,0 +1,65 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The PowerPC register mapping + + 0 system glue? (caller-save, volatile) + 1 SP (callee-save, non-volatile) + 2 AIX, powerpc64-linux: + RTOC (a strange special case) + powerpc32-linux: + reserved for use by system + + 3-10 args/return (caller-save, volatile) + 11,12 system glue? (caller-save, volatile) + 13 on 64-bit: reserved for thread state pointer + on 32-bit: (callee-save, non-volatile) + 14-31 (callee-save, non-volatile) + + f0 (caller-save, volatile) + f1-f13 args/return (caller-save, volatile) + f14-f31 (callee-save, non-volatile) + + \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. + \tr{0}--\tr{12} are caller-save registers. + + \tr{%f14}--\tr{%f31} are callee-save floating-point registers. + + We can do the Whole Business with callee-save registers only! + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__(#x) + +#define REG_R1 r14 +#define REG_R2 r15 +#define REG_R3 r16 +#define REG_R4 r17 +#define REG_R5 r18 +#define REG_R6 r19 +#define REG_R7 r20 +#define REG_R8 r21 +#define REG_R9 r22 +#define REG_R10 r23 + +#define REG_F1 fr14 +#define REG_F2 fr15 +#define REG_F3 fr16 +#define REG_F4 fr17 +#define REG_F5 fr18 +#define REG_F6 fr19 + +#define REG_D1 fr20 +#define REG_D2 fr21 +#define REG_D3 fr22 +#define REG_D4 fr23 +#define REG_D5 fr24 +#define REG_D6 fr25 + +#define REG_Sp r24 +#define REG_SpLim r25 +#define REG_Hp r26 +#define REG_Base r27 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/riscv64.h ===================================== @@ -0,0 +1,61 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The riscv64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + sp | Stack pointer | callee-saved + gp | Global pointer | callee-saved + tp | Thread pointer | callee-saved + t0,t1,t2 | - | caller-saved + s0 | Frame pointer | callee-saved + s1 | - | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + s2..s11 | - | callee-saved + t3..t6 | - | caller-saved + ft0..ft7 | - | caller-saved + fs0,fs1 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + fs2..fs11 | - | callee-saved + ft8..ft11 | - | caller-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base s1 +#define REG_Sp s2 +#define REG_Hp s3 +#define REG_R1 s4 +#define REG_R2 s5 +#define REG_R3 s6 +#define REG_R4 s7 +#define REG_R5 s8 +#define REG_R6 s9 +#define REG_R7 s10 +#define REG_SpLim s11 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 +#define REG_F5 fs4 +#define REG_F6 fs5 + +#define REG_D1 fs6 +#define REG_D2 fs7 +#define REG_D3 fs8 +#define REG_D4 fs9 +#define REG_D5 fs10 +#define REG_D6 fs11 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/s390x.h ===================================== @@ -0,0 +1,72 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The s390x register mapping + + Register | Role(s) | Call effect + ------------+-------------------------------------+----------------- + r0,r1 | - | caller-saved + r2 | Argument / return value | caller-saved + r3,r4,r5 | Arguments | caller-saved + r6 | Argument | callee-saved + r7...r11 | - | callee-saved + r12 | (Commonly used as GOT pointer) | callee-saved + r13 | (Commonly used as literal pool pointer) | callee-saved + r14 | Return address | caller-saved + r15 | Stack pointer | callee-saved + f0 | Argument / return value | caller-saved + f2,f4,f6 | Arguments | caller-saved + f1,f3,f5,f7 | - | caller-saved + f8...f15 | - | callee-saved + v0...v31 | - | caller-saved + + Each general purpose register r0 through r15 as well as each floating-point + register f0 through f15 is 64 bits wide. Each vector register v0 through v31 + is 128 bits wide. + + Note, the vector registers v0 through v15 overlap with the floating-point + registers f0 through f15. + + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__("%" #x) + +#define REG_Base r7 +#define REG_Sp r8 +#define REG_Hp r10 +#define REG_R1 r11 +#define REG_R2 r12 +#define REG_R3 r13 +#define REG_R4 r6 +#define REG_R5 r2 +#define REG_R6 r3 +#define REG_R7 r4 +#define REG_R8 r5 +#define REG_SpLim r9 +#define REG_MachSp r15 + +#define REG_F1 f8 +#define REG_F2 f9 +#define REG_F3 f10 +#define REG_F4 f11 +#define REG_F5 f0 +#define REG_F6 f1 + +#define REG_D1 f12 +#define REG_D2 f13 +#define REG_D3 f14 +#define REG_D4 f15 +#define REG_D5 f2 +#define REG_D6 f3 + +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 +#define CALLER_SAVES_R7 +#define CALLER_SAVES_R8 + +#define CALLER_SAVES_F5 +#define CALLER_SAVES_F6 + +#define CALLER_SAVES_D5 +#define CALLER_SAVES_D6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/wasm32.h ===================================== ===================================== rts/include/stg/MachRegs/x86.h ===================================== @@ -0,0 +1,210 @@ +/* ----------------------------------------------------------------------------- + The x86 register mapping + + Ok, we've only got 6 general purpose registers, a frame pointer and a + stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, + hence they get trashed across ccalls and are caller saves. \tr{%ebx}, + \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. + + Reg STG-Reg + --------------- + ebx Base + ebp Sp + esi R1 + edi Hp + + Leaving SpLim out of the picture. + -------------------------------------------------------------------------- */ + +#if defined(MACHREGS_i386) + +#define REG(x) __asm__("%" #x) + +#if !defined(not_doing_dynamic_linking) +#define REG_Base ebx +#endif +#define REG_Sp ebp + +#if !defined(STOLEN_X86_REGS) +#define STOLEN_X86_REGS 4 +#endif + +#if STOLEN_X86_REGS >= 3 +# define REG_R1 esi +#endif + +#if STOLEN_X86_REGS >= 4 +# define REG_Hp edi +#endif +#define REG_MachSp esp + +#define REG_XMM1 xmm0 +#define REG_XMM2 xmm1 +#define REG_XMM3 xmm2 +#define REG_XMM4 xmm3 + +#define REG_YMM1 ymm0 +#define REG_YMM2 ymm1 +#define REG_YMM3 ymm2 +#define REG_YMM4 ymm3 + +#define REG_ZMM1 zmm0 +#define REG_ZMM2 zmm1 +#define REG_ZMM3 zmm2 +#define REG_ZMM4 zmm3 + +#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ +#define MAX_REAL_FLOAT_REG 0 +#define MAX_REAL_DOUBLE_REG 0 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 4 +#define MAX_REAL_YMM_REG 4 +#define MAX_REAL_ZMM_REG 4 + +/* ----------------------------------------------------------------------------- + The x86-64 register mapping + + %rax caller-saves, don't steal this one + %rbx YES + %rcx arg reg, caller-saves + %rdx arg reg, caller-saves + %rsi arg reg, caller-saves + %rdi arg reg, caller-saves + %rbp YES (our *prime* register) + %rsp (unavailable - stack pointer) + %r8 arg reg, caller-saves + %r9 arg reg, caller-saves + %r10 caller-saves + %r11 caller-saves + %r12 YES + %r13 YES + %r14 YES + %r15 YES + + %xmm0-7 arg regs, caller-saves + %xmm8-15 caller-saves + + Use the caller-saves regs for Rn, because we don't always have to + save those (as opposed to Sp/Hp/SpLim etc. which always have to be + saved). + + --------------------------------------------------------------------------- */ + +#elif defined(MACHREGS_x86_64) + +#define REG(x) __asm__("%" #x) + +#define REG_Base r13 +#define REG_Sp rbp +#define REG_Hp r12 +#define REG_R1 rbx +#define REG_R2 r14 +#define REG_R3 rsi +#define REG_R4 rdi +#define REG_R5 r8 +#define REG_R6 r9 +#define REG_SpLim r15 +#define REG_MachSp rsp + +/* +Map both Fn and Dn to register xmmn so that we can pass a function any +combination of up to six Float# or Double# arguments without touching +the stack. See Note [Overlapping global registers] for implications. +*/ + +#define REG_F1 xmm1 +#define REG_F2 xmm2 +#define REG_F3 xmm3 +#define REG_F4 xmm4 +#define REG_F5 xmm5 +#define REG_F6 xmm6 + +#define REG_D1 xmm1 +#define REG_D2 xmm2 +#define REG_D3 xmm3 +#define REG_D4 xmm4 +#define REG_D5 xmm5 +#define REG_D6 xmm6 + +#define REG_XMM1 xmm1 +#define REG_XMM2 xmm2 +#define REG_XMM3 xmm3 +#define REG_XMM4 xmm4 +#define REG_XMM5 xmm5 +#define REG_XMM6 xmm6 + +#define REG_YMM1 ymm1 +#define REG_YMM2 ymm2 +#define REG_YMM3 ymm3 +#define REG_YMM4 ymm4 +#define REG_YMM5 ymm5 +#define REG_YMM6 ymm6 + +#define REG_ZMM1 zmm1 +#define REG_ZMM2 zmm2 +#define REG_ZMM3 zmm3 +#define REG_ZMM4 zmm4 +#define REG_ZMM5 zmm5 +#define REG_ZMM6 zmm6 + +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_R3 +#define CALLER_SAVES_R4 +#endif +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 + +#define CALLER_SAVES_F1 +#define CALLER_SAVES_F2 +#define CALLER_SAVES_F3 +#define CALLER_SAVES_F4 +#define CALLER_SAVES_F5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_F6 +#endif + +#define CALLER_SAVES_D1 +#define CALLER_SAVES_D2 +#define CALLER_SAVES_D3 +#define CALLER_SAVES_D4 +#define CALLER_SAVES_D5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_D6 +#endif + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 +#define CALLER_SAVES_XMM3 +#define CALLER_SAVES_XMM4 +#define CALLER_SAVES_XMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_XMM6 +#endif + +#define CALLER_SAVES_YMM1 +#define CALLER_SAVES_YMM2 +#define CALLER_SAVES_YMM3 +#define CALLER_SAVES_YMM4 +#define CALLER_SAVES_YMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_YMM6 +#endif + +#define CALLER_SAVES_ZMM1 +#define CALLER_SAVES_ZMM2 +#define CALLER_SAVES_ZMM3 +#define CALLER_SAVES_ZMM4 +#define CALLER_SAVES_ZMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_ZMM6 +#endif + +#define MAX_REAL_VANILLA_REG 6 +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 6 +#define MAX_REAL_YMM_REG 6 +#define MAX_REAL_ZMM_REG 6 + +#endif /* MACHREGS_i386 || MACHREGS_x86_64 */ \ No newline at end of file ===================================== rts/rts.cabal.in ===================================== @@ -123,6 +123,14 @@ library ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h DerivedConstants.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/Types.h @@ -293,6 +301,14 @@ library rts/storage/TSO.h stg/DLL.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/MiscClosures.h stg/Prim.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3609031c374ca017cf63334ec495f6b42c915827 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3609031c374ca017cf63334ec495f6b42c915827 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 14:09:06 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 02 Oct 2023 10:09:06 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T23003 Message-ID: <651acf02bcc8d_364e0412ac168017200@gitlab.mail> Ben Gamari pushed new branch wip/T23003 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T23003 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 14:09:59 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 02 Oct 2023 10:09:59 -0400 Subject: [Git][ghc/ghc][wip/T23003] rts/nonmoving: Fix on LLP64 platforms Message-ID: <651acf375fdc_364e0412acc0e417554f@gitlab.mail> Ben Gamari pushed to branch wip/T23003 at Glasgow Haskell Compiler / GHC Commits: 5ec0c2ec by Ben Gamari at 2023-10-02T10:09:43-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #23042. - - - - - 1 changed file: - rts/sm/NonMoving.h Changes: ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ec0c2ecb0d77e03b78a5ac44f8b86558cc0155f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ec0c2ecb0d77e03b78a5ac44f8b86558cc0155f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 14:13:38 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Mon, 02 Oct 2023 10:13:38 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/upload.sh-cleanups Message-ID: <651ad012390ae_364e0412c799b41815ad@gitlab.mail> Bryan R pushed new branch wip/upload.sh-cleanups at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/upload.sh-cleanups You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 14:21:55 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 02 Oct 2023 10:21:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/fix_arm_immediates Message-ID: <651ad203cfdda_364e04130f2dec1910ce@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/fix_arm_immediates at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/fix_arm_immediates You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 14:26:32 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 02 Oct 2023 10:26:32 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Fix several mistakes around free variables in iface breakpoints Message-ID: <651ad31851ee3_364e0412dc36d019951f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - 279262fa by Andrew Lelechenko at 2023-10-02T10:25:53-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 054caa96 by Andrew Lelechenko at 2023-10-02T10:25:53-04:00 Inline bucket_match - - - - - a8d4df58 by sheaf at 2023-10-02T10:26:00-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - 30 changed files: - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Pmc/Utils.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de2034bcb61b02369a049254a354edcc61476999...a8d4df58cc3161daa9f0a7ea9b04d01a6b52391a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de2034bcb61b02369a049254a354edcc61476999...a8d4df58cc3161daa9f0a7ea9b04d01a6b52391a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 15:38:06 2023 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Mon, 02 Oct 2023 11:38:06 -0400 Subject: [Git][ghc/ghc][wip/int-index/t2t-expr] Comments for IsPunnedVarOcc Message-ID: <651ae3dea2f19_364e04153bb0b8225056@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/t2t-expr at Glasgow Haskell Compiler / GHC Commits: 96bbea26 by Vladislav Zavialov at 2023-10-02T18:34:15+03:00 Comments for IsPunnedVarOcc - - - - - 1 changed file: - compiler/GHC/Hs/Expr.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -222,9 +222,16 @@ type instance XOverLabel GhcTc = DataConCantHappen -- --------------------------------------------------------------------- +-- | Is this variable occurrence punned, i.e. is there a variable with the same +-- 'occNameFS' but a different 'occNameSpace' in the context? +-- +-- This is used to reject punned variable occurrences when converting required +-- type arguments from HsExpr to HsType (see the "T2T-Mapping" section of GHC Proposal #281). data IsPunnedVarOcc = DistinctVarOcc - | PunnedVarOcc Name Name + | PunnedVarOcc + Name -- how the variable was actually resolved + Name -- how it could have been resolved if we were to look in a different namespace deriving (Eq, Data) type instance XVar GhcPs = NoExtField View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96bbea260945576e201a4931e79ec7db755cc821 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96bbea260945576e201a4931e79ec7db755cc821 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 16:42:21 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 02 Oct 2023 12:42:21 -0400 Subject: [Git][ghc/ghc][wip/test-mingwex-regression] Apply 1 suggestion(s) to 1 file(s) Message-ID: <651af2edeb931_364e0416b993ec231161@gitlab.mail> John Ericson pushed to branch wip/test-mingwex-regression at Glasgow Haskell Compiler / GHC Commits: 07bbd8ff by Ben Gamari at 2023-10-02T16:42:19+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - testsuite/tests/th/all.T Changes: ===================================== testsuite/tests/th/all.T ===================================== @@ -589,5 +589,5 @@ test('T23829_hasty', normal, compile_fail, ['']) test('T23829_hasty_b', normal, compile_fail, ['']) test('T23927', normal, compile_and_run, ['']) test('T23954', normal, compile_and_run, ['']) -test('T23309', [extra_files(['T23309A.hs']), req_c], multimod_compile, ['T23309', '-v0 T23309.c']) +test('T23309', [extra_files(['T23309A.hs']), req_c], multimod_compile, ['T23309', '-v0 T23309.c -optc-fPIC']) test('T23378', [extra_files(['T23378A.hs'])], multimod_compile, ['T23378', '-v0']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07bbd8ff29c76beefd4b7c476b2817631d8d9d87 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07bbd8ff29c76beefd4b7c476b2817631d8d9d87 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 16:46:05 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 02 Oct 2023 12:46:05 -0400 Subject: [Git][ghc/ghc][wip/test-mingwex-regression] 66 commits: EPA: track unicode version for unrestrictedFunTyCon Message-ID: <651af3cdb5132_364e041680926823386@gitlab.mail> John Ericson pushed to branch wip/test-mingwex-regression at Glasgow Haskell Compiler / GHC Commits: f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - 8a1fbbab by John Ericson at 2023-10-02T12:45:50-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> Apply 1 suggestion(s) to 1 file(s) - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/07bbd8ff29c76beefd4b7c476b2817631d8d9d87...8a1fbbabe69afa65fad6c2369450986fd6710cb3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/07bbd8ff29c76beefd4b7c476b2817631d8d9d87...8a1fbbabe69afa65fad6c2369450986fd6710cb3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 17:36:33 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 02 Oct 2023 13:36:33 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Simplify and correct nasty case in coercion opt Message-ID: <651affa1cc2c9_364e0417cf45ec2481a4@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - c14a420c by Andrew Lelechenko at 2023-10-02T13:36:23-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 7ee29cdb by Andrew Lelechenko at 2023-10-02T13:36:23-04:00 Inline bucket_match - - - - - cabaaafd by sheaf at 2023-10-02T13:36:26-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - 15 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -95,10 +95,10 @@ module GHC.Core.Coercion ( -- ** Lifting liftCoSubst, liftCoSubstTyVar, liftCoSubstWith, liftCoSubstWithEx, emptyLiftingContext, extendLiftingContext, extendLiftingContextAndInScope, - liftCoSubstVarBndrUsing, isMappedByLC, + liftCoSubstVarBndrUsing, isMappedByLC, extendLiftingContextCvSubst, mkSubstLiftingContext, zapLiftingContext, - substForAllCoBndrUsingLC, lcSubst, lcInScopeSet, + substForAllCoBndrUsingLC, lcLookupCoVar, lcInScopeSet, LiftCoEnv, LiftingContext(..), liftEnvSubstLeft, liftEnvSubstRight, substRightCo, substLeftCo, swapLiftCoEnv, lcSubstLeft, lcSubstRight, @@ -1991,6 +1991,15 @@ extendLiftingContext (LC subst env) tv arg | otherwise = LC subst (extendVarEnv env tv arg) +-- | Extend the substitution component of a lifting context with +-- a new binding for a coercion variable. Used during coercion optimisation. +extendLiftingContextCvSubst :: LiftingContext + -> CoVar + -> Coercion + -> LiftingContext +extendLiftingContextCvSubst (LC subst env) cv co + = LC (extendCvSubst subst cv co) env + -- | Extend a lifting context with a new mapping, and extend the in-scope set extendLiftingContextAndInScope :: LiftingContext -- ^ Original LC -> TyCoVar -- ^ new variable to map... @@ -2298,9 +2307,9 @@ liftEnvSubst selector subst lc_env where equality_ty = selector (coercionKind co) --- | Extract the underlying substitution from the LiftingContext -lcSubst :: LiftingContext -> Subst -lcSubst (LC subst _) = subst +-- | Lookup a 'CoVar' in the substitution in a 'LiftingContext' +lcLookupCoVar :: LiftingContext -> CoVar -> Maybe Coercion +lcLookupCoVar (LC subst _) cv = lookupCoVar subst cv -- | Get the 'InScopeSet' from a 'LiftingContext' lcInScopeSet :: LiftingContext -> InScopeSet ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -310,14 +310,15 @@ opt_co4 env sym rep r (FunCo _r afl afr cow co1 co2) !(afl', afr') = swapSym sym (afl, afr) opt_co4 env sym rep r (CoVarCo cv) - | Just co <- lookupCoVar (lcSubst env) cv + | Just co <- lcLookupCoVar env cv -- see Note [Forall over coercion] for why + -- this is the right thing here = opt_co4_wrap (zapLiftingContext env) sym rep r co | ty1 `eqType` ty2 -- See Note [Optimise CoVarCo to Refl] = mkReflCo (chooseRole rep r) ty1 | otherwise - = assert (isCoVar cv1 ) + = assert (isCoVar cv1) $ wrapRole rep r $ wrapSym sym $ CoVarCo cv1 @@ -414,6 +415,40 @@ opt_co4 env sym rep r (LRCo lr co) pick_lr CLeft (l, _) = l pick_lr CRight (_, r) = r +{- +Note [Forall over coercion] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Example: + type (:~:) :: forall k. k -> k -> Type + Refl :: forall k (a :: k) (b :: k). forall (cv :: (~#) k k a b). (:~:) k a b + k1,k2,k3,k4 :: Type + eta :: (k1 ~# k2) ~# (k3 ~# k4) == ((~#) Type Type k1 k2) ~# ((~#) Type Type k3 k4) + co1_3 :: k1 ~# k3 + co2_4 :: k2 ~# k4 + nth 2 eta :: k1 ~# k3 + nth 3 eta :: k2 ~# k4 + co11_31 :: ~# (sym co1_3) + co22_24 :: ~# co2_4 + (forall (cv :: eta). Refl co1_3 co2_4 (co11_31 ;; cv ;; co22_24)) :: + (forall (cv :: k1 ~# k2). Refl Type k1 k2 ( ;; cv ;; ) ~# + (forall (cv :: k3 ~# k4). Refl Type k3 k4 + (sym co1_3 ;; nth 2 eta ;; cv ;; sym (nth 3 eta) ;; co2_4)) + co1_2 :: k1 ~# k2 + co3_4 :: k3 ~# k4 + co5 :: co1_2 ~# co3_4 + InstCo (forall (cv :: eta). Refl co1_3 co2_4 (co11_31 ;; cv ;; co22_24)) co5 :: + (Refl Type k1 k2 ( ;; cv ;; ))[cv |-> co1_2] ~# + (Refl Type k3 k4 (sym co1_3 ;; nth 2 eta ;; cv ;; sym (nth 3 eta) ;; co2_4))[cv |-> co3_4] + == + (Refl Type k1 k2 ( ;; co1_2 ;; )) ~# + (Refl Type k3 k4 (sym co1_3 ;; nth 2 eta ;; co3_4 ;; sym (nth 3 eta) ;; co2_4)) + ==> + Refl co1_3 co2_4 (co11_31 ;; co1_2 ;; co22_24) +Conclusion: Because of the way this all works, we want to put in the *left-hand* +coercion in co5's type. (In the code, co5 is called `arg`.) +So we extend the environment binding cv to arg's left-hand type. +-} + -- See Note [Optimising InstCo] opt_co4 env sym rep r (InstCo co1 arg) -- forall over type... @@ -425,12 +460,10 @@ opt_co4 env sym rep r (InstCo co1 arg) -- tv |-> (t1 :: k1) ~ (((t2 :: k2) |> (sym kind_co)) :: k1) sym rep r co_body - -- forall over coercion... - | Just (cv, _visL, _visR, kind_co, co_body) <- splitForAllCo_co_maybe co1 + -- See Note [Forall over coercion] + | Just (cv, _visL, _visR, _kind_co, co_body) <- splitForAllCo_co_maybe co1 , CoercionTy h1 <- t1 - , CoercionTy h2 <- t2 - = let new_co = mk_new_co cv (opt_co4_wrap env sym False Nominal kind_co) h1 h2 - in opt_co4_wrap (extendLiftingContext env cv new_co) sym rep r co_body + = opt_co4_wrap (extendLiftingContextCvSubst env cv h1) sym rep r co_body -- See if it is a forall after optimization -- If so, do an inefficient one-variable substitution, then re-optimize @@ -441,12 +474,10 @@ opt_co4 env sym rep r (InstCo co1 arg) (mkCoherenceRightCo Nominal t2' (mkSymCo kind_co') arg')) False False r' co_body' - -- forall over coercion... - | Just (cv', _visL, _visR, kind_co', co_body') <- splitForAllCo_co_maybe co1' + -- See Note [Forall over coercion] + | Just (cv', _visL, _visR, _kind_co', co_body') <- splitForAllCo_co_maybe co1' , CoercionTy h1' <- t1' - , CoercionTy h2' <- t2' - = let new_co = mk_new_co cv' kind_co' h1' h2' - in opt_co4_wrap (extendLiftingContext (zapLiftingContext env) cv' new_co) + = opt_co4_wrap (extendLiftingContextCvSubst (zapLiftingContext env) cv' h1') False False r' co_body' | otherwise = InstCo co1' arg' @@ -467,20 +498,6 @@ opt_co4 env sym rep r (InstCo co1 arg) Pair t1 t2 = coercionKind sym_arg Pair t1' t2' = coercionKind arg' - mk_new_co cv kind_co h1 h2 - = let -- h1 :: (t1 ~ t2) - -- h2 :: (t3 ~ t4) - -- kind_co :: (t1 ~ t2) ~ (t3 ~ t4) - -- n1 :: t1 ~ t3 - -- n2 :: t2 ~ t4 - -- new_co = (h1 :: t1 ~ t2) ~ ((n1;h2;sym n2) :: t1 ~ t2) - r2 = coVarRole cv - kind_co' = downgradeRole r2 Nominal kind_co - n1 = mkSelCo (SelTyCon 2 r2) kind_co' - n2 = mkSelCo (SelTyCon 3 r2) kind_co' - in mkProofIrrelCo Nominal (Refl (coercionType h1)) h1 - (n1 `mkTransCo` h2 `mkTransCo` (mkSymCo n2)) - opt_co4 env sym _rep r (KindCo co) = assert (r == Nominal) $ let kco' = promoteCoercion co in ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a8d4df58cc3161daa9f0a7ea9b04d01a6b52391a...cabaaafd76895ef714ff459abe9e447593bdfd34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a8d4df58cc3161daa9f0a7ea9b04d01a6b52391a...cabaaafd76895ef714ff459abe9e447593bdfd34 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 17:53:49 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 02 Oct 2023 13:53:49 -0400 Subject: [Git][ghc/ghc][wip/expand-do] Expands `do` blocks before typechecking using the `HsExpansion` philosophy Message-ID: <651b03ad87ff5_364e041862a3dc2554f8@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: b94a213d by Apoorv Ingle at 2023-10-02T10:46:23-05:00 Expands `do` blocks before typechecking using the `HsExpansion` philosophy - Fixes #18324 #20020 #23147 #22788 #15598 #22086 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Match` explains change in detail - New datatypes to make this expansion work: `GHC.Hs.Expr.XXExprGhcRn`: It contains 1. Expansion bits for Statements (`ExpansionStmt`) and Patterns (`ExpansionPat`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 30 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Tc/Types/ErrCtxt.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Basic.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b94a213d6451eb444afc1884852c3729fff2374f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b94a213d6451eb444afc1884852c3729fff2374f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 20:28:32 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 02 Oct 2023 16:28:32 -0400 Subject: [Git][ghc/ghc][wip/hadrian-windows-bindist-cross] 48 commits: Move lib{numa,dw} defines to RTS configure Message-ID: <651b27f0b1302_364e041bf9cf5c27531@gitlab.mail> Ben Gamari pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC Commits: 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - 72662c52 by Matthew Pickering at 2023-10-02T16:27:54-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 84f2d07c by Matthew Pickering at 2023-10-02T16:27:54-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 55d76be1 by Matthew Pickering at 2023-10-02T16:27:54-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - b776e04c by Matthew Pickering at 2023-10-02T16:27:54-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 61acb418 by Matthew Pickering at 2023-10-02T16:27:54-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 828a5821 by Ben Gamari at 2023-10-02T16:27:54-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - daf565c9 by Matthew Pickering at 2023-10-02T16:27:54-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - 1388ea27 by Matthew Pickering at 2023-10-02T16:27:54-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 89178477 by Matthew Pickering at 2023-10-02T16:27:54-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 0267aa72 by Matthew Pickering at 2023-10-02T16:27:55-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - e235a9f8 by Matthew Pickering at 2023-10-02T16:27:55-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - d7f664ed by Matthew Pickering at 2023-10-02T16:27:55-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 02293049 by Matthew Pickering at 2023-10-02T16:27:55-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - e09546f0 by Matthew Pickering at 2023-10-02T16:27:55-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 82ca0c05 by Matthew Pickering at 2023-10-02T16:27:55-04:00 hadrian: Don't pass LDFLAGS as a --configure-arg to cabal configure We don't have anything sensible to set LDFLAGS to because the "linker" flags we have are actually flags we pass to the C compiler when it's used as a linker. Likewise stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - e3121716 by Ben Gamari at 2023-10-02T16:27:55-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Pmc/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/559bb6b55f06740dbbff21c4bc104f5a0c804ae4...e3121716ab98eb552f3d388b22d1d695c3632202 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/559bb6b55f06740dbbff21c4bc104f5a0c804ae4...e3121716ab98eb552f3d388b22d1d695c3632202 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 20:29:12 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Mon, 02 Oct 2023 16:29:12 -0400 Subject: [Git][ghc/ghc][wip/az/ghc-cpp] 3 commits: Simplify Lexer interface. Only ITcpp Message-ID: <651b281857306_364e041bfc7ff42777d1@gitlab.mail> Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: 347968a7 by Alan Zimmerman at 2023-10-01T22:49:36+01:00 Simplify Lexer interface. Only ITcpp We transfer directive lines through it, then parse them from scratch in the preprocessor. - - - - - e75306cd by Alan Zimmerman at 2023-10-02T21:28:04+01:00 Deal with directive on last line, with no trailing \n - - - - - 54c33324 by Alan Zimmerman at 2023-10-02T21:28:42+01:00 Start parsing and processing the directives - - - - - 3 changed files: - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PreProcess.hs - utils/check-cpp/Main.hs Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -303,6 +303,7 @@ $unigraphic / { isSmartQuote } { smart_quote_error } \n ; -- Ghc CPP symbols ^\# \ * @cppkeyword .* \n / { ifExtension GhcCppBit } { cppToken cpp_prag } + ^\# \ * @cppkeyword .* / { ifExtension GhcCppBit } { cppToken cpp_prag } ^\# line { begin line_prag1 } ^\# / { followedByDigit } { begin line_prag1 } @@ -320,6 +321,7 @@ $unigraphic / { isSmartQuote } { smart_quote_error } -- we might encounter {-# here, but {- has been handled already \n ; ^\# \ * @cppkeyword .* \n / { ifExtension GhcCppBit } { cppToken cpp_prag } + ^\# \ * @cppkeyword .* / { ifExtension GhcCppBit } { cppToken cpp_prag } ^\# (line)? { begin line_prag1 } } @@ -346,8 +348,10 @@ $unigraphic / { isSmartQuote } { smart_quote_error } -- CPP continuation lines. Keep concatenating, or exit { - .* \\ \n { cppTokenCont (ITcppContinue True) } - .* \n { cppTokenPop (ITcppContinue False) } + .* \\ \n { cppTokenCont (ITcpp True) } + .* \\ { cppTokenCont (ITcpp True) } + -- .* \n { cppTokenPop (ITcpp False) } + .* { cppTokenPop (ITcpp False) } -- () { popCpp } } @@ -1029,16 +1033,27 @@ data Token | ITlineComment String PsSpan -- ^ comment starting by "--" | ITblockComment String PsSpan -- ^ comment in {- -} - -- GHC CPP extension. Each contains an entire line of source code, - -- possibly joining up ones ending in backslash - | ITcppStart Bool FastString -- ^ Start of a CPP #-prefixed line. Flag for continuation - | ITcppContinue Bool FastString -- ^ Continuation after a trailing backslash. Flag for continuation - + -- GHC CPP extension. See Note [GhcCPP Token] + | ITcpp Bool FastString -- ^ CPP #-prefixed line, or continuation. deriving Show instance Outputable Token where ppr x = text (show x) +{- Note [GhcCPP Token] +~~~~~~~~~~~~~~~~~~~~~~ +We only invoke the Ghc CPP processing on lines beginning with a '#' +and one of the keywords in @cppkeyword. + +These directives can finish on a trailing slash, which signals a +continuation onto the next line. + +When lexing, we detect the start of the directive, and put the line +into a ITcpp token, with a flag indicating if it ends with a +continuation. Subsequent continued lines are treated the same way, +until the final ITcpp token with the flag set False. +-} + {- Note [PsSpan in Comments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When using the Api Annotations to exact print a modified AST, managing @@ -1273,20 +1288,30 @@ cppToken code span buf len _buf2 = let tokStr = lexemeToFastString buf len -- check if the string ends with backslash and newline -- NOTE: performance likely sucks, make it work for now - continue <- case (reverse $ unpackFS tokStr) of - -- ('\n':'\\':_) -> pushLexState code >> return True - ('\n':'\\':_) -> pushLexState (trace ("cppToken: push state") code) >> return True - _ -> return False - return (L span (ITcppStart continue $! tokStr)) + (len0, continue) <- case (reverse $ unpackFS tokStr) of + -- ('\n':'\\':_) -> pushLexState code >> return (len -2, True) + ('\n':'\\':_) -> pushLexState (trace ("cppToken: push state") code) >> return (len - 2, True) + ('\n':_) -> return (len - 1, False) + _ -> return (len, False) + return (L span (ITcpp continue $! lexemeToFastString buf len0)) -- trace ("cppToken:" ++ show (code, t)) $ do return (L span t) cppTokenCont :: (FastString -> Token)-> Action -cppTokenCont t span buf len _buf2 = return (L span (t $! lexemeToFastString buf len)) +cppTokenCont code span buf len _buf2 = + do + let tokStr = lexemeToFastString buf len + -- check if the string ends with backslash and newline + -- NOTE: performance likely sucks, make it work for now + (len0, continue) <- case (reverse $ unpackFS tokStr) of + ('\n':'\\':_) -> return (len - 2, True) + ('\n':_) -> return (len - 1, False) + _ -> return (len, False) + return (L span (ITcpp continue $! lexemeToFastString buf len0)) cppTokenPop :: (FastString -> Token)-> Action cppTokenPop t span buf len _buf2 = do _ <- popLexState - -- return (L span (t $! lexemeToFastString buf len)) + -- return (L span (t $! lexemeToFastString buf (len - 1))) return (L span (t $! lexemeToFastString buf (trace "cppTokenPop" len))) popCpp :: Action @@ -2761,7 +2786,7 @@ data PState = PState { -- | Use for emulating (limited) CPP preprocessing in GHC. -- TODO: move this into PreProcess, and make a param on PState data PpState = PpState { - pp_defines :: !(Set String), + pp_defines :: !(Map String [String]), pp_continuation :: ![Located Token], -- pp_context :: ![PpContext], pp_context :: ![Token], -- What preprocessor directive we are currently processing @@ -2774,7 +2799,7 @@ data PpContext = PpContextIf [Located Token] initPpState :: PpState initPpState = PpState - { pp_defines = Set.empty + { pp_defines = Map.empty , pp_continuation = [] , pp_context = [] , pp_accepting = True ===================================== compiler/GHC/Parser/PreProcess.hs ===================================== @@ -152,15 +152,15 @@ getAccepting = P $ \s -> POk s (pp_accepting (pp s)) -- definitions start -------------------- -ppDefine :: FastString -> P () -ppDefine def = P $ \s -> - -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () - POk s{pp = (pp s){pp_defines = Set.insert (trace ("ppDefine:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))}} () - -ppIsDefined :: FastString -> P Bool -ppIsDefined def = P $ \s -> - -- POk s (Set.member def (pp_defines (pp s))) - POk s (Set.member (trace ("ppIsDefined:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))) +-- ppDefine :: FastString -> P () +-- ppDefine def = P $ \s -> +-- -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () +-- POk s{pp = (pp s){pp_defines = Set.insert (trace ("ppDefine:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))}} () + +-- ppIsDefined :: FastString -> P Bool +-- ppIsDefined def = P $ \s -> +-- -- POk s (Set.member def (pp_defines (pp s))) +-- POk s (Set.member (trace ("ppIsDefined:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))) -- | Take a @FastString@ of the form "#define FOO\n" and strip off all but "FOO" cleanTokenString :: FastString -> String ===================================== utils/check-cpp/Main.hs ===================================== @@ -5,7 +5,7 @@ import Control.Monad.IO.Class import Data.Char import Data.Data hiding (Fixity) import Data.List -import qualified Data.Set as Set +import qualified Data.Map as Map import Debug.Trace import GHC import qualified GHC.Data.EnumSet as EnumSet @@ -60,7 +60,7 @@ ppLexer queueComments cont = ( \tk -> let contInner t = (trace ("ppLexer: tk=" ++ show (unLoc tk, unLoc t)) cont) t - contPush = pushContext (unLoc tk) >> contIgnoreTok tk + -- contPush = pushContext (unLoc tk) >> contIgnoreTok tk contIgnoreTok (L l tok) = do case l of RealSrcSpan r (Strict.Just b) -> Lexer.queueIgnoredToken (L (PsSpan r b) tok) @@ -69,44 +69,12 @@ ppLexer queueComments cont = in -- case tk of case (trace ("M.ppLexer:tk=" ++ show (unLoc tk)) tk) of - L _ (ITcppStart continuation s) -> do + L _ ITeof -> contInner tk + L _ (ITcpp continuation s) -> do if continuation - then do - pushContinuation tk - contIgnoreTok tk - else do - processCppToks s - contIgnoreTok tk - L _ (ITcppContinue continuation s) -> do - if continuation - then do - pushContinuation tk - contIgnoreTok tk - else do - processCppToks s - contIgnoreTok tk - -- L _ (ITcppDefine s) -> do - -- -- ppDefine (trace ("ppDefine:" ++ show s) s) - -- ppDefine s - -- popContext - -- contIgnoreTok tk - -- L _ (ITcppIf _) -> contPush - -- L _ (ITcppIfdef s) -> do - -- defined <- ppIsDefined s - -- -- setAccepting defined - -- setAccepting (trace ("ifdef:" ++ show (s, defined)) defined) - -- contIgnoreTok tk - -- L _ (ITcppIfndef s) -> do - -- defined <- ppIsDefined s - -- -- setAccepting (not defined) - -- setAccepting (trace ("ifdef:" ++ show (s, defined)) (not defined)) - -- contIgnoreTok tk - -- L _ ITcppElse -> do - -- preprocessElse - -- contIgnoreTok tk - -- L _ ITcppEndif -> do - -- preprocessEnd - -- contIgnoreTok tk + then pushContinuation tk + else processCppToks s + contIgnoreTok tk _ -> do state <- getCppState case (trace ("CPP state:" ++ show state) state) of @@ -126,10 +94,8 @@ preprocessEnd = do processCppToks :: FastString -> P () processCppToks fs = do - let str = unpackFS fs let - get (L _ (ITcppStart _ s)) = s - get (L _ (ITcppContinue _ s)) = s + get (L _ (ITcpp _ s)) = s get _ = error "should not" -- Combine any prior continuation tokens cs <- popContinuation @@ -138,32 +104,44 @@ processCppToks fs = do processCpp :: [FastString] -> P () processCpp fs = do - traceM $ "processCpp: fs=" ++ show fs - return () + -- traceM $ "processCpp: fs=" ++ show fs + -- let s = cppInitial fs + let s = cppInitial fs + case regularParse cppDirective s of + Left err -> error $ show err + Right (CppDefine name def) -> do + ppDefine name def + Right (CppIfdef name) -> do + defined <- ppIsDefined name + setAccepting defined + Right (CppIfndef name) -> do + defined <- ppIsDefined name + setAccepting (not defined) + Right CppElse -> do + accepting <- getAccepting + setAccepting (not accepting) + return () + Right CppEndif -> do + -- TODO: nested states + setAccepting True + return () + + return (trace ("processCpp:s=" ++ show s) ()) -- --------------------------------------------------------------------- -- Preprocessor state functions data CppState = CppIgnoring - | CppInDefine - | CppInIfdef - | CppInIfndef | CppNormal deriving (Show) getCppState :: P CppState getCppState = do - context <- peekContext accepting <- getAccepting - case context of - -- ITcppDefine _ -> return CppInDefine - -- ITcppIfdef _ -> return CppInIfdef - -- ITcppIfndef _ -> return CppInIfndef - _ -> - if accepting - then return CppNormal - else return CppIgnoring + if accepting + then return CppNormal + else return CppIgnoring -- pp_context stack start ----------------- @@ -212,15 +190,15 @@ popContinuation = -- definitions start -------------------- -ppDefine :: FastString -> P () -ppDefine def = P $ \s -> +ppDefine :: String -> [String] -> P () +ppDefine name val = P $ \s -> -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () - POk s{pp = (pp s){pp_defines = Set.insert (trace ("ppDefine:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))}} () + POk s{pp = (pp s){pp_defines = Map.insert (trace ("ppDefine:def=[" ++ name ++ "]") name) val (pp_defines (pp s))}} () -ppIsDefined :: FastString -> P Bool +ppIsDefined :: String -> P Bool ppIsDefined def = P $ \s -> - -- POk s (Set.member (cleanTokenString def) (pp_defines (pp s))) - POk s (Set.member (trace ("ppIsDefined:def=[" ++ show (cleanTokenString def) ++ "]") (cleanTokenString def)) (pp_defines (pp s))) + -- POk s (Map.member def (pp_defines (pp s))) + POk s (Map.member (trace ("ppIsDefined:def=[" ++ def ++ "]") def) (pp_defines (pp s))) -- | Take a @FastString@ of the form "#define FOO\n" and strip off all but "FOO" cleanTokenString :: FastString -> String @@ -229,10 +207,13 @@ cleanTokenString fs = r ss = dropWhile (\c -> not $ isSpace c) (unpackFS fs) r = init ss -parseDefine :: FastString -> Maybe (String, String) -parseDefine s = r +parseDefine :: FastString -> Maybe (String, [String]) +parseDefine fs = r where - r = Just (cleanTokenString s, "") + -- r = Just (cleanTokenString s, "") + r = case regularParse cppDefinition (unpackFS fs) of + Left _ -> Nothing + Right v -> Just v -- ===================================================================== -- Parsec parsing @@ -241,6 +222,63 @@ type CppParser = Parsec String () regularParse :: Parser a -> String -> Either Parsec.ParseError a regularParse p = PS.parse p "" + +-- TODO: delete this +cppDefinition :: CppParser (String, [String]) +cppDefinition = do + _ <- PS.char '#' + _ <- whiteSpace + _ <- lexeme (PS.string "define") + name <- cppToken + definition <- cppTokens + return (name, definition) + +data CppDirective + = CppDefine String [String] + | CppIfdef String + | CppIfndef String + | CppElse + | CppEndif + deriving (Show, Eq) + +cppDirective :: CppParser CppDirective +cppDirective = do + _ <- PS.char '#' + _ <- whiteSpace + choice + [ cppKw "define" >> cmdDefinition + -- , cppKw "include" CppIncludeKw + -- , cppKw "undef" CppUndefKw + -- , cppKw "error" CppErrorKw + , try$ cppKw "ifdef" >> cmdIfdef + , cppKw "ifndef" >> cmdIfndef + -- , cppKw "if" CppIfKw + -- , cppKw "elif" CppElifKw + , try $ cppKw "else" >> return CppElse + , cppKw "endif" >> return CppEndif + ] + +cmdDefinition :: CppParser CppDirective +cmdDefinition = do + name <- cppToken + definition <- cppTokens + return $ CppDefine name definition + +cmdIfdef :: CppParser CppDirective +cmdIfdef = do + name <- cppToken + return $ CppIfdef name + +cmdIfndef :: CppParser CppDirective +cmdIfndef = do + name <- cppToken + return $ CppIfndef name + +cppKw :: String -> CppParser () +cppKw kw = do + _ <- lexeme (PS.string kw) + return () + cppComment :: CppParser () cppComment = do _ <- PS.string "/*" @@ -258,13 +296,17 @@ lexeme p = p <* whiteSpace cppToken :: CppParser String cppToken = lexeme (PS.many1 (PS.satisfy (\c -> not (isSpace c)))) +cppTokens :: CppParser [String] +cppTokens = PS.many cppToken + {- | Do cpp initial processing, as per https://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html See Note [GhcCPP Initial Processing] -} -cppInitial :: FastString -> String +cppInitial :: [FastString] -> String cppInitial fs = r where - r = unpackFS fs + -- go fs' = reverse $ drop 2 $ reverse $ unpackFS fs' + r = concatMap unpackFS fs {- Note [GhcCPP Initial Processing] @@ -491,7 +533,6 @@ t2 = do , "#else" , "x = 5" , "#endif" - , "" ] t3 :: IO () @@ -573,7 +614,14 @@ t6 = do , "#else" , "x = \"no version\"" , "#endif" + , "" ] -t7 :: Maybe (String, String) -t7 = parseDefine (mkFastString "#define VERSION_ghc_exactprint \"1.7.0.1\"\n") +t7 :: Maybe (String, [String]) +t7 = parseDefine (mkFastString "#define VERSION_ghc_exactprint \"1.7.0.1\"") + +t8 :: Maybe (String, [String]) +t8 = parseDefine (mkFastString "#define MIN_VERSION_ghc_exactprint(major1,major2,minor) ( (major1) < 1 || (major1) == 1 && (major2) < 7 || (major1) == 1 && (major2) == 7 && (minor) <= 0)") + +t9 :: Either Parsec.ParseError CppDirective +t9 = regularParse cppDirective "#define VERSION_ghc_exactprint \"1.7.0.1\"" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/89aaf2869980802922f676c0d3f391d0db568b17...54c33324972d6bc3ccd48426a40f5492809d3c1b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/89aaf2869980802922f676c0d3f391d0db568b17...54c33324972d6bc3ccd48426a40f5492809d3c1b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 20:36:50 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 02 Oct 2023 16:36:50 -0400 Subject: [Git][ghc/ghc][wip/hadrian-windows-bindist-cross] toolchain: Don't pass --target to emscripten toolchain Message-ID: <651b29e2a2bf7_364e041c1008802799ed@gitlab.mail> Ben Gamari pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC Commits: 391a4ce2 by Ben Gamari at 2023-10-02T16:36:35-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 7 changed files: - m4/fp_cc_supports_target.m4 - m4/fp_prog_cc_linker_target.m4 - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/src/GHC/Toolchain/Program.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== m4/fp_cc_supports_target.m4 ===================================== @@ -14,8 +14,13 @@ AC_DEFUN([FP_CC_SUPPORTS_TARGET], [ AC_REQUIRE([GHC_LLVM_TARGET_SET_VAR]) AC_MSG_CHECKING([whether $1 supports --target]) + echo 'int main() { return 0; }' > conftest.c - if $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then + if test "$target_cpu" = "javascript" ; then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then CONF_CC_SUPPORTS_TARGET=YES AC_MSG_RESULT([yes]) else ===================================== m4/fp_prog_cc_linker_target.m4 ===================================== @@ -8,11 +8,18 @@ AC_DEFUN([FP_PROG_CC_LINKER_TARGET], [ AC_MSG_CHECKING([whether $CC used as a linker understands --target]) + echo 'int foo() { return 0; }' > conftest1.c echo 'int main() { return 0; }' > conftest2.c "${CC}" $$1 -c conftest1.c || AC_MSG_ERROR([Failed to compile conftest1.c]) "${CC}" $$1 -c conftest2.c || AC_MSG_ERROR([Failed to compile conftest2.c]) - if "$CC" $$2 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; + + -- See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + if test "$target_cpu" = "javascript" + then + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif "$CC" $$2 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; then $2="--target=$LlvmTarget $$2" AC_MSG_RESULT([yes]) ===================================== utils/ghc-toolchain/exe/Main.hs ===================================== @@ -380,11 +380,15 @@ mkTarget opts = do normalised_triple <- normaliseTriple (optTriple opts) -- Use Llvm target if specified, otherwise use triple as llvm target let tgtLlvmTarget = fromMaybe normalised_triple (optLlvmTriple opts) - cc0 <- findCc tgtLlvmTarget (optCc opts) - cxx <- findCxx tgtLlvmTarget (optCxx opts) + + (archOs, tgtVendor) <- do + cc0 <- findBasicCc (optCc opts) + parseTriple cc0 normalised_triple + + cc0 <- findCc archOs tgtLlvmTarget (optCc opts) + cxx <- findCxx archOs tgtLlvmTarget (optCxx opts) cpp <- findCpp (optCpp opts) cc0 hsCpp <- findHsCpp (optHsCpp opts) cc0 - (archOs, tgtVendor) <- parseTriple cc0 normalised_triple cc <- addPlatformDepCcFlags archOs cc0 readelf <- optional $ findReadelf (optReadelf opts) ccLink <- findCcLink tgtLlvmTarget (optLd opts) (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Program.hs ===================================== @@ -30,6 +30,7 @@ import System.Directory import System.Exit import System.Process hiding (env) +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Utils @@ -182,17 +183,37 @@ compile ext extraFlags lens c outPath program = do callProgram (view lens c) $ extraFlags ++ ["-o", outPath, srcPath] expectFileExists outPath "compiler produced no output" +-- Note [Don't pass --target to emscripten toolchain] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Emscripten's CC wrapper is a bit wonky in that it accepts the `--target` +-- flag when used as a linker yet rejects it as a compiler (e.g. with `-c`). +-- This is exacerbated by the fact that Cabal currently in some cases +-- combines (and therefore conflates) link and compilation flags. +-- +-- Ultimately this should be fixed in Cabal but in the meantime we work around it +-- by handling this toolchain specifically in the various +-- "supports --target" checks in `configure` and `ghc-toolchain`. +-- +-- Fixes #23744. + -- | Does compiler program support the @--target=@ option? If so, we should -- pass it whenever possible to avoid ambiguity and potential compile-time -- errors (e.g. see #20162). -supportsTarget :: Lens compiler Program +supportsTarget :: ArchOS + -> Lens compiler Program -> (compiler -> M ()) -- ^ Action to check if compiler with @--target@ flag works -> String -- ^ The LLVM target to use if @cc@ supports @--target@ -> compiler -- ^ The compiler to check @--target@ support for -> M compiler -- ^ Return compiler with @--target@ flag if supported -supportsTarget lens checkWorks llvmTarget c --- TODO: #23603 - | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) = return c +supportsTarget archOs lens checkWorks llvmTarget c + -- See Note [Don't pass --target to emscripten toolchain]. + | ArchJavaScript <- archOS_arch archOs + = return c + + -- No reason to check if the options already contain a --target flag + | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) + = return c + | otherwise = let c' = over (lens % _prgFlags) (("--target="++llvmTarget):) c in (c' <$ checkWorks (over (lens % _prgFlags) ("-Werror":) c')) <|> return c ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs ===================================== @@ -4,6 +4,7 @@ module GHC.Toolchain.Tools.Cc ( Cc(..) , _ccProgram + , findBasicCc , findCc -- * Helpful utilities , preprocess @@ -33,22 +34,29 @@ _ccProgram = Lens ccProgram (\x o -> o{ccProgram=x}) _ccFlags :: Lens Cc [String] _ccFlags = _ccProgram % _prgFlags -findCc :: String -- ^ The llvm target to use if Cc supports --target - -> ProgOpt -> M Cc -findCc llvmTarget progOpt = checking "for C compiler" $ do +-- We use this to find a minimally-functional compiler needed to call +-- parseTriple. +findBasicCc :: ProgOpt -> M Cc +findBasicCc progOpt = checking "for C compiler" $ do -- TODO: We keep the candidate order we had in configure, but perhaps -- there's a more optimal one ccProgram <- findProgram "C compiler" progOpt ["gcc", "clang", "cc"] + return $ Cc{ccProgram} - cc0 <- ignoreUnusedArgs $ Cc {ccProgram} - cc1 <- ccSupportsTarget llvmTarget cc0 - checking "whether Cc works" $ checkCcWorks cc1 - cc2 <- oneOf "cc doesn't support C99" $ map checkC99Support - [ cc1 - , cc1 & _ccFlags %++ "-std=gnu99" +findCc :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target + -> ProgOpt -> M Cc +findCc archOs llvmTarget progOpt = do + cc0 <- findBasicCc progOpt + cc1 <- ignoreUnusedArgs cc0 + cc2 <- ccSupportsTarget archOs llvmTarget cc1 + checking "whether Cc works" $ checkCcWorks cc2 + cc3 <- oneOf "cc doesn't support C99" $ map checkC99Support + [ cc2 + , cc2 & _ccFlags %++ "-std=gnu99" ] - checkCcSupportsExtraViaCFlags cc2 - return cc2 + checkCcSupportsExtraViaCFlags cc3 + return cc3 checkCcWorks :: Cc -> M () checkCcWorks cc = withTempDir $ \dir -> do @@ -75,9 +83,10 @@ ignoreUnusedArgs cc -- Does Cc support the --target= option? If so, we should pass it -- whenever possible to avoid ambiguity and potential compile-time errors (e.g. -- see #20162). -ccSupportsTarget :: String -> Cc -> M Cc -ccSupportsTarget target cc = checking "whether Cc supports --target" $ - supportsTarget _ccProgram checkCcWorks target cc +ccSupportsTarget :: ArchOS -> String -> Cc -> M Cc +ccSupportsTarget archOs target cc = + checking "whether Cc supports --target" $ + supportsTarget archOs _ccProgram checkCcWorks target cc checkC99Support :: Cc -> M Cc checkC99Support cc = checking "for C99 support" $ withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs ===================================== @@ -8,6 +8,8 @@ module GHC.Toolchain.Tools.Cxx ) where import System.FilePath + +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Program import GHC.Toolchain.Utils @@ -19,18 +21,20 @@ newtype Cxx = Cxx { cxxProgram :: Program _cxxProgram :: Lens Cxx Program _cxxProgram = Lens cxxProgram (\x o -> o{cxxProgram=x}) -findCxx :: String -- ^ The llvm target to use if Cc supports --target +findCxx :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target -> ProgOpt -> M Cxx -findCxx target progOpt = checking "for C++ compiler" $ do +findCxx archOs target progOpt = checking "for C++ compiler" $ do -- TODO: We use the search order in configure, but there could be a more optimal one cxxProgram <- findProgram "C++ compiler" progOpt ["g++", "clang++", "c++"] - cxx <- cxxSupportsTarget target Cxx{cxxProgram} + cxx <- cxxSupportsTarget archOs target Cxx{cxxProgram} checkCxxWorks cxx return cxx -cxxSupportsTarget :: String -> Cxx -> M Cxx -cxxSupportsTarget target cxx = checking "whether C++ supports --target" $ - supportsTarget _cxxProgram checkCxxWorks target cxx +cxxSupportsTarget :: ArchOS -> String -> Cxx -> M Cxx +cxxSupportsTarget archOs target cxx = + checking "whether C++ supports --target" $ + supportsTarget archOs _cxxProgram checkCxxWorks target cxx checkCxxWorks :: Cxx -> M () checkCxxWorks cxx = withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -62,7 +62,7 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp _ -> do -- If not then try to find decent linker flags findLinkFlags ldOverride cc rawCcLink <|> pure rawCcLink - ccLinkProgram <- linkSupportsTarget cc target ccLinkProgram + ccLinkProgram <- linkSupportsTarget archOs cc target ccLinkProgram ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram @@ -94,12 +94,12 @@ findLinkFlags enableOverride cc ccLink | otherwise = return ccLink -linkSupportsTarget :: Cc -> String -> Program -> M Program +linkSupportsTarget :: ArchOS -> Cc -> String -> Program -> M Program -- Javascript toolchain provided by emsdk just ignores --target flag so -- we have this special case to match with ./configure (#23744) -linkSupportsTarget cc target link - = checking "whether cc linker supports --target" $ - supportsTarget (Lens id const) (checkLinkWorks cc) target link +linkSupportsTarget archOs cc target link = + checking "whether cc linker supports --target" $ + supportsTarget archOs (Lens id const) (checkLinkWorks cc) target link -- | Should we attempt to find a more efficient linker on this platform? -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/391a4ce294ef5e16da4ff006657e6c7d8f02c767 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/391a4ce294ef5e16da4ff006657e6c7d8f02c767 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 20:37:20 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 02 Oct 2023 16:37:20 -0400 Subject: [Git][ghc/ghc][wip/hadrian-windows-bindist-cross] toolchain: Don't pass --target to emscripten toolchain Message-ID: <651b2a00d3418_364e041c2fec542807d9@gitlab.mail> Ben Gamari pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC Commits: 40b264e8 by Ben Gamari at 2023-10-02T16:37:10-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 7 changed files: - m4/fp_cc_supports_target.m4 - m4/fp_prog_cc_linker_target.m4 - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/src/GHC/Toolchain/Program.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== m4/fp_cc_supports_target.m4 ===================================== @@ -14,8 +14,13 @@ AC_DEFUN([FP_CC_SUPPORTS_TARGET], [ AC_REQUIRE([GHC_LLVM_TARGET_SET_VAR]) AC_MSG_CHECKING([whether $1 supports --target]) + echo 'int main() { return 0; }' > conftest.c - if $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then + if test "$target_cpu" = "javascript" ; then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then CONF_CC_SUPPORTS_TARGET=YES AC_MSG_RESULT([yes]) else ===================================== m4/fp_prog_cc_linker_target.m4 ===================================== @@ -8,11 +8,18 @@ AC_DEFUN([FP_PROG_CC_LINKER_TARGET], [ AC_MSG_CHECKING([whether $CC used as a linker understands --target]) + echo 'int foo() { return 0; }' > conftest1.c echo 'int main() { return 0; }' > conftest2.c "${CC}" $$1 -c conftest1.c || AC_MSG_ERROR([Failed to compile conftest1.c]) "${CC}" $$1 -c conftest2.c || AC_MSG_ERROR([Failed to compile conftest2.c]) - if "$CC" $$2 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; + + if test "$target_cpu" = "javascript" + then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif "$CC" $$2 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; then $2="--target=$LlvmTarget $$2" AC_MSG_RESULT([yes]) ===================================== utils/ghc-toolchain/exe/Main.hs ===================================== @@ -380,11 +380,15 @@ mkTarget opts = do normalised_triple <- normaliseTriple (optTriple opts) -- Use Llvm target if specified, otherwise use triple as llvm target let tgtLlvmTarget = fromMaybe normalised_triple (optLlvmTriple opts) - cc0 <- findCc tgtLlvmTarget (optCc opts) - cxx <- findCxx tgtLlvmTarget (optCxx opts) + + (archOs, tgtVendor) <- do + cc0 <- findBasicCc (optCc opts) + parseTriple cc0 normalised_triple + + cc0 <- findCc archOs tgtLlvmTarget (optCc opts) + cxx <- findCxx archOs tgtLlvmTarget (optCxx opts) cpp <- findCpp (optCpp opts) cc0 hsCpp <- findHsCpp (optHsCpp opts) cc0 - (archOs, tgtVendor) <- parseTriple cc0 normalised_triple cc <- addPlatformDepCcFlags archOs cc0 readelf <- optional $ findReadelf (optReadelf opts) ccLink <- findCcLink tgtLlvmTarget (optLd opts) (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Program.hs ===================================== @@ -30,6 +30,7 @@ import System.Directory import System.Exit import System.Process hiding (env) +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Utils @@ -182,17 +183,37 @@ compile ext extraFlags lens c outPath program = do callProgram (view lens c) $ extraFlags ++ ["-o", outPath, srcPath] expectFileExists outPath "compiler produced no output" +-- Note [Don't pass --target to emscripten toolchain] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Emscripten's CC wrapper is a bit wonky in that it accepts the `--target` +-- flag when used as a linker yet rejects it as a compiler (e.g. with `-c`). +-- This is exacerbated by the fact that Cabal currently in some cases +-- combines (and therefore conflates) link and compilation flags. +-- +-- Ultimately this should be fixed in Cabal but in the meantime we work around it +-- by handling this toolchain specifically in the various +-- "supports --target" checks in `configure` and `ghc-toolchain`. +-- +-- Fixes #23744. + -- | Does compiler program support the @--target=@ option? If so, we should -- pass it whenever possible to avoid ambiguity and potential compile-time -- errors (e.g. see #20162). -supportsTarget :: Lens compiler Program +supportsTarget :: ArchOS + -> Lens compiler Program -> (compiler -> M ()) -- ^ Action to check if compiler with @--target@ flag works -> String -- ^ The LLVM target to use if @cc@ supports @--target@ -> compiler -- ^ The compiler to check @--target@ support for -> M compiler -- ^ Return compiler with @--target@ flag if supported -supportsTarget lens checkWorks llvmTarget c --- TODO: #23603 - | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) = return c +supportsTarget archOs lens checkWorks llvmTarget c + -- See Note [Don't pass --target to emscripten toolchain]. + | ArchJavaScript <- archOS_arch archOs + = return c + + -- No reason to check if the options already contain a --target flag + | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) + = return c + | otherwise = let c' = over (lens % _prgFlags) (("--target="++llvmTarget):) c in (c' <$ checkWorks (over (lens % _prgFlags) ("-Werror":) c')) <|> return c ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs ===================================== @@ -4,6 +4,7 @@ module GHC.Toolchain.Tools.Cc ( Cc(..) , _ccProgram + , findBasicCc , findCc -- * Helpful utilities , preprocess @@ -33,22 +34,29 @@ _ccProgram = Lens ccProgram (\x o -> o{ccProgram=x}) _ccFlags :: Lens Cc [String] _ccFlags = _ccProgram % _prgFlags -findCc :: String -- ^ The llvm target to use if Cc supports --target - -> ProgOpt -> M Cc -findCc llvmTarget progOpt = checking "for C compiler" $ do +-- We use this to find a minimally-functional compiler needed to call +-- parseTriple. +findBasicCc :: ProgOpt -> M Cc +findBasicCc progOpt = checking "for C compiler" $ do -- TODO: We keep the candidate order we had in configure, but perhaps -- there's a more optimal one ccProgram <- findProgram "C compiler" progOpt ["gcc", "clang", "cc"] + return $ Cc{ccProgram} - cc0 <- ignoreUnusedArgs $ Cc {ccProgram} - cc1 <- ccSupportsTarget llvmTarget cc0 - checking "whether Cc works" $ checkCcWorks cc1 - cc2 <- oneOf "cc doesn't support C99" $ map checkC99Support - [ cc1 - , cc1 & _ccFlags %++ "-std=gnu99" +findCc :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target + -> ProgOpt -> M Cc +findCc archOs llvmTarget progOpt = do + cc0 <- findBasicCc progOpt + cc1 <- ignoreUnusedArgs cc0 + cc2 <- ccSupportsTarget archOs llvmTarget cc1 + checking "whether Cc works" $ checkCcWorks cc2 + cc3 <- oneOf "cc doesn't support C99" $ map checkC99Support + [ cc2 + , cc2 & _ccFlags %++ "-std=gnu99" ] - checkCcSupportsExtraViaCFlags cc2 - return cc2 + checkCcSupportsExtraViaCFlags cc3 + return cc3 checkCcWorks :: Cc -> M () checkCcWorks cc = withTempDir $ \dir -> do @@ -75,9 +83,10 @@ ignoreUnusedArgs cc -- Does Cc support the --target= option? If so, we should pass it -- whenever possible to avoid ambiguity and potential compile-time errors (e.g. -- see #20162). -ccSupportsTarget :: String -> Cc -> M Cc -ccSupportsTarget target cc = checking "whether Cc supports --target" $ - supportsTarget _ccProgram checkCcWorks target cc +ccSupportsTarget :: ArchOS -> String -> Cc -> M Cc +ccSupportsTarget archOs target cc = + checking "whether Cc supports --target" $ + supportsTarget archOs _ccProgram checkCcWorks target cc checkC99Support :: Cc -> M Cc checkC99Support cc = checking "for C99 support" $ withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs ===================================== @@ -8,6 +8,8 @@ module GHC.Toolchain.Tools.Cxx ) where import System.FilePath + +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Program import GHC.Toolchain.Utils @@ -19,18 +21,20 @@ newtype Cxx = Cxx { cxxProgram :: Program _cxxProgram :: Lens Cxx Program _cxxProgram = Lens cxxProgram (\x o -> o{cxxProgram=x}) -findCxx :: String -- ^ The llvm target to use if Cc supports --target +findCxx :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target -> ProgOpt -> M Cxx -findCxx target progOpt = checking "for C++ compiler" $ do +findCxx archOs target progOpt = checking "for C++ compiler" $ do -- TODO: We use the search order in configure, but there could be a more optimal one cxxProgram <- findProgram "C++ compiler" progOpt ["g++", "clang++", "c++"] - cxx <- cxxSupportsTarget target Cxx{cxxProgram} + cxx <- cxxSupportsTarget archOs target Cxx{cxxProgram} checkCxxWorks cxx return cxx -cxxSupportsTarget :: String -> Cxx -> M Cxx -cxxSupportsTarget target cxx = checking "whether C++ supports --target" $ - supportsTarget _cxxProgram checkCxxWorks target cxx +cxxSupportsTarget :: ArchOS -> String -> Cxx -> M Cxx +cxxSupportsTarget archOs target cxx = + checking "whether C++ supports --target" $ + supportsTarget archOs _cxxProgram checkCxxWorks target cxx checkCxxWorks :: Cxx -> M () checkCxxWorks cxx = withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -62,7 +62,7 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp _ -> do -- If not then try to find decent linker flags findLinkFlags ldOverride cc rawCcLink <|> pure rawCcLink - ccLinkProgram <- linkSupportsTarget cc target ccLinkProgram + ccLinkProgram <- linkSupportsTarget archOs cc target ccLinkProgram ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram @@ -94,12 +94,12 @@ findLinkFlags enableOverride cc ccLink | otherwise = return ccLink -linkSupportsTarget :: Cc -> String -> Program -> M Program +linkSupportsTarget :: ArchOS -> Cc -> String -> Program -> M Program -- Javascript toolchain provided by emsdk just ignores --target flag so -- we have this special case to match with ./configure (#23744) -linkSupportsTarget cc target link - = checking "whether cc linker supports --target" $ - supportsTarget (Lens id const) (checkLinkWorks cc) target link +linkSupportsTarget archOs cc target link = + checking "whether cc linker supports --target" $ + supportsTarget archOs (Lens id const) (checkLinkWorks cc) target link -- | Should we attempt to find a more efficient linker on this platform? -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/40b264e85734dda3f94b2dd54f72bdb50b868869 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/40b264e85734dda3f94b2dd54f72bdb50b868869 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 2 20:47:13 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 02 Oct 2023 16:47:13 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651b2c5152bfc_364e041c2fd14c286480@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0b55aa56 by Andrew Lelechenko at 2023-10-02T16:47:04-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - d28febc8 by Andrew Lelechenko at 2023-10-02T16:47:04-04:00 Inline bucket_match - - - - - 923488bd by sheaf at 2023-10-02T16:47:06-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - b9f2255a by Ben Gamari at 2023-10-02T16:47:07-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #23042. - - - - - 14 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - rts/sm/NonMoving.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cabaaafd76895ef714ff459abe9e447593bdfd34...b9f2255ad4aef276793104f78a9d144f3ee31bd3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cabaaafd76895ef714ff459abe9e447593bdfd34...b9f2255ad4aef276793104f78a9d144f3ee31bd3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 00:47:43 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 02 Oct 2023 20:47:43 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651b64af4fbdb_364e042237ad8033268d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b2de424c by Andrew Lelechenko at 2023-10-02T20:47:29-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 9fccb85c by Andrew Lelechenko at 2023-10-02T20:47:30-04:00 Inline bucket_match - - - - - f2fdaddc by sheaf at 2023-10-02T20:47:32-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a5cbe773 by Ben Gamari at 2023-10-02T20:47:32-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #23042. - - - - - 14 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - rts/sm/NonMoving.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9f2255ad4aef276793104f78a9d144f3ee31bd3...a5cbe773b6accbca4551b21a77310e83ad156e02 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9f2255ad4aef276793104f78a9d144f3ee31bd3...a5cbe773b6accbca4551b21a77310e83ad156e02 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 05:18:42 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 03 Oct 2023 01:18:42 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651ba431d6903_364e04288375e83603ea@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0245888a by Andrew Lelechenko at 2023-10-03T01:18:25-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 7f4979fa by Andrew Lelechenko at 2023-10-03T01:18:25-04:00 Inline bucket_match - - - - - 5a4f1dd8 by Ben Gamari at 2023-10-03T01:18:25-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 36d4cfb2 by sheaf at 2023-10-03T01:18:27-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - b8d32c8c by Ben Gamari at 2023-10-03T01:18:28-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #23042. - - - - - 15 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - m4/find_ld.m4 - rts/sm/NonMoving.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== m4/find_ld.m4 ===================================== @@ -70,19 +70,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a5cbe773b6accbca4551b21a77310e83ad156e02...b8d32c8c5f8b3da7a04d8e0da4b4c0dcfc812534 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a5cbe773b6accbca4551b21a77310e83ad156e02...b8d32c8c5f8b3da7a04d8e0da4b4c0dcfc812534 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 08:19:17 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 03 Oct 2023 04:19:17 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651bce8584501_364e042cf339ec40678a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 952a312a by Andrew Lelechenko at 2023-10-03T04:18:49-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - a6cdba47 by Andrew Lelechenko at 2023-10-03T04:18:49-04:00 Inline bucket_match - - - - - c8e747a9 by Ben Gamari at 2023-10-03T04:18:50-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 9920609b by sheaf at 2023-10-03T04:18:52-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - 96747a5f by Ben Gamari at 2023-10-03T04:18:52-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #23042. - - - - - 15 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - m4/find_ld.m4 - rts/sm/NonMoving.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== m4/find_ld.m4 ===================================== @@ -70,19 +70,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b8d32c8c5f8b3da7a04d8e0da4b4c0dcfc812534...96747a5fb8b3733c5b651bc1b2d5d9329916259b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b8d32c8c5f8b3da7a04d8e0da4b4c0dcfc812534...96747a5fb8b3733c5b651bc1b2d5d9329916259b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 09:26:36 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Oct 2023 05:26:36 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 74 commits: base: Advertise linear time of readFloat Message-ID: <651bde4cac2d1_364e042e7997e842264d@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - 8376424c by John Ericson at 2023-09-26T10:20:49-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - da2aef77 by John Ericson at 2023-09-26T10:21:05-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 7cb2985c by John Ericson at 2023-09-26T10:21:41-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - d07c237b by John Ericson at 2023-09-26T10:21:55-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 268250a1 by John Ericson at 2023-09-26T10:30:11-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - 87e6bdc2 by John Ericson at 2023-09-26T10:30:21-04:00 Move apple compat check to RTS configure - - - - - 3850d3be by John Ericson at 2023-09-26T10:32:06-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - d5016e2d by John Ericson at 2023-09-26T10:32:53-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 25c14435 by John Ericson at 2023-09-26T10:33:33-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 20f20114 by John Ericson at 2023-09-26T10:33:33-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 1c3054a5 by John Ericson at 2023-09-26T10:33:33-04:00 Move libdl check to RTS configure - - - - - 61ffadea by John Ericson at 2023-09-26T10:34:27-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - d3fe76fc by John Ericson at 2023-09-26T10:35:07-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - df1c1921 by John Ericson at 2023-09-26T10:35:07-04:00 Split libm check between top level and RTS - - - - - 1e4a4e87 by John Ericson at 2023-09-26T10:36:15-04:00 Move mingwex check to RTS configure - - - - - 969080bd by John Ericson at 2023-09-26T10:36:15-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 6f5c1aa7 by John Ericson at 2023-09-26T10:36:15-04:00 Move over a number of C-style checks to RTS configure - - - - - 129c83dd by John Ericson at 2023-09-26T10:36:15-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - fd787202 by John Ericson at 2023-09-26T10:36:15-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 2e5aa898 by John Ericson at 2023-09-26T10:36:15-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 1a245514 by GHC GitLab CI at 2023-10-02T16:17:57+00:00 wip: cross - - - - - 1f2eed0a by Matthew Pickering at 2023-10-02T16:17:57+00:00 stages - - - - - beab9407 by Matthew Pickering at 2023-10-02T16:17:57+00:00 Set cross-prefix appropiately - - - - - 01ccca1d by Matthew Pickering at 2023-10-02T16:17:57+00:00 misleading comment - - - - - 51ddcf1a by Matthew Pickering at 2023-10-02T16:17:57+00:00 fix - - - - - a81004a4 by GHC GitLab CI at 2023-10-02T16:17:57+00:00 NM_STAGE0 - - - - - 6c0ca9db by GHC GitLab CI at 2023-10-02T16:17:57+00:00 some succ stage - - - - - 403bbac4 by GHC GitLab CI at 2023-10-02T16:17:57+00:00 wip working - - - - - bdf4423c by Matthew Pickering at 2023-10-02T16:17:58+00:00 binary dist - - - - - b5ac25cd by GHC GitLab CI at 2023-10-02T16:17:58+00:00 fix - - - - - 7839ee23 by GHC GitLab CI at 2023-10-02T16:17:58+00:00 Build static cross binaries - - - - - 48fc70d4 by Matthew Pickering at 2023-10-02T16:17:58+00:00 Remove cross predicates - - - - - b6d1c5b3 by Matthew Pickering at 2023-10-02T16:17:58+00:00 Propagate some more Stage0 variables to host file - - - - - 915002e0 by Matthew Pickering at 2023-10-02T16:17:58+00:00 clean - - - - - 1f407a3e by GHC GitLab CI at 2023-10-02T16:17:58+00:00 fix hsc2hs cross predicate - - - - - e9e1eff2 by GHC GitLab CI at 2023-10-02T16:17:58+00:00 pass proper host on cabal configure - - - - - 11421a3d by John Ericson at 2023-10-02T17:25:31+00:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 893cb7da by John Ericson at 2023-10-02T17:26:05+00:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Build.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Error.hs - compiler/GHC/Unit/Info.hs - compiler/GHC/Utils/Outputable.hs - configure.ac - distrib/cross-port - docs/users_guide/expected-undocumented-flags.txt - docs/users_guide/using.rst - hadrian/bootstrap/plan-9_4_1.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed997787139890b5e669948cd5f98f29ee3dcf60...893cb7da329f243e4f0b09d0c1f8a2babba54f7d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed997787139890b5e669948cd5f98f29ee3dcf60...893cb7da329f243e4f0b09d0c1f8a2babba54f7d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 11:36:18 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 03 Oct 2023 07:36:18 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] CROSS_STAGE variable Message-ID: <651bfcb270125_364e0431695934449181@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 29b56497 by Matthew Pickering at 2023-10-03T12:35:36+01:00 CROSS_STAGE variable - - - - - 4 changed files: - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== .gitlab/ci.sh ===================================== @@ -58,6 +58,9 @@ Hadrian build system Environment variables affecting both build systems: CROSS_TARGET Triple of cross-compilation target. + CROSS_STAGE The stage of the cross-compiler to build either + * 2: Build a normal cross-compiler bindist + * 3: Build a target executable bindist (with the stage2 cross-compiler) VERBOSE Set to non-empty for verbose build output RUNTEST_ARGS Arguments passed to runtest.py MSYSTEM (Windows-only) Which platform to build from (CLANG64). @@ -487,6 +490,12 @@ function build_hadrian() { export XZ_OPT="${XZ_OPT:-} -T$cores" fi + case "${CROSS_STAGE:2}" in + 2) BINDIST_TARGET="binary-dist";; + 3) BINDIST_TARGET="binary-dist-stage3";; + *) fail "Unknown CROSS_STAGE, must be 2 or 3";; + esac + if [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian build-cabal -V else @@ -496,7 +505,7 @@ function build_hadrian() { mv _build/reloc-bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz" ;; *) - run_hadrian test:all_deps binary-dist -V + run_hadrian test:all_deps $BINDIST_TARGET mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz" ;; esac ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -145,6 +145,7 @@ data BuildConfig , withNuma :: Bool , withZstd :: Bool , crossTarget :: Maybe String + , crossStage :: Maybe Int , crossEmulator :: CrossEmulator , configureWrapper :: Maybe String , fullyStatic :: Bool @@ -159,7 +160,7 @@ configureArgsStr :: BuildConfig -> String configureArgsStr bc = unwords $ ["--enable-unregisterised"| unregisterised bc ] ++ ["--disable-tables-next-to-code" | not (tablesNextToCode bc) ] - ++ ["--with-intree-gmp" | Just _ <- pure (crossTarget bc) ] + ++ ["--with-intree-gmp" | Just _ <- [crossTarget bc] ] ++ ["--with-system-libffi" | crossTarget bc == Just "wasm32-wasi" ] ++ ["--enable-ipe-data-compression" | withZstd bc ] ++ ["--enable-strict-ghc-toolchain-check"] @@ -203,6 +204,7 @@ vanilla = BuildConfig , withNuma = False , withZstd = False , crossTarget = Nothing + , crossStage = Nothing , crossEmulator = NoEmulator , configureWrapper = Nothing , fullyStatic = False @@ -249,6 +251,7 @@ crossConfig :: String -- ^ target triple -> BuildConfig crossConfig triple emulator configure_wrapper = vanilla { crossTarget = Just triple + , crossStage = Just 2 , crossEmulator = emulator , configureWrapper = configure_wrapper } @@ -746,6 +749,7 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} } , "CONFIGURE_ARGS" =: configureArgsStr buildConfig , maybe mempty ("CONFIGURE_WRAPPER" =:) (configureWrapper buildConfig) , maybe mempty ("CROSS_TARGET" =:) (crossTarget buildConfig) + , maybe mempty (("CROSS_STAGE" =:) . show) (crossStage buildConfig) , case crossEmulator buildConfig of NoEmulator -> case crossTarget buildConfig of Nothing -> mempty ===================================== .gitlab/jobs.yaml ===================================== @@ -951,6 +951,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", + "CROSS_STAGE": "2", "CROSS_TARGET": "wasm32-wasi", "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", @@ -1015,6 +1016,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-int_native-cross_wasm32-wasi-release+fully_static", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", + "CROSS_STAGE": "2", "CROSS_TARGET": "wasm32-wasi", "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", @@ -1079,6 +1081,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-unreg-cross_wasm32-wasi-release+fully_static", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--enable-unregisterised --with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", + "CROSS_STAGE": "2", "CROSS_TARGET": "wasm32-wasi", "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", @@ -1768,6 +1771,7 @@ "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_STAGE": "2", "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate", @@ -1833,6 +1837,7 @@ "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", "CONFIGURE_WRAPPER": "emconfigure", "CROSS_EMULATOR": "js-emulator", + "CROSS_STAGE": "2", "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", @@ -4526,6 +4531,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", + "CROSS_STAGE": "2", "CROSS_TARGET": "wasm32-wasi", "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", @@ -4590,6 +4596,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-int_native-cross_wasm32-wasi-release+fully_static", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", + "CROSS_STAGE": "2", "CROSS_TARGET": "wasm32-wasi", "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", @@ -4654,6 +4661,7 @@ "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-unreg-cross_wasm32-wasi-release+fully_static", "BUILD_FLAVOUR": "release+fully_static", "CONFIGURE_ARGS": "--enable-unregisterised --with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check", + "CROSS_STAGE": "2", "CROSS_TARGET": "wasm32-wasi", "HADRIAN_ARGS": "--docs=none", "RUNTEST_ARGS": "", @@ -5211,6 +5219,7 @@ "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu", + "CROSS_STAGE": "2", "CROSS_TARGET": "aarch64-linux-gnu", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" @@ -5275,6 +5284,7 @@ "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", "CONFIGURE_WRAPPER": "emconfigure", "CROSS_EMULATOR": "js-emulator", + "CROSS_STAGE": "2", "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -330,6 +330,7 @@ bindistRules = do if cross then need ["binary-dist-dir-cross"] else buildBinDistDir root normalBindist + phony "binary-dist-dir-cross" $ buildBinDistDir root crossBindist phony "binary-dist-dir-stage3" $ buildBinDistDir root targetBindist @@ -361,6 +362,10 @@ bindistRules = do phony (name <> "-dist-bzip2") $ mk_bindist Bzip2 phony (name <> "-dist-xz") $ mk_bindist Xz + -- TODO: Generate these targets as well + phony ("binary-dist-cross") $ buildBinDistX "binary-dist-dir-cross" "bindist" Xz + phony ("binary-dist-stage3") $ buildBinDistX "binary-dist-dir-stage3" "bindist" Xz + -- Prepare binary distribution configure script -- (generated under /distrib/configure by 'autoreconf') root -/- "bindist" -/- "ghc-*" -/- "configure" %> \configurePath -> do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/29b56497777d8828da820dce7597ebda807e3b25 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/29b56497777d8828da820dce7597ebda807e3b25 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 13:23:09 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Tue, 03 Oct 2023 09:23:09 -0400 Subject: [Git][ghc/ghc][wip/expand-do] Regression for #21206 fixed as part of #18324 Message-ID: <651c15bdc9821_364e0433e11abc47166d@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 09c87b21 by Apoorv Ingle at 2023-10-03T08:22:53-05:00 Regression for #21206 fixed as part of #18324 - - - - - 1 changed file: - + testsuite/tests/typecheck/should_compile/T21206.hs Changes: ===================================== testsuite/tests/typecheck/should_compile/T21206.hs ===================================== @@ -0,0 +1,33 @@ +{-# LANGUAGE QualifiedDo #-} +module T where + +import Prelude hiding (pure, (>>=)) + +data Free f u a + = Pure (u a) + | forall x. Free (f u x) (forall u'. u <= u' => u' x -> Free f u' x) + +pure :: u a -> Free f u a +pure = Pure +(>>=) :: Free f u a -> (forall u'. u <= u' => u' a -> Free f u' a) -> Free f u a +Pure x >>= k = k x + +class f < g where + inj :: f u a -> g u a + +class u <= u' where + inj' :: u a -> u' a + +instance u <= u where + inj' = id + +send :: (f < g) => f u a -> Free g u a +send op = Free (inj op) Pure + +data State s u a where + Get :: State s u s + Put :: u s -> State s u () + +prog () = T.do + x <- send Get + Pure x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/09c87b21bf8edd323916ceb70052620844bf5dc3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/09c87b21bf8edd323916ceb70052620844bf5dc3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 13:25:44 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Tue, 03 Oct 2023 09:25:44 -0400 Subject: [Git][ghc/ghc][wip/expand-do] Regression for #21206 fixed as part of #18324 Message-ID: <651c16583ce_364e0433ab3cf84728f9@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: e010a03c by Apoorv Ingle at 2023-10-03T08:25:26-05:00 Regression for #21206 fixed as part of #18324 - - - - - 2 changed files: - + testsuite/tests/typecheck/should_compile/T21206.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== testsuite/tests/typecheck/should_compile/T21206.hs ===================================== @@ -0,0 +1,33 @@ +{-# LANGUAGE QualifiedDo #-} +module T where + +import Prelude hiding (pure, (>>=)) + +data Free f u a + = Pure (u a) + | forall x. Free (f u x) (forall u'. u <= u' => u' x -> Free f u' x) + +pure :: u a -> Free f u a +pure = Pure +(>>=) :: Free f u a -> (forall u'. u <= u' => u' a -> Free f u' a) -> Free f u a +Pure x >>= k = k x + +class f < g where + inj :: f u a -> g u a + +class u <= u' where + inj' :: u a -> u' a + +instance u <= u where + inj' = id + +send :: (f < g) => f u a -> Free g u a +send op = Free (inj op) Pure + +data State s u a where + Get :: State s u s + Put :: u s -> State s u () + +prog () = T.do + x <- send Get + Pure x ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -896,3 +896,4 @@ test('T23861', normal, compile, ['']) test('T23918', normal, compile, ['']) test('T17564', normal, compile, ['']) test('T22788', normal, compile, ['']) +test('T21206', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e010a03c1f2ba0d565f9751af5ab83f1fc388d4e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e010a03c1f2ba0d565f9751af5ab83f1fc388d4e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 14:48:01 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 10:48:01 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24049 Message-ID: <651c29a1e8918_3432531ad851c134179@gitlab.mail> Ben Gamari pushed new branch wip/T24049 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24049 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 14:55:43 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 10:55:43 -0400 Subject: [Git][ghc/ghc][wip/T24049] users-guide: Fix discussion of -Wpartial-fields Message-ID: <651c2b6f50d6c_3432531b08dac1414cf@gitlab.mail> Ben Gamari pushed to branch wip/T24049 at Glasgow Haskell Compiler / GHC Commits: 2ed20a3f by Ben Gamari at 2023-10-03T14:55:41+00:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 1 changed file: - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2158,7 +2158,7 @@ of ``-W(no-)*``. The option :ghc-flag:`-Wpartial-fields` warns about a record field ``f`` that is defined in some, but not all, the contructors of a - data type, because ```f``\ 's record selector function may fail. For + data type, because ``f``\ 's record selector function may fail. For example, the record selector function ``f``, defined in the ``Foo`` constructor record below, will fail when applied to ``Bar``, so the compiler will emit a warning at its definition when @@ -2170,6 +2170,9 @@ of ``-W(no-)*``. data Foo = Foo { _f :: Int } | Bar + Another related warning is :ghc-flag:`-Wincomplete-record-selectors`, + which warns at use sites rather than definition sites. + .. ghc-flag:: -Wunused-packages :shortdesc: warn when package is requested on command line, but not needed. :type: dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ed20a3f717a515ff968c277b44b6f32383621f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ed20a3f717a515ff968c277b44b6f32383621f8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 14:57:32 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 10:57:32 -0400 Subject: [Git][ghc/ghc][wip/T24049] users-guide: Fix discussion of -Wpartial-fields Message-ID: <651c2bdc9ca82_34325318bf0c814334a@gitlab.mail> Ben Gamari pushed to branch wip/T24049 at Glasgow Haskell Compiler / GHC Commits: 03135171 by Ben Gamari at 2023-10-03T10:57:21-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 1 changed file: - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2157,16 +2157,21 @@ of ``-W(no-)*``. :since: 8.4 The option :ghc-flag:`-Wpartial-fields` warns about a record field - `f` that is defined in some, but not all, the contructors of a - data type, because `f`'s record selector function may fail. For - exampe, the record selector function `f`, defined in the `Foo` + ``f`` that is defined in some, but not all, the contructors of a + data type, because ``f``\ 's record selector function may fail. For + example, the record selector function ``f``, defined in the ``Foo`` constructor record below, will fail when applied to ``Bar``, so the compiler will emit a warning at its definition when - :ghc-flag:`-Wpartial-fields` is enabled. + :ghc-flag:`-Wpartial-fields` is enabled. :: + + data Foo = Foo { f :: Int } | Bar The warning is suppressed if the field name begins with an underscore. :: - data Foo = Foo { f :: Int } | Bar + data Foo = Foo { _f :: Int } | Bar + + Another related warning is :ghc-flag:`-Wincomplete-record-selectors`, + which warns at use sites rather than definition sites. .. ghc-flag:: -Wunused-packages :shortdesc: warn when package is requested on command line, but not needed. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03135171c9902be077d2750edb71a9e3a7e65435 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03135171c9902be077d2750edb71a9e3a7e65435 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 16:22:04 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 12:22:04 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24052 Message-ID: <651c3fac334cb_3432533f59c24165221@gitlab.mail> Ben Gamari pushed new branch wip/T24052 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24052 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 16:23:16 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 12:23:16 -0400 Subject: [Git][ghc/ghc][wip/T24052] 3 commits: testsuite: Run some tests unconditionally in nonmoving ways Message-ID: <651c3ff4c510e_3432533f8633c1654c2@gitlab.mail> Ben Gamari pushed to branch wip/T24052 at Glasgow Haskell Compiler / GHC Commits: 14b1e783 by Ben Gamari at 2023-10-03T12:22:32-04:00 testsuite: Run some tests unconditionally in nonmoving ways Improve test coverage of the nonmoving collector by running a small subset of tests unconditionally with the nonmoving collector. Fixes #24052. - - - - - 95133e41 by Ben Gamari at 2023-10-03T12:23:09-04:00 testsuite: Fix invalid string literal `"\+"` is not a valid Python string; this should have been `r"\+"`. - - - - - 04e32ed6 by Ben Gamari at 2023-10-03T12:23:09-04:00 rts/nonmoving: Reflow notes - - - - - 3 changed files: - rts/sm/NonMoving.c - testsuite/driver/testlib.py - testsuite/tests/concurrent/should_run/all.T Changes: ===================================== rts/sm/NonMoving.c ===================================== @@ -151,9 +151,9 @@ static void nonmovingBumpEpoch(void) { * 3. [STW] Root collection: Here we walk over a variety of root sources * and add them to the mark queue (see nonmovingCollect). * - * 4. [CONC] Concurrent marking: Here we do the majority of marking concurrently - * with mutator execution (but with the write barrier enabled; see - * Note [Update remembered set]). + * 4. [CONC] Concurrent marking: Here we do the majority of marking + * concurrently with mutator execution (but with the write barrier enabled; + * see Note [Update remembered set]). * * 5. [STW] Final sync: Here we interrupt the mutators, ask them to * flush their final update remembered sets, and mark any new references @@ -218,9 +218,9 @@ static void nonmovingBumpEpoch(void) { * - Note [Concurrent read barrier on deRefWeak#] (NonMovingMark.c) describes * the read barrier on Weak# objects. * - * - Note [Unintentional marking in resurrectThreads] (NonMovingMark.c) describes - * a tricky interaction between the update remembered set flush and weak - * finalization. + * - Note [Unintentional marking in resurrectThreads] (NonMovingMark.c) + * describes a tricky interaction between the update remembered set flush and + * weak finalization. * * - Note [Origin references in the nonmoving collector] (NonMovingMark.h) * describes how we implement indirection short-cutting and the selector @@ -229,8 +229,8 @@ static void nonmovingBumpEpoch(void) { * - Note [StgStack dirtiness flags and concurrent marking] (TSO.h) describes * the protocol for concurrent marking of stacks. * - * - Note [Nonmoving write barrier in Perform{Put,Take}] (PrimOps.cmm) describes - * a tricky barrier necessary when resuming threads blocked on MVar + * - Note [Nonmoving write barrier in Perform{Put,Take}] (PrimOps.cmm) + * describes a tricky barrier necessary when resuming threads blocked on MVar * operations. * * - Note [Static objects under the nonmoving collector] (Storage.c) describes @@ -240,13 +240,17 @@ static void nonmovingBumpEpoch(void) { * how we use the DIRTY flags associated with MUT_VARs and TVARs to improve * barrier efficiency. * - * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) describes - * how weak pointers are handled when the non-moving GC is in use. + * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) + * describes how weak pointers are handled when the non-moving GC is in use. * * - Note [Sync phase marking budget] describes how we avoid long mutator * pauses during the sync phase * - * - Note [Allocator sizes] goes into detail about our choice of allocator sizes. + * - Note [Allocator sizes] goes into detail about our choice of allocator + * sizes. + * + * - Note [Testing the nonmoving collector] describes how we test the + * collector. * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage @@ -259,15 +263,15 @@ static void nonmovingBumpEpoch(void) { * Concurrency-control of non-moving garbage collection is a bit tricky. There * are a few things to keep in mind: * - * - Only one non-moving collection may be active at a time. This is enforced by the - * concurrent_coll_running flag, which is set when a collection is on-going. If - * we attempt to initiate a new collection while this is set we wait on the - * concurrent_coll_finished condition variable, which signals when the - * active collection finishes. + * - Only one non-moving collection may be active at a time. This is enforced + * by the concurrent_coll_running flag, which is set when a collection is + * on-going. If we attempt to initiate a new collection while this is set we + * wait on the concurrent_coll_finished condition variable, which signals + * when the active collection finishes. * - * - In between the mark and sweep phases the non-moving collector must synchronize - * with mutator threads to collect and mark their final update remembered - * sets. This is accomplished using + * - In between the mark and sweep phases the non-moving collector must + * synchronize with mutator threads to collect and mark their final update + * remembered sets. This is accomplished using * stopAllCapabilitiesWith(SYNC_FLUSH_UPD_REM_SET). Capabilities are held * the final mark has concluded. * @@ -361,9 +365,9 @@ static void nonmovingBumpEpoch(void) { * ╰─────────────────╯ * ┆ * - * In this case we have a TSO blocked on a dead MVar. Because the MVAR_TSO_QUEUE on - * which it is blocked lives in the moving heap, the TSO is necessarily on the - * oldest generation's mut_list. As in Note [Aging under the non-moving + * In this case we have a TSO blocked on a dead MVar. Because the MVAR_TSO_QUEUE + * on which it is blocked lives in the moving heap, the TSO is necessarily on + * the oldest generation's mut_list. As in Note [Aging under the non-moving * collector], the MVAR_TSO_QUEUE will be evacuated. If MVAR_TSO_QUEUE is aged * (e.g. evacuated to the young generation) then the MVAR will be added to the * mark queue. Consequently, we will falsely conclude that the MVAR is still @@ -387,9 +391,9 @@ static void nonmovingBumpEpoch(void) { * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The nonmoving collector uses an approximate heuristic for reporting live * data quantity. Specifically, during mark we record how much live data we - * find in nonmoving_segment_live_words. At the end of mark this is combined with nonmoving_large_words - * and nonmoving_compact_words, and we declare this amount to - * be how much live data we have on in the nonmoving heap (by setting + * find in nonmoving_segment_live_words. At the end of mark this is combined + * with nonmoving_large_words and nonmoving_compact_words, and we declare this + * amount to be how much live data we have on in the nonmoving heap (by setting * oldest_gen->live_estimate). * * In addition, we update oldest_gen->live_estimate every time we fill a @@ -413,10 +417,10 @@ static void nonmovingBumpEpoch(void) { * - Minor collections assume that all sparks living in the non-moving heap * are reachable. * - * - Major collections prune the spark queue during the final sync. This pruning - * assumes that all sparks in the young generations are reachable (since the - * BF_EVACUATED flag won't be set on the nursery blocks) and will consequently - * only prune dead sparks living in the non-moving heap. + * - Major collections prune the spark queue during the final sync. This + * pruning assumes that all sparks in the young generations are reachable (since + * the BF_EVACUATED flag won't be set on the nursery blocks) and will + * consequently only prune dead sparks living in the non-moving heap. * * * Note [Dirty flags in the non-moving collector] @@ -439,8 +443,8 @@ static void nonmovingBumpEpoch(void) { * In the non-moving collector we use the same dirty flag to implement a * related optimisation on the non-moving write barrier: Specifically, the * snapshot invariant only requires that the non-moving write barrier applies - * to the *first* mutation to an object after collection begins. To achieve this, - * we impose the following invariant: + * to the *first* mutation to an object after collection begins. To achieve + * this, we impose the following invariant: * * An object being marked as dirty implies that all of its fields are on * the mark queue (or, equivalently, update remembered set). @@ -492,8 +496,8 @@ static void nonmovingBumpEpoch(void) { * ┊ * * This is bad. When we resume mutation a mutator may mutate MVAR A; since it's - * already dirty we would fail to add Y to the update remembered set, breaking the - * snapshot invariant and potentially losing track of the liveness of Z. + * already dirty we would fail to add Y to the update remembered set, breaking + * the snapshot invariant and potentially losing track of the liveness of Z. * * To avoid this nonmovingScavengeOne we eagerly pushes the values of the * fields of all objects which it fails to evacuate (e.g. MVAR A) to the update @@ -535,8 +539,9 @@ static void nonmovingBumpEpoch(void) { * Note [Allocator sizes] * ~~~~~~~~~~~~~~~~~~~~~~ * Our choice of allocator sizes has to balance several considerations: - * - Allocator sizes should be available for the most commonly request block sizes, - * in order to avoid excessive waste from rounding up to the next size (internal fragmentation). + * - Allocator sizes should be available for the most commonly request block + * sizes, in order to avoid excessive waste from rounding up to the next size + * (internal fragmentation). * - It should be possible to efficiently determine which allocator services * a certain block size. * - The amount of allocators should be kept down to avoid overheads @@ -548,18 +553,37 @@ static void nonmovingBumpEpoch(void) { * arbitrary allocator sizes, we need to do some precomputation and make * use of the integer division by constants optimisation. * - * We currenlty try to balance these considerations by adopting the following scheme. - * We have nonmoving_alloca_dense_cnt "dense" allocators starting with size - * NONMOVING_ALLOCA0, and incrementing by NONMOVING_ALLOCA_DENSE_INCREMENT. + * We currenlty try to balance these considerations by adopting the following + * scheme. We have nonmoving_alloca_dense_cnt "dense" allocators starting with + * size NONMOVING_ALLOCA0, and incrementing by NONMOVING_ALLOCA_DENSE_INCREMENT. * These service the vast majority of allocations. * In practice, Haskell programs tend to allocate a lot of small objects. * - * Other allocations are handled by a family of "sparse" allocators, each providing - * blocks up to a power of 2. This places an upper bound on the waste at half the - * required block size. + * Other allocations are handled by a family of "sparse" allocators, each + * providing blocks up to a power of 2. This places an upper bound on the waste + * at half the required block size. * * See #23340 * + * + * Note [Testing the nonmoving collector] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * The testsuite has four "ways" which test the nonmoving collector: + * + * - nonmoving: runs tests under the nonmoving collector running in + * non-concurrent mode (i.e. using the non-threaded runtime) + * - nonmoving_thr: runs tests under the collector running in concurrent + * mode (with the threaded runtime) + * - nonmoving_thr_sanity: runs tests with concurrent collection and + * sanity checking (i.e. `+RTS -DS`) + * - nonmoving_thr_ghc: compiles tests with `ghc +RTS --nonmoving-gc -RTS` + * as GHC itself tends to be a good smoke test of the collector. + * + * To avoid blowing up validation times, we do not run any of these ways in the + * default "normal" test speed. To ensure that we catch regressions in during + * normal validation we do run a small number of tests in these ways. These + * tests are identified by the `nonmoving_test` test modifier. + * */ memcount nonmoving_segment_live_words = 0; ===================================== testsuite/driver/testlib.py ===================================== @@ -149,6 +149,10 @@ def js_broken( bug: IssueNumber ): else: return normal; +def nonmoving_test( name, opts ): + """ See Note [Testing the nonmoving collector] in rts/sm/NonMoving.c """ + return extra_ways(['nonmoving', 'nonmoving_thr_sanity', 'nonmoving_thr_ghc'])(name, opts) + def expect_fail( name, opts ): # The compiler, testdriver, OS or platform is missing a certain # feature, and we don't plan to or can't fix it now or in the @@ -1023,8 +1027,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -1,3 +1,5 @@ +setTestOpts(nonmoving_test) + # ----------------------------------------------------------------------------- # These tests we do even for 'make fast' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5cc3de7ba741055eec293cf790b68de52631636e...04e32ed6bc1c4c1dbe5b3dcf4ac6294d2a836dd9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5cc3de7ba741055eec293cf790b68de52631636e...04e32ed6bc1c4c1dbe5b3dcf4ac6294d2a836dd9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 16:27:56 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 12:27:56 -0400 Subject: [Git][ghc/ghc][wip/T24052] 3 commits: testsuite: Fix invalid string literal Message-ID: <651c410c12f14_34325345a6ba41687d6@gitlab.mail> Ben Gamari pushed to branch wip/T24052 at Glasgow Haskell Compiler / GHC Commits: 39248140 by Ben Gamari at 2023-10-03T12:27:46-04:00 testsuite: Fix invalid string literal `"\+"` is not a valid Python string; this should have been `r"\+"`. - - - - - 610067f2 by Ben Gamari at 2023-10-03T12:27:46-04:00 rts/nonmoving: Reflow notes - - - - - a1526106 by Ben Gamari at 2023-10-03T12:27:46-04:00 testsuite: Run some tests unconditionally in nonmoving ways Improve test coverage of the nonmoving collector by running a small subset of tests unconditionally with the nonmoving collector. Fixes #24052. - - - - - 4 changed files: - rts/sm/NonMoving.c - testsuite/driver/testlib.py - testsuite/tests/array/should_run/all.T - testsuite/tests/concurrent/should_run/all.T Changes: ===================================== rts/sm/NonMoving.c ===================================== @@ -151,9 +151,9 @@ static void nonmovingBumpEpoch(void) { * 3. [STW] Root collection: Here we walk over a variety of root sources * and add them to the mark queue (see nonmovingCollect). * - * 4. [CONC] Concurrent marking: Here we do the majority of marking concurrently - * with mutator execution (but with the write barrier enabled; see - * Note [Update remembered set]). + * 4. [CONC] Concurrent marking: Here we do the majority of marking + * concurrently with mutator execution (but with the write barrier enabled; + * see Note [Update remembered set]). * * 5. [STW] Final sync: Here we interrupt the mutators, ask them to * flush their final update remembered sets, and mark any new references @@ -218,9 +218,9 @@ static void nonmovingBumpEpoch(void) { * - Note [Concurrent read barrier on deRefWeak#] (NonMovingMark.c) describes * the read barrier on Weak# objects. * - * - Note [Unintentional marking in resurrectThreads] (NonMovingMark.c) describes - * a tricky interaction between the update remembered set flush and weak - * finalization. + * - Note [Unintentional marking in resurrectThreads] (NonMovingMark.c) + * describes a tricky interaction between the update remembered set flush and + * weak finalization. * * - Note [Origin references in the nonmoving collector] (NonMovingMark.h) * describes how we implement indirection short-cutting and the selector @@ -229,8 +229,8 @@ static void nonmovingBumpEpoch(void) { * - Note [StgStack dirtiness flags and concurrent marking] (TSO.h) describes * the protocol for concurrent marking of stacks. * - * - Note [Nonmoving write barrier in Perform{Put,Take}] (PrimOps.cmm) describes - * a tricky barrier necessary when resuming threads blocked on MVar + * - Note [Nonmoving write barrier in Perform{Put,Take}] (PrimOps.cmm) + * describes a tricky barrier necessary when resuming threads blocked on MVar * operations. * * - Note [Static objects under the nonmoving collector] (Storage.c) describes @@ -240,13 +240,17 @@ static void nonmovingBumpEpoch(void) { * how we use the DIRTY flags associated with MUT_VARs and TVARs to improve * barrier efficiency. * - * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) describes - * how weak pointers are handled when the non-moving GC is in use. + * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) + * describes how weak pointers are handled when the non-moving GC is in use. * * - Note [Sync phase marking budget] describes how we avoid long mutator * pauses during the sync phase * - * - Note [Allocator sizes] goes into detail about our choice of allocator sizes. + * - Note [Allocator sizes] goes into detail about our choice of allocator + * sizes. + * + * - Note [Testing the nonmoving collector] describes how we test the + * collector. * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage @@ -259,15 +263,15 @@ static void nonmovingBumpEpoch(void) { * Concurrency-control of non-moving garbage collection is a bit tricky. There * are a few things to keep in mind: * - * - Only one non-moving collection may be active at a time. This is enforced by the - * concurrent_coll_running flag, which is set when a collection is on-going. If - * we attempt to initiate a new collection while this is set we wait on the - * concurrent_coll_finished condition variable, which signals when the - * active collection finishes. + * - Only one non-moving collection may be active at a time. This is enforced + * by the concurrent_coll_running flag, which is set when a collection is + * on-going. If we attempt to initiate a new collection while this is set we + * wait on the concurrent_coll_finished condition variable, which signals + * when the active collection finishes. * - * - In between the mark and sweep phases the non-moving collector must synchronize - * with mutator threads to collect and mark their final update remembered - * sets. This is accomplished using + * - In between the mark and sweep phases the non-moving collector must + * synchronize with mutator threads to collect and mark their final update + * remembered sets. This is accomplished using * stopAllCapabilitiesWith(SYNC_FLUSH_UPD_REM_SET). Capabilities are held * the final mark has concluded. * @@ -361,9 +365,9 @@ static void nonmovingBumpEpoch(void) { * ╰─────────────────╯ * ┆ * - * In this case we have a TSO blocked on a dead MVar. Because the MVAR_TSO_QUEUE on - * which it is blocked lives in the moving heap, the TSO is necessarily on the - * oldest generation's mut_list. As in Note [Aging under the non-moving + * In this case we have a TSO blocked on a dead MVar. Because the MVAR_TSO_QUEUE + * on which it is blocked lives in the moving heap, the TSO is necessarily on + * the oldest generation's mut_list. As in Note [Aging under the non-moving * collector], the MVAR_TSO_QUEUE will be evacuated. If MVAR_TSO_QUEUE is aged * (e.g. evacuated to the young generation) then the MVAR will be added to the * mark queue. Consequently, we will falsely conclude that the MVAR is still @@ -387,9 +391,9 @@ static void nonmovingBumpEpoch(void) { * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The nonmoving collector uses an approximate heuristic for reporting live * data quantity. Specifically, during mark we record how much live data we - * find in nonmoving_segment_live_words. At the end of mark this is combined with nonmoving_large_words - * and nonmoving_compact_words, and we declare this amount to - * be how much live data we have on in the nonmoving heap (by setting + * find in nonmoving_segment_live_words. At the end of mark this is combined + * with nonmoving_large_words and nonmoving_compact_words, and we declare this + * amount to be how much live data we have on in the nonmoving heap (by setting * oldest_gen->live_estimate). * * In addition, we update oldest_gen->live_estimate every time we fill a @@ -413,10 +417,10 @@ static void nonmovingBumpEpoch(void) { * - Minor collections assume that all sparks living in the non-moving heap * are reachable. * - * - Major collections prune the spark queue during the final sync. This pruning - * assumes that all sparks in the young generations are reachable (since the - * BF_EVACUATED flag won't be set on the nursery blocks) and will consequently - * only prune dead sparks living in the non-moving heap. + * - Major collections prune the spark queue during the final sync. This + * pruning assumes that all sparks in the young generations are reachable (since + * the BF_EVACUATED flag won't be set on the nursery blocks) and will + * consequently only prune dead sparks living in the non-moving heap. * * * Note [Dirty flags in the non-moving collector] @@ -439,8 +443,8 @@ static void nonmovingBumpEpoch(void) { * In the non-moving collector we use the same dirty flag to implement a * related optimisation on the non-moving write barrier: Specifically, the * snapshot invariant only requires that the non-moving write barrier applies - * to the *first* mutation to an object after collection begins. To achieve this, - * we impose the following invariant: + * to the *first* mutation to an object after collection begins. To achieve + * this, we impose the following invariant: * * An object being marked as dirty implies that all of its fields are on * the mark queue (or, equivalently, update remembered set). @@ -492,8 +496,8 @@ static void nonmovingBumpEpoch(void) { * ┊ * * This is bad. When we resume mutation a mutator may mutate MVAR A; since it's - * already dirty we would fail to add Y to the update remembered set, breaking the - * snapshot invariant and potentially losing track of the liveness of Z. + * already dirty we would fail to add Y to the update remembered set, breaking + * the snapshot invariant and potentially losing track of the liveness of Z. * * To avoid this nonmovingScavengeOne we eagerly pushes the values of the * fields of all objects which it fails to evacuate (e.g. MVAR A) to the update @@ -535,8 +539,9 @@ static void nonmovingBumpEpoch(void) { * Note [Allocator sizes] * ~~~~~~~~~~~~~~~~~~~~~~ * Our choice of allocator sizes has to balance several considerations: - * - Allocator sizes should be available for the most commonly request block sizes, - * in order to avoid excessive waste from rounding up to the next size (internal fragmentation). + * - Allocator sizes should be available for the most commonly request block + * sizes, in order to avoid excessive waste from rounding up to the next size + * (internal fragmentation). * - It should be possible to efficiently determine which allocator services * a certain block size. * - The amount of allocators should be kept down to avoid overheads @@ -548,18 +553,37 @@ static void nonmovingBumpEpoch(void) { * arbitrary allocator sizes, we need to do some precomputation and make * use of the integer division by constants optimisation. * - * We currenlty try to balance these considerations by adopting the following scheme. - * We have nonmoving_alloca_dense_cnt "dense" allocators starting with size - * NONMOVING_ALLOCA0, and incrementing by NONMOVING_ALLOCA_DENSE_INCREMENT. + * We currenlty try to balance these considerations by adopting the following + * scheme. We have nonmoving_alloca_dense_cnt "dense" allocators starting with + * size NONMOVING_ALLOCA0, and incrementing by NONMOVING_ALLOCA_DENSE_INCREMENT. * These service the vast majority of allocations. * In practice, Haskell programs tend to allocate a lot of small objects. * - * Other allocations are handled by a family of "sparse" allocators, each providing - * blocks up to a power of 2. This places an upper bound on the waste at half the - * required block size. + * Other allocations are handled by a family of "sparse" allocators, each + * providing blocks up to a power of 2. This places an upper bound on the waste + * at half the required block size. * * See #23340 * + * + * Note [Testing the nonmoving collector] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * The testsuite has four "ways" which test the nonmoving collector: + * + * - nonmoving: runs tests under the nonmoving collector running in + * non-concurrent mode (i.e. using the non-threaded runtime) + * - nonmoving_thr: runs tests under the collector running in concurrent + * mode (with the threaded runtime) + * - nonmoving_thr_sanity: runs tests with concurrent collection and + * sanity checking (i.e. `+RTS -DS`) + * - nonmoving_thr_ghc: compiles tests with `ghc +RTS --nonmoving-gc -RTS` + * as GHC itself tends to be a good smoke test of the collector. + * + * To avoid blowing up validation times, we do not run any of these ways in the + * default "normal" test speed. To ensure that we catch regressions in during + * normal validation we do run a small number of tests in these ways. These + * tests are identified by the `nonmoving_test` test modifier. + * */ memcount nonmoving_segment_live_words = 0; ===================================== testsuite/driver/testlib.py ===================================== @@ -149,6 +149,15 @@ def js_broken( bug: IssueNumber ): else: return normal; +def nonmoving_test( name, opts ): + """ + Always run the given test with the nonmoving collector, in addition to + the usual ways. + + See Note [Testing the nonmoving collector] in rts/sm/NonMoving.c. + """ + return extra_ways(['nonmoving', 'nonmoving_thr_sanity', 'nonmoving_thr_ghc'])(name, opts) + def expect_fail( name, opts ): # The compiler, testdriver, OS or platform is missing a certain # feature, and we don't plan to or can't fix it now or in the @@ -1023,8 +1032,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): ===================================== testsuite/tests/array/should_run/all.T ===================================== @@ -21,6 +21,6 @@ test('arr014', when(fast(), skip), compile_and_run, ['']) test('arr015', when(fast(), skip), compile_and_run, ['']) test('arr017', when(fast(), skip), compile_and_run, ['']) test('arr018', when(fast(), skip), compile_and_run, ['']) -test('arr019', normal, compile_and_run, ['']) -test('arr020', normal, compile_and_run, ['']) +test('arr019', nonmoving_test, compile_and_run, ['']) +test('arr020', nonmoving_test, compile_and_run, ['']) test('T21962', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -1,3 +1,5 @@ +setTestOpts(nonmoving_test) + # ----------------------------------------------------------------------------- # These tests we do even for 'make fast' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04e32ed6bc1c4c1dbe5b3dcf4ac6294d2a836dd9...a1526106a847308dd52ad8f485f4de3c9ae80427 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04e32ed6bc1c4c1dbe5b3dcf4ac6294d2a836dd9...a1526106a847308dd52ad8f485f4de3c9ae80427 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 16:36:42 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 12:36:42 -0400 Subject: [Git][ghc/ghc][wip/T24052] testsuite: Run some tests unconditionally in nonmoving ways Message-ID: <651c431a57cbe_343253456e90c1721be@gitlab.mail> Ben Gamari pushed to branch wip/T24052 at Glasgow Haskell Compiler / GHC Commits: ff7716e9 by Ben Gamari at 2023-10-03T12:36:34-04:00 testsuite: Run some tests unconditionally in nonmoving ways Improve test coverage of the nonmoving collector by running a small subset of tests unconditionally with the nonmoving collector. Fixes #24052. - - - - - 4 changed files: - rts/sm/NonMoving.c - testsuite/driver/testlib.py - testsuite/tests/array/should_run/all.T - testsuite/tests/concurrent/should_run/all.T Changes: ===================================== rts/sm/NonMoving.c ===================================== @@ -565,6 +565,25 @@ static void nonmovingBumpEpoch(void) { * * See #23340 * + * + * Note [Testing the nonmoving collector] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * The testsuite has four "ways" which test the nonmoving collector: + * + * - nonmoving: runs tests under the nonmoving collector running in + * non-concurrent mode (i.e. using the non-threaded runtime) + * - nonmoving_thr: runs tests under the collector running in concurrent + * mode (with the threaded runtime) + * - nonmoving_thr_sanity: runs tests with concurrent collection and + * sanity checking (i.e. `+RTS -DS`) + * - nonmoving_thr_ghc: compiles tests with `ghc +RTS --nonmoving-gc -RTS` + * as GHC itself tends to be a good smoke test of the collector. + * + * To avoid blowing up validation times, we do not run any of these ways in the + * default "normal" test speed. To ensure that we catch regressions in during + * normal validation we do run a small number of tests in these ways. These + * tests are identified by the `nonmoving_test` test modifier. + * */ memcount nonmoving_segment_live_words = 0; ===================================== testsuite/driver/testlib.py ===================================== @@ -149,6 +149,15 @@ def js_broken( bug: IssueNumber ): else: return normal; +def nonmoving_test( name, opts ): + """ + Always run the given test with the nonmoving collector, in addition to + the usual ways. + + See Note [Testing the nonmoving collector] in rts/sm/NonMoving.c. + """ + return extra_ways(['nonmoving', 'nonmoving_thr_sanity', 'nonmoving_thr_ghc'])(name, opts) + def expect_fail( name, opts ): # The compiler, testdriver, OS or platform is missing a certain # feature, and we don't plan to or can't fix it now or in the ===================================== testsuite/tests/array/should_run/all.T ===================================== @@ -21,6 +21,6 @@ test('arr014', when(fast(), skip), compile_and_run, ['']) test('arr015', when(fast(), skip), compile_and_run, ['']) test('arr017', when(fast(), skip), compile_and_run, ['']) test('arr018', when(fast(), skip), compile_and_run, ['']) -test('arr019', normal, compile_and_run, ['']) -test('arr020', normal, compile_and_run, ['']) +test('arr019', nonmoving_test, compile_and_run, ['']) +test('arr020', nonmoving_test, compile_and_run, ['']) test('T21962', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -1,18 +1,18 @@ # ----------------------------------------------------------------------------- # These tests we do even for 'make fast' -test('conc003', normal, compile_and_run, ['']) -test('conc006', normal, compile_and_run, ['']) -test('conc027', normal, compile_and_run, ['']) -test('conc051', normal, compile_and_run, ['']) +test('conc003', nonmoving_test, compile_and_run, ['']) +test('conc006', nonmoving_test, compile_and_run, ['']) +test('conc027', nonmoving_test, compile_and_run, ['']) +test('conc051', nonmoving_test, compile_and_run, ['']) if ('threaded1' in config.run_ways): only_threaded_ways = only_ways(['ghci','threaded1','threaded2', 'nonmoving_thr']) else: only_threaded_ways = skip -test('conc069', only_threaded_ways, compile_and_run, ['']) -test('conc069a', only_threaded_ways, compile_and_run, ['']) +test('conc069', [nonmoving_test, only_threaded_ways], compile_and_run, ['']) +test('conc069a', nonmoving_test, only_threaded_ways], compile_and_run, ['']) # this test gives slightly different results for non-threaded ways, so omit # those for now. test('conc070', only_threaded_ways, compile_and_run, ['']) @@ -47,8 +47,8 @@ test('T3429', [ extra_run_opts('+RTS -C0.001 -RTS'), # times out with ghci test('T4030', omit_ghci, compile_and_run, ['-O']) -test('throwto002', normal, compile_and_run, ['']) -test('throwto003', normal, compile_and_run, ['']) +test('throwto002', nonmoving_test, compile_and_run, ['']) +test('throwto003', nonmoving_test, compile_and_run, ['']) test('mask001', normal, compile_and_run, ['']) test('mask002', js_broken(22261), compile_and_run, ['']) @@ -81,9 +81,9 @@ test('T5611a', fragile(12751), compile_and_run, ['']) test('T5238', normal, compile_and_run, ['']) test('T5866', exit_code(1), compile_and_run, ['']) -test('readMVar1', normal, compile_and_run, ['']) -test('readMVar2', normal, compile_and_run, ['']) -test('readMVar3', normal, compile_and_run, ['']) +test('readMVar1', nonmoving_test, compile_and_run, ['']) +test('readMVar2', nonmoving_test, compile_and_run, ['']) +test('readMVar3', nonmoving_test, compile_and_run, ['']) test('tryReadMVar1', normal, compile_and_run, ['']) test('tryReadMVar2', normal, compile_and_run, ['']) @@ -121,9 +121,9 @@ test('allocLimit4', [ extra_run_opts('+RTS -xq300k -RTS'), setTestOpts(when(fast(), skip)) -test('conc001', normal, compile_and_run, ['']) -test('conc002', normal, compile_and_run, ['']) -test('conc004', normal, compile_and_run, ['']) +test('conc001', nonmoving_test, compile_and_run, ['']) +test('conc002', nonmoving_test, compile_and_run, ['']) +test('conc004', nonmoving_test, compile_and_run, ['']) test('conc007', extra_run_opts('+RTS -H128M -RTS'), compile_and_run, ['']) test('conc008', normal, compile_and_run, ['']) test('conc009', exit_code(1), compile_and_run, ['']) @@ -218,16 +218,17 @@ test('conc039', [omit_ways(ghci_ways + threaded_ways), js_skip], compile_and_run test('conc040', [exit_code(1), omit_ghci, js_skip], compile_and_run, ['']) # STM-related tests. -test('conc041', normal, compile_and_run, ['']) -test('conc042', normal, compile_and_run, ['']) -test('conc043', normal, compile_and_run, ['']) -test('conc044', normal, compile_and_run, ['']) -test('conc045', normal, compile_and_run, ['']) +test('conc041', nonmoving_test, compile_and_run, ['']) +test('conc042', nonmoving_test, compile_and_run, ['']) +test('conc043', nonmoving_test, compile_and_run, ['']) +test('conc044', nonmoving_test, compile_and_run, ['']) +test('conc045', nonmoving_test, compile_and_run, ['']) -test('conc058', normal, compile_and_run, ['']) +test('conc058', nonmoving_test, compile_and_run, ['']) test('conc059', [only_ways(['threaded1', 'threaded2', 'nonmoving_thr']), + nonmoving_test, pre_cmd('$MAKE -s --no-print-directory conc059_setup')], compile_and_run, ['conc059_c.c -no-hs-main']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff7716e91fd6663d9e6cd45025634cd9d996fd15 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff7716e91fd6663d9e6cd45025634cd9d996fd15 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 16:44:17 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 12:44:17 -0400 Subject: [Git][ghc/ghc][wip/T24049] users-guide: Fix discussion of -Wpartial-fields Message-ID: <651c44e123ea7_3432534aba7a8174921@gitlab.mail> Ben Gamari pushed to branch wip/T24049 at Glasgow Haskell Compiler / GHC Commits: 76641510 by Ben Gamari at 2023-10-03T12:44:11-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 1 changed file: - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2157,16 +2157,19 @@ of ``-W(no-)*``. :since: 8.4 The option :ghc-flag:`-Wpartial-fields` warns about a record field - `f` that is defined in some, but not all, the contructors of a - data type, because `f`'s record selector function may fail. For - exampe, the record selector function `f`, defined in the `Foo` - constructor record below, will fail when applied to ``Bar``, so - the compiler will emit a warning at its definition when - :ghc-flag:`-Wpartial-fields` is enabled. + ``f`` that is defined in some, but not all, of the constructors of a + data type, as such selector functions are partial. For example, when + :ghc-flag:`-Wpartial-fields` is enabled the compiler will emit a warning at + the definition of ``Foo`` below: :: + + data Foo = Foo { f :: Int } | Bar The warning is suppressed if the field name begins with an underscore. :: - data Foo = Foo { f :: Int } | Bar + data Foo = Foo { _f :: Int } | Bar + + Another related warning is :ghc-flag:`-Wincomplete-record-selectors`, + which warns at use sites rather than definition sites. .. ghc-flag:: -Wunused-packages :shortdesc: warn when package is requested on command line, but not needed. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7664151082235936696afac9a2a4cc7cb9f3277f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7664151082235936696afac9a2a4cc7cb9f3277f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 16:57:08 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 12:57:08 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24050 Message-ID: <651c47e4dacd7_3432534afd7741800b1@gitlab.mail> Ben Gamari pushed new branch wip/T24050 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24050 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 17:14:25 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 13:14:25 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24022 Message-ID: <651c4bf1a2923_3432534f17d8c190585@gitlab.mail> Ben Gamari pushed new branch wip/T24022 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24022 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 17:15:33 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 13:15:33 -0400 Subject: [Git][ghc/ghc][wip/T24022] users-guide: Fix BNF grammar of instance declarations Message-ID: <651c4c3565b14_3432534a9aaac192721@gitlab.mail> Ben Gamari pushed to branch wip/T24022 at Glasgow Haskell Compiler / GHC Commits: 409542df by Ben Gamari at 2023-10-03T13:15:24-04:00 users-guide: Fix BNF grammar of instance declarations Fixes #24022. - - - - - 1 changed file: - docs/users_guide/exts/instances.rst Changes: ===================================== docs/users_guide/exts/instances.rst ===================================== @@ -135,12 +135,15 @@ BNF-style grammar for the tops of instance declarations below. | ctype ',' ctxt inst_head ::= '(' inst_head ')' - | prefix_cls_tycon arg_types - | arg_type infix_cls_tycon arg_type - | '(' arg_type infix_cls_tycon arg_type ')' arg_types + | prefix_cls_tycon args + | arg_type args infix_cls_tycon arg_type args + | '(' arg_type args infix_cls_tycon arg_type args ')' args - arg_type ::= - | arg_type arg_types + args ::= + | arg args + + arg :: '@' arg_type + | arg_type opt_where ::= | 'where' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/409542dff6baf1a90a58eebfb5c814a31def04a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/409542dff6baf1a90a58eebfb5c814a31def04a4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 17:39:55 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 03 Oct 2023 13:39:55 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651c51eb90b68_3432534ee8bf4199753@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f1c7ebfb by Andrew Lelechenko at 2023-10-03T13:39:42-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 92427d3f by Andrew Lelechenko at 2023-10-03T13:39:42-04:00 Inline bucket_match - - - - - 5f74d14d by Ben Gamari at 2023-10-03T13:39:42-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 64c26c0f by sheaf at 2023-10-03T13:39:44-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a604175d by Ben Gamari at 2023-10-03T13:39:45-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #23042. - - - - - 0b007af8 by Cheng Shao at 2023-10-03T13:39:47-04:00 rts: fix incorrect ticket reference - - - - - 16 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - m4/find_ld.m4 - rts/include/rts/ghc_ffi.h - rts/sm/NonMoving.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== m4/find_ld.m4 ===================================== @@ -70,19 +70,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) ===================================== rts/include/rts/ghc_ffi.h ===================================== @@ -1,5 +1,5 @@ /* - * wrapper working around #23586. + * wrapper working around #23568. * * (c) The University of Glasgow 2023 * ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96747a5fb8b3733c5b651bc1b2d5d9329916259b...0b007af8f35d52e340a4d0752c73b36abefe5f8b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96747a5fb8b3733c5b651bc1b2d5d9329916259b...0b007af8f35d52e340a4d0752c73b36abefe5f8b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 19:59:52 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Tue, 03 Oct 2023 15:59:52 -0400 Subject: [Git][ghc/ghc][wip/t24032] 8 commits: Fix several mistakes around free variables in iface breakpoints Message-ID: <651c72b82300e_3432539816308228649@gitlab.mail> Finley McIlwaine pushed to branch wip/t24032 at Glasgow Haskell Compiler / GHC Commits: d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - ed6d07e4 by Finley McIlwaine at 2023-10-03T12:59:43-07:00 Make specialiser monad a newtype around IO * Use the new IO powers to generate uniques as well - - - - - 8404c2c3 by Finley McIlwaine at 2023-10-03T12:59:43-07:00 Add -ddump-specialisations, -ddump-specialization These flags will dump information about any specialisations generated as a result of pragmas or the specialiser. Resolves: #24032 - - - - - 30 changed files: - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Pmc/Utils.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d797260cf699bd3e1cfa9e430619b8cfa38fe151...8404c2c3ec04a33d61bba83750e2e696ecd22c0f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d797260cf699bd3e1cfa9e430619b8cfa38fe151...8404c2c3ec04a33d61bba83750e2e696ecd22c0f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 20:13:19 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 03 Oct 2023 16:13:19 -0400 Subject: [Git][ghc/ghc][wip/az/ghc-cpp] Prepare for processing include files Message-ID: <651c75df8257f_343253a1eb61c2290a7@gitlab.mail> Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: a93ee0fd by Alan Zimmerman at 2023-10-03T20:17:02+01:00 Prepare for processing include files - - - - - 2 changed files: - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Parser/Lexer.x Changes: ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -19,7 +19,7 @@ import GHC.Prelude import GHC.Cmm.Expr -import GHC.Parser.Lexer +import GHC.Parser.Lexer hiding (getInput, setInput) import GHC.Cmm.Parser.Monad import GHC.Types.SrcLoc import GHC.Types.Unique.FM ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -81,7 +81,8 @@ module GHC.Parser.Lexer ( adjustChar, addPsMessage, -- * for integration with the preprocessor - queueIgnoredToken + queueIgnoredToken, + getInput, setInput ) where import GHC.Prelude View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a93ee0fd02f6229565954e28ff336805881950e0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a93ee0fd02f6229565954e28ff336805881950e0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 21:01:10 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 03 Oct 2023 17:01:10 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651c8116a5cb4_343253aa06f9025255b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e02c41bf by Andrew Lelechenko at 2023-10-03T17:00:08-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - ef390f1e by Andrew Lelechenko at 2023-10-03T17:00:08-04:00 Inline bucket_match - - - - - ef9c28ff by Ben Gamari at 2023-10-03T17:00:08-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - fa000b40 by sheaf at 2023-10-03T17:00:11-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - 81cae5f7 by Ben Gamari at 2023-10-03T17:00:11-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #23042. - - - - - dad88a7b by Cheng Shao at 2023-10-03T17:00:13-04:00 rts: fix incorrect ticket reference - - - - - 16 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - m4/find_ld.m4 - rts/include/rts/ghc_ffi.h - rts/sm/NonMoving.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== m4/find_ld.m4 ===================================== @@ -70,19 +70,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) ===================================== rts/include/rts/ghc_ffi.h ===================================== @@ -1,5 +1,5 @@ /* - * wrapper working around #23586. + * wrapper working around #23568. * * (c) The University of Glasgow 2023 * ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0b007af8f35d52e340a4d0752c73b36abefe5f8b...dad88a7b4ffb22c062ada80c070cf11aaed0f576 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0b007af8f35d52e340a4d0752c73b36abefe5f8b...dad88a7b4ffb22c062ada80c070cf11aaed0f576 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 21:11:13 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 17:11:13 -0400 Subject: [Git][ghc/ghc][wip/hadrian-windows-bindist-cross] 3 commits: toolchain: Don't pass --target to emscripten toolchain Message-ID: <651c837125db6_343253a44e9182527c9@gitlab.mail> Ben Gamari pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC Commits: 18f93ba2 by Ben Gamari at 2023-10-03T17:09:04-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 4b9c45a5 by Matthew Pickering at 2023-10-03T17:09:28-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - a7779a95 by Ben Gamari at 2023-10-03T17:09:53-04:00 configure: Probe stage0 link flags - - - - - 9 changed files: - configure.ac - hadrian/src/Settings/Builders/Cabal.hs - m4/fp_cc_supports_target.m4 - m4/fp_prog_cc_linker_target.m4 - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/src/GHC/Toolchain/Program.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== configure.ac ===================================== @@ -661,6 +661,7 @@ FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0 FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1]) FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2]) +FP_PROG_CC_LINKER_TARGET([CONF_CC_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) FP_PROG_CC_LINKER_TARGET([CONF_CC_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) FP_PROG_CC_LINKER_TARGET([CONF_CC_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -192,7 +192,6 @@ configureArgs cFlags' ldFlags' = do mconcat [ conf "CFLAGS" cFlags , conf "LDFLAGS" ldFlags - , not (null cldFlags) ? arg ("--gcc-options=" ++ cldFlags) , conf "--with-iconv-includes" $ arg =<< getSetting IconvIncludeDir , conf "--with-iconv-libraries" $ arg =<< getSetting IconvLibDir , conf "--with-gmp-includes" $ arg =<< getSetting GmpIncludeDir ===================================== m4/fp_cc_supports_target.m4 ===================================== @@ -14,8 +14,13 @@ AC_DEFUN([FP_CC_SUPPORTS_TARGET], [ AC_REQUIRE([GHC_LLVM_TARGET_SET_VAR]) AC_MSG_CHECKING([whether $1 supports --target]) + echo 'int main() { return 0; }' > conftest.c - if $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then + if test "$target_cpu" = "javascript" ; then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then CONF_CC_SUPPORTS_TARGET=YES AC_MSG_RESULT([yes]) else ===================================== m4/fp_prog_cc_linker_target.m4 ===================================== @@ -8,11 +8,18 @@ AC_DEFUN([FP_PROG_CC_LINKER_TARGET], [ AC_MSG_CHECKING([whether $CC used as a linker understands --target]) + echo 'int foo() { return 0; }' > conftest1.c echo 'int main() { return 0; }' > conftest2.c "${CC}" $$1 -c conftest1.c || AC_MSG_ERROR([Failed to compile conftest1.c]) "${CC}" $$1 -c conftest2.c || AC_MSG_ERROR([Failed to compile conftest2.c]) - if "$CC" $$2 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; + + if test "$target_cpu" = "javascript" + then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif "$CC" $$2 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; then $2="--target=$LlvmTarget $$2" AC_MSG_RESULT([yes]) ===================================== utils/ghc-toolchain/exe/Main.hs ===================================== @@ -380,11 +380,15 @@ mkTarget opts = do normalised_triple <- normaliseTriple (optTriple opts) -- Use Llvm target if specified, otherwise use triple as llvm target let tgtLlvmTarget = fromMaybe normalised_triple (optLlvmTriple opts) - cc0 <- findCc tgtLlvmTarget (optCc opts) - cxx <- findCxx tgtLlvmTarget (optCxx opts) + + (archOs, tgtVendor) <- do + cc0 <- findBasicCc (optCc opts) + parseTriple cc0 normalised_triple + + cc0 <- findCc archOs tgtLlvmTarget (optCc opts) + cxx <- findCxx archOs tgtLlvmTarget (optCxx opts) cpp <- findCpp (optCpp opts) cc0 hsCpp <- findHsCpp (optHsCpp opts) cc0 - (archOs, tgtVendor) <- parseTriple cc0 normalised_triple cc <- addPlatformDepCcFlags archOs cc0 readelf <- optional $ findReadelf (optReadelf opts) ccLink <- findCcLink tgtLlvmTarget (optLd opts) (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Program.hs ===================================== @@ -30,6 +30,7 @@ import System.Directory import System.Exit import System.Process hiding (env) +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Utils @@ -182,17 +183,37 @@ compile ext extraFlags lens c outPath program = do callProgram (view lens c) $ extraFlags ++ ["-o", outPath, srcPath] expectFileExists outPath "compiler produced no output" +-- Note [Don't pass --target to emscripten toolchain] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Emscripten's CC wrapper is a bit wonky in that it accepts the `--target` +-- flag when used as a linker yet rejects it as a compiler (e.g. with `-c`). +-- This is exacerbated by the fact that Cabal currently in some cases +-- combines (and therefore conflates) link and compilation flags. +-- +-- Ultimately this should be fixed in Cabal but in the meantime we work around it +-- by handling this toolchain specifically in the various +-- "supports --target" checks in `configure` and `ghc-toolchain`. +-- +-- Fixes #23744. + -- | Does compiler program support the @--target=@ option? If so, we should -- pass it whenever possible to avoid ambiguity and potential compile-time -- errors (e.g. see #20162). -supportsTarget :: Lens compiler Program +supportsTarget :: ArchOS + -> Lens compiler Program -> (compiler -> M ()) -- ^ Action to check if compiler with @--target@ flag works -> String -- ^ The LLVM target to use if @cc@ supports @--target@ -> compiler -- ^ The compiler to check @--target@ support for -> M compiler -- ^ Return compiler with @--target@ flag if supported -supportsTarget lens checkWorks llvmTarget c --- TODO: #23603 - | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) = return c +supportsTarget archOs lens checkWorks llvmTarget c + -- See Note [Don't pass --target to emscripten toolchain]. + | ArchJavaScript <- archOS_arch archOs + = return c + + -- No reason to check if the options already contain a --target flag + | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) + = return c + | otherwise = let c' = over (lens % _prgFlags) (("--target="++llvmTarget):) c in (c' <$ checkWorks (over (lens % _prgFlags) ("-Werror":) c')) <|> return c ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs ===================================== @@ -4,6 +4,7 @@ module GHC.Toolchain.Tools.Cc ( Cc(..) , _ccProgram + , findBasicCc , findCc -- * Helpful utilities , preprocess @@ -33,22 +34,29 @@ _ccProgram = Lens ccProgram (\x o -> o{ccProgram=x}) _ccFlags :: Lens Cc [String] _ccFlags = _ccProgram % _prgFlags -findCc :: String -- ^ The llvm target to use if Cc supports --target - -> ProgOpt -> M Cc -findCc llvmTarget progOpt = checking "for C compiler" $ do +-- We use this to find a minimally-functional compiler needed to call +-- parseTriple. +findBasicCc :: ProgOpt -> M Cc +findBasicCc progOpt = checking "for C compiler" $ do -- TODO: We keep the candidate order we had in configure, but perhaps -- there's a more optimal one ccProgram <- findProgram "C compiler" progOpt ["gcc", "clang", "cc"] + return $ Cc{ccProgram} - cc0 <- ignoreUnusedArgs $ Cc {ccProgram} - cc1 <- ccSupportsTarget llvmTarget cc0 - checking "whether Cc works" $ checkCcWorks cc1 - cc2 <- oneOf "cc doesn't support C99" $ map checkC99Support - [ cc1 - , cc1 & _ccFlags %++ "-std=gnu99" +findCc :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target + -> ProgOpt -> M Cc +findCc archOs llvmTarget progOpt = do + cc0 <- findBasicCc progOpt + cc1 <- ignoreUnusedArgs cc0 + cc2 <- ccSupportsTarget archOs llvmTarget cc1 + checking "whether Cc works" $ checkCcWorks cc2 + cc3 <- oneOf "cc doesn't support C99" $ map checkC99Support + [ cc2 + , cc2 & _ccFlags %++ "-std=gnu99" ] - checkCcSupportsExtraViaCFlags cc2 - return cc2 + checkCcSupportsExtraViaCFlags cc3 + return cc3 checkCcWorks :: Cc -> M () checkCcWorks cc = withTempDir $ \dir -> do @@ -75,9 +83,10 @@ ignoreUnusedArgs cc -- Does Cc support the --target= option? If so, we should pass it -- whenever possible to avoid ambiguity and potential compile-time errors (e.g. -- see #20162). -ccSupportsTarget :: String -> Cc -> M Cc -ccSupportsTarget target cc = checking "whether Cc supports --target" $ - supportsTarget _ccProgram checkCcWorks target cc +ccSupportsTarget :: ArchOS -> String -> Cc -> M Cc +ccSupportsTarget archOs target cc = + checking "whether Cc supports --target" $ + supportsTarget archOs _ccProgram checkCcWorks target cc checkC99Support :: Cc -> M Cc checkC99Support cc = checking "for C99 support" $ withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs ===================================== @@ -8,6 +8,8 @@ module GHC.Toolchain.Tools.Cxx ) where import System.FilePath + +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Program import GHC.Toolchain.Utils @@ -19,18 +21,20 @@ newtype Cxx = Cxx { cxxProgram :: Program _cxxProgram :: Lens Cxx Program _cxxProgram = Lens cxxProgram (\x o -> o{cxxProgram=x}) -findCxx :: String -- ^ The llvm target to use if Cc supports --target +findCxx :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target -> ProgOpt -> M Cxx -findCxx target progOpt = checking "for C++ compiler" $ do +findCxx archOs target progOpt = checking "for C++ compiler" $ do -- TODO: We use the search order in configure, but there could be a more optimal one cxxProgram <- findProgram "C++ compiler" progOpt ["g++", "clang++", "c++"] - cxx <- cxxSupportsTarget target Cxx{cxxProgram} + cxx <- cxxSupportsTarget archOs target Cxx{cxxProgram} checkCxxWorks cxx return cxx -cxxSupportsTarget :: String -> Cxx -> M Cxx -cxxSupportsTarget target cxx = checking "whether C++ supports --target" $ - supportsTarget _cxxProgram checkCxxWorks target cxx +cxxSupportsTarget :: ArchOS -> String -> Cxx -> M Cxx +cxxSupportsTarget archOs target cxx = + checking "whether C++ supports --target" $ + supportsTarget archOs _cxxProgram checkCxxWorks target cxx checkCxxWorks :: Cxx -> M () checkCxxWorks cxx = withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -62,7 +62,7 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp _ -> do -- If not then try to find decent linker flags findLinkFlags ldOverride cc rawCcLink <|> pure rawCcLink - ccLinkProgram <- linkSupportsTarget cc target ccLinkProgram + ccLinkProgram <- linkSupportsTarget archOs cc target ccLinkProgram ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram @@ -94,12 +94,12 @@ findLinkFlags enableOverride cc ccLink | otherwise = return ccLink -linkSupportsTarget :: Cc -> String -> Program -> M Program +linkSupportsTarget :: ArchOS -> Cc -> String -> Program -> M Program -- Javascript toolchain provided by emsdk just ignores --target flag so -- we have this special case to match with ./configure (#23744) -linkSupportsTarget cc target link - = checking "whether cc linker supports --target" $ - supportsTarget (Lens id const) (checkLinkWorks cc) target link +linkSupportsTarget archOs cc target link = + checking "whether cc linker supports --target" $ + supportsTarget archOs (Lens id const) (checkLinkWorks cc) target link -- | Should we attempt to find a more efficient linker on this platform? -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/40b264e85734dda3f94b2dd54f72bdb50b868869...a7779a9563cfd3593ef713cc8f5a7e0162bf4ed2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/40b264e85734dda3f94b2dd54f72bdb50b868869...a7779a9563cfd3593ef713cc8f5a7e0162bf4ed2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 21:17:51 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Tue, 03 Oct 2023 17:17:51 -0400 Subject: [Git][ghc/ghc][wip/t24032] Add -ddump-specialisations, -ddump-specialization Message-ID: <651c84ffe26bb_343253bb23a80253614@gitlab.mail> Finley McIlwaine pushed to branch wip/t24032 at Glasgow Haskell Compiler / GHC Commits: f7ced925 by Finley McIlwaine at 2023-10-03T14:17:40-07:00 Add -ddump-specialisations, -ddump-specialization These flags will dump information about any specialisations generated as a result of pragmas or the specialiser. Resolves: #24032 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Binds.hs - + compiler/GHC/Types/DumpSpecInfo.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst Changes: ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralisedNewtypeDeriving #-} +{-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -57,8 +58,11 @@ import GHC.Types.Var.Env import GHC.Types.Id import GHC.Types.Id.Info import GHC.Types.Error +import GHC.Types.DumpSpecInfo import GHC.Utils.Error ( mkMCDiagnostic ) +import GHC.Utils.Logger (Logger) +import qualified GHC.Utils.Logger as Logger import GHC.Utils.Monad ( foldlM, MonadIO ) import GHC.Utils.Misc import GHC.Utils.Outputable @@ -646,6 +650,7 @@ specProgram guts@(ModGuts { mg_module = this_mod , mg_rules = local_rules , mg_binds = binds }) = do { dflags <- getDynFlags + ; logger <- Logger.getLogger ; rule_env <- initRuleEnv guts -- See Note [Fire rules in the specialiser] @@ -660,7 +665,8 @@ specProgram guts@(ModGuts { mg_module = this_mod -- bindersOfBinds binds , se_module = this_mod , se_rules = rule_env - , se_dflags = dflags } + , se_dflags = dflags + , se_logger = logger } go [] = return ([], emptyUDs) go (bind:binds) = do (bind', binds', uds') <- specBind TopLevel top_env bind $ \_ -> @@ -1171,6 +1177,7 @@ data SpecEnv , se_module :: Module , se_rules :: RuleEnv -- From the home package and this module , se_dflags :: DynFlags + , se_logger :: Logger } instance Outputable SpecEnv where @@ -1673,6 +1680,7 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs is_dfun = isDFunId fn dflags = se_dflags env this_mod = se_module env + logger = se_logger env -- Figure out whether the function has an INLINE pragma -- See Note [Inline specialisations] @@ -1744,7 +1752,7 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs -- See Note [Specialisations Must Be Lifted] -- C.f. GHC.Core.Opt.WorkWrap.Utils.needsVoidWorkerArg add_void_arg = isUnliftedType spec_fn_ty1 && not (isJoinId fn) - (spec_bndrs, spec_rhs, spec_fn_ty) + (spec_bndrs, spec_rhs, spec_fn_type) | add_void_arg = ( voidPrimId : spec_bndrs1 , Lam voidArgId spec_rhs1 , mkVisFunTyMany unboxedUnitTy spec_fn_ty1) @@ -1788,7 +1796,7 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs DFunId is_nt -> DFunId is_nt _ -> VanillaId - ; spec_fn <- newSpecIdSM (idName fn) spec_fn_ty spec_fn_details spec_fn_info + ; spec_fn <- newSpecIdSM (idName fn) spec_fn_type spec_fn_details spec_fn_info ; let -- The rule to put in the function's specialisation is: -- forall x @b d1' d2'. @@ -1805,12 +1813,27 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs spec_f_w_arity = spec_fn - _rule_trace_doc = vcat [ ppr fn <+> dcolon <+> ppr fn_type - , ppr spec_fn <+> dcolon <+> ppr spec_fn_ty + unspec_fn_doc = ppr fn <+> dcolon <+> ppr fn_type + spec_fn_doc = ppr spec_fn <+> dcolon <+> ppr spec_fn_type + + _rule_trace_doc = vcat [ unspec_fn_doc + , spec_fn_doc , ppr rhs_bndrs, ppr call_args , ppr spec_rule ] + -- Dump the specialisation if -ddump-specialisations is enabled + ; dumpSpecialisationWithLogger @Module @Id @Type logger $ + DumpSpecInfo + { dumpSpecInfo_module = this_mod + , dumpSpecInfo_fromPragma = False + , dumpSpecInfo_polyId = fn + , dumpSpecInfo_polyTy = fn_type + , dumpSpecInfo_specId = spec_fn + , dumpSpecInfo_specTy = spec_fn_type + , dumpSpecInfo_dicts = map varType rule_bndrs + } + ; -- pprTrace "spec_call: rule" _rule_trace_doc return ( spec_rule : rules_acc , (spec_f_w_arity, spec_rhs) : pairs_acc @@ -3439,13 +3462,13 @@ newtype SpecM result } deriving newtype (Functor, Applicative, Monad, MonadIO) --- See Note [Uniques for wired-in prelude things and known masks] in GHC.Builtin.Uniques -specMask :: Char -specMask = 't' +-- See Note [Uniques for wired-in prelude things and known tags] in GHC.Builtin.Uniques +specTag :: Char +specTag = 't' instance MonadUnique SpecM where - getUniqueSupplyM = liftIO $ mkSplitUniqSupply specMask - getUniqueM = liftIO $ uniqFromMask specMask + getUniqueSupplyM = liftIO $ mkSplitUniqSupply specTag + getUniqueM = liftIO $ uniqFromTag specTag runSpecM :: SpecM a -> CoreM a runSpecM = liftIO . unSpecM ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -109,6 +109,7 @@ data DumpFlag | Opt_D_dump_simpl_iterations | Opt_D_dump_spec | Opt_D_dump_spec_constr + | Opt_D_dump_specialisations | Opt_D_dump_prep | Opt_D_dump_late_cc | Opt_D_dump_stg_from_core -- ^ Initial STG (CoreToStg output) ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1440,6 +1440,10 @@ dynamic_flags_deps = [ (setDumpFlag Opt_D_dump_spec) , make_ord_flag defGhcFlag "ddump-spec-constr" (setDumpFlag Opt_D_dump_spec_constr) + , make_ord_flag defGhcFlag "ddump-specialisations" + (setDumpFlag Opt_D_dump_specialisations) + , make_ord_flag defGhcFlag "ddump-specializations" + (setDumpFlag Opt_D_dump_specialisations) , make_ord_flag defGhcFlag "ddump-prep" (setDumpFlag Opt_D_dump_prep) , make_ord_flag defGhcFlag "ddump-late-cc" ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -1,6 +1,5 @@ - {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeApplications #-} {- (c) The University of Glasgow 2006 @@ -66,6 +65,7 @@ import GHC.Types.Name import GHC.Types.Var.Set import GHC.Types.Var.Env import GHC.Types.Var( EvVar ) +import GHC.Types.DumpSpecInfo import GHC.Types.SrcLoc import GHC.Types.Basic import GHC.Types.Unique.Set( nonDetEltsUniqSet ) @@ -806,6 +806,18 @@ dsSpec mb_poly_rhs (L loc (SpecPrag poly_id spec_co spec_inl)) ; dsWarnOrphanRule rule + -- Dump the specialisation if -ddump-specialisations is enabled + ; dumpSpecialisation @Module @Id @Type $ + DumpSpecInfo + { dumpSpecInfo_module = this_mod + , dumpSpecInfo_fromPragma = True + , dumpSpecInfo_polyId = poly_id + , dumpSpecInfo_polyTy = idType poly_id + , dumpSpecInfo_specId = spec_id + , dumpSpecInfo_specTy = spec_ty + , dumpSpecInfo_dicts = map varType rule_bndrs + } + ; return (Just (unitOL (spec_id, spec_rhs), rule)) -- NB: do *not* use makeCorePair on (spec_id,spec_rhs), because -- makeCorePair overwrites the unfolding, which we have @@ -846,7 +858,6 @@ dsSpec mb_poly_rhs (L loc (SpecPrag poly_id spec_co spec_inl)) rule_act | no_act_spec = inlinePragmaActivation id_inl -- Inherit | otherwise = spec_prag_act -- Specified by user - dsWarnOrphanRule :: CoreRule -> DsM () dsWarnOrphanRule rule = when (isOrphan (ru_orphan rule)) $ ===================================== compiler/GHC/Types/DumpSpecInfo.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE StandaloneDeriving #-} + +-- | A module for the DumpSpecInfo type whose values contain information about +-- specialisations generated by GHC. Output by -ddump-specialisations flag. +module GHC.Types.DumpSpecInfo + ( DumpSpecInfo(..) + , DumpSpecInfoTypes(..) + , dumpSpecialisation + , dumpSpecialisationWithLogger + ) where + +import GHC.Core.Type +import GHC.Driver.Flags (DumpFlag(..)) +import GHC.Prelude +import GHC.Types.Id +import GHC.Unit.Module +import GHC.Utils.Logger +import GHC.Utils.Outputable + +import Control.Monad +import Control.Monad.IO.Class + +data DumpSpecInfoTypes = + DumpSpecInfoCustom + | DumpSpecInfoString + +data DumpSpecInfo mod id ty = DumpSpecInfo + { -- | Module the specialisation was generated in ('Module' in GHC) + dumpSpecInfo_module :: !mod + + -- | Was this specialisation the result of a pragma? + , dumpSpecInfo_fromPragma :: !Bool + + -- | Overloaded function identifier ('Id' in GHC) + , dumpSpecInfo_polyId :: !id + -- | Overloaded function type ('Type' in GHC) + , dumpSpecInfo_polyTy :: !ty + + -- | Specialised function identifier ('Identifier' in GHC) + , dumpSpecInfo_specId :: !id + -- | Specialised function type ('Type' in GHC) + , dumpSpecInfo_specTy :: !ty + + -- | The types of the dictionaries the specialisation is for (list of 'Type' + -- in GHC) + , dumpSpecInfo_dicts :: ![ty] + } + +-- | This instance is intentionally written so the following composition +-- succeeds: +-- +-- @read \@(DumpSpecInfo String String String) . show \@(DumpSpecInfo Module Id Type)@ +instance Show (DumpSpecInfo Module Id Type) where + show DumpSpecInfo{..} = + renderWithContext + defaultSDocContext + { sdocLineLength = maxBound + } + $ withPprStyle (mkDumpStyle alwaysQualify) + $ vcat + [ text "Specialisation generated:" + , nest 2 $ text "DumpSpecInfo" <+> + ( braces . sep $ + [ text "dumpSpecInfo_module" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_module) <> comma + , text "dumpSpecInfo_fromPragma" <+> equals <+> ppr dumpSpecInfo_fromPragma <> comma + , text "dumpSpecInfo_polyId" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_polyId) <> comma + , text "dumpSpecInfo_polyTy" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_polyTy) <> comma + , text "dumpSpecInfo_specId" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_specId) <> comma + , text "dumpSpecInfo_specTy" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_specTy) <> comma + , text "dumpSpecInfo_dicts" <+> equals <+> ppr (map (doubleQuotes . ppr) dumpSpecInfo_dicts) + ] + ) + ] + +deriving instance Show (DumpSpecInfo String String String) +deriving instance Read (DumpSpecInfo String String String) +deriving instance Eq (DumpSpecInfo String String String) + +dumpSpecialisation + :: forall mod id ty m. (MonadIO m, HasLogger m, Show (DumpSpecInfo mod id ty)) + => DumpSpecInfo mod id ty + -> m () +dumpSpecialisation spec_info = do + logger <- getLogger + dumpSpecialisationWithLogger logger spec_info + +dumpSpecialisationWithLogger + :: forall mod id ty m. (MonadIO m, Show (DumpSpecInfo mod id ty)) + => Logger + -> DumpSpecInfo mod id ty + -> m () +dumpSpecialisationWithLogger logger spec_info = do + when (logHasDumpFlag logger Opt_D_dump_specialisations) $ + log_specialisation logger (text $ show spec_info) + +log_specialisation :: MonadIO m => Logger -> SDoc -> m () +log_specialisation logger doc = + liftIO $ + putDumpFileMaybe logger + Opt_D_dump_specialisations + "" + FormatText + doc ===================================== compiler/ghc.cabal.in ===================================== @@ -813,6 +813,7 @@ Library GHC.Types.CostCentre.State GHC.Types.Cpr GHC.Types.Demand + GHC.Types.DumpSpecInfo GHC.Types.Error GHC.Types.Error.Codes GHC.Types.FieldLabel ===================================== docs/users_guide/debugging.rst ===================================== @@ -343,6 +343,15 @@ subexpression elimination pass. Dump output of the SpecConstr specialisation pass +.. ghc-flag:: -ddump-specializations +.. ghc-flag:: -ddump-specialisations + :shortdesc: Dump information about generated specialisations + :type: dynamic + + Dump information about any specialisations resulting from pragmas or the + specialiser logic. Currently, the identifiers and types of the unspecialised + function and the generated specialised function are dumped. + .. ghc-flag:: -ddump-rules :shortdesc: Dump rewrite rules :type: dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7ced925d284b34fdd73fab65273fdd358489434 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7ced925d284b34fdd73fab65273fdd358489434 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 21:32:09 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 17:32:09 -0400 Subject: [Git][ghc/ghc][wip/hadrian-windows-bindist-cross] 2 commits: hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Message-ID: <651c885946a4c_343253bec362c255943@gitlab.mail> Ben Gamari pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC Commits: 47d9a787 by Matthew Pickering at 2023-10-03T17:32:00-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c7ff4b64 by Ben Gamari at 2023-10-03T17:32:00-04:00 configure: Probe stage0 link flags - - - - - 2 changed files: - configure.ac - hadrian/src/Settings/Builders/Cabal.hs Changes: ===================================== configure.ac ===================================== @@ -661,6 +661,7 @@ FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0 FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1]) FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2]) +FP_PROG_CC_LINKER_TARGET([CONF_CC_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) FP_PROG_CC_LINKER_TARGET([CONF_CC_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) FP_PROG_CC_LINKER_TARGET([CONF_CC_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -188,11 +188,9 @@ configureArgs cFlags' ldFlags' = do , cFlags' ] ldFlags = ldArgs <> ldFlags' - cldFlags <- unwords <$> (cFlags <> ldFlags) mconcat [ conf "CFLAGS" cFlags , conf "LDFLAGS" ldFlags - , not (null cldFlags) ? arg ("--gcc-options=" ++ cldFlags) , conf "--with-iconv-includes" $ arg =<< getSetting IconvIncludeDir , conf "--with-iconv-libraries" $ arg =<< getSetting IconvLibDir , conf "--with-gmp-includes" $ arg =<< getSetting GmpIncludeDir View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7779a9563cfd3593ef713cc8f5a7e0162bf4ed2...c7ff4b64bdd20d6628e0b6aee168d3bac23b04c3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7779a9563cfd3593ef713cc8f5a7e0162bf4ed2...c7ff4b64bdd20d6628e0b6aee168d3bac23b04c3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 21:34:03 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 17:34:03 -0400 Subject: [Git][ghc/ghc][wip/T24050] hadrian: Move hsc2hs wrapper generation to bindist installation Message-ID: <651c88cb5ce68_343253bfb0558256841@gitlab.mail> Ben Gamari pushed to branch wip/T24050 at Glasgow Haskell Compiler / GHC Commits: 34601354 by Ben Gamari at 2023-10-03T17:33:49-04:00 hadrian: Move hsc2hs wrapper generation to bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. Fixes #24050. - - - - - 2 changed files: - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -235,13 +235,21 @@ install_man: export SHELL .PHONY: install_wrappers -install_wrappers: install_bin_libdir +install_wrappers: install_bin_libdir install_hsc2hs_wrapper @echo "Installing wrapper scripts" $(INSTALL_DIR) "$(DESTDIR)$(WrapperBinsDir)" for p in `cd wrappers; $(FIND) . ! -type d`; do \ mk/install_script.sh "$$p" "$(DESTDIR)/$(WrapperBinsDir)/$$p" "$(WrapperBinsDir)" "$(ActualBinsDir)" "$(ActualBinsDir)/$$p" "$(ActualLibsDir)" "$(docdir)" "$(includedir)"; \ done +.PHONY: install_hsc2hs_wrapper +install_hsc2hs_wrapper: + @echo "Installing hsc2hs wrapper" + echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> hsc2hs-wrapper + $(INSTALL_SCRIPT) hsc2hs-wrapper "$(DESTDIR)$(ActualBinsDir)/hsc2hs" + rm -f hsc2hs-wrapper + + PKG_CONFS = $(shell find "$(DESTDIR)$(ActualLibsDir)/package.conf.d" -name '*.conf' | sed "s: :\0xxx\0:g") .PHONY: update_package_db update_package_db: install_bin install_lib ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -15,8 +15,6 @@ import Target import Utilities import qualified System.Directory.Extra as IO import Data.Either -import GHC.Toolchain (ccProgram, tgtCCompiler, ccLinkProgram, tgtCCompilerLink) -import GHC.Toolchain.Program (prgFlags) import qualified Data.Set as Set import Oracles.Flavour @@ -428,7 +426,7 @@ pkgToWrappers pkg = do | pkg == runGhc -> pure $ map (prefix++) ["runghc", "runhaskell"] -- These are the packages which we want to expose to the user and hence -- there are wrappers installed in the bindist. - | pkg `elem` [hpcBin, haddock, hp2ps, hsc2hs, ghc, ghcPkg] + | pkg `elem` [hpcBin, haddock, hp2ps, ghc, ghcPkg] -> (:[]) <$> (programName =<< programContext Stage1 pkg) | otherwise -> pure [] @@ -437,7 +435,6 @@ wrapper "ghc" = ghcWrapper wrapper "ghc-pkg" = ghcPkgWrapper wrapper "ghci" = ghciScriptWrapper wrapper "haddock" = haddockWrapper -wrapper "hsc2hs" = hsc2hsWrapper wrapper "runghc" = runGhcWrapper wrapper "runhaskell" = runGhcWrapper wrapper _ = commonWrapper @@ -459,18 +456,6 @@ haddockWrapper = pure $ "exec \"$executablename\" -B\"$libdir\" -l\"$libdir\" ${ commonWrapper :: Action String commonWrapper = pure $ "exec \"$executablename\" ${1+\"$@\"}\n" --- echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> "$(WRAPPER)" -hsc2hsWrapper :: Action String -hsc2hsWrapper = do - ccArgs <- map ("--cflag=" <>) . prgFlags . ccProgram . tgtCCompiler <$> targetStage Stage1 - linkFlags <- map ("--lflag=" <>) . prgFlags . ccLinkProgram . tgtCCompilerLink <$> targetStage Stage1 - wrapper <- drop 4 . lines <$> liftIO (readFile "utils/hsc2hs/hsc2hs.wrapper") - return $ unlines - ( "HSC2HS_EXTRA=\"" <> unwords (ccArgs ++ linkFlags) <> "\"" - : "tflag=\"--template=$libdir/template-hsc.h\"" - : "Iflag=\"-I$includedir/\"" - : wrapper ) - runGhcWrapper :: Action String runGhcWrapper = pure $ "exec \"$executablename\" -f \"$exedir/ghc\" ${1+\"$@\"}\n" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34601354e984194cfed569e47f478be29676366c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34601354e984194cfed569e47f478be29676366c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 21:35:38 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 17:35:38 -0400 Subject: [Git][ghc/ghc][wip/T24052] testsuite: Run some tests unconditionally in nonmoving ways Message-ID: <651c892accffe_343253c0ad8fc257292@gitlab.mail> Ben Gamari pushed to branch wip/T24052 at Glasgow Haskell Compiler / GHC Commits: 0a0c75cd by Ben Gamari at 2023-10-03T17:35:19-04:00 testsuite: Run some tests unconditionally in nonmoving ways Improve test coverage of the nonmoving collector by running a small subset of tests unconditionally with the nonmoving collector. Fixes #24052. - - - - - 4 changed files: - rts/sm/NonMoving.c - testsuite/driver/testlib.py - testsuite/tests/array/should_run/all.T - testsuite/tests/concurrent/should_run/all.T Changes: ===================================== rts/sm/NonMoving.c ===================================== @@ -565,6 +565,25 @@ static void nonmovingBumpEpoch(void) { * * See #23340 * + * + * Note [Testing the nonmoving collector] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * The testsuite has four "ways" which test the nonmoving collector: + * + * - nonmoving: runs tests under the nonmoving collector running in + * non-concurrent mode (i.e. using the non-threaded runtime) + * - nonmoving_thr: runs tests under the collector running in concurrent + * mode (with the threaded runtime) + * - nonmoving_thr_sanity: runs tests with concurrent collection and + * sanity checking (i.e. `+RTS -DS`) + * - nonmoving_thr_ghc: compiles tests with `ghc +RTS --nonmoving-gc -RTS` + * as GHC itself tends to be a good smoke test of the collector. + * + * To avoid blowing up validation times, we do not run any of these ways in the + * default "normal" test speed. To ensure that we catch regressions in during + * normal validation we do run a small number of tests in these ways. These + * tests are identified by the `nonmoving_test` test modifier. + * */ memcount nonmoving_segment_live_words = 0; ===================================== testsuite/driver/testlib.py ===================================== @@ -149,6 +149,15 @@ def js_broken( bug: IssueNumber ): else: return normal; +def nonmoving_test( name, opts ): + """ + Always run the given test with the nonmoving collector, in addition to + the usual ways. + + See Note [Testing the nonmoving collector] in rts/sm/NonMoving.c. + """ + return extra_ways(['nonmoving', 'nonmoving_thr_sanity', 'nonmoving_thr_ghc'])(name, opts) + def expect_fail( name, opts ): # The compiler, testdriver, OS or platform is missing a certain # feature, and we don't plan to or can't fix it now or in the ===================================== testsuite/tests/array/should_run/all.T ===================================== @@ -21,6 +21,6 @@ test('arr014', when(fast(), skip), compile_and_run, ['']) test('arr015', when(fast(), skip), compile_and_run, ['']) test('arr017', when(fast(), skip), compile_and_run, ['']) test('arr018', when(fast(), skip), compile_and_run, ['']) -test('arr019', normal, compile_and_run, ['']) -test('arr020', normal, compile_and_run, ['']) +test('arr019', nonmoving_test, compile_and_run, ['']) +test('arr020', nonmoving_test, compile_and_run, ['']) test('T21962', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -1,18 +1,18 @@ # ----------------------------------------------------------------------------- # These tests we do even for 'make fast' -test('conc003', normal, compile_and_run, ['']) -test('conc006', normal, compile_and_run, ['']) -test('conc027', normal, compile_and_run, ['']) -test('conc051', normal, compile_and_run, ['']) +test('conc003', nonmoving_test, compile_and_run, ['']) +test('conc006', nonmoving_test, compile_and_run, ['']) +test('conc027', nonmoving_test, compile_and_run, ['']) +test('conc051', nonmoving_test, compile_and_run, ['']) if ('threaded1' in config.run_ways): only_threaded_ways = only_ways(['ghci','threaded1','threaded2', 'nonmoving_thr']) else: only_threaded_ways = skip -test('conc069', only_threaded_ways, compile_and_run, ['']) -test('conc069a', only_threaded_ways, compile_and_run, ['']) +test('conc069', [nonmoving_test, only_threaded_ways], compile_and_run, ['']) +test('conc069a', [nonmoving_test, only_threaded_ways], compile_and_run, ['']) # this test gives slightly different results for non-threaded ways, so omit # those for now. test('conc070', only_threaded_ways, compile_and_run, ['']) @@ -47,8 +47,8 @@ test('T3429', [ extra_run_opts('+RTS -C0.001 -RTS'), # times out with ghci test('T4030', omit_ghci, compile_and_run, ['-O']) -test('throwto002', normal, compile_and_run, ['']) -test('throwto003', normal, compile_and_run, ['']) +test('throwto002', nonmoving_test, compile_and_run, ['']) +test('throwto003', nonmoving_test, compile_and_run, ['']) test('mask001', normal, compile_and_run, ['']) test('mask002', js_broken(22261), compile_and_run, ['']) @@ -81,9 +81,9 @@ test('T5611a', fragile(12751), compile_and_run, ['']) test('T5238', normal, compile_and_run, ['']) test('T5866', exit_code(1), compile_and_run, ['']) -test('readMVar1', normal, compile_and_run, ['']) -test('readMVar2', normal, compile_and_run, ['']) -test('readMVar3', normal, compile_and_run, ['']) +test('readMVar1', nonmoving_test, compile_and_run, ['']) +test('readMVar2', nonmoving_test, compile_and_run, ['']) +test('readMVar3', nonmoving_test, compile_and_run, ['']) test('tryReadMVar1', normal, compile_and_run, ['']) test('tryReadMVar2', normal, compile_and_run, ['']) @@ -121,9 +121,9 @@ test('allocLimit4', [ extra_run_opts('+RTS -xq300k -RTS'), setTestOpts(when(fast(), skip)) -test('conc001', normal, compile_and_run, ['']) -test('conc002', normal, compile_and_run, ['']) -test('conc004', normal, compile_and_run, ['']) +test('conc001', nonmoving_test, compile_and_run, ['']) +test('conc002', nonmoving_test, compile_and_run, ['']) +test('conc004', nonmoving_test, compile_and_run, ['']) test('conc007', extra_run_opts('+RTS -H128M -RTS'), compile_and_run, ['']) test('conc008', normal, compile_and_run, ['']) test('conc009', exit_code(1), compile_and_run, ['']) @@ -218,16 +218,17 @@ test('conc039', [omit_ways(ghci_ways + threaded_ways), js_skip], compile_and_run test('conc040', [exit_code(1), omit_ghci, js_skip], compile_and_run, ['']) # STM-related tests. -test('conc041', normal, compile_and_run, ['']) -test('conc042', normal, compile_and_run, ['']) -test('conc043', normal, compile_and_run, ['']) -test('conc044', normal, compile_and_run, ['']) -test('conc045', normal, compile_and_run, ['']) +test('conc041', nonmoving_test, compile_and_run, ['']) +test('conc042', nonmoving_test, compile_and_run, ['']) +test('conc043', nonmoving_test, compile_and_run, ['']) +test('conc044', nonmoving_test, compile_and_run, ['']) +test('conc045', nonmoving_test, compile_and_run, ['']) -test('conc058', normal, compile_and_run, ['']) +test('conc058', nonmoving_test, compile_and_run, ['']) test('conc059', [only_ways(['threaded1', 'threaded2', 'nonmoving_thr']), + nonmoving_test, pre_cmd('$MAKE -s --no-print-directory conc059_setup')], compile_and_run, ['conc059_c.c -no-hs-main']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a0c75cd55628aad1964e3e4e53b842bdf3de384 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a0c75cd55628aad1964e3e4e53b842bdf3de384 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 21:46:21 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 03 Oct 2023 17:46:21 -0400 Subject: [Git][ghc/ghc][wip/az/ghc-cpp] Move PpState into PreProcess Message-ID: <651c8bad3991c_343253c33523c268489@gitlab.mail> Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: 3bfb1fd6 by Alan Zimmerman at 2023-10-03T22:45:18+01:00 Move PpState into PreProcess And initParserState, initPragState too - - - - - 17 changed files: - compiler/GHC.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Parser.hs-boot - compiler/GHC/Parser.y - compiler/GHC/Parser/HaddockLex.x - compiler/GHC/Parser/Header.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Parser/PreProcess.hs - compiler/GHC/Parser/Utils.hs - ghc/GHCi/UI.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -333,7 +333,8 @@ import GHC.Runtime.Context import GHCi.RemoteTypes import qualified GHC.Parser as Parser -import GHC.Parser.Lexer +import GHC.Parser.Lexer hiding (initParserState) +import GHC.Parser.PreProcess (initParserState) import GHC.Parser.Annotation import GHC.Parser.Utils @@ -1627,7 +1628,7 @@ getTokenStream :: ModSummary -> IO [Located Token] getTokenStream mod = do (sourceFile, source, dflags) <- getModuleSourceAndFlags mod let startLoc = mkRealSrcLoc (mkFastString sourceFile) 1 1 - case lexTokenStream (initParserOpts dflags) source startLoc of + case lexTokenStream initPpState (initParserOpts dflags) source startLoc of POk _ ts -> return ts PFailed pst -> throwErrors (GhcPsMessage <$> getPsErrorMessages pst) @@ -1638,7 +1639,7 @@ getRichTokenStream :: ModSummary -> IO [(Located Token, String)] getRichTokenStream mod = do (sourceFile, source, dflags) <- getModuleSourceAndFlags mod let startLoc = mkRealSrcLoc (mkFastString sourceFile) 1 1 - case lexTokenStream (initParserOpts dflags) source startLoc of + case lexTokenStream initPpState (initParserOpts dflags) source startLoc of POk _ ts -> return $ addSourceToTokens startLoc source ts PFailed pst -> throwErrors (GhcPsMessage <$> getPsErrorMessages pst) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1576,7 +1576,7 @@ parseCmmFile cmmpConfig this_mod home_unit filename = do buf <- hGetStringBuffer filename let init_loc = mkRealSrcLoc (mkFastString filename) 1 1 - init_state = (initParserState (cmmpParserOpts cmmpConfig) buf init_loc) { lex_state = [0] } + init_state = (initParserState () (cmmpParserOpts cmmpConfig) buf init_loc) { lex_state = [0] } -- reset the lex_state: the Lexer monad leaves some stuff -- in there we don't want. pdConfig = cmmpPDConfig cmmpConfig ===================================== compiler/GHC/Cmm/Parser/Monad.hs ===================================== @@ -34,7 +34,7 @@ import GHC.Types.SrcLoc import GHC.Unit.Types import GHC.Unit.Home -newtype PD a = PD { unPD :: PDConfig -> HomeUnit -> PState -> ParseResult a } +newtype PD a = PD { unPD :: PDConfig -> HomeUnit -> PState () -> ParseResult () a } instance Functor PD where fmap = liftM @@ -46,7 +46,7 @@ instance Applicative PD where instance Monad PD where (>>=) = thenPD -liftP :: P a -> PD a +liftP :: P () a -> PD a liftP (P f) = PD $ \_ _ s -> f s failMsgPD :: (SrcSpan -> MsgEnvelope PsMessage) -> PD a ===================================== compiler/GHC/Driver/Backpack.hs ===================================== @@ -37,7 +37,8 @@ import GHC.Driver.Errors.Types import GHC.Parser import GHC.Parser.Header -import GHC.Parser.Lexer +import GHC.Parser.Lexer hiding (initParserState) +import GHC.Parser.PreProcess (initParserState) import GHC.Parser.Annotation import GHC.Rename.Names ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -193,7 +193,8 @@ import GHC.CoreToStg ( coreToStg ) import GHC.Parser.Errors.Types import GHC.Parser -import GHC.Parser.Lexer as Lexer +import GHC.Parser.Lexer as Lexer hiding (initPpState, initParserState) +import GHC.Parser.PreProcess (initParserState) import GHC.Tc.Module import GHC.Tc.Utils.Monad @@ -2468,11 +2469,11 @@ hscParseIdentifier hsc_env str = runInteractiveHsc hsc_env $ hscParseThing parseIdentifier str hscParseThing :: (Outputable thing, Data thing) - => Lexer.P thing -> String -> Hsc thing + => Lexer.P PpState thing -> String -> Hsc thing hscParseThing = hscParseThingWithLocation "" 1 hscParseThingWithLocation :: (Outputable thing, Data thing) => String -> Int - -> Lexer.P thing -> String -> Hsc thing + -> Lexer.P PpState thing -> String -> Hsc thing hscParseThingWithLocation source linenumber parser str = do dflags <- getDynFlags logger <- getLogger ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -57,6 +57,7 @@ import GHC.Data.Maybe import GHC.Iface.Make import GHC.Driver.Config.Parser import GHC.Parser.Header +import GHC.Parser.PreProcess (initPpState) import GHC.Data.StringBuffer import GHC.Types.SourceError import GHC.Unit.Finder ===================================== compiler/GHC/Parser.hs-boot ===================================== @@ -4,4 +4,4 @@ import GHC.Types.Name.Reader (RdrName) import GHC.Parser.Lexer (P) import GHC.Parser.Annotation (LocatedN) -parseIdentifier :: P (LocatedN RdrName) +parseIdentifier :: P p (LocatedN RdrName) ===================================== compiler/GHC/Parser.y ===================================== @@ -83,8 +83,9 @@ import GHC.Core.DataCon ( DataCon, dataConName ) import GHC.Parser.PostProcess import GHC.Parser.PostProcess.Haddock -import GHC.Parser.Lexer hiding (lexer, lexerDbg) -import GHC.Parser.PreProcess +-- import GHC.Parser.Lexer hiding (lexer, lexerDbg) +import GHC.Parser.Lexer +import GHC.Parser.PreProcess hiding (lexer, lexerDbg) import GHC.Parser.HaddockLex import GHC.Parser.Annotation import GHC.Parser.Errors.Types @@ -756,7 +757,7 @@ TH_QQUASIQUOTE { L _ (ITqQuasiQuote _) } -- '#else' { L _ ITcppElse } -- '#endif' { L _ ITcppEndif } -%monad { P } { >>= } { return } +%monad { P p } { >>= } { return } %lexer { (lexer True) } { L _ ITeof } -- %lexer { (lexerDbg True) } { L _ ITeof } -- Replace 'lexer' above with 'lexerDbg' @@ -3986,7 +3987,7 @@ bars :: { ([SrcSpan],Int) } -- One or more bars | '|' { ([gl $1],1) } { -happyError :: P a +happyError :: P p a happyError = srcParseFail getVARID (L _ (ITvarid x)) = x @@ -4088,7 +4089,7 @@ hasE (L _ (ITopenExpQuote HasE _)) = True hasE (L _ (ITopenTExpQuote HasE)) = True hasE _ = False -getSCC :: Located Token -> P FastString +getSCC :: Located Token -> P p FastString getSCC lt = do let s = getSTRING lt -- We probably actually want to be more restrictive than this if ' ' `elem` unpackFS s @@ -4192,7 +4193,7 @@ incorrect. -- Make a source location for the file. We're a bit lazy here and just -- make a point SrcSpan at line 1, column 0. Strictly speaking we should -- try to find the span of the whole file (ToDo). -fileSrcSpan :: P SrcSpan +fileSrcSpan :: P p SrcSpan fileSrcSpan = do l <- getRealSrcLoc; let loc = mkSrcLoc (srcLocFile l) 1 1; @@ -4218,13 +4219,13 @@ looksLikeMult ty1 l_op ty2 | otherwise = False -- Hint about the MultiWayIf extension -hintMultiWayIf :: SrcSpan -> P () +hintMultiWayIf :: SrcSpan -> P p () hintMultiWayIf span = do mwiEnabled <- getBit MultiWayIfBit unless mwiEnabled $ addError $ mkPlainErrorMsgEnvelope span PsErrMultiWayIf -- Hint about explicit-forall -hintExplicitForall :: Located Token -> P () +hintExplicitForall :: Located Token -> P p () hintExplicitForall tok = do forall <- getBit ExplicitForallBit rulePrag <- getBit InRulePragBit @@ -4232,7 +4233,7 @@ hintExplicitForall tok = do (PsErrExplicitForall (isUnicode tok)) -- Hint about qualified-do -hintQualifiedDo :: Located Token -> P () +hintQualifiedDo :: Located Token -> P p () hintQualifiedDo tok = do qualifiedDo <- getBit QualifiedDoBit case maybeQDoDoc of @@ -4249,7 +4250,7 @@ hintQualifiedDo tok = do -- When two single quotes don't followed by tyvar or gtycon, we report the -- error as empty character literal, or TH quote that missing proper type -- variable or constructor. See #13450. -reportEmptyDoubleQuotes :: SrcSpan -> P a +reportEmptyDoubleQuotes :: SrcSpan -> P p a reportEmptyDoubleQuotes span = do thQuotes <- getBit ThQuotesBit addFatalError $ mkPlainErrorMsgEnvelope span $ PsErrEmptyDoubleQuotes thQuotes @@ -4343,7 +4344,7 @@ acs a = do return (a cs) -- Called at the very end to pick up the EOF position, as well as any comments not allocated yet. -acsFinal :: (EpAnnComments -> Maybe (RealSrcSpan, RealSrcSpan) -> Located a) -> P (Located a) +acsFinal :: (EpAnnComments -> Maybe (RealSrcSpan, RealSrcSpan) -> Located a) -> P p (Located a) acsFinal a = do let (L l _) = a emptyComments Nothing cs <- getCommentsFor l @@ -4364,7 +4365,7 @@ acsa a = do acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) acsA a = reLocA <$> acs a -acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP +acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P p ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a ; return (ecpFromExp $ expr) } @@ -4440,7 +4441,7 @@ pvL a = do { av <- a -- This and the signature module parser are the only parser entry points that -- deal with Haddock comments. The other entry points ('parseDeclaration', -- 'parseExpression', etc) do not insert them into the AST. -parseModule :: P (Located (HsModule GhcPs)) +parseModule :: P p (Located (HsModule GhcPs)) parseModule = parseModuleNoHaddock >>= addHaddockToModule -- | Parse a Haskell signature module with Haddock comments. This is done in two @@ -4452,7 +4453,7 @@ parseModule = parseModuleNoHaddock >>= addHaddockToModule -- This and the module parser are the only parser entry points that deal with -- Haddock comments. The other entry points ('parseDeclaration', -- 'parseExpression', etc) do not insert them into the AST. -parseSignature :: P (Located (HsModule GhcPs)) +parseSignature :: P p (Located (HsModule GhcPs)) parseSignature = parseSignatureNoHaddock >>= addHaddockToModule commentsA :: (Monoid ann) => SrcSpan -> EpAnnComments -> SrcSpanAnn' (EpAnn ann) @@ -4461,7 +4462,7 @@ commentsA loc cs = SrcSpanAnn (EpAnn (Anchor (rs loc) UnchangedAnchor) mempty cs -- | Instead of getting the *enclosed* comments, this includes the -- *preceding* ones. It is used at the top level to get comments -- between top level declarations. -commentsPA :: (Monoid ann) => LocatedAn ann a -> P (LocatedAn ann a) +commentsPA :: (Monoid ann) => LocatedAn ann a -> P p (LocatedAn ann a) commentsPA la@(L l a) = do cs <- getPriorCommentsFor (getLocA la) return (L (addCommentsToSrcAnn l cs) a) ===================================== compiler/GHC/Parser/HaddockLex.x ===================================== @@ -132,7 +132,7 @@ advanceSrcLocBS !loc bs = case utf8UnconsByteString bs of Just (c, bs') -> advanceSrcLocBS (advanceSrcLoc loc c) bs' -- | Lex 'StringLiteral' for warning messages -lexStringLiteral :: P (LocatedN RdrName) -- ^ A precise identifier parser +lexStringLiteral :: P () (LocatedN RdrName) -- ^ A precise identifier parser -> Located StringLiteral -> Located (WithHsDocIdentifiers StringLiteral GhcPs) lexStringLiteral identParser (L l sl@(StringLiteral _ fs _)) @@ -150,7 +150,7 @@ lexStringLiteral identParser (L l sl@(StringLiteral _ fs _)) fakeLoc = mkRealSrcLoc nilFS 0 0 -- | Lex identifiers from a docstring. -lexHsDoc :: P (LocatedN RdrName) -- ^ A precise identifier parser +lexHsDoc :: P () (LocatedN RdrName) -- ^ A precise identifier parser -> HsDocString -> HsDoc GhcPs lexHsDoc identParser doc = @@ -170,7 +170,7 @@ lexHsDoc identParser doc = fakeLoc = mkRealSrcLoc nilFS 0 0 -validateIdentWith :: P (LocatedN RdrName) -> SrcSpan -> ByteString -> Maybe (Located RdrName) +validateIdentWith :: P () (LocatedN RdrName) -> SrcSpan -> ByteString -> Maybe (Located RdrName) validateIdentWith identParser mloc str0 = let -- These ParserFlags should be as "inclusive" as possible, allowing -- identifiers defined with any language extension. @@ -184,7 +184,7 @@ validateIdentWith identParser mloc str0 = realSrcLc = case mloc of RealSrcSpan loc _ -> realSrcSpanStart loc UnhelpfulSpan _ -> mkRealSrcLoc nilFS 0 0 - pstate = initParserState pflags buffer realSrcLc + pstate = initParserState () pflags buffer realSrcLc in case unP identParser pstate of POk _ name -> Just $ case mloc of RealSrcSpan _ _ -> reLoc name ===================================== compiler/GHC/Parser/Header.hs ===================================== @@ -28,7 +28,8 @@ import GHC.Driver.Errors.Types -- Unfortunate, needed due to the fact we throw e import GHC.Parser.Errors.Types import GHC.Parser ( parseHeader ) -import GHC.Parser.Lexer +import GHC.Parser.Lexer hiding (initPragState, initParserState) +import GHC.Parser.PreProcess (initPragState, initParserState) import GHC.Hs import GHC.Unit.Module @@ -200,7 +201,7 @@ lazyGetToks popts filename handle = do where loc = mkRealSrcLoc (mkFastString filename) 1 1 - lazyLexBuf :: Handle -> PState -> Bool -> Int -> IO [Located Token] + lazyLexBuf :: Handle -> PState p -> Bool -> Int -> IO [Located Token] lazyLexBuf handle state eof size = case unP (lexer False return) state of POk state' t -> do @@ -218,7 +219,7 @@ lazyGetToks popts filename handle = do | otherwise -> return [L (mkSrcSpanPs (last_loc state)) ITeof] -- parser assumes an ITeof sentinel at the end - getMore :: Handle -> PState -> Int -> IO [Located Token] + getMore :: Handle -> PState p -> Int -> IO [Located Token] getMore handle state size = do -- pprTrace "getMore" (text (show (buffer state))) (return ()) let new_size = size * 2 ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1234,56 +1234,56 @@ reservedSymsFM = listToUFM $ -- ----------------------------------------------------------------------------- -- Lexer actions -type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) +type Action p = PsSpan -> StringBuffer -> Int -> StringBuffer -> P p (PsLocated Token) -special :: Token -> Action +special :: Token -> Action p special tok span _buf _len _buf2 = return (L span tok) -token, layout_token :: Token -> Action +token, layout_token :: Token -> Action p token t span _buf _len _buf2 = return (L span t) layout_token t span _buf _len _buf2 = pushLexState layout >> return (L span t) -idtoken :: (StringBuffer -> Int -> Token) -> Action +idtoken :: (StringBuffer -> Int -> Token) -> Action p idtoken f span buf len _buf2 = return (L span $! (f buf len)) -qdo_token :: (Maybe FastString -> Token) -> Action +qdo_token :: (Maybe FastString -> Token) -> Action p qdo_token con span buf len _buf2 = do maybe_layout token return (L span $! token) where !token = con $! Just $! fst $! splitQualName buf len False -skip_one_varid :: (FastString -> Token) -> Action +skip_one_varid :: (FastString -> Token) -> Action p skip_one_varid f span buf len _buf2 = return (L span $! f (lexemeToFastString (stepOn buf) (len-1))) -skip_one_varid_src :: (SourceText -> FastString -> Token) -> Action +skip_one_varid_src :: (SourceText -> FastString -> Token) -> Action p skip_one_varid_src f span buf len _buf2 = return (L span $! f (SourceText $ lexemeToFastString (stepOn buf) (len-1)) (lexemeToFastString (stepOn buf) (len-1))) -skip_two_varid :: (FastString -> Token) -> Action +skip_two_varid :: (FastString -> Token) -> Action p skip_two_varid f span buf len _buf2 = return (L span $! f (lexemeToFastString (stepOn (stepOn buf)) (len-2))) -strtoken :: (String -> Token) -> Action +strtoken :: (String -> Token) -> Action p strtoken f span buf len _buf2 = return (L span $! (f $! lexemeToString buf len)) -fstrtoken :: (FastString -> Token) -> Action +fstrtoken :: (FastString -> Token) -> Action p fstrtoken f span buf len _buf2 = return (L span $! (f $! lexemeToFastString buf len)) -begin :: Int -> Action +begin :: Int -> Action p begin code _span _str _len _buf2 = do pushLexState code; lexToken -pop :: Action +pop :: Action p pop _span _buf _len _buf2 = do _ <- popLexState lexToken -- trace "pop" $ do lexToken -cppToken :: Int -> Action +cppToken :: Int -> Action p cppToken code span buf len _buf2 = do let tokStr = lexemeToFastString buf len @@ -1297,7 +1297,7 @@ cppToken code span buf len _buf2 = return (L span (ITcpp continue $! lexemeToFastString buf len0)) -- trace ("cppToken:" ++ show (code, t)) $ do return (L span t) -cppTokenCont :: (FastString -> Token)-> Action +cppTokenCont :: (FastString -> Token)-> Action p cppTokenCont code span buf len _buf2 = do let tokStr = lexemeToFastString buf len @@ -1309,34 +1309,34 @@ cppTokenCont code span buf len _buf2 = _ -> return (len, False) return (L span (ITcpp continue $! lexemeToFastString buf len0)) -cppTokenPop :: (FastString -> Token)-> Action +cppTokenPop :: (FastString -> Token)-> Action p cppTokenPop t span buf len _buf2 = do _ <- popLexState -- return (L span (t $! lexemeToFastString buf (len - 1))) return (L span (t $! lexemeToFastString buf (trace "cppTokenPop" len))) -popCpp :: Action +popCpp :: Action p popCpp _span _buf _len _buf2 = do _ <- popLexState -- lexToken trace "pop" $ do lexToken -- See Note [Nested comment line pragmas] -failLinePrag1 :: Action +failLinePrag1 :: Action p failLinePrag1 span _buf _len _buf2 = do b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else lexError LexErrorInPragma -- See Note [Nested comment line pragmas] -popLinePrag1 :: Action +popLinePrag1 :: Action p popLinePrag1 span _buf _len _buf2 = do b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else do _ <- popLexState lexToken -hopefully_open_brace :: Action +hopefully_open_brace :: Action p hopefully_open_brace span buf len buf2 = do relaxed <- getBit RelaxedLayoutBit ctx <- getContext @@ -1350,7 +1350,7 @@ hopefully_open_brace span buf len buf2 else addFatalError $ mkPlainErrorMsgEnvelope (mkSrcSpanPs span) PsErrMissingBlock -pop_and :: Action -> Action +pop_and :: Action p -> Action p pop_and act span buf len buf2 = do _ <- popLexState act span buf len buf2 @@ -1400,7 +1400,7 @@ get_op_ws buf1 buf2 = mk_op_ws False False = OpWsLooseInfix {-# INLINE with_op_ws #-} -with_op_ws :: (OpWs -> Action) -> Action +with_op_ws :: (OpWs -> Action p) -> Action p with_op_ws act span buf len buf2 = act (get_op_ws buf buf2) span buf len buf2 {-# INLINE nextCharIs #-} @@ -1501,7 +1501,7 @@ alexNotPred p userState in1 len in2 alexOrPred p1 p2 userState in1 len in2 = p1 userState in1 len in2 || p2 userState in1 len in2 -multiline_doc_comment :: Action +multiline_doc_comment :: Action p multiline_doc_comment span buf _len _buf2 = {-# SCC "multiline_doc_comment" #-} withLexedDocType worker where worker input@(AI start_loc _) docType checkNextLine = go start_loc "" [] input @@ -1547,7 +1547,7 @@ multiline_doc_comment span buf _len _buf2 = {-# SCC "multiline_doc_comment" #-} | otherwise -> input Nothing -> input -lineCommentToken :: Action +lineCommentToken :: Action p lineCommentToken span buf len buf2 = do b <- getBit RawTokenStreamBit if b then do @@ -1560,7 +1560,7 @@ lineCommentToken span buf len buf2 = do nested comments require traversing by hand, they can't be parsed using regular expressions. -} -nested_comment :: Action +nested_comment :: Action p nested_comment span buf len _buf2 = {-# SCC "nested_comment" #-} do l <- getLastLocIncludingComments let endComment input (L _ comment) = commentEnd lexToken input (Nothing, ITblockComment comment l) buf span @@ -1569,7 +1569,7 @@ nested_comment span buf len _buf2 = {-# SCC "nested_comment" #-} do let start_decorator = reverse $ lexemeToString buf len nested_comment_logic endComment start_decorator input span -nested_doc_comment :: Action +nested_doc_comment :: Action p nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLexedDocType worker where worker input docType _checkNextLine = nested_comment_logic endComment "" input span @@ -1585,11 +1585,11 @@ nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLe -- | Includes the trailing '-}' decorators -- drop the last two elements with the callback if you don't want them to be included nested_comment_logic - :: (AlexInput -> Located String -> P (PsLocated Token)) -- ^ Continuation that gets the rest of the input and the lexed comment + :: (AlexInput -> Located String -> P p (PsLocated Token)) -- ^ Continuation that gets the rest of the input and the lexed comment -> String -- ^ starting value for accumulator (reversed) - When we want to include a decorator '{-' in the comment -> AlexInput -> PsSpan - -> P (PsLocated Token) + -> P p (PsLocated Token) nested_comment_logic endComment commentAcc input span = go commentAcc (1::Int) input where go commentAcc 0 input@(AI end_loc _) = do @@ -1623,13 +1623,13 @@ nested_comment_logic endComment commentAcc input span = go commentAcc (1::Int) i Just (_,_) -> go ('\n':commentAcc) n input (_, Just (c,input)) -> go (c:commentAcc) n input -ghcCppSet :: P Bool +ghcCppSet :: P p Bool ghcCppSet = do exts <- getExts return $ xtest GhcCppBit exts -- See Note [Nested comment line pragmas] -parseNestedPragma :: AlexInput -> P (String,AlexInput) +parseNestedPragma :: AlexInput -> P p (String,AlexInput) parseNestedPragma input@(AI _ buf) = do origInput <- getInput setInput input @@ -1675,8 +1675,8 @@ See #314 for more background on the bug this fixes. -} {-# INLINE withLexedDocType #-} -withLexedDocType :: (AlexInput -> ((HsDocStringDecorator -> HsDocString) -> (HdkComment, Token)) -> Bool -> P (PsLocated Token)) - -> P (PsLocated Token) +withLexedDocType :: (AlexInput -> ((HsDocStringDecorator -> HsDocString) -> (HdkComment, Token)) -> Bool -> P p (PsLocated Token)) + -> P p (PsLocated Token) withLexedDocType lexDocComment = do input@(AI _ buf) <- getInput l <- getLastLocIncludingComments @@ -1721,7 +1721,7 @@ mkHdkCommentSection loc n mkDS = (HdkCommentSection n ds, ITdocComment ds loc) -- RULES pragmas turn on the forall and '.' keywords, and we turn them -- off again at the end of the pragma. -rulePrag :: Action +rulePrag :: Action p rulePrag span buf len _buf2 = do setExts (.|. xbit InRulePragBit) let !src = lexemeToFastString buf len @@ -1729,7 +1729,7 @@ rulePrag span buf len _buf2 = do -- When 'UsePosPragsBit' is not set, it is expected that we emit a token instead -- of updating the position in 'PState' -linePrag :: Action +linePrag :: Action p linePrag span buf len buf2 = do usePosPrags <- getBit UsePosPragsBit if usePosPrags @@ -1739,7 +1739,7 @@ linePrag span buf len buf2 = do -- When 'UsePosPragsBit' is not set, it is expected that we emit a token instead -- of updating the position in 'PState' -columnPrag :: Action +columnPrag :: Action p columnPrag span buf len buf2 = do usePosPrags <- getBit UsePosPragsBit if usePosPrags @@ -1747,7 +1747,7 @@ columnPrag span buf len buf2 = do else let !src = lexemeToFastString buf len in return (L span (ITcolumn_prag (SourceText src))) -endPrag :: Action +endPrag :: Action p endPrag span _buf _len _buf2 = do setExts (.&. complement (xbit InRulePragBit)) return (L span ITclose_prag) @@ -1761,12 +1761,12 @@ endPrag span _buf _len _buf2 = do -- called afterwards, so it can just update the state. {-# INLINE commentEnd #-} -commentEnd :: P (PsLocated Token) +commentEnd :: P p (PsLocated Token) -> AlexInput -> (Maybe HdkComment, Token) -> StringBuffer -> PsSpan - -> P (PsLocated Token) + -> P p (PsLocated Token) commentEnd cont input (m_hdk_comment, hdk_token) buf span = do setInput input let (AI loc nextBuf) = input @@ -1781,17 +1781,17 @@ commentEnd cont input (m_hdk_comment, hdk_token) buf span = do {-# INLINE docCommentEnd #-} docCommentEnd :: AlexInput -> (HdkComment, Token) -> StringBuffer -> - PsSpan -> P (PsLocated Token) + PsSpan -> P p (PsLocated Token) docCommentEnd input (hdk_comment, tok) buf span = commentEnd lexToken input (Just hdk_comment, tok) buf span -errBrace :: AlexInput -> RealSrcSpan -> P a +errBrace :: AlexInput -> RealSrcSpan -> P p a errBrace (AI end _) span = failLocMsgP (realSrcSpanStart span) (psRealLoc end) (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc (PsErrLexer LexUnterminatedComment LexErrKind_EOF)) -open_brace, close_brace :: Action +open_brace, close_brace :: Action p open_brace span _str _len _buf2 = do ctx <- getContext setContext (NoLayout:ctx) @@ -1838,7 +1838,7 @@ splitQualName orig_buf len parens = split orig_buf orig_buf where qual_size = orig_buf `byteDiff` dot_buf -varid :: Action +varid :: Action p varid span buf len _buf2 = case lookupUFM reservedWordsFM fs of Just (ITcase, _) -> do @@ -1885,7 +1885,7 @@ qvarsym buf len = ITqvarsym $! splitQualName buf len False qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] -varsym :: OpWs -> Action +varsym :: OpWs -> Action p varsym opws at OpWsPrefix = sym $ \span exts s -> let warnExtConflict errtok = do { addPsMessage (mkSrcSpanPs span) (PsWarnOperatorWhitespaceExtConflict errtok) @@ -1935,12 +1935,12 @@ varsym OpWsLooseInfix = sym $ \_ _ s -> | otherwise -> return $ ITvarsym s -consym :: OpWs -> Action +consym :: OpWs -> Action p consym opws = sym $ \span _exts s -> do { warnOperatorWhitespace opws span s ; return (ITconsym s) } -warnOperatorWhitespace :: OpWs -> PsSpan -> FastString -> P () +warnOperatorWhitespace :: OpWs -> PsSpan -> FastString -> P p () warnOperatorWhitespace opws span s = whenIsJust (check_unusual_opws opws) $ \opws' -> addPsMessage @@ -1957,7 +1957,7 @@ check_unusual_opws opws = OpWsTightInfix -> Just OperatorWhitespaceOccurrence_TightInfix OpWsLooseInfix -> Nothing -sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P p Token) -> Action p sym con span buf len _buf2 = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1988,7 +1988,7 @@ tok_integral :: (SourceText -> Integer -> Token) -> (Integer -> Integer) -> Int -> Int -> (Integer, (Char -> Int)) - -> Action + -> Action p tok_integral itint transint transbuf translen (radix,char_to_int) span buf len _buf2 = do numericUnderscores <- getBit NumericUnderscoresBit -- #14473 let src = lexemeToFastString buf len @@ -2002,7 +2002,7 @@ tok_integral itint transint transbuf translen (radix,char_to_int) span buf len _ tok_num :: (Integer -> Integer) -> Int -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_num = tok_integral $ \case st@(SourceText (unconsFS -> Just ('-',_))) -> itint st (const True) st@(SourceText _) -> itint st (const False) @@ -2013,12 +2013,12 @@ tok_num = tok_integral $ \case tok_primint :: (Integer -> Integer) -> Int -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_primint = tok_integral ITprimint tok_primword :: Int -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_primword = tok_integral ITprimword positive positive, negative :: (Integer -> Integer) positive = id @@ -2035,13 +2035,13 @@ tok_primintX :: (SourceText -> Integer -> Token) -> Int -> (Integer -> Integer) -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_primintX itint addlen transint transbuf = tok_integral itint transint transbuf (transbuf+addlen) tok_primint8, tok_primint16, tok_primint32, tok_primint64 :: (Integer -> Integer) - -> Int -> (Integer, (Char->Int)) -> Action + -> Int -> (Integer, (Char->Int)) -> Action p tok_primint8 = tok_primintX ITprimint8 5 tok_primint16 = tok_primintX ITprimint16 6 tok_primint32 = tok_primintX ITprimint32 6 @@ -2052,19 +2052,19 @@ tok_primint64 = tok_primintX ITprimint64 6 tok_primwordX :: (SourceText -> Integer -> Token) -> Int -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_primwordX itint addlen transbuf = tok_integral itint positive transbuf (transbuf+addlen) tok_primword8, tok_primword16, tok_primword32, tok_primword64 - :: Int -> (Integer, (Char->Int)) -> Action + :: Int -> (Integer, (Char->Int)) -> Action p tok_primword8 = tok_primwordX ITprimword8 6 tok_primword16 = tok_primwordX ITprimword16 7 tok_primword32 = tok_primwordX ITprimword32 7 tok_primword64 = tok_primwordX ITprimword64 7 -- readSignificandExponentPair can understand negative rationals, exponents, everything. -tok_frac :: Int -> (String -> Token) -> Action +tok_frac :: Int -> (String -> Token) -> Action p tok_frac drop f span buf len _buf2 = do numericUnderscores <- getBit NumericUnderscoresBit -- #14473 let src = lexemeToString buf (len-drop) @@ -2099,7 +2099,7 @@ readFractionalLitX readStr b str = -- Layout processing -- we're at the first token on a line, insert layout tokens if necessary -do_bol :: Action +do_bol :: Action p do_bol span _str _len _buf2 = do -- See Note [Nested comment line pragmas] b <- getBit InNestedCommentBit @@ -2121,7 +2121,7 @@ do_bol span _str _len _buf2 = do -- certain keywords put us in the "layout" state, where we might -- add an opening curly brace. -maybe_layout :: Token -> P () +maybe_layout :: Token -> P p () maybe_layout t = do -- If the alternative layout rule is enabled then -- we never create an implicit layout context here. -- Layout is handled XXX instead. @@ -2150,7 +2150,7 @@ maybe_layout t = do -- If the alternative layout rule is enabled then -- We are slightly more lenient than this: when the new context is started -- by a 'do', then we allow the new context to be at the same indentation as -- the previous context. This is what the 'strict' argument is for. -new_layout_context :: Bool -> Bool -> Token -> Action +new_layout_context :: Bool -> Bool -> Token -> Action p new_layout_context strict gen_semic tok span _buf len _buf2 = do _ <- popLexState (AI l _) <- getInput @@ -2169,7 +2169,7 @@ new_layout_context strict gen_semic tok span _buf len _buf2 = do _ -> do setContext (Layout offset gen_semic : ctx) return (L span tok) -do_layout_left :: Action +do_layout_left :: Action p do_layout_left span _buf _len _buf2 = do _ <- popLexState pushLexState bol -- we must be at the start of a line @@ -2178,7 +2178,7 @@ do_layout_left span _buf _len _buf2 = do -- ----------------------------------------------------------------------------- -- LINE pragmas -setLineAndFile :: Int -> Action +setLineAndFile :: Int -> Action p setLineAndFile code (PsSpan span _) buf len _buf2 = do let src = lexemeToString buf (len - 1) -- drop trailing quotation mark linenumLen = length $ head $ words src @@ -2205,7 +2205,7 @@ setLineAndFile code (PsSpan span _) buf len _buf2 = do pushLexState code lexToken -setColumn :: Action +setColumn :: Action p setColumn (PsSpan span _) buf len _buf2 = do let column = case reads (lexemeToString buf len) of @@ -2226,12 +2226,12 @@ alrInitialLoc file = mkRealSrcSpan loc loc -- Options, includes and language pragmas. -lex_string_prag :: (String -> Token) -> Action +lex_string_prag :: (String -> Token) -> Action p lex_string_prag mkTok = lex_string_prag_comment mkTok' where mkTok' s _ = mkTok s -lex_string_prag_comment :: (String -> PsSpan -> Token) -> Action +lex_string_prag_comment :: (String -> PsSpan -> Token) -> Action p lex_string_prag_comment mkTok span _buf _len _buf2 = do input <- getInput start <- getParsedLoc @@ -2260,7 +2260,7 @@ lex_string_prag_comment mkTok span _buf _len _buf2 -- This stuff is horrible. I hates it. -lex_string_tok :: Action +lex_string_tok :: Action p lex_string_tok span buf _len _buf2 = do lexed <- lex_string (AI end bufEnd) <- getInput @@ -2272,7 +2272,7 @@ lex_string_tok span buf _len _buf2 = do return $ L (mkPsSpan (psSpanStart span) end) tok -lex_quoted_label :: Action +lex_quoted_label :: Action p lex_quoted_label span buf _len _buf2 = do start <- getInput s <- lex_string_helper "" start @@ -2287,7 +2287,7 @@ lex_quoted_label span buf _len _buf2 = do data LexedString = LexedRegularString String | LexedPrimString String -lex_string :: P LexedString +lex_string :: P p LexedString lex_string = do start <- getInput s <- lex_string_helper "" start @@ -2310,7 +2310,7 @@ lex_string = do return $ LexedRegularString s -lex_string_helper :: String -> AlexInput -> P String +lex_string_helper :: String -> AlexInput -> P p String lex_string_helper s start = do i <- getInput case alexGetChar' i of @@ -2345,7 +2345,7 @@ lex_string_helper s start = do _other -> lit_error i -lex_stringgap :: String -> AlexInput -> P String +lex_stringgap :: String -> AlexInput -> P p String lex_stringgap s start = do i <- getInput c <- getCharOrFail i @@ -2356,7 +2356,7 @@ lex_stringgap s start = do _other -> lit_error i -lex_char_tok :: Action +lex_char_tok :: Action p -- Here we are basically parsing character literals, such as 'x' or '\n' -- but we additionally spot 'x and ''T, returning ITsimpleQuote and -- ITtyQuote respectively, but WITHOUT CONSUMING the x or T part @@ -2399,7 +2399,7 @@ lex_char_tok span buf _len _buf2 = do -- We've seen ' let (AI end _) = i1 return (L (mkPsSpan loc end) ITsimpleQuote) -finish_char_tok :: StringBuffer -> PsLoc -> Char -> P (PsLocated Token) +finish_char_tok :: StringBuffer -> PsLoc -> Char -> P p (PsLocated Token) finish_char_tok buf loc ch -- We've already seen the closing quote -- Just need to check for trailing # = do magicHash <- getBit MagicHashBit @@ -2423,7 +2423,7 @@ isAny :: Char -> Bool isAny c | c > '\x7f' = isPrint c | otherwise = is_any c -lex_escape :: P Char +lex_escape :: P p Char lex_escape = do i0@(AI loc _) <- getInput c <- getCharOrFail i0 @@ -2472,7 +2472,7 @@ lex_escape = do return escape_char [] -> lit_error i0 -readNum :: (Char -> Bool) -> Int -> (Char -> Int) -> P Char +readNum :: (Char -> Bool) -> Int -> (Char -> Int) -> P p Char readNum is_digit base conv = do i <- getInput c <- getCharOrFail i @@ -2480,7 +2480,7 @@ readNum is_digit base conv = do then readNum2 is_digit base conv (conv c) else lit_error i -readNum2 :: (Char -> Bool) -> Int -> (Char -> Int) -> Int -> P Char +readNum2 :: (Char -> Bool) -> Int -> (Char -> Int) -> Int -> P p Char readNum2 is_digit base conv i = do input <- getInput read i input @@ -2537,10 +2537,10 @@ silly_escape_chars = [ -- the position of the error in the buffer. This is so that we can report -- a correct location to the user, but also so we can detect UTF-8 decoding -- errors if they occur. -lit_error :: AlexInput -> P a +lit_error :: AlexInput -> P p a lit_error i = do setInput i; lexError LexStringCharLit -getCharOrFail :: AlexInput -> P Char +getCharOrFail :: AlexInput -> P p Char getCharOrFail i = do case alexGetChar' i of Nothing -> lexError LexStringCharLitEOF @@ -2549,7 +2549,7 @@ getCharOrFail i = do -- ----------------------------------------------------------------------------- -- QuasiQuote -lex_qquasiquote_tok :: Action +lex_qquasiquote_tok :: Action p lex_qquasiquote_tok span buf len _buf2 = do let (qual, quoter) = splitQualName (stepOn buf) (len - 2) False quoteStart <- getParsedLoc @@ -2561,7 +2561,7 @@ lex_qquasiquote_tok span buf len _buf2 = do mkFastString (reverse quote), mkPsSpan quoteStart end))) -lex_quasiquote_tok :: Action +lex_quasiquote_tok :: Action p lex_quasiquote_tok span buf len _buf2 = do let quoter = tail (lexemeToString buf (len - 1)) -- 'tail' drops the initial '[', @@ -2574,7 +2574,7 @@ lex_quasiquote_tok span buf len _buf2 = do mkFastString (reverse quote), mkPsSpan quoteStart end))) -lex_quasiquote :: RealSrcLoc -> String -> P String +lex_quasiquote :: RealSrcLoc -> String -> P p String lex_quasiquote start s = do i <- getInput case alexGetChar' i of @@ -2591,7 +2591,7 @@ lex_quasiquote start s = do Just (c, i) -> do setInput i; lex_quasiquote start (c : s) -quasiquote_error :: RealSrcLoc -> P a +quasiquote_error :: RealSrcLoc -> P p a quasiquote_error start = do (AI end buf) <- getInput reportLexError start (psRealLoc end) buf @@ -2621,18 +2621,18 @@ smart_quote_error_message c loc = PsErrUnicodeCharLooksLike c correct_char correct_char_name in err -smart_quote_error :: Action +smart_quote_error :: Action p smart_quote_error span buf _len _buf2 = do let c = currentChar buf addFatalError (smart_quote_error_message c (psSpanStart span)) -add_smart_quote_error :: Char -> PsLoc -> P a +add_smart_quote_error :: Char -> PsLoc -> P p a add_smart_quote_error c loc = addFatalError (smart_quote_error_message c loc) -add_nonfatal_smart_quote_error :: Char -> PsLoc -> P () +add_nonfatal_smart_quote_error :: Char -> PsLoc -> P p () add_nonfatal_smart_quote_error c loc = addError (smart_quote_error_message c loc) -advance_to_smart_quote_character :: P () +advance_to_smart_quote_character :: P p () advance_to_smart_quote_character = do i <- getInput case alexGetChar' i of @@ -2643,12 +2643,12 @@ advance_to_smart_quote_character = do -- ----------------------------------------------------------------------------- -- Warnings -warnTab :: Action +warnTab :: Action p warnTab srcspan _buf _len _buf2 = do addTabWarning (psRealSpan srcspan) lexToken -warnThen :: PsMessage -> Action -> Action +warnThen :: PsMessage -> Action p -> Action p warnThen warning action srcspan buf len buf2 = do addPsMessage (RealSrcSpan (psRealSpan srcspan) Strict.Nothing) warning action srcspan buf len buf2 @@ -2672,14 +2672,14 @@ data LayoutContext deriving Show -- | The result of running a parser. -newtype ParseResult a = PR (# (# PState, a #) | PState #) +newtype ParseResult p a = PR (# (# PState p, a #) | PState p #) -- | The parser has consumed a (possibly empty) prefix of the input and produced -- a result. Use 'getPsMessages' to check for accumulated warnings and non-fatal -- errors. -- -- The carried parsing state can be used to resume parsing. -pattern POk :: PState -> a -> ParseResult a +pattern POk :: PState p -> a -> ParseResult p a pattern POk s a = PR (# (# s , a #) | #) -- | The parser has consumed a (possibly empty) prefix of the input and failed. @@ -2687,7 +2687,7 @@ pattern POk s a = PR (# (# s , a #) | #) -- The carried parsing state can be used to resume parsing. It is the state -- right before failure, including the fatal parse error. 'getPsMessages' and -- 'getPsErrorMessages' must return a non-empty bag of errors. -pattern PFailed :: PState -> ParseResult a +pattern PFailed :: PState p -> ParseResult p a pattern PFailed s = PR (# | s #) {-# COMPLETE POk, PFailed #-} @@ -2721,7 +2721,7 @@ data HdkComment | HdkCommentSection Int HsDocString deriving Show -data PState = PState { +data PState a = PState { buffer :: StringBuffer, options :: ParserOpts, warnings :: Messages PsMessage, @@ -2770,7 +2770,8 @@ data PState = PState { hdk_comments :: OrdList (PsLocated HdkComment), -- See Note [CPP in GHC] in GHC.Parser.PreProcess - pp :: !PpState + -- pp :: !PpState + pp :: !a } -- last_loc and last_len are used when generating error messages, -- and in pushCurrentContext only. Sigh, if only Happy passed the @@ -2798,6 +2799,7 @@ data PpState = PpState { data PpContext = PpContextIf [Located Token] deriving (Show) +-- TODO: delete initPpState :: PpState initPpState = PpState { pp_defines = Map.empty @@ -2815,90 +2817,90 @@ data ALRLayout = ALRLayoutLet | ALRLayoutDo -- | The parsing monad, isomorphic to @StateT PState Maybe at . -newtype P a = P { unP :: PState -> ParseResult a } +newtype P p a = P { unP :: PState p -> ParseResult p a } -instance Functor P where +instance Functor (P p) where fmap = liftM -instance Applicative P where +instance Applicative (P p) where pure = returnP (<*>) = ap -instance Monad P where +instance Monad (P p) where (>>=) = thenP -returnP :: a -> P a +returnP :: a -> P p a returnP a = a `seq` (P $ \s -> POk s a) -thenP :: P a -> (a -> P b) -> P b +thenP :: P p a -> (a -> P p b) -> P p b (P m) `thenP` k = P $ \ s -> case m s of POk s1 a -> (unP (k a)) s1 PFailed s1 -> PFailed s1 -failMsgP :: (SrcSpan -> MsgEnvelope PsMessage) -> P a +failMsgP :: (SrcSpan -> MsgEnvelope PsMessage) -> P p a failMsgP f = do pState <- getPState addFatalError (f (mkSrcSpanPs (last_loc pState))) -failLocMsgP :: RealSrcLoc -> RealSrcLoc -> (SrcSpan -> MsgEnvelope PsMessage) -> P a +failLocMsgP :: RealSrcLoc -> RealSrcLoc -> (SrcSpan -> MsgEnvelope PsMessage) -> P p a failLocMsgP loc1 loc2 f = addFatalError (f (RealSrcSpan (mkRealSrcSpan loc1 loc2) Strict.Nothing)) -getPState :: P PState +getPState :: P p (PState p) getPState = P $ \s -> POk s s -getExts :: P ExtsBitmap +getExts :: P p ExtsBitmap getExts = P $ \s -> POk s (pExtsBitmap . options $ s) -setExts :: (ExtsBitmap -> ExtsBitmap) -> P () +setExts :: (ExtsBitmap -> ExtsBitmap) -> P p () setExts f = P $ \s -> POk s { options = let p = options s in p { pExtsBitmap = f (pExtsBitmap p) } } () -setSrcLoc :: RealSrcLoc -> P () +setSrcLoc :: RealSrcLoc -> P p () setSrcLoc new_loc = P $ \s@(PState{ loc = PsLoc _ buf_loc }) -> POk s{ loc = PsLoc new_loc buf_loc } () -getRealSrcLoc :: P RealSrcLoc +getRealSrcLoc :: P p RealSrcLoc getRealSrcLoc = P $ \s@(PState{ loc=loc }) -> POk s (psRealLoc loc) -getParsedLoc :: P PsLoc +getParsedLoc :: P p PsLoc getParsedLoc = P $ \s@(PState{ loc=loc }) -> POk s loc -addSrcFile :: FastString -> P () +addSrcFile :: FastString -> P p () addSrcFile f = P $ \s -> POk s{ srcfiles = f : srcfiles s } () -setEofPos :: RealSrcSpan -> RealSrcSpan -> P () +setEofPos :: RealSrcSpan -> RealSrcSpan -> P p () setEofPos span gap = P $ \s -> POk s{ eof_pos = Strict.Just (span `Strict.And` gap) } () -setLastToken :: PsSpan -> Int -> P () +setLastToken :: PsSpan -> Int -> P p () setLastToken loc len = P $ \s -> POk s { last_loc=loc, last_len=len } () -setLastTk :: PsLocated Token -> P () +setLastTk :: PsLocated Token -> P p () setLastTk tk@(L l _) = P $ \s -> if isPointRealSpan (psRealSpan l) then POk s { last_tk = Strict.Just tk } () else POk s { last_tk = Strict.Just tk , prev_loc = l } () -setLastComment :: PsLocated Token -> P () +setLastComment :: PsLocated Token -> P p () setLastComment (L l _) = P $ \s -> POk s { prev_loc = l } () -getLastTk :: P (Strict.Maybe (PsLocated Token)) +getLastTk :: P p (Strict.Maybe (PsLocated Token)) getLastTk = P $ \s@(PState { last_tk = last_tk }) -> POk s last_tk -- see Note [PsSpan in Comments] -getLastLocIncludingComments :: P PsSpan +getLastLocIncludingComments :: P p PsSpan getLastLocIncludingComments = P $ \s@(PState { prev_loc = prev_loc }) -> POk s prev_loc -getLastLoc :: P PsSpan +getLastLoc :: P p PsSpan getLastLoc = P $ \s@(PState { last_loc = last_loc }) -> POk s last_loc data AlexInput = AI !PsLoc !StringBuffer @@ -3009,34 +3011,34 @@ alexGetChar' (AI loc s) where (c,s') = nextChar s loc' = advancePsLoc loc c -getInput :: P AlexInput +getInput :: P p AlexInput getInput = P $ \s at PState{ loc=l, buffer=b } -> POk s (AI l b) -setInput :: AlexInput -> P () +setInput :: AlexInput -> P p () setInput (AI l b) = P $ \s -> POk s{ loc=l, buffer=b } () -nextIsEOF :: P Bool +nextIsEOF :: P p Bool nextIsEOF = do AI _ s <- getInput return $ atEnd s -pushLexState :: Int -> P () +pushLexState :: Int -> P p () pushLexState ls = P $ \s at PState{ lex_state=l } -> POk s{lex_state=ls:l} () -- pushLexState ls = P $ \s at PState{ lex_state= l } -> POk s{lex_state= trace ("pushLexState:" ++ show ls) ls:l} () -popLexState :: P Int +popLexState :: P p Int popLexState = P $ \s at PState{ lex_state=ls:l } -> POk s{ lex_state=l } ls -- popLexState = P $ \s at PState{ lex_state=ls:l } -> POk s{ lex_state= trace ("popLexState:" ++ show (ls,l)) l } ls -getLexState :: P Int +getLexState :: P p Int getLexState = P $ \s at PState{ lex_state=ls:_ } -> POk s ls -popNextToken :: P (Maybe (PsLocated Token)) +popNextToken :: P p (Maybe (PsLocated Token)) popNextToken = P $ \s at PState{ alr_next_token = m } -> POk (s {alr_next_token = Nothing}) m -activeContext :: P Bool +activeContext :: P p Bool activeContext = do ctxt <- getALRContext expc <- getAlrExpectingOCurly @@ -3045,55 +3047,55 @@ activeContext = do ([],Nothing) -> return impt _other -> return True -resetAlrLastLoc :: FastString -> P () +resetAlrLastLoc :: FastString -> P p () resetAlrLastLoc file = P $ \s@(PState {alr_last_loc = PsSpan _ buf_span}) -> POk s{ alr_last_loc = PsSpan (alrInitialLoc file) buf_span } () -setAlrLastLoc :: PsSpan -> P () +setAlrLastLoc :: PsSpan -> P p () setAlrLastLoc l = P $ \s -> POk (s {alr_last_loc = l}) () -getAlrLastLoc :: P PsSpan +getAlrLastLoc :: P p PsSpan getAlrLastLoc = P $ \s@(PState {alr_last_loc = l}) -> POk s l -getALRContext :: P [ALRContext] +getALRContext :: P p [ALRContext] getALRContext = P $ \s@(PState {alr_context = cs}) -> POk s cs -setALRContext :: [ALRContext] -> P () +setALRContext :: [ALRContext] -> P p () setALRContext cs = P $ \s -> POk (s {alr_context = cs}) () -getJustClosedExplicitLetBlock :: P Bool +getJustClosedExplicitLetBlock :: P p Bool getJustClosedExplicitLetBlock = P $ \s@(PState {alr_justClosedExplicitLetBlock = b}) -> POk s b -setJustClosedExplicitLetBlock :: Bool -> P () +setJustClosedExplicitLetBlock :: Bool -> P p () setJustClosedExplicitLetBlock b = P $ \s -> POk (s {alr_justClosedExplicitLetBlock = b}) () -setNextToken :: PsLocated Token -> P () +setNextToken :: PsLocated Token -> P p () setNextToken t = P $ \s -> POk (s {alr_next_token = Just t}) () -implicitTokenPending :: P Bool +implicitTokenPending :: P p Bool implicitTokenPending = P $ \s at PState{ alr_pending_implicit_tokens = ts } -> case ts of [] -> POk s False _ -> POk s True -popPendingImplicitToken :: P (Maybe (PsLocated Token)) +popPendingImplicitToken :: P p (Maybe (PsLocated Token)) popPendingImplicitToken = P $ \s at PState{ alr_pending_implicit_tokens = ts } -> case ts of [] -> POk s Nothing (t : ts') -> POk (s {alr_pending_implicit_tokens = ts'}) (Just t) -setPendingImplicitTokens :: [PsLocated Token] -> P () +setPendingImplicitTokens :: [PsLocated Token] -> P p () setPendingImplicitTokens ts = P $ \s -> POk (s {alr_pending_implicit_tokens = ts}) () -getAlrExpectingOCurly :: P (Maybe ALRLayout) +getAlrExpectingOCurly :: P p (Maybe ALRLayout) getAlrExpectingOCurly = P $ \s@(PState {alr_expecting_ocurly = b}) -> POk s b -setAlrExpectingOCurly :: Maybe ALRLayout -> P () +setAlrExpectingOCurly :: Maybe ALRLayout -> P p () setAlrExpectingOCurly b = P $ \s -> POk (s {alr_expecting_ocurly = b}) () -- | For reasons of efficiency, boolean parsing flags (eg, language extensions @@ -3270,15 +3272,15 @@ disableHaddock opts = upd_bitmap (xunset HaddockBit) -- | Set parser options for parsing OPTIONS pragmas -initPragState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState -initPragState options buf loc = (initParserState options buf loc) +initPragState :: p -> ParserOpts -> StringBuffer -> RealSrcLoc -> PState p +initPragState p options buf loc = (initParserState p options buf loc) -- initPragState options buf loc = (initParserState options buf (trace ("initPragState:" ++ show bol) loc)) { lex_state = [bol, option_prags, 0] } -- | Creates a parse state from a 'ParserOpts' value -initParserState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState -initParserState options buf loc = +initParserState :: p -> ParserOpts -> StringBuffer -> RealSrcLoc -> PState p +initParserState ppState options buf loc = PState { buffer = buf, options = options, @@ -3304,7 +3306,8 @@ initParserState options buf loc = header_comments = Strict.Nothing, comment_q = [], hdk_comments = nilOL, - pp = initPpState + -- pp = initPpState + pp = ppState } where init_loc = PsLoc loc (BufPos 0) @@ -3352,7 +3355,7 @@ class Monad m => MonadP m where -- that come after the given span allocateFinalCommentsP :: RealSrcSpan -> m EpAnnComments -instance MonadP P where +instance MonadP (P p) where addError err = P $ \s -> POk s { errors = err `addMessage` errors s} () @@ -3399,15 +3402,15 @@ getFinalCommentsFor :: (MonadP m) => SrcSpan -> m EpAnnComments getFinalCommentsFor (RealSrcSpan l _) = allocateFinalCommentsP l getFinalCommentsFor _ = return emptyComments -getEofPos :: P (Strict.Maybe (Strict.Pair RealSrcSpan RealSrcSpan)) +getEofPos :: P p (Strict.Maybe (Strict.Pair RealSrcSpan RealSrcSpan)) getEofPos = P $ \s@(PState { eof_pos = pos }) -> POk s pos -addPsMessage :: SrcSpan -> PsMessage -> P () +addPsMessage :: SrcSpan -> PsMessage -> P p () addPsMessage srcspan msg = do diag_opts <- (pDiagOpts . options) <$> getPState addWarning (mkPlainMsgEnvelope diag_opts srcspan msg) -addTabWarning :: RealSrcSpan -> P () +addTabWarning :: RealSrcSpan -> P p () addTabWarning srcspan = P $ \s at PState{tab_first=tf, tab_count=tc, options=o} -> let tf' = tf <|> Strict.Just srcspan @@ -3419,12 +3422,12 @@ addTabWarning srcspan -- | Get a bag of the errors that have been accumulated so far. -- Does not take -Werror into account. -getPsErrorMessages :: PState -> Messages PsMessage +getPsErrorMessages :: PState p -> Messages PsMessage getPsErrorMessages p = errors p -- | Get the warnings and errors accumulated so far. -- Does not take -Werror into account. -getPsMessages :: PState -> (Messages PsMessage, Messages PsMessage) +getPsMessages :: PState p -> (Messages PsMessage, Messages PsMessage) getPsMessages p = let ws = warnings p diag_opts = pDiagOpts (options p) @@ -3439,13 +3442,13 @@ getPsMessages p = in msg `addMessage` ws in (ws', errors p) -getContext :: P [LayoutContext] +getContext :: P p [LayoutContext] getContext = P $ \s at PState{context=ctx} -> POk s ctx -setContext :: [LayoutContext] -> P () +setContext :: [LayoutContext] -> P p () setContext ctx = P $ \s -> POk s{context=ctx} () -popContext :: P () +popContext :: P p () popContext = P $ \ s@(PState{ buffer = buf, options = o, context = ctx, last_len = len, last_loc = last_loc }) -> case ctx of @@ -3455,16 +3458,16 @@ popContext = P $ \ s@(PState{ buffer = buf, options = o, context = ctx, unP (addFatalError $ srcParseErr o buf len (mkSrcSpanPs last_loc)) s -- Push a new layout context at the indentation of the last token read. -pushCurrentContext :: GenSemic -> P () +pushCurrentContext :: GenSemic -> P p () pushCurrentContext gen_semic = P $ \ s at PState{ last_loc=loc, context=ctx } -> POk s{context = Layout (srcSpanStartCol (psRealSpan loc)) gen_semic : ctx} () -- This is only used at the outer level of a module when the 'module' keyword is -- missing. -pushModuleContext :: P () +pushModuleContext :: P p () pushModuleContext = pushCurrentContext generateSemic -getOffside :: P (Ordering, Bool) +getOffside :: P p (Ordering, Bool) getOffside = P $ \s at PState{last_loc=loc, context=stk} -> let offs = srcSpanStartCol (psRealSpan loc) in let ord = case stk of @@ -3504,14 +3507,14 @@ srcParseErr options buf len loc = mkPlainErrorMsgEnvelope loc (PsErrParse token -- Report a parse failure, giving the span of the previous token as -- the location of the error. This is the entry point for errors -- detected during parsing. -srcParseFail :: P a +srcParseFail :: P p a srcParseFail = P $ \s at PState{ buffer = buf, options = o, last_len = len, last_loc = last_loc } -> unP (addFatalError $ srcParseErr o buf len (mkSrcSpanPs last_loc)) s -- A lexical error is reported at a particular position in the source file, -- not over a token range. -lexError :: LexErr -> P a +lexError :: LexErr -> P p a lexError e = do loc <- getRealSrcLoc (AI end buf) <- getInput @@ -3522,7 +3525,7 @@ lexError e = do -- This is the top-level function: called from the parser each time a -- new token is to be read from the input. -lexer, lexerDbg :: Bool -> (Located Token -> P a) -> P a +lexer, lexerDbg :: Bool -> (Located Token -> P p a) -> P p a lexer queueComments cont = do alr <- getBit AlternativeLayoutRuleBit @@ -3539,7 +3542,7 @@ lexerDbg queueComments cont = lexer queueComments contDbg where contDbg tok = trace ("token: " ++ show (unLoc tok)) (cont tok) -lexTokenAlr :: P (PsLocated Token) +lexTokenAlr :: P p (PsLocated Token) lexTokenAlr = do mPending <- popPendingImplicitToken t <- case mPending of Nothing -> @@ -3563,7 +3566,7 @@ lexTokenAlr = do mPending <- popPendingImplicitToken _ -> return () return t -alternativeLayoutRuleToken :: PsLocated Token -> P (PsLocated Token) +alternativeLayoutRuleToken :: PsLocated Token -> P p (PsLocated Token) alternativeLayoutRuleToken t = do context <- getALRContext lastLoc <- getAlrLastLoc @@ -3754,7 +3757,7 @@ topNoLayoutContainsCommas [] = False topNoLayoutContainsCommas (ALRLayout _ _ : ls) = topNoLayoutContainsCommas ls topNoLayoutContainsCommas (ALRNoLayout b _ : _) = b -lexToken :: P (PsLocated Token) +lexToken :: P p (PsLocated Token) lexToken = do inp@(AI loc1 buf) <- getInput sc <- getLexState @@ -3787,7 +3790,7 @@ reportLexError :: RealSrcLoc -> RealSrcLoc -> StringBuffer -> (LexErrKind -> SrcSpan -> MsgEnvelope PsMessage) - -> P a + -> P p a reportLexError loc1 loc2 buf f | atEnd buf = failLocMsgP loc1 loc2 (f LexErrKind_EOF) | otherwise = @@ -3796,14 +3799,14 @@ reportLexError loc1 loc2 buf f then failLocMsgP loc2 loc2 (f LexErrKind_UTF8) else failLocMsgP loc1 loc2 (f (LexErrKind_Char c)) -lexTokenStream :: ParserOpts -> StringBuffer -> RealSrcLoc -> ParseResult [Located Token] -lexTokenStream opts buf loc = unP go initState{ options = opts' } +lexTokenStream :: p -> ParserOpts -> StringBuffer -> RealSrcLoc -> ParseResult p [Located Token] +lexTokenStream pp opts buf loc = unP go initState{ options = opts' } where new_exts = xunset UsePosPragsBit -- parse LINE/COLUMN pragmas as tokens $ xset RawTokenStreamBit -- include comments $ pExtsBitmap opts opts' = opts { pExtsBitmap = new_exts } - initState = initParserState opts' buf loc + initState = initParserState pp opts' buf loc go = do ltok <- lexer False return case ltok of @@ -3866,13 +3869,13 @@ twoWordPrags = Map.fromList [ fstrtoken (\s -> (ITspec_inline_prag (SourceText s) False))) ] -dispatch_pragmas :: Map String Action -> Action +dispatch_pragmas :: Map String (Action p) -> Action p dispatch_pragmas prags span buf len buf2 = case Map.lookup (clean_pragma (lexemeToString buf len)) prags of Just found -> found span buf len buf2 Nothing -> lexError LexUnknownPragma -known_pragma :: Map String Action -> AlexAccPred ExtsBitmap +known_pragma :: Map String (Action p) -> AlexAccPred ExtsBitmap known_pragma prags _ (AI _ startbuf) _ (AI _ curbuf) = isKnown && nextCharIsNot curbuf pragmaNameChar where l = lexemeToString startbuf (byteDiff startbuf curbuf) @@ -3891,7 +3894,7 @@ clean_pragma prag = canon_ws (map toLower (unprefix prag)) _ -> prag' canon_ws s = unwords (map canonical (words s)) -warn_unknown_prag :: Map String Action -> Action +warn_unknown_prag :: Map String (Action p) -> Action p warn_unknown_prag prags span buf len buf2 = do let uppercase = map toUpper unknown_prag = uppercase (clean_pragma (lexemeToString buf len)) @@ -3923,12 +3926,12 @@ mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCl lo = mkRealSrcSpan (realSrcSpanStart ss) (mkRealSrcLoc f sl (sc+1)) lc = mkRealSrcSpan (mkRealSrcLoc f el (ec - 1)) (realSrcSpanEnd ss) -queueComment :: RealLocated Token -> P() +queueComment :: RealLocated Token -> P p () queueComment c = P $ \s -> POk s { comment_q = commentToAnnotation c : comment_q s } () -queueIgnoredToken :: PsLocated Token -> P() +queueIgnoredToken :: PsLocated Token -> P p () queueIgnoredToken (L l tok) = do ll <- getLastLocIncludingComments let ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -195,7 +195,7 @@ mkClassDecl :: SrcSpan -> OrdList (LHsDecl GhcPs) -> LayoutInfo GhcPs -> [AddEpAnn] - -> P (LTyClDecl GhcPs) + -> P p (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layoutInfo annsIn = do { let loc = noAnnSrcSpan loc' @@ -224,7 +224,7 @@ mkTyData :: SrcSpan -> [LConDecl GhcPs] -> Located (HsDeriving GhcPs) -> [AddEpAnn] - -> P (LTyClDecl GhcPs) + -> P p (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn = do { let loc = noAnnSrcSpan loc' @@ -244,7 +244,7 @@ mkDataDefn :: Maybe (LocatedP CType) -> Maybe (LHsKind GhcPs) -> DataDefnCons (LConDecl GhcPs) -> HsDeriving GhcPs - -> P (HsDataDefn GhcPs) + -> P p (HsDataDefn GhcPs) mkDataDefn cType mcxt ksig data_cons maybe_deriv = do { checkDatatypeContext mcxt ; return (HsDataDefn { dd_ext = noExtField @@ -258,7 +258,7 @@ mkTySynonym :: SrcSpan -> LHsType GhcPs -- LHS -> LHsType GhcPs -- RHS -> [AddEpAnn] - -> P (LTyClDecl GhcPs) + -> P p (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs ; cs1 <- getCommentsFor loc -- Add any API Annotations to the top SrcSpan [temp] @@ -276,7 +276,7 @@ mkStandaloneKindSig -> Located [LocatedN RdrName] -- LHS -> LHsSigType GhcPs -- RHS -> [AddEpAnn] - -> P (LStandaloneKindSig GhcPs) + -> P p (LStandaloneKindSig GhcPs) mkStandaloneKindSig loc lhs rhs anns = do { vs <- mapM check_lhs_name (unLoc lhs) ; v <- check_singular_lhs (reverse vs) @@ -301,7 +301,7 @@ mkTyFamInstEqn :: SrcSpan -> LHsType GhcPs -> LHsType GhcPs -> [AddEpAnn] - -> P (LTyFamInstEqn GhcPs) + -> P p (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs ; cs <- getCommentsFor loc @@ -322,7 +322,7 @@ mkDataFamInst :: SrcSpan -> [LConDecl GhcPs] -> Located (HsDeriving GhcPs) -> [AddEpAnn] - -> P (LInstDecl GhcPs) + -> P p (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr @@ -357,7 +357,7 @@ mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) mkTyFamInst :: SrcSpan -> TyFamInstEqn GhcPs -> [AddEpAnn] - -> P (LInstDecl GhcPs) + -> P p (LInstDecl GhcPs) mkTyFamInst loc eqn anns = do cs <- getCommentsFor loc return (L (noAnnSrcSpan loc) (TyFamInstD noExtField @@ -370,7 +370,7 @@ mkFamDecl :: SrcSpan -> LFamilyResultSig GhcPs -- Optional result signature -> Maybe (LInjectivityAnn GhcPs) -- Injectivity annotation -> [AddEpAnn] - -> P (LTyClDecl GhcPs) + -> P p (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs ; cs1 <- getCommentsFor loc -- Add any API Annotations to the top SrcSpan [temp] @@ -392,7 +392,7 @@ mkFamDecl loc info topLevel lhs ksig injAnn annsIn OpenTypeFamily -> empty ClosedTypeFamily {} -> whereDots -mkSpliceDecl :: LHsExpr GhcPs -> P (LHsDecl GhcPs) +mkSpliceDecl :: LHsExpr GhcPs -> P p (LHsDecl GhcPs) -- If the user wrote -- [pads| ... ] then return a QuasiQuoteD -- $(e) then return a SpliceD @@ -421,7 +421,7 @@ mkRoleAnnotDecl :: SrcSpan -> LocatedN RdrName -- type being annotated -> [Located (Maybe FastString)] -- roles -> [AddEpAnn] - -> P (LRoleAnnotDecl GhcPs) + -> P p (LRoleAnnotDecl GhcPs) mkRoleAnnotDecl loc tycon roles anns = do { roles' <- mapM parse_role roles ; cs <- getCommentsFor loc @@ -446,20 +446,20 @@ mkRoleAnnotDecl loc tycon roles anns -- | Converts a list of 'LHsTyVarBndr's annotated with their 'Specificity' to -- binders without annotations. Only accepts specified variables, and errors if -- any of the provided binders has an 'InferredSpec' annotation. -fromSpecTyVarBndrs :: [LHsTyVarBndr Specificity GhcPs] -> P [LHsTyVarBndr () GhcPs] +fromSpecTyVarBndrs :: [LHsTyVarBndr Specificity GhcPs] -> P p [LHsTyVarBndr () GhcPs] fromSpecTyVarBndrs = mapM fromSpecTyVarBndr -- | Converts 'LHsTyVarBndr' annotated with its 'Specificity' to one without -- annotations. Only accepts specified variables, and errors if the provided -- binder has an 'InferredSpec' annotation. -fromSpecTyVarBndr :: LHsTyVarBndr Specificity GhcPs -> P (LHsTyVarBndr () GhcPs) +fromSpecTyVarBndr :: LHsTyVarBndr Specificity GhcPs -> P p (LHsTyVarBndr () GhcPs) fromSpecTyVarBndr bndr = case bndr of (L loc (UserTyVar xtv flag idp)) -> (check_spec flag loc) >> return (L loc $ UserTyVar xtv () idp) (L loc (KindedTyVar xtv flag idp k)) -> (check_spec flag loc) >> return (L loc $ KindedTyVar xtv () idp k) where - check_spec :: Specificity -> SrcSpanAnnA -> P () + check_spec :: Specificity -> SrcSpanAnnA -> P p () check_spec SpecifiedSpec _ = return () check_spec InferredSpec loc = addFatalError $ mkPlainErrorMsgEnvelope (locA loc) $ PsErrInferredTypeVarNotAllowed @@ -527,7 +527,7 @@ cvTopDecls :: OrdList (LHsDecl GhcPs) -> [LHsDecl GhcPs] cvTopDecls decls = getMonoBindAll (fromOL decls) -- Declaration list may only contain value bindings and signatures. -cvBindGroup :: OrdList (LHsDecl GhcPs) -> P (HsValBinds GhcPs) +cvBindGroup :: OrdList (LHsDecl GhcPs) -> P p (HsValBinds GhcPs) cvBindGroup binding = do { (mbs, sigs, fam_ds, tfam_insts , dfam_insts, _) <- cvBindsAndSigs binding @@ -535,7 +535,7 @@ cvBindGroup binding ; return $ ValBinds NoAnnSortKey mbs sigs } cvBindsAndSigs :: OrdList (LHsDecl GhcPs) - -> P (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs] + -> P p (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs] , [LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs]) -- Input decls contain just value bindings and signatures -- and in case of class or instance declarations also @@ -733,7 +733,7 @@ tyConToDataCon (L loc tc) mkPatSynMatchGroup :: LocatedN RdrName -> LocatedL (OrdList (LHsDecl GhcPs)) - -> P (MatchGroup GhcPs (LHsExpr GhcPs)) + -> P p (MatchGroup GhcPs (LHsExpr GhcPs)) mkPatSynMatchGroup (L loc patsyn_name) (L ld decls) = do { matches <- mapM fromDecl (fromOL decls) ; when (null matches) (wrongNumberErr (locA loc)) @@ -779,7 +779,7 @@ mkPatSynMatchGroup (L loc patsyn_name) (L ld decls) = addFatalError $ mkPlainErrorMsgEnvelope loc $ (PsErrEmptyWhereInPatSynDecl patsyn_name) -recordPatSynErr :: SrcSpan -> LPat GhcPs -> P a +recordPatSynErr :: SrcSpan -> LPat GhcPs -> P p a recordPatSynErr loc pat = addFatalError $ mkPlainErrorMsgEnvelope loc $ (PsErrRecordSyntaxInPatSynDecl pat) @@ -808,7 +808,7 @@ mkGadtDecl :: SrcSpan -> NonEmpty (LocatedN RdrName) -> LHsUniToken "::" "∷" GhcPs -> LHsSigType GhcPs - -> P (LConDecl GhcPs) + -> P p (LConDecl GhcPs) mkGadtDecl loc names dcol ty = do cs <- getCommentsFor loc let l = noAnnSrcSpan loc @@ -935,7 +935,7 @@ eitherToP (Left err) = addFatalError err eitherToP (Right thing) = return thing checkTyVars :: SDoc -> SDoc -> LocatedN RdrName -> [LHsTypeArg GhcPs] - -> P (LHsQTyVars GhcPs) -- the synthesized type variables + -> P p (LHsQTyVars GhcPs) -- the synthesized type variables -- ^ Check whether the given list of type parameters are all type variables -- (possibly with a kind signature). checkTyVars pp_what equals_or_where tc tparms @@ -948,7 +948,7 @@ checkTyVars pp_what equals_or_where tc tparms (PsErrMalformedDecl pp_what (unLoc tc)) -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> HsBndrVis GhcPs -> LHsType GhcPs - -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) + -> P p (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) chkParens ops cps cs bvis (L l (HsParTy an ty)) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) @@ -957,7 +957,7 @@ checkTyVars pp_what equals_or_where tc tparms chkParens ops cps cs bvis ty = chk ops cps cs bvis ty -- Check that the name space is correct! - chk :: [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) + chk :: [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> HsBndrVis GhcPs -> LHsType GhcPs -> P p (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) chk ops cps cs bvis (L l (HsKindSig annk (L annt (HsTyVar ann _ (L lv tv))) k)) | isRdrTyVar tv = let @@ -993,7 +993,7 @@ whereDots, equalsDots :: SDoc whereDots = text "where ..." equalsDots = text "= ..." -checkDatatypeContext :: Maybe (LHsContext GhcPs) -> P () +checkDatatypeContext :: Maybe (LHsContext GhcPs) -> P p () checkDatatypeContext Nothing = return () checkDatatypeContext (Just c) = do allowed <- getBit DatatypeContextsBit @@ -1023,7 +1023,7 @@ mkRuleTyVarBndrs = fmap cvt_one tm_to_ty _ = panic "mkRuleTyVarBndrs" -- See Note [Parsing explicit foralls in Rules] in Parser.y -checkRuleTyVarBndrNames :: [LHsTyVarBndr flag GhcPs] -> P () +checkRuleTyVarBndrNames :: [LHsTyVarBndr flag GhcPs] -> P p () checkRuleTyVarBndrNames = mapM_ (check . fmap hsTyVarName) where check (L loc (Unqual occ)) = when (occNameFS occ `elem` [fsLit "forall",fsLit "family",fsLit "role"]) @@ -1041,7 +1041,7 @@ checkRecordSyntax lr@(L loc r) -- | Check if the gadt_constrlist is empty. Only raise parse error for -- `data T where` to avoid affecting existing error message, see #8258. checkEmptyGADTs :: Located ([AddEpAnn], [LConDecl GhcPs]) - -> P (Located ([AddEpAnn], [LConDecl GhcPs])) + -> P p (Located ([AddEpAnn], [LConDecl GhcPs])) checkEmptyGADTs gadts@(L span (_, [])) -- Empty GADT declaration. = do gadtSyntax <- getBit GadtSyntaxBit -- GADTs implies GADTSyntax unless gadtSyntax $ addError $ mkPlainErrorMsgEnvelope span $ @@ -1052,10 +1052,10 @@ checkEmptyGADTs gadts = return gadts -- Ordinary GADT declaration. checkTyClHdr :: Bool -- True <=> class header -- False <=> type header -> LHsType GhcPs - -> P (LocatedN RdrName, -- the head symbol (type or class name) - [LHsTypeArg GhcPs], -- parameters of head symbol - LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + -> P p (LocatedN RdrName, -- the head symbol (type or class name) + [LHsTypeArg GhcPs], -- parameters of head symbol + LexicalFixity, -- the declaration is in infix format + [AddEpAnn]) -- API Annotation for HsParTy -- when stripping parens -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) @@ -1152,12 +1152,12 @@ checkCmdBlockArguments :: LHsCmd GhcPs -> PV () -- (Eq a) --> [Eq a] -- (((Eq a))) --> [Eq a] -- @ -checkContext :: LHsType GhcPs -> P (LHsContext GhcPs) +checkContext :: LHsType GhcPs -> P p (LHsContext GhcPs) checkContext orig_t@(L (SrcSpanAnn _ l) _orig_t) = check ([],[],emptyComments) orig_t where check :: ([EpaLocation],[EpaLocation],EpAnnComments) - -> LHsType GhcPs -> P (LHsContext GhcPs) + -> LHsType GhcPs -> P p (LHsContext GhcPs) check (oparens,cparens,cs) (L _l (HsTupleTy ann' HsBoxedOrConstraintTuple ts)) -- (Eq a, Ord b) shows up as a tuple type. Only boxed tuples can -- be used as context constraints. @@ -1184,7 +1184,7 @@ checkContext orig_t@(L (SrcSpanAnn _ l) _orig_t) = checkImportDecl :: Maybe EpaLocation -> Maybe EpaLocation - -> P () + -> P p () checkImportDecl mPre mPost = do let whenJust mg f = maybe (pure ()) f mg @@ -1213,10 +1213,10 @@ checkImportDecl mPre mPost = do -- We parse patterns as expressions and check for valid patterns below, -- converting the expression into a pattern at the same time. -checkPattern :: LocatedA (PatBuilder GhcPs) -> P (LPat GhcPs) +checkPattern :: LocatedA (PatBuilder GhcPs) -> P p (LPat GhcPs) checkPattern = runPV . checkLPat -checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P (LPat GhcPs) +checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P p (LPat GhcPs) checkPattern_details extraDetails pp = runPV_details extraDetails (pp >>= checkLPat) checkLPat :: LocatedA (PatBuilder GhcPs) -> PV (LPat GhcPs) @@ -1320,7 +1320,7 @@ checkValDef :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> Maybe (AddEpAnn, LHsType GhcPs) -> Located (GRHSs GhcPs (LHsExpr GhcPs)) - -> P (HsBind GhcPs) + -> P p (HsBind GhcPs) checkValDef loc lhs (Just (sigAnn, sig)) grhss -- x :: ty = rhs parses as a *pattern* binding @@ -1345,7 +1345,7 @@ checkFunBind :: SrcStrictness -> LexicalFixity -> [LocatedA (PatBuilder GhcPs)] -> Located (GRHSs GhcPs (LHsExpr GhcPs)) - -> P (HsBind GhcPs) + -> P p (HsBind GhcPs) checkFunBind strictness locF ann fun is_infix pats (L _ grhss) = do ps <- runPV_details extraDetails (mapM checkLPat pats) let match_span = noAnnSrcSpan $ locF @@ -1378,7 +1378,7 @@ checkPatBind :: SrcSpan -> [AddEpAnn] -> LPat GhcPs -> Located (GRHSs GhcPs (LHsExpr GhcPs)) - -> P (HsBind GhcPs) + -> P p (HsBind GhcPs) checkPatBind loc annsIn (L _ (BangPat (EpAnn _ ans cs) (L _ (VarPat _ v)))) (L _match_span grhss) = return (makeFunBind v (L (noAnnSrcSpan loc) @@ -1395,7 +1395,7 @@ checkPatBind loc annsIn lhs (L _ grhss) = do cs <- getCommentsFor loc return (PatBind (EpAnn (spanAsAnchor loc) annsIn cs) lhs grhss) -checkValSigLhs :: LHsExpr GhcPs -> P (LocatedN RdrName) +checkValSigLhs :: LHsExpr GhcPs -> P p (LocatedN RdrName) checkValSigLhs (L _ (HsVar _ lrdr@(L _ v))) | isUnqual v , not (isDataOcc (rdrNameOcc v)) @@ -1420,8 +1420,8 @@ checkDoAndIfThenElse err guardExpr semiThen thenExpr semiElse elseExpr | otherwise = return () isFunLhs :: LocatedA (PatBuilder GhcPs) - -> P (Maybe (LocatedN RdrName, LexicalFixity, - [LocatedA (PatBuilder GhcPs)],[AddEpAnn])) + -> P p (Maybe (LocatedN RdrName, LexicalFixity, + [LocatedA (PatBuilder GhcPs)],[AddEpAnn])) -- A variable binding is parsed as a FunBind. -- Just (fun, is_infix, arg_pats) if e is a function LHS isFunLhs e = go e [] [] [] @@ -2558,7 +2558,7 @@ pattern match on the pattern stored inside 'PatBuilderPat'. checkPrecP :: Located (SourceText,Int) -- ^ precedence -> Located (OrdList (LocatedN RdrName)) -- ^ operators - -> P () + -> P p () checkPrecP (L l (_,i)) (L _ ol) | 0 <= i, i <= maxPrecedence = pure () | all specialOp ol = pure () @@ -2694,7 +2694,7 @@ mkOpaquePragma src } checkNewOrData :: SrcSpan -> RdrName -> Bool -> NewOrData -> [LConDecl GhcPs] - -> P (DataDefnCons (LConDecl GhcPs)) + -> P p (DataDefnCons (LConDecl GhcPs)) checkNewOrData span name is_type_data = curry $ \ case (NewType, [a]) -> pure $ NewTypeCon a (DataType, as) -> pure $ DataTypeCons is_type_data (handle_type_data as) @@ -2723,7 +2723,7 @@ checkNewOrData span name is_type_data = curry $ \ case mkImport :: Located CCallConv -> Located Safety -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) - -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) + -> P p (EpAnn [AddEpAnn] -> HsDecl GhcPs) mkImport cconv safety (L loc (StringLiteral esrc entity _), v, ty) = case unLoc cconv of CCallConv -> returnSpec =<< mkCImport @@ -2833,7 +2833,7 @@ parseCImport cconv safety nm str sourceText = -- mkExport :: Located CCallConv -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) - -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) + -> P p (EpAnn [AddEpAnn] -> HsDecl GhcPs) mkExport (L lc cconv) (L le (StringLiteral esrc entity _), v, ty) = return $ \ann -> ForD noExtField $ ForeignExport { fd_e_ext = ann, fd_name = v, fd_sig_ty = ty @@ -2864,7 +2864,7 @@ data ImpExpQcSpec = ImpExpQcName (LocatedN RdrName) | ImpExpQcWildcard mkModuleImpExp :: Maybe (LWarningTxt GhcPs) -> [AddEpAnn] -> LocatedA ImpExpQcSpec - -> ImpExpSubSpec -> P (IE GhcPs) + -> ImpExpSubSpec -> P p (IE GhcPs) mkModuleImpExp warning anns (L l specname) subs = do cs <- getCommentsFor (locA l) -- AZ: IEVar can discard comments let ann = EpAnn (spanAsAnchor $ maybe (locA l) getLocA warning) anns cs @@ -2912,12 +2912,12 @@ mkModuleImpExp warning anns (L l specname) subs = do wrapped = map (fmap ieNameFromSpec) mkTypeImpExp :: LocatedN RdrName -- TcCls or Var name space - -> P (LocatedN RdrName) + -> P p (LocatedN RdrName) mkTypeImpExp name = do requireExplicitNamespaces (getLocA name) return (fmap (`setRdrNameSpace` tcClsName) name) -checkImportSpec :: LocatedL [LIE GhcPs] -> P (LocatedL [LIE GhcPs]) +checkImportSpec :: LocatedL [LIE GhcPs] -> P p (LocatedL [LIE GhcPs]) checkImportSpec ie@(L _ specs) = case [l | (L l (IEThingWith _ _ (IEWildcard _) _)) <- specs] of [] -> return ie @@ -2927,7 +2927,7 @@ checkImportSpec ie@(L _ specs) = addFatalError $ mkPlainErrorMsgEnvelope l PsErrIllegalImportBundleForm -- In the correct order -mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec) +mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P p ([AddEpAnn], ImpExpSubSpec) mkImpExpSubSpec [] = return ([], ImpExpList []) mkImpExpSubSpec [L la ImpExpQcWildcard] = return ([AddEpAnn AnnDotdot (la2e la)], ImpExpAll) @@ -2943,19 +2943,19 @@ isImpExpQcWildcard _ = False ----------------------------------------------------------------------------- -- Warnings and failures -warnPrepositiveQualifiedModule :: SrcSpan -> P () +warnPrepositiveQualifiedModule :: SrcSpan -> P p () warnPrepositiveQualifiedModule span = addPsMessage span PsWarnImportPreQualified -failNotEnabledImportQualifiedPost :: SrcSpan -> P () +failNotEnabledImportQualifiedPost :: SrcSpan -> P p () failNotEnabledImportQualifiedPost loc = addError $ mkPlainErrorMsgEnvelope loc $ PsErrImportPostQualified -failImportQualifiedTwice :: SrcSpan -> P () +failImportQualifiedTwice :: SrcSpan -> P p () failImportQualifiedTwice loc = addError $ mkPlainErrorMsgEnvelope loc $ PsErrImportQualifiedTwice -warnStarIsType :: SrcSpan -> P () +warnStarIsType :: SrcSpan -> P p () warnStarIsType span = addPsMessage span PsWarnStarIsType failOpFewArgs :: MonadP m => LocatedN RdrName -> m a @@ -3023,13 +3023,13 @@ instance Monad PV where PV_Ok acc' a -> unPV (f a) ctx acc' PV_Failed acc' -> PV_Failed acc' -runPV :: PV a -> P a +runPV :: PV a -> P p a runPV = runPV_details noParseContext askParseContext :: PV ParseContext askParseContext = PV $ \(PV_Context _ details) acc -> PV_Ok acc details -runPV_details :: ParseContext -> PV a -> P a +runPV_details :: ParseContext -> PV a -> P p a runPV_details details m = P $ \s -> let ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -180,7 +180,7 @@ we have to use 'flattenBindsAndSigs' to traverse it in the correct order. -- to a parsed HsModule. -- -- Reports badly positioned comments when -Winvalid-haddock is enabled. -addHaddockToModule :: Located (HsModule GhcPs) -> P (Located (HsModule GhcPs)) +addHaddockToModule :: Located (HsModule GhcPs) -> P p (Located (HsModule GhcPs)) addHaddockToModule lmod = do pState <- getPState let all_comments = toList (hdk_comments pState) @@ -192,7 +192,7 @@ addHaddockToModule lmod = do mapM_ reportHdkWarning hdk_warnings return lmod' -reportHdkWarning :: HdkWarn -> P () +reportHdkWarning :: HdkWarn -> P p () reportHdkWarning (HdkWarnInvalidComment (L l _)) = addPsMessage (mkSrcSpanPs l) PsWarnHaddockInvalidPos reportHdkWarning (HdkWarnExtraComment (L l _)) = ===================================== compiler/GHC/Parser/PreProcess.hs ===================================== @@ -8,13 +8,18 @@ module GHC.Parser.PreProcess ( -- ppLexerDbg, lexer, lexerDbg, + initPpState, + initParserState, + initPragState, ) where import Data.Char +import qualified Data.Map as Map import qualified Data.Set as Set import Debug.Trace (trace) import GHC.Data.FastString import qualified GHC.Data.Strict as Strict +import GHC.Data.StringBuffer import GHC.Parser.Errors.Ppr () import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), PpState (..), Token (..)) import qualified GHC.Parser.Lexer as Lexer @@ -23,7 +28,26 @@ import GHC.Types.SrcLoc -- --------------------------------------------------------------------- -lexer, lexerDbg :: Bool -> (Located Token -> P a) -> P a +-- | Set parser options for parsing OPTIONS pragmas +initPragState :: Lexer.ParserOpts -> StringBuffer -> RealSrcLoc -> PState PpState +initPragState = Lexer.initPragState initPpState + +-- | Creates a parse state from a 'ParserOpts' value +initParserState :: Lexer.ParserOpts -> StringBuffer -> RealSrcLoc -> PState PpState +initParserState = Lexer.initPragState initPpState + +initPpState :: PpState +initPpState = + PpState + { pp_defines = Map.empty + , pp_continuation = [] + , pp_context = [] + , pp_accepting = True + } + +-- --------------------------------------------------------------------- + +lexer, lexerDbg :: Bool -> (Located Token -> P PpState a) -> P PpState a -- bypass for now, work in ghci lexer = Lexer.lexer lexerDbg = Lexer.lexerDbg @@ -141,11 +165,11 @@ lexerDbg = Lexer.lexerDbg -- in -- POk s r -setAccepting :: Bool -> P () +setAccepting :: Bool -> P PpState () setAccepting on = P $ \s -> POk s{pp = (pp s){pp_accepting = on}} () -getAccepting :: P Bool +getAccepting :: P PpState Bool getAccepting = P $ \s -> POk s (pp_accepting (pp s)) -- pp_context stack end ------------------- ===================================== compiler/GHC/Parser/Utils.hs ===================================== @@ -50,9 +50,9 @@ isDecl pflags stmt = _ -> True Lexer.PFailed _ -> False -parseThing :: Lexer.P thing -> ParserOpts -> String -> Lexer.ParseResult thing +parseThing :: Lexer.P () thing -> ParserOpts -> String -> Lexer.ParseResult () thing parseThing parser opts stmt = do let buf = stringToStringBuffer stmt loc = mkRealSrcLoc (fsLit "") 1 1 - Lexer.unP parser (Lexer.initParserState opts buf loc) + Lexer.unP parser (Lexer.initParserState () opts buf loc) ===================================== ghc/GHCi/UI.hs ===================================== @@ -77,7 +77,8 @@ import GHC.Builtin.Names import GHC.Builtin.Types( stringTyCon_RDR ) import GHC.Types.Name.Reader as RdrName ( getGRE_NameQualifier_maybes, getRdrName ) import GHC.Types.SrcLoc as SrcLoc -import qualified GHC.Parser.Lexer as Lexer +import qualified GHC.Parser.Lexer as Lexer hiding (initParserState) +import qualified GHC.Parser.PreProcess as Lexer (initParserState) import GHC.Parser.Header ( toArgs ) import qualified GHC.Parser.Header as Header import GHC.Types.PkgQual ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 267207c66495388c76297f9bd3f57454c021b9a9 +Subproject commit fd39bed22d4ac1d5f691f65391df8628f5693848 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3bfb1fd64c49e246ea72df5d5b3b4e4b1d70758e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3bfb1fd64c49e246ea72df5d5b3b4e4b1d70758e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 3 22:17:10 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 03 Oct 2023 18:17:10 -0400 Subject: [Git][ghc/ghc][wip/az/ghc-cpp] Move PpState into PreProcess Message-ID: <651c92e69003e_343253d6f8e18268652@gitlab.mail> Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: 289fee54 by Alan Zimmerman at 2023-10-03T23:16:40+01:00 Move PpState into PreProcess And initParserState, initPragState too - - - - - 17 changed files: - compiler/GHC.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Parser.hs-boot - compiler/GHC/Parser.y - compiler/GHC/Parser/HaddockLex.x - compiler/GHC/Parser/Header.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Parser/PreProcess.hs - compiler/GHC/Parser/Utils.hs - ghc/GHCi/UI.hs - utils/check-cpp/Main.hs - utils/haddock Changes: ===================================== compiler/GHC.hs ===================================== @@ -333,7 +333,8 @@ import GHC.Runtime.Context import GHCi.RemoteTypes import qualified GHC.Parser as Parser -import GHC.Parser.Lexer +import GHC.Parser.Lexer hiding (initParserState) +import GHC.Parser.PreProcess (initParserState) import GHC.Parser.Annotation import GHC.Parser.Utils @@ -1627,7 +1628,7 @@ getTokenStream :: ModSummary -> IO [Located Token] getTokenStream mod = do (sourceFile, source, dflags) <- getModuleSourceAndFlags mod let startLoc = mkRealSrcLoc (mkFastString sourceFile) 1 1 - case lexTokenStream (initParserOpts dflags) source startLoc of + case lexTokenStream initPpState (initParserOpts dflags) source startLoc of POk _ ts -> return ts PFailed pst -> throwErrors (GhcPsMessage <$> getPsErrorMessages pst) @@ -1638,7 +1639,7 @@ getRichTokenStream :: ModSummary -> IO [(Located Token, String)] getRichTokenStream mod = do (sourceFile, source, dflags) <- getModuleSourceAndFlags mod let startLoc = mkRealSrcLoc (mkFastString sourceFile) 1 1 - case lexTokenStream (initParserOpts dflags) source startLoc of + case lexTokenStream initPpState (initParserOpts dflags) source startLoc of POk _ ts -> return $ addSourceToTokens startLoc source ts PFailed pst -> throwErrors (GhcPsMessage <$> getPsErrorMessages pst) ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1576,7 +1576,7 @@ parseCmmFile cmmpConfig this_mod home_unit filename = do buf <- hGetStringBuffer filename let init_loc = mkRealSrcLoc (mkFastString filename) 1 1 - init_state = (initParserState (cmmpParserOpts cmmpConfig) buf init_loc) { lex_state = [0] } + init_state = (initParserState () (cmmpParserOpts cmmpConfig) buf init_loc) { lex_state = [0] } -- reset the lex_state: the Lexer monad leaves some stuff -- in there we don't want. pdConfig = cmmpPDConfig cmmpConfig ===================================== compiler/GHC/Cmm/Parser/Monad.hs ===================================== @@ -34,7 +34,7 @@ import GHC.Types.SrcLoc import GHC.Unit.Types import GHC.Unit.Home -newtype PD a = PD { unPD :: PDConfig -> HomeUnit -> PState -> ParseResult a } +newtype PD a = PD { unPD :: PDConfig -> HomeUnit -> PState () -> ParseResult () a } instance Functor PD where fmap = liftM @@ -46,7 +46,7 @@ instance Applicative PD where instance Monad PD where (>>=) = thenPD -liftP :: P a -> PD a +liftP :: P () a -> PD a liftP (P f) = PD $ \_ _ s -> f s failMsgPD :: (SrcSpan -> MsgEnvelope PsMessage) -> PD a ===================================== compiler/GHC/Driver/Backpack.hs ===================================== @@ -37,7 +37,8 @@ import GHC.Driver.Errors.Types import GHC.Parser import GHC.Parser.Header -import GHC.Parser.Lexer +import GHC.Parser.Lexer hiding (initParserState) +import GHC.Parser.PreProcess (initParserState) import GHC.Parser.Annotation import GHC.Rename.Names ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -193,7 +193,8 @@ import GHC.CoreToStg ( coreToStg ) import GHC.Parser.Errors.Types import GHC.Parser -import GHC.Parser.Lexer as Lexer +import GHC.Parser.Lexer as Lexer hiding (initPpState, initParserState) +import GHC.Parser.PreProcess (initParserState) import GHC.Tc.Module import GHC.Tc.Utils.Monad @@ -2468,11 +2469,11 @@ hscParseIdentifier hsc_env str = runInteractiveHsc hsc_env $ hscParseThing parseIdentifier str hscParseThing :: (Outputable thing, Data thing) - => Lexer.P thing -> String -> Hsc thing + => Lexer.P PpState thing -> String -> Hsc thing hscParseThing = hscParseThingWithLocation "" 1 hscParseThingWithLocation :: (Outputable thing, Data thing) => String -> Int - -> Lexer.P thing -> String -> Hsc thing + -> Lexer.P PpState thing -> String -> Hsc thing hscParseThingWithLocation source linenumber parser str = do dflags <- getDynFlags logger <- getLogger ===================================== compiler/GHC/Parser.hs-boot ===================================== @@ -4,4 +4,4 @@ import GHC.Types.Name.Reader (RdrName) import GHC.Parser.Lexer (P) import GHC.Parser.Annotation (LocatedN) -parseIdentifier :: P (LocatedN RdrName) +parseIdentifier :: P p (LocatedN RdrName) ===================================== compiler/GHC/Parser.y ===================================== @@ -83,8 +83,9 @@ import GHC.Core.DataCon ( DataCon, dataConName ) import GHC.Parser.PostProcess import GHC.Parser.PostProcess.Haddock -import GHC.Parser.Lexer hiding (lexer, lexerDbg) -import GHC.Parser.PreProcess +-- import GHC.Parser.Lexer hiding (lexer, lexerDbg) +import GHC.Parser.Lexer +import GHC.Parser.PreProcess hiding (lexer, lexerDbg) import GHC.Parser.HaddockLex import GHC.Parser.Annotation import GHC.Parser.Errors.Types @@ -756,7 +757,7 @@ TH_QQUASIQUOTE { L _ (ITqQuasiQuote _) } -- '#else' { L _ ITcppElse } -- '#endif' { L _ ITcppEndif } -%monad { P } { >>= } { return } +%monad { P p } { >>= } { return } %lexer { (lexer True) } { L _ ITeof } -- %lexer { (lexerDbg True) } { L _ ITeof } -- Replace 'lexer' above with 'lexerDbg' @@ -3986,7 +3987,7 @@ bars :: { ([SrcSpan],Int) } -- One or more bars | '|' { ([gl $1],1) } { -happyError :: P a +happyError :: P p a happyError = srcParseFail getVARID (L _ (ITvarid x)) = x @@ -4088,7 +4089,7 @@ hasE (L _ (ITopenExpQuote HasE _)) = True hasE (L _ (ITopenTExpQuote HasE)) = True hasE _ = False -getSCC :: Located Token -> P FastString +getSCC :: Located Token -> P p FastString getSCC lt = do let s = getSTRING lt -- We probably actually want to be more restrictive than this if ' ' `elem` unpackFS s @@ -4192,7 +4193,7 @@ incorrect. -- Make a source location for the file. We're a bit lazy here and just -- make a point SrcSpan at line 1, column 0. Strictly speaking we should -- try to find the span of the whole file (ToDo). -fileSrcSpan :: P SrcSpan +fileSrcSpan :: P p SrcSpan fileSrcSpan = do l <- getRealSrcLoc; let loc = mkSrcLoc (srcLocFile l) 1 1; @@ -4218,13 +4219,13 @@ looksLikeMult ty1 l_op ty2 | otherwise = False -- Hint about the MultiWayIf extension -hintMultiWayIf :: SrcSpan -> P () +hintMultiWayIf :: SrcSpan -> P p () hintMultiWayIf span = do mwiEnabled <- getBit MultiWayIfBit unless mwiEnabled $ addError $ mkPlainErrorMsgEnvelope span PsErrMultiWayIf -- Hint about explicit-forall -hintExplicitForall :: Located Token -> P () +hintExplicitForall :: Located Token -> P p () hintExplicitForall tok = do forall <- getBit ExplicitForallBit rulePrag <- getBit InRulePragBit @@ -4232,7 +4233,7 @@ hintExplicitForall tok = do (PsErrExplicitForall (isUnicode tok)) -- Hint about qualified-do -hintQualifiedDo :: Located Token -> P () +hintQualifiedDo :: Located Token -> P p () hintQualifiedDo tok = do qualifiedDo <- getBit QualifiedDoBit case maybeQDoDoc of @@ -4249,7 +4250,7 @@ hintQualifiedDo tok = do -- When two single quotes don't followed by tyvar or gtycon, we report the -- error as empty character literal, or TH quote that missing proper type -- variable or constructor. See #13450. -reportEmptyDoubleQuotes :: SrcSpan -> P a +reportEmptyDoubleQuotes :: SrcSpan -> P p a reportEmptyDoubleQuotes span = do thQuotes <- getBit ThQuotesBit addFatalError $ mkPlainErrorMsgEnvelope span $ PsErrEmptyDoubleQuotes thQuotes @@ -4343,7 +4344,7 @@ acs a = do return (a cs) -- Called at the very end to pick up the EOF position, as well as any comments not allocated yet. -acsFinal :: (EpAnnComments -> Maybe (RealSrcSpan, RealSrcSpan) -> Located a) -> P (Located a) +acsFinal :: (EpAnnComments -> Maybe (RealSrcSpan, RealSrcSpan) -> Located a) -> P p (Located a) acsFinal a = do let (L l _) = a emptyComments Nothing cs <- getCommentsFor l @@ -4364,7 +4365,7 @@ acsa a = do acsA :: MonadP m => (EpAnnComments -> Located a) -> m (LocatedAn t a) acsA a = reLocA <$> acs a -acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P ECP +acsExpr :: (EpAnnComments -> LHsExpr GhcPs) -> P p ECP acsExpr a = do { expr :: (LHsExpr GhcPs) <- runPV $ acsa a ; return (ecpFromExp $ expr) } @@ -4440,7 +4441,7 @@ pvL a = do { av <- a -- This and the signature module parser are the only parser entry points that -- deal with Haddock comments. The other entry points ('parseDeclaration', -- 'parseExpression', etc) do not insert them into the AST. -parseModule :: P (Located (HsModule GhcPs)) +parseModule :: P p (Located (HsModule GhcPs)) parseModule = parseModuleNoHaddock >>= addHaddockToModule -- | Parse a Haskell signature module with Haddock comments. This is done in two @@ -4452,7 +4453,7 @@ parseModule = parseModuleNoHaddock >>= addHaddockToModule -- This and the module parser are the only parser entry points that deal with -- Haddock comments. The other entry points ('parseDeclaration', -- 'parseExpression', etc) do not insert them into the AST. -parseSignature :: P (Located (HsModule GhcPs)) +parseSignature :: P p (Located (HsModule GhcPs)) parseSignature = parseSignatureNoHaddock >>= addHaddockToModule commentsA :: (Monoid ann) => SrcSpan -> EpAnnComments -> SrcSpanAnn' (EpAnn ann) @@ -4461,7 +4462,7 @@ commentsA loc cs = SrcSpanAnn (EpAnn (Anchor (rs loc) UnchangedAnchor) mempty cs -- | Instead of getting the *enclosed* comments, this includes the -- *preceding* ones. It is used at the top level to get comments -- between top level declarations. -commentsPA :: (Monoid ann) => LocatedAn ann a -> P (LocatedAn ann a) +commentsPA :: (Monoid ann) => LocatedAn ann a -> P p (LocatedAn ann a) commentsPA la@(L l a) = do cs <- getPriorCommentsFor (getLocA la) return (L (addCommentsToSrcAnn l cs) a) ===================================== compiler/GHC/Parser/HaddockLex.x ===================================== @@ -132,7 +132,7 @@ advanceSrcLocBS !loc bs = case utf8UnconsByteString bs of Just (c, bs') -> advanceSrcLocBS (advanceSrcLoc loc c) bs' -- | Lex 'StringLiteral' for warning messages -lexStringLiteral :: P (LocatedN RdrName) -- ^ A precise identifier parser +lexStringLiteral :: P () (LocatedN RdrName) -- ^ A precise identifier parser -> Located StringLiteral -> Located (WithHsDocIdentifiers StringLiteral GhcPs) lexStringLiteral identParser (L l sl@(StringLiteral _ fs _)) @@ -150,7 +150,7 @@ lexStringLiteral identParser (L l sl@(StringLiteral _ fs _)) fakeLoc = mkRealSrcLoc nilFS 0 0 -- | Lex identifiers from a docstring. -lexHsDoc :: P (LocatedN RdrName) -- ^ A precise identifier parser +lexHsDoc :: P () (LocatedN RdrName) -- ^ A precise identifier parser -> HsDocString -> HsDoc GhcPs lexHsDoc identParser doc = @@ -170,7 +170,7 @@ lexHsDoc identParser doc = fakeLoc = mkRealSrcLoc nilFS 0 0 -validateIdentWith :: P (LocatedN RdrName) -> SrcSpan -> ByteString -> Maybe (Located RdrName) +validateIdentWith :: P () (LocatedN RdrName) -> SrcSpan -> ByteString -> Maybe (Located RdrName) validateIdentWith identParser mloc str0 = let -- These ParserFlags should be as "inclusive" as possible, allowing -- identifiers defined with any language extension. @@ -184,7 +184,7 @@ validateIdentWith identParser mloc str0 = realSrcLc = case mloc of RealSrcSpan loc _ -> realSrcSpanStart loc UnhelpfulSpan _ -> mkRealSrcLoc nilFS 0 0 - pstate = initParserState pflags buffer realSrcLc + pstate = initParserState () pflags buffer realSrcLc in case unP identParser pstate of POk _ name -> Just $ case mloc of RealSrcSpan _ _ -> reLoc name ===================================== compiler/GHC/Parser/Header.hs ===================================== @@ -28,7 +28,8 @@ import GHC.Driver.Errors.Types -- Unfortunate, needed due to the fact we throw e import GHC.Parser.Errors.Types import GHC.Parser ( parseHeader ) -import GHC.Parser.Lexer +import GHC.Parser.Lexer hiding (initPragState, initParserState) +import GHC.Parser.PreProcess (initPragState, initParserState) import GHC.Hs import GHC.Unit.Module @@ -200,7 +201,7 @@ lazyGetToks popts filename handle = do where loc = mkRealSrcLoc (mkFastString filename) 1 1 - lazyLexBuf :: Handle -> PState -> Bool -> Int -> IO [Located Token] + lazyLexBuf :: Handle -> PState p -> Bool -> Int -> IO [Located Token] lazyLexBuf handle state eof size = case unP (lexer False return) state of POk state' t -> do @@ -218,7 +219,7 @@ lazyGetToks popts filename handle = do | otherwise -> return [L (mkSrcSpanPs (last_loc state)) ITeof] -- parser assumes an ITeof sentinel at the end - getMore :: Handle -> PState -> Int -> IO [Located Token] + getMore :: Handle -> PState p -> Int -> IO [Located Token] getMore handle state size = do -- pprTrace "getMore" (text (show (buffer state))) (return ()) let new_size = size * 2 ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1234,56 +1234,56 @@ reservedSymsFM = listToUFM $ -- ----------------------------------------------------------------------------- -- Lexer actions -type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) +type Action p = PsSpan -> StringBuffer -> Int -> StringBuffer -> P p (PsLocated Token) -special :: Token -> Action +special :: Token -> Action p special tok span _buf _len _buf2 = return (L span tok) -token, layout_token :: Token -> Action +token, layout_token :: Token -> Action p token t span _buf _len _buf2 = return (L span t) layout_token t span _buf _len _buf2 = pushLexState layout >> return (L span t) -idtoken :: (StringBuffer -> Int -> Token) -> Action +idtoken :: (StringBuffer -> Int -> Token) -> Action p idtoken f span buf len _buf2 = return (L span $! (f buf len)) -qdo_token :: (Maybe FastString -> Token) -> Action +qdo_token :: (Maybe FastString -> Token) -> Action p qdo_token con span buf len _buf2 = do maybe_layout token return (L span $! token) where !token = con $! Just $! fst $! splitQualName buf len False -skip_one_varid :: (FastString -> Token) -> Action +skip_one_varid :: (FastString -> Token) -> Action p skip_one_varid f span buf len _buf2 = return (L span $! f (lexemeToFastString (stepOn buf) (len-1))) -skip_one_varid_src :: (SourceText -> FastString -> Token) -> Action +skip_one_varid_src :: (SourceText -> FastString -> Token) -> Action p skip_one_varid_src f span buf len _buf2 = return (L span $! f (SourceText $ lexemeToFastString (stepOn buf) (len-1)) (lexemeToFastString (stepOn buf) (len-1))) -skip_two_varid :: (FastString -> Token) -> Action +skip_two_varid :: (FastString -> Token) -> Action p skip_two_varid f span buf len _buf2 = return (L span $! f (lexemeToFastString (stepOn (stepOn buf)) (len-2))) -strtoken :: (String -> Token) -> Action +strtoken :: (String -> Token) -> Action p strtoken f span buf len _buf2 = return (L span $! (f $! lexemeToString buf len)) -fstrtoken :: (FastString -> Token) -> Action +fstrtoken :: (FastString -> Token) -> Action p fstrtoken f span buf len _buf2 = return (L span $! (f $! lexemeToFastString buf len)) -begin :: Int -> Action +begin :: Int -> Action p begin code _span _str _len _buf2 = do pushLexState code; lexToken -pop :: Action +pop :: Action p pop _span _buf _len _buf2 = do _ <- popLexState lexToken -- trace "pop" $ do lexToken -cppToken :: Int -> Action +cppToken :: Int -> Action p cppToken code span buf len _buf2 = do let tokStr = lexemeToFastString buf len @@ -1297,7 +1297,7 @@ cppToken code span buf len _buf2 = return (L span (ITcpp continue $! lexemeToFastString buf len0)) -- trace ("cppToken:" ++ show (code, t)) $ do return (L span t) -cppTokenCont :: (FastString -> Token)-> Action +cppTokenCont :: (FastString -> Token)-> Action p cppTokenCont code span buf len _buf2 = do let tokStr = lexemeToFastString buf len @@ -1309,34 +1309,34 @@ cppTokenCont code span buf len _buf2 = _ -> return (len, False) return (L span (ITcpp continue $! lexemeToFastString buf len0)) -cppTokenPop :: (FastString -> Token)-> Action +cppTokenPop :: (FastString -> Token)-> Action p cppTokenPop t span buf len _buf2 = do _ <- popLexState -- return (L span (t $! lexemeToFastString buf (len - 1))) return (L span (t $! lexemeToFastString buf (trace "cppTokenPop" len))) -popCpp :: Action +popCpp :: Action p popCpp _span _buf _len _buf2 = do _ <- popLexState -- lexToken trace "pop" $ do lexToken -- See Note [Nested comment line pragmas] -failLinePrag1 :: Action +failLinePrag1 :: Action p failLinePrag1 span _buf _len _buf2 = do b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else lexError LexErrorInPragma -- See Note [Nested comment line pragmas] -popLinePrag1 :: Action +popLinePrag1 :: Action p popLinePrag1 span _buf _len _buf2 = do b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else do _ <- popLexState lexToken -hopefully_open_brace :: Action +hopefully_open_brace :: Action p hopefully_open_brace span buf len buf2 = do relaxed <- getBit RelaxedLayoutBit ctx <- getContext @@ -1350,7 +1350,7 @@ hopefully_open_brace span buf len buf2 else addFatalError $ mkPlainErrorMsgEnvelope (mkSrcSpanPs span) PsErrMissingBlock -pop_and :: Action -> Action +pop_and :: Action p -> Action p pop_and act span buf len buf2 = do _ <- popLexState act span buf len buf2 @@ -1400,7 +1400,7 @@ get_op_ws buf1 buf2 = mk_op_ws False False = OpWsLooseInfix {-# INLINE with_op_ws #-} -with_op_ws :: (OpWs -> Action) -> Action +with_op_ws :: (OpWs -> Action p) -> Action p with_op_ws act span buf len buf2 = act (get_op_ws buf buf2) span buf len buf2 {-# INLINE nextCharIs #-} @@ -1501,7 +1501,7 @@ alexNotPred p userState in1 len in2 alexOrPred p1 p2 userState in1 len in2 = p1 userState in1 len in2 || p2 userState in1 len in2 -multiline_doc_comment :: Action +multiline_doc_comment :: Action p multiline_doc_comment span buf _len _buf2 = {-# SCC "multiline_doc_comment" #-} withLexedDocType worker where worker input@(AI start_loc _) docType checkNextLine = go start_loc "" [] input @@ -1547,7 +1547,7 @@ multiline_doc_comment span buf _len _buf2 = {-# SCC "multiline_doc_comment" #-} | otherwise -> input Nothing -> input -lineCommentToken :: Action +lineCommentToken :: Action p lineCommentToken span buf len buf2 = do b <- getBit RawTokenStreamBit if b then do @@ -1560,7 +1560,7 @@ lineCommentToken span buf len buf2 = do nested comments require traversing by hand, they can't be parsed using regular expressions. -} -nested_comment :: Action +nested_comment :: Action p nested_comment span buf len _buf2 = {-# SCC "nested_comment" #-} do l <- getLastLocIncludingComments let endComment input (L _ comment) = commentEnd lexToken input (Nothing, ITblockComment comment l) buf span @@ -1569,7 +1569,7 @@ nested_comment span buf len _buf2 = {-# SCC "nested_comment" #-} do let start_decorator = reverse $ lexemeToString buf len nested_comment_logic endComment start_decorator input span -nested_doc_comment :: Action +nested_doc_comment :: Action p nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLexedDocType worker where worker input docType _checkNextLine = nested_comment_logic endComment "" input span @@ -1585,11 +1585,11 @@ nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLe -- | Includes the trailing '-}' decorators -- drop the last two elements with the callback if you don't want them to be included nested_comment_logic - :: (AlexInput -> Located String -> P (PsLocated Token)) -- ^ Continuation that gets the rest of the input and the lexed comment + :: (AlexInput -> Located String -> P p (PsLocated Token)) -- ^ Continuation that gets the rest of the input and the lexed comment -> String -- ^ starting value for accumulator (reversed) - When we want to include a decorator '{-' in the comment -> AlexInput -> PsSpan - -> P (PsLocated Token) + -> P p (PsLocated Token) nested_comment_logic endComment commentAcc input span = go commentAcc (1::Int) input where go commentAcc 0 input@(AI end_loc _) = do @@ -1623,13 +1623,13 @@ nested_comment_logic endComment commentAcc input span = go commentAcc (1::Int) i Just (_,_) -> go ('\n':commentAcc) n input (_, Just (c,input)) -> go (c:commentAcc) n input -ghcCppSet :: P Bool +ghcCppSet :: P p Bool ghcCppSet = do exts <- getExts return $ xtest GhcCppBit exts -- See Note [Nested comment line pragmas] -parseNestedPragma :: AlexInput -> P (String,AlexInput) +parseNestedPragma :: AlexInput -> P p (String,AlexInput) parseNestedPragma input@(AI _ buf) = do origInput <- getInput setInput input @@ -1675,8 +1675,8 @@ See #314 for more background on the bug this fixes. -} {-# INLINE withLexedDocType #-} -withLexedDocType :: (AlexInput -> ((HsDocStringDecorator -> HsDocString) -> (HdkComment, Token)) -> Bool -> P (PsLocated Token)) - -> P (PsLocated Token) +withLexedDocType :: (AlexInput -> ((HsDocStringDecorator -> HsDocString) -> (HdkComment, Token)) -> Bool -> P p (PsLocated Token)) + -> P p (PsLocated Token) withLexedDocType lexDocComment = do input@(AI _ buf) <- getInput l <- getLastLocIncludingComments @@ -1721,7 +1721,7 @@ mkHdkCommentSection loc n mkDS = (HdkCommentSection n ds, ITdocComment ds loc) -- RULES pragmas turn on the forall and '.' keywords, and we turn them -- off again at the end of the pragma. -rulePrag :: Action +rulePrag :: Action p rulePrag span buf len _buf2 = do setExts (.|. xbit InRulePragBit) let !src = lexemeToFastString buf len @@ -1729,7 +1729,7 @@ rulePrag span buf len _buf2 = do -- When 'UsePosPragsBit' is not set, it is expected that we emit a token instead -- of updating the position in 'PState' -linePrag :: Action +linePrag :: Action p linePrag span buf len buf2 = do usePosPrags <- getBit UsePosPragsBit if usePosPrags @@ -1739,7 +1739,7 @@ linePrag span buf len buf2 = do -- When 'UsePosPragsBit' is not set, it is expected that we emit a token instead -- of updating the position in 'PState' -columnPrag :: Action +columnPrag :: Action p columnPrag span buf len buf2 = do usePosPrags <- getBit UsePosPragsBit if usePosPrags @@ -1747,7 +1747,7 @@ columnPrag span buf len buf2 = do else let !src = lexemeToFastString buf len in return (L span (ITcolumn_prag (SourceText src))) -endPrag :: Action +endPrag :: Action p endPrag span _buf _len _buf2 = do setExts (.&. complement (xbit InRulePragBit)) return (L span ITclose_prag) @@ -1761,12 +1761,12 @@ endPrag span _buf _len _buf2 = do -- called afterwards, so it can just update the state. {-# INLINE commentEnd #-} -commentEnd :: P (PsLocated Token) +commentEnd :: P p (PsLocated Token) -> AlexInput -> (Maybe HdkComment, Token) -> StringBuffer -> PsSpan - -> P (PsLocated Token) + -> P p (PsLocated Token) commentEnd cont input (m_hdk_comment, hdk_token) buf span = do setInput input let (AI loc nextBuf) = input @@ -1781,17 +1781,17 @@ commentEnd cont input (m_hdk_comment, hdk_token) buf span = do {-# INLINE docCommentEnd #-} docCommentEnd :: AlexInput -> (HdkComment, Token) -> StringBuffer -> - PsSpan -> P (PsLocated Token) + PsSpan -> P p (PsLocated Token) docCommentEnd input (hdk_comment, tok) buf span = commentEnd lexToken input (Just hdk_comment, tok) buf span -errBrace :: AlexInput -> RealSrcSpan -> P a +errBrace :: AlexInput -> RealSrcSpan -> P p a errBrace (AI end _) span = failLocMsgP (realSrcSpanStart span) (psRealLoc end) (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc (PsErrLexer LexUnterminatedComment LexErrKind_EOF)) -open_brace, close_brace :: Action +open_brace, close_brace :: Action p open_brace span _str _len _buf2 = do ctx <- getContext setContext (NoLayout:ctx) @@ -1838,7 +1838,7 @@ splitQualName orig_buf len parens = split orig_buf orig_buf where qual_size = orig_buf `byteDiff` dot_buf -varid :: Action +varid :: Action p varid span buf len _buf2 = case lookupUFM reservedWordsFM fs of Just (ITcase, _) -> do @@ -1885,7 +1885,7 @@ qvarsym buf len = ITqvarsym $! splitQualName buf len False qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] -varsym :: OpWs -> Action +varsym :: OpWs -> Action p varsym opws at OpWsPrefix = sym $ \span exts s -> let warnExtConflict errtok = do { addPsMessage (mkSrcSpanPs span) (PsWarnOperatorWhitespaceExtConflict errtok) @@ -1935,12 +1935,12 @@ varsym OpWsLooseInfix = sym $ \_ _ s -> | otherwise -> return $ ITvarsym s -consym :: OpWs -> Action +consym :: OpWs -> Action p consym opws = sym $ \span _exts s -> do { warnOperatorWhitespace opws span s ; return (ITconsym s) } -warnOperatorWhitespace :: OpWs -> PsSpan -> FastString -> P () +warnOperatorWhitespace :: OpWs -> PsSpan -> FastString -> P p () warnOperatorWhitespace opws span s = whenIsJust (check_unusual_opws opws) $ \opws' -> addPsMessage @@ -1957,7 +1957,7 @@ check_unusual_opws opws = OpWsTightInfix -> Just OperatorWhitespaceOccurrence_TightInfix OpWsLooseInfix -> Nothing -sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P p Token) -> Action p sym con span buf len _buf2 = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1988,7 +1988,7 @@ tok_integral :: (SourceText -> Integer -> Token) -> (Integer -> Integer) -> Int -> Int -> (Integer, (Char -> Int)) - -> Action + -> Action p tok_integral itint transint transbuf translen (radix,char_to_int) span buf len _buf2 = do numericUnderscores <- getBit NumericUnderscoresBit -- #14473 let src = lexemeToFastString buf len @@ -2002,7 +2002,7 @@ tok_integral itint transint transbuf translen (radix,char_to_int) span buf len _ tok_num :: (Integer -> Integer) -> Int -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_num = tok_integral $ \case st@(SourceText (unconsFS -> Just ('-',_))) -> itint st (const True) st@(SourceText _) -> itint st (const False) @@ -2013,12 +2013,12 @@ tok_num = tok_integral $ \case tok_primint :: (Integer -> Integer) -> Int -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_primint = tok_integral ITprimint tok_primword :: Int -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_primword = tok_integral ITprimword positive positive, negative :: (Integer -> Integer) positive = id @@ -2035,13 +2035,13 @@ tok_primintX :: (SourceText -> Integer -> Token) -> Int -> (Integer -> Integer) -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_primintX itint addlen transint transbuf = tok_integral itint transint transbuf (transbuf+addlen) tok_primint8, tok_primint16, tok_primint32, tok_primint64 :: (Integer -> Integer) - -> Int -> (Integer, (Char->Int)) -> Action + -> Int -> (Integer, (Char->Int)) -> Action p tok_primint8 = tok_primintX ITprimint8 5 tok_primint16 = tok_primintX ITprimint16 6 tok_primint32 = tok_primintX ITprimint32 6 @@ -2052,19 +2052,19 @@ tok_primint64 = tok_primintX ITprimint64 6 tok_primwordX :: (SourceText -> Integer -> Token) -> Int -> Int - -> (Integer, (Char->Int)) -> Action + -> (Integer, (Char->Int)) -> Action p tok_primwordX itint addlen transbuf = tok_integral itint positive transbuf (transbuf+addlen) tok_primword8, tok_primword16, tok_primword32, tok_primword64 - :: Int -> (Integer, (Char->Int)) -> Action + :: Int -> (Integer, (Char->Int)) -> Action p tok_primword8 = tok_primwordX ITprimword8 6 tok_primword16 = tok_primwordX ITprimword16 7 tok_primword32 = tok_primwordX ITprimword32 7 tok_primword64 = tok_primwordX ITprimword64 7 -- readSignificandExponentPair can understand negative rationals, exponents, everything. -tok_frac :: Int -> (String -> Token) -> Action +tok_frac :: Int -> (String -> Token) -> Action p tok_frac drop f span buf len _buf2 = do numericUnderscores <- getBit NumericUnderscoresBit -- #14473 let src = lexemeToString buf (len-drop) @@ -2099,7 +2099,7 @@ readFractionalLitX readStr b str = -- Layout processing -- we're at the first token on a line, insert layout tokens if necessary -do_bol :: Action +do_bol :: Action p do_bol span _str _len _buf2 = do -- See Note [Nested comment line pragmas] b <- getBit InNestedCommentBit @@ -2121,7 +2121,7 @@ do_bol span _str _len _buf2 = do -- certain keywords put us in the "layout" state, where we might -- add an opening curly brace. -maybe_layout :: Token -> P () +maybe_layout :: Token -> P p () maybe_layout t = do -- If the alternative layout rule is enabled then -- we never create an implicit layout context here. -- Layout is handled XXX instead. @@ -2150,7 +2150,7 @@ maybe_layout t = do -- If the alternative layout rule is enabled then -- We are slightly more lenient than this: when the new context is started -- by a 'do', then we allow the new context to be at the same indentation as -- the previous context. This is what the 'strict' argument is for. -new_layout_context :: Bool -> Bool -> Token -> Action +new_layout_context :: Bool -> Bool -> Token -> Action p new_layout_context strict gen_semic tok span _buf len _buf2 = do _ <- popLexState (AI l _) <- getInput @@ -2169,7 +2169,7 @@ new_layout_context strict gen_semic tok span _buf len _buf2 = do _ -> do setContext (Layout offset gen_semic : ctx) return (L span tok) -do_layout_left :: Action +do_layout_left :: Action p do_layout_left span _buf _len _buf2 = do _ <- popLexState pushLexState bol -- we must be at the start of a line @@ -2178,7 +2178,7 @@ do_layout_left span _buf _len _buf2 = do -- ----------------------------------------------------------------------------- -- LINE pragmas -setLineAndFile :: Int -> Action +setLineAndFile :: Int -> Action p setLineAndFile code (PsSpan span _) buf len _buf2 = do let src = lexemeToString buf (len - 1) -- drop trailing quotation mark linenumLen = length $ head $ words src @@ -2205,7 +2205,7 @@ setLineAndFile code (PsSpan span _) buf len _buf2 = do pushLexState code lexToken -setColumn :: Action +setColumn :: Action p setColumn (PsSpan span _) buf len _buf2 = do let column = case reads (lexemeToString buf len) of @@ -2226,12 +2226,12 @@ alrInitialLoc file = mkRealSrcSpan loc loc -- Options, includes and language pragmas. -lex_string_prag :: (String -> Token) -> Action +lex_string_prag :: (String -> Token) -> Action p lex_string_prag mkTok = lex_string_prag_comment mkTok' where mkTok' s _ = mkTok s -lex_string_prag_comment :: (String -> PsSpan -> Token) -> Action +lex_string_prag_comment :: (String -> PsSpan -> Token) -> Action p lex_string_prag_comment mkTok span _buf _len _buf2 = do input <- getInput start <- getParsedLoc @@ -2260,7 +2260,7 @@ lex_string_prag_comment mkTok span _buf _len _buf2 -- This stuff is horrible. I hates it. -lex_string_tok :: Action +lex_string_tok :: Action p lex_string_tok span buf _len _buf2 = do lexed <- lex_string (AI end bufEnd) <- getInput @@ -2272,7 +2272,7 @@ lex_string_tok span buf _len _buf2 = do return $ L (mkPsSpan (psSpanStart span) end) tok -lex_quoted_label :: Action +lex_quoted_label :: Action p lex_quoted_label span buf _len _buf2 = do start <- getInput s <- lex_string_helper "" start @@ -2287,7 +2287,7 @@ lex_quoted_label span buf _len _buf2 = do data LexedString = LexedRegularString String | LexedPrimString String -lex_string :: P LexedString +lex_string :: P p LexedString lex_string = do start <- getInput s <- lex_string_helper "" start @@ -2310,7 +2310,7 @@ lex_string = do return $ LexedRegularString s -lex_string_helper :: String -> AlexInput -> P String +lex_string_helper :: String -> AlexInput -> P p String lex_string_helper s start = do i <- getInput case alexGetChar' i of @@ -2345,7 +2345,7 @@ lex_string_helper s start = do _other -> lit_error i -lex_stringgap :: String -> AlexInput -> P String +lex_stringgap :: String -> AlexInput -> P p String lex_stringgap s start = do i <- getInput c <- getCharOrFail i @@ -2356,7 +2356,7 @@ lex_stringgap s start = do _other -> lit_error i -lex_char_tok :: Action +lex_char_tok :: Action p -- Here we are basically parsing character literals, such as 'x' or '\n' -- but we additionally spot 'x and ''T, returning ITsimpleQuote and -- ITtyQuote respectively, but WITHOUT CONSUMING the x or T part @@ -2399,7 +2399,7 @@ lex_char_tok span buf _len _buf2 = do -- We've seen ' let (AI end _) = i1 return (L (mkPsSpan loc end) ITsimpleQuote) -finish_char_tok :: StringBuffer -> PsLoc -> Char -> P (PsLocated Token) +finish_char_tok :: StringBuffer -> PsLoc -> Char -> P p (PsLocated Token) finish_char_tok buf loc ch -- We've already seen the closing quote -- Just need to check for trailing # = do magicHash <- getBit MagicHashBit @@ -2423,7 +2423,7 @@ isAny :: Char -> Bool isAny c | c > '\x7f' = isPrint c | otherwise = is_any c -lex_escape :: P Char +lex_escape :: P p Char lex_escape = do i0@(AI loc _) <- getInput c <- getCharOrFail i0 @@ -2472,7 +2472,7 @@ lex_escape = do return escape_char [] -> lit_error i0 -readNum :: (Char -> Bool) -> Int -> (Char -> Int) -> P Char +readNum :: (Char -> Bool) -> Int -> (Char -> Int) -> P p Char readNum is_digit base conv = do i <- getInput c <- getCharOrFail i @@ -2480,7 +2480,7 @@ readNum is_digit base conv = do then readNum2 is_digit base conv (conv c) else lit_error i -readNum2 :: (Char -> Bool) -> Int -> (Char -> Int) -> Int -> P Char +readNum2 :: (Char -> Bool) -> Int -> (Char -> Int) -> Int -> P p Char readNum2 is_digit base conv i = do input <- getInput read i input @@ -2537,10 +2537,10 @@ silly_escape_chars = [ -- the position of the error in the buffer. This is so that we can report -- a correct location to the user, but also so we can detect UTF-8 decoding -- errors if they occur. -lit_error :: AlexInput -> P a +lit_error :: AlexInput -> P p a lit_error i = do setInput i; lexError LexStringCharLit -getCharOrFail :: AlexInput -> P Char +getCharOrFail :: AlexInput -> P p Char getCharOrFail i = do case alexGetChar' i of Nothing -> lexError LexStringCharLitEOF @@ -2549,7 +2549,7 @@ getCharOrFail i = do -- ----------------------------------------------------------------------------- -- QuasiQuote -lex_qquasiquote_tok :: Action +lex_qquasiquote_tok :: Action p lex_qquasiquote_tok span buf len _buf2 = do let (qual, quoter) = splitQualName (stepOn buf) (len - 2) False quoteStart <- getParsedLoc @@ -2561,7 +2561,7 @@ lex_qquasiquote_tok span buf len _buf2 = do mkFastString (reverse quote), mkPsSpan quoteStart end))) -lex_quasiquote_tok :: Action +lex_quasiquote_tok :: Action p lex_quasiquote_tok span buf len _buf2 = do let quoter = tail (lexemeToString buf (len - 1)) -- 'tail' drops the initial '[', @@ -2574,7 +2574,7 @@ lex_quasiquote_tok span buf len _buf2 = do mkFastString (reverse quote), mkPsSpan quoteStart end))) -lex_quasiquote :: RealSrcLoc -> String -> P String +lex_quasiquote :: RealSrcLoc -> String -> P p String lex_quasiquote start s = do i <- getInput case alexGetChar' i of @@ -2591,7 +2591,7 @@ lex_quasiquote start s = do Just (c, i) -> do setInput i; lex_quasiquote start (c : s) -quasiquote_error :: RealSrcLoc -> P a +quasiquote_error :: RealSrcLoc -> P p a quasiquote_error start = do (AI end buf) <- getInput reportLexError start (psRealLoc end) buf @@ -2621,18 +2621,18 @@ smart_quote_error_message c loc = PsErrUnicodeCharLooksLike c correct_char correct_char_name in err -smart_quote_error :: Action +smart_quote_error :: Action p smart_quote_error span buf _len _buf2 = do let c = currentChar buf addFatalError (smart_quote_error_message c (psSpanStart span)) -add_smart_quote_error :: Char -> PsLoc -> P a +add_smart_quote_error :: Char -> PsLoc -> P p a add_smart_quote_error c loc = addFatalError (smart_quote_error_message c loc) -add_nonfatal_smart_quote_error :: Char -> PsLoc -> P () +add_nonfatal_smart_quote_error :: Char -> PsLoc -> P p () add_nonfatal_smart_quote_error c loc = addError (smart_quote_error_message c loc) -advance_to_smart_quote_character :: P () +advance_to_smart_quote_character :: P p () advance_to_smart_quote_character = do i <- getInput case alexGetChar' i of @@ -2643,12 +2643,12 @@ advance_to_smart_quote_character = do -- ----------------------------------------------------------------------------- -- Warnings -warnTab :: Action +warnTab :: Action p warnTab srcspan _buf _len _buf2 = do addTabWarning (psRealSpan srcspan) lexToken -warnThen :: PsMessage -> Action -> Action +warnThen :: PsMessage -> Action p -> Action p warnThen warning action srcspan buf len buf2 = do addPsMessage (RealSrcSpan (psRealSpan srcspan) Strict.Nothing) warning action srcspan buf len buf2 @@ -2672,14 +2672,14 @@ data LayoutContext deriving Show -- | The result of running a parser. -newtype ParseResult a = PR (# (# PState, a #) | PState #) +newtype ParseResult p a = PR (# (# PState p, a #) | PState p #) -- | The parser has consumed a (possibly empty) prefix of the input and produced -- a result. Use 'getPsMessages' to check for accumulated warnings and non-fatal -- errors. -- -- The carried parsing state can be used to resume parsing. -pattern POk :: PState -> a -> ParseResult a +pattern POk :: PState p -> a -> ParseResult p a pattern POk s a = PR (# (# s , a #) | #) -- | The parser has consumed a (possibly empty) prefix of the input and failed. @@ -2687,7 +2687,7 @@ pattern POk s a = PR (# (# s , a #) | #) -- The carried parsing state can be used to resume parsing. It is the state -- right before failure, including the fatal parse error. 'getPsMessages' and -- 'getPsErrorMessages' must return a non-empty bag of errors. -pattern PFailed :: PState -> ParseResult a +pattern PFailed :: PState p -> ParseResult p a pattern PFailed s = PR (# | s #) {-# COMPLETE POk, PFailed #-} @@ -2721,7 +2721,7 @@ data HdkComment | HdkCommentSection Int HsDocString deriving Show -data PState = PState { +data PState a = PState { buffer :: StringBuffer, options :: ParserOpts, warnings :: Messages PsMessage, @@ -2770,7 +2770,8 @@ data PState = PState { hdk_comments :: OrdList (PsLocated HdkComment), -- See Note [CPP in GHC] in GHC.Parser.PreProcess - pp :: !PpState + -- pp :: !PpState + pp :: !a } -- last_loc and last_len are used when generating error messages, -- and in pushCurrentContext only. Sigh, if only Happy passed the @@ -2798,6 +2799,7 @@ data PpState = PpState { data PpContext = PpContextIf [Located Token] deriving (Show) +-- TODO: delete initPpState :: PpState initPpState = PpState { pp_defines = Map.empty @@ -2815,90 +2817,90 @@ data ALRLayout = ALRLayoutLet | ALRLayoutDo -- | The parsing monad, isomorphic to @StateT PState Maybe at . -newtype P a = P { unP :: PState -> ParseResult a } +newtype P p a = P { unP :: PState p -> ParseResult p a } -instance Functor P where +instance Functor (P p) where fmap = liftM -instance Applicative P where +instance Applicative (P p) where pure = returnP (<*>) = ap -instance Monad P where +instance Monad (P p) where (>>=) = thenP -returnP :: a -> P a +returnP :: a -> P p a returnP a = a `seq` (P $ \s -> POk s a) -thenP :: P a -> (a -> P b) -> P b +thenP :: P p a -> (a -> P p b) -> P p b (P m) `thenP` k = P $ \ s -> case m s of POk s1 a -> (unP (k a)) s1 PFailed s1 -> PFailed s1 -failMsgP :: (SrcSpan -> MsgEnvelope PsMessage) -> P a +failMsgP :: (SrcSpan -> MsgEnvelope PsMessage) -> P p a failMsgP f = do pState <- getPState addFatalError (f (mkSrcSpanPs (last_loc pState))) -failLocMsgP :: RealSrcLoc -> RealSrcLoc -> (SrcSpan -> MsgEnvelope PsMessage) -> P a +failLocMsgP :: RealSrcLoc -> RealSrcLoc -> (SrcSpan -> MsgEnvelope PsMessage) -> P p a failLocMsgP loc1 loc2 f = addFatalError (f (RealSrcSpan (mkRealSrcSpan loc1 loc2) Strict.Nothing)) -getPState :: P PState +getPState :: P p (PState p) getPState = P $ \s -> POk s s -getExts :: P ExtsBitmap +getExts :: P p ExtsBitmap getExts = P $ \s -> POk s (pExtsBitmap . options $ s) -setExts :: (ExtsBitmap -> ExtsBitmap) -> P () +setExts :: (ExtsBitmap -> ExtsBitmap) -> P p () setExts f = P $ \s -> POk s { options = let p = options s in p { pExtsBitmap = f (pExtsBitmap p) } } () -setSrcLoc :: RealSrcLoc -> P () +setSrcLoc :: RealSrcLoc -> P p () setSrcLoc new_loc = P $ \s@(PState{ loc = PsLoc _ buf_loc }) -> POk s{ loc = PsLoc new_loc buf_loc } () -getRealSrcLoc :: P RealSrcLoc +getRealSrcLoc :: P p RealSrcLoc getRealSrcLoc = P $ \s@(PState{ loc=loc }) -> POk s (psRealLoc loc) -getParsedLoc :: P PsLoc +getParsedLoc :: P p PsLoc getParsedLoc = P $ \s@(PState{ loc=loc }) -> POk s loc -addSrcFile :: FastString -> P () +addSrcFile :: FastString -> P p () addSrcFile f = P $ \s -> POk s{ srcfiles = f : srcfiles s } () -setEofPos :: RealSrcSpan -> RealSrcSpan -> P () +setEofPos :: RealSrcSpan -> RealSrcSpan -> P p () setEofPos span gap = P $ \s -> POk s{ eof_pos = Strict.Just (span `Strict.And` gap) } () -setLastToken :: PsSpan -> Int -> P () +setLastToken :: PsSpan -> Int -> P p () setLastToken loc len = P $ \s -> POk s { last_loc=loc, last_len=len } () -setLastTk :: PsLocated Token -> P () +setLastTk :: PsLocated Token -> P p () setLastTk tk@(L l _) = P $ \s -> if isPointRealSpan (psRealSpan l) then POk s { last_tk = Strict.Just tk } () else POk s { last_tk = Strict.Just tk , prev_loc = l } () -setLastComment :: PsLocated Token -> P () +setLastComment :: PsLocated Token -> P p () setLastComment (L l _) = P $ \s -> POk s { prev_loc = l } () -getLastTk :: P (Strict.Maybe (PsLocated Token)) +getLastTk :: P p (Strict.Maybe (PsLocated Token)) getLastTk = P $ \s@(PState { last_tk = last_tk }) -> POk s last_tk -- see Note [PsSpan in Comments] -getLastLocIncludingComments :: P PsSpan +getLastLocIncludingComments :: P p PsSpan getLastLocIncludingComments = P $ \s@(PState { prev_loc = prev_loc }) -> POk s prev_loc -getLastLoc :: P PsSpan +getLastLoc :: P p PsSpan getLastLoc = P $ \s@(PState { last_loc = last_loc }) -> POk s last_loc data AlexInput = AI !PsLoc !StringBuffer @@ -3009,34 +3011,34 @@ alexGetChar' (AI loc s) where (c,s') = nextChar s loc' = advancePsLoc loc c -getInput :: P AlexInput +getInput :: P p AlexInput getInput = P $ \s at PState{ loc=l, buffer=b } -> POk s (AI l b) -setInput :: AlexInput -> P () +setInput :: AlexInput -> P p () setInput (AI l b) = P $ \s -> POk s{ loc=l, buffer=b } () -nextIsEOF :: P Bool +nextIsEOF :: P p Bool nextIsEOF = do AI _ s <- getInput return $ atEnd s -pushLexState :: Int -> P () +pushLexState :: Int -> P p () pushLexState ls = P $ \s at PState{ lex_state=l } -> POk s{lex_state=ls:l} () -- pushLexState ls = P $ \s at PState{ lex_state= l } -> POk s{lex_state= trace ("pushLexState:" ++ show ls) ls:l} () -popLexState :: P Int +popLexState :: P p Int popLexState = P $ \s at PState{ lex_state=ls:l } -> POk s{ lex_state=l } ls -- popLexState = P $ \s at PState{ lex_state=ls:l } -> POk s{ lex_state= trace ("popLexState:" ++ show (ls,l)) l } ls -getLexState :: P Int +getLexState :: P p Int getLexState = P $ \s at PState{ lex_state=ls:_ } -> POk s ls -popNextToken :: P (Maybe (PsLocated Token)) +popNextToken :: P p (Maybe (PsLocated Token)) popNextToken = P $ \s at PState{ alr_next_token = m } -> POk (s {alr_next_token = Nothing}) m -activeContext :: P Bool +activeContext :: P p Bool activeContext = do ctxt <- getALRContext expc <- getAlrExpectingOCurly @@ -3045,55 +3047,55 @@ activeContext = do ([],Nothing) -> return impt _other -> return True -resetAlrLastLoc :: FastString -> P () +resetAlrLastLoc :: FastString -> P p () resetAlrLastLoc file = P $ \s@(PState {alr_last_loc = PsSpan _ buf_span}) -> POk s{ alr_last_loc = PsSpan (alrInitialLoc file) buf_span } () -setAlrLastLoc :: PsSpan -> P () +setAlrLastLoc :: PsSpan -> P p () setAlrLastLoc l = P $ \s -> POk (s {alr_last_loc = l}) () -getAlrLastLoc :: P PsSpan +getAlrLastLoc :: P p PsSpan getAlrLastLoc = P $ \s@(PState {alr_last_loc = l}) -> POk s l -getALRContext :: P [ALRContext] +getALRContext :: P p [ALRContext] getALRContext = P $ \s@(PState {alr_context = cs}) -> POk s cs -setALRContext :: [ALRContext] -> P () +setALRContext :: [ALRContext] -> P p () setALRContext cs = P $ \s -> POk (s {alr_context = cs}) () -getJustClosedExplicitLetBlock :: P Bool +getJustClosedExplicitLetBlock :: P p Bool getJustClosedExplicitLetBlock = P $ \s@(PState {alr_justClosedExplicitLetBlock = b}) -> POk s b -setJustClosedExplicitLetBlock :: Bool -> P () +setJustClosedExplicitLetBlock :: Bool -> P p () setJustClosedExplicitLetBlock b = P $ \s -> POk (s {alr_justClosedExplicitLetBlock = b}) () -setNextToken :: PsLocated Token -> P () +setNextToken :: PsLocated Token -> P p () setNextToken t = P $ \s -> POk (s {alr_next_token = Just t}) () -implicitTokenPending :: P Bool +implicitTokenPending :: P p Bool implicitTokenPending = P $ \s at PState{ alr_pending_implicit_tokens = ts } -> case ts of [] -> POk s False _ -> POk s True -popPendingImplicitToken :: P (Maybe (PsLocated Token)) +popPendingImplicitToken :: P p (Maybe (PsLocated Token)) popPendingImplicitToken = P $ \s at PState{ alr_pending_implicit_tokens = ts } -> case ts of [] -> POk s Nothing (t : ts') -> POk (s {alr_pending_implicit_tokens = ts'}) (Just t) -setPendingImplicitTokens :: [PsLocated Token] -> P () +setPendingImplicitTokens :: [PsLocated Token] -> P p () setPendingImplicitTokens ts = P $ \s -> POk (s {alr_pending_implicit_tokens = ts}) () -getAlrExpectingOCurly :: P (Maybe ALRLayout) +getAlrExpectingOCurly :: P p (Maybe ALRLayout) getAlrExpectingOCurly = P $ \s@(PState {alr_expecting_ocurly = b}) -> POk s b -setAlrExpectingOCurly :: Maybe ALRLayout -> P () +setAlrExpectingOCurly :: Maybe ALRLayout -> P p () setAlrExpectingOCurly b = P $ \s -> POk (s {alr_expecting_ocurly = b}) () -- | For reasons of efficiency, boolean parsing flags (eg, language extensions @@ -3270,15 +3272,15 @@ disableHaddock opts = upd_bitmap (xunset HaddockBit) -- | Set parser options for parsing OPTIONS pragmas -initPragState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState -initPragState options buf loc = (initParserState options buf loc) +initPragState :: p -> ParserOpts -> StringBuffer -> RealSrcLoc -> PState p +initPragState p options buf loc = (initParserState p options buf loc) -- initPragState options buf loc = (initParserState options buf (trace ("initPragState:" ++ show bol) loc)) { lex_state = [bol, option_prags, 0] } -- | Creates a parse state from a 'ParserOpts' value -initParserState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState -initParserState options buf loc = +initParserState :: p -> ParserOpts -> StringBuffer -> RealSrcLoc -> PState p +initParserState ppState options buf loc = PState { buffer = buf, options = options, @@ -3304,7 +3306,8 @@ initParserState options buf loc = header_comments = Strict.Nothing, comment_q = [], hdk_comments = nilOL, - pp = initPpState + -- pp = initPpState + pp = ppState } where init_loc = PsLoc loc (BufPos 0) @@ -3352,7 +3355,7 @@ class Monad m => MonadP m where -- that come after the given span allocateFinalCommentsP :: RealSrcSpan -> m EpAnnComments -instance MonadP P where +instance MonadP (P p) where addError err = P $ \s -> POk s { errors = err `addMessage` errors s} () @@ -3399,15 +3402,15 @@ getFinalCommentsFor :: (MonadP m) => SrcSpan -> m EpAnnComments getFinalCommentsFor (RealSrcSpan l _) = allocateFinalCommentsP l getFinalCommentsFor _ = return emptyComments -getEofPos :: P (Strict.Maybe (Strict.Pair RealSrcSpan RealSrcSpan)) +getEofPos :: P p (Strict.Maybe (Strict.Pair RealSrcSpan RealSrcSpan)) getEofPos = P $ \s@(PState { eof_pos = pos }) -> POk s pos -addPsMessage :: SrcSpan -> PsMessage -> P () +addPsMessage :: SrcSpan -> PsMessage -> P p () addPsMessage srcspan msg = do diag_opts <- (pDiagOpts . options) <$> getPState addWarning (mkPlainMsgEnvelope diag_opts srcspan msg) -addTabWarning :: RealSrcSpan -> P () +addTabWarning :: RealSrcSpan -> P p () addTabWarning srcspan = P $ \s at PState{tab_first=tf, tab_count=tc, options=o} -> let tf' = tf <|> Strict.Just srcspan @@ -3419,12 +3422,12 @@ addTabWarning srcspan -- | Get a bag of the errors that have been accumulated so far. -- Does not take -Werror into account. -getPsErrorMessages :: PState -> Messages PsMessage +getPsErrorMessages :: PState p -> Messages PsMessage getPsErrorMessages p = errors p -- | Get the warnings and errors accumulated so far. -- Does not take -Werror into account. -getPsMessages :: PState -> (Messages PsMessage, Messages PsMessage) +getPsMessages :: PState p -> (Messages PsMessage, Messages PsMessage) getPsMessages p = let ws = warnings p diag_opts = pDiagOpts (options p) @@ -3439,13 +3442,13 @@ getPsMessages p = in msg `addMessage` ws in (ws', errors p) -getContext :: P [LayoutContext] +getContext :: P p [LayoutContext] getContext = P $ \s at PState{context=ctx} -> POk s ctx -setContext :: [LayoutContext] -> P () +setContext :: [LayoutContext] -> P p () setContext ctx = P $ \s -> POk s{context=ctx} () -popContext :: P () +popContext :: P p () popContext = P $ \ s@(PState{ buffer = buf, options = o, context = ctx, last_len = len, last_loc = last_loc }) -> case ctx of @@ -3455,16 +3458,16 @@ popContext = P $ \ s@(PState{ buffer = buf, options = o, context = ctx, unP (addFatalError $ srcParseErr o buf len (mkSrcSpanPs last_loc)) s -- Push a new layout context at the indentation of the last token read. -pushCurrentContext :: GenSemic -> P () +pushCurrentContext :: GenSemic -> P p () pushCurrentContext gen_semic = P $ \ s at PState{ last_loc=loc, context=ctx } -> POk s{context = Layout (srcSpanStartCol (psRealSpan loc)) gen_semic : ctx} () -- This is only used at the outer level of a module when the 'module' keyword is -- missing. -pushModuleContext :: P () +pushModuleContext :: P p () pushModuleContext = pushCurrentContext generateSemic -getOffside :: P (Ordering, Bool) +getOffside :: P p (Ordering, Bool) getOffside = P $ \s at PState{last_loc=loc, context=stk} -> let offs = srcSpanStartCol (psRealSpan loc) in let ord = case stk of @@ -3504,14 +3507,14 @@ srcParseErr options buf len loc = mkPlainErrorMsgEnvelope loc (PsErrParse token -- Report a parse failure, giving the span of the previous token as -- the location of the error. This is the entry point for errors -- detected during parsing. -srcParseFail :: P a +srcParseFail :: P p a srcParseFail = P $ \s at PState{ buffer = buf, options = o, last_len = len, last_loc = last_loc } -> unP (addFatalError $ srcParseErr o buf len (mkSrcSpanPs last_loc)) s -- A lexical error is reported at a particular position in the source file, -- not over a token range. -lexError :: LexErr -> P a +lexError :: LexErr -> P p a lexError e = do loc <- getRealSrcLoc (AI end buf) <- getInput @@ -3522,7 +3525,7 @@ lexError e = do -- This is the top-level function: called from the parser each time a -- new token is to be read from the input. -lexer, lexerDbg :: Bool -> (Located Token -> P a) -> P a +lexer, lexerDbg :: Bool -> (Located Token -> P p a) -> P p a lexer queueComments cont = do alr <- getBit AlternativeLayoutRuleBit @@ -3539,7 +3542,7 @@ lexerDbg queueComments cont = lexer queueComments contDbg where contDbg tok = trace ("token: " ++ show (unLoc tok)) (cont tok) -lexTokenAlr :: P (PsLocated Token) +lexTokenAlr :: P p (PsLocated Token) lexTokenAlr = do mPending <- popPendingImplicitToken t <- case mPending of Nothing -> @@ -3563,7 +3566,7 @@ lexTokenAlr = do mPending <- popPendingImplicitToken _ -> return () return t -alternativeLayoutRuleToken :: PsLocated Token -> P (PsLocated Token) +alternativeLayoutRuleToken :: PsLocated Token -> P p (PsLocated Token) alternativeLayoutRuleToken t = do context <- getALRContext lastLoc <- getAlrLastLoc @@ -3754,7 +3757,7 @@ topNoLayoutContainsCommas [] = False topNoLayoutContainsCommas (ALRLayout _ _ : ls) = topNoLayoutContainsCommas ls topNoLayoutContainsCommas (ALRNoLayout b _ : _) = b -lexToken :: P (PsLocated Token) +lexToken :: P p (PsLocated Token) lexToken = do inp@(AI loc1 buf) <- getInput sc <- getLexState @@ -3787,7 +3790,7 @@ reportLexError :: RealSrcLoc -> RealSrcLoc -> StringBuffer -> (LexErrKind -> SrcSpan -> MsgEnvelope PsMessage) - -> P a + -> P p a reportLexError loc1 loc2 buf f | atEnd buf = failLocMsgP loc1 loc2 (f LexErrKind_EOF) | otherwise = @@ -3796,14 +3799,14 @@ reportLexError loc1 loc2 buf f then failLocMsgP loc2 loc2 (f LexErrKind_UTF8) else failLocMsgP loc1 loc2 (f (LexErrKind_Char c)) -lexTokenStream :: ParserOpts -> StringBuffer -> RealSrcLoc -> ParseResult [Located Token] -lexTokenStream opts buf loc = unP go initState{ options = opts' } +lexTokenStream :: p -> ParserOpts -> StringBuffer -> RealSrcLoc -> ParseResult p [Located Token] +lexTokenStream pp opts buf loc = unP go initState{ options = opts' } where new_exts = xunset UsePosPragsBit -- parse LINE/COLUMN pragmas as tokens $ xset RawTokenStreamBit -- include comments $ pExtsBitmap opts opts' = opts { pExtsBitmap = new_exts } - initState = initParserState opts' buf loc + initState = initParserState pp opts' buf loc go = do ltok <- lexer False return case ltok of @@ -3866,13 +3869,13 @@ twoWordPrags = Map.fromList [ fstrtoken (\s -> (ITspec_inline_prag (SourceText s) False))) ] -dispatch_pragmas :: Map String Action -> Action +dispatch_pragmas :: Map String (Action p) -> Action p dispatch_pragmas prags span buf len buf2 = case Map.lookup (clean_pragma (lexemeToString buf len)) prags of Just found -> found span buf len buf2 Nothing -> lexError LexUnknownPragma -known_pragma :: Map String Action -> AlexAccPred ExtsBitmap +known_pragma :: Map String (Action p) -> AlexAccPred ExtsBitmap known_pragma prags _ (AI _ startbuf) _ (AI _ curbuf) = isKnown && nextCharIsNot curbuf pragmaNameChar where l = lexemeToString startbuf (byteDiff startbuf curbuf) @@ -3891,7 +3894,7 @@ clean_pragma prag = canon_ws (map toLower (unprefix prag)) _ -> prag' canon_ws s = unwords (map canonical (words s)) -warn_unknown_prag :: Map String Action -> Action +warn_unknown_prag :: Map String (Action p) -> Action p warn_unknown_prag prags span buf len buf2 = do let uppercase = map toUpper unknown_prag = uppercase (clean_pragma (lexemeToString buf len)) @@ -3923,12 +3926,12 @@ mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCl lo = mkRealSrcSpan (realSrcSpanStart ss) (mkRealSrcLoc f sl (sc+1)) lc = mkRealSrcSpan (mkRealSrcLoc f el (ec - 1)) (realSrcSpanEnd ss) -queueComment :: RealLocated Token -> P() +queueComment :: RealLocated Token -> P p () queueComment c = P $ \s -> POk s { comment_q = commentToAnnotation c : comment_q s } () -queueIgnoredToken :: PsLocated Token -> P() +queueIgnoredToken :: PsLocated Token -> P p () queueIgnoredToken (L l tok) = do ll <- getLastLocIncludingComments let ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -195,7 +195,7 @@ mkClassDecl :: SrcSpan -> OrdList (LHsDecl GhcPs) -> LayoutInfo GhcPs -> [AddEpAnn] - -> P (LTyClDecl GhcPs) + -> P p (LTyClDecl GhcPs) mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layoutInfo annsIn = do { let loc = noAnnSrcSpan loc' @@ -224,7 +224,7 @@ mkTyData :: SrcSpan -> [LConDecl GhcPs] -> Located (HsDeriving GhcPs) -> [AddEpAnn] - -> P (LTyClDecl GhcPs) + -> P p (LTyClDecl GhcPs) mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) ksig data_cons (L _ maybe_deriv) annsIn = do { let loc = noAnnSrcSpan loc' @@ -244,7 +244,7 @@ mkDataDefn :: Maybe (LocatedP CType) -> Maybe (LHsKind GhcPs) -> DataDefnCons (LConDecl GhcPs) -> HsDeriving GhcPs - -> P (HsDataDefn GhcPs) + -> P p (HsDataDefn GhcPs) mkDataDefn cType mcxt ksig data_cons maybe_deriv = do { checkDatatypeContext mcxt ; return (HsDataDefn { dd_ext = noExtField @@ -258,7 +258,7 @@ mkTySynonym :: SrcSpan -> LHsType GhcPs -- LHS -> LHsType GhcPs -- RHS -> [AddEpAnn] - -> P (LTyClDecl GhcPs) + -> P p (LTyClDecl GhcPs) mkTySynonym loc lhs rhs annsIn = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs ; cs1 <- getCommentsFor loc -- Add any API Annotations to the top SrcSpan [temp] @@ -276,7 +276,7 @@ mkStandaloneKindSig -> Located [LocatedN RdrName] -- LHS -> LHsSigType GhcPs -- RHS -> [AddEpAnn] - -> P (LStandaloneKindSig GhcPs) + -> P p (LStandaloneKindSig GhcPs) mkStandaloneKindSig loc lhs rhs anns = do { vs <- mapM check_lhs_name (unLoc lhs) ; v <- check_singular_lhs (reverse vs) @@ -301,7 +301,7 @@ mkTyFamInstEqn :: SrcSpan -> LHsType GhcPs -> LHsType GhcPs -> [AddEpAnn] - -> P (LTyFamInstEqn GhcPs) + -> P p (LTyFamInstEqn GhcPs) mkTyFamInstEqn loc bndrs lhs rhs anns = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs ; cs <- getCommentsFor loc @@ -322,7 +322,7 @@ mkDataFamInst :: SrcSpan -> [LConDecl GhcPs] -> Located (HsDeriving GhcPs) -> [AddEpAnn] - -> P (LInstDecl GhcPs) + -> P p (LInstDecl GhcPs) mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) ksig data_cons (L _ maybe_deriv) anns = do { (tc, tparams, fixity, ann) <- checkTyClHdr False tycl_hdr @@ -357,7 +357,7 @@ mkDataFamInst loc new_or_data cType (mcxt, bndrs, tycl_hdr) mkTyFamInst :: SrcSpan -> TyFamInstEqn GhcPs -> [AddEpAnn] - -> P (LInstDecl GhcPs) + -> P p (LInstDecl GhcPs) mkTyFamInst loc eqn anns = do cs <- getCommentsFor loc return (L (noAnnSrcSpan loc) (TyFamInstD noExtField @@ -370,7 +370,7 @@ mkFamDecl :: SrcSpan -> LFamilyResultSig GhcPs -- Optional result signature -> Maybe (LInjectivityAnn GhcPs) -- Injectivity annotation -> [AddEpAnn] - -> P (LTyClDecl GhcPs) + -> P p (LTyClDecl GhcPs) mkFamDecl loc info topLevel lhs ksig injAnn annsIn = do { (tc, tparams, fixity, ann) <- checkTyClHdr False lhs ; cs1 <- getCommentsFor loc -- Add any API Annotations to the top SrcSpan [temp] @@ -392,7 +392,7 @@ mkFamDecl loc info topLevel lhs ksig injAnn annsIn OpenTypeFamily -> empty ClosedTypeFamily {} -> whereDots -mkSpliceDecl :: LHsExpr GhcPs -> P (LHsDecl GhcPs) +mkSpliceDecl :: LHsExpr GhcPs -> P p (LHsDecl GhcPs) -- If the user wrote -- [pads| ... ] then return a QuasiQuoteD -- $(e) then return a SpliceD @@ -421,7 +421,7 @@ mkRoleAnnotDecl :: SrcSpan -> LocatedN RdrName -- type being annotated -> [Located (Maybe FastString)] -- roles -> [AddEpAnn] - -> P (LRoleAnnotDecl GhcPs) + -> P p (LRoleAnnotDecl GhcPs) mkRoleAnnotDecl loc tycon roles anns = do { roles' <- mapM parse_role roles ; cs <- getCommentsFor loc @@ -446,20 +446,20 @@ mkRoleAnnotDecl loc tycon roles anns -- | Converts a list of 'LHsTyVarBndr's annotated with their 'Specificity' to -- binders without annotations. Only accepts specified variables, and errors if -- any of the provided binders has an 'InferredSpec' annotation. -fromSpecTyVarBndrs :: [LHsTyVarBndr Specificity GhcPs] -> P [LHsTyVarBndr () GhcPs] +fromSpecTyVarBndrs :: [LHsTyVarBndr Specificity GhcPs] -> P p [LHsTyVarBndr () GhcPs] fromSpecTyVarBndrs = mapM fromSpecTyVarBndr -- | Converts 'LHsTyVarBndr' annotated with its 'Specificity' to one without -- annotations. Only accepts specified variables, and errors if the provided -- binder has an 'InferredSpec' annotation. -fromSpecTyVarBndr :: LHsTyVarBndr Specificity GhcPs -> P (LHsTyVarBndr () GhcPs) +fromSpecTyVarBndr :: LHsTyVarBndr Specificity GhcPs -> P p (LHsTyVarBndr () GhcPs) fromSpecTyVarBndr bndr = case bndr of (L loc (UserTyVar xtv flag idp)) -> (check_spec flag loc) >> return (L loc $ UserTyVar xtv () idp) (L loc (KindedTyVar xtv flag idp k)) -> (check_spec flag loc) >> return (L loc $ KindedTyVar xtv () idp k) where - check_spec :: Specificity -> SrcSpanAnnA -> P () + check_spec :: Specificity -> SrcSpanAnnA -> P p () check_spec SpecifiedSpec _ = return () check_spec InferredSpec loc = addFatalError $ mkPlainErrorMsgEnvelope (locA loc) $ PsErrInferredTypeVarNotAllowed @@ -527,7 +527,7 @@ cvTopDecls :: OrdList (LHsDecl GhcPs) -> [LHsDecl GhcPs] cvTopDecls decls = getMonoBindAll (fromOL decls) -- Declaration list may only contain value bindings and signatures. -cvBindGroup :: OrdList (LHsDecl GhcPs) -> P (HsValBinds GhcPs) +cvBindGroup :: OrdList (LHsDecl GhcPs) -> P p (HsValBinds GhcPs) cvBindGroup binding = do { (mbs, sigs, fam_ds, tfam_insts , dfam_insts, _) <- cvBindsAndSigs binding @@ -535,7 +535,7 @@ cvBindGroup binding ; return $ ValBinds NoAnnSortKey mbs sigs } cvBindsAndSigs :: OrdList (LHsDecl GhcPs) - -> P (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs] + -> P p (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs] , [LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs]) -- Input decls contain just value bindings and signatures -- and in case of class or instance declarations also @@ -733,7 +733,7 @@ tyConToDataCon (L loc tc) mkPatSynMatchGroup :: LocatedN RdrName -> LocatedL (OrdList (LHsDecl GhcPs)) - -> P (MatchGroup GhcPs (LHsExpr GhcPs)) + -> P p (MatchGroup GhcPs (LHsExpr GhcPs)) mkPatSynMatchGroup (L loc patsyn_name) (L ld decls) = do { matches <- mapM fromDecl (fromOL decls) ; when (null matches) (wrongNumberErr (locA loc)) @@ -779,7 +779,7 @@ mkPatSynMatchGroup (L loc patsyn_name) (L ld decls) = addFatalError $ mkPlainErrorMsgEnvelope loc $ (PsErrEmptyWhereInPatSynDecl patsyn_name) -recordPatSynErr :: SrcSpan -> LPat GhcPs -> P a +recordPatSynErr :: SrcSpan -> LPat GhcPs -> P p a recordPatSynErr loc pat = addFatalError $ mkPlainErrorMsgEnvelope loc $ (PsErrRecordSyntaxInPatSynDecl pat) @@ -808,7 +808,7 @@ mkGadtDecl :: SrcSpan -> NonEmpty (LocatedN RdrName) -> LHsUniToken "::" "∷" GhcPs -> LHsSigType GhcPs - -> P (LConDecl GhcPs) + -> P p (LConDecl GhcPs) mkGadtDecl loc names dcol ty = do cs <- getCommentsFor loc let l = noAnnSrcSpan loc @@ -935,7 +935,7 @@ eitherToP (Left err) = addFatalError err eitherToP (Right thing) = return thing checkTyVars :: SDoc -> SDoc -> LocatedN RdrName -> [LHsTypeArg GhcPs] - -> P (LHsQTyVars GhcPs) -- the synthesized type variables + -> P p (LHsQTyVars GhcPs) -- the synthesized type variables -- ^ Check whether the given list of type parameters are all type variables -- (possibly with a kind signature). checkTyVars pp_what equals_or_where tc tparms @@ -948,7 +948,7 @@ checkTyVars pp_what equals_or_where tc tparms (PsErrMalformedDecl pp_what (unLoc tc)) -- Keep around an action for adjusting the annotations of extra parens chkParens :: [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> HsBndrVis GhcPs -> LHsType GhcPs - -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) + -> P p (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) chkParens ops cps cs bvis (L l (HsParTy an ty)) = let (o,c) = mkParensEpAnn (realSrcSpan $ locA l) @@ -957,7 +957,7 @@ checkTyVars pp_what equals_or_where tc tparms chkParens ops cps cs bvis ty = chk ops cps cs bvis ty -- Check that the name space is correct! - chk :: [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> HsBndrVis GhcPs -> LHsType GhcPs -> P (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) + chk :: [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> HsBndrVis GhcPs -> LHsType GhcPs -> P p (LHsTyVarBndr (HsBndrVis GhcPs) GhcPs) chk ops cps cs bvis (L l (HsKindSig annk (L annt (HsTyVar ann _ (L lv tv))) k)) | isRdrTyVar tv = let @@ -993,7 +993,7 @@ whereDots, equalsDots :: SDoc whereDots = text "where ..." equalsDots = text "= ..." -checkDatatypeContext :: Maybe (LHsContext GhcPs) -> P () +checkDatatypeContext :: Maybe (LHsContext GhcPs) -> P p () checkDatatypeContext Nothing = return () checkDatatypeContext (Just c) = do allowed <- getBit DatatypeContextsBit @@ -1023,7 +1023,7 @@ mkRuleTyVarBndrs = fmap cvt_one tm_to_ty _ = panic "mkRuleTyVarBndrs" -- See Note [Parsing explicit foralls in Rules] in Parser.y -checkRuleTyVarBndrNames :: [LHsTyVarBndr flag GhcPs] -> P () +checkRuleTyVarBndrNames :: [LHsTyVarBndr flag GhcPs] -> P p () checkRuleTyVarBndrNames = mapM_ (check . fmap hsTyVarName) where check (L loc (Unqual occ)) = when (occNameFS occ `elem` [fsLit "forall",fsLit "family",fsLit "role"]) @@ -1041,7 +1041,7 @@ checkRecordSyntax lr@(L loc r) -- | Check if the gadt_constrlist is empty. Only raise parse error for -- `data T where` to avoid affecting existing error message, see #8258. checkEmptyGADTs :: Located ([AddEpAnn], [LConDecl GhcPs]) - -> P (Located ([AddEpAnn], [LConDecl GhcPs])) + -> P p (Located ([AddEpAnn], [LConDecl GhcPs])) checkEmptyGADTs gadts@(L span (_, [])) -- Empty GADT declaration. = do gadtSyntax <- getBit GadtSyntaxBit -- GADTs implies GADTSyntax unless gadtSyntax $ addError $ mkPlainErrorMsgEnvelope span $ @@ -1052,10 +1052,10 @@ checkEmptyGADTs gadts = return gadts -- Ordinary GADT declaration. checkTyClHdr :: Bool -- True <=> class header -- False <=> type header -> LHsType GhcPs - -> P (LocatedN RdrName, -- the head symbol (type or class name) - [LHsTypeArg GhcPs], -- parameters of head symbol - LexicalFixity, -- the declaration is in infix format - [AddEpAnn]) -- API Annotation for HsParTy + -> P p (LocatedN RdrName, -- the head symbol (type or class name) + [LHsTypeArg GhcPs], -- parameters of head symbol + LexicalFixity, -- the declaration is in infix format + [AddEpAnn]) -- API Annotation for HsParTy -- when stripping parens -- Well-formedness check and decomposition of type and class heads. -- Decomposes T ty1 .. tyn into (T, [ty1, ..., tyn]) @@ -1152,12 +1152,12 @@ checkCmdBlockArguments :: LHsCmd GhcPs -> PV () -- (Eq a) --> [Eq a] -- (((Eq a))) --> [Eq a] -- @ -checkContext :: LHsType GhcPs -> P (LHsContext GhcPs) +checkContext :: LHsType GhcPs -> P p (LHsContext GhcPs) checkContext orig_t@(L (SrcSpanAnn _ l) _orig_t) = check ([],[],emptyComments) orig_t where check :: ([EpaLocation],[EpaLocation],EpAnnComments) - -> LHsType GhcPs -> P (LHsContext GhcPs) + -> LHsType GhcPs -> P p (LHsContext GhcPs) check (oparens,cparens,cs) (L _l (HsTupleTy ann' HsBoxedOrConstraintTuple ts)) -- (Eq a, Ord b) shows up as a tuple type. Only boxed tuples can -- be used as context constraints. @@ -1184,7 +1184,7 @@ checkContext orig_t@(L (SrcSpanAnn _ l) _orig_t) = checkImportDecl :: Maybe EpaLocation -> Maybe EpaLocation - -> P () + -> P p () checkImportDecl mPre mPost = do let whenJust mg f = maybe (pure ()) f mg @@ -1213,10 +1213,10 @@ checkImportDecl mPre mPost = do -- We parse patterns as expressions and check for valid patterns below, -- converting the expression into a pattern at the same time. -checkPattern :: LocatedA (PatBuilder GhcPs) -> P (LPat GhcPs) +checkPattern :: LocatedA (PatBuilder GhcPs) -> P p (LPat GhcPs) checkPattern = runPV . checkLPat -checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P (LPat GhcPs) +checkPattern_details :: ParseContext -> PV (LocatedA (PatBuilder GhcPs)) -> P p (LPat GhcPs) checkPattern_details extraDetails pp = runPV_details extraDetails (pp >>= checkLPat) checkLPat :: LocatedA (PatBuilder GhcPs) -> PV (LPat GhcPs) @@ -1320,7 +1320,7 @@ checkValDef :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> Maybe (AddEpAnn, LHsType GhcPs) -> Located (GRHSs GhcPs (LHsExpr GhcPs)) - -> P (HsBind GhcPs) + -> P p (HsBind GhcPs) checkValDef loc lhs (Just (sigAnn, sig)) grhss -- x :: ty = rhs parses as a *pattern* binding @@ -1345,7 +1345,7 @@ checkFunBind :: SrcStrictness -> LexicalFixity -> [LocatedA (PatBuilder GhcPs)] -> Located (GRHSs GhcPs (LHsExpr GhcPs)) - -> P (HsBind GhcPs) + -> P p (HsBind GhcPs) checkFunBind strictness locF ann fun is_infix pats (L _ grhss) = do ps <- runPV_details extraDetails (mapM checkLPat pats) let match_span = noAnnSrcSpan $ locF @@ -1378,7 +1378,7 @@ checkPatBind :: SrcSpan -> [AddEpAnn] -> LPat GhcPs -> Located (GRHSs GhcPs (LHsExpr GhcPs)) - -> P (HsBind GhcPs) + -> P p (HsBind GhcPs) checkPatBind loc annsIn (L _ (BangPat (EpAnn _ ans cs) (L _ (VarPat _ v)))) (L _match_span grhss) = return (makeFunBind v (L (noAnnSrcSpan loc) @@ -1395,7 +1395,7 @@ checkPatBind loc annsIn lhs (L _ grhss) = do cs <- getCommentsFor loc return (PatBind (EpAnn (spanAsAnchor loc) annsIn cs) lhs grhss) -checkValSigLhs :: LHsExpr GhcPs -> P (LocatedN RdrName) +checkValSigLhs :: LHsExpr GhcPs -> P p (LocatedN RdrName) checkValSigLhs (L _ (HsVar _ lrdr@(L _ v))) | isUnqual v , not (isDataOcc (rdrNameOcc v)) @@ -1420,8 +1420,8 @@ checkDoAndIfThenElse err guardExpr semiThen thenExpr semiElse elseExpr | otherwise = return () isFunLhs :: LocatedA (PatBuilder GhcPs) - -> P (Maybe (LocatedN RdrName, LexicalFixity, - [LocatedA (PatBuilder GhcPs)],[AddEpAnn])) + -> P p (Maybe (LocatedN RdrName, LexicalFixity, + [LocatedA (PatBuilder GhcPs)],[AddEpAnn])) -- A variable binding is parsed as a FunBind. -- Just (fun, is_infix, arg_pats) if e is a function LHS isFunLhs e = go e [] [] [] @@ -2558,7 +2558,7 @@ pattern match on the pattern stored inside 'PatBuilderPat'. checkPrecP :: Located (SourceText,Int) -- ^ precedence -> Located (OrdList (LocatedN RdrName)) -- ^ operators - -> P () + -> P p () checkPrecP (L l (_,i)) (L _ ol) | 0 <= i, i <= maxPrecedence = pure () | all specialOp ol = pure () @@ -2694,7 +2694,7 @@ mkOpaquePragma src } checkNewOrData :: SrcSpan -> RdrName -> Bool -> NewOrData -> [LConDecl GhcPs] - -> P (DataDefnCons (LConDecl GhcPs)) + -> P p (DataDefnCons (LConDecl GhcPs)) checkNewOrData span name is_type_data = curry $ \ case (NewType, [a]) -> pure $ NewTypeCon a (DataType, as) -> pure $ DataTypeCons is_type_data (handle_type_data as) @@ -2723,7 +2723,7 @@ checkNewOrData span name is_type_data = curry $ \ case mkImport :: Located CCallConv -> Located Safety -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) - -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) + -> P p (EpAnn [AddEpAnn] -> HsDecl GhcPs) mkImport cconv safety (L loc (StringLiteral esrc entity _), v, ty) = case unLoc cconv of CCallConv -> returnSpec =<< mkCImport @@ -2833,7 +2833,7 @@ parseCImport cconv safety nm str sourceText = -- mkExport :: Located CCallConv -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) - -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) + -> P p (EpAnn [AddEpAnn] -> HsDecl GhcPs) mkExport (L lc cconv) (L le (StringLiteral esrc entity _), v, ty) = return $ \ann -> ForD noExtField $ ForeignExport { fd_e_ext = ann, fd_name = v, fd_sig_ty = ty @@ -2864,7 +2864,7 @@ data ImpExpQcSpec = ImpExpQcName (LocatedN RdrName) | ImpExpQcWildcard mkModuleImpExp :: Maybe (LWarningTxt GhcPs) -> [AddEpAnn] -> LocatedA ImpExpQcSpec - -> ImpExpSubSpec -> P (IE GhcPs) + -> ImpExpSubSpec -> P p (IE GhcPs) mkModuleImpExp warning anns (L l specname) subs = do cs <- getCommentsFor (locA l) -- AZ: IEVar can discard comments let ann = EpAnn (spanAsAnchor $ maybe (locA l) getLocA warning) anns cs @@ -2912,12 +2912,12 @@ mkModuleImpExp warning anns (L l specname) subs = do wrapped = map (fmap ieNameFromSpec) mkTypeImpExp :: LocatedN RdrName -- TcCls or Var name space - -> P (LocatedN RdrName) + -> P p (LocatedN RdrName) mkTypeImpExp name = do requireExplicitNamespaces (getLocA name) return (fmap (`setRdrNameSpace` tcClsName) name) -checkImportSpec :: LocatedL [LIE GhcPs] -> P (LocatedL [LIE GhcPs]) +checkImportSpec :: LocatedL [LIE GhcPs] -> P p (LocatedL [LIE GhcPs]) checkImportSpec ie@(L _ specs) = case [l | (L l (IEThingWith _ _ (IEWildcard _) _)) <- specs] of [] -> return ie @@ -2927,7 +2927,7 @@ checkImportSpec ie@(L _ specs) = addFatalError $ mkPlainErrorMsgEnvelope l PsErrIllegalImportBundleForm -- In the correct order -mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec) +mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P p ([AddEpAnn], ImpExpSubSpec) mkImpExpSubSpec [] = return ([], ImpExpList []) mkImpExpSubSpec [L la ImpExpQcWildcard] = return ([AddEpAnn AnnDotdot (la2e la)], ImpExpAll) @@ -2943,19 +2943,19 @@ isImpExpQcWildcard _ = False ----------------------------------------------------------------------------- -- Warnings and failures -warnPrepositiveQualifiedModule :: SrcSpan -> P () +warnPrepositiveQualifiedModule :: SrcSpan -> P p () warnPrepositiveQualifiedModule span = addPsMessage span PsWarnImportPreQualified -failNotEnabledImportQualifiedPost :: SrcSpan -> P () +failNotEnabledImportQualifiedPost :: SrcSpan -> P p () failNotEnabledImportQualifiedPost loc = addError $ mkPlainErrorMsgEnvelope loc $ PsErrImportPostQualified -failImportQualifiedTwice :: SrcSpan -> P () +failImportQualifiedTwice :: SrcSpan -> P p () failImportQualifiedTwice loc = addError $ mkPlainErrorMsgEnvelope loc $ PsErrImportQualifiedTwice -warnStarIsType :: SrcSpan -> P () +warnStarIsType :: SrcSpan -> P p () warnStarIsType span = addPsMessage span PsWarnStarIsType failOpFewArgs :: MonadP m => LocatedN RdrName -> m a @@ -3023,13 +3023,13 @@ instance Monad PV where PV_Ok acc' a -> unPV (f a) ctx acc' PV_Failed acc' -> PV_Failed acc' -runPV :: PV a -> P a +runPV :: PV a -> P p a runPV = runPV_details noParseContext askParseContext :: PV ParseContext askParseContext = PV $ \(PV_Context _ details) acc -> PV_Ok acc details -runPV_details :: ParseContext -> PV a -> P a +runPV_details :: ParseContext -> PV a -> P p a runPV_details details m = P $ \s -> let ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -180,7 +180,7 @@ we have to use 'flattenBindsAndSigs' to traverse it in the correct order. -- to a parsed HsModule. -- -- Reports badly positioned comments when -Winvalid-haddock is enabled. -addHaddockToModule :: Located (HsModule GhcPs) -> P (Located (HsModule GhcPs)) +addHaddockToModule :: Located (HsModule GhcPs) -> P p (Located (HsModule GhcPs)) addHaddockToModule lmod = do pState <- getPState let all_comments = toList (hdk_comments pState) @@ -192,7 +192,7 @@ addHaddockToModule lmod = do mapM_ reportHdkWarning hdk_warnings return lmod' -reportHdkWarning :: HdkWarn -> P () +reportHdkWarning :: HdkWarn -> P p () reportHdkWarning (HdkWarnInvalidComment (L l _)) = addPsMessage (mkSrcSpanPs l) PsWarnHaddockInvalidPos reportHdkWarning (HdkWarnExtraComment (L l _)) = ===================================== compiler/GHC/Parser/PreProcess.hs ===================================== @@ -8,13 +8,19 @@ module GHC.Parser.PreProcess ( -- ppLexerDbg, lexer, lexerDbg, + initPpState, + initParserState, + initPragState, + PpState ) where import Data.Char +import qualified Data.Map as Map import qualified Data.Set as Set import Debug.Trace (trace) import GHC.Data.FastString import qualified GHC.Data.Strict as Strict +import GHC.Data.StringBuffer import GHC.Parser.Errors.Ppr () import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), PpState (..), Token (..)) import qualified GHC.Parser.Lexer as Lexer @@ -23,7 +29,26 @@ import GHC.Types.SrcLoc -- --------------------------------------------------------------------- -lexer, lexerDbg :: Bool -> (Located Token -> P a) -> P a +-- | Set parser options for parsing OPTIONS pragmas +initPragState :: Lexer.ParserOpts -> StringBuffer -> RealSrcLoc -> PState PpState +initPragState = Lexer.initPragState initPpState + +-- | Creates a parse state from a 'ParserOpts' value +initParserState :: Lexer.ParserOpts -> StringBuffer -> RealSrcLoc -> PState PpState +initParserState = Lexer.initParserState initPpState + +initPpState :: PpState +initPpState = + PpState + { pp_defines = Map.empty + , pp_continuation = [] + , pp_context = [] + , pp_accepting = True + } + +-- --------------------------------------------------------------------- + +lexer, lexerDbg :: Bool -> (Located Token -> P PpState a) -> P PpState a -- bypass for now, work in ghci lexer = Lexer.lexer lexerDbg = Lexer.lexerDbg @@ -141,11 +166,11 @@ lexerDbg = Lexer.lexerDbg -- in -- POk s r -setAccepting :: Bool -> P () +setAccepting :: Bool -> P PpState () setAccepting on = P $ \s -> POk s{pp = (pp s){pp_accepting = on}} () -getAccepting :: P Bool +getAccepting :: P PpState Bool getAccepting = P $ \s -> POk s (pp_accepting (pp s)) -- pp_context stack end ------------------- ===================================== compiler/GHC/Parser/Utils.hs ===================================== @@ -12,7 +12,8 @@ import GHC.Data.StringBuffer import GHC.Data.FastString import GHC.Types.SrcLoc -import qualified GHC.Parser.Lexer as Lexer (P (..), ParseResult(..), unP, initParserState) +import qualified GHC.Parser.Lexer as Lexer (P (..), ParseResult(..), unP ) +import qualified GHC.Parser.PreProcess as Lexer (initParserState, PpState) import GHC.Parser.Lexer (ParserOpts) import qualified GHC.Parser as Parser (parseStmt, parseModule, parseDeclaration, parseImport) @@ -50,7 +51,7 @@ isDecl pflags stmt = _ -> True Lexer.PFailed _ -> False -parseThing :: Lexer.P thing -> ParserOpts -> String -> Lexer.ParseResult thing +parseThing :: Lexer.P Lexer.PpState thing -> ParserOpts -> String -> Lexer.ParseResult Lexer.PpState thing parseThing parser opts stmt = do let buf = stringToStringBuffer stmt loc = mkRealSrcLoc (fsLit "") 1 1 ===================================== ghc/GHCi/UI.hs ===================================== @@ -77,7 +77,8 @@ import GHC.Builtin.Names import GHC.Builtin.Types( stringTyCon_RDR ) import GHC.Types.Name.Reader as RdrName ( getGRE_NameQualifier_maybes, getRdrName ) import GHC.Types.SrcLoc as SrcLoc -import qualified GHC.Parser.Lexer as Lexer +import qualified GHC.Parser.Lexer as Lexer hiding (initParserState) +import qualified GHC.Parser.PreProcess as Lexer (initParserState) import GHC.Parser.Header ( toArgs ) import qualified GHC.Parser.Header as Header import GHC.Types.PkgQual ===================================== utils/check-cpp/Main.hs ===================================== @@ -21,7 +21,8 @@ import qualified GHC.LanguageExtensions as LangExt import GHC.Parser.Errors.Ppr () import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), PpState (..), Token (..)) import qualified GHC.Parser.Lexer as GHC -import qualified GHC.Parser.Lexer as Lexer +import qualified GHC.Parser.Lexer as Lexer hiding (initParserState) +import qualified GHC.Parser.PreProcess as Lexer (initParserState) import GHC.Types.Error import GHC.Types.SrcLoc import GHC.Utils.Error @@ -49,7 +50,11 @@ showAst ast = -- ===================================================================== -ppLexer, ppLexerDbg :: Bool -> (Located Token -> P a) -> P a +type PP = P PpState + +-- ===================================================================== + +ppLexer, ppLexerDbg :: Bool -> (Located Token -> PP a) -> PP a -- Use this instead of 'lexer' in GHC.Parser to dump the tokens for debugging. ppLexerDbg queueComments cont = ppLexer queueComments contDbg where @@ -82,17 +87,17 @@ ppLexer queueComments cont = _ -> contInner tk ) -preprocessElse :: P () +preprocessElse :: PP () preprocessElse = do accepting <- getAccepting setAccepting (not accepting) -preprocessEnd :: P () +preprocessEnd :: PP () preprocessEnd = do -- TODO: nested context setAccepting True -processCppToks :: FastString -> P () +processCppToks :: FastString -> PP () processCppToks fs = do let get (L _ (ITcpp _ s)) = s @@ -102,7 +107,7 @@ processCppToks fs = do processCpp (reverse $ fs : map get cs) return () -processCpp :: [FastString] -> P () +processCpp :: [FastString] -> PP () processCpp fs = do -- traceM $ "processCpp: fs=" ++ show fs -- let s = cppInitial fs @@ -136,7 +141,7 @@ data CppState | CppNormal deriving (Show) -getCppState :: P CppState +getCppState :: PP CppState getCppState = do accepting <- getAccepting if accepting @@ -145,11 +150,11 @@ getCppState = do -- pp_context stack start ----------------- -pushContext :: Token -> P () +pushContext :: Token -> PP () pushContext new = P $ \s -> POk s{pp = (pp s){pp_context = new : pp_context (pp s)}} () -popContext :: P () +popContext :: PP () popContext = P $ \s -> let @@ -159,7 +164,7 @@ popContext = in POk s{pp = (pp s){pp_context = new_context}} () -peekContext :: P Token +peekContext :: PP Token peekContext = P $ \s -> let @@ -169,20 +174,20 @@ peekContext = in POk s r -setAccepting :: Bool -> P () +setAccepting :: Bool -> PP () setAccepting on = P $ \s -> POk s{pp = (pp s){pp_accepting = on}} () -getAccepting :: P Bool +getAccepting :: PP Bool getAccepting = P $ \s -> POk s (pp_accepting (pp s)) -- ------------------------------------- -pushContinuation :: Located Token -> P () +pushContinuation :: Located Token -> PP () pushContinuation new = P $ \s -> POk s{pp = (pp s){pp_continuation = new : pp_continuation (pp s)}} () -popContinuation :: P [Located Token] +popContinuation :: PP [Located Token] popContinuation = P $ \s -> POk s{pp = (pp s){pp_continuation = []}} (pp_continuation (pp s)) @@ -190,12 +195,12 @@ popContinuation = -- definitions start -------------------- -ppDefine :: String -> [String] -> P () +ppDefine :: String -> [String] -> PP () ppDefine name val = P $ \s -> -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () POk s{pp = (pp s){pp_defines = Map.insert (trace ("ppDefine:def=[" ++ name ++ "]") name) val (pp_defines (pp s))}} () -ppIsDefined :: String -> P Bool +ppIsDefined :: String -> PP Bool ppIsDefined def = P $ \s -> -- POk s (Map.member def (pp_defines (pp s))) POk s (Map.member (trace ("ppIsDefined:def=[" ++ def ++ "]") def) (pp_defines (pp s))) @@ -415,16 +420,16 @@ ghcWrapper libdir a = -- --------------------------------------------------------------------- -parseModuleNoHaddock :: P [Located Token] +parseModuleNoHaddock :: PP [Located Token] parseModuleNoHaddock = happySomeParser where -- happySomeParser = happyThen (happyParse 0#) (\x -> happyReturn (let {(HappyWrap35 x') = happyOut35 x} in x')) happySomeParser = (>>=) (happyParse 0) (\x -> return x) -happyParse :: Int -> P [Located Token] +happyParse :: Int -> PP [Located Token] happyParse start_state = happyNewToken start_state [] [] -happyNewToken :: Int -> [Int] -> [Located Token] -> P [Located Token] +happyNewToken :: Int -> [Int] -> [Located Token] -> PP [Located Token] happyNewToken action sts stk = -- lexer ppLexerDbg @@ -439,7 +444,7 @@ happyNewToken action sts stk = -- _ -> happyError' (tk, []) ) -happyDoAction :: Int -> Located Token -> Int -> [Int] -> [Located Token] -> P [Located Token] +happyDoAction :: Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] -- happyDoAction num tk action sts stk = P $ \s -> POk s tk happyDoAction num tk action sts stk = case num of @@ -455,7 +460,7 @@ happyDoAction num tk action sts stk = -- happyAccept j tk st sts (HappyStk ans _) = -- (happyTcHack j (happyTcHack st)) (happyReturn1 ans) -happyAccept :: Int -> Located Token -> Int -> [Int] -> [Located Token] -> P [Located Token] +happyAccept :: Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] happyAccept _j tk _st _sts stk = trace ("happyAccept:" ++ show tk) $ return stk @@ -463,28 +468,28 @@ happyAccept _j tk _st _sts stk = -- happyReturn1 :: a -> P a -- happyReturn1 = return -happyShift :: Int -> Int -> Located Token -> Int -> [Int] -> [Located Token] -> P [Located Token] +happyShift :: Int -> Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] happyShift new_state _i tk st sts stk = do happyNewToken new_state (st : sts) (tk : stk) -- happyShift new_state i tk st sts stk = -- happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) -happyFail :: [String] -> Int -> Located Token -> p2 -> p3 -> p4 -> P a +happyFail :: [String] -> Int -> Located Token -> p2 -> p3 -> p4 -> PP a happyFail explist i tk _old_st _ _stk = trace ("failing" ++ show explist) $ happyError_ explist i tk -happyError_ :: [String] -> p -> Located Token -> P a +happyError_ :: [String] -> p1 -> Located Token -> PP a happyError_ explist _ tk = happyError' (tk, explist) notHappyAtAll :: a notHappyAtAll = Prelude.error "Internal Happy error\n" -happyError' :: (Located Token, [String]) -> P a +happyError' :: (Located Token, [String]) -> PP a happyError' tk = (\(_tokens, _explist) -> happyError) tk -happyError :: P a +happyError :: PP a happyError = Lexer.srcParseFail -- ===================================================================== ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 267207c66495388c76297f9bd3f57454c021b9a9 +Subproject commit fd39bed22d4ac1d5f691f65391df8628f5693848 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/289fee545c92909f55f6c4a439be6d5d17fe8461 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/289fee545c92909f55f6c4a439be6d5d17fe8461 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 00:11:08 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 03 Oct 2023 20:11:08 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651cad9c76265_343253fd4ea04289348@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b0c5dfb9 by Andrew Lelechenko at 2023-10-03T20:10:37-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 903a870e by Andrew Lelechenko at 2023-10-03T20:10:37-04:00 Inline bucket_match - - - - - 4e09b8b9 by Ben Gamari at 2023-10-03T20:10:37-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - b6776454 by Krzysztof Gogolewski at 2023-10-03T20:10:38-04:00 Add a regression test for #24029 - - - - - eb467fc5 by sheaf at 2023-10-03T20:10:40-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - 6453b59a by Ben Gamari at 2023-10-03T20:10:40-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #23042. - - - - - fd31d659 by Cheng Shao at 2023-10-03T20:10:42-04:00 rts: fix incorrect ticket reference - - - - - 703a4505 by Ben Gamari at 2023-10-03T20:10:42-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 19 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - docs/users_guide/using-warnings.rst - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - m4/find_ld.m4 - rts/include/rts/ghc_ffi.h - rts/sm/NonMoving.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T24029.hs - testsuite/tests/simplCore/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2157,16 +2157,19 @@ of ``-W(no-)*``. :since: 8.4 The option :ghc-flag:`-Wpartial-fields` warns about a record field - `f` that is defined in some, but not all, the contructors of a - data type, because `f`'s record selector function may fail. For - exampe, the record selector function `f`, defined in the `Foo` - constructor record below, will fail when applied to ``Bar``, so - the compiler will emit a warning at its definition when - :ghc-flag:`-Wpartial-fields` is enabled. + ``f`` that is defined in some, but not all, of the constructors of a + data type, as such selector functions are partial. For example, when + :ghc-flag:`-Wpartial-fields` is enabled the compiler will emit a warning at + the definition of ``Foo`` below: :: + + data Foo = Foo { f :: Int } | Bar The warning is suppressed if the field name begins with an underscore. :: - data Foo = Foo { f :: Int } | Bar + data Foo = Foo { _f :: Int } | Bar + + Another related warning is :ghc-flag:`-Wincomplete-record-selectors`, + which warns at use sites rather than definition sites. .. ghc-flag:: -Wunused-packages :shortdesc: warn when package is requested on command line, but not needed. ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== m4/find_ld.m4 ===================================== @@ -70,19 +70,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) ===================================== rts/include/rts/ghc_ffi.h ===================================== @@ -1,5 +1,5 @@ /* - * wrapper working around #23586. + * wrapper working around #23568. * * (c) The University of Glasgow 2023 * ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== testsuite/tests/simplCore/should_compile/T24029.hs ===================================== @@ -0,0 +1,21 @@ +{-# OPTIONS_GHC -O #-} +module T24029 (surround) where + +data Buffer where + Buffer :: !Int -> Buffer + +newtype Builder = Builder (Buffer -> Buffer) + +c :: Builder -> Builder -> Builder +c (Builder f) (Builder g) = Builder (\b -> f (g b)) + +i :: Buffer -> Buffer +i (Buffer x) = Buffer x + +surround :: Builder -> Builder +surround f = f +{-# NOINLINE [1] surround #-} + +{-# RULES +"surround/surround" forall a. surround a = c (Builder (i . i)) a + #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -502,3 +502,4 @@ test('T23938', [extra_files(['T23938A.hs'])], multimod_compile, ['T23938', '-O - test('T23922a', normal, compile, ['-O']) test('T23952', [extra_files(['T23952a.hs'])], multimod_compile, ['T23952', '-v0 -O']) test('T24014', normal, compile, ['-dcore-lint']) +test('T24029', normal, compile, ['']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dad88a7b4ffb22c062ada80c070cf11aaed0f576...703a4505469edd30a44b33bc973fe0f10b2d78c2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dad88a7b4ffb22c062ada80c070cf11aaed0f576...703a4505469edd30a44b33bc973fe0f10b2d78c2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 00:51:41 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Tue, 03 Oct 2023 20:51:41 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/add-ddump-specialisations Message-ID: <651cb71d73fb1_34325310eb07ac30474f@gitlab.mail> Finley McIlwaine pushed new branch wip/add-ddump-specialisations at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/add-ddump-specialisations You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 03:40:02 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 23:40:02 -0400 Subject: [Git][ghc/ghc][wip/T23003] rts/nonmoving: Fix on LLP64 platforms Message-ID: <651cde9267c90_34325314b9dbb0317596@gitlab.mail> Ben Gamari pushed to branch wip/T23003 at Glasgow Haskell Compiler / GHC Commits: eba65885 by Ben Gamari at 2023-10-03T23:39:44-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - 1 changed file: - rts/sm/NonMoving.h Changes: ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK ((1ULL << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE (1ULL << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W ((1ULL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eba6588544165a8da4107e0dfde7ce2fbdd6d945 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eba6588544165a8da4107e0dfde7ce2fbdd6d945 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 03:49:51 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 03 Oct 2023 23:49:51 -0400 Subject: [Git][ghc/ghc][wip/T23003] rts/nonmoving: Fix on LLP64 platforms Message-ID: <651ce0dfe2386_34325314df22583232ab@gitlab.mail> Ben Gamari pushed to branch wip/T23003 at Glasgow Haskell Compiler / GHC Commits: 904f58b7 by Ben Gamari at 2023-10-03T23:49:45-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - 1 changed file: - rts/sm/NonMoving.h Changes: ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE ((uintptr_t)1 << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/904f58b777cd024e70415e1ab7d128b94fc3728b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/904f58b777cd024e70415e1ab7d128b94fc3728b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 04:08:03 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Wed, 04 Oct 2023 00:08:03 -0400 Subject: [Git][ghc/ghc][wip/t24032] Add -ddump-specialisations, -ddump-specialization Message-ID: <651ce52370c65_34325315b613e432771d@gitlab.mail> Finley McIlwaine pushed to branch wip/t24032 at Glasgow Haskell Compiler / GHC Commits: 24f12d07 by Finley McIlwaine at 2023-10-03T21:07:31-07:00 Add -ddump-specialisations, -ddump-specialization These flags will dump information about any specialisations generated as a result of pragmas or the specialiser. Resolves: #24032 - - - - - 7 changed files: - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Binds.hs - + compiler/GHC/Types/DumpSpecInfo.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst Changes: ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralisedNewtypeDeriving #-} +{-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -57,8 +58,11 @@ import GHC.Types.Var.Env import GHC.Types.Id import GHC.Types.Id.Info import GHC.Types.Error +import GHC.Types.DumpSpecInfo import GHC.Utils.Error ( mkMCDiagnostic ) +import GHC.Utils.Logger (Logger) +import qualified GHC.Utils.Logger as Logger import GHC.Utils.Monad ( foldlM, MonadIO ) import GHC.Utils.Misc import GHC.Utils.Outputable @@ -646,6 +650,7 @@ specProgram guts@(ModGuts { mg_module = this_mod , mg_rules = local_rules , mg_binds = binds }) = do { dflags <- getDynFlags + ; logger <- Logger.getLogger ; rule_env <- initRuleEnv guts -- See Note [Fire rules in the specialiser] @@ -660,7 +665,8 @@ specProgram guts@(ModGuts { mg_module = this_mod -- bindersOfBinds binds , se_module = this_mod , se_rules = rule_env - , se_dflags = dflags } + , se_dflags = dflags + , se_logger = logger } go [] = return ([], emptyUDs) go (bind:binds) = do (bind', binds', uds') <- specBind TopLevel top_env bind $ \_ -> @@ -1171,6 +1177,7 @@ data SpecEnv , se_module :: Module , se_rules :: RuleEnv -- From the home package and this module , se_dflags :: DynFlags + , se_logger :: Logger } instance Outputable SpecEnv where @@ -1673,6 +1680,7 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs is_dfun = isDFunId fn dflags = se_dflags env this_mod = se_module env + logger = se_logger env -- Figure out whether the function has an INLINE pragma -- See Note [Inline specialisations] @@ -1744,7 +1752,7 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs -- See Note [Specialisations Must Be Lifted] -- C.f. GHC.Core.Opt.WorkWrap.Utils.needsVoidWorkerArg add_void_arg = isUnliftedType spec_fn_ty1 && not (isJoinId fn) - (spec_bndrs, spec_rhs, spec_fn_ty) + (spec_bndrs, spec_rhs, spec_fn_type) | add_void_arg = ( voidPrimId : spec_bndrs1 , Lam voidArgId spec_rhs1 , mkVisFunTyMany unboxedUnitTy spec_fn_ty1) @@ -1788,7 +1796,7 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs DFunId is_nt -> DFunId is_nt _ -> VanillaId - ; spec_fn <- newSpecIdSM (idName fn) spec_fn_ty spec_fn_details spec_fn_info + ; spec_fn <- newSpecIdSM (idName fn) spec_fn_type spec_fn_details spec_fn_info ; let -- The rule to put in the function's specialisation is: -- forall x @b d1' d2'. @@ -1805,12 +1813,27 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs spec_f_w_arity = spec_fn - _rule_trace_doc = vcat [ ppr fn <+> dcolon <+> ppr fn_type - , ppr spec_fn <+> dcolon <+> ppr spec_fn_ty + unspec_fn_doc = ppr fn <+> dcolon <+> ppr fn_type + spec_fn_doc = ppr spec_fn <+> dcolon <+> ppr spec_fn_type + + _rule_trace_doc = vcat [ unspec_fn_doc + , spec_fn_doc , ppr rhs_bndrs, ppr call_args , ppr spec_rule ] + -- Dump the specialisation if -ddump-specialisations is enabled + ; dumpSpecialisationWithLogger @Module @Id @Type logger $ + DumpSpecInfo + { dumpSpecInfo_module = this_mod + , dumpSpecInfo_fromPragma = False + , dumpSpecInfo_polyId = fn + , dumpSpecInfo_polyTy = fn_type + , dumpSpecInfo_specId = spec_fn + , dumpSpecInfo_specTy = spec_fn_type + , dumpSpecInfo_dicts = map varType rule_bndrs + } + ; -- pprTrace "spec_call: rule" _rule_trace_doc return ( spec_rule : rules_acc , (spec_f_w_arity, spec_rhs) : pairs_acc @@ -3439,13 +3462,13 @@ newtype SpecM result } deriving newtype (Functor, Applicative, Monad, MonadIO) --- See Note [Uniques for wired-in prelude things and known masks] in GHC.Builtin.Uniques -specMask :: Char -specMask = 't' +-- See Note [Uniques for wired-in prelude things and known tags] in GHC.Builtin.Uniques +specTag :: Char +specTag = 't' instance MonadUnique SpecM where - getUniqueSupplyM = liftIO $ mkSplitUniqSupply specMask - getUniqueM = liftIO $ uniqFromMask specMask + getUniqueSupplyM = liftIO $ mkSplitUniqSupply specTag + getUniqueM = liftIO $ uniqFromTag specTag runSpecM :: SpecM a -> CoreM a runSpecM = liftIO . unSpecM ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -109,6 +109,7 @@ data DumpFlag | Opt_D_dump_simpl_iterations | Opt_D_dump_spec | Opt_D_dump_spec_constr + | Opt_D_dump_specialisations | Opt_D_dump_prep | Opt_D_dump_late_cc | Opt_D_dump_stg_from_core -- ^ Initial STG (CoreToStg output) ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -1440,6 +1440,10 @@ dynamic_flags_deps = [ (setDumpFlag Opt_D_dump_spec) , make_ord_flag defGhcFlag "ddump-spec-constr" (setDumpFlag Opt_D_dump_spec_constr) + , make_ord_flag defGhcFlag "ddump-specialisations" + (setDumpFlag Opt_D_dump_specialisations) + , make_ord_flag defGhcFlag "ddump-specializations" + (setDumpFlag Opt_D_dump_specialisations) , make_ord_flag defGhcFlag "ddump-prep" (setDumpFlag Opt_D_dump_prep) , make_ord_flag defGhcFlag "ddump-late-cc" ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -1,6 +1,5 @@ - {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeApplications #-} {- (c) The University of Glasgow 2006 @@ -66,6 +65,7 @@ import GHC.Types.Name import GHC.Types.Var.Set import GHC.Types.Var.Env import GHC.Types.Var( EvVar ) +import GHC.Types.DumpSpecInfo import GHC.Types.SrcLoc import GHC.Types.Basic import GHC.Types.Unique.Set( nonDetEltsUniqSet ) @@ -806,6 +806,18 @@ dsSpec mb_poly_rhs (L loc (SpecPrag poly_id spec_co spec_inl)) ; dsWarnOrphanRule rule + -- Dump the specialisation if -ddump-specialisations is enabled + ; dumpSpecialisation @Module @Id @Type $ + DumpSpecInfo + { dumpSpecInfo_module = this_mod + , dumpSpecInfo_fromPragma = True + , dumpSpecInfo_polyId = poly_id + , dumpSpecInfo_polyTy = idType poly_id + , dumpSpecInfo_specId = spec_id + , dumpSpecInfo_specTy = spec_ty + , dumpSpecInfo_dicts = map varType rule_bndrs + } + ; return (Just (unitOL (spec_id, spec_rhs), rule)) -- NB: do *not* use makeCorePair on (spec_id,spec_rhs), because -- makeCorePair overwrites the unfolding, which we have @@ -846,7 +858,6 @@ dsSpec mb_poly_rhs (L loc (SpecPrag poly_id spec_co spec_inl)) rule_act | no_act_spec = inlinePragmaActivation id_inl -- Inherit | otherwise = spec_prag_act -- Specified by user - dsWarnOrphanRule :: CoreRule -> DsM () dsWarnOrphanRule rule = when (isOrphan (ru_orphan rule)) $ ===================================== compiler/GHC/Types/DumpSpecInfo.hs ===================================== @@ -0,0 +1,106 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE StandaloneDeriving #-} + +-- | A module for the DumpSpecInfo type whose values contain information about +-- specialisations generated by GHC. Output by -ddump-specialisations flag. +module GHC.Types.DumpSpecInfo + ( DumpSpecInfo(..) + , DumpSpecInfoTypes(..) + , dumpSpecialisation + , dumpSpecialisationWithLogger + ) where + +import GHC.Core.Type +import GHC.Driver.Flags (DumpFlag(..)) +import GHC.Prelude +import GHC.Types.Id +import GHC.Unit.Module +import GHC.Utils.Logger +import GHC.Utils.Outputable + +import Control.Monad +import Control.Monad.IO.Class + +data DumpSpecInfoTypes = + DumpSpecInfoCustom + | DumpSpecInfoString + +data DumpSpecInfo mod id ty = DumpSpecInfo + { -- | Module the specialisation was generated in ('Module' in GHC) + dumpSpecInfo_module :: !mod + + -- | Was this specialisation the result of a pragma? + , dumpSpecInfo_fromPragma :: !Bool + + -- | Overloaded function identifier ('Id' in GHC) + , dumpSpecInfo_polyId :: !id + -- | Overloaded function type ('Type' in GHC) + , dumpSpecInfo_polyTy :: !ty + + -- | Specialised function identifier ('Identifier' in GHC) + , dumpSpecInfo_specId :: !id + -- | Specialised function type ('Type' in GHC) + , dumpSpecInfo_specTy :: !ty + + -- | The types of the dictionaries the specialisation is for (list of 'Type' + -- in GHC) + , dumpSpecInfo_dicts :: ![ty] + } + +-- | This instance is intentionally written so the following composition +-- succeeds: +-- +-- @read \@(DumpSpecInfo String String String) . show \@(DumpSpecInfo Module Id Type)@ +instance Show (DumpSpecInfo Module Id Type) where + show DumpSpecInfo{..} = + renderWithContext + defaultSDocContext + { sdocLineLength = maxBound + } + $ withPprStyle (mkDumpStyle alwaysQualify) + $ vcat + [ text "Specialisation generated:" + , nest 2 $ text "DumpSpecInfo" <+> + ( braces . sep $ + [ text "dumpSpecInfo_module" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_module) <> comma + , text "dumpSpecInfo_fromPragma" <+> equals <+> ppr dumpSpecInfo_fromPragma <> comma + , text "dumpSpecInfo_polyId" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_polyId) <> comma + , text "dumpSpecInfo_polyTy" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_polyTy) <> comma + , text "dumpSpecInfo_specId" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_specId) <> comma + , text "dumpSpecInfo_specTy" <+> equals <+> doubleQuotes (ppr dumpSpecInfo_specTy) <> comma + , text "dumpSpecInfo_dicts" <+> equals <+> ppr (map (doubleQuotes . ppr) dumpSpecInfo_dicts) + ] + ) + ] + +deriving instance Show (DumpSpecInfo String String String) +deriving instance Read (DumpSpecInfo String String String) +deriving instance Eq (DumpSpecInfo String String String) + +dumpSpecialisation + :: forall mod id ty m. (MonadIO m, HasLogger m, Show (DumpSpecInfo mod id ty)) + => DumpSpecInfo mod id ty + -> m () +dumpSpecialisation spec_info = do + logger <- getLogger + dumpSpecialisationWithLogger logger spec_info + +dumpSpecialisationWithLogger + :: forall mod id ty m. (MonadIO m, Show (DumpSpecInfo mod id ty)) + => Logger + -> DumpSpecInfo mod id ty + -> m () +dumpSpecialisationWithLogger logger spec_info = do + when (logHasDumpFlag logger Opt_D_dump_specialisations) $ + log_specialisation logger (text $ show spec_info) + +log_specialisation :: MonadIO m => Logger -> SDoc -> m () +log_specialisation logger doc = + liftIO $ + putDumpFileMaybe logger + Opt_D_dump_specialisations + "" + FormatText + doc ===================================== compiler/ghc.cabal.in ===================================== @@ -813,6 +813,7 @@ Library GHC.Types.CostCentre.State GHC.Types.Cpr GHC.Types.Demand + GHC.Types.DumpSpecInfo GHC.Types.Error GHC.Types.Error.Codes GHC.Types.FieldLabel ===================================== docs/users_guide/debugging.rst ===================================== @@ -343,6 +343,19 @@ subexpression elimination pass. Dump output of the SpecConstr specialisation pass +.. ghc-flag:: -ddump-specializations + :shortdesc: Dump information about generated specialisations + :type: dynamic + + Equivalent to :ghc-flag:`-ddump-specialisations` + +.. ghc-flag:: -ddump-specialisations + :shortdesc: Dump information about generated specialisations + :type: dynamic + + Dump information about any specialisations resulting from pragmas or the + specialiser logic. + .. ghc-flag:: -ddump-rules :shortdesc: Dump rewrite rules :type: dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/24f12d076a5a1ccfa57f2ad3205ae08f5e4659c8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/24f12d076a5a1ccfa57f2ad3205ae08f5e4659c8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 05:02:16 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 01:02:16 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651cf1d847a97_34325316a4408c3505a7@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 83e5368d by Andrew Lelechenko at 2023-10-04T01:01:36-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 5f609a5b by Andrew Lelechenko at 2023-10-04T01:01:36-04:00 Inline bucket_match - - - - - 0c84ded0 by Ben Gamari at 2023-10-04T01:01:36-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - b9f07804 by Krzysztof Gogolewski at 2023-10-04T01:01:37-04:00 Add a regression test for #24029 - - - - - 697d1ea1 by sheaf at 2023-10-04T01:01:39-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - 7ce19e36 by Cheng Shao at 2023-10-04T01:01:40-04:00 rts: fix incorrect ticket reference - - - - - ae6f38a3 by Ben Gamari at 2023-10-04T01:01:41-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 18 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - docs/users_guide/using-warnings.rst - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - m4/find_ld.m4 - rts/include/rts/ghc_ffi.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T24029.hs - testsuite/tests/simplCore/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2157,16 +2157,19 @@ of ``-W(no-)*``. :since: 8.4 The option :ghc-flag:`-Wpartial-fields` warns about a record field - `f` that is defined in some, but not all, the contructors of a - data type, because `f`'s record selector function may fail. For - exampe, the record selector function `f`, defined in the `Foo` - constructor record below, will fail when applied to ``Bar``, so - the compiler will emit a warning at its definition when - :ghc-flag:`-Wpartial-fields` is enabled. + ``f`` that is defined in some, but not all, of the constructors of a + data type, as such selector functions are partial. For example, when + :ghc-flag:`-Wpartial-fields` is enabled the compiler will emit a warning at + the definition of ``Foo`` below: :: + + data Foo = Foo { f :: Int } | Bar The warning is suppressed if the field name begins with an underscore. :: - data Foo = Foo { f :: Int } | Bar + data Foo = Foo { _f :: Int } | Bar + + Another related warning is :ghc-flag:`-Wincomplete-record-selectors`, + which warns at use sites rather than definition sites. .. ghc-flag:: -Wunused-packages :shortdesc: warn when package is requested on command line, but not needed. ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== m4/find_ld.m4 ===================================== @@ -70,19 +70,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) ===================================== rts/include/rts/ghc_ffi.h ===================================== @@ -1,5 +1,5 @@ /* - * wrapper working around #23586. + * wrapper working around #23568. * * (c) The University of Glasgow 2023 * ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== testsuite/tests/simplCore/should_compile/T24029.hs ===================================== @@ -0,0 +1,21 @@ +{-# OPTIONS_GHC -O #-} +module T24029 (surround) where + +data Buffer where + Buffer :: !Int -> Buffer + +newtype Builder = Builder (Buffer -> Buffer) + +c :: Builder -> Builder -> Builder +c (Builder f) (Builder g) = Builder (\b -> f (g b)) + +i :: Buffer -> Buffer +i (Buffer x) = Buffer x + +surround :: Builder -> Builder +surround f = f +{-# NOINLINE [1] surround #-} + +{-# RULES +"surround/surround" forall a. surround a = c (Builder (i . i)) a + #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -502,3 +502,4 @@ test('T23938', [extra_files(['T23938A.hs'])], multimod_compile, ['T23938', '-O - test('T23922a', normal, compile, ['-O']) test('T23952', [extra_files(['T23952a.hs'])], multimod_compile, ['T23952', '-v0 -O']) test('T24014', normal, compile, ['-dcore-lint']) +test('T24029', normal, compile, ['']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/703a4505469edd30a44b33bc973fe0f10b2d78c2...ae6f38a340e5facc8f27921fb0a0ea2398827b69 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/703a4505469edd30a44b33bc973fe0f10b2d78c2...ae6f38a340e5facc8f27921fb0a0ea2398827b69 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:03:20 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 04 Oct 2023 05:03:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/git-fetch-failure Message-ID: <651d2a58d0c0_3432531c6001dc4000d5@gitlab.mail> Bryan R pushed new branch wip/git-fetch-failure at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/git-fetch-failure You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:03:52 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 04 Oct 2023 05:03:52 -0400 Subject: [Git][ghc/ghc][wip/git-fetch-failure] Work around perf note fetch failure Message-ID: <651d2a7839116_3432531c98f8c0400262@gitlab.mail> Bryan R pushed to branch wip/git-fetch-failure at Glasgow Haskell Compiler / GHC Commits: bd94e760 by Bryan Richter at 2023-10-04T12:03:33+03:00 Work around perf note fetch failure Addresses #24055. - - - - - 1 changed file: - .gitlab/test-metrics.sh Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git fetch -c http.postBuffer 2097152 -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd94e760a9ffec436c5c44cd18f34126876720df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd94e760a9ffec436c5c44cd18f34126876720df You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:14:55 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 04 Oct 2023 05:14:55 -0400 Subject: [Git][ghc/ghc][wip/git-fetch-failure] Work around perf note fetch failure Message-ID: <651d2d0fe7f9f_3432531ce1b394407320@gitlab.mail> Bryan R pushed to branch wip/git-fetch-failure at Glasgow Haskell Compiler / GHC Commits: d0c09a9a by Bryan Richter at 2023-10-04T12:13:17+03:00 Work around perf note fetch failure Addresses #24055. - - - - - 1 changed file: - .gitlab/test-metrics.sh Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer 2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0c09a9a7082d1c88f23e468425c74e4f757ffa0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0c09a9a7082d1c88f23e468425c74e4f757ffa0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:14:52 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Oct 2023 05:14:52 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Correctly compute cross-prefix Message-ID: <651d2d0c4c18e_3432531ce1b3944071e0@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 5c0f83fe by Matthew Pickering at 2023-10-04T10:12:02+01:00 Correctly compute cross-prefix - - - - - 3 changed files: - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Settings/Builders/RunTest.hs - testsuite/ghc-config/ghc-config.hs Changes: ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -43,6 +43,7 @@ data TestSetting = TestHostOS | TestLeadingUnderscore | TestGhcPackageDb | TestGhcLibDir + | TestCrossCompiling deriving (Show) -- | Lookup a test setting in @ghcconfig@ file. @@ -74,6 +75,7 @@ testSetting key = do TestLeadingUnderscore -> "LeadingUnderscore" TestGhcPackageDb -> "GhcGlobalPackageDb" TestGhcLibDir -> "GhcLibdir" + TestCrossCompiling -> "CrossCompiling" -- | Get the RTS ways of the test compiler testRTSSettings :: Action [String] ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -322,14 +322,18 @@ runTestBuilderArgs = builder Testsuite ? do -- | Command line arguments for running GHC's test script. getTestArgs :: Args getTestArgs = do - stage <- getStage -- targets specified in the TEST env var testEnvTargets <- maybe [] words <$> expr (liftIO $ lookupEnv "TEST") args <- expr $ userSetting defaultTestArgs bindir <- expr $ getBinaryDirectory (testCompiler args) compiler <- expr $ getCompilerPath (testCompiler args) globalVerbosity <- shakeVerbosity <$> expr getShakeOptions - cross_prefix <- expr (crossPrefix (succStage stage)) + + -- MP: Is it better to compute cross_prefix from testCompiler? + cross <- expr $ getBooleanSetting TestCrossCompiling + test_target <- expr $ getTestSetting TestTARGETPLATFORM + let cross_prefix = if cross then test_target ++ "-" else "" + -- the testsuite driver will itself tell us if we need to generate the docs target -- So we always pass the haddock path if the hadrian configuration allows us to build -- docs ===================================== testsuite/ghc-config/ghc-config.hs ===================================== @@ -28,6 +28,7 @@ main = do getGhcFieldOrFail fields "GhcRTSWays" "RTS ways" getGhcFieldOrFail fields "GhcLibdir" "LibDir" getGhcFieldOrFail fields "GhcGlobalPackageDb" "Global Package DB" + getGhcFieldOrFail fields "CrossCompiling" "cross compiling" getGhcFieldOrDefault fields "GhcDynamic" "GHC Dynamic" "NO" getGhcFieldOrDefault fields "GhcProfiled" "GHC Profiled" "NO" getGhcFieldOrDefault fields "LeadingUnderscore" "Leading underscore" "NO" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c0f83feabafa09d4ec34897fb7012aa7bf8557c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c0f83feabafa09d4ec34897fb7012aa7bf8557c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:42:22 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 05:42:22 -0400 Subject: [Git][ghc/ghc][master] Simplify and correct nasty case in coercion opt Message-ID: <651d337ed93a4_18f5291361cc7653f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 2 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -95,10 +95,10 @@ module GHC.Core.Coercion ( -- ** Lifting liftCoSubst, liftCoSubstTyVar, liftCoSubstWith, liftCoSubstWithEx, emptyLiftingContext, extendLiftingContext, extendLiftingContextAndInScope, - liftCoSubstVarBndrUsing, isMappedByLC, + liftCoSubstVarBndrUsing, isMappedByLC, extendLiftingContextCvSubst, mkSubstLiftingContext, zapLiftingContext, - substForAllCoBndrUsingLC, lcSubst, lcInScopeSet, + substForAllCoBndrUsingLC, lcLookupCoVar, lcInScopeSet, LiftCoEnv, LiftingContext(..), liftEnvSubstLeft, liftEnvSubstRight, substRightCo, substLeftCo, swapLiftCoEnv, lcSubstLeft, lcSubstRight, @@ -1991,6 +1991,15 @@ extendLiftingContext (LC subst env) tv arg | otherwise = LC subst (extendVarEnv env tv arg) +-- | Extend the substitution component of a lifting context with +-- a new binding for a coercion variable. Used during coercion optimisation. +extendLiftingContextCvSubst :: LiftingContext + -> CoVar + -> Coercion + -> LiftingContext +extendLiftingContextCvSubst (LC subst env) cv co + = LC (extendCvSubst subst cv co) env + -- | Extend a lifting context with a new mapping, and extend the in-scope set extendLiftingContextAndInScope :: LiftingContext -- ^ Original LC -> TyCoVar -- ^ new variable to map... @@ -2298,9 +2307,9 @@ liftEnvSubst selector subst lc_env where equality_ty = selector (coercionKind co) --- | Extract the underlying substitution from the LiftingContext -lcSubst :: LiftingContext -> Subst -lcSubst (LC subst _) = subst +-- | Lookup a 'CoVar' in the substitution in a 'LiftingContext' +lcLookupCoVar :: LiftingContext -> CoVar -> Maybe Coercion +lcLookupCoVar (LC subst _) cv = lookupCoVar subst cv -- | Get the 'InScopeSet' from a 'LiftingContext' lcInScopeSet :: LiftingContext -> InScopeSet ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -310,14 +310,15 @@ opt_co4 env sym rep r (FunCo _r afl afr cow co1 co2) !(afl', afr') = swapSym sym (afl, afr) opt_co4 env sym rep r (CoVarCo cv) - | Just co <- lookupCoVar (lcSubst env) cv + | Just co <- lcLookupCoVar env cv -- see Note [Forall over coercion] for why + -- this is the right thing here = opt_co4_wrap (zapLiftingContext env) sym rep r co | ty1 `eqType` ty2 -- See Note [Optimise CoVarCo to Refl] = mkReflCo (chooseRole rep r) ty1 | otherwise - = assert (isCoVar cv1 ) + = assert (isCoVar cv1) $ wrapRole rep r $ wrapSym sym $ CoVarCo cv1 @@ -414,6 +415,40 @@ opt_co4 env sym rep r (LRCo lr co) pick_lr CLeft (l, _) = l pick_lr CRight (_, r) = r +{- +Note [Forall over coercion] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Example: + type (:~:) :: forall k. k -> k -> Type + Refl :: forall k (a :: k) (b :: k). forall (cv :: (~#) k k a b). (:~:) k a b + k1,k2,k3,k4 :: Type + eta :: (k1 ~# k2) ~# (k3 ~# k4) == ((~#) Type Type k1 k2) ~# ((~#) Type Type k3 k4) + co1_3 :: k1 ~# k3 + co2_4 :: k2 ~# k4 + nth 2 eta :: k1 ~# k3 + nth 3 eta :: k2 ~# k4 + co11_31 :: ~# (sym co1_3) + co22_24 :: ~# co2_4 + (forall (cv :: eta). Refl co1_3 co2_4 (co11_31 ;; cv ;; co22_24)) :: + (forall (cv :: k1 ~# k2). Refl Type k1 k2 ( ;; cv ;; ) ~# + (forall (cv :: k3 ~# k4). Refl Type k3 k4 + (sym co1_3 ;; nth 2 eta ;; cv ;; sym (nth 3 eta) ;; co2_4)) + co1_2 :: k1 ~# k2 + co3_4 :: k3 ~# k4 + co5 :: co1_2 ~# co3_4 + InstCo (forall (cv :: eta). Refl co1_3 co2_4 (co11_31 ;; cv ;; co22_24)) co5 :: + (Refl Type k1 k2 ( ;; cv ;; ))[cv |-> co1_2] ~# + (Refl Type k3 k4 (sym co1_3 ;; nth 2 eta ;; cv ;; sym (nth 3 eta) ;; co2_4))[cv |-> co3_4] + == + (Refl Type k1 k2 ( ;; co1_2 ;; )) ~# + (Refl Type k3 k4 (sym co1_3 ;; nth 2 eta ;; co3_4 ;; sym (nth 3 eta) ;; co2_4)) + ==> + Refl co1_3 co2_4 (co11_31 ;; co1_2 ;; co22_24) +Conclusion: Because of the way this all works, we want to put in the *left-hand* +coercion in co5's type. (In the code, co5 is called `arg`.) +So we extend the environment binding cv to arg's left-hand type. +-} + -- See Note [Optimising InstCo] opt_co4 env sym rep r (InstCo co1 arg) -- forall over type... @@ -425,12 +460,10 @@ opt_co4 env sym rep r (InstCo co1 arg) -- tv |-> (t1 :: k1) ~ (((t2 :: k2) |> (sym kind_co)) :: k1) sym rep r co_body - -- forall over coercion... - | Just (cv, _visL, _visR, kind_co, co_body) <- splitForAllCo_co_maybe co1 + -- See Note [Forall over coercion] + | Just (cv, _visL, _visR, _kind_co, co_body) <- splitForAllCo_co_maybe co1 , CoercionTy h1 <- t1 - , CoercionTy h2 <- t2 - = let new_co = mk_new_co cv (opt_co4_wrap env sym False Nominal kind_co) h1 h2 - in opt_co4_wrap (extendLiftingContext env cv new_co) sym rep r co_body + = opt_co4_wrap (extendLiftingContextCvSubst env cv h1) sym rep r co_body -- See if it is a forall after optimization -- If so, do an inefficient one-variable substitution, then re-optimize @@ -441,12 +474,10 @@ opt_co4 env sym rep r (InstCo co1 arg) (mkCoherenceRightCo Nominal t2' (mkSymCo kind_co') arg')) False False r' co_body' - -- forall over coercion... - | Just (cv', _visL, _visR, kind_co', co_body') <- splitForAllCo_co_maybe co1' + -- See Note [Forall over coercion] + | Just (cv', _visL, _visR, _kind_co', co_body') <- splitForAllCo_co_maybe co1' , CoercionTy h1' <- t1' - , CoercionTy h2' <- t2' - = let new_co = mk_new_co cv' kind_co' h1' h2' - in opt_co4_wrap (extendLiftingContext (zapLiftingContext env) cv' new_co) + = opt_co4_wrap (extendLiftingContextCvSubst (zapLiftingContext env) cv' h1') False False r' co_body' | otherwise = InstCo co1' arg' @@ -467,20 +498,6 @@ opt_co4 env sym rep r (InstCo co1 arg) Pair t1 t2 = coercionKind sym_arg Pair t1' t2' = coercionKind arg' - mk_new_co cv kind_co h1 h2 - = let -- h1 :: (t1 ~ t2) - -- h2 :: (t3 ~ t4) - -- kind_co :: (t1 ~ t2) ~ (t3 ~ t4) - -- n1 :: t1 ~ t3 - -- n2 :: t2 ~ t4 - -- new_co = (h1 :: t1 ~ t2) ~ ((n1;h2;sym n2) :: t1 ~ t2) - r2 = coVarRole cv - kind_co' = downgradeRole r2 Nominal kind_co - n1 = mkSelCo (SelTyCon 2 r2) kind_co' - n2 = mkSelCo (SelTyCon 3 r2) kind_co' - in mkProofIrrelCo Nominal (Refl (coercionType h1)) h1 - (n1 `mkTransCo` h2 `mkTransCo` (mkSymCo n2)) - opt_co4 env sym _rep r (KindCo co) = assert (r == Nominal) $ let kco' = promoteCoercion co in View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bc2047834c8e6fb5041d257b5bfe0f1402e3ef28 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bc2047834c8e6fb5041d257b5bfe0f1402e3ef28 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:42:57 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 05:42:57 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651d33a1273c4_18f52912db6c799cf@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - 10 changed files: - compiler/GHC/Data/FastString.hs - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc2047834c8e6fb5041d257b5bfe0f1402e3ef28...4e46dc2b009bcd08576a9e765d413cc2a66c6e15 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc2047834c8e6fb5041d257b5bfe0f1402e3ef28...4e46dc2b009bcd08576a9e765d413cc2a66c6e15 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:43:51 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 05:43:51 -0400 Subject: [Git][ghc/ghc][master] configure: Fix #21712 again Message-ID: <651d33d7e11c9_18f52912d7848481e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 1 changed file: - m4/find_ld.m4 Changes: ===================================== m4/find_ld.m4 ===================================== @@ -70,19 +70,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f6b2751f58df5f4f83caa7a7ca56e66659d02b09 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f6b2751f58df5f4f83caa7a7ca56e66659d02b09 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:44:58 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 05:44:58 -0400 Subject: [Git][ghc/ghc][master] Add a regression test for #24029 Message-ID: <651d341aa0c77_18f52912db6c9143c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 2 changed files: - + testsuite/tests/simplCore/should_compile/T24029.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== testsuite/tests/simplCore/should_compile/T24029.hs ===================================== @@ -0,0 +1,21 @@ +{-# OPTIONS_GHC -O #-} +module T24029 (surround) where + +data Buffer where + Buffer :: !Int -> Buffer + +newtype Builder = Builder (Buffer -> Buffer) + +c :: Builder -> Builder -> Builder +c (Builder f) (Builder g) = Builder (\b -> f (g b)) + +i :: Buffer -> Buffer +i (Buffer x) = Buffer x + +surround :: Builder -> Builder +surround f = f +{-# NOINLINE [1] surround #-} + +{-# RULES +"surround/surround" forall a. surround a = c (Builder (i . i)) a + #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -502,3 +502,4 @@ test('T23938', [extra_files(['T23938A.hs'])], multimod_compile, ['T23938', '-O - test('T23922a', normal, compile, ['-O']) test('T23952', [extra_files(['T23952a.hs'])], multimod_compile, ['T23952', '-v0 -O']) test('T24014', normal, compile, ['-dcore-lint']) +test('T24029', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2f0a101dca5ced29072b87a8f7a030e598d00d1a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2f0a101dca5ced29072b87a8f7a030e598d00d1a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:45:55 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 05:45:55 -0400 Subject: [Git][ghc/ghc][master] Fix non-symbolic children lookup of fixity decl Message-ID: <651d34539f5b5_18f52912daf494737@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - 3 changed files: - compiler/GHC/Types/Name/Reader.hs - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cee3fd7febdd97a9b4bcae7dddafe69b166149c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cee3fd7febdd97a9b4bcae7dddafe69b166149c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:48:17 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 05:48:17 -0400 Subject: [Git][ghc/ghc][master] rts: fix incorrect ticket reference Message-ID: <651d34e15a633_18f52912d7701027ca@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - 1 changed file: - rts/include/rts/ghc_ffi.h Changes: ===================================== rts/include/rts/ghc_ffi.h ===================================== @@ -1,5 +1,5 @@ /* - * wrapper working around #23586. + * wrapper working around #23568. * * (c) The University of Glasgow 2023 * View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4785b3337291cb89ab20f8654741ddc11f36168 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4785b3337291cb89ab20f8654741ddc11f36168 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:48:47 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 05:48:47 -0400 Subject: [Git][ghc/ghc][master] users-guide: Fix discussion of -Wpartial-fields Message-ID: <651d34ffd1157_18f52912db0810292@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 1 changed file: - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2157,16 +2157,19 @@ of ``-W(no-)*``. :since: 8.4 The option :ghc-flag:`-Wpartial-fields` warns about a record field - `f` that is defined in some, but not all, the contructors of a - data type, because `f`'s record selector function may fail. For - exampe, the record selector function `f`, defined in the `Foo` - constructor record below, will fail when applied to ``Bar``, so - the compiler will emit a warning at its definition when - :ghc-flag:`-Wpartial-fields` is enabled. + ``f`` that is defined in some, but not all, of the constructors of a + data type, as such selector functions are partial. For example, when + :ghc-flag:`-Wpartial-fields` is enabled the compiler will emit a warning at + the definition of ``Foo`` below: :: + + data Foo = Foo { f :: Int } | Bar The warning is suppressed if the field name begins with an underscore. :: - data Foo = Foo { f :: Int } | Bar + data Foo = Foo { _f :: Int } | Bar + + Another related warning is :ghc-flag:`-Wincomplete-record-selectors`, + which warns at use sites rather than definition sites. .. ghc-flag:: -Wunused-packages :shortdesc: warn when package is requested on command line, but not needed. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e037f45940a60027a6d95627c2ab1b2676acb9a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e037f45940a60027a6d95627c2ab1b2676acb9a4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 09:58:01 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Oct 2023 05:58:01 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Move predicates to --info rather than +RTS --info Message-ID: <651d37299255_18f52912daf4113581@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 66da8fae by Matthew Pickering at 2023-10-04T10:56:43+01:00 Move predicates to --info rather than +RTS --info - - - - - 3 changed files: - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Settings/Builders/RunTest.hs - testsuite/ghc-config/ghc-config.hs Changes: ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -23,8 +23,8 @@ testConfigFile = buildRoot <&> (-/- "test/ghcconfig") data TestSetting = TestHostOS | TestWORDSIZE | TestTARGETPLATFORM - | TestTargetOS_CPP - | TestTargetARCH_CPP + | TestTargetOS + | TestTargetARCH | TestRTSWay | TestGhcStage | TestGhcDebugAssertions @@ -55,8 +55,8 @@ testSetting key = do TestHostOS -> "HostOS" TestWORDSIZE -> "WORDSIZE" TestTARGETPLATFORM -> "TARGETPLATFORM" - TestTargetOS_CPP -> "TargetOS_CPP" - TestTargetARCH_CPP -> "TargetARCH_CPP" + TestTargetOS -> "TargetOS" + TestTargetARCH -> "TargetARCH" TestRTSWay -> "RTSWay" TestGhcStage -> "GhcStage" TestGhcDebugAssertions -> "GhcDebugAssertions" ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -21,6 +21,8 @@ import Settings.Program import qualified Context.Type import GHC.Toolchain.Target +import Text.Read +import GHC.Platform.ArchOS getTestSetting :: TestSetting -> Action String getTestSetting key = testSetting key @@ -167,10 +169,13 @@ outOfTreeCompilerArgs = do debugAssertions <- getBooleanSetting TestGhcDebugAssertions + let readArch :: String -> Maybe Arch + readArch = readMaybe + os <- getTestSetting TestHostOS - arch <- getTestSetting TestTargetARCH_CPP + arch <- maybe "unknown" stringEncodeArch . readArch <$> getTestSetting TestTargetARCH platform <- getTestSetting TestTARGETPLATFORM - wordsize <- getTestSetting TestWORDSIZE + wordsize <- show . ((8 :: Int) *) . read <$> getTestSetting TestWORDSIZE rtsWay <- getTestSetting TestRTSWay let debugged = "debug" `isInfixOf` rtsWay ===================================== testsuite/ghc-config/ghc-config.hs ===================================== @@ -9,15 +9,16 @@ main = do info <- readProcess ghc ["+RTS", "--info"] "" let fields = read info :: [(String,String)] getGhcFieldOrFail fields "HostOS" "Host OS" - getGhcFieldOrFail fields "WORDSIZE" "Word size" - getGhcFieldOrFail fields "TARGETPLATFORM" "Target platform" - getGhcFieldOrFail fields "TargetOS_CPP" "Target OS" - getGhcFieldOrFail fields "TargetARCH_CPP" "Target architecture" getGhcFieldOrFail fields "RTSWay" "RTS way" info <- readProcess ghc ["--info"] "" let fields = read info :: [(String,String)] + getGhcFieldOrFail fields "TARGETPLATFORM" "Target platform" + getGhcFieldOrFail fields "WORDSIZE" "target word size" + getGhcFieldOrFail fields "TargetOS" "target os" + getGhcFieldOrFail fields "TargetARCH" "target arch" + getGhcFieldOrFail fields "GhcStage" "Stage" getGhcFieldOrFail fields "GhcDebugAssertions" "Debug on" getGhcFieldOrFail fields "GhcWithNativeCodeGen" "Have native code generator" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/66da8fae4614fcbfc7ed7a6802addb2ba2c724a1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/66da8fae4614fcbfc7ed7a6802addb2ba2c724a1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 10:16:54 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 06:16:54 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Bump bytestring submodule to 0.12.0.2 Message-ID: <651d3b963831f_18f52912d78411867a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 39672070 by Matthew Pickering at 2023-10-04T06:16:34-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 4c41ad4f by Ben Gamari at 2023-10-04T06:16:35-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - 27 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - docs/users_guide/using-warnings.rst - driver/ghci/ghci-wrapper.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Packages.hs - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - m4/find_ld.m4 - rts/include/rts/ghc_ffi.h - rts/sm/NonMoving.h - − testsuite/tests/driver/T16737.hs - − testsuite/tests/driver/T16737.stdout - − testsuite/tests/driver/T16737include/T16737.h - testsuite/tests/driver/all.T - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T24029.hs - testsuite/tests/simplCore/should_compile/all.T - utils/iserv/iserv.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -506,6 +506,10 @@ bucket_match fs sbs = go fs go (fs@(FastString {fs_sbs=fs_sbs}) : ls) | fs_sbs == sbs = Just fs | otherwise = go ls +-- bucket_match used to inline before changes to instance Eq ShortByteString +-- in bytestring-0.12, which made it slighhtly larger than inlining threshold. +-- Non-inlining causes a small, but measurable performance regression, so let's force it. +{-# INLINE bucket_match #-} mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -411,19 +411,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do includePathsQuoteImplicit cmdline_include_paths) let include_paths = include_paths_quote ++ include_paths_global - -- pass -D or -optP to preprocessor when compiling foreign C files - -- (#16737). Doing it in this way is simpler and also enable the C - -- compiler to perform preprocessing and parsing in a single pass, - -- but it may introduce inconsistency if a different pgm_P is specified. - let opts = getOpts dflags opt_P - aug_imports = augmentImports dflags opts - - more_preprocessor_opts = concat - [ ["-Xpreprocessor", i] - | not hcc - , i <- aug_imports - ] - let gcc_extra_viac_flags = extraGccViaCFlags dflags let pic_c_flags = picCCOpts dflags @@ -512,7 +499,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do ++ [ "-include", ghcVersionH ] ++ framework_paths ++ include_paths - ++ more_preprocessor_opts ++ pkg_extra_cc_opts )) ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== compiler/ghc.cabal.in ===================================== @@ -98,7 +98,7 @@ Library deepseq >= 1.4 && < 1.6, directory >= 1 && < 1.4, process >= 1 && < 1.7, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, binary == 0.8.*, time >= 1.4 && < 1.13, containers >= 0.6.2.1 && < 0.7, ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -2157,16 +2157,19 @@ of ``-W(no-)*``. :since: 8.4 The option :ghc-flag:`-Wpartial-fields` warns about a record field - `f` that is defined in some, but not all, the contructors of a - data type, because `f`'s record selector function may fail. For - exampe, the record selector function `f`, defined in the `Foo` - constructor record below, will fail when applied to ``Bar``, so - the compiler will emit a warning at its definition when - :ghc-flag:`-Wpartial-fields` is enabled. + ``f`` that is defined in some, but not all, of the constructors of a + data type, as such selector functions are partial. For example, when + :ghc-flag:`-Wpartial-fields` is enabled the compiler will emit a warning at + the definition of ``Foo`` below: :: + + data Foo = Foo { f :: Int } | Bar The warning is suppressed if the field name begins with an underscore. :: - data Foo = Foo { f :: Int } | Bar + data Foo = Foo { _f :: Int } | Bar + + Another related warning is :ghc-flag:`-Wincomplete-record-selectors`, + which warns at use sites rather than definition sites. .. ghc-flag:: -Wunused-packages :shortdesc: warn when package is requested on command line, but not needed. ===================================== driver/ghci/ghci-wrapper.cabal.in ===================================== @@ -29,4 +29,4 @@ Executable ghci -- We need to call the versioned ghc executable because the unversioned -- GHC executable is a wrapper that doesn't call FreeConsole and so -- breaks an interactive process like GHCi. See #21889, #14150 and #13411 - CPP-Options: -DEXE_PATH="ghc- at ProjectVersion@" + cc-options: -DEXE_PATH="ghc- at ProjectVersion@" ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable ghc Main-Is: Main.hs Build-Depends: base >= 4 && < 5, array >= 0.1 && < 0.6, - bytestring >= 0.9 && < 0.12, + bytestring >= 0.9 && < 0.13, directory >= 1 && < 1.4, process >= 1 && < 1.7, filepath >= 1 && < 1.5, ===================================== hadrian/hadrian.cabal ===================================== @@ -153,7 +153,7 @@ executable hadrian , TypeFamilies build-depends: Cabal >= 3.10 && < 3.11 , base >= 4.11 && < 5 - , bytestring >= 0.10 && < 0.12 + , bytestring >= 0.10 && < 0.13 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -515,8 +515,8 @@ createVersionWrapper pkg versioned_exe install_path = do | otherwise = 0 cmd ghcPath (["-no-hs-main", "-o", install_path, "-I"++version_wrapper_dir - , "-DEXE_PATH=\"" ++ versioned_exe ++ "\"" - , "-DINTERACTIVE_PROCESS=" ++ show interactive + , "-optc-DEXE_PATH=\"" ++ versioned_exe ++ "\"" + , "-optc-DINTERACTIVE_PROCESS=" ++ show interactive ] ++ wrapper_files) {- ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -297,14 +297,11 @@ rtsPackageArgs = package rts ? do libzstdIncludeDir <- getSetting LibZstdIncludeDir libzstdLibraryDir <- getSetting LibZstdLibDir + -- Arguments passed to GHC when compiling C and .cmm sources. let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\"" - -- Set the namespace for the rts fs functions - , arg $ "-DFS_NAMESPACE=rts" - , arg $ "-DCOMPILING_RTS" , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] @@ -333,9 +330,16 @@ rtsPackageArgs = package rts ? do , "-fno-omit-frame-pointer" , "-g3" , "-O0" ] + -- Set the namespace for the rts fs functions + , arg $ "-DFS_NAMESPACE=rts" + + , arg $ "-DCOMPILING_RTS" , inputs ["**/RtsMessages.c", "**/Trace.c"] ? - arg ("-DProjectVersion=" ++ show projectVersion) + pure + ["-DProjectVersion=" ++ show projectVersion + , "-DRtsWay=\"rts_" ++ show way ++ "\"" + ] , input "**/RtsUtils.c" ? pure [ "-DProjectVersion=" ++ show projectVersion @@ -353,6 +357,7 @@ rtsPackageArgs = package rts ? do , "-DTargetVendor=" ++ show targetVendor , "-DGhcUnregisterised=" ++ show ghcUnreg , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DRtsWay=\"rts_" ++ show way ++ "\"" ] -- We're after pur performance here. So make sure fast math and ===================================== libraries/bytestring ===================================== @@ -1 +1 @@ -Subproject commit 2bdeb7b0e7dd100fce9e1f4d1ecf1cd6b5b9702c +Subproject commit 39f40116a4adf8a3296067d64bd00e1a1e5e15bd ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -75,7 +75,7 @@ Library build-depends: base >= 4.7 && < 4.20, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -41,7 +41,7 @@ library build-depends: ghc-prim >= 0.5.3 && < 0.11, base >= 4.9.0 && < 4.20, - bytestring >= 0.10.6.0 && <0.12 + bytestring >= 0.10.6.0 && <0.13 ghc-options: -Wall exposed-modules: GHC.Compact ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -78,7 +78,7 @@ library base >= 4.8 && < 4.20, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, filepath == 1.4.*, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 0ea07e223685787893dccbcbb67f1720ef4cf80e +Subproject commit 16ee820fc86f43045365f2c3536ad18147eb0b79 ===================================== m4/find_ld.m4 ===================================== @@ -70,19 +70,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) ===================================== rts/include/rts/ghc_ffi.h ===================================== @@ -1,5 +1,5 @@ /* - * wrapper working around #23586. + * wrapper working around #23568. * * (c) The University of Glasgow 2023 * ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE ((uintptr_t)1 << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/driver/T16737.hs deleted ===================================== @@ -1,32 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -DFOO=2 -optP=-DBAR=3 -optc=-DBAZ=5 -optcxx=-DBAZ=7 #-} - -import Language.Haskell.TH.Syntax - -do - let code = unlines - [ "#if defined(__cplusplus)" - , "extern \"C\" {" - , "#endif" - , "#include " - , "int FUN(void) {" - , " return FOO * BAR * BAZ;" - , "}" - , "#if defined(__cplusplus)" - , "}" - , "#endif" - ] - addForeignSource LangC code - addForeignSource LangCxx code - pure [] - -foreign import ccall unsafe "c_value" - c_value :: IO Int - -foreign import ccall unsafe "cxx_value" - cxx_value :: IO Int - -main :: IO () -main = do - print =<< c_value - print =<< cxx_value ===================================== testsuite/tests/driver/T16737.stdout deleted ===================================== @@ -1,2 +0,0 @@ -30 -42 ===================================== testsuite/tests/driver/T16737include/T16737.h deleted ===================================== @@ -1,7 +0,0 @@ -#pragma once - -#if defined(__cplusplus) -#define FUN cxx_value -#else -#define FUN c_value -#endif ===================================== testsuite/tests/driver/all.T ===================================== @@ -285,12 +285,6 @@ test('inline-check', [omit_ways(['hpc', 'profasm'])] test('T14452', js_broken(22261), makefile_test, []) test('T14923', normal, makefile_test, []) test('T15396', normal, compile_and_run, ['-package ghc']) -test('T16737', - [extra_files(['T16737include/']), - req_th, - req_c, - expect_broken_for(16541, ghci_ways)], - compile_and_run, ['-optP=-isystem -optP=T16737include']) test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) ===================================== testsuite/tests/simplCore/should_compile/T24029.hs ===================================== @@ -0,0 +1,21 @@ +{-# OPTIONS_GHC -O #-} +module T24029 (surround) where + +data Buffer where + Buffer :: !Int -> Buffer + +newtype Builder = Builder (Buffer -> Buffer) + +c :: Builder -> Builder -> Builder +c (Builder f) (Builder g) = Builder (\b -> f (g b)) + +i :: Buffer -> Buffer +i (Buffer x) = Buffer x + +surround :: Builder -> Builder +surround f = f +{-# NOINLINE [1] surround #-} + +{-# RULES +"surround/surround" forall a. surround a = c (Builder (i . i)) a + #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -502,3 +502,4 @@ test('T23938', [extra_files(['T23938A.hs'])], multimod_compile, ['T23938', '-O - test('T23922a', normal, compile, ['-O']) test('T23952', [extra_files(['T23952a.hs'])], multimod_compile, ['T23952', '-v0 -O']) test('T24014', normal, compile, ['-dcore-lint']) +test('T24029', normal, compile, ['']) ===================================== utils/iserv/iserv.cabal.in ===================================== @@ -33,7 +33,7 @@ Executable iserv Build-Depends: array >= 0.5 && < 0.6, base >= 4 && < 5, binary >= 0.7 && < 0.11, - bytestring >= 0.10 && < 0.12, + bytestring >= 0.10 && < 0.13, containers >= 0.5 && < 0.7, deepseq >= 1.4 && < 1.6, ghci == @ProjectVersionMunged@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae6f38a340e5facc8f27921fb0a0ea2398827b69...4c41ad4f65ed12a1a1a519f2fc9a4d0c2e8400db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae6f38a340e5facc8f27921fb0a0ea2398827b69...4c41ad4f65ed12a1a1a519f2fc9a4d0c2e8400db You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 10:49:25 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 04 Oct 2023 06:49:25 -0400 Subject: [Git][ghc/ghc][wip/git-fetch-failure] Work around perf note fetch failure Message-ID: <651d4335afa5e_18f52912dbbc1248e9@gitlab.mail> Bryan R pushed to branch wip/git-fetch-failure at Glasgow Haskell Compiler / GHC Commits: d6eb5d86 by Bryan Richter at 2023-10-04T13:48:13+03:00 Work around perf note fetch failure Addresses #24055. - - - - - 1 changed file: - .gitlab/test-metrics.sh Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d6eb5d8604b5972ed348c33e28a97f60c8900197 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d6eb5d8604b5972ed348c33e28a97f60c8900197 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 11:37:42 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Oct 2023 07:37:42 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 4 commits: WIP: Run testsuite from bindist for cross Message-ID: <651d4e86aa631_18f52912d7701321a0@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 501133f0 by GHC GitLab CI at 2023-10-03T16:18:53+00:00 WIP: Run testsuite from bindist for cross - - - - - 7d2b974b by Matthew Pickering at 2023-10-04T09:12:45+00:00 Correctly compute cross-prefix - - - - - 74ff483e by Matthew Pickering at 2023-10-04T09:58:17+00:00 Move predicates to --info rather than +RTS --info - - - - - c932319c by GHC GitLab CI at 2023-10-04T11:36:04+00:00 WIP - - - - - 12 changed files: - .gitlab/ci.sh - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Packages.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Default.hs - testsuite/driver/testlib.py - testsuite/ghc-config/ghc-config.hs Changes: ===================================== .gitlab/ci.sh ===================================== @@ -490,7 +490,8 @@ function build_hadrian() { export XZ_OPT="${XZ_OPT:-} -T$cores" fi - case "${CROSS_STAGE:2}" in + echo "CROSS_STAGE: $CROSS_STAGE" + case "${CROSS_STAGE:-2}" in 2) BINDIST_TARGET="binary-dist";; 3) BINDIST_TARGET="binary-dist-stage3";; *) fail "Unknown CROSS_STAGE, must be 2 or 3";; @@ -555,7 +556,7 @@ function install_bindist() { # FIXME: The bindist configure script shouldn't need to be reminded of # the target platform. See #21970. if [ -n "${CROSS_TARGET:-}" ]; then - args+=( "--target=$CROSS_TARGET" "--host=$CROSS_TARGET" ) + args+=( "--target=$CROSS_TARGET" ) fi run ${CONFIGURE_WRAPPER:-} ./configure \ @@ -592,34 +593,14 @@ function test_hadrian() { info "Cannot test cross-compiled build without CROSS_EMULATOR being set." return # special case for JS backend - elif [ -n "${CROSS_TARGET:-}" ] && [ "${CROSS_EMULATOR:-}" == "js-emulator" ]; then - # The JS backend doesn't support CROSS_EMULATOR logic yet - unset CROSS_EMULATOR - # run "hadrian test" directly, not using the bindist, even though it did get installed. - # This is a temporary solution, See !9515 for the status of hadrian support. - run_hadrian \ - test \ - --summary-junit=./junit.xml \ - --test-have-intree-files \ - --docs=none \ - "runtest.opts+=${RUNTEST_ARGS:-}" \ - "runtest.opts+=--unexpected-output-dir=$TOP/unexpected-test-output" \ - || fail "cross-compiled hadrian main testsuite" - elif [[ -n "${CROSS_TARGET:-}" ]] && [[ "${CROSS_TARGET:-}" == *"wasm"* ]]; then - run_hadrian \ - test \ - --summary-junit=./junit.xml \ - "runtest.opts+=${RUNTEST_ARGS:-}" \ - "runtest.opts+=--unexpected-output-dir=$TOP/unexpected-test-output" \ - || fail "hadrian main testsuite targetting $CROSS_TARGET" - elif [ -n "${CROSS_TARGET:-}" ]; then - local instdir="$TOP/_build/install" - local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" - install_bindist _build/bindist/ghc-*/ "$instdir" - echo 'main = putStrLn "hello world"' > expected - run "$test_compiler" -package ghc "$TOP/.gitlab/hello.hs" -o hello - ${CROSS_EMULATOR:-} ./hello > actual - run diff expected actual +# elif [ -n "${CROSS_TARGET:-}" ]; then +# local instdir="$TOP/_build/install" +# local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" +# install_bindist _build/bindist/ghc-*/ "$instdir" +# echo 'main = putStrLn "hello world"' > expected +# run "$test_compiler" -package ghc "$TOP/.gitlab/hello.hs" -o hello +# ${CROSS_EMULATOR:-} ./hello > actual +# run diff expected actual elif [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian \ test \ ===================================== distrib/configure.ac.in ===================================== @@ -47,7 +47,6 @@ FPTOOLS_SET_PLATFORMS_VARS # Requires FPTOOLS_SET_PLATFORMS_VARS to be run first. FP_FIND_ROOT -# ToDo: if Stage1Only=YES, should be YES CrossCompiling=NO # If 'host' and 'target' differ, then this means we are building a cross-compiler. if test "$target" != "$host" ; then ===================================== hadrian/bindist/Makefile ===================================== @@ -187,7 +187,9 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - chmod ugo+rx "$$dest"/bin/* + if [ -d "$$dest/bin" ]; then \ + chmod ugo+rx "$$dest"/bin/*; \ + fi # Work around #17418 on Darwin if [ -e "${XATTR}" ]; then \ "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ ===================================== hadrian/bindist/config.mk.in ===================================== @@ -130,7 +130,6 @@ INSTALL_DIR = $(INSTALL) -m 755 -d #----------------------------------------------------------------------------- # Build configuration -CrossCompiling = @CrossCompiling@ CrossCompilePrefix = @CrossCompilePrefix@ GhcUnregisterised = @Unregisterised@ ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -23,8 +23,8 @@ testConfigFile = buildRoot <&> (-/- "test/ghcconfig") data TestSetting = TestHostOS | TestWORDSIZE | TestTARGETPLATFORM - | TestTargetOS_CPP - | TestTargetARCH_CPP + | TestTargetOS + | TestTargetARCH | TestRTSWay | TestGhcStage | TestGhcDebugAssertions @@ -43,6 +43,7 @@ data TestSetting = TestHostOS | TestLeadingUnderscore | TestGhcPackageDb | TestGhcLibDir + | TestCrossCompiling deriving (Show) -- | Lookup a test setting in @ghcconfig@ file. @@ -54,8 +55,8 @@ testSetting key = do TestHostOS -> "HostOS" TestWORDSIZE -> "WORDSIZE" TestTARGETPLATFORM -> "TARGETPLATFORM" - TestTargetOS_CPP -> "TargetOS_CPP" - TestTargetARCH_CPP -> "TargetARCH_CPP" + TestTargetOS -> "TargetOS" + TestTargetARCH -> "TargetARCH" TestRTSWay -> "RTSWay" TestGhcStage -> "GhcStage" TestGhcDebugAssertions -> "GhcDebugAssertions" @@ -74,6 +75,7 @@ testSetting key = do TestLeadingUnderscore -> "LeadingUnderscore" TestGhcPackageDb -> "GhcGlobalPackageDb" TestGhcLibDir -> "GhcLibdir" + TestCrossCompiling -> "CrossCompiling" -- | Get the RTS ways of the test compiler testRTSSettings :: Action [String] ===================================== hadrian/src/Packages.hs ===================================== @@ -15,7 +15,7 @@ module Packages ( ghcPackages, isGhcPackage, -- * Package information - crossPrefix, programName, nonHsMainPackage, autogenPath, programPath, timeoutPath, + crossPrefix, programBasename, programName, nonHsMainPackage, autogenPath, programPath, timeoutPath, rtsContext, rtsBuildPath, libffiBuildPath, ensureConfigured ) where @@ -185,9 +185,10 @@ programName Context {..} = do -- use Cabal conditionals + a 'profiling' flag -- to declare the executable name, and I'm not sure -- this is allowed (or desired for that matter). - return $ prefix ++ basename - where - basename + return $ prefix ++ programBasename way package + +programBasename :: Way -> Package -> String +programBasename way package | package == ghc = "ghc" | package == ghciWrapper = "ghci" -- See Note [Hadrian's ghci-wrapper package] | package == hpcBin = "hpc" ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Toolchain (ccProgram, tgtCCompiler, ccLinkProgram, tgtCCompilerLink) import GHC.Toolchain.Program (prgFlags) import qualified Data.Set as Set import Oracles.Flavour +import Debug.Trace {- Note [Binary distributions] @@ -280,7 +281,7 @@ buildBinDistDir root conf at BindistConfig{..} = do need $ map (bindistFilesDir -/-) (["configure", "Makefile"] ++ bindistInstallFiles) copyFile ("hadrian" -/- "bindist" -/- "config.mk.in") (bindistFilesDir -/- "config.mk.in") - generateBuildMk >>= writeFile' (bindistFilesDir -/- "build.mk") + generateBuildMk conf >>= writeFile' (bindistFilesDir -/- "build.mk") copyFile ("hadrian" -/- "cfg" -/- "default.target.in") (bindistFilesDir -/- "default.target.in") copyFile ("hadrian" -/- "cfg" -/- "default.host.target.in") (bindistFilesDir -/- "default.host.target.in") @@ -404,12 +405,16 @@ data Compressor = Gzip | Bzip2 | Xz -- Information from the build configuration which needs to be propagated to config.mk.in -generateBuildMk :: Action String -generateBuildMk = do - dynamicGhc <- askDynGhcPrograms Stage1 - rtsWays <- unwords . map show . Set.toList <$> interpretInContext (vanillaContext Stage1 rts) getRtsWays +generateBuildMk :: BindistConfig -> Action String +generateBuildMk BindistConfig{..} = do + dynamicGhc <- askDynGhcPrograms executable_stage + rtsWays <- unwords . map show . Set.toList <$> interpretInContext (vanillaContext library_stage rts) getRtsWays + cross <- crossStage executable_stage + traceShowM ("cross", library_stage, executable_stage, cross) return $ unlines [ "GhcRTSWays" =. rtsWays - , "DYNAMIC_GHC_PROGRAMS" =. yesNo dynamicGhc ] + -- MP: TODO just very hacky, should be one place where cross implies static (see programContext for where this is currently) + , "DYNAMIC_GHC_PROGRAMS" =. yesNo (dynamicGhc && not cross) + , "CrossCompiling" =. yesNo cross ] where ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -228,14 +228,8 @@ testRules = do rel_runghc <- relative_path_stage (Stage0 InTreeLibs) runGhc -- force stage0 program building for cross - when cross $ need [rel_hpc, rel_haddock, rel_runghc] + --when cross $ need [rel_hpc, rel_haddock, rel_runghc] - prog_ghc_pkg <- make_absolute rel_ghc_pkg - prog_hsc2hs <- make_absolute rel_hsc2hs - prog_hp2ps <- make_absolute rel_hp2ps - prog_haddock <- make_absolute rel_haddock - prog_hpc <- make_absolute rel_hpc - prog_runghc <- make_absolute rel_runghc ghcPath <- getCompilerPath testCompilerArg @@ -246,11 +240,28 @@ testRules = do [ "--interactive", "-v0", "-ignore-dot-ghci" , "-fno-ghci-history", "-fprint-error-index-links=never" ] + -- MP: TODO wrong ccPath <- queryTargetTarget stg (Toolchain.prgPath . Toolchain.ccProgram . Toolchain.tgtCCompiler) ccFlags <- queryTargetTarget stg (unwords . Toolchain.prgFlags . Toolchain.ccProgram . Toolchain.tgtCCompiler) pythonPath <- builderPath Python + testGhc <- testCompiler <$> userSetting defaultTestArgs + bindir <- getBinaryDirectory testGhc + cross <- getBooleanSetting TestCrossCompiling + test_target_platform <- getTestSetting TestTARGETPLATFORM + let cross_prefix = if cross then test_target_platform ++ "-" else "" + + let exe_path :: Package -> String + exe_path pkg = bindir (cross_prefix ++ programBasename vanilla pkg) <.> exe + + prog_ghc_pkg <- make_absolute (exe_path ghcPkg) + prog_hsc2hs <- make_absolute (exe_path hsc2hs) + prog_hp2ps <- make_absolute (exe_path hp2ps) + prog_haddock <- make_absolute (exe_path haddock) + prog_hpc <- make_absolute (exe_path hpc) + prog_runghc <- make_absolute (exe_path runGhc) + -- Set environment variables for test's Makefile. -- TODO: Ideally we would define all those env vars in 'env', so that -- Shake can keep track of them, but it is not as easy as it seems ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -3,7 +3,9 @@ module Settings.Builders.RunTest (runTestBuilderArgs , runTestGhcFlags , assertSameCompilerArgs , outOfTreeCompilerArgs - , TestCompilerArgs(..) ) where + , TestCompilerArgs(..) + , getBooleanSetting + , getTestSetting ) where import Hadrian.Utilities import qualified System.FilePath @@ -21,6 +23,9 @@ import Settings.Program import qualified Context.Type import GHC.Toolchain.Target +import Text.Read +import GHC.Platform.ArchOS +import Debug.Trace getTestSetting :: TestSetting -> Action String getTestSetting key = testSetting key @@ -167,13 +172,18 @@ outOfTreeCompilerArgs = do debugAssertions <- getBooleanSetting TestGhcDebugAssertions + let readArch :: String -> Maybe Arch + readArch = readMaybe + os <- getTestSetting TestHostOS - arch <- getTestSetting TestTargetARCH_CPP + arch <- maybe "unknown" stringEncodeArch . readArch <$> getTestSetting TestTargetARCH platform <- getTestSetting TestTARGETPLATFORM - wordsize <- getTestSetting TestWORDSIZE + wordsize <- show . ((8 :: Int) *) . read <$> getTestSetting TestWORDSIZE rtsWay <- getTestSetting TestRTSWay let debugged = "debug" `isInfixOf` rtsWay + traceShowM (os, arch, platform) + llc_cmd <- getTestSetting TestLLC have_llvm <- liftIO (isJust <$> findExecutable llc_cmd) profiled <- getBooleanSetting TestGhcProfiled @@ -322,14 +332,19 @@ runTestBuilderArgs = builder Testsuite ? do -- | Command line arguments for running GHC's test script. getTestArgs :: Args getTestArgs = do - stage <- getStage -- targets specified in the TEST env var testEnvTargets <- maybe [] words <$> expr (liftIO $ lookupEnv "TEST") args <- expr $ userSetting defaultTestArgs bindir <- expr $ getBinaryDirectory (testCompiler args) compiler <- expr $ getCompilerPath (testCompiler args) globalVerbosity <- shakeVerbosity <$> expr getShakeOptions - cross_prefix <- expr (crossPrefix (succStage stage)) + + -- MP: Is it better to compute cross_prefix from testCompiler? + cross <- expr $ getBooleanSetting TestCrossCompiling + test_target <- expr $ getTestSetting TestTARGETPLATFORM + let cross_prefix = if cross then test_target ++ "-" else "" + traceShowM ("cross", cross, cross_prefix, test_target) + -- the testsuite driver will itself tell us if we need to generate the docs target -- So we always pass the haddock path if the hadrian configuration allows us to build -- docs ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -158,12 +158,11 @@ stage1Packages = do , stm , unlit , xhtml + , haddock + , hpcBin , if winTarget then win32 else unix - ] - , when (not cross) - [ haddock - , hpcBin - , iserv + ] ++ + [ iserv , runGhc , ghcToolchainBin ] ===================================== testsuite/driver/testlib.py ===================================== @@ -144,6 +144,7 @@ def js_skip( name, opts ): # expect broken for the JS backend def js_broken( bug: IssueNumber ): + print ("js_broken", js_arch()) if js_arch(): return expect_broken(bug); else: @@ -727,6 +728,7 @@ def opsys( os: str ) -> bool: return config.os == os def arch( arch: str ) -> bool: + print(arch, config.arch) return config.arch == arch def wordsize( ws: int ) -> bool: ===================================== testsuite/ghc-config/ghc-config.hs ===================================== @@ -9,15 +9,16 @@ main = do info <- readProcess ghc ["+RTS", "--info"] "" let fields = read info :: [(String,String)] getGhcFieldOrFail fields "HostOS" "Host OS" - getGhcFieldOrFail fields "WORDSIZE" "Word size" - getGhcFieldOrFail fields "TARGETPLATFORM" "Target platform" - getGhcFieldOrFail fields "TargetOS_CPP" "Target OS" - getGhcFieldOrFail fields "TargetARCH_CPP" "Target architecture" getGhcFieldOrFail fields "RTSWay" "RTS way" info <- readProcess ghc ["--info"] "" let fields = read info :: [(String,String)] + getGhcFieldOrFail fields "TARGETPLATFORM" "Target platform" + getGhcFieldOrFail fields "WORDSIZE" "target word size" + getGhcFieldOrFail fields "TargetOS" "target os" + getGhcFieldOrFail fields "TargetARCH" "target arch" + getGhcFieldOrFail fields "GhcStage" "Stage" getGhcFieldOrFail fields "GhcDebugAssertions" "Debug on" getGhcFieldOrFail fields "GhcWithNativeCodeGen" "Have native code generator" @@ -28,6 +29,7 @@ main = do getGhcFieldOrFail fields "GhcRTSWays" "RTS ways" getGhcFieldOrFail fields "GhcLibdir" "LibDir" getGhcFieldOrFail fields "GhcGlobalPackageDb" "Global Package DB" + getGhcFieldOrFail fields "CrossCompiling" "cross compiling" getGhcFieldOrDefault fields "GhcDynamic" "GHC Dynamic" "NO" getGhcFieldOrDefault fields "GhcProfiled" "GHC Profiled" "NO" getGhcFieldOrDefault fields "LeadingUnderscore" "Leading underscore" "NO" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/66da8fae4614fcbfc7ed7a6802addb2ba2c724a1...c932319ccd2c02825cfdf34bb971920907e6c40a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/66da8fae4614fcbfc7ed7a6802addb2ba2c724a1...c932319ccd2c02825cfdf34bb971920907e6c40a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 13:01:10 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 04 Oct 2023 09:01:10 -0400 Subject: [Git][ghc/ghc][wip/hadrian-windows-bindist-cross] configure: Probe stage0 link flags Message-ID: <651d621692203_18f5295e76da0143881@gitlab.mail> Ben Gamari pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC Commits: ef5ac072 by Ben Gamari at 2023-10-04T09:01:03-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 2 changed files: - configure.ac - m4/fp_prog_cc_linker_target.m4 Changes: ===================================== configure.ac ===================================== @@ -661,8 +661,9 @@ FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0 FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1]) FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2]) -FP_PROG_CC_LINKER_TARGET([CONF_CC_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) -FP_PROG_CC_LINKER_TARGET([CONF_CC_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) +FP_PROG_CC_LINKER_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) dnl ** See whether cc used as a linker supports -no-pie FP_GCC_SUPPORTS_NO_PIE ===================================== m4/fp_prog_cc_linker_target.m4 ===================================== @@ -2,8 +2,9 @@ # ------------------- # Check to see if the C compiler used as a linker supports `--target` # -# $1 - Variable which contains the options passed to the C compiler when compiling a C file -# $2 - Variable which contains the options passed to the C compiler when used as +# $1 - The compiler +# $2 - Variable which contains the options passed to the C compiler when compiling a C file +# $3 - Variable which contains the options passed to the C compiler when used as # a linker AC_DEFUN([FP_PROG_CC_LINKER_TARGET], [ @@ -11,17 +12,17 @@ AC_DEFUN([FP_PROG_CC_LINKER_TARGET], echo 'int foo() { return 0; }' > conftest1.c echo 'int main() { return 0; }' > conftest2.c - "${CC}" $$1 -c conftest1.c || AC_MSG_ERROR([Failed to compile conftest1.c]) - "${CC}" $$1 -c conftest2.c || AC_MSG_ERROR([Failed to compile conftest2.c]) + "$1" $$2 -c conftest1.c || AC_MSG_ERROR([Failed to compile conftest1.c]) + "$1" $$2 -c conftest2.c || AC_MSG_ERROR([Failed to compile conftest2.c]) if test "$target_cpu" = "javascript" then # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program CONF_CC_SUPPORTS_TARGET=NO AC_MSG_RESULT([no]) - elif "$CC" $$2 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; + elif "$CC" $$3 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; then - $2="--target=$LlvmTarget $$2" + $3="--target=$LlvmTarget $$3" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef5ac0722fd55f3d3c0eba0c56c74c4724efc783 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef5ac0722fd55f3d3c0eba0c56c74c4724efc783 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 13:11:15 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 04 Oct 2023 09:11:15 -0400 Subject: [Git][ghc/ghc][wip/andreask/zero_reg] 72 commits: base: Advertise linear time of readFloat Message-ID: <651d6473e33b7_18f5295e79d841492b7@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/zero_reg at Glasgow Haskell Compiler / GHC Commits: 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - b9c85181 by Andreas Klebinger at 2023-10-04T13:11:04+00:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/CodeGen.Platform.h - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3609031c374ca017cf63334ec495f6b42c915827...b9c85181ee773aac63d88fc3c2169601382bfabf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3609031c374ca017cf63334ec495f6b42c915827...b9c85181ee773aac63d88fc3c2169601382bfabf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 13:24:30 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 04 Oct 2023 09:24:30 -0400 Subject: [Git][ghc/ghc][wip/T24050] hadrian: Move hsc2hs wrapper generation to bindist installation Message-ID: <651d678e7b16d_18f5296be10581582df@gitlab.mail> Ben Gamari pushed to branch wip/T24050 at Glasgow Haskell Compiler / GHC Commits: cb8b6d78 by Ben Gamari at 2023-10-04T09:24:21-04:00 hadrian: Move hsc2hs wrapper generation to bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. Fixes #24050. - - - - - 2 changed files: - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -235,13 +235,21 @@ install_man: export SHELL .PHONY: install_wrappers -install_wrappers: install_bin_libdir +install_wrappers: install_bin_libdir install_hsc2hs_wrapper @echo "Installing wrapper scripts" $(INSTALL_DIR) "$(DESTDIR)$(WrapperBinsDir)" for p in `cd wrappers; $(FIND) . ! -type d`; do \ mk/install_script.sh "$$p" "$(DESTDIR)/$(WrapperBinsDir)/$$p" "$(WrapperBinsDir)" "$(ActualBinsDir)" "$(ActualBinsDir)/$$p" "$(ActualLibsDir)" "$(docdir)" "$(includedir)"; \ done +.PHONY: install_hsc2hs_wrapper +install_hsc2hs_wrapper: + @echo "Installing hsc2hs wrapper" + echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> hsc2hs-wrapper + $(INSTALL_SCRIPT) hsc2hs-wrapper "$(DESTDIR)$(bindir)/hsc2hs" + rm -f hsc2hs-wrapper + + PKG_CONFS = $(shell find "$(DESTDIR)$(ActualLibsDir)/package.conf.d" -name '*.conf' | sed "s: :\0xxx\0:g") .PHONY: update_package_db update_package_db: install_bin install_lib ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -15,8 +15,6 @@ import Target import Utilities import qualified System.Directory.Extra as IO import Data.Either -import GHC.Toolchain (ccProgram, tgtCCompiler, ccLinkProgram, tgtCCompilerLink) -import GHC.Toolchain.Program (prgFlags) import qualified Data.Set as Set import Oracles.Flavour @@ -428,7 +426,7 @@ pkgToWrappers pkg = do | pkg == runGhc -> pure $ map (prefix++) ["runghc", "runhaskell"] -- These are the packages which we want to expose to the user and hence -- there are wrappers installed in the bindist. - | pkg `elem` [hpcBin, haddock, hp2ps, hsc2hs, ghc, ghcPkg] + | pkg `elem` [hpcBin, haddock, hp2ps, ghc, ghcPkg] -> (:[]) <$> (programName =<< programContext Stage1 pkg) | otherwise -> pure [] @@ -437,7 +435,6 @@ wrapper "ghc" = ghcWrapper wrapper "ghc-pkg" = ghcPkgWrapper wrapper "ghci" = ghciScriptWrapper wrapper "haddock" = haddockWrapper -wrapper "hsc2hs" = hsc2hsWrapper wrapper "runghc" = runGhcWrapper wrapper "runhaskell" = runGhcWrapper wrapper _ = commonWrapper @@ -459,18 +456,6 @@ haddockWrapper = pure $ "exec \"$executablename\" -B\"$libdir\" -l\"$libdir\" ${ commonWrapper :: Action String commonWrapper = pure $ "exec \"$executablename\" ${1+\"$@\"}\n" --- echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> "$(WRAPPER)" -hsc2hsWrapper :: Action String -hsc2hsWrapper = do - ccArgs <- map ("--cflag=" <>) . prgFlags . ccProgram . tgtCCompiler <$> targetStage Stage1 - linkFlags <- map ("--lflag=" <>) . prgFlags . ccLinkProgram . tgtCCompilerLink <$> targetStage Stage1 - wrapper <- drop 4 . lines <$> liftIO (readFile "utils/hsc2hs/hsc2hs.wrapper") - return $ unlines - ( "HSC2HS_EXTRA=\"" <> unwords (ccArgs ++ linkFlags) <> "\"" - : "tflag=\"--template=$libdir/template-hsc.h\"" - : "Iflag=\"-I$includedir/\"" - : wrapper ) - runGhcWrapper :: Action String runGhcWrapper = pure $ "exec \"$executablename\" -f \"$exedir/ghc\" ${1+\"$@\"}\n" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb8b6d7825dd72316004725e3c33d07473867022 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb8b6d7825dd72316004725e3c33d07473867022 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 14:47:20 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 10:47:20 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" Message-ID: <651d7af8d40c7_18f5298ac869c18957b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: abfeaafd by Matthew Pickering at 2023-10-04T10:47:06-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 66ac5bf0 by John Ericson at 2023-10-04T10:47:06-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> Apply 1 suggestion(s) to 1 file(s) - - - - - e4eea8aa by Ben Gamari at 2023-10-04T10:47:07-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - baa9d573 by Andreas Klebinger at 2023-10-04T10:47:08-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 16522f85 by Bryan Richter at 2023-10-04T10:47:08-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 19 changed files: - .gitlab/test-metrics.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Driver/Pipeline/Execute.hs - driver/ghci/ghci-wrapper.cabal.in - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Packages.hs - rts/sm/NonMoving.h - − testsuite/tests/driver/T16737.hs - − testsuite/tests/driver/T16737.stdout - − testsuite/tests/driver/T16737include/T16737.h - testsuite/tests/driver/all.T - + testsuite/tests/th/T23309.c - + testsuite/tests/th/T23309.hs - + testsuite/tests/th/T23309.stderr - + testsuite/tests/th/T23309A.hs - + testsuite/tests/th/T23378.hs - + testsuite/tests/th/T23378.stderr - + testsuite/tests/th/T23378A.hs - testsuite/tests/th/all.T Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -781,12 +781,12 @@ getRegister' config plat expr return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) -- 3. Logic &&, || - CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (AND (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg - CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (ORR (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg @@ -1070,13 +1070,16 @@ getRegister' config plat expr -- | Is a given number encodable as a bitmask immediate? -- -- https://stackoverflow.com/questions/30904718/range-of-immediate-values-in-armv8-a64-assembly -isAArch64Bitmask :: Integer -> Bool +isAArch64Bitmask :: Width -> Integer -> Bool -- N.B. zero and ~0 are not encodable as bitmask immediates -isAArch64Bitmask 0 = False -isAArch64Bitmask n - | n == bit 64 - 1 = False -isAArch64Bitmask n = - check 64 || check 32 || check 16 || check 8 +isAArch64Bitmask width n = + assert (width `elem` [W32,W64]) $ + case n of + 0 -> False + _ | n == bit (widthInBits width) - 1 + -> False -- 1111...1111 + | otherwise + -> (width == W64 && check 64) || check 32 || check 16 || check 8 where -- Check whether @n@ can be represented as a subpattern of the given -- width. ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -411,19 +411,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do includePathsQuoteImplicit cmdline_include_paths) let include_paths = include_paths_quote ++ include_paths_global - -- pass -D or -optP to preprocessor when compiling foreign C files - -- (#16737). Doing it in this way is simpler and also enable the C - -- compiler to perform preprocessing and parsing in a single pass, - -- but it may introduce inconsistency if a different pgm_P is specified. - let opts = getOpts dflags opt_P - aug_imports = augmentImports dflags opts - - more_preprocessor_opts = concat - [ ["-Xpreprocessor", i] - | not hcc - , i <- aug_imports - ] - let gcc_extra_viac_flags = extraGccViaCFlags dflags let pic_c_flags = picCCOpts dflags @@ -512,7 +499,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do ++ [ "-include", ghcVersionH ] ++ framework_paths ++ include_paths - ++ more_preprocessor_opts ++ pkg_extra_cc_opts )) ===================================== driver/ghci/ghci-wrapper.cabal.in ===================================== @@ -29,4 +29,4 @@ Executable ghci -- We need to call the versioned ghc executable because the unversioned -- GHC executable is a wrapper that doesn't call FreeConsole and so -- breaks an interactive process like GHCi. See #21889, #14150 and #13411 - CPP-Options: -DEXE_PATH="ghc- at ProjectVersion@" + cc-options: -DEXE_PATH="ghc- at ProjectVersion@" ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -515,8 +515,8 @@ createVersionWrapper pkg versioned_exe install_path = do | otherwise = 0 cmd ghcPath (["-no-hs-main", "-o", install_path, "-I"++version_wrapper_dir - , "-DEXE_PATH=\"" ++ versioned_exe ++ "\"" - , "-DINTERACTIVE_PROCESS=" ++ show interactive + , "-optc-DEXE_PATH=\"" ++ versioned_exe ++ "\"" + , "-optc-DINTERACTIVE_PROCESS=" ++ show interactive ] ++ wrapper_files) {- ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -297,14 +297,11 @@ rtsPackageArgs = package rts ? do libzstdIncludeDir <- getSetting LibZstdIncludeDir libzstdLibraryDir <- getSetting LibZstdLibDir + -- Arguments passed to GHC when compiling C and .cmm sources. let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\"" - -- Set the namespace for the rts fs functions - , arg $ "-DFS_NAMESPACE=rts" - , arg $ "-DCOMPILING_RTS" , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] @@ -333,9 +330,16 @@ rtsPackageArgs = package rts ? do , "-fno-omit-frame-pointer" , "-g3" , "-O0" ] + -- Set the namespace for the rts fs functions + , arg $ "-DFS_NAMESPACE=rts" + + , arg $ "-DCOMPILING_RTS" , inputs ["**/RtsMessages.c", "**/Trace.c"] ? - arg ("-DProjectVersion=" ++ show projectVersion) + pure + ["-DProjectVersion=" ++ show projectVersion + , "-DRtsWay=\"rts_" ++ show way ++ "\"" + ] , input "**/RtsUtils.c" ? pure [ "-DProjectVersion=" ++ show projectVersion @@ -353,6 +357,7 @@ rtsPackageArgs = package rts ? do , "-DTargetVendor=" ++ show targetVendor , "-DGhcUnregisterised=" ++ show ghcUnreg , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DRtsWay=\"rts_" ++ show way ++ "\"" ] -- We're after pur performance here. So make sure fast math and ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE ((uintptr_t)1 << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/driver/T16737.hs deleted ===================================== @@ -1,32 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -DFOO=2 -optP=-DBAR=3 -optc=-DBAZ=5 -optcxx=-DBAZ=7 #-} - -import Language.Haskell.TH.Syntax - -do - let code = unlines - [ "#if defined(__cplusplus)" - , "extern \"C\" {" - , "#endif" - , "#include " - , "int FUN(void) {" - , " return FOO * BAR * BAZ;" - , "}" - , "#if defined(__cplusplus)" - , "}" - , "#endif" - ] - addForeignSource LangC code - addForeignSource LangCxx code - pure [] - -foreign import ccall unsafe "c_value" - c_value :: IO Int - -foreign import ccall unsafe "cxx_value" - cxx_value :: IO Int - -main :: IO () -main = do - print =<< c_value - print =<< cxx_value ===================================== testsuite/tests/driver/T16737.stdout deleted ===================================== @@ -1,2 +0,0 @@ -30 -42 ===================================== testsuite/tests/driver/T16737include/T16737.h deleted ===================================== @@ -1,7 +0,0 @@ -#pragma once - -#if defined(__cplusplus) -#define FUN cxx_value -#else -#define FUN c_value -#endif ===================================== testsuite/tests/driver/all.T ===================================== @@ -285,12 +285,6 @@ test('inline-check', [omit_ways(['hpc', 'profasm'])] test('T14452', js_broken(22261), makefile_test, []) test('T14923', normal, makefile_test, []) test('T15396', normal, compile_and_run, ['-package ghc']) -test('T16737', - [extra_files(['T16737include/']), - req_th, - req_c, - expect_broken_for(16541, ghci_ways)], - compile_and_run, ['-optP=-isystem -optP=T16737include']) test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) ===================================== testsuite/tests/th/T23309.c ===================================== @@ -0,0 +1,8 @@ +#define _GNU_SOURCE 1 +#include + +const char* foo(int e) { + static char s[256]; + sprintf(s, "The value of e is: %u", e); + return s; +} ===================================== testsuite/tests/th/T23309.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23309 where + +import Foreign.C.String +import Language.Haskell.TH +import System.IO + +import T23309A + +$(do runIO $ do + cstr <- c_foo 42 + str <- peekCString cstr + hPutStrLn stderr str + hFlush stderr + return []) ===================================== testsuite/tests/th/T23309.stderr ===================================== @@ -0,0 +1 @@ +The value of e is: 42 ===================================== testsuite/tests/th/T23309A.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE CPP #-} +module T23309A (c_foo) where + +import Foreign.C.String +import Foreign.C.Types + +#if defined(mingw32_HOST_OS) +# if defined(i386_HOST_ARCH) +# define CALLCONV stdcall +# elif defined(x86_64_HOST_ARCH) +# define CALLCONV ccall +# else +# error Unknown mingw32 arch +# endif +#else +# define CALLCONV ccall +#endif + +foreign import CALLCONV unsafe "foo" c_foo :: CInt -> IO CString ===================================== testsuite/tests/th/T23378.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23378 where + +import Foreign.C.String +import Language.Haskell.TH +import System.IO + +import T23378A + +$(do runIO $ do + hPrint stderr isatty + hFlush stderr + return []) ===================================== testsuite/tests/th/T23378.stderr ===================================== @@ -0,0 +1 @@ +False ===================================== testsuite/tests/th/T23378A.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE CPP #-} +module T23378A where + +import Foreign.C.Types +import System.IO.Unsafe + +isatty :: Bool +isatty = + unsafePerformIO (c_isatty 1) == 1 +{-# NOINLINE isatty #-} + +#if defined(mingw32_HOST_OS) +# define SYM "_isatty" +#else +# define SYM "isatty" +#endif + +foreign import ccall unsafe SYM + c_isatty :: CInt -> IO CInt ===================================== testsuite/tests/th/all.T ===================================== @@ -589,6 +589,8 @@ test('T23829_hasty', normal, compile_fail, ['']) test('T23829_hasty_b', normal, compile_fail, ['']) test('T23927', normal, compile_and_run, ['']) test('T23954', normal, compile_and_run, ['']) +test('T23309', [extra_files(['T23309A.hs']), req_c], multimod_compile, ['T23309', '-v0 T23309.c -optc-fPIC']) +test('T23378', [extra_files(['T23378A.hs'])], multimod_compile, ['T23378', '-v0']) test('T23962', normal, compile_and_run, ['']) test('T23968', normal, compile_and_run, ['']) test('T23971', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c41ad4f65ed12a1a1a519f2fc9a4d0c2e8400db...16522f85e1264718fd7f4902d5abaea3cd78c492 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c41ad4f65ed12a1a1a519f2fc9a4d0c2e8400db...16522f85e1264718fd7f4902d5abaea3cd78c492 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 15:05:06 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 04 Oct 2023 11:05:06 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T21348 Message-ID: <651d7f22ba704_18f52992545282084f8@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/T21348 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T21348 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 16:18:11 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 04 Oct 2023 12:18:11 -0400 Subject: [Git][ghc/ghc][wip/T23442] CorePrep: Refactor FloatingBind (#23442) Message-ID: <651d9043bbbdf_18f529b165db82203de@gitlab.mail> Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC Commits: 7a11cdd7 by Sebastian Graf at 2023-10-04T18:17:57+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. - - - - - 2 changed files: - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. Flatten nested lets as much as possible. + See Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,51 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Very often (caveat in Wrinkle (FCP1) below, `v` is actually used and the thunk +closure was in vain. +Hence we carry around a bunch of floated bindings with us so that we can leave +behind more values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's simply like any other ok-for-spec-eval Float (see `mkNonRecFloat`) that has + a non-DEFAULT Case alternative to bind the unsafe coercion field of the Refl + constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + +Wrinkles: + (FCP1) + Let floating as above is not necessarily an optimisation if `v` doesn't + up being evaluated. In that case, we allocate a 4 word thunk closure for `v` + but won't need to allocate separate closures for `sat` (2 words) and the + `(:)` conapp (3 words), thus saving at least one word, depending on how much + the set of FVs between `sat` and `(:)` overlap. + The pros and cons of this so called "let-from-let" transformation are well + characterised in Section 3.3 of the paper + "Let-floating: moving bindings to give faster programs". + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +603,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +624,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (top_floats floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { top_floats = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { top_floats = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +656,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +673,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +683,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +694,30 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = FloatSome TopLvlFloatable + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs + +data FloatDecision + = FloatNone + | FloatAll + | FloatSome !FloatInfo -- ^ Float all bindings with <= this info + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + FloatSome info -> partitionFloats info floats + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +803,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +854,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +908,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +931,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1174,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1220,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1232,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1311,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1343,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1456,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1479,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1495,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1509,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1543,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1791,159 +1812,319 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it is a (let-bound) value +(`BoundVal`), or otherwise whether it will be `CaseBound` or `LetBound`. +Depending on the `BindInfo`, the `FloatingBind` encodes ... + + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> ... }` + * `BoundVal`: A let binding `let x = rhs in ...`, and `rhs` is an HNF + * `LetBound`: A let binding `let x = rhs in ...`, and `rhs` is not an HNF + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is either ok-for-spec-eval +(See Note [Speculative evaluation]), unlifted, strictly used (and perhaps +lifted), or a literal string (Wrinkle (FI1) below). + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +All lazy (and hence lifted) bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Wrinkles: + (FI1) + String literals are currently the only kind of unlifted binding that may + live at the top-level. Indeed, they will be floated quite aggressively, but + the code generator expects unboxed values to be case-bound (in contrast to + boxed values). This requires a special case in 'mkNonRecFloat'. + See also Wrinkle (FS1) of Note [ANF-ising literal string arguments]. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind`. +It has one `OrdList` per class of `FloatInfo` with the following meaning: + + * Any binding in `top_floats` floats at least as far as `TopLvlFloatable`; + any binding in `lzy_floats` floats at least as far as `LazyContextFloatable`; + any binding in `str_floats` floats at least as far as `StrictContextFloatable`. + (See `floatsAtLeastAsFarAs`. + + * `top_floats`, `lzy_floats` and `str_floats` are in dependency order + For example, no binding in `top_floats` may scope over a binding in + `str_floats`. + +(It is always safe to put the whole telescope in `str_floats`.) +There are several operations for creating and combining `Floats` that maintain +these properties. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the `FloatInfo` of the `Floats` (e.g., the highest class of non-empty +`OrdList`): + + * If we want to float to the top-level (`x = <>; ...`), we may take all + bindings that are `TopLvlFloatable` and leave the rest inside the binding. + This is encoded in a `FloatDecision` of `FloatSome TopLvlFloatable`. + * If we want to float locally (let or app), then the floating decision is + `FloatAll` or `FloatNone`; see Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + | BoundVal -- ^ A value binding (E.g., a 'LetBound' that is an HNF) + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + ppr BoundVal = text "Letv" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { top_floats :: !(OrdList FloatingBind) + , lzy_floats :: !(OrdList FloatingBind) + , str_floats :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] + ppr (Floats top lzy str) = text "Floats" <> braces (vcat (map ppr [top, lzy, str])) + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs TopLvlFloatable _ = True +floatsAtLeastAsFarAs _ TopLvlFloatable = False +floatsAtLeastAsFarAs LazyContextFloatable _ = True +floatsAtLeastAsFarAs _ LazyContextFloatable = False +floatsAtLeastAsFarAs StrictContextFloatable StrictContextFloatable = True + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (BoundVal, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- See Note [BindInfo and FloatInfo], Wrinkle (FI1) + -- for why it's not BoundVal + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted is_hnf = exprIsHNF rhs is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats nilOL nilOL nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats b1 b2 b3) = isNilOL b1 && isNilOL b2 && isNilOL b3 -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats (Floats top lzy str) = top `appOL` lzy `appOL` str unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) +unitFloat = snocFloat emptyFloats -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Computes the \"worst\" 'FloatInfo' for a 'Floats', e.g., the 'FloatInfo' +-- of the innermost 'OrdList' which is non-empty. +floatsInfo :: Floats -> FloatInfo +floatsInfo floats + | not (isNilOL (str_floats floats)) = StrictContextFloatable + | not (isNilOL (lzy_floats floats)) = LazyContextFloatable + | otherwise = TopLvlFloatable + +-- | Append a 'FloatingBind' `b` to a 'Floats' telescope `bs` that may reference any +-- binding of the 'Floats'. +-- This function picks the appropriate 'OrdList' in `bs` that `b` is appended to, +-- respecting its 'FloatInfo' and scoping. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb@(Float bind bound info) + | CaseBound <- bound + , TopLvlFloatable <- info + , NonRec _ rhs <- bind + , exprIsTickedString rhs + -- Always insert Literal (strings) at the front. + -- They won't scope over any existing binding in `floats` and it is where we + -- expect all literal strings in `cpeBind Rec{}`. + = floats { top_floats = fb `consOL` top_floats floats } + | otherwise + = snoc_at floats fb (max (floatsInfo floats) info) + -- max: Respect scoping, hence `floatsInfo`, and respect info of `fb` +snocFloat floats fb at UnsafeEqualityCase{} -- treat it like an ok-for-spec Float + = snoc_at floats fb (max (floatsInfo floats) LazyContextFloatable) +snocFloat floats fb at FloatTick{} + = snoc_at floats fb (floatsInfo floats) -- Ticks are simply snoced + +snoc_at :: Floats -> FloatingBind -> FloatInfo -> Floats +snoc_at floats fb info = case info of + TopLvlFloatable -> floats { top_floats = top_floats floats `snocOL` fb } + LazyContextFloatable -> floats { lzy_floats = lzy_floats floats `snocOL` fb } + StrictContextFloatable -> floats { str_floats = str_floats floats `snocOL` fb } + +-- | Put all floats with 'FloatInfo' less than or equal to the given one in the +-- left partition, the rest in the right. Morally, +-- +-- > partitionFloats info fs = partition (<= info) fs +-- +partitionFloats :: FloatInfo -> Floats -> (Floats, Floats) +partitionFloats info (Floats top lzy str) = case info of + TopLvlFloatable -> (Floats top nilOL nilOL, Floats nilOL lzy str) + LazyContextFloatable -> (Floats top lzy nilOL, Floats nilOL nilOL str) + StrictContextFloatable -> (Floats top lzy str, Floats nilOL nilOL nilOL) + +-- | Push floats into lower buckets so that `info` floats at least as far as any +-- non-empty buckets of the `Floats`. +-- I.e., `push_down_floats LazyContextFloatable fs` will have empty +-- `top_floats`. +push_down_floats :: FloatInfo -> Floats -> Floats +push_down_floats info fs@(Floats top lzy str) = case info of + TopLvlFloatable -> fs + LazyContextFloatable -> Floats nilOL (top `appOL` lzy) str + StrictContextFloatable -> Floats nilOL nilOL (getFloats fs) + +-- | Cons a 'FloatingBind' `b` to a 'Floats' telescope `bs` which scopes over +-- `b`. This function appropriately pushes around bindings in the 'OrdList's of +-- `bs` so that `b` is the very first binding in the resulting telescope. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb at FloatTick{} floats = + floats { top_floats = fb `consOL` top_floats floats } +consFloat fb@(Float _ _ info) floats = case info of + TopLvlFloatable -> floats' { top_floats = fb `consOL` top_floats floats' } + LazyContextFloatable -> floats' { lzy_floats = fb `consOL` lzy_floats floats' } + StrictContextFloatable -> floats' { str_floats = fb `consOL` str_floats floats' } + where + floats' = push_down_floats info floats +consFloat fb at UnsafeEqualityCase{} floats = -- like the LazyContextFloatable Float case + floats' { lzy_floats = fb `consOL` lzy_floats floats' } + where + floats' = push_down_floats LazyContextFloatable floats + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + -- After having pushed down floats in inner, we can simply zip with up. + zipFloats outer (push_down_floats (floatsInfo outer) inner) + +-- | Zip up two telescopes which don't scope over each other. +zipFloats :: Floats -> Floats -> Floats +zipFloats floats1 floats2 + = Floats + { top_floats = top_floats floats1 `appOL` top_floats floats2 + , lzy_floats = lzy_floats floats1 `appOL` lzy_floats floats2 + , str_floats = str_floats floats1 `appOL` str_floats floats2 + } -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- For top level only; we don't expect any Strict or LazyContextFloatable 'FloatInfo' +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2132,85 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? + +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + + + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (floatsInfo floats <= max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2465,33 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (top, ticks1) = foldlOL f (nilOL,nilOL) (top_floats floats) + (lzy, ticks2) = foldlOL f (nilOL,ticks1) (lzy_floats floats) + (str, ticks3) = foldlOL f (nilOL,ticks2) (str_floats floats) + in (Floats top lzy str, ticks3) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f@(Float _ BoundVal _) + -- don't need to wrap the tick around a value; nothing to execute. + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a11cdd713f0029d952cc3039d99eea82e0a3e2c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a11cdd713f0029d952cc3039d99eea82e0a3e2c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 16:20:11 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 04 Oct 2023 12:20:11 -0400 Subject: [Git][ghc/ghc][wip/T23442] CorePrep: Refactor FloatingBind (#23442) Message-ID: <651d90bb20ab2_18f529b165db822226c@gitlab.mail> Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC Commits: 41475800 by Sebastian Graf at 2023-10-04T18:18:14+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- fulsom 0.0% -0.3% ida 0.0% +0.1% linear 0.0% +0.1% mandel2 0.0% -0.4% pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min -0.0% -1.7% Max +0.0% +0.1% Geometric Mean -0.0% -0.0% ``` - - - - - 2 changed files: - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. Flatten nested lets as much as possible. + See Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,51 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Very often (caveat in Wrinkle (FCP1) below, `v` is actually used and the thunk +closure was in vain. +Hence we carry around a bunch of floated bindings with us so that we can leave +behind more values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's simply like any other ok-for-spec-eval Float (see `mkNonRecFloat`) that has + a non-DEFAULT Case alternative to bind the unsafe coercion field of the Refl + constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + +Wrinkles: + (FCP1) + Let floating as above is not necessarily an optimisation if `v` doesn't + up being evaluated. In that case, we allocate a 4 word thunk closure for `v` + but won't need to allocate separate closures for `sat` (2 words) and the + `(:)` conapp (3 words), thus saving at least one word, depending on how much + the set of FVs between `sat` and `(:)` overlap. + The pros and cons of this so called "let-from-let" transformation are well + characterised in Section 3.3 of the paper + "Let-floating: moving bindings to give faster programs". + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +603,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +624,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (top_floats floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { top_floats = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { top_floats = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +656,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +673,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +683,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +694,30 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = FloatSome TopLvlFloatable + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs + +data FloatDecision + = FloatNone + | FloatAll + | FloatSome !FloatInfo -- ^ Float all bindings with <= this info + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + FloatSome info -> partitionFloats info floats + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +803,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +854,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +908,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +931,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1174,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1220,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1232,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1311,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1343,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1456,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1479,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1495,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1509,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1543,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1791,159 +1812,319 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it is a (let-bound) value +(`BoundVal`), or otherwise whether it will be `CaseBound` or `LetBound`. +Depending on the `BindInfo`, the `FloatingBind` encodes ... + + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> ... }` + * `BoundVal`: A let binding `let x = rhs in ...`, and `rhs` is an HNF + * `LetBound`: A let binding `let x = rhs in ...`, and `rhs` is not an HNF + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is either ok-for-spec-eval +(See Note [Speculative evaluation]), unlifted, strictly used (and perhaps +lifted), or a literal string (Wrinkle (FI1) below). + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +All lazy (and hence lifted) bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Wrinkles: + (FI1) + String literals are currently the only kind of unlifted binding that may + live at the top-level. Indeed, they will be floated quite aggressively, but + the code generator expects unboxed values to be case-bound (in contrast to + boxed values). This requires a special case in 'mkNonRecFloat'. + See also Wrinkle (FS1) of Note [ANF-ising literal string arguments]. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind`. +It has one `OrdList` per class of `FloatInfo` with the following meaning: + + * Any binding in `top_floats` floats at least as far as `TopLvlFloatable`; + any binding in `lzy_floats` floats at least as far as `LazyContextFloatable`; + any binding in `str_floats` floats at least as far as `StrictContextFloatable`. + (See `floatsAtLeastAsFarAs`. + + * `top_floats`, `lzy_floats` and `str_floats` are in dependency order + For example, no binding in `top_floats` may scope over a binding in + `str_floats`. + +(It is always safe to put the whole telescope in `str_floats`.) +There are several operations for creating and combining `Floats` that maintain +these properties. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the `FloatInfo` of the `Floats` (e.g., the highest class of non-empty +`OrdList`): + + * If we want to float to the top-level (`x = <>; ...`), we may take all + bindings that are `TopLvlFloatable` and leave the rest inside the binding. + This is encoded in a `FloatDecision` of `FloatSome TopLvlFloatable`. + * If we want to float locally (let or app), then the floating decision is + `FloatAll` or `FloatNone`; see Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + | BoundVal -- ^ A value binding (E.g., a 'LetBound' that is an HNF) + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + ppr BoundVal = text "Letv" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { top_floats :: !(OrdList FloatingBind) + , lzy_floats :: !(OrdList FloatingBind) + , str_floats :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] + ppr (Floats top lzy str) = text "Floats" <> braces (vcat (map ppr [top, lzy, str])) + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs TopLvlFloatable _ = True +floatsAtLeastAsFarAs _ TopLvlFloatable = False +floatsAtLeastAsFarAs LazyContextFloatable _ = True +floatsAtLeastAsFarAs _ LazyContextFloatable = False +floatsAtLeastAsFarAs StrictContextFloatable StrictContextFloatable = True + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (BoundVal, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- See Note [BindInfo and FloatInfo], Wrinkle (FI1) + -- for why it's not BoundVal + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted is_hnf = exprIsHNF rhs is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats nilOL nilOL nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats b1 b2 b3) = isNilOL b1 && isNilOL b2 && isNilOL b3 -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats (Floats top lzy str) = top `appOL` lzy `appOL` str unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) +unitFloat = snocFloat emptyFloats -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Computes the \"worst\" 'FloatInfo' for a 'Floats', e.g., the 'FloatInfo' +-- of the innermost 'OrdList' which is non-empty. +floatsInfo :: Floats -> FloatInfo +floatsInfo floats + | not (isNilOL (str_floats floats)) = StrictContextFloatable + | not (isNilOL (lzy_floats floats)) = LazyContextFloatable + | otherwise = TopLvlFloatable + +-- | Append a 'FloatingBind' `b` to a 'Floats' telescope `bs` that may reference any +-- binding of the 'Floats'. +-- This function picks the appropriate 'OrdList' in `bs` that `b` is appended to, +-- respecting its 'FloatInfo' and scoping. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb@(Float bind bound info) + | CaseBound <- bound + , TopLvlFloatable <- info + , NonRec _ rhs <- bind + , exprIsTickedString rhs + -- Always insert Literal (strings) at the front. + -- They won't scope over any existing binding in `floats` and it is where we + -- expect all literal strings in `cpeBind Rec{}`. + = floats { top_floats = fb `consOL` top_floats floats } + | otherwise + = snoc_at floats fb (max (floatsInfo floats) info) + -- max: Respect scoping, hence `floatsInfo`, and respect info of `fb` +snocFloat floats fb at UnsafeEqualityCase{} -- treat it like an ok-for-spec Float + = snoc_at floats fb (max (floatsInfo floats) LazyContextFloatable) +snocFloat floats fb at FloatTick{} + = snoc_at floats fb (floatsInfo floats) -- Ticks are simply snoced + +snoc_at :: Floats -> FloatingBind -> FloatInfo -> Floats +snoc_at floats fb info = case info of + TopLvlFloatable -> floats { top_floats = top_floats floats `snocOL` fb } + LazyContextFloatable -> floats { lzy_floats = lzy_floats floats `snocOL` fb } + StrictContextFloatable -> floats { str_floats = str_floats floats `snocOL` fb } + +-- | Put all floats with 'FloatInfo' less than or equal to the given one in the +-- left partition, the rest in the right. Morally, +-- +-- > partitionFloats info fs = partition (<= info) fs +-- +partitionFloats :: FloatInfo -> Floats -> (Floats, Floats) +partitionFloats info (Floats top lzy str) = case info of + TopLvlFloatable -> (Floats top nilOL nilOL, Floats nilOL lzy str) + LazyContextFloatable -> (Floats top lzy nilOL, Floats nilOL nilOL str) + StrictContextFloatable -> (Floats top lzy str, Floats nilOL nilOL nilOL) + +-- | Push floats into lower buckets so that `info` floats at least as far as any +-- non-empty buckets of the `Floats`. +-- I.e., `push_down_floats LazyContextFloatable fs` will have empty +-- `top_floats`. +push_down_floats :: FloatInfo -> Floats -> Floats +push_down_floats info fs@(Floats top lzy str) = case info of + TopLvlFloatable -> fs + LazyContextFloatable -> Floats nilOL (top `appOL` lzy) str + StrictContextFloatable -> Floats nilOL nilOL (getFloats fs) + +-- | Cons a 'FloatingBind' `b` to a 'Floats' telescope `bs` which scopes over +-- `b`. This function appropriately pushes around bindings in the 'OrdList's of +-- `bs` so that `b` is the very first binding in the resulting telescope. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb at FloatTick{} floats = + floats { top_floats = fb `consOL` top_floats floats } +consFloat fb@(Float _ _ info) floats = case info of + TopLvlFloatable -> floats' { top_floats = fb `consOL` top_floats floats' } + LazyContextFloatable -> floats' { lzy_floats = fb `consOL` lzy_floats floats' } + StrictContextFloatable -> floats' { str_floats = fb `consOL` str_floats floats' } + where + floats' = push_down_floats info floats +consFloat fb at UnsafeEqualityCase{} floats = -- like the LazyContextFloatable Float case + floats' { lzy_floats = fb `consOL` lzy_floats floats' } + where + floats' = push_down_floats LazyContextFloatable floats + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + -- After having pushed down floats in inner, we can simply zip with up. + zipFloats outer (push_down_floats (floatsInfo outer) inner) + +-- | Zip up two telescopes which don't scope over each other. +zipFloats :: Floats -> Floats -> Floats +zipFloats floats1 floats2 + = Floats + { top_floats = top_floats floats1 `appOL` top_floats floats2 + , lzy_floats = lzy_floats floats1 `appOL` lzy_floats floats2 + , str_floats = str_floats floats1 `appOL` str_floats floats2 + } -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- For top level only; we don't expect any Strict or LazyContextFloatable 'FloatInfo' +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2132,85 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? + +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + + + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (floatsInfo floats <= max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2465,33 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (top, ticks1) = foldlOL f (nilOL,nilOL) (top_floats floats) + (lzy, ticks2) = foldlOL f (nilOL,ticks1) (lzy_floats floats) + (str, ticks3) = foldlOL f (nilOL,ticks2) (str_floats floats) + in (Floats top lzy str, ticks3) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f@(Float _ BoundVal _) + -- don't need to wrap the tick around a value; nothing to execute. + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/41475800e10b5800b71be84f6ae99b5170bc8e1d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/41475800e10b5800b71be84f6ae99b5170bc8e1d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 16:47:45 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 04 Oct 2023 12:47:45 -0400 Subject: [Git][ghc/ghc][wip/andreask/keep-auto-rules] 72 commits: base: Advertise linear time of readFloat Message-ID: <651d97315c5ea_18f529bc1cd9c22348b@gitlab.mail> Simon Peyton Jones pushed to branch wip/andreask/keep-auto-rules at Glasgow Haskell Compiler / GHC Commits: 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8a72a7ad by Andreas Klebinger at 2023-10-04T15:59:48+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/FastString.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6672dce0bf53c10f17610aeb66fe5a546b32d44b...8a72a7ade0d6414376dea23396086115d6b089d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6672dce0bf53c10f17610aeb66fe5a546b32d44b...8a72a7ade0d6414376dea23396086115d6b089d6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 18:28:32 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 04 Oct 2023 14:28:32 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" Message-ID: <651daed0afc95_18f529e5a3dc825383@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: bb407a32 by Matthew Pickering at 2023-10-04T14:27:43-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - d1d3455b by John Ericson at 2023-10-04T14:27:44-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> Apply 1 suggestion(s) to 1 file(s) - - - - - 8271cc80 by Ben Gamari at 2023-10-04T14:27:44-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - c90e5890 by Andreas Klebinger at 2023-10-04T14:27:45-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - b490351e by Bryan Richter at 2023-10-04T14:27:45-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 19 changed files: - .gitlab/test-metrics.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Driver/Pipeline/Execute.hs - driver/ghci/ghci-wrapper.cabal.in - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Packages.hs - rts/sm/NonMoving.h - − testsuite/tests/driver/T16737.hs - − testsuite/tests/driver/T16737.stdout - − testsuite/tests/driver/T16737include/T16737.h - testsuite/tests/driver/all.T - + testsuite/tests/th/T23309.c - + testsuite/tests/th/T23309.hs - + testsuite/tests/th/T23309.stderr - + testsuite/tests/th/T23309A.hs - + testsuite/tests/th/T23378.hs - + testsuite/tests/th/T23378.stderr - + testsuite/tests/th/T23378A.hs - testsuite/tests/th/all.T Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -781,12 +781,12 @@ getRegister' config plat expr return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) -- 3. Logic &&, || - CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (AND (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg - CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (ORR (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg @@ -1070,13 +1070,16 @@ getRegister' config plat expr -- | Is a given number encodable as a bitmask immediate? -- -- https://stackoverflow.com/questions/30904718/range-of-immediate-values-in-armv8-a64-assembly -isAArch64Bitmask :: Integer -> Bool +isAArch64Bitmask :: Width -> Integer -> Bool -- N.B. zero and ~0 are not encodable as bitmask immediates -isAArch64Bitmask 0 = False -isAArch64Bitmask n - | n == bit 64 - 1 = False -isAArch64Bitmask n = - check 64 || check 32 || check 16 || check 8 +isAArch64Bitmask width n = + assert (width `elem` [W32,W64]) $ + case n of + 0 -> False + _ | n == bit (widthInBits width) - 1 + -> False -- 1111...1111 + | otherwise + -> (width == W64 && check 64) || check 32 || check 16 || check 8 where -- Check whether @n@ can be represented as a subpattern of the given -- width. ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -411,19 +411,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do includePathsQuoteImplicit cmdline_include_paths) let include_paths = include_paths_quote ++ include_paths_global - -- pass -D or -optP to preprocessor when compiling foreign C files - -- (#16737). Doing it in this way is simpler and also enable the C - -- compiler to perform preprocessing and parsing in a single pass, - -- but it may introduce inconsistency if a different pgm_P is specified. - let opts = getOpts dflags opt_P - aug_imports = augmentImports dflags opts - - more_preprocessor_opts = concat - [ ["-Xpreprocessor", i] - | not hcc - , i <- aug_imports - ] - let gcc_extra_viac_flags = extraGccViaCFlags dflags let pic_c_flags = picCCOpts dflags @@ -512,7 +499,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do ++ [ "-include", ghcVersionH ] ++ framework_paths ++ include_paths - ++ more_preprocessor_opts ++ pkg_extra_cc_opts )) ===================================== driver/ghci/ghci-wrapper.cabal.in ===================================== @@ -29,4 +29,4 @@ Executable ghci -- We need to call the versioned ghc executable because the unversioned -- GHC executable is a wrapper that doesn't call FreeConsole and so -- breaks an interactive process like GHCi. See #21889, #14150 and #13411 - CPP-Options: -DEXE_PATH="ghc- at ProjectVersion@" + cc-options: -DEXE_PATH="ghc- at ProjectVersion@" ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -515,8 +515,8 @@ createVersionWrapper pkg versioned_exe install_path = do | otherwise = 0 cmd ghcPath (["-no-hs-main", "-o", install_path, "-I"++version_wrapper_dir - , "-DEXE_PATH=\"" ++ versioned_exe ++ "\"" - , "-DINTERACTIVE_PROCESS=" ++ show interactive + , "-optc-DEXE_PATH=\"" ++ versioned_exe ++ "\"" + , "-optc-DINTERACTIVE_PROCESS=" ++ show interactive ] ++ wrapper_files) {- ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -297,14 +297,11 @@ rtsPackageArgs = package rts ? do libzstdIncludeDir <- getSetting LibZstdIncludeDir libzstdLibraryDir <- getSetting LibZstdLibDir + -- Arguments passed to GHC when compiling C and .cmm sources. let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\"" - -- Set the namespace for the rts fs functions - , arg $ "-DFS_NAMESPACE=rts" - , arg $ "-DCOMPILING_RTS" , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] @@ -333,9 +330,16 @@ rtsPackageArgs = package rts ? do , "-fno-omit-frame-pointer" , "-g3" , "-O0" ] + -- Set the namespace for the rts fs functions + , arg $ "-DFS_NAMESPACE=rts" + + , arg $ "-DCOMPILING_RTS" , inputs ["**/RtsMessages.c", "**/Trace.c"] ? - arg ("-DProjectVersion=" ++ show projectVersion) + pure + ["-DProjectVersion=" ++ show projectVersion + , "-DRtsWay=\"rts_" ++ show way ++ "\"" + ] , input "**/RtsUtils.c" ? pure [ "-DProjectVersion=" ++ show projectVersion @@ -353,6 +357,7 @@ rtsPackageArgs = package rts ? do , "-DTargetVendor=" ++ show targetVendor , "-DGhcUnregisterised=" ++ show ghcUnreg , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DRtsWay=\"rts_" ++ show way ++ "\"" ] -- We're after pur performance here. So make sure fast math and ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE ((uintptr_t)1 << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/driver/T16737.hs deleted ===================================== @@ -1,32 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -DFOO=2 -optP=-DBAR=3 -optc=-DBAZ=5 -optcxx=-DBAZ=7 #-} - -import Language.Haskell.TH.Syntax - -do - let code = unlines - [ "#if defined(__cplusplus)" - , "extern \"C\" {" - , "#endif" - , "#include " - , "int FUN(void) {" - , " return FOO * BAR * BAZ;" - , "}" - , "#if defined(__cplusplus)" - , "}" - , "#endif" - ] - addForeignSource LangC code - addForeignSource LangCxx code - pure [] - -foreign import ccall unsafe "c_value" - c_value :: IO Int - -foreign import ccall unsafe "cxx_value" - cxx_value :: IO Int - -main :: IO () -main = do - print =<< c_value - print =<< cxx_value ===================================== testsuite/tests/driver/T16737.stdout deleted ===================================== @@ -1,2 +0,0 @@ -30 -42 ===================================== testsuite/tests/driver/T16737include/T16737.h deleted ===================================== @@ -1,7 +0,0 @@ -#pragma once - -#if defined(__cplusplus) -#define FUN cxx_value -#else -#define FUN c_value -#endif ===================================== testsuite/tests/driver/all.T ===================================== @@ -285,12 +285,6 @@ test('inline-check', [omit_ways(['hpc', 'profasm'])] test('T14452', js_broken(22261), makefile_test, []) test('T14923', normal, makefile_test, []) test('T15396', normal, compile_and_run, ['-package ghc']) -test('T16737', - [extra_files(['T16737include/']), - req_th, - req_c, - expect_broken_for(16541, ghci_ways)], - compile_and_run, ['-optP=-isystem -optP=T16737include']) test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) ===================================== testsuite/tests/th/T23309.c ===================================== @@ -0,0 +1,8 @@ +#define _GNU_SOURCE 1 +#include + +const char* foo(int e) { + static char s[256]; + sprintf(s, "The value of e is: %u", e); + return s; +} ===================================== testsuite/tests/th/T23309.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23309 where + +import Foreign.C.String +import Language.Haskell.TH +import System.IO + +import T23309A + +$(do runIO $ do + cstr <- c_foo 42 + str <- peekCString cstr + hPutStrLn stderr str + hFlush stderr + return []) ===================================== testsuite/tests/th/T23309.stderr ===================================== @@ -0,0 +1 @@ +The value of e is: 42 ===================================== testsuite/tests/th/T23309A.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE CPP #-} +module T23309A (c_foo) where + +import Foreign.C.String +import Foreign.C.Types + +#if defined(mingw32_HOST_OS) +# if defined(i386_HOST_ARCH) +# define CALLCONV stdcall +# elif defined(x86_64_HOST_ARCH) +# define CALLCONV ccall +# else +# error Unknown mingw32 arch +# endif +#else +# define CALLCONV ccall +#endif + +foreign import CALLCONV unsafe "foo" c_foo :: CInt -> IO CString ===================================== testsuite/tests/th/T23378.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23378 where + +import Foreign.C.String +import Language.Haskell.TH +import System.IO + +import T23378A + +$(do runIO $ do + hPrint stderr isatty + hFlush stderr + return []) ===================================== testsuite/tests/th/T23378.stderr ===================================== @@ -0,0 +1 @@ +False ===================================== testsuite/tests/th/T23378A.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE CPP #-} +module T23378A where + +import Foreign.C.Types +import System.IO.Unsafe + +isatty :: Bool +isatty = + unsafePerformIO (c_isatty 1) == 1 +{-# NOINLINE isatty #-} + +#if defined(mingw32_HOST_OS) +# define SYM "_isatty" +#else +# define SYM "isatty" +#endif + +foreign import ccall unsafe SYM + c_isatty :: CInt -> IO CInt ===================================== testsuite/tests/th/all.T ===================================== @@ -589,6 +589,8 @@ test('T23829_hasty', normal, compile_fail, ['']) test('T23829_hasty_b', normal, compile_fail, ['']) test('T23927', normal, compile_and_run, ['']) test('T23954', normal, compile_and_run, ['']) +test('T23309', [extra_files(['T23309A.hs']), req_c], multimod_compile, ['T23309', '-v0 T23309.c -optc-fPIC']) +test('T23378', [extra_files(['T23378A.hs'])], multimod_compile, ['T23378', '-v0']) test('T23962', normal, compile_and_run, ['']) test('T23968', normal, compile_and_run, ['']) test('T23971', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16522f85e1264718fd7f4902d5abaea3cd78c492...b490351e2b98bf05ba6da6e29ae67b74e398b6ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16522f85e1264718fd7f4902d5abaea3cd78c492...b490351e2b98bf05ba6da6e29ae67b74e398b6ce You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 18:29:14 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 04 Oct 2023 14:29:14 -0400 Subject: [Git][ghc/ghc][wip/az/epa-hasannotation-class] EPA: Introduce HasAnnotation class Message-ID: <651daefa9468_18f529e268974254034@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-hasannotation-class at Glasgow Haskell Compiler / GHC Commits: 81e6a4d0 by Alan Zimmerman at 2023-10-04T19:28:54+01:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 10 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/ThToHs.hs - utils/check-exact/Orphans.hs - utils/check-exact/Utils.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2187,6 +2187,6 @@ type instance Anno FastString = SrcAnn NoEpAnns type instance Anno (DotFieldOcc (GhcPass p)) = SrcAnn NoEpAnns -instance (Anno a ~ SrcSpanAnn' (EpAnn an)) +instance (Anno a ~ SrcSpanAnn' (EpAnn an), NoAnn an) => WrapXRec (GhcPass p) a where wrapXRec = noLocA ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -108,6 +108,7 @@ type instance Anno Name = SrcSpanAnnN type instance Anno Id = SrcSpanAnnN type IsSrcSpanAnn p a = ( Anno (IdGhcP p) ~ SrcSpanAnn' (EpAnn a), + NoAnn a, IsPass p) instance UnXRec (GhcPass p) where ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -541,7 +541,7 @@ mkHsOpTy prom ty1 op ty2 = HsOpTy noAnn prom ty1 op ty2 mkHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppTy t1 t2 - = addCLocAA t1 t2 (HsAppTy noExtField t1 (parenthesizeHsType appPrec t2)) + = addCLocA t1 t2 (HsAppTy noExtField t1 (parenthesizeHsType appPrec t2)) mkHsAppTys :: LHsType (GhcPass p) -> [LHsType (GhcPass p)] -> LHsType (GhcPass p) @@ -550,7 +550,7 @@ mkHsAppTys = foldl' mkHsAppTy mkHsAppKindTy :: LHsType (GhcPass p) -> LHsToken "@" (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppKindTy ty at k - = addCLocAA ty k (HsAppKindTy noExtField ty at k) + = addCLocA ty k (HsAppKindTy noExtField ty at k) {- ************************************************************************ ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -232,14 +232,14 @@ mkLamCaseMatchGroup origin lam_variant (L l matches) = mkMatchGroup origin (L l $ map fixCtxt matches) where fixCtxt (L a match) = L a match{m_ctxt = LamAlt lam_variant} -mkLocatedList :: Semigroup a +mkLocatedList :: (Semigroup a, NoAnn an) => [GenLocated (SrcAnn a) e2] -> LocatedAn an [GenLocated (SrcAnn a) e2] mkLocatedList ms = case nonEmpty ms of Nothing -> noLocA [] Just ms1 -> L (noAnnSrcSpan $ locA $ combineLocsA (NE.head ms1) (NE.last ms1)) ms mkHsApp :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -mkHsApp e1 e2 = addCLocAA e1 e2 (HsApp noComments e1 e2) +mkHsApp e1 e2 = addCLocA e1 e2 (HsApp noComments e1 e2) mkHsAppWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) @@ -250,7 +250,7 @@ mkHsAppWith mkLocated e1 e2 = mkLocated e1 e2 (HsApp noAnn e1 e2) mkHsApps :: LHsExpr (GhcPass id) -> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id) -mkHsApps = mkHsAppsWith addCLocAA +mkHsApps = mkHsAppsWith addCLocA mkHsAppsWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) @@ -260,7 +260,7 @@ mkHsAppsWith mkHsAppsWith mkLocated = foldl' (mkHsAppWith mkLocated) mkHsAppType :: LHsExpr GhcRn -> LHsWcType GhcRn -> LHsExpr GhcRn -mkHsAppType e t = addCLocAA t_body e (HsAppType noExtField e noHsTok paren_wct) +mkHsAppType e t = addCLocA t_body e (HsAppType noExtField e noHsTok paren_wct) where t_body = hswc_body t paren_wct = t { hswc_body = parenthesizeHsType appPrec t_body } @@ -1832,5 +1832,3 @@ rec_field_expl_impl rec_flds (RecFieldsDotDot { .. }) = ImplicitFieldBinders { implFlBndr_field = foExt fld , implFlBndr_binders = collectPatBinders CollNoDictBinders rhs } - - ===================================== compiler/GHC/Parser.y ===================================== @@ -4120,7 +4120,7 @@ sL1 :: HasLoc a => a -> b -> Located b sL1 x = sL (getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1a #-} -sL1a :: HasLoc a => a -> b -> LocatedAn t b +sL1a :: (HasLoc a, HasAnnotation t) => a -> b -> GenLocated t b sL1a x = sL (noAnnSrcSpan $ getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1n #-} @@ -4132,7 +4132,7 @@ sLL :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c sLL x y = sL (comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLa #-} -sLLa :: (HasLoc a, HasLoc b) => a -> b -> c -> LocatedAn t c +sLLa :: (HasLoc a, HasLoc b, NoAnn t) => a -> b -> c -> LocatedAn t c sLLa x y = sL (noAnnSrcSpan $ comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLl #-} ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -71,13 +71,14 @@ module GHC.Parser.Annotation ( mapLocA, combineLocsA, combineSrcSpansA, - addCLocA, addCLocAA, + addCLocA, -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. - noLocA, getLocA, + HasAnnotation(..), + noLocA, + getLocA, noSrcSpanA, - noAnnSrcSpan, -- ** Working with comments in annotations noComments, comment, addCommentsToSrcAnn, setCommentsSrcAnn, @@ -994,15 +995,15 @@ la2na l = noAnnSrcSpan (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -la2la :: LocatedAn ann1 a2 -> LocatedAn ann2 a2 +la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 la2la (L la a) = L (noAnnSrcSpan (locA la)) a l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = noAnnSrcSpan (locA l) +l2l l = SrcSpanAnn EpAnnNotUsed (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -na2la :: SrcSpanAnn' a -> SrcAnn ann +na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) reLoc :: LocatedAn a e -> Located e @@ -1022,18 +1023,21 @@ reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- -noLocA :: a -> LocatedAn an a -noLocA = L (SrcSpanAnn EpAnnNotUsed noSrcSpan) +class HasAnnotation e where + noAnnSrcSpan :: SrcSpan -> e + +instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where + noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l + +noLocA :: (HasAnnotation e) => a -> GenLocated e a +noLocA = L (noAnnSrcSpan noSrcSpan) getLocA :: GenLocated (SrcSpanAnn' a) e -> SrcSpan getLocA = getHasLoc -noSrcSpanA :: SrcAnn ann +noSrcSpanA :: (HasAnnotation e) => e noSrcSpanA = noAnnSrcSpan noSrcSpan -noAnnSrcSpan :: SrcSpan -> SrcAnn ann -noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l - -- --------------------------------------------------------------------- class NoAnn a where @@ -1163,7 +1167,7 @@ epAnnComments (EpAnn _ _ cs) = cs sortLocatedA :: [GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e] sortLocatedA = sortBy (leftmost_smallest `on` getLocA) -mapLocA :: (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b +mapLocA :: (NoAnn ann) => (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b mapLocA f (L l a) = L (noAnnSrcSpan l) (f a) -- AZ:TODO: move this somewhere sane @@ -1179,11 +1183,9 @@ combineSrcSpansA (SrcSpanAnn aa la) (SrcSpanAnn ab lb) SrcSpanAnn (EpAnn (widenAnchorR anc (realSrcSpan l)) an cs) l -- | Combine locations from two 'Located' things and add them to a third thing -addCLocA :: GenLocated (SrcSpanAnn' a) e1 -> GenLocated SrcSpan e2 -> e3 -> GenLocated (SrcAnn ann) e3 -addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (getLoc b)) c - -addCLocAA :: GenLocated (SrcSpanAnn' a1) e1 -> GenLocated (SrcSpanAnn' a2) e2 -> e3 -> GenLocated (SrcAnn ann) e3 -addCLocAA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (locA $ getLoc b)) c +addCLocA :: (HasLoc a, HasLoc b, HasAnnotation l) + => a -> b -> c -> GenLocated l c +addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (getHasLoc a) (getHasLoc b)) c -- --------------------------------------------------------------------- -- Utilities for manipulating EpAnnComments @@ -1332,26 +1334,33 @@ instance Semigroup EpAnnComments where EpaCommentsBalanced cs1 as1 <> EpaCommentsBalanced cs2 as2 = EpaCommentsBalanced (cs1 ++ cs2) (as1++as2) -instance NoAnn NoEpAnns where - noAnn = NoEpAnns - instance Semigroup AnnListItem where (AnnListItem l1) <> (AnnListItem l2) = AnnListItem (l1 <> l2) -instance NoAnn AnnListItem where - noAnn = AnnListItem [] - - instance Semigroup (AnnSortKey tag) where NoAnnSortKey <> x = x x <> NoAnnSortKey = x AnnSortKey ls1 <> AnnSortKey ls2 = AnnSortKey (ls1 <> ls2) +instance Monoid (AnnSortKey tag) where + mempty = NoAnnSortKey + +-- --------------------------------------------------------------------- +-- NoAnn instances + +instance NoAnn NoEpAnns where + noAnn = NoEpAnns + +instance NoAnn AnnListItem where + noAnn = AnnListItem [] + +instance NoAnn AnnContext where + noAnn = AnnContext Nothing [] [] + instance NoAnn AnnList where noAnn = AnnList Nothing Nothing Nothing [] [] -instance Monoid (AnnSortKey tag) where - mempty = NoAnnSortKey +-- --------------------------------------------------------------------- instance NoAnn NameAnn where noAnn = NameAnnTrailing [] ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -714,7 +714,7 @@ checkCTupSize tup_size * * ********************************************************************* -} -wrapGenSpan :: a -> LocatedAn an a +wrapGenSpan :: (NoAnn an) => a -> LocatedAn an a -- Wrap something in a "generatedSrcSpan" -- See Note [Rebindable syntax and HsExpansion] wrapGenSpan x = L (noAnnSrcSpan generatedSrcSpan) x @@ -742,10 +742,10 @@ genHsVar nm = HsVar noExtField $ wrapGenSpan nm genAppType :: HsExpr GhcRn -> HsType (NoGhcTc GhcRn) -> HsExpr GhcRn genAppType expr ty = HsAppType noExtField (wrapGenSpan expr) noHsTok (mkEmptyWildCardBndrs (wrapGenSpan ty)) -genLHsLit :: HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) +genLHsLit :: (NoAnn an) => HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) genLHsLit = wrapGenSpan . HsLit noAnn -genHsIntegralLit :: IntegralLit -> LocatedAn an (HsExpr GhcRn) +genHsIntegralLit :: (NoAnn an) => IntegralLit -> LocatedAn an (HsExpr GhcRn) genHsIntegralLit = genLHsLit . HsInt noExtField genHsTyLit :: FastString -> HsType GhcRn @@ -767,11 +767,15 @@ genWildPat = wrapGenSpan $ WildPat noExtField genSimpleFunBind :: Name -> [LPat GhcRn] -> LHsExpr GhcRn -> LHsBind GhcRn genSimpleFunBind fun pats expr - = L gen $ genFunBind (L gen fun) - [mkMatch (mkPrefixFunRhs (L gen fun)) pats expr + = L genA $ genFunBind (L genN fun) + [mkMatch (mkPrefixFunRhs (L genN fun)) pats expr emptyLocalBinds] where - gen = noAnnSrcSpan generatedSrcSpan + genA :: SrcSpanAnnA + genA = noAnnSrcSpan generatedSrcSpan + + genN :: SrcSpanAnnN + genN = noAnnSrcSpan generatedSrcSpan genFunBind :: LocatedN Name -> [LMatch GhcRn (LHsExpr GhcRn)] -> HsBind GhcRn ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -142,13 +142,13 @@ getL = CvtM (\_ loc -> Right (loc,loc)) setL :: SrcSpan -> CvtM () setL loc = CvtM (\_ _ -> Right (loc, ())) -returnLA :: e -> CvtM (LocatedAn ann e) +returnLA :: (NoAnn ann) => e -> CvtM (LocatedAn ann e) returnLA x = CvtM (\_ loc -> Right (loc, L (noAnnSrcSpan loc) x)) returnJustLA :: a -> CvtM (Maybe (LocatedA a)) returnJustLA = fmap Just . returnLA -wrapParLA :: (LocatedAn ann a -> b) -> a -> CvtM b +wrapParLA :: (NoAnn ann) => (LocatedAn ann a -> b) -> a -> CvtM b wrapParLA add_par x = CvtM (\_ loc -> Right (loc, add_par (L (noAnnSrcSpan loc) x))) wrapMsg :: ThingBeingConverted -> CvtM' ConversionFailReason a -> CvtM' RunSpliceFailReason a ===================================== utils/check-exact/Orphans.hs ===================================== @@ -62,9 +62,6 @@ instance NoAnn AddEpAnn where instance NoAnn AnnKeywordId where noAnn = Annlarrowtail {- gotta pick one -} -instance NoAnn AnnContext where - noAnn = AnnContext Nothing [] [] - instance NoAnn EpAnnSumPat where noAnn = EpAnnSumPat noAnn noAnn noAnn ===================================== utils/check-exact/Utils.hs ===================================== @@ -371,9 +371,9 @@ setAnchorHsModule hsmod anc cs = hsmod { hsmodExt = (hsmodExt hsmod) {hsmodAnn = -- |Version of l2l that preserves the anchor, immportant if it has an -- updated AnchorOperation -moveAnchor :: Monoid b => SrcAnn a -> SrcAnn b +moveAnchor :: NoAnn b => SrcAnn a -> SrcAnn b moveAnchor (SrcSpanAnn EpAnnNotUsed l) = noAnnSrcSpan l -moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc mempty cs) l +moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc noAnn cs) l -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81e6a4d0073938904410de96a32fef1f2ff23c9b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81e6a4d0073938904410de96a32fef1f2ff23c9b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 19:50:26 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 04 Oct 2023 15:50:26 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] wip Message-ID: <651dc202a82da_18f529106f75d826328a@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: bb8990ea by GHC GitLab CI at 2023-10-04T19:50:14+00:00 wip - - - - - 3 changed files: - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs - testsuite/driver/testlib.py Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -116,7 +116,7 @@ lib/settings : config.mk @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ - @echo ',("unlit command", "$$topdir/bin/$(CrossCompilePrefix)unlit")' >> $@ + @echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@ @echo ',("target os", "$(HaskellTargetOs)")' >> $@ @@ -187,9 +187,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - if [ -d "$$dest/bin" ]; then \ - chmod ugo+rx "$$dest"/bin/*; \ - fi # Work around #17418 on Darwin if [ -e "${XATTR}" ]; then \ "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -20,6 +20,7 @@ import GHC.Toolchain.Program (prgFlags) import qualified Data.Set as Set import Oracles.Flavour import Debug.Trace +import qualified System.Directory.Extra as IO {- Note [Binary distributions] @@ -171,6 +172,7 @@ buildBinDistDir root conf at BindistConfig{..} = do -- let rtsDir = "rts" let ghcBuildDir = root -/- stageString library_stage + ghcLibBinBuildDir = root -/- stageString executable_stage -/- "lib" -/- "bin" bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform rtsIncludeDir = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir @@ -181,6 +183,7 @@ buildBinDistDir root conf at BindistConfig{..} = do createDirectory bindistFilesDir createDirectory (bindistFilesDir -/- "bin") createDirectory (bindistFilesDir -/- "lib") + createDirectory (bindistFilesDir -/- "lib" -/- "bin") -- Also create wrappers with version suffixes (#20074) forM_ (bin_targets ++ iserv_targets) $ \(pkg, prog_path) -> do let orig_filename = takeFileName prog_path @@ -227,6 +230,9 @@ buildBinDistDir root conf at BindistConfig{..} = do IO.createFileLink version_prog versioned_runhaskell_path copyDirectory (ghcBuildDir -/- "lib") bindistFilesDir + ld <- liftIO $ IO.listDirectory ghcLibBinBuildDir + traceShowM ld + copyDirectory ghcLibBinBuildDir bindistFilesDir copyDirectory (rtsIncludeDir) bindistFilesDir when windowsHost $ createGhcii (bindistFilesDir -/- "bin") ===================================== testsuite/driver/testlib.py ===================================== @@ -144,7 +144,6 @@ def js_skip( name, opts ): # expect broken for the JS backend def js_broken( bug: IssueNumber ): - print ("js_broken", js_arch()) if js_arch(): return expect_broken(bug); else: @@ -728,7 +727,6 @@ def opsys( os: str ) -> bool: return config.os == os def arch( arch: str ) -> bool: - print(arch, config.arch) return config.arch == arch def wordsize( ws: int ) -> bool: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bb8990ea3c247bd407239d07cafc082f6ef1b66f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bb8990ea3c247bd407239d07cafc082f6ef1b66f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 4 22:28:34 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 04 Oct 2023 18:28:34 -0400 Subject: [Git][ghc/ghc][wip/az/ghc-cpp] Process nested include files Message-ID: <651de71287acb_18f529145ec6e429982b@gitlab.mail> Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: 4ba68570 by Alan Zimmerman at 2023-10-04T23:27:25+01:00 Process nested include files Also move PpState out of Lexer.x, so it is easy to evolve it in a ghci session, loading utils/check-cpp/Main.hs - - - - - 8 changed files: - compiler/GHC.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Driver/Main.hs - compiler/GHC/Parser/HaddockLex.x - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PreProcess.hs - hadrian/src/Settings/Default.hs - utils/check-cpp/Main.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -334,7 +334,7 @@ import GHCi.RemoteTypes import qualified GHC.Parser as Parser import GHC.Parser.Lexer hiding (initParserState) -import GHC.Parser.PreProcess (initParserState) +import GHC.Parser.PreProcess (initParserState, initPpState) import GHC.Parser.Annotation import GHC.Parser.Utils ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -19,7 +19,7 @@ import GHC.Prelude import GHC.Cmm.Expr -import GHC.Parser.Lexer hiding (getInput, setInput) +import GHC.Parser.Lexer hiding (getInput, setInput, AlexInput) import GHC.Cmm.Parser.Monad import GHC.Types.SrcLoc import GHC.Types.Unique.FM ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -193,8 +193,8 @@ import GHC.CoreToStg ( coreToStg ) import GHC.Parser.Errors.Types import GHC.Parser -import GHC.Parser.Lexer as Lexer hiding (initPpState, initParserState) -import GHC.Parser.PreProcess (initParserState) +import GHC.Parser.Lexer as Lexer hiding (initParserState) +import GHC.Parser.PreProcess (initParserState, PpState) import GHC.Tc.Module import GHC.Tc.Utils.Monad ===================================== compiler/GHC/Parser/HaddockLex.x ===================================== @@ -9,7 +9,7 @@ import GHC.Prelude import GHC.Data.FastString import GHC.Hs.Doc -import GHC.Parser.Lexer +import GHC.Parser.Lexer hiding (AlexInput) import GHC.Parser.Annotation import GHC.Types.SrcLoc import GHC.Types.SourceText ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -58,7 +58,7 @@ module GHC.Parser.Lexer ( Token(..), lexer, lexerDbg, ParserOpts(..), mkParserOpts, PState (..), initParserState, initPragState, - PpState(..), initPpState, PpContext(..), + -- PpState(..), initPpState, PpContext(..), P(..), ParseResult(POk, PFailed), allocateComments, allocatePriorComments, allocateFinalComments, MonadP(..), @@ -82,7 +82,7 @@ module GHC.Parser.Lexer ( addPsMessage, -- * for integration with the preprocessor queueIgnoredToken, - getInput, setInput + getInput, setInput, AlexInput(..) ) where import GHC.Prelude @@ -2785,28 +2785,28 @@ data PState a = PState { -- of the action, it is the *current* token. Do I understand -- correctly? --- | Use for emulating (limited) CPP preprocessing in GHC. --- TODO: move this into PreProcess, and make a param on PState -data PpState = PpState { - pp_defines :: !(Map String [String]), - pp_continuation :: ![Located Token], - -- pp_context :: ![PpContext], - pp_context :: ![Token], -- What preprocessor directive we are currently processing - pp_accepting :: !Bool - } - deriving (Show) +-- -- | Use for emulating (limited) CPP preprocessing in GHC. +-- -- TODO: move this into PreProcess, and make a param on PState +-- data PpState = PpState { +-- pp_defines :: !(Map String [String]), +-- pp_continuation :: ![Located Token], +-- -- pp_context :: ![PpContext], +-- pp_context :: ![Token], -- What preprocessor directive we are currently processing +-- pp_accepting :: !Bool +-- } +-- deriving (Show) data PpContext = PpContextIf [Located Token] deriving (Show) -- TODO: delete -initPpState :: PpState -initPpState = PpState - { pp_defines = Map.empty - , pp_continuation = [] - , pp_context = [] - , pp_accepting = True - } +-- initPpState :: PpState +-- initPpState = PpState +-- { pp_defines = Map.empty +-- , pp_continuation = [] +-- , pp_context = [] +-- , pp_accepting = True +-- } data ALRContext = ALRNoLayout Bool{- does it contain commas? -} Bool{- is it a 'let' block? -} @@ -2904,6 +2904,7 @@ getLastLoc :: P p PsSpan getLastLoc = P $ \s@(PState { last_loc = last_loc }) -> POk s last_loc data AlexInput = AI !PsLoc !StringBuffer + deriving (Show) {- Note [Unicode in Alex] ===================================== compiler/GHC/Parser/PreProcess.hs ===================================== @@ -15,6 +15,7 @@ module GHC.Parser.PreProcess ( ) where import Data.Char +import Data.Map (Map) import qualified Data.Map as Map import qualified Data.Set as Set import Debug.Trace (trace) @@ -22,7 +23,7 @@ import GHC.Data.FastString import qualified GHC.Data.Strict as Strict import GHC.Data.StringBuffer import GHC.Parser.Errors.Ppr () -import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), PpState (..), Token (..)) +import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), Token (..)) import qualified GHC.Parser.Lexer as Lexer import GHC.Prelude import GHC.Types.SrcLoc @@ -46,6 +47,15 @@ initPpState = , pp_accepting = True } +data PpState = PpState { + pp_defines :: !(Map String [String]), + pp_continuation :: ![Located Token], + -- pp_context :: ![PpContext], + pp_context :: ![Token], -- What preprocessor directive we are currently processing + pp_accepting :: !Bool + } + deriving (Show) + -- --------------------------------------------------------------------- lexer, lexerDbg :: Bool -> (Located Token -> P PpState a) -> P PpState a ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -161,8 +161,10 @@ stage1Packages = do , if winTarget then win32 else unix ] , when (not cross) - [ haddock - , hpcBin + [ + -- haddock + -- , + hpcBin , iserv , runGhc , ghcToolchainBin ===================================== utils/check-cpp/Main.hs ===================================== @@ -5,6 +5,7 @@ import Control.Monad.IO.Class import Data.Char import Data.Data hiding (Fixity) import Data.List +import Data.Map (Map) import qualified Data.Map as Map import Debug.Trace import GHC @@ -19,21 +20,17 @@ import qualified GHC.Driver.Session as GHC import GHC.Hs.Dump import qualified GHC.LanguageExtensions as LangExt import GHC.Parser.Errors.Ppr () -import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), PpState (..), Token (..)) +import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), Token (..)) import qualified GHC.Parser.Lexer as GHC -import qualified GHC.Parser.Lexer as Lexer hiding (initParserState) -import qualified GHC.Parser.PreProcess as Lexer (initParserState) +import qualified GHC.Parser.Lexer as Lexer import GHC.Types.Error import GHC.Types.SrcLoc import GHC.Utils.Error import GHC.Utils.Outputable - import qualified Text.Parsec as Parsec import Text.Parsec.Char as PS import Text.Parsec.Combinator as PS import Text.Parsec.Prim as PS - --- import qualified Text.Parsec as Parsec import Text.Parsec.String (Parser) -- import Text.Parsec.Char @@ -52,6 +49,28 @@ showAst ast = type PP = P PpState +initPpState :: PpState +initPpState = + PpState + { pp_defines = Map.empty + , pp_includes = Map.empty + , pp_include_stack = [] + , pp_continuation = [] + , pp_context = [] + , pp_accepting = True + } + +data PpState = PpState + { pp_defines :: !(Map String [String]) + , pp_includes :: !(Map String StringBuffer) + , pp_include_stack :: ![Lexer.AlexInput] + , pp_continuation :: ![Located Token] + , pp_context :: ![Token] -- What preprocessor directive we are currently processing + , pp_accepting :: !Bool + } + deriving (Show) +-- deriving instance Show Lexer.AlexInput + -- ===================================================================== ppLexer, ppLexerDbg :: Bool -> (Located Token -> PP a) -> PP a @@ -74,7 +93,13 @@ ppLexer queueComments cont = in -- case tk of case (trace ("M.ppLexer:tk=" ++ show (unLoc tk)) tk) of - L _ ITeof -> contInner tk + L _ ITeof -> do + mInp <- popIncludeLoc + case mInp of + Nothing -> contInner tk + Just inp -> do + Lexer.setInput inp + ppLexer queueComments cont L _ (ITcpp continuation s) -> do if continuation then pushContinuation tk @@ -82,7 +107,8 @@ ppLexer queueComments cont = contIgnoreTok tk _ -> do state <- getCppState - case (trace ("CPP state:" ++ show state) state) of + -- case (trace ("CPP state:" ++ show state) state) of + case state of CppIgnoring -> contIgnoreTok tk _ -> contInner tk ) @@ -113,25 +139,28 @@ processCpp fs = do -- let s = cppInitial fs let s = cppInitial fs case regularParse cppDirective s of - Left err -> error $ show err - Right (CppDefine name def) -> do - ppDefine name def - Right (CppIfdef name) -> do - defined <- ppIsDefined name - setAccepting defined - Right (CppIfndef name) -> do - defined <- ppIsDefined name - setAccepting (not defined) - Right CppElse -> do - accepting <- getAccepting - setAccepting (not accepting) - return () - Right CppEndif -> do - -- TODO: nested states - setAccepting True - return () - - return (trace ("processCpp:s=" ++ show s) ()) + Left err -> error $ show err + Right (CppInclude filename) -> do + ppInclude filename + Right (CppDefine name def) -> do + ppDefine name def + Right (CppIfdef name) -> do + defined <- ppIsDefined name + setAccepting defined + Right (CppIfndef name) -> do + defined <- ppIsDefined name + setAccepting (not defined) + Right CppElse -> do + accepting <- getAccepting + setAccepting (not accepting) + return () + Right CppEndif -> do + -- TODO: nested states + setAccepting True + return () + + -- return (trace ("processCpp:s=" ++ show s) ()) + return () -- --------------------------------------------------------------------- -- Preprocessor state functions @@ -193,8 +222,42 @@ popContinuation = -- pp_context stack end ------------------- +-- pp_include start ----------------------- + +getInclude :: String -> PP (Maybe StringBuffer) +getInclude filename = P $ \s -> POk s (Map.lookup filename (pp_includes (pp s))) + +pushIncludeLoc :: Lexer.AlexInput -> PP () +pushIncludeLoc pos + = P $ \s -> POk s {pp = (pp s){ pp_include_stack = pos: pp_include_stack (pp s)}} () + +popIncludeLoc :: PP (Maybe Lexer.AlexInput) +popIncludeLoc = + P $ \s -> + let + (new_st,r) = case pp_include_stack (pp s) of + [] ->([], Nothing) + (h:t) -> (t, Just h) + in + POk s{pp = (pp s){pp_include_stack = new_st }} r + +-- pp_include end ------------------------- + -- definitions start -------------------- +ppInclude :: String -> PP () +ppInclude filename = do + mSrc <- getInclude filename + case mSrc of + Nothing -> return () + Just src -> do + origInput <- Lexer.getInput + pushIncludeLoc origInput + let loc = PsLoc (mkRealSrcLoc (mkFastString filename) 1 1) (BufPos 0) + Lexer.setInput (Lexer.AI loc src) + return $ trace ("ppInclude:mSrc=[" ++ show mSrc ++ "]") () + -- return $ trace ("ppInclude:filename=[" ++ filename ++ "]") () + ppDefine :: String -> [String] -> PP () ppDefine name val = P $ \s -> -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () @@ -227,7 +290,6 @@ type CppParser = Parsec String () regularParse :: Parser a -> String -> Either Parsec.ParseError a regularParse p = PS.parse p "" - -- TODO: delete this cppDefinition :: CppParser (String, [String]) cppDefinition = do @@ -239,11 +301,12 @@ cppDefinition = do return (name, definition) data CppDirective - = CppDefine String [String] - | CppIfdef String - | CppIfndef String - | CppElse - | CppEndif + = CppInclude String + | CppDefine String [String] + | CppIfdef String + | CppIfndef String + | CppElse + | CppEndif deriving (Show, Eq) cppDirective :: CppParser CppDirective @@ -252,32 +315,39 @@ cppDirective = do _ <- whiteSpace choice [ cppKw "define" >> cmdDefinition - -- , cppKw "include" CppIncludeKw - -- , cppKw "undef" CppUndefKw - -- , cppKw "error" CppErrorKw - , try$ cppKw "ifdef" >> cmdIfdef + , try $ cppKw "include" >> cmdInclude + , try $ cppKw "ifdef" >> cmdIfdef , cppKw "ifndef" >> cmdIfndef - -- , cppKw "if" CppIfKw - -- , cppKw "elif" CppElifKw , try $ cppKw "else" >> return CppElse , cppKw "endif" >> return CppEndif + -- , cppKw "if" CppIfKw + -- , cppKw "elif" CppElifKw + -- , cppKw "undef" CppUndefKw + -- , cppKw "error" CppErrorKw ] +cmdInclude :: CppParser CppDirective +cmdInclude = do + _ <- string "\"" + filename <- many1 (satisfy (\c -> not (isSpace c || c == '"'))) + _ <- string "\"" + return $ CppInclude filename + cmdDefinition :: CppParser CppDirective cmdDefinition = do - name <- cppToken - definition <- cppTokens - return $ CppDefine name definition + name <- cppToken + definition <- cppTokens + return $ CppDefine name definition cmdIfdef :: CppParser CppDirective cmdIfdef = do - name <- cppToken - return $ CppIfdef name + name <- cppToken + return $ CppIfdef name cmdIfndef :: CppParser CppDirective cmdIfndef = do - name <- cppToken - return $ CppIfndef name + name <- cppToken + return $ CppIfndef name cppKw :: String -> CppParser () cppKw kw = do @@ -334,10 +404,11 @@ directive. -- Emulate the parser type LibDir = FilePath +type Includes = [(String, [String])] -- parseString :: LibDir -> String -> IO (WarningMessages, Either ErrorMessages [Located Token]) -parseString :: LibDir -> String -> IO [Located Token] -parseString libdir str = ghcWrapper libdir $ do +parseString :: LibDir -> Includes -> String -> IO [Located Token] +parseString libdir includes str = ghcWrapper libdir $ do dflags0 <- initDynFlags let dflags = dflags0{extensionFlags = EnumSet.insert LangExt.GhcCpp (extensionFlags dflags0)} let pflags = initParserOpts dflags @@ -345,12 +416,15 @@ parseString libdir str = ghcWrapper libdir $ do liftIO $ putStrLn "-- parsing ----------" liftIO $ putStrLn str liftIO $ putStrLn "---------------------" - return $ strGetToks pflags "fake_test_file.hs" str + return $ strGetToks includes pflags "fake_test_file.hs" str -strGetToks :: Lexer.ParserOpts -> FilePath -> String -> [Located Token] -strGetToks popts filename str = reverse $ lexAll pstate +strGetToks :: Includes -> Lexer.ParserOpts -> FilePath -> String -> [Located Token] +-- strGetToks includes popts filename str = reverse $ lexAll pstate +strGetToks includes popts filename str = reverse $ lexAll (trace ("pstate=" ++ show initState) pstate) where - pstate = Lexer.initParserState popts buf loc + includeMap = Map.fromList $ map (\(k,v) -> (k, stringToStringBuffer (intercalate "\n" v))) includes + initState = initPpState { pp_includes = includeMap } + pstate = Lexer.initParserState initState popts buf loc loc = mkRealSrcLoc (mkFastString filename) 1 1 buf = stringToStringBuffer str -- cpp_enabled = Lexer.GhcCppBit `Lexer.xtest` Lexer.pExtsBitmap popts @@ -387,7 +461,7 @@ strParser str dflags filename = loc = mkRealSrcLoc (mkFastString filename) 1 1 buf = stringToStringBuffer str in - case unP parseModuleNoHaddock (Lexer.initParserState (initParserOpts dflags) buf loc) of + case unP parseModuleNoHaddock (Lexer.initParserState initPpState (initParserOpts dflags) buf loc) of PFailed pst -> let (warns, errs) = Lexer.getPsMessages pst in (GhcPsMessage <$> warns, Left $ GhcPsMessage <$> errs) @@ -506,9 +580,12 @@ libdirNow :: LibDir libdirNow = "/home/alanz/mysrc/git.haskell.org/worktree/bisect/_build/stage1/lib" doTest :: [String] -> IO () -doTest strings = do +doTest strings = doTestWithIncludes [] strings + +doTestWithIncludes :: Includes -> [String] -> IO () +doTestWithIncludes includes strings = do let test = intercalate "\n" strings - !tks <- parseString libdirNow test + !tks <- parseString libdirNow includes test putStrLn "-----------------------------------------" printToks (reverse tks) @@ -630,3 +707,26 @@ t8 = parseDefine (mkFastString "#define MIN_VERSION_ghc_exactprint(major1,major2 t9 :: Either Parsec.ParseError CppDirective t9 = regularParse cppDirective "#define VERSION_ghc_exactprint \"1.7.0.1\"" + +t10 :: IO () +t10 = do + doTestWithIncludes testIncludes + [ "#include \"bar.h\"" + , "" + , "#ifdef FOO" + , "x = 1" + , "#else" + , "x = 2" + , "#endif" + ] + +testIncludes :: Includes +testIncludes = + [ + ( "bar.h" + , ["#include \"sub.h\""] + ), + ( "sub.h" + , ["#define FOO"] + ) + ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ba68570d8f07162efc641474133bd0695e85a39 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ba68570d8f07162efc641474133bd0695e85a39 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 06:17:29 2023 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Thu, 05 Oct 2023 02:17:29 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/stability-flag Message-ID: <651e54f99086c_18f5291f122748320694@gitlab.mail> Josh Meredith pushed new branch wip/stability-flag at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/stability-flag You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 06:46:11 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Oct 2023 02:46:11 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" Message-ID: <651e5bb3205b_18f5291fd70e6434782f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0d9f1761 by Matthew Pickering at 2023-10-05T02:44:47-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 077d25ef by Ben Gamari at 2023-10-05T02:44:48-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - 36b85b26 by Andreas Klebinger at 2023-10-05T02:44:49-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 6edc3287 by Bryan Richter at 2023-10-05T02:44:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 18cd5d3e by Krzysztof Gogolewski at 2023-10-05T02:44:49-04:00 Add a test for #21348 - - - - - 34f92752 by Rewbert at 2023-10-05T02:44:51-04:00 Fixes #24046 - - - - - 15 changed files: - .gitlab/test-metrics.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Driver/Pipeline/Execute.hs - driver/ghci/ghci-wrapper.cabal.in - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Packages.hs - rts/sm/NonMoving.h - − testsuite/tests/driver/T16737.hs - − testsuite/tests/driver/T16737.stdout - − testsuite/tests/driver/T16737include/T16737.h - testsuite/tests/driver/all.T - + testsuite/tests/simplCore/should_compile/T21348.hs - testsuite/tests/simplCore/should_compile/all.T - + testsuite/tests/th/T24046.hs - testsuite/tests/th/all.T Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -781,12 +781,12 @@ getRegister' config plat expr return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) -- 3. Logic &&, || - CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (AND (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg - CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (ORR (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg @@ -1070,13 +1070,16 @@ getRegister' config plat expr -- | Is a given number encodable as a bitmask immediate? -- -- https://stackoverflow.com/questions/30904718/range-of-immediate-values-in-armv8-a64-assembly -isAArch64Bitmask :: Integer -> Bool +isAArch64Bitmask :: Width -> Integer -> Bool -- N.B. zero and ~0 are not encodable as bitmask immediates -isAArch64Bitmask 0 = False -isAArch64Bitmask n - | n == bit 64 - 1 = False -isAArch64Bitmask n = - check 64 || check 32 || check 16 || check 8 +isAArch64Bitmask width n = + assert (width `elem` [W32,W64]) $ + case n of + 0 -> False + _ | n == bit (widthInBits width) - 1 + -> False -- 1111...1111 + | otherwise + -> (width == W64 && check 64) || check 32 || check 16 || check 8 where -- Check whether @n@ can be represented as a subpattern of the given -- width. ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -411,19 +411,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do includePathsQuoteImplicit cmdline_include_paths) let include_paths = include_paths_quote ++ include_paths_global - -- pass -D or -optP to preprocessor when compiling foreign C files - -- (#16737). Doing it in this way is simpler and also enable the C - -- compiler to perform preprocessing and parsing in a single pass, - -- but it may introduce inconsistency if a different pgm_P is specified. - let opts = getOpts dflags opt_P - aug_imports = augmentImports dflags opts - - more_preprocessor_opts = concat - [ ["-Xpreprocessor", i] - | not hcc - , i <- aug_imports - ] - let gcc_extra_viac_flags = extraGccViaCFlags dflags let pic_c_flags = picCCOpts dflags @@ -512,7 +499,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do ++ [ "-include", ghcVersionH ] ++ framework_paths ++ include_paths - ++ more_preprocessor_opts ++ pkg_extra_cc_opts )) ===================================== driver/ghci/ghci-wrapper.cabal.in ===================================== @@ -29,4 +29,4 @@ Executable ghci -- We need to call the versioned ghc executable because the unversioned -- GHC executable is a wrapper that doesn't call FreeConsole and so -- breaks an interactive process like GHCi. See #21889, #14150 and #13411 - CPP-Options: -DEXE_PATH="ghc- at ProjectVersion@" + cc-options: -DEXE_PATH="ghc- at ProjectVersion@" ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -515,8 +515,8 @@ createVersionWrapper pkg versioned_exe install_path = do | otherwise = 0 cmd ghcPath (["-no-hs-main", "-o", install_path, "-I"++version_wrapper_dir - , "-DEXE_PATH=\"" ++ versioned_exe ++ "\"" - , "-DINTERACTIVE_PROCESS=" ++ show interactive + , "-optc-DEXE_PATH=\"" ++ versioned_exe ++ "\"" + , "-optc-DINTERACTIVE_PROCESS=" ++ show interactive ] ++ wrapper_files) {- ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -297,14 +297,11 @@ rtsPackageArgs = package rts ? do libzstdIncludeDir <- getSetting LibZstdIncludeDir libzstdLibraryDir <- getSetting LibZstdLibDir + -- Arguments passed to GHC when compiling C and .cmm sources. let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\"" - -- Set the namespace for the rts fs functions - , arg $ "-DFS_NAMESPACE=rts" - , arg $ "-DCOMPILING_RTS" , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] @@ -333,9 +330,16 @@ rtsPackageArgs = package rts ? do , "-fno-omit-frame-pointer" , "-g3" , "-O0" ] + -- Set the namespace for the rts fs functions + , arg $ "-DFS_NAMESPACE=rts" + + , arg $ "-DCOMPILING_RTS" , inputs ["**/RtsMessages.c", "**/Trace.c"] ? - arg ("-DProjectVersion=" ++ show projectVersion) + pure + ["-DProjectVersion=" ++ show projectVersion + , "-DRtsWay=\"rts_" ++ show way ++ "\"" + ] , input "**/RtsUtils.c" ? pure [ "-DProjectVersion=" ++ show projectVersion @@ -353,6 +357,7 @@ rtsPackageArgs = package rts ? do , "-DTargetVendor=" ++ show targetVendor , "-DGhcUnregisterised=" ++ show ghcUnreg , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DRtsWay=\"rts_" ++ show way ++ "\"" ] -- We're after pur performance here. So make sure fast math and ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE ((uintptr_t)1 << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/driver/T16737.hs deleted ===================================== @@ -1,32 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -DFOO=2 -optP=-DBAR=3 -optc=-DBAZ=5 -optcxx=-DBAZ=7 #-} - -import Language.Haskell.TH.Syntax - -do - let code = unlines - [ "#if defined(__cplusplus)" - , "extern \"C\" {" - , "#endif" - , "#include " - , "int FUN(void) {" - , " return FOO * BAR * BAZ;" - , "}" - , "#if defined(__cplusplus)" - , "}" - , "#endif" - ] - addForeignSource LangC code - addForeignSource LangCxx code - pure [] - -foreign import ccall unsafe "c_value" - c_value :: IO Int - -foreign import ccall unsafe "cxx_value" - cxx_value :: IO Int - -main :: IO () -main = do - print =<< c_value - print =<< cxx_value ===================================== testsuite/tests/driver/T16737.stdout deleted ===================================== @@ -1,2 +0,0 @@ -30 -42 ===================================== testsuite/tests/driver/T16737include/T16737.h deleted ===================================== @@ -1,7 +0,0 @@ -#pragma once - -#if defined(__cplusplus) -#define FUN cxx_value -#else -#define FUN c_value -#endif ===================================== testsuite/tests/driver/all.T ===================================== @@ -285,12 +285,6 @@ test('inline-check', [omit_ways(['hpc', 'profasm'])] test('T14452', js_broken(22261), makefile_test, []) test('T14923', normal, makefile_test, []) test('T15396', normal, compile_and_run, ['-package ghc']) -test('T16737', - [extra_files(['T16737include/']), - req_th, - req_c, - expect_broken_for(16541, ghci_ways)], - compile_and_run, ['-optP=-isystem -optP=T16737include']) test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) ===================================== testsuite/tests/simplCore/should_compile/T21348.hs ===================================== @@ -0,0 +1,97 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableInstances #-} + +module T21348 where + +import qualified Data.Map as M +import Data.Kind (Type) + +newtype Parser a = Parser { + runParser :: () -> (a -> Int) -> Int + } deriving (Functor) + +instance Applicative Parser where + pure a = Parser $ \_path ks -> ks a + {-# INLINE pure #-} + (<*>) m e = Parser $ \path ks -> let ks' a = runParser (a <$> e) path ks + in runParser m path ks' + {-# INLINE (<*>) #-} + +data Value = Object (M.Map String Value) | Unused + +class FromJSON a where + parseJSON :: Value -> Parser a + _unused :: a -> a + +instance FromJSON Bool where + parseJSON _ = pure False + _unused = id + +data Pa a = MkPa Bool a + +class RecordFromJSON f where + recordParseJSON :: () -> M.Map String Value -> Parser (Pa f) + +class RecordFromJSON2 f where + recordParseJSON2 :: M.Map String Value -> Parser f + +instance (RecordFromJSON2 b) => RecordFromJSON b where + recordParseJSON _ obj = MkPa <$> pure False + <*> recordParseJSON2 obj + {-# INLINE recordParseJSON #-} + +instance (FromJSON a) => RecordFromJSON2 a where + recordParseJSON2 obj = pure () *> (id <$> (id <$> parseJSON (obj M.! "x"))) + {-# INLINE recordParseJSON2 #-} + +data Rec :: [Type] -> Type where + RNil :: Rec '[] + RCons :: Field r -> Rec rs -> Rec (r ': rs) + +data Rec2 :: [Type] -> Type where + RNil2 :: Rec2 '[] + RCons2 :: DocField r -> Rec2 rs -> Rec2 (r ': rs) + +data Field x = Field x + +newtype DocField x = DocField (Field x) + +instance FromJSON (Rec '[]) where + parseJSON _ = undefined + _unused = id + +instance (FromJSON t, FromJSON (Rec rs)) => FromJSON (Rec (t ': rs)) where + parseJSON v = rebuild <$> parseJSON v <*> parseJSON v + where rebuild m rest = Field m `RCons` rest + _unused = id + +instance (RMap rs, FromJSON (Rec rs)) => FromJSON (Rec2 rs) where + parseJSON v = rmap DocField <$> parseJSON v + _unused = id + +class RMap rs where + rmap :: (forall x. Field x -> DocField x) -> Rec rs -> Rec2 rs + +instance RMap '[] where + rmap _ RNil = RNil2 + {-# INLINE rmap #-} + +instance RMap xs => RMap (x ': xs) where + rmap f (x `RCons` xs) = f x `RCons2` rmap f xs + {-# INLINE rmap #-} + +g :: RecordFromJSON a => Value -> Parser (Pa a) +g (Object r) = recordParseJSON () r +g Unused = undefined + +bug :: Value -> Parser (Pa (Rec2 '[Bool, Bool, Bool, Bool])) +bug = g ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -503,3 +503,4 @@ test('T23922a', normal, compile, ['-O']) test('T23952', [extra_files(['T23952a.hs'])], multimod_compile, ['T23952', '-v0 -O']) test('T24014', normal, compile, ['-dcore-lint']) test('T24029', normal, compile, ['']) +test('T21348', normal, compile, ['-O']) ===================================== testsuite/tests/th/T24046.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24046 where + +import Language.Haskell.TH.Syntax + +-- Test added in relation to this issue: https://gitlab.haskell.org/ghc/ghc/-/issues/24046 + +{-# NOINLINE foo #-} +foo = undefined + +$( let simplerule = [PragmaD $ RuleP "rejected-rule" Nothing foralld lhs rhs AllPhases] + + foralld = [RuleVar $ mkName "x", RuleVar $ mkName "y"] + + lhs = AppE (AppE (VarE $ mkName "foo") (VarE $ mkName "x")) (VarE $ mkName "y") + + rhs = AppE (AppE (VarE $ mkName "foo") (VarE $ mkName "y")) (VarE $ mkName "x") + in return simplerule) ===================================== testsuite/tests/th/all.T ===================================== @@ -146,6 +146,7 @@ test('T2817', normal, compile, ['-v0']) test('T2713', normal, compile_fail, ['-v0']) test('T2674', normal, compile_fail, ['-v0']) test('TH_emptycase', normal, compile, ['-v0']) +test('T24046', normal, compile, ['-v0']) test('T2386', [only_ways(['normal'])], makefile_test, ['T2386']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b490351e2b98bf05ba6da6e29ae67b74e398b6ce...34f927525bdc679ac56f53993c7911bcf5f68832 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b490351e2b98bf05ba6da6e29ae67b74e398b6ce...34f927525bdc679ac56f53993c7911bcf5f68832 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 09:35:52 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Oct 2023 05:35:52 -0400 Subject: [Git][ghc/ghc][master] Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" Message-ID: <651e8378bebe6_18f52923e43a68371875@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8 changed files: - compiler/GHC/Driver/Pipeline/Execute.hs - driver/ghci/ghci-wrapper.cabal.in - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Packages.hs - − testsuite/tests/driver/T16737.hs - − testsuite/tests/driver/T16737.stdout - − testsuite/tests/driver/T16737include/T16737.h - testsuite/tests/driver/all.T Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -411,19 +411,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do includePathsQuoteImplicit cmdline_include_paths) let include_paths = include_paths_quote ++ include_paths_global - -- pass -D or -optP to preprocessor when compiling foreign C files - -- (#16737). Doing it in this way is simpler and also enable the C - -- compiler to perform preprocessing and parsing in a single pass, - -- but it may introduce inconsistency if a different pgm_P is specified. - let opts = getOpts dflags opt_P - aug_imports = augmentImports dflags opts - - more_preprocessor_opts = concat - [ ["-Xpreprocessor", i] - | not hcc - , i <- aug_imports - ] - let gcc_extra_viac_flags = extraGccViaCFlags dflags let pic_c_flags = picCCOpts dflags @@ -512,7 +499,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do ++ [ "-include", ghcVersionH ] ++ framework_paths ++ include_paths - ++ more_preprocessor_opts ++ pkg_extra_cc_opts )) ===================================== driver/ghci/ghci-wrapper.cabal.in ===================================== @@ -29,4 +29,4 @@ Executable ghci -- We need to call the versioned ghc executable because the unversioned -- GHC executable is a wrapper that doesn't call FreeConsole and so -- breaks an interactive process like GHCi. See #21889, #14150 and #13411 - CPP-Options: -DEXE_PATH="ghc- at ProjectVersion@" + cc-options: -DEXE_PATH="ghc- at ProjectVersion@" ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -515,8 +515,8 @@ createVersionWrapper pkg versioned_exe install_path = do | otherwise = 0 cmd ghcPath (["-no-hs-main", "-o", install_path, "-I"++version_wrapper_dir - , "-DEXE_PATH=\"" ++ versioned_exe ++ "\"" - , "-DINTERACTIVE_PROCESS=" ++ show interactive + , "-optc-DEXE_PATH=\"" ++ versioned_exe ++ "\"" + , "-optc-DINTERACTIVE_PROCESS=" ++ show interactive ] ++ wrapper_files) {- ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -297,14 +297,11 @@ rtsPackageArgs = package rts ? do libzstdIncludeDir <- getSetting LibZstdIncludeDir libzstdLibraryDir <- getSetting LibZstdLibDir + -- Arguments passed to GHC when compiling C and .cmm sources. let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\"" - -- Set the namespace for the rts fs functions - , arg $ "-DFS_NAMESPACE=rts" - , arg $ "-DCOMPILING_RTS" , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] @@ -333,9 +330,16 @@ rtsPackageArgs = package rts ? do , "-fno-omit-frame-pointer" , "-g3" , "-O0" ] + -- Set the namespace for the rts fs functions + , arg $ "-DFS_NAMESPACE=rts" + + , arg $ "-DCOMPILING_RTS" , inputs ["**/RtsMessages.c", "**/Trace.c"] ? - arg ("-DProjectVersion=" ++ show projectVersion) + pure + ["-DProjectVersion=" ++ show projectVersion + , "-DRtsWay=\"rts_" ++ show way ++ "\"" + ] , input "**/RtsUtils.c" ? pure [ "-DProjectVersion=" ++ show projectVersion @@ -353,6 +357,7 @@ rtsPackageArgs = package rts ? do , "-DTargetVendor=" ++ show targetVendor , "-DGhcUnregisterised=" ++ show ghcUnreg , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DRtsWay=\"rts_" ++ show way ++ "\"" ] -- We're after pur performance here. So make sure fast math and ===================================== testsuite/tests/driver/T16737.hs deleted ===================================== @@ -1,32 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -DFOO=2 -optP=-DBAR=3 -optc=-DBAZ=5 -optcxx=-DBAZ=7 #-} - -import Language.Haskell.TH.Syntax - -do - let code = unlines - [ "#if defined(__cplusplus)" - , "extern \"C\" {" - , "#endif" - , "#include " - , "int FUN(void) {" - , " return FOO * BAR * BAZ;" - , "}" - , "#if defined(__cplusplus)" - , "}" - , "#endif" - ] - addForeignSource LangC code - addForeignSource LangCxx code - pure [] - -foreign import ccall unsafe "c_value" - c_value :: IO Int - -foreign import ccall unsafe "cxx_value" - cxx_value :: IO Int - -main :: IO () -main = do - print =<< c_value - print =<< cxx_value ===================================== testsuite/tests/driver/T16737.stdout deleted ===================================== @@ -1,2 +0,0 @@ -30 -42 ===================================== testsuite/tests/driver/T16737include/T16737.h deleted ===================================== @@ -1,7 +0,0 @@ -#pragma once - -#if defined(__cplusplus) -#define FUN cxx_value -#else -#define FUN c_value -#endif ===================================== testsuite/tests/driver/all.T ===================================== @@ -285,12 +285,6 @@ test('inline-check', [omit_ways(['hpc', 'profasm'])] test('T14452', js_broken(22261), makefile_test, []) test('T14923', normal, makefile_test, []) test('T15396', normal, compile_and_run, ['-package ghc']) -test('T16737', - [extra_files(['T16737include/']), - req_th, - req_c, - expect_broken_for(16541, ghci_ways)], - compile_and_run, ['-optP=-isystem -optP=T16737include']) test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8ff3134ed4aa323b0199ad683f72165e51a59ab6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8ff3134ed4aa323b0199ad683f72165e51a59ab6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 09:36:58 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Oct 2023 05:36:58 -0400 Subject: [Git][ghc/ghc][master] rts/nonmoving: Fix on LLP64 platforms Message-ID: <651e83baeba80_18f52923edbc643819d5@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - 1 changed file: - rts/sm/NonMoving.h Changes: ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE ((uintptr_t)1 << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f6010b98f560200997a9d84a4e07bfd0ad6e496 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f6010b98f560200997a9d84a4e07bfd0ad6e496 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 09:37:39 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Oct 2023 05:37:39 -0400 Subject: [Git][ghc/ghc][master] Fix isAArch64Bitmask for 32bit immediates. Message-ID: <651e83e3400de_18f52923ed90f43850b6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -781,12 +781,12 @@ getRegister' config plat expr return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) -- 3. Logic &&, || - CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (AND (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg - CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (ORR (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg @@ -1070,13 +1070,16 @@ getRegister' config plat expr -- | Is a given number encodable as a bitmask immediate? -- -- https://stackoverflow.com/questions/30904718/range-of-immediate-values-in-armv8-a64-assembly -isAArch64Bitmask :: Integer -> Bool +isAArch64Bitmask :: Width -> Integer -> Bool -- N.B. zero and ~0 are not encodable as bitmask immediates -isAArch64Bitmask 0 = False -isAArch64Bitmask n - | n == bit 64 - 1 = False -isAArch64Bitmask n = - check 64 || check 32 || check 16 || check 8 +isAArch64Bitmask width n = + assert (width `elem` [W32,W64]) $ + case n of + 0 -> False + _ | n == bit (widthInBits width) - 1 + -> False -- 1111...1111 + | otherwise + -> (width == W64 && check 64) || check 32 || check 16 || check 8 where -- Check whether @n@ can be represented as a subpattern of the given -- width. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f20d02f81e1e84887db311a475adb68ae3c3cfdc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f20d02f81e1e84887db311a475adb68ae3c3cfdc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 09:38:41 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Oct 2023 05:38:41 -0400 Subject: [Git][ghc/ghc][master] Work around perf note fetch failure Message-ID: <651e842164077_18f52923ed90f4392931@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 1 changed file: - .gitlab/test-metrics.sh Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/63afb701a1638d7bd32c34fb24a9fd3ff897b634 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/63afb701a1638d7bd32c34fb24a9fd3ff897b634 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 09:39:00 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Oct 2023 05:39:00 -0400 Subject: [Git][ghc/ghc][master] Add a test for #21348 Message-ID: <651e84347091e_18f52923ed46083931c9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 2 changed files: - + testsuite/tests/simplCore/should_compile/T21348.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== testsuite/tests/simplCore/should_compile/T21348.hs ===================================== @@ -0,0 +1,97 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableInstances #-} + +module T21348 where + +import qualified Data.Map as M +import Data.Kind (Type) + +newtype Parser a = Parser { + runParser :: () -> (a -> Int) -> Int + } deriving (Functor) + +instance Applicative Parser where + pure a = Parser $ \_path ks -> ks a + {-# INLINE pure #-} + (<*>) m e = Parser $ \path ks -> let ks' a = runParser (a <$> e) path ks + in runParser m path ks' + {-# INLINE (<*>) #-} + +data Value = Object (M.Map String Value) | Unused + +class FromJSON a where + parseJSON :: Value -> Parser a + _unused :: a -> a + +instance FromJSON Bool where + parseJSON _ = pure False + _unused = id + +data Pa a = MkPa Bool a + +class RecordFromJSON f where + recordParseJSON :: () -> M.Map String Value -> Parser (Pa f) + +class RecordFromJSON2 f where + recordParseJSON2 :: M.Map String Value -> Parser f + +instance (RecordFromJSON2 b) => RecordFromJSON b where + recordParseJSON _ obj = MkPa <$> pure False + <*> recordParseJSON2 obj + {-# INLINE recordParseJSON #-} + +instance (FromJSON a) => RecordFromJSON2 a where + recordParseJSON2 obj = pure () *> (id <$> (id <$> parseJSON (obj M.! "x"))) + {-# INLINE recordParseJSON2 #-} + +data Rec :: [Type] -> Type where + RNil :: Rec '[] + RCons :: Field r -> Rec rs -> Rec (r ': rs) + +data Rec2 :: [Type] -> Type where + RNil2 :: Rec2 '[] + RCons2 :: DocField r -> Rec2 rs -> Rec2 (r ': rs) + +data Field x = Field x + +newtype DocField x = DocField (Field x) + +instance FromJSON (Rec '[]) where + parseJSON _ = undefined + _unused = id + +instance (FromJSON t, FromJSON (Rec rs)) => FromJSON (Rec (t ': rs)) where + parseJSON v = rebuild <$> parseJSON v <*> parseJSON v + where rebuild m rest = Field m `RCons` rest + _unused = id + +instance (RMap rs, FromJSON (Rec rs)) => FromJSON (Rec2 rs) where + parseJSON v = rmap DocField <$> parseJSON v + _unused = id + +class RMap rs where + rmap :: (forall x. Field x -> DocField x) -> Rec rs -> Rec2 rs + +instance RMap '[] where + rmap _ RNil = RNil2 + {-# INLINE rmap #-} + +instance RMap xs => RMap (x ': xs) where + rmap f (x `RCons` xs) = f x `RCons2` rmap f xs + {-# INLINE rmap #-} + +g :: RecordFromJSON a => Value -> Parser (Pa a) +g (Object r) = recordParseJSON () r +g Unused = undefined + +bug :: Value -> Parser (Pa (Rec2 '[Bool, Bool, Bool, Bool])) +bug = g ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -503,3 +503,4 @@ test('T23922a', normal, compile, ['-O']) test('T23952', [extra_files(['T23952a.hs'])], multimod_compile, ['T23952', '-v0 -O']) test('T24014', normal, compile, ['-dcore-lint']) test('T24029', normal, compile, ['']) +test('T21348', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/242102f4e7631ef47bfb5219355ecf8aad4bc842 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/242102f4e7631ef47bfb5219355ecf8aad4bc842 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 09:39:28 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Oct 2023 05:39:28 -0400 Subject: [Git][ghc/ghc][master] Fixes #24046 Message-ID: <651e845059f5e_18f52923eda1c0393343@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 2 changed files: - + testsuite/tests/th/T24046.hs - testsuite/tests/th/all.T Changes: ===================================== testsuite/tests/th/T24046.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24046 where + +import Language.Haskell.TH.Syntax + +-- Test added in relation to this issue: https://gitlab.haskell.org/ghc/ghc/-/issues/24046 + +{-# NOINLINE foo #-} +foo = undefined + +$( let simplerule = [PragmaD $ RuleP "rejected-rule" Nothing foralld lhs rhs AllPhases] + + foralld = [RuleVar $ mkName "x", RuleVar $ mkName "y"] + + lhs = AppE (AppE (VarE $ mkName "foo") (VarE $ mkName "x")) (VarE $ mkName "y") + + rhs = AppE (AppE (VarE $ mkName "foo") (VarE $ mkName "y")) (VarE $ mkName "x") + in return simplerule) ===================================== testsuite/tests/th/all.T ===================================== @@ -146,6 +146,7 @@ test('T2817', normal, compile, ['-v0']) test('T2713', normal, compile_fail, ['-v0']) test('T2674', normal, compile_fail, ['-v0']) test('TH_emptycase', normal, compile, ['-v0']) +test('T24046', normal, compile, ['-v0']) test('T2386', [only_ways(['normal'])], makefile_test, ['T2386']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d390bce49398409878a8580a78bbe7a3bd08914 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d390bce49398409878a8580a78bbe7a3bd08914 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 10:22:14 2023 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Thu, 05 Oct 2023 06:22:14 -0400 Subject: [Git][ghc/ghc][wip/T24052] 17 commits: Simplify and correct nasty case in coercion opt Message-ID: <651e8e56931c6_18f52925e5ba6c404891@gitlab.mail> sheaf pushed to branch wip/T24052 at Glasgow Haskell Compiler / GHC Commits: bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 2b2352db by Ben Gamari at 2023-10-05T10:22:10+00:00 testsuite: Fix invalid string literal `"\+"` is not a valid Python string; this should have been `r"\+"`. - - - - - 2c8c8ce8 by Ben Gamari at 2023-10-05T10:22:10+00:00 rts/nonmoving: Reflow notes - - - - - 7ef28e05 by Ben Gamari at 2023-10-05T10:22:10+00:00 testsuite: Run some tests unconditionally in nonmoving ways Improve test coverage of the nonmoving collector by running a small subset of tests unconditionally with the nonmoving collector. Fixes #24052. - - - - - 30 changed files: - .gitlab/test-metrics.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - docs/users_guide/using-warnings.rst - driver/ghci/ghci-wrapper.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Packages.hs - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - m4/find_ld.m4 - rts/include/rts/ghc_ffi.h - rts/sm/NonMoving.c - rts/sm/NonMoving.h - testsuite/driver/testlib.py - testsuite/tests/array/should_run/all.T - testsuite/tests/concurrent/should_run/all.T - − testsuite/tests/driver/T16737.hs - − testsuite/tests/driver/T16737.stdout - − testsuite/tests/driver/T16737include/T16737.h - testsuite/tests/driver/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a0c75cd55628aad1964e3e4e53b842bdf3de384...7ef28e059328638c18acd75585c4837e5a8161ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a0c75cd55628aad1964e3e4e53b842bdf3de384...7ef28e059328638c18acd75585c4837e5a8161ce You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 10:26:27 2023 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Thu, 05 Oct 2023 06:26:27 -0400 Subject: [Git][ghc/ghc][wip/jsbits-userguide] 78 commits: base: Advertise linear time of readFloat Message-ID: <651e8f536e64d_18f529259a1440405288@gitlab.mail> Josh Meredith pushed to branch wip/jsbits-userguide at Glasgow Haskell Compiler / GHC Commits: 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - b2e15d07 by Josh Meredith at 2023-10-05T21:25:47+11:00 JS/userguide: wip explanation of writing jsbits - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload_ghc_libs.py - .gitlab/test-metrics.sh - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/526d45d096e131bdb02187ba52a4342441d55251...b2e15d0781af6dd7dc11e0f0812486b4eb87b705 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/526d45d096e131bdb02187ba52a4342441d55251...b2e15d0781af6dd7dc11e0f0812486b4eb87b705 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 11:56:33 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 07:56:33 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 2 commits: TEST_HAVE_INTREE Message-ID: <651ea470aa6fb_18f5292821235c422110@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: f662bd86 by GHC GitLab CI at 2023-10-05T11:55:56+00:00 TEST_HAVE_INTREE - - - - - 3af1bd50 by GHC GitLab CI at 2023-10-05T11:56:18+00:00 askDynGhcPrograms, force cross - - - - - 4 changed files: - .gitlab/ci.sh - hadrian/src/Oracles/Flavour.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Settings/Program.hs Changes: ===================================== .gitlab/ci.sh ===================================== @@ -643,11 +643,18 @@ function test_hadrian() { rm proftest.hs fi + # The check-exact check-ppr programs etc can not be built when testing a cross compiler. + if [ -z "${CROSS_TARGET:-}" ]; then + TEST_HAVE_INTREE="--test-have-intree-files" + else + TEST_HAVE_INTREE="" + fi + run_hadrian \ test \ --summary-junit=./junit.xml \ - --test-have-intree-files \ --test-compiler="${test_compiler}" \ + $TEST_HAVE_INTREE \ "runtest.opts+=${RUNTEST_ARGS:-}" \ "runtest.opts+=--unexpected-output-dir=$TOP/unexpected-test-output" \ || fail "hadrian main testsuite" ===================================== hadrian/src/Oracles/Flavour.hs ===================================== @@ -12,6 +12,7 @@ module Oracles.Flavour import Base import Flavour import Settings (flavour) +import Oracles.Setting newtype DynGhcPrograms = DynGhcPrograms Stage deriving (Show, Typeable, Eq, Hashable, Binary, NFData) @@ -23,7 +24,10 @@ type instance RuleResult GhcProfiled = Bool oracles :: Rules () oracles = do - void $ addOracle $ \(DynGhcPrograms stage) -> flip dynamicGhcPrograms stage =<< flavour + void $ addOracle $ \(DynGhcPrograms stage) -> do + cross <- crossStage stage + from_flavour <- flip dynamicGhcPrograms stage =<< flavour + return (from_flavour && not cross) void $ addOracle $ \(GhcProfiled stage) -> ghcProfiled <$> flavour <*> pure (succStage stage) ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -26,6 +26,7 @@ import Utilities import qualified Data.Set as Set import qualified Text.Parsec as Parsec +import Oracles.Flavour docRoot :: FilePath docRoot = "doc" @@ -268,7 +269,7 @@ buildPackageDocumentation = do -- Build Haddock documentation -- TODO: Pass the correct way from Rules via Context. - dynamicPrograms <- flip dynamicGhcPrograms (stage context)=<< flavour + dynamicPrograms <- askDynGhcPrograms (stage context) let haddockWay = if dynamicPrograms then dynamic else vanilla -- Build the dependencies of the package we are going to build documentation for ===================================== hadrian/src/Settings/Program.hs ===================================== @@ -14,16 +14,15 @@ import Packages programContext :: Stage -> Package -> Action Context programContext stage pkg = do profiled <- askGhcProfiled stage - dynGhcProgs <- askDynGhcPrograms stage --dynamicGhcPrograms =<< flavour + dynGhcProgs <- askDynGhcPrograms stage -- Have to build static if it's a cross stage as we won't distribute the libraries built for the host. - cross <- crossStage stage - return $ Context stage pkg (wayFor profiled dynGhcProgs cross) Final + return $ Context stage pkg (wayFor profiled dynGhcProgs) Final - where wayFor prof dyn cross + where wayFor prof dyn | prof && dyn = error "programContext: profiling+dynamic not supported" | pkg == ghc && prof && notStage0 stage = profiling - | dyn && notStage0 stage && not cross = dynamic + | dyn && notStage0 stage = dynamic | otherwise = vanilla notStage0 (Stage0 {}) = False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bb8990ea3c247bd407239d07cafc082f6ef1b66f...3af1bd50f8dcb93c995b595601c5e5736544028e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bb8990ea3c247bd407239d07cafc082f6ef1b66f...3af1bd50f8dcb93c995b595601c5e5736544028e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 12:40:20 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 08:40:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-internals-move Message-ID: <651eaeb4d86bd_18f5292952ab10437395@gitlab.mail> Ben Gamari pushed new branch wip/ghc-internals-move at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-internals-move You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 12:44:17 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 08:44:17 -0400 Subject: [Git][ghc/ghc][wip/ghc-internals-move] 20 commits: Move src/Foreign/Concurrent.hs back to base Message-ID: <651eafa198e1e_18f5292952d194437553@gitlab.mail> Ben Gamari pushed to branch wip/ghc-internals-move at Glasgow Haskell Compiler / GHC Commits: 37d3d13e by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Foreign/Concurrent.hs back to base - - - - - de44cbdf by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Foreign/Ptr.hs back to base - - - - - b3c9f94e by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Array/Byte.hs back to base - - - - - 60199ffc by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Fixed.hs back to base - - - - - 1b7bf7e6 by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Foldable1.hs back to base - - - - - bc0298ca by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Complex.hs back to base - - - - - dd28336b by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Functor/Compose.hs back to base - - - - - 1a496f21 by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Functor/Contravariant.hs back to base - - - - - 64b80213 by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Ratio.hs back to base - - - - - 0faab627 by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/List.hs back to base - - - - - f5253f50 by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Char.hs back to base - - - - - 021f269b by Ben Gamari at 2023-10-05T08:42:22-04:00 Move src/Data/Bits.hs back to base - - - - - d47c2ebf by Ben Gamari at 2023-10-05T08:43:00-04:00 Move src/Control/Concurrent/QSemN.hs back to base - - - - - 4a4fb454 by Ben Gamari at 2023-10-05T08:43:58-04:00 Move src/Control/Concurrent/QSem.hs back to base - - - - - 1fd3cce7 by Ben Gamari at 2023-10-05T08:43:59-04:00 Move src/Control/Concurrent/Chan.hs back to base - - - - - 50f07a12 by Ben Gamari at 2023-10-05T08:43:59-04:00 Move src/Text/Printf.hs back to base - - - - - 54fa5c6b by Ben Gamari at 2023-10-05T08:43:59-04:00 Move src/Foreign/Marshal/Pool.hs back to base - - - - - 1c3d6a17 by Ben Gamari at 2023-10-05T08:43:59-04:00 Move src/Foreign/Marshal/Error.hs back to base - - - - - 5ba6258f by Ben Gamari at 2023-10-05T08:43:59-04:00 Move src/Foreign/Marshal/Unsafe.hs back to base - - - - - f4287ca9 by Ben Gamari at 2023-10-05T08:43:59-04:00 Move src/Data/List/NonEmpty.hs back to base - - - - - 22 changed files: - libraries/base/base.cabal - libraries/ghc-internal/src/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs - libraries/ghc-internal/src/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs - libraries/ghc-internal/src/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs - libraries/ghc-internal/src/Data/Array/Byte.hs → libraries/base/src/Data/Array/Byte.hs - libraries/ghc-internal/src/Data/Bits.hs → libraries/base/src/Data/Bits.hs - libraries/ghc-internal/src/Data/Char.hs → libraries/base/src/Data/Char.hs - libraries/ghc-internal/src/Data/Complex.hs → libraries/base/src/Data/Complex.hs - libraries/ghc-internal/src/Data/Fixed.hs → libraries/base/src/Data/Fixed.hs - libraries/ghc-internal/src/Data/Foldable1.hs → libraries/base/src/Data/Foldable1.hs - libraries/ghc-internal/src/Data/Functor/Compose.hs → libraries/base/src/Data/Functor/Compose.hs - libraries/ghc-internal/src/Data/Functor/Contravariant.hs → libraries/base/src/Data/Functor/Contravariant.hs - libraries/ghc-internal/src/Data/List.hs → libraries/base/src/Data/List.hs - libraries/ghc-internal/src/Data/List/NonEmpty.hs → libraries/base/src/Data/List/NonEmpty.hs - libraries/ghc-internal/src/Data/Ratio.hs → libraries/base/src/Data/Ratio.hs - libraries/ghc-internal/src/Foreign/Concurrent.hs → libraries/base/src/Foreign/Concurrent.hs - libraries/ghc-internal/src/Foreign/Marshal/Error.hs → libraries/base/src/Foreign/Marshal/Error.hs - libraries/ghc-internal/src/Foreign/Marshal/Pool.hs → libraries/base/src/Foreign/Marshal/Pool.hs - libraries/ghc-internal/src/Foreign/Marshal/Unsafe.hs → libraries/base/src/Foreign/Marshal/Unsafe.hs - libraries/ghc-internal/src/Foreign/Ptr.hs → libraries/base/src/Foreign/Ptr.hs - libraries/ghc-internal/src/Text/Printf.hs → libraries/base/src/Text/Printf.hs - libraries/ghc-internal/ghc-internal.cabal Changes: ===================================== libraries/base/base.cabal ===================================== @@ -25,12 +25,32 @@ Library exposed-modules: Control.Applicative + , Control.Concurrent.Chan + , Control.Concurrent.QSem + , Control.Concurrent.QSemN , Control.Monad.Fix , Control.Monad.IO.Class , Control.Monad.Zip + , Data.Array.Byte , Data.Bifoldable1 , Data.Bitraversable + , Data.Bits + , Data.Char + , Data.Complex + , Data.Fixed + , Data.Foldable1 + , Data.Functor.Compose + , Data.Functor.Contravariant + , Data.List + , Data.List.NonEmpty + , Data.Ratio , Data.STRef.Lazy + , Foreign.Concurrent + , Foreign.Marshal.Error + , Foreign.Marshal.Pool + , Foreign.Marshal.Unsafe + , Foreign.Ptr + , Text.Printf , System.Console.GetOpt , System.IO.Unsafe , System.Info @@ -41,10 +61,7 @@ Library , Control.Arrow , Control.Category , Control.Concurrent - , Control.Concurrent.Chan , Control.Concurrent.MVar - , Control.Concurrent.QSem - , Control.Concurrent.QSemN , Control.Exception , Control.Exception.Base , Control.Monad @@ -57,27 +74,19 @@ Library , Control.Monad.ST.Safe , Control.Monad.ST.Strict , Control.Monad.ST.Unsafe - , Data.Array.Byte , Data.Bifoldable , Data.Bifunctor - , Data.Bits , Data.Bool - , Data.Char , Data.Coerce - , Data.Complex , Data.Data , Data.Dynamic , Data.Either , Data.Eq , Data.Enum - , Data.Fixed , Data.Foldable - , Data.Foldable1 , Data.Function , Data.Functor , Data.Functor.Classes - , Data.Functor.Contravariant - , Data.Functor.Compose , Data.Functor.Const , Data.Functor.Identity , Data.Functor.Product @@ -86,13 +95,10 @@ Library , Data.Int , Data.Ix , Data.Kind - , Data.List - , Data.List.NonEmpty , Data.Maybe , Data.Monoid , Data.Ord , Data.Proxy - , Data.Ratio , Data.Semigroup , Data.STRef , Data.STRef.Strict @@ -115,19 +121,14 @@ Library , Foreign.C.Error , Foreign.C.String , Foreign.C.Types - , Foreign.Concurrent , Foreign.ForeignPtr , Foreign.ForeignPtr.Safe , Foreign.ForeignPtr.Unsafe , Foreign.Marshal , Foreign.Marshal.Alloc , Foreign.Marshal.Array - , Foreign.Marshal.Error - , Foreign.Marshal.Pool , Foreign.Marshal.Safe - , Foreign.Marshal.Unsafe , Foreign.Marshal.Utils - , Foreign.Ptr , Foreign.Safe , Foreign.StablePtr , Foreign.Storable @@ -250,7 +251,6 @@ Library , System.Posix.Types , Text.ParserCombinators.ReadP , Text.ParserCombinators.ReadPrec - , Text.Printf , Text.Read , Text.Read.Lex , Text.Show ===================================== libraries/ghc-internal/src/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs ===================================== ===================================== libraries/ghc-internal/src/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs ===================================== ===================================== libraries/ghc-internal/src/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Array/Byte.hs → libraries/base/src/Data/Array/Byte.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Bits.hs → libraries/base/src/Data/Bits.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Char.hs → libraries/base/src/Data/Char.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Complex.hs → libraries/base/src/Data/Complex.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Fixed.hs → libraries/base/src/Data/Fixed.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Foldable1.hs → libraries/base/src/Data/Foldable1.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Functor/Compose.hs → libraries/base/src/Data/Functor/Compose.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Functor/Contravariant.hs → libraries/base/src/Data/Functor/Contravariant.hs ===================================== ===================================== libraries/ghc-internal/src/Data/List.hs → libraries/base/src/Data/List.hs ===================================== ===================================== libraries/ghc-internal/src/Data/List/NonEmpty.hs → libraries/base/src/Data/List/NonEmpty.hs ===================================== ===================================== libraries/ghc-internal/src/Data/Ratio.hs → libraries/base/src/Data/Ratio.hs ===================================== ===================================== libraries/ghc-internal/src/Foreign/Concurrent.hs → libraries/base/src/Foreign/Concurrent.hs ===================================== ===================================== libraries/ghc-internal/src/Foreign/Marshal/Error.hs → libraries/base/src/Foreign/Marshal/Error.hs ===================================== ===================================== libraries/ghc-internal/src/Foreign/Marshal/Pool.hs → libraries/base/src/Foreign/Marshal/Pool.hs ===================================== ===================================== libraries/ghc-internal/src/Foreign/Marshal/Unsafe.hs → libraries/base/src/Foreign/Marshal/Unsafe.hs ===================================== ===================================== libraries/ghc-internal/src/Foreign/Ptr.hs → libraries/base/src/Foreign/Ptr.hs ===================================== ===================================== libraries/ghc-internal/src/Text/Printf.hs → libraries/base/src/Text/Printf.hs ===================================== ===================================== libraries/ghc-internal/ghc-internal.cabal ===================================== @@ -93,10 +93,7 @@ Library Control.Arrow Control.Category Control.Concurrent - Control.Concurrent.Chan Control.Concurrent.MVar - Control.Concurrent.QSem - Control.Concurrent.QSemN Control.Exception Control.Exception.Base Control.Monad @@ -109,27 +106,19 @@ Library Control.Monad.ST.Safe Control.Monad.ST.Strict Control.Monad.ST.Unsafe - Data.Array.Byte Data.Bifoldable Data.Bifunctor - Data.Bits Data.Bool - Data.Char Data.Coerce - Data.Complex Data.Data Data.Dynamic Data.Either Data.Eq Data.Enum - Data.Fixed Data.Foldable - Data.Foldable1 Data.Function Data.Functor Data.Functor.Classes - Data.Functor.Contravariant - Data.Functor.Compose Data.Functor.Const Data.Functor.Identity Data.Functor.Product @@ -138,13 +127,10 @@ Library Data.Int Data.Ix Data.Kind - Data.List - Data.List.NonEmpty Data.Maybe Data.Monoid Data.Ord Data.Proxy - Data.Ratio Data.Semigroup Data.STRef Data.STRef.Strict @@ -167,19 +153,14 @@ Library Foreign.C.Error Foreign.C.String Foreign.C.Types - Foreign.Concurrent Foreign.ForeignPtr Foreign.ForeignPtr.Safe Foreign.ForeignPtr.Unsafe Foreign.Marshal Foreign.Marshal.Alloc Foreign.Marshal.Array - Foreign.Marshal.Error - Foreign.Marshal.Pool Foreign.Marshal.Safe - Foreign.Marshal.Unsafe Foreign.Marshal.Utils - Foreign.Ptr Foreign.Safe Foreign.StablePtr Foreign.Storable @@ -302,7 +283,6 @@ Library System.Posix.Types Text.ParserCombinators.ReadP Text.ParserCombinators.ReadPrec - Text.Printf Text.Read Text.Read.Lex Text.Show View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4db3a82c2c134657852b748d61c40aeb10c3422f...f4287ca904cbc1b20549455c3837e80f2b8048e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4db3a82c2c134657852b748d61c40aeb10c3422f...f4287ca904cbc1b20549455c3837e80f2b8048e3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 12:48:39 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 08:48:39 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] fix warnings Message-ID: <651eb0a7140bf_18f529295814ec4377d8@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 9e20f427 by Matthew Pickering at 2023-10-05T13:48:31+01:00 fix warnings - - - - - 3 changed files: - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/RunTest.hs Changes: ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -20,7 +20,6 @@ import GHC.Toolchain.Program (prgFlags) import qualified Data.Set as Set import Oracles.Flavour import Debug.Trace -import qualified System.Directory.Extra as IO {- Note [Binary distributions] @@ -172,7 +171,7 @@ buildBinDistDir root conf at BindistConfig{..} = do -- let rtsDir = "rts" let ghcBuildDir = root -/- stageString library_stage - ghcLibBinBuildDir = root -/- stageString executable_stage -/- "lib" -/- "bin" + ghcLibBinBuildDir = root -/- stageString executable_stage -/- "lib" -/- "bin" bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform rtsIncludeDir = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir @@ -416,11 +415,10 @@ generateBuildMk BindistConfig{..} = do dynamicGhc <- askDynGhcPrograms executable_stage rtsWays <- unwords . map show . Set.toList <$> interpretInContext (vanillaContext library_stage rts) getRtsWays cross <- crossStage executable_stage - traceShowM ("cross", library_stage, executable_stage, cross) return $ unlines [ "GhcRTSWays" =. rtsWays -- MP: TODO just very hacky, should be one place where cross implies static (see programContext for where this is currently) - , "DYNAMIC_GHC_PROGRAMS" =. yesNo (dynamicGhc && not cross) - , "CrossCompiling" =. yesNo cross ] + , "DYNAMIC_GHC_PROGRAMS" =. yesNo dynamicGhc + , "CrossCompiling" =. yesNo cross ] where ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -212,24 +212,12 @@ testRules = do -- Prepare Ghc configuration file for input compiler. need [root -/- timeoutPath] - cross <- flag CrossCompiling -- get relative path for the given program in the given stage - let relative_path_stage s p = programPath =<< programContext s p let make_absolute rel_path = do abs_path <- liftIO (IO.makeAbsolute rel_path) fixAbsolutePathOnWindows abs_path - rel_ghc_pkg <- relative_path_stage Stage1 ghcPkg - rel_hsc2hs <- relative_path_stage Stage1 hsc2hs - rel_hp2ps <- relative_path_stage Stage1 hp2ps - rel_haddock <- relative_path_stage (Stage0 InTreeLibs) haddock - rel_hpc <- relative_path_stage (Stage0 InTreeLibs) hpc - rel_runghc <- relative_path_stage (Stage0 InTreeLibs) runGhc - - -- force stage0 program building for cross - --when cross $ need [rel_hpc, rel_haddock, rel_runghc] - ghcPath <- getCompilerPath testCompilerArg @@ -240,7 +228,7 @@ testRules = do [ "--interactive", "-v0", "-ignore-dot-ghci" , "-fno-ghci-history", "-fprint-error-index-links=never" ] - -- MP: TODO wrong + -- MP: TODO wrong, should use the ccPath and ccFlags from the bindist we are testing. ccPath <- queryTargetTarget stg (Toolchain.prgPath . Toolchain.ccProgram . Toolchain.tgtCCompiler) ccFlags <- queryTargetTarget stg (unwords . Toolchain.prgFlags . Toolchain.ccProgram . Toolchain.tgtCCompiler) @@ -248,12 +236,12 @@ testRules = do testGhc <- testCompiler <$> userSetting defaultTestArgs bindir <- getBinaryDirectory testGhc - cross <- getBooleanSetting TestCrossCompiling - test_target_platform <- getTestSetting TestTARGETPLATFORM - let cross_prefix = if cross then test_target_platform ++ "-" else "" + cross <- getBooleanSetting TestCrossCompiling + test_target_platform <- getTestSetting TestTARGETPLATFORM + let cross_prefix = if cross then test_target_platform ++ "-" else "" - let exe_path :: Package -> String - exe_path pkg = bindir (cross_prefix ++ programBasename vanilla pkg) <.> exe + let exe_path :: Package -> String + exe_path pkg = bindir (cross_prefix ++ programBasename vanilla pkg) <.> exe prog_ghc_pkg <- make_absolute (exe_path ghcPkg) prog_hsc2hs <- make_absolute (exe_path hsc2hs) ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -4,8 +4,8 @@ module Settings.Builders.RunTest (runTestBuilderArgs , assertSameCompilerArgs , outOfTreeCompilerArgs , TestCompilerArgs(..) - , getBooleanSetting - , getTestSetting ) where + , getBooleanSetting + , getTestSetting ) where import Hadrian.Utilities import qualified System.FilePath View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e20f427dd0f457581ae3aa2d6f41c90b4117cb2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e20f427dd0f457581ae3aa2d6f41c90b4117cb2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 12:49:09 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 08:49:09 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] more warnings Message-ID: <651eb0c58ccfe_18f529295c38744379b3@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: a62a84e6 by Matthew Pickering at 2023-10-05T13:48:58+01:00 more warnings - - - - - 1 changed file: - hadrian/src/Settings/Default.hs Changes: ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -158,11 +158,11 @@ stage1Packages = do , stm , unlit , xhtml - , haddock - , hpcBin + , haddock + , hpcBin , if winTarget then win32 else unix ] ++ - [ iserv + [ iserv , runGhc , ghcToolchainBin ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a62a84e6301c25d346b7297e7b4c21b2c51118cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a62a84e6301c25d346b7297e7b4c21b2c51118cb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 13:21:23 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Thu, 05 Oct 2023 09:21:23 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ci-fix-index-state Message-ID: <651eb8532de6d_18f5292a4536284524fd@gitlab.mail> Bryan R pushed new branch wip/ci-fix-index-state at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ci-fix-index-state You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 13:21:50 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 09:21:50 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] remove CROSS_EMULATOR js-emulator Message-ID: <651eb86e50748_18f5292a47a7c84526f9@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: f2b01a14 by Matthew Pickering at 2023-10-05T14:21:28+01:00 remove CROSS_EMULATOR js-emulator - - - - - 2 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -1013,7 +1013,7 @@ job_groups = , disableValidate (standardBuildsWithConfig AArch64 (Linux Alpine318) (splitSectionsBroken vanilla)) , fullyStaticBrokenTests (disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine312) staticNativeInt))) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure") + , validateBuilds Amd64 (Linux Debian11) (crossConfig "javascript-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ) { bignumBackend = Native } ===================================== .gitlab/jobs.yaml ===================================== @@ -1836,7 +1836,6 @@ "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", "CROSS_STAGE": "2", "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", @@ -5283,7 +5282,6 @@ "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "js-emulator", "CROSS_STAGE": "2", "CROSS_TARGET": "javascript-unknown-ghcjs", "RUNTEST_ARGS": "", View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f2b01a14405ad08ae3bfd9b1a9c74013685ff6a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f2b01a14405ad08ae3bfd9b1a9c74013685ff6a4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 13:30:35 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Thu, 05 Oct 2023 09:30:35 -0400 Subject: [Git][ghc/ghc][wip/ci-fix-index-state] 2 commits: Update hackage index state Message-ID: <651eba7ba1596_18f5292a8c12f04532f6@gitlab.mail> Bryan R pushed to branch wip/ci-fix-index-state at Glasgow Haskell Compiler / GHC Commits: 60df9f21 by Bryan Richter at 2023-10-05T16:29:56+03:00 Update hackage index state - - - - - 374026cb by Bryan Richter at 2023-10-05T16:30:18+03:00 Ensure hadrian uses CI's hackage index state - - - - - 2 changed files: - .gitlab/ci.sh - hadrian/cabal.project Changes: ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7729f619690f0a7f1b8bd2311f21bd4efb1703e8...374026cb916f518066c5acae7b8fe7e2a4b257e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7729f619690f0a7f1b8bd2311f21bd4efb1703e8...374026cb916f518066c5acae7b8fe7e2a4b257e9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 14:12:46 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 10:12:46 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/libbin Message-ID: <651ec45e8f462_18f5292bbde66c46468d@gitlab.mail> Matthew Pickering pushed new branch wip/libbin at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/libbin You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 15:53:12 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 11:53:12 -0400 Subject: [Git][ghc/ghc][wip/libbin] hadrian: Build all executables in bin/ folder Message-ID: <651edbe8320a5_18f5292dcb98f04798d1@gitlab.mail> Matthew Pickering pushed to branch wip/libbin at Glasgow Haskell Compiler / GHC Commits: c19c47d2 by Matthew Pickering at 2023-10-05T16:52:30+01:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 4 changed files: - hadrian/bindist/Makefile - hadrian/src/Packages.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -117,7 +117,7 @@ lib/settings : config.mk @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ - @echo ',("unlit command", "$$topdir/bin/$(CrossCompilePrefix)unlit")' >> $@ + @echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@ @echo ',("target os", "$(HaskellTargetOs)")' >> $@ ===================================== hadrian/src/Packages.hs ===================================== @@ -202,14 +202,8 @@ programName Context {..} = do -- | The 'FilePath' to a program executable in a given 'Context'. programPath :: Context -> Action FilePath programPath context at Context {..} = do - -- TODO: The @touchy@ utility lives in the @lib/bin@ directory instead of - -- @bin@, which is likely just a historical accident that should be fixed. - -- See: https://github.com/snowleopard/hadrian/issues/570 - -- Likewise for @iserv@ and @unlit at . name <- programName context - path <- if package `elem` [iserv, touchy, unlit] - then stageLibPath stage <&> (-/- "bin") - else stageBinPath stage + path <- stageBinPath stage return $ path -/- name <.> exe -- TODO: Move @timeout@ to the @util@ directory and build in a more standard ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -469,7 +469,7 @@ generateSettings = do , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand) , ("windres command", queryTarget (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me. - , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) + , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) , ("cross compiling", expr $ yesNo <$> flag CrossCompiling) , ("target platform string", queryTarget targetPlatformTriple) , ("target os", queryTarget (show . archOS_OS . tgtArchOs)) ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -38,7 +38,7 @@ buildProgramRules rs = do -- Rules for programs that are actually built by hadrian. forM_ allStages $ \stage -> [ root -/- stageString stage -/- "bin" -/- "*" - , root -/- stageString stage -/- "lib/bin" -/- "*" ] |%> \bin -> do + ] |%> \bin -> do programContexts <- getProgramContexts stage case lookupProgramContext bin programContexts of Nothing -> error $ "Unknown program " ++ show bin @@ -105,9 +105,6 @@ buildProgram bin ctx@(Context{..}) rs = do (True, s) | s > stage0InTree -> do srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin")) copyFile (srcDir -/- takeFileName bin) bin - (False, s) | s > stage0InTree && (package `elem` [touchy, unlit]) -> do - srcDir <- stageLibPath stage0InTree <&> (-/- "bin") - copyFile (srcDir -/- takeFileName bin) bin _ -> buildBinary rs bin ctx buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c19c47d297000a73587c3f5c8ed2dc10fd54f58d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c19c47d297000a73587c3f5c8ed2dc10fd54f58d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 15:54:27 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 11:54:27 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/bindeps Message-ID: <651edc33513a6_18f5292e3bb65848027b@gitlab.mail> Matthew Pickering pushed new branch wip/bindeps at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bindeps You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 15:55:58 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 11:55:58 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/base-src Message-ID: <651edc8e61086_18f5292e3ce1a4482167@gitlab.mail> Ben Gamari pushed new branch wip/base-src at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/base-src You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 16:03:39 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 12:03:39 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 3 commits: whitespace Message-ID: <651ede5b9d6a7_18f5292e3a8eb84931ea@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: b22d40f1 by Matthew Pickering at 2023-10-05T15:42:16+01:00 whitespace - - - - - 93420843 by Matthew Pickering at 2023-10-05T16:46:50+01:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - 38332414 by Matthew Pickering at 2023-10-05T17:02:23+01:00 Werror - - - - - 5 changed files: - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Packages.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Program.hs Changes: ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Packages.hs ===================================== @@ -188,7 +188,7 @@ programName Context {..} = do return $ prefix ++ programBasename way package programBasename :: Way -> Package -> String -programBasename way package +programBasename way package | package == ghc = "ghc" | package == ghciWrapper = "ghci" -- See Note [Hadrian's ghci-wrapper package] | package == hpcBin = "hpc" ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Program.hs ===================================== @@ -5,7 +5,6 @@ module Settings.Program import Base import Context import Oracles.Flavour -import Oracles.Setting import Packages -- TODO: there is duplication and inconsistency between this and @@ -14,11 +13,11 @@ import Packages programContext :: Stage -> Package -> Action Context programContext stage pkg = do profiled <- askGhcProfiled stage - dynGhcProgs <- askDynGhcPrograms stage + dynGhcProgs <- askDynGhcPrograms stage -- Have to build static if it's a cross stage as we won't distribute the libraries built for the host. return $ Context stage pkg (wayFor profiled dynGhcProgs) Final - where wayFor prof dyn + where wayFor prof dyn | prof && dyn = error "programContext: profiling+dynamic not supported" | pkg == ghc && prof && notStage0 stage = profiling View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f2b01a14405ad08ae3bfd9b1a9c74013685ff6a4...383324142ee5cef2c18d3c137fff314519a4b0f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f2b01a14405ad08ae3bfd9b1a9c74013685ff6a4...383324142ee5cef2c18d3c137fff314519a4b0f0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 19:34:09 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 05 Oct 2023 15:34:09 -0400 Subject: [Git][ghc/ghc][wip/az/ghc-cpp] Split into separate files Message-ID: <651f0fb1acdf3_18f529337a3144513074@gitlab.mail> Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: 9c7e0f69 by Alan Zimmerman at 2023-10-05T20:33:42+01:00 Split into separate files - - - - - 4 changed files: - utils/check-cpp/Main.hs - + utils/check-cpp/Parse.hs - + utils/check-cpp/ParseSimulate.hs - + utils/check-cpp/PreProcess.hs Changes: ===================================== utils/check-cpp/Main.hs ===================================== @@ -2,16 +2,13 @@ {-# LANGUAGE BangPatterns #-} import Control.Monad.IO.Class -import Data.Char import Data.Data hiding (Fixity) import Data.List -import Data.Map (Map) import qualified Data.Map as Map import Debug.Trace import GHC import qualified GHC.Data.EnumSet as EnumSet import GHC.Data.FastString -import qualified GHC.Data.Strict as Strict import GHC.Data.StringBuffer import GHC.Driver.Config.Parser import GHC.Driver.Errors.Types @@ -20,7 +17,7 @@ import qualified GHC.Driver.Session as GHC import GHC.Hs.Dump import qualified GHC.LanguageExtensions as LangExt import GHC.Parser.Errors.Ppr () -import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), Token (..)) +import GHC.Parser.Lexer (P (..), ParseResult (..), Token (..)) import qualified GHC.Parser.Lexer as GHC import qualified GHC.Parser.Lexer as Lexer import GHC.Types.Error @@ -28,15 +25,10 @@ import GHC.Types.SrcLoc import GHC.Utils.Error import GHC.Utils.Outputable import qualified Text.Parsec as Parsec -import Text.Parsec.Char as PS -import Text.Parsec.Combinator as PS -import Text.Parsec.Prim as PS -import Text.Parsec.String (Parser) --- import Text.Parsec.Char --- import FunctionsAndTypesForParsing (regularParse, parseWithEof, parseWithLeftOver) --- import Text.Parsec.String.Combinator (many1) --- import Text.Parsec.Combinator (many1) +import Parse +import ParseSimulate +import PreProcess -- --------------------------------------------------------------------- @@ -47,359 +39,6 @@ showAst ast = -- ===================================================================== -type PP = P PpState - -initPpState :: PpState -initPpState = - PpState - { pp_defines = Map.empty - , pp_includes = Map.empty - , pp_include_stack = [] - , pp_continuation = [] - , pp_context = [] - , pp_accepting = True - } - -data PpState = PpState - { pp_defines :: !(Map String [String]) - , pp_includes :: !(Map String StringBuffer) - , pp_include_stack :: ![Lexer.AlexInput] - , pp_continuation :: ![Located Token] - , pp_context :: ![Token] -- What preprocessor directive we are currently processing - , pp_accepting :: !Bool - } - deriving (Show) --- deriving instance Show Lexer.AlexInput - --- ===================================================================== - -ppLexer, ppLexerDbg :: Bool -> (Located Token -> PP a) -> PP a --- Use this instead of 'lexer' in GHC.Parser to dump the tokens for debugging. -ppLexerDbg queueComments cont = ppLexer queueComments contDbg - where - contDbg tok = trace ("pptoken: " ++ show (unLoc tok)) (cont tok) -ppLexer queueComments cont = - Lexer.lexer - queueComments - ( \tk -> - let - contInner t = (trace ("ppLexer: tk=" ++ show (unLoc tk, unLoc t)) cont) t - -- contPush = pushContext (unLoc tk) >> contIgnoreTok tk - contIgnoreTok (L l tok) = do - case l of - RealSrcSpan r (Strict.Just b) -> Lexer.queueIgnoredToken (L (PsSpan r b) tok) - _ -> return () - ppLexer queueComments cont - in - -- case tk of - case (trace ("M.ppLexer:tk=" ++ show (unLoc tk)) tk) of - L _ ITeof -> do - mInp <- popIncludeLoc - case mInp of - Nothing -> contInner tk - Just inp -> do - Lexer.setInput inp - ppLexer queueComments cont - L _ (ITcpp continuation s) -> do - if continuation - then pushContinuation tk - else processCppToks s - contIgnoreTok tk - _ -> do - state <- getCppState - -- case (trace ("CPP state:" ++ show state) state) of - case state of - CppIgnoring -> contIgnoreTok tk - _ -> contInner tk - ) - -preprocessElse :: PP () -preprocessElse = do - accepting <- getAccepting - setAccepting (not accepting) - -preprocessEnd :: PP () -preprocessEnd = do - -- TODO: nested context - setAccepting True - -processCppToks :: FastString -> PP () -processCppToks fs = do - let - get (L _ (ITcpp _ s)) = s - get _ = error "should not" - -- Combine any prior continuation tokens - cs <- popContinuation - processCpp (reverse $ fs : map get cs) - return () - -processCpp :: [FastString] -> PP () -processCpp fs = do - -- traceM $ "processCpp: fs=" ++ show fs - -- let s = cppInitial fs - let s = cppInitial fs - case regularParse cppDirective s of - Left err -> error $ show err - Right (CppInclude filename) -> do - ppInclude filename - Right (CppDefine name def) -> do - ppDefine name def - Right (CppIfdef name) -> do - defined <- ppIsDefined name - setAccepting defined - Right (CppIfndef name) -> do - defined <- ppIsDefined name - setAccepting (not defined) - Right CppElse -> do - accepting <- getAccepting - setAccepting (not accepting) - return () - Right CppEndif -> do - -- TODO: nested states - setAccepting True - return () - - -- return (trace ("processCpp:s=" ++ show s) ()) - return () - --- --------------------------------------------------------------------- --- Preprocessor state functions - -data CppState - = CppIgnoring - | CppNormal - deriving (Show) - -getCppState :: PP CppState -getCppState = do - accepting <- getAccepting - if accepting - then return CppNormal - else return CppIgnoring - --- pp_context stack start ----------------- - -pushContext :: Token -> PP () -pushContext new = - P $ \s -> POk s{pp = (pp s){pp_context = new : pp_context (pp s)}} () - -popContext :: PP () -popContext = - P $ \s -> - let - new_context = case pp_context (pp s) of - [] -> [] - (_ : t) -> t - in - POk s{pp = (pp s){pp_context = new_context}} () - -peekContext :: PP Token -peekContext = - P $ \s -> - let - r = case pp_context (pp s) of - [] -> ITeof -- Anthing really, for now, except a CPP one - (h : _) -> h - in - POk s r - -setAccepting :: Bool -> PP () -setAccepting on = - P $ \s -> POk s{pp = (pp s){pp_accepting = on}} () - -getAccepting :: PP Bool -getAccepting = P $ \s -> POk s (pp_accepting (pp s)) - --- ------------------------------------- - -pushContinuation :: Located Token -> PP () -pushContinuation new = - P $ \s -> POk s{pp = (pp s){pp_continuation = new : pp_continuation (pp s)}} () - -popContinuation :: PP [Located Token] -popContinuation = - P $ \s -> POk s{pp = (pp s){pp_continuation = []}} (pp_continuation (pp s)) - --- pp_context stack end ------------------- - --- pp_include start ----------------------- - -getInclude :: String -> PP (Maybe StringBuffer) -getInclude filename = P $ \s -> POk s (Map.lookup filename (pp_includes (pp s))) - -pushIncludeLoc :: Lexer.AlexInput -> PP () -pushIncludeLoc pos - = P $ \s -> POk s {pp = (pp s){ pp_include_stack = pos: pp_include_stack (pp s)}} () - -popIncludeLoc :: PP (Maybe Lexer.AlexInput) -popIncludeLoc = - P $ \s -> - let - (new_st,r) = case pp_include_stack (pp s) of - [] ->([], Nothing) - (h:t) -> (t, Just h) - in - POk s{pp = (pp s){pp_include_stack = new_st }} r - --- pp_include end ------------------------- - --- definitions start -------------------- - -ppInclude :: String -> PP () -ppInclude filename = do - mSrc <- getInclude filename - case mSrc of - Nothing -> return () - Just src -> do - origInput <- Lexer.getInput - pushIncludeLoc origInput - let loc = PsLoc (mkRealSrcLoc (mkFastString filename) 1 1) (BufPos 0) - Lexer.setInput (Lexer.AI loc src) - return $ trace ("ppInclude:mSrc=[" ++ show mSrc ++ "]") () - -- return $ trace ("ppInclude:filename=[" ++ filename ++ "]") () - -ppDefine :: String -> [String] -> PP () -ppDefine name val = P $ \s -> - -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () - POk s{pp = (pp s){pp_defines = Map.insert (trace ("ppDefine:def=[" ++ name ++ "]") name) val (pp_defines (pp s))}} () - -ppIsDefined :: String -> PP Bool -ppIsDefined def = P $ \s -> - -- POk s (Map.member def (pp_defines (pp s))) - POk s (Map.member (trace ("ppIsDefined:def=[" ++ def ++ "]") def) (pp_defines (pp s))) - --- | Take a @FastString@ of the form "#define FOO\n" and strip off all but "FOO" -cleanTokenString :: FastString -> String -cleanTokenString fs = r - where - ss = dropWhile (\c -> not $ isSpace c) (unpackFS fs) - r = init ss - -parseDefine :: FastString -> Maybe (String, [String]) -parseDefine fs = r - where - -- r = Just (cleanTokenString s, "") - r = case regularParse cppDefinition (unpackFS fs) of - Left _ -> Nothing - Right v -> Just v - --- ===================================================================== --- Parsec parsing -type CppParser = Parsec String () - -regularParse :: Parser a -> String -> Either Parsec.ParseError a -regularParse p = PS.parse p "" - --- TODO: delete this -cppDefinition :: CppParser (String, [String]) -cppDefinition = do - _ <- PS.char '#' - _ <- whiteSpace - _ <- lexeme (PS.string "define") - name <- cppToken - definition <- cppTokens - return (name, definition) - -data CppDirective - = CppInclude String - | CppDefine String [String] - | CppIfdef String - | CppIfndef String - | CppElse - | CppEndif - deriving (Show, Eq) - -cppDirective :: CppParser CppDirective -cppDirective = do - _ <- PS.char '#' - _ <- whiteSpace - choice - [ cppKw "define" >> cmdDefinition - , try $ cppKw "include" >> cmdInclude - , try $ cppKw "ifdef" >> cmdIfdef - , cppKw "ifndef" >> cmdIfndef - , try $ cppKw "else" >> return CppElse - , cppKw "endif" >> return CppEndif - -- , cppKw "if" CppIfKw - -- , cppKw "elif" CppElifKw - -- , cppKw "undef" CppUndefKw - -- , cppKw "error" CppErrorKw - ] - -cmdInclude :: CppParser CppDirective -cmdInclude = do - _ <- string "\"" - filename <- many1 (satisfy (\c -> not (isSpace c || c == '"'))) - _ <- string "\"" - return $ CppInclude filename - -cmdDefinition :: CppParser CppDirective -cmdDefinition = do - name <- cppToken - definition <- cppTokens - return $ CppDefine name definition - -cmdIfdef :: CppParser CppDirective -cmdIfdef = do - name <- cppToken - return $ CppIfdef name - -cmdIfndef :: CppParser CppDirective -cmdIfndef = do - name <- cppToken - return $ CppIfndef name - -cppKw :: String -> CppParser () -cppKw kw = do - _ <- lexeme (PS.string kw) - return () - -cppComment :: CppParser () -cppComment = do - _ <- PS.string "/*" - _ <- PS.manyTill PS.anyChar (PS.try (PS.string "*/")) - return () - -whiteSpace :: CppParser () -whiteSpace = do - _ <- PS.many (PS.choice [cppComment, PS.space >> return ()]) - return () - -lexeme :: CppParser a -> CppParser a -lexeme p = p <* whiteSpace - -cppToken :: CppParser String -cppToken = lexeme (PS.many1 (PS.satisfy (\c -> not (isSpace c)))) - -cppTokens :: CppParser [String] -cppTokens = PS.many cppToken - -{- | Do cpp initial processing, as per https://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html -See Note [GhcCPP Initial Processing] --} -cppInitial :: [FastString] -> String -cppInitial fs = r - where - -- go fs' = reverse $ drop 2 $ reverse $ unpackFS fs' - r = concatMap unpackFS fs - -{- -Note [GhcCPP Initial Processing] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This processing is based on the description at -https://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html - -It is only done for lines starting with a preprocessor -directive. - -1. Broken into lines. We rely on the GHC Lexer to do this -2. Trigraphs are not processed -3. Continued lines are merged into a single line - and is handled in the Lexer. -4. All comments are replaced with a single space - --} - -- ===================================================================== -- Emulate the parser @@ -422,8 +61,8 @@ strGetToks :: Includes -> Lexer.ParserOpts -> FilePath -> String -> [Located Tok -- strGetToks includes popts filename str = reverse $ lexAll pstate strGetToks includes popts filename str = reverse $ lexAll (trace ("pstate=" ++ show initState) pstate) where - includeMap = Map.fromList $ map (\(k,v) -> (k, stringToStringBuffer (intercalate "\n" v))) includes - initState = initPpState { pp_includes = includeMap } + includeMap = Map.fromList $ map (\(k, v) -> (k, stringToStringBuffer (intercalate "\n" v))) includes + initState = initPpState{pp_includes = includeMap} pstate = Lexer.initParserState initState popts buf loc loc = mkRealSrcLoc (mkFastString filename) 1 1 buf = stringToStringBuffer str @@ -494,78 +133,6 @@ ghcWrapper libdir a = -- --------------------------------------------------------------------- -parseModuleNoHaddock :: PP [Located Token] -parseModuleNoHaddock = happySomeParser - where - -- happySomeParser = happyThen (happyParse 0#) (\x -> happyReturn (let {(HappyWrap35 x') = happyOut35 x} in x')) - happySomeParser = (>>=) (happyParse 0) (\x -> return x) - -happyParse :: Int -> PP [Located Token] -happyParse start_state = happyNewToken start_state [] [] - -happyNewToken :: Int -> [Int] -> [Located Token] -> PP [Located Token] -happyNewToken action sts stk = - -- lexer - ppLexerDbg - True - ( \tk -> - let cont i = - trace ("happyNewToken:tk=" ++ show tk) - $ happyDoAction i tk action sts stk - in case tk of - L _ ITeof -> happyDoAction 169 tk action sts stk - _ -> cont 5 - -- _ -> happyError' (tk, []) - ) - -happyDoAction :: Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] --- happyDoAction num tk action sts stk = P $ \s -> POk s tk -happyDoAction num tk action sts stk = - case num of - 1 -> happyShift 2 num tk action sts stk - 2 -> happyShift 5 num tk action sts stk - 3 -> happyShift 5 num tk action sts stk - 4 -> happyShift 5 num tk action sts stk - 5 -> happyShift 5 num tk action sts stk - 50 -> happyAccept num tk action sts stk - 169 -> happyAccept num tk action sts stk - i -> happyFail ["failing:" ++ show i] i tk action sts stk - --- happyAccept j tk st sts (HappyStk ans _) = --- (happyTcHack j (happyTcHack st)) (happyReturn1 ans) - -happyAccept :: Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] -happyAccept _j tk _st _sts stk = - trace ("happyAccept:" ++ show tk) - $ return stk - --- happyReturn1 :: a -> P a --- happyReturn1 = return - -happyShift :: Int -> Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] -happyShift new_state _i tk st sts stk = do - happyNewToken new_state (st : sts) (tk : stk) - --- happyShift new_state i tk st sts stk = --- happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) - -happyFail :: [String] -> Int -> Located Token -> p2 -> p3 -> p4 -> PP a -happyFail explist i tk _old_st _ _stk = - trace ("failing" ++ show explist) - $ happyError_ explist i tk - -happyError_ :: [String] -> p1 -> Located Token -> PP a -happyError_ explist _ tk = happyError' (tk, explist) - -notHappyAtAll :: a -notHappyAtAll = Prelude.error "Internal Happy error\n" - -happyError' :: (Located Token, [String]) -> PP a -happyError' tk = (\(_tokens, _explist) -> happyError) tk - -happyError :: PP a -happyError = Lexer.srcParseFail - -- ===================================================================== -- --------------------------------------------------------------------- @@ -710,7 +277,8 @@ t9 = regularParse cppDirective "#define VERSION_ghc_exactprint \"1.7.0.1\"" t10 :: IO () t10 = do - doTestWithIncludes testIncludes + doTestWithIncludes + testIncludes [ "#include \"bar.h\"" , "" , "#ifdef FOO" @@ -725,7 +293,8 @@ testIncludes = [ ( "bar.h" , ["#include \"sub.h\""] - ), + ) + , ( "sub.h" , ["#define FOO"] ) ===================================== utils/check-cpp/Parse.hs ===================================== @@ -0,0 +1,194 @@ +module Parse where + +import Data.Char +import GHC.Parser.Errors.Ppr () +import qualified Text.Parsec as Parsec +import Text.Parsec.Char as PS +import Text.Parsec.Combinator as PS +import Text.Parsec.Prim as PS +import Text.Parsec.String (Parser) + +-- import Debug.Trace + +-- --------------------------------------------------------------------- + +type CppParser = Parsec String () + +regularParse :: Parser a -> String -> Either Parsec.ParseError a +regularParse p = PS.parse p "" + +-- TODO: delete this +cppDefinition :: CppParser (String, [String]) +cppDefinition = do + _ <- PS.char '#' + _ <- whiteSpace + _ <- lexeme (PS.string "define") + name <- cppToken + definition <- cppTokens + return (name, definition) + +data CppDirective + = CppInclude String + | CppDefine String [String] + | CppIfdef String + | CppIfndef String + | CppElse + | CppEndif + deriving (Show, Eq) + +cppDirective :: CppParser CppDirective +cppDirective = do + _ <- PS.char '#' + _ <- whiteSpace + choice + [ cppKw "define" >> cmdDefinition + , try $ cppKw "include" >> cmdInclude + , try $ cppKw "ifdef" >> cmdIfdef + , cppKw "ifndef" >> cmdIfndef + , try $ cppKw "else" >> return CppElse + , cppKw "endif" >> return CppEndif + -- , cppKw "if" CppIfKw + -- , cppKw "elif" CppElifKw + -- , cppKw "undef" CppUndefKw + -- , cppKw "error" CppErrorKw + ] + +cmdInclude :: CppParser CppDirective +cmdInclude = do + _ <- string "\"" + filename <- many1 (satisfy (\c -> not (isSpace c || c == '"'))) + _ <- string "\"" + return $ CppInclude filename + +cmdDefinition :: CppParser CppDirective +cmdDefinition = do + name <- cppToken + definition <- cppTokens + return $ CppDefine name definition + +cmdIfdef :: CppParser CppDirective +cmdIfdef = do + name <- cppToken + return $ CppIfdef name + +cmdIfndef :: CppParser CppDirective +cmdIfndef = do + name <- cppToken + return $ CppIfndef name + +cppKw :: String -> CppParser () +cppKw kw = do + _ <- lexeme (PS.string kw) + return () + +cppComment :: CppParser () +cppComment = do + _ <- PS.string "/*" + _ <- PS.manyTill PS.anyChar (PS.try (PS.string "*/")) + return () + +whiteSpace :: CppParser () +whiteSpace = do + _ <- PS.many (PS.choice [cppComment, PS.space >> return ()]) + return () + +lexeme :: CppParser a -> CppParser a +lexeme p = p <* whiteSpace + +cppToken :: CppParser String +cppToken = lexeme (PS.many1 (PS.satisfy (\c -> not (isSpace c)))) + +cppTokens :: CppParser [String] +cppTokens = PS.many cppToken + +-- --------------------------------------------------------------------- +-- import GHC.S.Types + +-- parseS :: String -> Either ParseError S +-- parseS = parse expr "" + +-- lexer :: P.TokenParser () +-- lexer = +-- P.makeTokenParser +-- ( emptyDef +-- { P.reservedNames = +-- [ "define" +-- , "include" +-- , "undef" +-- , "error" +-- , "ifdef" +-- , "ifndef" +-- , "if" +-- , "elif" +-- , "else" +-- , "endif" +-- ] +-- } +-- ) + +-- slam :: Parser S +-- slam = P.parens lexer $ do +-- P.reserved lexer "lam" +-- ident <- P.identifier lexer +-- body <- expr +-- return (SLam (Atom ident) body) + +-- slet :: Parser S +-- slet = P.parens lexer $ do +-- P.reserved lexer "let" +-- (ident, e1) <- P.parens lexer $ do +-- idnt <- P.identifier lexer +-- expr1 <- expr +-- return (idnt, expr1) +-- e2 <- expr +-- return (SLet (Atom ident) e1 e2) + +-- sletrec :: Parser S +-- sletrec = P.parens lexer $ do +-- P.reserved lexer "letrec" +-- ls <- P.parens lexer $ many1 $ P.parens lexer $ do +-- idnt <- P.identifier lexer +-- expr1 <- expr +-- return (Atom idnt, expr1) +-- e2 <- expr +-- return (SLetRec ls e2) + +-- scase :: Parser S +-- scase = P.parens lexer $ do +-- P.reserved lexer "case" +-- e <- expr +-- alt <- optionMaybe (P.identifier lexer) +-- alts <- P.parens lexer $ many1 $ P.parens lexer $ do +-- pat <- expr +-- ex <- expr +-- return (pat, ex) +-- case alt of +-- Just alt -> return (SCase (Atom alt) e alts) +-- Nothing -> return (SCase (Atom "_") e alts) + +-- swild :: Parser S +-- swild = do +-- P.symbol lexer "_" +-- return SWild + +-- sbinop :: Parser S +-- sbinop = P.parens lexer $ do +-- e1 <- expr +-- op <- P.operator lexer +-- e2 <- expr +-- return (SBinOp (Atom op) e1 e2) + +-- expr :: Parser S +-- expr = +-- choice +-- [ try slam +-- , try sbinop +-- , try slet +-- , try sletrec +-- , try scase +-- , STuple <$> P.parens lexer (many expr) +-- , swild +-- , SAtom <$> (Atom <$> (P.identifier lexer)) +-- , SString <$> P.stringLiteral lexer +-- , SInt <$> P.integer lexer +-- ] ===================================== utils/check-cpp/ParseSimulate.hs ===================================== @@ -0,0 +1,83 @@ +module ParseSimulate where + +import Debug.Trace +import GHC +import GHC.Parser.Errors.Ppr () +import GHC.Parser.Lexer (Token (..)) +import qualified GHC.Parser.Lexer as Lexer + +import PreProcess + +-- --------------------------------------------------------------------- + +parseModuleNoHaddock :: PP [Located Token] +parseModuleNoHaddock = happySomeParser + where + -- happySomeParser = happyThen (happyParse 0#) (\x -> happyReturn (let {(HappyWrap35 x') = happyOut35 x} in x')) + happySomeParser = (>>=) (happyParse 0) (\x -> return x) + +happyParse :: Int -> PP [Located Token] +happyParse start_state = happyNewToken start_state [] [] + +happyNewToken :: Int -> [Int] -> [Located Token] -> PP [Located Token] +happyNewToken action sts stk = + -- lexer + ppLexerDbg + True + ( \tk -> + let cont i = + trace ("happyNewToken:tk=" ++ show tk) + $ happyDoAction i tk action sts stk + in case tk of + L _ ITeof -> happyDoAction 169 tk action sts stk + _ -> cont 5 + -- _ -> happyError' (tk, []) + ) + +happyDoAction :: Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] +-- happyDoAction num tk action sts stk = P $ \s -> POk s tk +happyDoAction num tk action sts stk = + case num of + 1 -> happyShift 2 num tk action sts stk + 2 -> happyShift 5 num tk action sts stk + 3 -> happyShift 5 num tk action sts stk + 4 -> happyShift 5 num tk action sts stk + 5 -> happyShift 5 num tk action sts stk + 50 -> happyAccept num tk action sts stk + 169 -> happyAccept num tk action sts stk + i -> happyFail ["failing:" ++ show i] i tk action sts stk + +-- happyAccept j tk st sts (HappyStk ans _) = +-- (happyTcHack j (happyTcHack st)) (happyReturn1 ans) + +happyAccept :: Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] +happyAccept _j tk _st _sts stk = + trace ("happyAccept:" ++ show tk) + $ return stk + +-- happyReturn1 :: a -> P a +-- happyReturn1 = return + +happyShift :: Int -> Int -> Located Token -> Int -> [Int] -> [Located Token] -> PP [Located Token] +happyShift new_state _i tk st sts stk = do + happyNewToken new_state (st : sts) (tk : stk) + +-- happyShift new_state i tk st sts stk = +-- happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) + +happyFail :: [String] -> Int -> Located Token -> p2 -> p3 -> p4 -> PP a +happyFail explist i tk _old_st _ _stk = + trace ("failing" ++ show explist) + $ happyError_ explist i tk + +happyError_ :: [String] -> p1 -> Located Token -> PP a +happyError_ explist _ tk = happyError' (tk, explist) + +notHappyAtAll :: a +notHappyAtAll = Prelude.error "Internal Happy error\n" + +happyError' :: (Located Token, [String]) -> PP a +happyError' tk = (\(_tokens, _explist) -> happyError) tk + +happyError :: PP a +happyError = Lexer.srcParseFail ===================================== utils/check-cpp/PreProcess.hs ===================================== @@ -0,0 +1,288 @@ +module PreProcess where + +import Data.Char +import Data.Map (Map) +import qualified Data.Map as Map +import GHC +import GHC.Data.FastString +import qualified GHC.Data.Strict as Strict +import GHC.Data.StringBuffer +import GHC.Parser.Errors.Ppr () +import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), Token (..)) +import qualified GHC.Parser.Lexer as Lexer +import GHC.Types.SrcLoc + +import Debug.Trace + +import Parse + +-- --------------------------------------------------------------------- + +type PP = P PpState + +initPpState :: PpState +initPpState = + PpState + { pp_defines = Map.empty + , pp_includes = Map.empty + , pp_include_stack = [] + , pp_continuation = [] + , pp_context = [] + , pp_accepting = True + } + +data PpState = PpState + { pp_defines :: !(Map String [String]) + , pp_includes :: !(Map String StringBuffer) + , pp_include_stack :: ![Lexer.AlexInput] + , pp_continuation :: ![Located Token] + , pp_context :: ![Token] -- What preprocessor directive we are currently processing + , pp_accepting :: !Bool + } + deriving (Show) + +-- deriving instance Show Lexer.AlexInput +-- --------------------------------------------------------------------- + +data CppState + = CppIgnoring + | CppNormal + deriving (Show) + +-- --------------------------------------------------------------------- + +ppLexer, ppLexerDbg :: Bool -> (Located Token -> PP a) -> PP a +-- Use this instead of 'lexer' in GHC.Parser to dump the tokens for debugging. +ppLexerDbg queueComments cont = ppLexer queueComments contDbg + where + contDbg tok = trace ("pptoken: " ++ show (unLoc tok)) (cont tok) +ppLexer queueComments cont = + Lexer.lexer + queueComments + ( \tk -> + let + contInner t = (trace ("ppLexer: tk=" ++ show (unLoc tk, unLoc t)) cont) t + -- contPush = pushContext (unLoc tk) >> contIgnoreTok tk + contIgnoreTok (L l tok) = do + case l of + RealSrcSpan r (Strict.Just b) -> Lexer.queueIgnoredToken (L (PsSpan r b) tok) + _ -> return () + ppLexer queueComments cont + in + -- case tk of + case (trace ("M.ppLexer:tk=" ++ show (unLoc tk)) tk) of + L _ ITeof -> do + mInp <- popIncludeLoc + case mInp of + Nothing -> contInner tk + Just inp -> do + Lexer.setInput inp + ppLexer queueComments cont + L _ (ITcpp continuation s) -> do + if continuation + then pushContinuation tk + else processCppToks s + contIgnoreTok tk + _ -> do + state <- getCppState + -- case (trace ("CPP state:" ++ show state) state) of + case state of + CppIgnoring -> contIgnoreTok tk + _ -> contInner tk + ) + +-- --------------------------------------------------------------------- + +preprocessElse :: PP () +preprocessElse = do + accepting <- getAccepting + setAccepting (not accepting) + +preprocessEnd :: PP () +preprocessEnd = do + -- TODO: nested context + setAccepting True + +processCppToks :: FastString -> PP () +processCppToks fs = do + let + get (L _ (ITcpp _ s)) = s + get _ = error "should not" + -- Combine any prior continuation tokens + cs <- popContinuation + processCpp (reverse $ fs : map get cs) + return () + +processCpp :: [FastString] -> PP () +processCpp fs = do + -- traceM $ "processCpp: fs=" ++ show fs + -- let s = cppInitial fs + let s = cppInitial fs + case regularParse cppDirective s of + Left err -> error $ show err + Right (CppInclude filename) -> do + ppInclude filename + Right (CppDefine name def) -> do + ppDefine name def + Right (CppIfdef name) -> do + defined <- ppIsDefined name + setAccepting defined + Right (CppIfndef name) -> do + defined <- ppIsDefined name + setAccepting (not defined) + Right CppElse -> do + accepting <- getAccepting + setAccepting (not accepting) + return () + Right CppEndif -> do + -- TODO: nested states + setAccepting True + return () + + -- return (trace ("processCpp:s=" ++ show s) ()) + return () + +-- --------------------------------------------------------------------- +-- Preprocessor state functions + +getCppState :: PP CppState +getCppState = do + accepting <- getAccepting + if accepting + then return CppNormal + else return CppIgnoring + +-- pp_context stack start ----------------- + +pushContext :: Token -> PP () +pushContext new = + P $ \s -> POk s{pp = (pp s){pp_context = new : pp_context (pp s)}} () + +popContext :: PP () +popContext = + P $ \s -> + let + new_context = case pp_context (pp s) of + [] -> [] + (_ : t) -> t + in + POk s{pp = (pp s){pp_context = new_context}} () + +peekContext :: PP Token +peekContext = + P $ \s -> + let + r = case pp_context (pp s) of + [] -> ITeof -- Anthing really, for now, except a CPP one + (h : _) -> h + in + POk s r + +setAccepting :: Bool -> PP () +setAccepting on = + P $ \s -> POk s{pp = (pp s){pp_accepting = on}} () + +getAccepting :: PP Bool +getAccepting = P $ \s -> POk s (pp_accepting (pp s)) + +-- ------------------------------------- + +pushContinuation :: Located Token -> PP () +pushContinuation new = + P $ \s -> POk s{pp = (pp s){pp_continuation = new : pp_continuation (pp s)}} () + +popContinuation :: PP [Located Token] +popContinuation = + P $ \s -> POk s{pp = (pp s){pp_continuation = []}} (pp_continuation (pp s)) + +-- pp_context stack end ------------------- + +-- pp_include start ----------------------- + +getInclude :: String -> PP (Maybe StringBuffer) +getInclude filename = P $ \s -> POk s (Map.lookup filename (pp_includes (pp s))) + +pushIncludeLoc :: Lexer.AlexInput -> PP () +pushIncludeLoc pos = + P $ \s -> POk s{pp = (pp s){pp_include_stack = pos : pp_include_stack (pp s)}} () + +popIncludeLoc :: PP (Maybe Lexer.AlexInput) +popIncludeLoc = + P $ \s -> + let + (new_st, r) = case pp_include_stack (pp s) of + [] -> ([], Nothing) + (h : t) -> (t, Just h) + in + POk s{pp = (pp s){pp_include_stack = new_st}} r + +-- pp_include end ------------------------- + +-- definitions start -------------------- + +ppInclude :: String -> PP () +ppInclude filename = do + mSrc <- getInclude filename + case mSrc of + Nothing -> return () + Just src -> do + origInput <- Lexer.getInput + pushIncludeLoc origInput + let loc = PsLoc (mkRealSrcLoc (mkFastString filename) 1 1) (BufPos 0) + Lexer.setInput (Lexer.AI loc src) + return $ trace ("ppInclude:mSrc=[" ++ show mSrc ++ "]") () + +-- return $ trace ("ppInclude:filename=[" ++ filename ++ "]") () + +ppDefine :: String -> [String] -> PP () +ppDefine name val = P $ \s -> + -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} () + POk s{pp = (pp s){pp_defines = Map.insert (trace ("ppDefine:def=[" ++ name ++ "]") name) val (pp_defines (pp s))}} () + +ppIsDefined :: String -> PP Bool +ppIsDefined def = P $ \s -> + -- POk s (Map.member def (pp_defines (pp s))) + POk s (Map.member (trace ("ppIsDefined:def=[" ++ def ++ "]") def) (pp_defines (pp s))) + +-- | Take a @FastString@ of the form "#define FOO\n" and strip off all but "FOO" +cleanTokenString :: FastString -> String +cleanTokenString fs = r + where + ss = dropWhile (\c -> not $ isSpace c) (unpackFS fs) + r = init ss + +parseDefine :: FastString -> Maybe (String, [String]) +parseDefine fs = r + where + -- r = Just (cleanTokenString s, "") + r = case regularParse cppDefinition (unpackFS fs) of + Left _ -> Nothing + Right v -> Just v + +-- ===================================================================== + +{- | Do cpp initial processing, as per https://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html +See Note [GhcCPP Initial Processing] +-} +cppInitial :: [FastString] -> String +cppInitial fs = r + where + -- go fs' = reverse $ drop 2 $ reverse $ unpackFS fs' + r = concatMap unpackFS fs + +{- +Note [GhcCPP Initial Processing] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This processing is based on the description at +https://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html + +It is only done for lines starting with a preprocessor +directive. + +1. Broken into lines. We rely on the GHC Lexer to do this +2. Trigraphs are not processed +3. Continued lines are merged into a single line + and is handled in the Lexer. +4. All comments are replaced with a single space + +-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c7e0f6989772855c535829f761e60ae396843dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c7e0f6989772855c535829f761e60ae396843dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 20:08:10 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 16:08:10 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] 3 commits: configure: Fix #21712 again Message-ID: <651f17aa3384e_18f52934379b30513287@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC Commits: 0a375448 by Ben Gamari at 2023-10-05T16:06:33-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. (cherry picked from commit f6b2751f58df5f4f83caa7a7ca56e66659d02b09) - - - - - b2791dba by Ben Gamari at 2023-10-05T16:07:05-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. (cherry picked from commit 8f6010b98f560200997a9d84a4e07bfd0ad6e496) - - - - - de4432cf by sheaf at 2023-10-05T16:07:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 (cherry picked from commit 8cee3fd7febdd97a9b4bcae7dddafe69b166149c) - - - - - 5 changed files: - compiler/GHC/Types/Name/Reader.hs - m4/find_ld.m4 - rts/sm/NonMoving.h - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1308,12 +1308,16 @@ childGREPriority (LookupChild { wantedParent = wanted_parent | isTermVarOrFieldNameSpace ns , isTermVarOrFieldNameSpace other_ns = Just 0 - | ns == varName + | isValNameSpace varName , other_ns == tcName - -- When looking up children, we sometimes want to a symbolic variable - -- name to resolve to a type constructor, e.g. for an infix declaration - -- "infix +!" we want to take into account both class methods and associated - -- types. See test T10816. + -- When looking up children, we sometimes want a value name + -- to resolve to a type constructor. + -- For example, for an infix declaration "infixr 3 +!" or "infix 2 `Fun`" + -- inside a class declaration, we want to account for the possibility + -- that the identifier refers to an associated type (type constructor + -- NameSpace), when otherwise "+!" would be in the term-level variable + -- NameSpace, and "Fun" would be in the term-level data constructor + -- NameSpace. See tests T10816, T23664, T24037. = Just 1 | ns == tcName , other_ns == dataName ===================================== m4/find_ld.m4 ===================================== @@ -61,19 +61,23 @@ AC_DEFUN([FIND_LD],[ AC_CHECK_TARGET_TOOL([LD], [ld]) } - if test "$ghc_host_os" = "darwin" ; then + case "$target" in + *-darwin) dnl N.B. Don't even try to find a more efficient linker on Darwin where dnl broken setups (e.g. unholy mixtures of Homebrew and the native dnl toolchain) are far too easy to come across. dnl dnl See #21712. AC_CHECK_TARGET_TOOL([LD], [ld]) - elif test "x$enable_ld_override" = "xyes"; then - find_ld - else - AC_CHECK_TARGET_TOOL([LD], [ld]) - fi - + ;; + *) + if test "x$enable_ld_override" = "xyes"; then + find_ld + else + AC_CHECK_TARGET_TOOL([LD], [ld]) + fi + ;; + esac CHECK_LD_COPY_BUG([$1]) ]) ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE ((uintptr_t)1 << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/tests/rename/should_compile/T24037.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, TypeOperators #-} + +module T24037 where + +class POrd a where + type Geq a b + infixr 6 `Geq` ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -215,6 +215,7 @@ test('T23434', normal, compile, ['']) test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) +test('T24037', normal, compile, ['']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86c1bdc48a6d4bc059c3fffb5c27d4fd69fc81bc...de4432cfef177c5669191f6a249f2d99ee00615d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86c1bdc48a6d4bc059c3fffb5c27d4fd69fc81bc...de4432cfef177c5669191f6a249f2d99ee00615d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 20:13:39 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 16:13:39 -0400 Subject: [Git][ghc/ghc][ghc-9.8] 3 commits: Bump containers submodule to 0.6.8 Message-ID: <651f18f36b474_18f529347a5858513445@gitlab.mail> Ben Gamari pushed to branch ghc-9.8 at Glasgow Haskell Compiler / GHC Commits: 5a602b33 by Ben Gamari at 2023-09-28T12:00:12-04:00 Bump containers submodule to 0.6.8 - - - - - c83b7688 by Ben Gamari at 2023-09-28T14:27:50-04:00 Bump Cabal submodule to 3.10.2.0 final - - - - - 86c1bdc4 by Ben Gamari at 2023-09-28T23:14:08-04:00 gitlab-ci: Allow release-hackage-lint to fail Head.hackage is not robust in the presence of patches to boot packages, as see in ghc/head.hackage#93. Allow it to fail for now. - - - - - 4 changed files: - .gitlab-ci.yml - libraries/Cabal - libraries/containers - testsuite/tests/driver/T4437.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -795,6 +795,7 @@ release-hackage-lint: artifacts: false rules: - if: '$RELEASE_JOB == "yes"' + allow_failure: true extends: .hackage variables: # No slow-validate bindist on release pipeline ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 720b6b1ab08655aa90c5454eefdcc5b4fa6e442b +Subproject commit 15a0010461c3d181f30fbbf5980bf75945d6df2a ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit f5d0b13251291c3bd1ae396f3e6c8b0b9eaf58b0 +Subproject commit 105289fde3ebd7419f817f8ade5381787209cbd9 ===================================== testsuite/tests/driver/T4437.hs ===================================== @@ -38,6 +38,7 @@ check title expected got expectedGhcOnlyExtensions :: [String] expectedGhcOnlyExtensions = [ "TypeAbstractions" + , "ExtendedLiterals" ] expectedCabalOnlyExtensions :: [String] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7b3fcb3da218d00bd0afe468edc43b4951f5c3f...86c1bdc48a6d4bc059c3fffb5c27d4fd69fc81bc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7b3fcb3da218d00bd0afe468edc43b4951f5c3f...86c1bdc48a6d4bc059c3fffb5c27d4fd69fc81bc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 20:22:53 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 16:22:53 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] 13 commits: Bump containers submodule to 0.6.8 Message-ID: <651f1b1d2a372_18f52934a364a05236f6@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC Commits: 5a602b33 by Ben Gamari at 2023-09-28T12:00:12-04:00 Bump containers submodule to 0.6.8 - - - - - c83b7688 by Ben Gamari at 2023-09-28T14:27:50-04:00 Bump Cabal submodule to 3.10.2.0 final - - - - - 86c1bdc4 by Ben Gamari at 2023-09-28T23:14:08-04:00 gitlab-ci: Allow release-hackage-lint to fail Head.hackage is not robust in the presence of patches to boot packages, as see in ghc/head.hackage#93. Allow it to fail for now. - - - - - 2a51d113 by Ben Gamari at 2023-10-05T16:13:45-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. (cherry picked from commit f6b2751f58df5f4f83caa7a7ca56e66659d02b09) - - - - - 8ed7ffb6 by Ben Gamari at 2023-10-05T16:13:45-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. (cherry picked from commit 8f6010b98f560200997a9d84a4e07bfd0ad6e496) - - - - - 894b6027 by sheaf at 2023-10-05T16:13:45-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 (cherry picked from commit 8cee3fd7febdd97a9b4bcae7dddafe69b166149c) - - - - - 9fb11d4a by Andreas Klebinger at 2023-10-05T16:15:25-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig (cherry picked from commit b048bea095d48751e7c182f2837c4a31fcad8fd7) - - - - - 88ca1d65 by Andreas Klebinger at 2023-10-05T16:15:29-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 (cherry picked from commit 2adc050857a9c1b992040fbfd55fbe65b2851b19) - - - - - 1fe0601f by Luite Stegeman at 2023-10-05T16:15:47-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 (cherry picked from commit 11ecc37bc27ffa1cf31358e21e09e140befa940c) - - - - - 77ec5b15 by Ben Gamari at 2023-10-05T16:16:04-04:00 system-cxx-std-lib: Add license and description (cherry picked from commit 151187407b7b4bdda5b80bd7b8bdf96d05e278dd) - - - - - c004b703 by Torsten Schmits at 2023-10-05T16:17:02-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 (cherry picked from commit 083794b10dc27e9d97b62cc8b8eb4e1da162bf66) - - - - - e76284cb by Alexis King at 2023-10-05T16:18:48-04:00 Don’t store the async exception masking state in CATCH frames (cherry picked from commit 8b61dfd6dfc78bfa6bb9449dac9a336e5d668b5e) - - - - - b33cbffd by Ben Gamari at 2023-10-05T16:19:26-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. (cherry picked from commit b35fd2cd7a12f3354a7fd2301bdf610c5d435017) - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Config/HsToCore/Ticks.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/debug-info.rst - docs/users_guide/ghci.rst - docs/users_guide/phases.rst - ghc/Main.hs - libraries/Cabal - libraries/base/configure.ac - libraries/base/jsbits/base.js - libraries/containers - m4/find_ld.m4 - mk/system-cxx-std-lib-1.0.conf.in - rts/Continuation.c - rts/Exception.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de4432cfef177c5669191f6a249f2d99ee00615d...b33cbffdff0ffa30f3c281da70072a5575eb5b32 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de4432cfef177c5669191f6a249f2d99ee00615d...b33cbffdff0ffa30f3c281da70072a5575eb5b32 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 20:23:30 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 16:23:30 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/release-9.8.1 Message-ID: <651f1b42f12d6_18f529347e80f452383a@gitlab.mail> Ben Gamari pushed new branch wip/release-9.8.1 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/release-9.8.1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 20:33:08 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 16:33:08 -0400 Subject: [Git][ghc/ghc][wip/T24050] hadrian: Move hsc2hs wrapper generation to bindist installation Message-ID: <651f1d847ac66_18f5293526dd6c5292a1@gitlab.mail> Ben Gamari pushed to branch wip/T24050 at Glasgow Haskell Compiler / GHC Commits: 80ce1d34 by Ben Gamari at 2023-10-05T16:32:57-04:00 hadrian: Move hsc2hs wrapper generation to bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. Fixes #24050. - - - - - 2 changed files: - hadrian/bindist/Makefile - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -235,13 +235,22 @@ install_man: export SHELL .PHONY: install_wrappers -install_wrappers: install_bin_libdir +install_wrappers: install_bin_libdir install_hsc2hs_wrapper @echo "Installing wrapper scripts" $(INSTALL_DIR) "$(DESTDIR)$(WrapperBinsDir)" for p in `cd wrappers; $(FIND) . ! -type d`; do \ mk/install_script.sh "$$p" "$(DESTDIR)/$(WrapperBinsDir)/$$p" "$(WrapperBinsDir)" "$(ActualBinsDir)" "$(ActualBinsDir)/$$p" "$(ActualLibsDir)" "$(docdir)" "$(includedir)"; \ done +.PHONY: install_hsc2hs_wrapper +install_hsc2hs_wrapper: + @echo "Installing hsc2hs wrapper" + echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> hsc2hs-wrapper + $(INSTALL_DIR) "$(DESTDIR)$(bindir)" + $(INSTALL_SCRIPT) hsc2hs-wrapper "$(DESTDIR)$(bindir)/hsc2hs" + rm -f hsc2hs-wrapper + + PKG_CONFS = $(shell find "$(DESTDIR)$(ActualLibsDir)/package.conf.d" -name '*.conf' | sed "s: :\0xxx\0:g") .PHONY: update_package_db update_package_db: install_bin install_lib ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -15,8 +15,6 @@ import Target import Utilities import qualified System.Directory.Extra as IO import Data.Either -import GHC.Toolchain (ccProgram, tgtCCompiler, ccLinkProgram, tgtCCompilerLink) -import GHC.Toolchain.Program (prgFlags) import qualified Data.Set as Set import Oracles.Flavour @@ -428,7 +426,7 @@ pkgToWrappers pkg = do | pkg == runGhc -> pure $ map (prefix++) ["runghc", "runhaskell"] -- These are the packages which we want to expose to the user and hence -- there are wrappers installed in the bindist. - | pkg `elem` [hpcBin, haddock, hp2ps, hsc2hs, ghc, ghcPkg] + | pkg `elem` [hpcBin, haddock, hp2ps, ghc, ghcPkg] -> (:[]) <$> (programName =<< programContext Stage1 pkg) | otherwise -> pure [] @@ -437,7 +435,6 @@ wrapper "ghc" = ghcWrapper wrapper "ghc-pkg" = ghcPkgWrapper wrapper "ghci" = ghciScriptWrapper wrapper "haddock" = haddockWrapper -wrapper "hsc2hs" = hsc2hsWrapper wrapper "runghc" = runGhcWrapper wrapper "runhaskell" = runGhcWrapper wrapper _ = commonWrapper @@ -459,18 +456,6 @@ haddockWrapper = pure $ "exec \"$executablename\" -B\"$libdir\" -l\"$libdir\" ${ commonWrapper :: Action String commonWrapper = pure $ "exec \"$executablename\" ${1+\"$@\"}\n" --- echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> "$(WRAPPER)" -hsc2hsWrapper :: Action String -hsc2hsWrapper = do - ccArgs <- map ("--cflag=" <>) . prgFlags . ccProgram . tgtCCompiler <$> targetStage Stage1 - linkFlags <- map ("--lflag=" <>) . prgFlags . ccLinkProgram . tgtCCompilerLink <$> targetStage Stage1 - wrapper <- drop 4 . lines <$> liftIO (readFile "utils/hsc2hs/hsc2hs.wrapper") - return $ unlines - ( "HSC2HS_EXTRA=\"" <> unwords (ccArgs ++ linkFlags) <> "\"" - : "tflag=\"--template=$libdir/template-hsc.h\"" - : "Iflag=\"-I$includedir/\"" - : wrapper ) - runGhcWrapper :: Action String runGhcWrapper = pure $ "exec \"$executablename\" -f \"$exedir/ghc\" ${1+\"$@\"}\n" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80ce1d34ffed67d7ff2899859728a0c503cd1be0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80ce1d34ffed67d7ff2899859728a0c503cd1be0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 20:34:08 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 16:34:08 -0400 Subject: [Git][ghc/ghc][wip/bump-unix] 2281 commits: winio: make consoleReadNonBlocking not wait for any events at all. Message-ID: <651f1dc030320_18f5293485c4b852971c@gitlab.mail> Ben Gamari pushed to branch wip/bump-unix at Glasgow Haskell Compiler / GHC Commits: fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00 winio: make consoleReadNonBlocking not wait for any events at all. - - - - - 42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00 rts: allow NULL to be used as an invalid StgStablePtr - - - - - 3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00 RTS: Add stack marker to StgCRunAsm.S Every object file must be properly marked for non-executable stack, even if it contains no code. - - - - - a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00 Bump unix submodule Adds `config.sub` to unix's `.gitignore`, fixing #19574. - - - - - 3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00 ghci: Fix most calls to isLoaded to work in multi-mode The most egrarious thing this fixes is the report about the total number of loaded modules after starting a session. Ticket #20889 - - - - - fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00 Enable :edit command in ghci multi-mode. This works after the last change to isLoaded. Ticket #20888 - - - - - 46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00 Fix a scoping bug in the Specialiser In the call to `specLookupRule` in `already_covered`, in `specCalls`, we need an in-scope set that includes the free vars of the arguments. But we simply were not guaranteeing that: did not include the `rule_bndrs`. Easily fixed. I'm not sure how how this bug has lain for quite so long without biting us. Fixes #21828. - - - - - 6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Edit Note [idArity varies independently of dmdTypeDepth] ...and refer to it in GHC.Core.Lint.lintLetBind. Fixes #21452 - - - - - 89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Tiny documentation wibbles (comments only) - - - - - 61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix readme - - - - - 61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix bootstrap - - - - - 8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00 tarball - - - - - e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Fix scopes for deriving clauses and instance signatures (#18425) - - - - - c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Record location of filled in default method bindings This is useful for hie files to reconstruct the evidence that default methods depend on. - - - - - 9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00 testsuite: Factor out common parts from hiefile tests - - - - - 6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00 Hadrian: update documentation of settings The documentation for key-value settings was a bit out of date. This patch updates it to account for `cabal.configure.opts` and `hsc2hs.run.opts`. The user-settings document was also re-arranged, to make the key-value settings more prominent (as it doesn't involve changing the Hadrian source code, and thus doesn't require any recompilation of Hadrian). - - - - - a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00 Fix potential space leak that arise from ModuleGraphs retaining references to previous ModuleGraphs, in particular the lazy `mg_non_boot` field. This manifests in `extendMG`. Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which is only called in two places in the compiler, and should only be called at most once for every home unit: GHC.Driver.Make: mainModuleSrcPath :: Maybe String mainModuleSrcPath = do ms <- mgLookupModule mod_graph (mainModIs hue) ml_hs_file (ms_location ms) GHCI.UI: listModuleLine modl line = do graph <- GHC.getModuleGraph let this = GHC.mgLookupModule graph modl Instead `mgLookupModule` can be a linear function that looks through the entire list of `ModuleGraphNodes` Fixes #21816 - - - - - dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00 rts: Fix AdjustorPool bitmap manipulation Previously the implementation of bitmap_first_unset assumed that `__builtin_clz` would accept `uint8_t` however it apparently rather extends its argument to `unsigned int`. To fix this we simply revert to a naive implementation since handling the various corner cases with `clz` is quite tricky. This should be fine given that AdjustorPool isn't particularly hot. Ideally we would have a single, optimised bitmap implementation in the RTS but I'll leave this for future work. Fixes #21838. - - - - - ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00 Change GHCi bytecode return convention for unlifted datatypes. This changes the bytecode return convention for unlifted algebraic datatypes to be the same as for lifted types, i.e. ENTER/PUSH_ALTS instead of RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED Fixes #20849 - - - - - 5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00 Compute record-dot-syntax types Ensures type information for record-dot-syntax is included in HieASTs. See #21797 - - - - - 89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00 Add record-dot-syntax test - - - - - 4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00 Document RuntimeRep polymorphism limitations of catch#, et al As noted in #21868, several primops accepting continuations producing RuntimeRep-polymorphic results aren't nearly as polymorphic as their types suggest. Document this limitation and adapt the `UnliftedWeakPtr` test to avoid breaking this limitation in `keepAlive#`. - - - - - 4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00 Make keepAlive# out-of-line This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203 - - - - - 1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00 Suppress extra output from configure check for c++ libraries - - - - - 3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00 rel-notes: Drop mention of #21745 fix Since we have backported the fix to 9.4.1. - - - - - b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00 Align the behaviour of `dopt` and `log_dopt` Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying function `log_dopt`) were different as the latter did not take the verbosity level into account. This led to problems during the refactoring as we cannot simply replace calls to `dopt` with calls to `logHasDumpFlag`. In addition to that a subtle bug in the GHC module was fixed: `setSessionDynFlags` did not update the logger and as a consequence the verbosity value of the logger was not set appropriately. Fixes #21861 - - - - - 28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00 rts: forkOn context switches the target capability Fixes #21824 - - - - - f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Eliminate orphan Outputable instances Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and `OutputableP` instances for the Cmm AST. This makes it significantly easier to use the Cmm pretty-printers in tracing output without incurring module import cycles. - - - - - f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Move toBlockList to GHC.Cmm - - - - - fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00 compiler: Add haddock sections to GHC.Utils.Panic - - - - - 097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00 configure: Don't override Windows CXXFLAGS At some point we used the clang distribution from msys2's `MINGW64` environment for our Windows toolchain. This defaulted to using libgcc and libstdc++ for its runtime library. However, we found for a variety of reasons that compiler-rt, libunwind, and libc++ were more reliable, consequently we explicitly overrode the CXXFLAGS to use these. However, since then we have switched to use the `CLANG64` packaging, which default to these already. Consequently we can drop these arguments, silencing some redundant argument warnings from clang. Fixes #21669. - - - - - e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Check that there are no NULL ctors - - - - - 616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Introduce support for invoking finalizers on unload Addresses #20494. - - - - - cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add T20494 - - - - - 03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Rename finit field to fini fini is short for "finalizer", which does not contain a "t". - - - - - 033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Refactor handling of oc->info Previously we would free oc->info after running initializers. However, we can't do this is we want to also run finalizers. Moreover, freeing oc->info so early was wrong for another reason: we will need it in order to unregister the exception tables (see the call to `RtlDeleteFunctionTable`). In service of #20494. - - - - - f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Add finalization support This implements #20494 for the PEi386 linker. Happily, this also appears to fix `T9405`, resolving #21361. - - - - - 2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00 Loader: Implement gnu-style -l:$path syntax Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic. - - - - - 5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00 Statically-link against libc++ on Windows Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435. - - - - - 8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run It turns out that PE objects may have multiple `.ctors`/`.dtors` sections but the RTS linker had assumed that there was only one. Fix this. Fixes #21618. - - - - - fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Respect dtor/ctor priority Previously we would run constructors and destructors in arbitrary order despite explicit priorities. Fixes #21847. - - - - - 1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add test for #21618 and #21847 - - - - - 6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Fix exception unwind unregistration RtlDeleteFunctionTable expects a pointer to the .pdata section yet we passed it the .xdata section. Happily, this fixes #21354. - - - - - d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Drop dead code - - - - - d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Use section flags to identify initializers - - - - - fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Introduce finalizer support - - - - - 5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl - - - - - 6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker/Elf: Work around GCC 6 init/fini behavior It appears that GCC 6t (at least on i386) fails to give init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY section types, instead marking them as SHT_PROGBITS. This caused T20494 to fail on Debian. - - - - - 5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Mark T13366Cxx as unbroken on Darwin - - - - - 1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Fix resolution of __dso_handle on Darwin Darwin expects a leading underscore. - - - - - a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Clean up section kinds - - - - - aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Ensure that __cxa_finalize is called on code unload - - - - - 028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00 testsuite: Fix T11829 on Centos 7 It appears that Centos 7 has a more strict C++ compiler than most distributions since std::runtime_error is defined in <stdexcept> rather than <exception>. In T11829 we mistakenly imported the latter. - - - - - a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00 hadrian: Rename documentation directories for consistency with make * Rename `docs` to `doc` * Place pdf documentation in `doc/` instead of `doc/pdfs/` Fixes #21164. - - - - - b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00 Fix incorrect proof of applyWhen’s properties - - - - - eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00 hadrian: Add multi:<pkg> and multi targets for starting a multi-repl This patch adds support to hadrian for starting a multi-repl containing all the packages which stage0 can build. In particular, there is the new user-facing command: ``` ./hadrian/ghci-multi ``` which when executed will start a multi-repl containing the `ghc` package and all it's dependencies. This is implemented by two new hadrian targets: ``` ./hadrian/build multi:<pkg> ``` Construct the arguments for a multi-repl session where the top-level package is <pkg>. For example, `./hadrian/ghci-multi` is implemented using `multi:ghc` target. There is also the `multi` command which constructs a repl for everything in stage0 which we can build. - - - - - 19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00 changelog typo - - - - - af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00 typos - - - - - 415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00 Refactor SpecConstr to use treat bindings uniformly This patch, provoked by #21457, simplifies SpecConstr by treating top-level and nested bindings uniformly (see the new scBind). * Eliminates the mysterious scTopBindEnv * Refactors scBind to handle top-level and nested definitions uniformly. * But, for now at least, continues the status quo of not doing SpecConstr for top-level non-recursive bindings. (In contrast we do specialise nested non-recursive bindings, although the original paper did not; see Note [Local let bindings].) I tried the effect of specialising top-level non-recursive bindings (which is now dead easy to switch on, unlike before) but found some regressions, so I backed off. See !8135. It's a pure refactoring. I think it'll do a better job in a few cases, but there is no regression test. - - - - - d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00 Rule matching: Don't compute the FVs if we don't look at them. - - - - - 5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 White space only in FamInstEnv - - - - - ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make transferPolyIdInfo work for CPR I don't know why this hasn't bitten us before, but it was plain wrong. - - - - - 9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Inline mapAccumLM This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically. - - - - - d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make SetLevels honour floatConsts This fix, in the definition of profitableFloat, is just for consistency. `floatConsts` should do what it says! I don't think it'll affect anything much, though. - - - - - d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Refactor wantToUnboxArg a bit * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg and similarly wantToUnboxResult to canUnboxResult. * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg, avoiding some yukky duplication. I decided it was clearer to give it a new data type for its return type, because I nedeed the FD_RecBox case which was not otherwise readiliy expressible. * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload * Get rid of the Unlift constructor of UnboxingDecision, eliminate two panics, and two arguments to canUnboxArg (new name). Much nicer now. - - - - - 6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00 Allow running memInventory when the concurrent nonmoving gc is enabled If the nonmoving gc is enabled and we are using a threaded RTS, we now try to grab the collector mutex to avoid memInventory and the collection racing. Before memInventory was disabled. - - - - - aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00 gitignore: don't ignore all aclocal.m4 files While GHC's own aclocal.m4 is generated by the aclocal tool, other packages' aclocal.m4 are committed in the repository. Previously `.gitignore` included an entry which covered *any* file named `aclocal.m4`, which lead to quite some confusion (e.g. see #21740). Fix this by modifying GHC's `.gitignore` to only cover GHC's own `aclocal.m4`. - - - - - 4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00 Add mapAccumM, forAccumM to Data.Traversable Approved by Core Libraries Committee in https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433 - - - - - bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00 configure: Use AC_PATH_TOOL to detect tools Previously we used AC_PATH_PROG which, as noted by #21601, does not look for tools with a target prefix, breaking cross-compilation. Fixes #21601. - - - - - e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00 driver: Fix implementation of -S We were failing to stop before running the assembler so the object file was also created. Fixes #21869 - - - - - e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00 rts/ProfHeap: Ensure new Censuses are zeroed When growing the Census array ProfHeap previously neglected to zero the new part of the array. Consequently `freeEra` would attempt to free random words that often looked suspiciously like pointers. Fixes #21880. - - - - - 81d65f7f by sheaf at 2022-07-21T15:37:22+02:00 Make withDict opaque to the specialiser As pointed out in #21575, it is not sufficient to set withDict to inline after the typeclass specialiser, because we might inline withDict in one module and then import it in another, and we run into the same problem. This means we could still end up with incorrect runtime results because the typeclass specialiser would assume that distinct typeclass evidence terms at the same type are equal, when this is not necessarily the case when using withDict. Instead, this patch introduces a new magicId, 'nospec', which is only inlined in CorePrep. We make use of it in the definition of withDict to ensure that the typeclass specialiser does not common up distinct typeclass evidence terms. Fixes #21575 - - - - - 9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00 Refactored Simplify pass * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify namespace and GHC.Core.Opt.Stats. Also removed services from configuration records. * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration. * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm` and moved the Simplify driver to GHC.Core.Opt.Simplify. * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env. * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment in GHC.Core.Opt.Simplify.Monad. * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions for those in a new module GHC.Driver.Config.Core.Opt.Simplify. Also added initialization functions for `SimplMode` to that module. * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types and the counting types and functions (`SimplCount` and `Tick`) to new module GHC.Core.Opt.Stats. * Added getter functions for the fields of `SimplMode`. The pedantic bottoms option and the platform are retrieved from the ArityOpts and RuleOpts and the getter functions allow us to retrieve values from `SpecEnv` without the knowledge where the data is stored exactly. * Moved the coercion optimization options from the top environment to `SimplMode`. This way the values left in the top environment are those dealing with monadic functionality, namely logging, IO related stuff and counting. Added a note "The environments of the Simplify pass". * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead. * Prep work before removing `InteractiveContext` from `HscEnv`. - - - - - 2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00 Make the specialiser deal better with specialised methods This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368. - - - - - ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00 ghc-boot: Clean up UTF-8 codecs In preparation for moving the UTF-8 codecs into `base`: * Move them to GHC.Utils.Encoding.UTF8 * Make names more consistent * Add some Haddocks - - - - - e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00 base: Introduce GHC.Encoding.UTF8 Here we copy a subset of the UTF-8 implementation living in `ghc-boot` into `base`, with the intent of dropping the former in the future. For this reason, the `ghc-boot` copy is now CPP-guarded on `MIN_VERSION_base(4,18,0)`. Naturally, we can't copy *all* of the functions defined by `ghc-boot` as some depend upon `bytestring`; we rather just copy those which only depend upon `base` and `ghc-prim`. Further consolidation? ---------------------- Currently GHC ships with at least five UTF-8 implementations: * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this can be used at a number of types including `Addr#`, `ByteArray#`, `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this can be removed in GHC 9.6+2, when the copies in `base` will become available to `ghc-boot`. * the copy of the `ghc-boot` definition now exported by `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`, `ByteArray#`, and `ForeignPtr` * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`; this is specialised at `Addr#`. * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`; this is specialised at `Addr#` but, unlike the above, supports recovery in the presence of partial codepoints (since in IO contexts codepoints may be broken across buffers) * the implementation provided by the `text` library This does seem a tad silly. On the other hand, these implementations *do* materially differ from one another (e.g. in the types they support, the detail in errors they can report, and the ability to recover from partial codepoints). Consequently, it's quite unclear that further consolidate would be worthwhile. - - - - - f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00 Add a Note summarising GHC's UTF-8 implementations GHC has a somewhat dizzying array of UTF-8 implementations. This note describes why this is the case. - - - - - 72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00 upload_ghc_libs: Fix path to documentation The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35 but this one occurrence was note updated. Finally closes #21164. - - - - - a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00 Add test for #21871 This adds a test for #21871, which was fixed by the No Skolem Info rework (MR !7105). Fixes #21871 - - - - - 6379f942 by sheaf at 2022-07-22T08:18:46-04:00 Add test for #21360 The way record updates are typechecked/desugared changed in MR !7981. Because we desugar in the typechecker to a simple case expression, the pattern match checker becomes able to spot the long-distance information and avoid emitting an incorrect pattern match warning. Fixes #21360 - - - - - ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00 Hadrian: don't try to build "unix" on Windows - - - - - dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Implement DeepSubsumption This MR adds the language extension -XDeepSubsumption, implementing GHC proposal #511. This change mitigates the impact of GHC proposal The changes are highly localised, by design. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. The main changes are: * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010, but off in Haskell2021. -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change. -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds: it makes type inference more complicated and less predictable, but it may be convenient in practice. * The main changes are in: * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result type. Without deep subsumption, unifyExpectedType would be sufficent. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. * There are no changes to Quick Look at all. * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to GHC.Magic.Dict * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where we'd forgotten to take the free vars of the multiplicity of an Id. * I also had to fix tcSplitNestedSigmaTys When I did the shallow-subsumption patch commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f Date: Sun Feb 2 18:23:11 2020 +0000 Simple subsumption I changed tcSplitNestedSigmaTys to not look through function arrows any more. But that was actually an un-forced change. This function is used only in * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect All to do with validity checking and error messages. Acutally its fine to look under function arrows here, and quite useful a test DeepSubsumption05 (a test motivated by a build failure in the `lens` package) shows. The fix is easy. I added Note [tcSplitNestedSigmaTys]. - - - - - e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption - - - - - 67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add DeepSubsumption08 - - - - - 5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Fix the interaction of operator sections and deep subsumption Fixes DeepSubsumption08 - - - - - 918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00 Add DeepSubsumption09 - - - - - 2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00 Default implementation for mempty/(<>) Approved by: https://github.com/haskell/core-libraries-committee/issues/61 This adds a default implementation for `mempty` and `(<>)` along with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid` instances can be defined in terms of `sconcat` / `mconcat`. The description for each class has also been updated to include the equivalent set of laws for the `sconcat`-only / `mconcat`-only instances. - - - - - 73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00 ci: Disable (broken) perf-nofib See #21859 - - - - - c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00 Docs: clarify ConstraintKinds infelicity GHC doesn't consistently require the ConstraintKinds extension to be enabled, as it allows programs such as type families returning a constraint without this extension. MR !7784 fixes this infelicity, but breaking user programs was deemed to not be worth it, so we document it instead. Fixes #21061. - - - - - 5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00 More improvements to worker/wrapper This patch fixes #21888, and simplifies finaliseArgBoxities by eliminating the (recently introduced) data type FinalDecision. A delicate interaction meant that this patch commit d1c25a48154236861a413e058ea38d1b8320273f Date: Tue Jul 12 16:33:46 2022 +0100 Refactor wantToUnboxArg a bit make worker/wrapper go into an infinite loop. This patch fixes it by narrowing the handling of case (B) of Note [Boxity for bottoming functions], to deal only the arguemnts that are type variables. Only then do we drop the trimBoxity call, which is what caused the bug. I also * Added documentation of case (B), which was previously completely un-mentioned. And a regression test, T21888a, to test it. * Made unboxDeeplyDmd stop at lazy demands. It's rare anyway for a bottoming function to have a lazy argument (mainly when the data type is recursive and then we don't want to unbox deeply). Plus there is Note [No lazy, Unboxed demands in demand signature] * Refactored the Case equation for dmdAnal a bit, to do less redundant pattern matching. - - - - - b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00 Fix a small buglet in tryEtaReduce Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was making an ill-formed cast. It didn't matter, because the subsequent guard discarded it; but still worth fixing. Spurious warnings are distracting. - - - - - 3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00 Fix #21889, GHCi misbehaves with Ctrl-C on Windows On Windows, we create multiple levels of wrappers for GHCi which ultimately execute ghc --interactive. In order to handle console events properly, each of these wrappers must call FreeConsole() in order to hand off event processing to the child process. See #14150. In addition to this, FreeConsole must only be called from interactive processes (#13411). This commit makes two changes to fix this situation: 1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole` if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi. 2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`: Before: ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe After: ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe - - - - - 79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00 docs: Fix documentation of \cases Fixes #21902. - - - - - e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00 ghc-cabal: allow Cabal 3.8 to unbreak make build When bootstrapping GHC 9.4.*, the build will fail when configuring ghc-cabal as part of the make based build system due to this upper bound, as Cabal has been updated to a 3.8 release. Reference #21914, see especially https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699 - - - - - 726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Fix isEvaldUnfolding and isValueUnfolding This fixes (1) in #21831. Easy, obviously correct. - - - - - 5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Switch off eta-expansion in rules and unfoldings I think this change will make little difference except to reduce clutter. But that's it -- if it causes problems we can switch it on again. - - - - - d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Teach SpecConstr about typeDeterminesValue This patch addresses #21831, point 2. See Note [generaliseDictPats] in SpecConstr I took the opportunity to refactor the construction of specialisation rules a bit, so that the rule name says what type we are specialising at. Surprisingly, there's a 20% decrease in compile time for test perf/compiler/T18223. I took a look at it, and the code size seems the same throughout. I did a quick ticky profile which seemed to show a bit less substitution going on. Hmm. Maybe it's the "don't do eta-expansion in stable unfoldings" patch, which is part of the same MR as this patch. Anyway, since it's a move in the right direction, I didn't think it was worth looking into further. Metric Decrease: T18223 - - - - - 65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Add a 'notes' file in testsuite/tests/perf/compiler This file is just a place to accumlate notes about particular benchmarks, so that I don't keep re-inventing the wheel. - - - - - 61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00 Get the in-scope set right in FamInstEnv.injectiveBranches There was an assert error, as Gergo pointed out in #21896. I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs. And also to GHC.Core.Unify.niFixTCvSubst. I also took the opportunity to get a couple more InScopeSets right, and to change some substTyUnchecked into substTy. This MR touches a lot of other files, but only because I also took the opportunity to introduce mkInScopeSetList, and use it. - - - - - 4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00 Add location to cc phase - - - - - 96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00 Avoid as pipeline when compiling c - - - - - 2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00 testsuite: Skip test cases involving -S when testing unregisterised GHC We no longer generate .s files anyway. Metric Decrease: MultiLayerModules T10421 T13035 T13701 T14697 T16875 T18140 T18304 T18923 T9198 - - - - - 82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00 testsuite: introduce nonmoving_thread_sanity way (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae) - - - - - 4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Track segment state It can often be useful during debugging to be able to determine the state of a nonmoving segment. Introduce some state, enabled by DEBUG, to track this. (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f) - - - - - 54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Don't scavenge objects which weren't evacuated This fixes a rather subtle bug in the logic responsible for scavenging objects evacuated to the non-moving generation. In particular, objects can be allocated into the non-moving generation by two ways: a. evacuation out of from-space by the garbage collector b. direct allocation by the mutator Like all evacuation, objects moved by (a) must be scavenged, since they may contain references to other objects located in from-space. To accomplish this we have the following scheme: * each nonmoving segment's block descriptor has a scan pointer which points to the first object which has yet to be scavenged * the GC tracks a set of "todo" segments which have pending scavenging work * to scavenge a segment, we scavenge each of the unmarked blocks between the scan pointer and segment's `next_free` pointer. We skip marked blocks since we know the allocator wouldn't have allocated into marked blocks (since they contain presumably live data). We can stop at `next_free` since, by definition, the GC could not have evacuated any objects to blocks above `next_free` (otherwise `next_free wouldn't be the first free block). However, this neglected to consider objects allocated by path (b). In short, the problem is that objects directly allocated by the mutator may become unreachable (but not swept, since the containing segment is not yet full), at which point they may contain references to swept objects. Specifically, we observed this in #21885 in the following way: 1. the mutator (specifically in #21885, a `lockCAF`) allocates an object (specifically a blackhole, which here we will call `blkh`; see Note [Static objects under the nonmoving collector] for the reason why) on the non-moving heap. The bitmap of the allocated block remains 0 (since allocation doesn't affect the bitmap) and the containing segment's (which we will call `blkh_seg`) `next_free` is advanced. 2. We enter the blackhole, evaluating the blackhole to produce a result (specificaly a cons cell) in the nursery 3. The blackhole gets updated into an indirection pointing to the cons cell; it is pushed to the generational remembered set 4. we perform a GC, the cons cell is evacuated into the nonmoving heap (into segment `cons_seg`) 5. the cons cell is marked 6. the GC concludes 7. the CAF and blackhole become unreachable 8. `cons_seg` is filled 9. we start another GC; the cons cell is swept 10. we start a new GC 11. something is evacuated into `blkh_seg`, adding it to the "todo" list 12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks between `scan` and `next_free`, which includes `blkh`). We attempt to evacuate `blkh`'s indirectee, which is the previously-swept cons cell. This is unsafe, since the indirectee is no longer a valid heap object. The problem here was that the scavenging logic *assumed* that (a) was the only source of allocations into the non-moving heap and therefore *all* unmarked blocks between `scan` and `next_free` were evacuated. However, due to (b) this is not true. The solution is to ensure that that the scanned region only encompasses the region of objects allocated during evacuation. We do this by updating `scan` as we push the segment to the todo-segment list to point to the block which was evacuated into. Doing this required changing the nonmoving scavenging implementation's update of the `scan` pointer to bump it *once*, instead of after scavenging each block as was done previously. This is because we may end up evacuating into the segment being scavenged as we scavenge it. This was quite tricky to discover but the result is quite simple, demonstrating yet again that global mutable state should be used exceedingly sparingly. Fixes #21885 (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060) - - - - - 25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00 testsuite: Skip a few tests as in the nonmoving collector Residency monitoring under the non-moving collector is quite conservative (e.g. the reported value is larger than reality) since otherwise we would need to block on concurrent collection. Skip a few tests that are sensitive to residency. (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70) - - - - - 42147534 by sternenseemann at 2022-07-26T16:26:53-04:00 hadrian: add flag disabling selftest rules which require QuickCheck The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699. - - - - - 9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00 Regression test for #21848 - - - - - ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00 driver: Don't create LinkNodes when -no-link is enabled Fixes #21866 - - - - - fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00 Docs: fix mistaken claim about kind signatures This patch fixes #21806 by rectifying an incorrect claim about the usage of kind variables in the header of a data declaration with a standalone kind signature. It also adds some clarifications about the number of parameters expected in GADT declarations and in type family declarations. - - - - - 2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00 testsuite: Correctly set withNativeCodeGen Fixes #21918 - - - - - f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00 Fix since annotations in GHC.Stack.CloneStack Fixes #21894 - - - - - aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00 Add -dsuppress-coercion-types to make coercions even smaller. Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)`` simply print `` `cast` <Co:11> :: ... `` - - - - - 97655ad8 by sheaf at 2022-08-02T19:27:29-04:00 User's guide: fix typo in hasfield.rst Fixes #21950 - - - - - 35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00 Remove TCvSubst and use Subst for both term and type-level subst This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types). - - - - - b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00 Fix TH + defer-type-errors interaction (#21920) Previously, we had to disable defer-type-errors in splices because of #7276. But this fix is no longer necessary, the test T7276 no longer segfaults and is now correctly deferred. - - - - - fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00 Add a note about about W/W for unlifting strict arguments This fixes #21236. - - - - - fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force safeInferred to avoid retaining extra copy of DynFlags This will only have a (very) modest impact on memory but we don't want to retain old copies of DynFlags hanging around so best to force this value. - - - - - 0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force name selectors to ensure no reference to Ids enter the NameCache I observed some unforced thunks in the NameCache which were retaining a whole Id, which ends up retaining a Type.. which ends up retaining old copies of HscEnv containing stale HomeModInfo. - - - - - 0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Fix leaks in --make mode when there are module loops This patch fixes quite a tricky leak where we would end up retaining stale ModDetails due to rehydrating modules against non-finalised interfaces. == Loops with multiple boot files It is possible for a module graph to have a loop (SCC, when ignoring boot files) which requires multiple boot files to break. In this case we must perform the necessary hydration steps before and after compiling modules which have boot files which are described above for corectness but also perform an additional hydration step at the end of the SCC to remove space leaks. Consider the following example: ┌───────┐ ┌───────┐ │ │ │ │ │ A │ │ B │ │ │ │ │ └─────┬─┘ └───┬───┘ │ │ ┌────▼─────────▼──┐ │ │ │ C │ └────┬─────────┬──┘ │ │ ┌────▼──┐ ┌───▼───┐ │ │ │ │ │ A-boot│ │ B-boot│ │ │ │ │ └───────┘ └───────┘ A, B and C live together in a SCC. Say we compile the modules in order A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps (because A has a boot file). Therefore C will be hydrated relative to A, and the ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again, and so B will reference C/A,B, its interface will be hydrated relative to both A and B. Now there is a space leak because say C is a very big module, there are now two different copies of ModDetails kept alive by modules A and B. The way to avoid this space leak is to rehydrate an entire SCC together at the end of compilation so that all the ModDetails point to interfaces for .hs files. In this example, when we hydrate A, B and C together then both A and B will refer to C/A,B. See #21900 for some more discussion. ------------------------------------------------------- In addition to this simple case, there is also the potential for a leak during parallel upsweep which is also fixed by this patch. Transcibed is Note [ModuleNameSet, efficiency and space leaks] Note [ModuleNameSet, efficiency and space leaks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During unsweep the results of compiling modules are placed into a MVar, to find the environment the module needs to compile itself in the MVar is consulted and the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking module dependencies and recreating the HUG from scratch each time is very expensive. In serial mode (-j1), this all works out fine because a module can only be compiled after its dependencies have finished compiling and not interleaved with compiling module loops. Therefore when we create the finalised or no loop interfaces, the HUG only contains finalised interfaces. In parallel mode, we have to be more careful because the HUG variable can contain non-finalised interfaces which have been started by another thread. In order to avoid a space leak where a finalised interface is compiled against a HPT which contains a non-finalised interface we have to restrict the HUG to only the visible modules. The visible modules is recording in the ModuleNameSet, this is propagated upwards whilst compiling and explains which transitive modules are visible from a certain point. This set is then used to restrict the HUG before the module is compiled to only the visible modules and thus avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance because a union occurs for each edge in the module graph. Therefore the set is represented directly as an IntSet which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. See test "jspace" for an example which used to trigger this problem. Fixes #21900 - - - - - 1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Store interfaces in ModIfaceCache more directly I realised hydration was completely irrelavant for this cache because the ModDetails are pruned from the result. So now it simplifies things a lot to just store the ModIface and Linkable, which we can put into the cache straight away rather than wait for the final version of a HomeModInfo to appear. - - - - - 6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00 cmm: Remove unused ReadOnlyData16 We don't actually emit rodata16 sections anywhere. - - - - - 16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00 findExternalRules: Don't needlessly traverse the list of rules. - - - - - 52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00 Remove backported items from 9.6 release notes They have been backported to 9.4 in commits 5423d84bd9a28f, 13c81cb6be95c5, 67ccbd6b2d4b9b. - - - - - 78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00 ci: Fix pages job The job has been failing because we don't bundle haddock docs anymore in the docs dist created by hadrian. Fixes #21789 - - - - - 037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00 codeGen/X86: Don't clobber switch variable in switch generation Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was safe to clobber the switch variable when generating code for a jump table since we were at the end of a block. However, this assumption is wrong; the register could be live in the jump target. Fixes #21968. - - - - - 50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00 Fix equality operator in jspace test - - - - - e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Improve BUILD_PAP comments - - - - - 41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Make dropTail comment a haddock comment - - - - - ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Add one more sanity check in stg_restore_cccs - - - - - 1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00 StgToCmm: Fix isSimpleScrut when profiling is enabled. When profiling is enabled we must enter functions that might represent thunks in order for their sccs to show up in the profile. We might allocate even if the function is already evaluated in this case. So we can't consider any potential function thunk to be a simple scrut when profiling. Not doing so caused profiled binaries to segfault. - - - - - fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Change `-fprof-late` to insert cost centres after unfolding creation. The former behaviour of adding cost centres after optimization but before unfoldings are created is not available via the flag `prof-late-inline` instead. I also reduced the overhead of -fprof-late* by pushing the cost centres into lambdas. This means the cost centres will only account for execution of functions and not their partial application. Further I made LATE_CC cost centres it's own CC flavour so they now won't clash with user defined ones if a user uses the same string for a custom scc. LateCC: Don't put cost centres inside constructor workers. With -fprof-late they are rarely useful as the worker is usually inlined. Even if the worker is not inlined or we use -fprof-late-linline they are generally not helpful but bloat compile and run time significantly. So we just don't add sccs inside constructor workers. ------------------------- Metric Decrease: T13701 ------------------------- - - - - - f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00 gitlab-ci: Fix hadrian bootstrapping of release pipelines Previously we would attempt to test hadrian bootstrapping in the `validate` build flavour. However, `ci.sh` refuses to run validation builds during release pipelines, resulting in job failures. Fix this by testing bootstrapping in the `release` flavour during release pipelines. We also attempted to record perf notes for these builds, which is redundant work and undesirable now since we no longer build in a consistent flavour. - - - - - c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00 compiler: Eliminate two uses of foldr in favor of foldl' These two uses constructed maps, which is a case where foldl' is generally more efficient since we avoid constructing an intermediate O(n)-depth stack. - - - - - d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00 rts: Fix code style - - - - - 57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00 genprimopcode: Drop ArrayArray# references As ArrayArray# no longer exists - - - - - 7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00 base: Organize Haddocks in GHC.Conc.Sync - - - - - aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00 Add primop to list threads A user came to #ghc yesterday wondering how best to check whether they were leaking threads. We ended up using the eventlog but it seems to me like it would be generally useful if Haskell programs could query their own threads. - - - - - 6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00 rts: Move thread labels into TSO This eliminates the thread label HashTable and instead tracks this information in the TSO, allowing us to use proper StgArrBytes arrays for backing the label and greatly simplifying management of object lifetimes when we expose them to the user with the coming `threadLabel#` primop. - - - - - 1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00 Add a primop to query the label of a thread - - - - - 43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00 base: Share finalization thread label For efficiency's sake we float the thread label assigned to the finalization thread to the top-level, ensuring that we only need to encode the label once. - - - - - 1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00 users-guide: Add release notes entry for thread introspection support - - - - - 09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix binary distribution install attributes Previously we would use plain `cp` to install various parts of the binary distribution. However, `cp`'s behavior w.r.t. file attributes is quite unclear; for this reason it is much better to rather use `install`. Fixes #21965. - - - - - 2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix installation of system-cxx-std-lib package conf - - - - - 7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00 gitlab-ci: Bump Docker images To give the ARMv7 job access to lld, fixing #21875. - - - - - afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Don't use mk/config.mk.in Ultimately we want to drop mk/config.mk so here I extract the bits needed by the Hadrian bindist installation logic into a Hadrian-specific file. While doing this I fixed binary distribution installation, #21901. - - - - - b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Fix naming of cross-compiler wrappers - - - - - 78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00 hadrian: Extend xattr Darwin hack to cover /lib As noted in #21506, it is now necessary to remove extended attributes from `/lib` as well as `/bin` to avoid SIP issues on Darwin. Fixes #21506. - - - - - 20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00 NCG(x86): Compile add+shift as lea if possible. - - - - - 742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00 dataToTag#: Skip runtime tag check if argument is infered tagged This addresses one part of #21710. - - - - - 1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00 rts: remove redundant stg_traceCcszh This out-of-line primop has no Haskell wrapper and hasn't been used anywhere in the tree. Furthermore, the code gets in the way of !7632, so it should be garbage collected. - - - - - a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00 Document a divergence from the report in parsing function lhss. GHC is happy to parse `(f) x y = x + y` when it should be a parse error based on the Haskell report. Seems harmless enough so we won't fix it but it's documented now. Fixes #19788 - - - - - 5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00 gitlab-ci: Add release job for aarch64/debian 11 - - - - - 5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Introduce validation job for aarch64 cross-compilation Begins to address #11958. - - - - - e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00 Bump process submodule - - - - - ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Add basic support for cross-compiler testiing Here we add a simple qemu-based test for cross-compilers. - - - - - 50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00 rts: Ensure that Array# card arrays are initialized In #19143 I noticed that newArray# failed to initialize the card table of newly-allocated arrays. However, embarrassingly, I then only fixed the issue in newArrayArray# and, in so doing, introduced the potential for an integer underflow on zero-length arrays (#21962). Here I fix the issue in newArray#, this time ensuring that we do not underflow in pathological cases. Fixes #19143. - - - - - e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00 testsuite: Add test for #21962 - - - - - c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00 gitlab-ci: Don't use coreutils on Darwin In general we want to ensure that the tested environment is as similar as possible to the environment the user will use. In the case of Darwin, this means we want to use the system's BSD command-line utilities, not coreutils. This would have caught #21974. - - - - - 1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00 hadrian: Fix bindist installation on Darwin It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does. - - - - - 681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00 hadrian: Fix access mode of installed package registration files Previously hadrian's bindist Makefile would modify package registrations placed by `install` via a shell pipeline and `mv`. However, the use of `mv` means that if umask is set then the user may otherwise end up with package registrations which are inaccessible. Fix this by ensuring that the mode is 0644. - - - - - e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00 Cleanups around pretty-printing * Remove hack when printing OccNames. No longer needed since e3dcc0d5 * Remove unused `pprCmms` and `instance Outputable Instr` * Simplify `pprCLabel` (no need to pass platform) * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by ImmLit, but that can take just a String instead. * Remove instance `Outputable CLabel` - proper output of labels needs a platform, and is done by the `OutputableP` instance - - - - - 66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00 rts/linker: Resolve iconv_* on FreeBSD FreeBSD's libiconv includes an implementation of the iconv_* functions in libc. Unfortunately these can only be resolved using dlvsym, which is how the RTS linker usually resolves such functions. To fix this we include an ad-hoc special case for iconv_*. Fixes #20354. - - - - - 5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00 system-cxx-std-lib: Add support for FreeBSD libcxxrt - - - - - ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00 gitlab-ci: Bump to use freebsd13 runners - - - - - d71a2051 by sheaf at 2022-08-09T13:47:28-04:00 Fix size_up_alloc to account for UnliftedDatatypes The size_up_alloc function mistakenly considered any type that isn't lifted to not allocate anything, which is wrong. What we want instead is to check the type isn't boxed. This accounts for (BoxedRep Unlifted). Fixes #21939 - - - - - 76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. - - - - - 7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. - - - - - dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00 Updates language extension documentation Adding a 'Status' field with a few values: - Deprecated - Experimental - InternalUseOnly - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98' Those values are pulled from the existing descriptions or elsewhere in the documentation. While at it, include the :implied by: where appropriate, to provide more detail. Fixes #21475 - - - - - 823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00 hadrian RunRest: add type signature for stageNumber avoids warning seen on 9.4.1: src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults] • Defaulting the following constraints to type ‘Integer’ (Show a0) arising from a use of ‘show’ at src/Settings/Builders/RunTest.hs:264:53-84 (Num a0) arising from a use of ‘stageNumber’ at src/Settings/Builders/RunTest.hs:264:59-83 • In the second argument of ‘(++)’, namely ‘show (stageNumber (C.stage ctx))’ In the second argument of ‘($)’, namely ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’ In the expression: arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | 264 | , arg "-e", arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compilation tested locally - - - - - f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00 Add support for external static plugins (#20964) This patch adds a new command-line flag: -fplugin-library=<file-path>;<unit-id>;<module>;<args> used like this: -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"] It allows a plugin to be loaded directly from a shared library. With this approach, GHC doesn't compile anything for the plugin and doesn't load any .hi file for the plugin and its dependencies. As such GHC doesn't need to support two environments (one for plugins, one for target code), which was the more ambitious approach tracked in #14335. Fix #20964 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Fix ARMv7 build It appears that the CI refactoring carried out in 5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some critical configuration: setting the build/host/target platforms and forcing use of a non-broken linker. - - - - - 596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Run ARMv7 jobs when ~ARM label is used - - - - - 7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00 hadrian: Don't attempt to install documentation if doc/ doesn't exist Previously we would attempt to install documentation even if the `doc` directory doesn't exist (e.g. due to `--docs=none`). This would result in the surprising side-effect of the entire contents of the bindist being installed in the destination documentation directory. Fix this. Fixes #21976. - - - - - 67575f20 by normalcoder at 2022-08-10T15:38:34-04:00 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - - - - - 45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00 Note [Trimming auto-rules]: State that this improves compiler perf. - - - - - 5c24b1b3 by Andrew Lelechenko at 2022-08-10T22:41:50-04:00 Document that threadDelay / timeout are susceptible to overflows on 32-bit machines - - - - - ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule - - - - - dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00 Revert "gitlab-ci: Add release job for aarch64/debian 11" This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46. The job was not tested before being merged and fails CI (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392) Ticket #22005 - - - - - ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00 typo - - - - - cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00 CmmToLlvm: Don't aliasify builtin LLVM variables Our aliasification logic would previously turn builtin LLVM variables into aliases, which apparently confuses LLVM. This manifested in initializers failing to be emitted, resulting in many profiling failures with the LLVM backend. Fixes #22019. - - - - - dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00 run_ci: remove monoidal-containers Fixes #21492 MonoidalMap is inlined and used to implement Variables, as before. The top-level value "jobs" is reimplemented as a regular Map, since it doesn't use the monoidal union anyway. - - - - - 64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00 CmmToAsm/AArch64: correct a typo - - - - - f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00 Fix #21979 - compact-share failing with -O I don't have good reason to believe the optimization level should affect if sharing works or not here. So limit the test to the normal way. - - - - - 68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix reference to dead llvm-version substitution Fixes #22052. - - - - - 28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix incorrect reference to `:extension: role - - - - - 71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Add :ghc-flag: reference - - - - - 385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00 hadrian: Place manpage in docroot This relocates it from docs/ to doc/ - - - - - 84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00 Bump haddock submodule Includes merge of `main` into `ghc-head` as well as some Haddock users guide fixes. - - - - - 59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00 base: Add changelog entries from ghc-9.2 Closes #21922. - - - - - a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00 relnotes: Add "included libraries" section As noted in #21988, some users rely on this. - - - - - a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Rephrase the rewrite rule documentation Previously the wording was a tad unclear. Fix this. Closes #21114. - - - - - 3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00 Implement Response File support for HPC This is an improvement to HPC authored by Richard Wallace (https://github.com/purefn) and myself. I have received permission from him to attempt to upstream it. This improvement was originally implemented as a patch to HPC via input-output-hk/haskell.nix: https://github.com/input-output-hk/haskell.nix/pull/1464 Paraphrasing Richard, HPC currently requires all inputs as command line arguments. With large projects this can result in an argument list too long error. I have only seen this error in Nix, but I assume it can occur is a plain Unix environment. This MR adds the standard response file syntax support to HPC. For example you can now pass a file to the command line which contains the arguments. ``` hpc @response_file_1 @response_file_2 ... The contents of a Response File must have this format: COMMAND ... example: report my_library.tix --include=ModuleA --include=ModuleB ``` Updates hpc submodule Co-authored-by: Richard Wallace <rwallace at thewallacepack.net> Fixes #22050 - - - - - 436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00 ghc-heap: Fix decoding of TSO closures An extra field was added to the TSO structure in 6d1700b6 but the decoding logic in ghc-heap was not updated for this new field. Fixes #22046 - - - - - a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00 driver: Honour -x option The -x option is used to manually specify which phase a file should be started to be compiled from (even if it lacks the correct extension). I just failed to implement this when refactoring the driver. In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to preprocess source files using GHC. I added a test to exercise this case. Fixes #22044 - - - - - e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00 Be more careful in chooseInferredQuantifiers This fixes #22065. We were failing to retain a quantifier that was mentioned in the kind of another retained quantifier. Easy to fix. - - - - - 714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00 testsuite: Add test for #21583 - - - - - 989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00 compiler: Drop --build-id=none hack Since 2011 the object-joining implementation has had a hack to pass `--build-id=none` to `ld` when supported, seemingly to work around a linker bug. This hack is now unnecessary and may break downstream users who expect objects to have valid build-ids. Remove it. Closes #22060. - - - - - 519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00 Make ru_fn field strict to avoid retaining Ids It's better to perform this projection from Id to Name strictly so we don't retain an old Id (hence IdInfo, hence Unfolding, hence everything etc) - - - - - 7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force `getOccFS bndr` to avoid retaining reference to Bndr. This is another symptom of #19619 - - - - - 4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force unfoldings when they are cleaned-up in Tidy and CorePrep If these thunks are not forced then the entire unfolding for the binding is live throughout the whole of CodeGen despite the fact it should have been discarded. Fixes #22071 - - - - - 2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00 haddock docs: Fix links from identifiers to dependent packages When implementing the base_url changes I made the pretty bad mistake of zipping together two lists which were in different orders. The simpler thing to do is just modify `haddockDependencies` to also return the package identifier so that everything stays in sync. Fixes #22001 - - - - - 9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00 Revert "Refactor SpecConstr to use treat bindings uniformly" This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729. This refactoring introduced quite a severe residency regression (900MB live from 650MB live when compiling mmark), see #21993 for a reproducer and more discussion. Ticket #21993 - - - - - 9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00 tc: warn about lazy annotations on unlifted arguments (fixes #21951) - - - - - e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00 Fix #22048 where we failed to drop rules for -fomit-interface-pragmas. Now we also filter the local rules (again) which fixes the issue. - - - - - 51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00 Print constraints in quotes (#21167) This patch improves the uniformity of error message formatting by printing constraints in quotes, as we do for types. Fix #21167 - - - - - ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00 19217 Implicitly quantify type variables in :kind command - - - - - 9939e95f by MorrowM at 2022-08-21T16:51:38-04:00 Recognize file-header pragmas in GHCi (#21507) - - - - - fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00 hadrian: Fix bootstrapping with ghc-9.4 The error was that we were trying to link together containers from boot package library (which depends template-haskell in boot package library) template-haskell from in-tree package database So the fix is to build containers in stage0 (and link against template-haskell built in stage0). Fixes #21981 - - - - - b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00 Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942. * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence * `ParensT` constructor is now always printed parenthesized * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down * using `>=` instead of former `>` to match the Core type printing logic * some test outputs have changed, losing extraneous parentheses - - - - - fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00 Fix and test for issue #21723 - - - - - 33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00 Test for issue #21942 - - - - - c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00 Updated the changelog - - - - - 80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00 hadrian: Don't duplicate binaries on installation Previously we used `install` on symbolic links, which ended up copying the target file rather than installing a symbolic link. Fixes #22062. - - - - - b929063e by Matthew Farkas-Dyck at 2022-08-24T02:37:01-04:00 Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Closes #22092. - - - - - 112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00 driver: don't actually merge objects when ar -L works - - - - - a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00 rts: Consistently use MiB in stats output Previously we would say `MB` even where we meant `MiB`. - - - - - a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223 - - - - - 909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00 upload_ghc_libs: Add means of passing Hackage credentials - - - - - 28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00 Scrub some partiality in `CommonBlockElim`. - - - - - 54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00 hadrian: Fix whitespace Previously this region of Settings.Packages was incorrectly indented. - - - - - c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00 validate: Drop --legacy flag In preparation for removal of the legacy `make`-based build system. - - - - - 822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00 gitlab-ci: Drop make build validation jobs In preparation for removal of the `make`-based build system - - - - - 6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop make build system Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html - - - - - dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00 Remove testsuite/tests/perf/haddock/.gitignore As noted in #16802, this is no longer needed. Closes #16802. - - - - - fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop hc-build script This has not worked for many, many years and relied on the now-removed `make`-based build system. - - - - - 659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mkdirhier This is only used by nofib's dead `dist` target - - - - - 4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mk/{build,install,config}.mk.in - - - - - 46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00 compiler: Drop comment references to make - - - - - d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add inits1 and tails1 to Data.List.NonEmpty See https://github.com/haskell/core-libraries-committee/issues/67 - - - - - 8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add since annotations and changelog entries - - - - - 6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00 Fix redundant import This fixes a build error on x86_64-linux-alpine3_12-validate. See the function 'loadExternalPlugins' defined in this file. - - - - - 4786acf7 by sheaf at 2022-08-26T15:05:23-04:00 Pmc: consider any 2 dicts of the same type equal This patch massages the keys used in the `TmOracle` `CoreMap` to ensure that dictionaries of coherent classes give the same key. That is, whenever we have an expression we want to insert or lookup in the `TmOracle` `CoreMap`, we first replace any dictionary `$dict_abcd :: ct` with a value of the form `error @ct`. This allows us to common-up view pattern functions with required constraints whose arguments differed only in the uniques of the dictionaries they were provided, thus fixing #21662. This is a rather ad-hoc change to the keys used in the `TmOracle` `CoreMap`. In the long run, we would probably want to use a different representation for the keys instead of simply using `CoreExpr` as-is. This more ambitious plan is outlined in #19272. Fixes #21662 Updates unix submodule - - - - - f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00 Remove label style from printing context Previously, the SDocContext used for code generation contained information whether the labels should use Asm or C style. However, at every individual call site, this is known statically. This removes the parameter to 'PprCode' and replaces every 'pdoc' used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'. The OutputableP instance is now used only for dumps. The output of T15155 changes, it now uses the Asm style (which is faithful to what actually happens). - - - - - 1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00 boot: cleanup legacy args Cleanup legacy boot script args, following removal of the legacy make build system. - - - - - 95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00 Improve SpecConstr for evals As #21763 showed, we were over-specialising in some cases, when the function involved was doing a simple 'eval', but not taking the value apart, or branching on it. This MR fixes the problem. See Note [Do not specialise evals]. Nofib barely budges, except that spectral/cichelli allocates about 3% less. Compiler bytes-allocated improves a bit geo. mean -0.1% minimum -0.5% maximum +0.0% The -0.5% is on T11303b, for what it's worth. - - - - - 565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Revert "Revert "Refactor SpecConstr to use treat bindings uniformly"" This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8. This commit was originally reverted due to an increase in space usage. This was diagnosed as because the SCE increased in size and that was being retained by another leak. See #22102 - - - - - 82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Avoid retaining bindings via ModGuts held on the stack It's better to overwrite the bindings fields of the ModGuts before starting an iteration as then all the old bindings can be collected as soon as the simplifier has processed them. Otherwise we end up with the old bindings being alive until right at the end of the simplifier pass as the mg_binds field is only modified right at the end. - - - - - 64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00 Force imposs_deflt_cons in filterAlts This fixes a pretty serious space leak as the forced thunk would retain `Alt b` values which would then contain reference to a lot of old bindings and other simplifier gunk. The OtherCon unfolding was not forced on subsequent simplifier runs so more and more old stuff would be retained until the end of simplification. Fixing this has a drastic effect on maximum residency for the mmark package which goes from ``` 45,005,401,056 bytes allocated in the heap 17,227,721,856 bytes copied during GC 818,281,720 bytes maximum residency (33 sample(s)) 9,659,144 bytes maximum slop 2245 MiB total memory in use (0 MB lost due to fragmentation) ``` to ``` 45,039,453,304 bytes allocated in the heap 13,128,181,400 bytes copied during GC 331,546,608 bytes maximum residency (40 sample(s)) 7,471,120 bytes maximum slop 916 MiB total memory in use (0 MB lost due to fragmentation) ``` See #21993 for some more discussion. - - - - - a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Use Solo to avoid retaining the SCE but to avoid performing the substitution The use of Solo here allows us to force the selection into the SCE to obtain the Subst but without forcing the substitution to be applied. The resulting thunk is placed into a lazy field which is rarely forced, so forcing it regresses peformance. - - - - - 161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00 Fix a nasty loop in Tidy As the remarkably-simple #22112 showed, we were making a black hole in the unfolding of a self-recursive binding. Boo! It's a bit tricky. Documented in GHC.Iface.Tidy, Note [tidyTopUnfolding: avoiding black holes] - - - - - 68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnIllegalHsigDefaultMethods TcRnBadGenericMethod TcRnWarningMinimalDefIncomplete TcRnDefaultMethodForPragmaLacksBinding TcRnIgnoreSpecialisePragmaOnDefMethod TcRnBadMethodErr TcRnNoExplicitAssocTypeOrDefaultDeclaration - - - - - cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00 Fix a bug in anyInRnEnvR This bug was a subtle error in anyInRnEnvR, introduced by commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06 Author: Andreas Klebinger <klebinger.andreas at gmx.at> Date: Sat Jul 9 01:19:52 2022 +0200 Rule matching: Don't compute the FVs if we don't look at them. The net result was #22028, where a rewrite rule would wrongly match on a lambda. The fix to that function is easy. - - - - - 0154bc80 by sheaf at 2022-08-30T06:05:41-04:00 Various Hadrian bootstrapping fixes - Don't always produce a distribution archive (#21629) - Use correct executable names for ghc-pkg and hsc2hs on windows (we were missing the .exe file extension) - Fix a bug where we weren't using the right archive format on Windows when unpacking the bootstrap sources. Fixes #21629 - - - - - 451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00 ci: Attempt using normal submodule cloning strategy We do not use any recursively cloned submodules, and this protects us from flaky upstream remotes. Fixes #22121 - - - - - 9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: stray "--" - - - - - 3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: syntatic -> syntactic - - - - - 7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00 Add a missing trimArityType This buglet was exposed by #22114, a consequence of my earlier refactoring of arity for join points. - - - - - e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump binary submodule to 0.8.9.1 - - - - - 4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump stm submodule to 2.5.1.0 - - - - - 837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00 users-guide: Document system-cxx-std-lib - - - - - f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00 Update submodule containers to 0.6.6 - - - - - 4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00 Update submodule process to 1.6.15.0 - - - - - 1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00 Bump directory submodule to 1.3.7.1 - - - - - 7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00 Bump text submodule to 2.0.1 - - - - - fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00 Bump deepseq submodule to 1.4.8.0 - - - - - a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00 Add dates to base, ghc-prim changelogs - - - - - 2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00 Update autoconf scripts Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983 - - - - - e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00 Bump bytestring submodule to 0.11.3.1 - - - - - f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00 Update submodule Cabal to tag Cabal-v3.8.1.0 closes #21931 - - - - - e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00 Refine in-tree compiler args for --test-compiler=stage1 Some of the logic to calculate in-tree arguments was not correct for the stage1 compiler. Namely we were not correctly reporting whether we were building static or dynamic executables and whether debug assertions were enabled. Fixes #22096 - - - - - 6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00 Make ghcDebugAssertions into a Stage predicate (Stage -> Bool) We also care whether we have debug assertions enabled for a stage one compiler, but the way which we turned on the assertions was quite different from the stage2 compiler. This makes the logic for turning on consistent across both and has the advantage of being able to correct determine in in-tree args whether a flavour enables assertions or not. Ticket #22096 - - - - - 15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00 Add regression test for #21550 This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5 "Use local instances with least superclass depth" - - - - - 7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00 Minor cleanup - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused), isCoVar_maybe (duplicated by getCoVar_maybe) - Replace a few occurrences of voidPrimId with (# #). void# is a deprecated synonym for the unboxed tuple. - Use showSDoc in :show linker. This makes it consistent with the other :show commands - - - - - 31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00 Fix bootstrap with ghc-9.0 It turns out Solo is a very recent addition to base, so for older GHC versions we just defined it inline here the one place we use it in the compiler. - - - - - d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00 DmdAnal: Don't panic in addCaseBndrDmd (#22039) Rather conservatively return Top. See Note [Untyped demand on case-alternative binders]. I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and `fieldBndrDmds`. Fixes #22039. - - - - - 25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00 gitlab-ci: Ensure that ghc derivation is in scope Previously the lint-ci job attempted to use cabal-install (specifically `cabal update`) without a GHC in PATH. However, cabal-install-3.8 appears to want GHC, even for `cabal update`. - - - - - f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00 typo - - - - - fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00 typos - - - - - a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00 whitespace - - - - - 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Andrew Lelechenko at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by Matthew Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Andrew Lelechenko at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Andrew Lelechenko at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Andrew Lelechenko at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Andrew Lelechenko at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Andrew Lelechenko at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Andrew Lelechenko at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Andrew Lelechenko at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergő Érdi at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Andrew Lelechenko at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by Matthew Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Andrew Lelechenko at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Andrew Lelechenko at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Andrew Lelechenko at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Andrew Lelechenko at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Andrew Lelechenko at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Andrew Lelechenko at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Andrew Lelechenko at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Andrew Lelechenko at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 75855643 by Ben Gamari at 2022-12-15T03:54:02-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - da7b51d8 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm: Introduce blockConcat - - - - - 34f6b09c by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm: Introduce MemoryOrderings - - - - - 43beaa7b by Ben Gamari at 2022-12-15T03:54:02-05:00 llvm: Respect memory specified orderings - - - - - 8faf74fc by Ben Gamari at 2022-12-15T03:54:02-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 6cc3944a by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Reduce some repetition - - - - - 6c9862c4 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 748490d2 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 28c6781a by Ben Gamari at 2022-12-15T03:54:02-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - d97aa311 by Ben Gamari at 2022-12-15T03:54:02-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 86974ef1 by Ben Gamari at 2022-12-15T03:54:02-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 93723290 by Ben Gamari at 2022-12-15T03:54:02-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-05:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 - - - - - 552b7908 by Ben Gamari at 2022-12-15T03:55:15-05:00 compiler: Ensure that MutVar operations have necessary barriers Here we add acquire and release barriers in readMutVar# and writeMutVar#, which are necessary for soundness. Fixes #22468. - - - - - 933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-05:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - 03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/ThreadPaused: Ordering fixes - - - - - 914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00 eventlog: Silence spurious data race - - - - - fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Use fences instead of explicit barriers - - - - - 2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 70999283 by Ben Gamari at 2022-12-16T16:12:44-05:00 rts: Introduce getNumCapabilities And ensure accesses to n_capabilities are atomic (although with relaxed ordering). This is necessary as RTS API callers may concurrently call into the RTS without holding a capability. - - - - - 98689f77 by Ben Gamari at 2022-12-16T16:12:44-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - 605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 86f20258 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts/Timer: Always use atomic operations As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded. - - - - - f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate access to capabilities array - - - - - 7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Encapsulate sched_state - - - - - 1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Style fix - - - - - 82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00 compiler: Use release store in eager blackholing - - - - - eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Fix ordering of makeStableName - - - - - ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00 rts: Note race with wakeBlockingQueue - - - - - 5acf33dd by Andrew Lelechenko at 2022-12-16T16:13:22-05:00 Bump submodule directory to 1.3.8.0 and hpc to HEAD - - - - - 0dd95421 by Andrew Lelechenko at 2022-12-16T16:13:22-05:00 Accept allocations increase on Windows This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips between lists and ByteArray. See #22625 for discussion. Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T10547 T12150 T12227 T12234 T12425 T13035 T13253 T13253-spj T13701 T13719 T15703 T16875 T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T21839r T5837 T6048 T9198 T9961 TcPlugin_RewritePerf hard_hole_fits - - - - - ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00 testsuite: Mark T9405 as fragile instead of broken on Windows It's starting to pass again, and the unexpected pass blocks CI. - - - - - 1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: remove obsolete commented code in wasm NCG It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged. - - - - - e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm Also removes some unreachable code here. - - - - - 1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: change fallback function signature to Cmm function signature in wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions. - - - - - 8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00 compiler: add optional tail-call support in wasm NCG When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461. - - - - - d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00 base: add missing autoconf checks for waitpid/umask These are not present in wasi-libc. Required for fixing #22589 - - - - - da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00 compiler: make .wasm the default executable extension on wasm32 Following convention as in other wasm toolchains. Fixes #22594. - - - - - ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00 ci: support hello.wasm in ci.sh cross testing logic - - - - - 6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00 Correct `exitWith` Haddocks The `IOError`-specific `catch` in the Prelude is long gone. - - - - - b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - 761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00 rts/libdw: Silence uninitialized usage warnings As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538 - - - - - 5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00 testsuite: Mark T16392 as fragile on windows See #22649 - - - - - 703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00 Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`. - - - - - 9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05:00 packaging: Fix upload_ghc_libs.py script This change reflects the changes where .cabal files are now generated by hadrian rather than ./configure. Fixes #22518 - - - - - 7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Drop uses of AC_PROG_CC_C99 As noted in #22566, this macro is deprecated as of autoconf-2.70 `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself. Closes #22566. - - - - - 36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00 configure: Use AS_HELP_STRING instead of AC_HELP_STRING The latter has been deprecated. See #22566. - - - - - befe6ff8 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00 GHCi.UI: fix various usages of head and tail - - - - - 666d0ba7 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00 GHCi.UI: avoid head and tail in parseCallEscape and around - - - - - 5d96fd50 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00 Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty - - - - - 3ce2ab94 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00 Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian - - - - - 954de93a by Andrew Lelechenko at 2022-12-21T06:17:56-05:00 Update submodule haskeline to HEAD (to allow transformers-0.6) - - - - - cefbeec3 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00 Update submodule transformers to 0.6.0.4 - - - - - b4730b62 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00 Fix tests T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations Metric Increase: T13253 - - - - - 0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05:00 Abstract over the right free vars Fix #22459, in two ways: (1) Make the Specialiser not create a bogus specialisation if it is presented by strangely polymorphic dictionary. See Note [Weird special case in SpecDict] in GHC.Core.Opt.Specialise (2) Be more careful in abstractFloats See Note [Which type variables to abstract over] in GHC.Core.Opt.Simplify.Utils. So (2) stops creating the excessively polymorphic dictionary in abstractFloats, while (1) stops crashing if some other pass should nevertheless create a weirdly polymorphic dictionary. - - - - - df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00 rts: explicitly store return value of ccall checkClosure to prevent type error (#22617) - - - - - e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix shadowing lacuna in OccurAnal Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix. - - - - - 3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00 Fix an assertion check in addToEqualCtList The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 - - - - - ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00 configure: Bump version to 9.6 - - - - - fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00 base: Bump version to 4.18 Requires various submodule bumps. - - - - - 93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00 ghc-boot: Fix bootstrapping - - - - - fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05:00 Don't consider large byte arrays/compact regions pinned. Workaround for #22255 which showed how treating large/compact regions as pinned could cause segfaults. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Eliminate race in bump_static_flag To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix races in collector status tracking Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make bitmap accesses atomic This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix benign race in update remembered set check Relaxed load is fine here since we will take the lock before looking at the list. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in shortcutting We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-05:00 compiler: Ensure that GHC toolchain is first in search path As noted in #22561, it is important that GHC's toolchain look first for its own headers and libraries to ensure that the system's are not found instead. If this happens things can break in surprising ways (e.g. see #22561). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Andrew Lelechenko at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+00:00 Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Involves adding many new NFData instances. Without forcing Docs, references to the TcGblEnv for each module are retained by the Docs structure. Usually these are forced when the ModIface is serialised but not when we aren't writing the interface. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00:00 compiler: Add -f[no-]split-sections flags Here we add a `-fsplit-sections` flag which may some day replace `-split-sections`. This has the advantage of automatically providing a `-fno-split-sections` flag, which is useful for our packaging because we enable `-split-sections` by default but want to disable it in certain configurations. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add no_split_sections tranformer This transformer reverts the effect of `split_sections`, which we intend to use for platforms which don't support split sections. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+00:00 ci: Build all test dependencies with in-tree compiler This means that these executables will honour flavour transformers such as "werror". Fixes #22555 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+00:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 6e6adbe3 by Jade Lovelace at 2023-01-11T00:55:30-05:00 Fix tcPluginRewrite example - - - - - faa57138 by Jade Lovelace at 2023-01-11T00:55:31-05:00 fix missing haddock pipe - - - - - 0470ea7c by Florian Weimer at 2023-01-11T00:56:10-05:00 m4/fp_leading_underscore.m4: Avoid implicit exit function declaration And switch to a new-style function definition. Fixes build issues with compilers that do not accept implicit function declarations. - - - - - b2857df4 by HaskellMouse at 2023-01-11T00:56:52-05:00 Added a new warning about compatibility with RequiredTypeArguments This commit introduces a new warning that indicates code incompatible with future extension: RequiredTypeArguments. Enabling this extension may break some code and the warning will help to make it compatible in advance. - - - - - 5f17e21a by Ben Gamari at 2023-01-11T00:57:27-05:00 testsuite: Drop testheapalloced.c As noted in #22414, this file (which appears to be a benchmark for characterising the one-step allocator's MBlock cache) is currently unreferenced. Remove it. Closes #22414. - - - - - bc125775 by Vladislav Zavialov at 2023-01-11T00:58:03-05:00 Introduce the TypeAbstractions language flag GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 083f7015 by Krzysztof Gogolewski at 2023-01-11T00:58:38-05:00 Misc cleanup - Remove unused mkWildEvBinder - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - aed1974e by Richard Eisenberg at 2023-01-11T08:30:42+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666 and #19690 The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. * Treat the head of a Wanted quantified constraint in the same way as the superclass of an instance decl; this is what fixes #19690. See GHC.Tc.Solver.Canonical Note [Solving a Wanted forall-constraint] (Thanks to Matthew Craven for this insight.) This entailed refactoring the GivenSc constructor of CtOrigin a bit, to say whether it comes from an instance decl or quantified constraint. * Some refactoring way in which redundant constraints are reported; we don't want to complain about the extra, apparently-redundant constraints that we must add to an instance decl because of the loopy-superclass thing. I moved some work from GHC.Tc.Errors to GHC.Tc.Solver. * Add a new section to the user manual to describe the loopy superclass issue and what rules it follows. - - - - - 300bcc15 by HaskellMouse at 2023-01-11T13:43:36-05:00 Parse qualified terms in type signatures This commit allows qualified terms in type signatures to pass the parser and to be cathced by renamer with more informative error message. Adds a few tests. Fixes #21605 - - - - - 964284fc by Simon Peyton Jones at 2023-01-11T13:44:12-05:00 Fix void-arg-adding mechanism for worker/wrapper As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo. - - - - - f7ceafc9 by Krzysztof Gogolewski at 2023-01-11T22:36:59-05:00 Add 'docWithStyle' to improve codegen This new combinator docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc let us remove the need for code to be polymorphic in HDoc when not used in code style. Metric Decrease: ManyConstructors T13035 T1969 - - - - - b3be0d18 by Simon Peyton Jones at 2023-01-11T22:37:35-05:00 Fix finaliseArgBoxities for OPAQUE function We never do worker wrapper for OPAQUE functions, so we must zap the unboxing info during strictness analysis. This patch fixes #22502 - - - - - db11f358 by Ben Gamari at 2023-01-12T07:49:04-05:00 Revert "rts: Drop racy assertion" The logic here was inverted. Reverting the commit to avoid confusion when examining the commit history. This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1. - - - - - 3242139f by Ben Gamari at 2023-01-12T07:49:04-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - 9ffd5d57 by Ben Gamari at 2023-01-12T07:49:41-05:00 configure: Fix escaping of `$tooldir` In !9547 I introduced `$tooldir` directories into GHC's default link and compilation flags to ensure that our C toolchain finds its own headers and libraries before others on the system. However, the patch was subtly wrong in the escaping of `$tooldir`. Fix this. Fixes #22561. - - - - - 905d0b6e by Sebastian Graf at 2023-01-12T15:51:47-05:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. The refactoring seems to have quite beneficial effect on ghc/alloc performance: ``` CoOpt_Read(normal) ghc/alloc 784,778,420 768,091,176 -2.1% GOOD T12150(optasm) ghc/alloc 77,762,270 75,986,720 -2.3% GOOD T12425(optasm) ghc/alloc 85,740,186 84,641,712 -1.3% GOOD T13056(optasm) ghc/alloc 306,104,656 299,811,632 -2.1% GOOD T13253(normal) ghc/alloc 350,233,952 346,004,008 -1.2% T14683(normal) ghc/alloc 2,800,514,792 2,754,651,360 -1.6% T15304(normal) ghc/alloc 1,230,883,318 1,215,978,336 -1.2% T15630(normal) ghc/alloc 153,379,590 151,796,488 -1.0% T16577(normal) ghc/alloc 7,356,797,056 7,244,194,416 -1.5% T17516(normal) ghc/alloc 1,718,941,448 1,692,157,288 -1.6% T19695(normal) ghc/alloc 1,485,794,632 1,458,022,112 -1.9% T21839c(normal) ghc/alloc 437,562,314 431,295,896 -1.4% GOOD T21839r(normal) ghc/alloc 446,927,580 440,615,776 -1.4% GOOD geo. mean -0.6% minimum -2.4% maximum -0.0% ``` Metric Decrease: CoOpt_Read T10421 T12150 T12425 T13056 T18698a T18698b T21839c T21839r T9961 - - - - - a1491c87 by Andreas Klebinger at 2023-01-12T15:52:23-05:00 Only gc sparks locally when we can ensure marking is done. When performing GC without work stealing there was no guarantee that spark pruning was happening after marking of the sparks. This could cause us to GC live sparks under certain circumstances. Fixes #22528. - - - - - 8acfe930 by Cheng Shao at 2023-01-12T15:53:00-05:00 Change MSYSTEM to CLANG64 uniformly - - - - - 73bc162b by M Farkas-Dyck at 2023-01-12T15:53:42-05:00 Make `GHC.Tc.Errors.Reporter` take `NonEmpty ErrorItem` rather than `[ErrorItem]`, which lets us drop some panics. Also use the `BasicMismatch` constructor rather than `mkBasicMismatchMsg`, which lets us drop the "-Wno-incomplete-record-updates" flag. - - - - - 1b812b69 by Oleg Grenrus at 2023-01-12T15:54:21-05:00 Fix #22728: Not all diagnostics in safe check are fatal Also add tests for the issue and -Winferred-safe-imports in general - - - - - c79b2b65 by Matthew Pickering at 2023-01-12T15:54:58-05:00 Don't run hadrian-multi on fast-ci label Fixes #22667 - - - - - 9a3d6add by Andrew Lelechenko at 2023-01-13T00:46:36-05:00 Bump submodule bytestring to 0.11.4.0 Metric Decrease: T21839c T21839r - - - - - df33c13c by Ben Gamari at 2023-01-13T00:47:12-05:00 gitlab-ci: Bump Darwin bootstrap toolchain This updates the bootstrap compiler on Darwin from 8.10.7 to 9.2.5, ensuring that we have the fix for #21964. - - - - - 756a66ec by Ben Gamari at 2023-01-13T00:47:12-05:00 gitlab-ci: Pass -w to cabal update Due to cabal#8447, cabal-install 3.8.1.0 requires a compiler to run `cabal update`. - - - - - 1142f858 by Cheng Shao at 2023-01-13T11:04:00+00:00 Bump hsc2hs submodule - - - - - d4686729 by Cheng Shao at 2023-01-13T11:04:00+00:00 Bump process submodule - - - - - 84ae6573 by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: Bump DOCKER_REV - - - - - d53598c5 by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: enable xz parallel compression for x64 jobs - - - - - d31fcbca by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: use in-image emsdk for js jobs - - - - - 93b9bbc1 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: improve nix-shell for gen_ci.hs and fix some ghc/hlint warnings - Add a ghc environment including prebuilt dependencies to the nix-shell. Get rid of the ad hoc cabal cache and all dependencies are now downloaded from the nixos binary cache. - Make gen_ci.hs a cabal package with HLS integration, to make future hacking of gen_ci.hs easier. - Fix some ghc/hlint warnings after I got HLS to work. - For the lint-ci-config job, do a shallow clone to save a few minutes of unnecessary git checkout time. - - - - - 8acc56c7 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: source the toolchain env file in wasm jobs - - - - - 87194df0 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: add wasm ci jobs via gen_ci.hs - There is one regular wasm job run in validate pipelines - Additionally, int-native/unreg wasm jobs run in nightly/release pipelines Also, remove the legacy handwritten wasm ci jobs in .gitlab-ci.yml. - - - - - b6eb9bcc by Matthew Pickering at 2023-01-13T11:52:16+00:00 wasm ci: Remove wasm release jobs This removes the wasm release jobs, as we do not yet intend to distribute these binaries. - - - - - 496607fd by Simon Peyton Jones at 2023-01-13T16:52:07-05:00 Add a missing checkEscapingKind Ticket #22743 pointed out that there is a missing check, for type-inferred bindings, that the inferred type doesn't have an escaping kind. The fix is easy. - - - - - 7a9a1042 by Andreas Klebinger at 2023-01-16T20:48:19-05:00 Separate core inlining logic from `Unfolding` type. This seems like a good idea either way, but is mostly motivated by a patch where this avoids a module loop. - - - - - 33b58f77 by sheaf at 2023-01-16T20:48:57-05:00 Hadrian: generalise &%> to avoid warnings This patch introduces a more general version of &%> that works with general traversable shapes, instead of lists. This allows us to pass along the information that the length of the list of filepaths passed to the function exactly matches the length of the input list of filepath patterns, avoiding pattern match warnings. Fixes #22430 - - - - - 8c7a991c by Andreas Klebinger at 2023-01-16T20:49:34-05:00 Add regression test for #22611. A case were a function used to fail to specialize, but now does. - - - - - 6abea760 by Andreas Klebinger at 2023-01-16T20:50:10-05:00 Mark maximumBy/minimumBy as INLINE. The RHS was too large to inline which often prevented the overhead of the Maybe from being optimized away. By marking it as INLINE we can eliminate the overhead of both the maybe and are able to unpack the accumulator when possible. Fixes #22609 - - - - - 99d151bb by Matthew Pickering at 2023-01-16T20:50:50-05:00 ci: Bump CACHE_REV so that ghc-9.6 branch and HEAD have different caches Having the same CACHE_REV on both branches leads to issues where the darwin toolchain is different on ghc-9.6 and HEAD which leads to long darwin build times. In general we should ensure that each branch has a different CACHE_REV. - - - - - 6a5845fb by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Change owner of files in source-tarball job This fixes errors of the form: ``` fatal: detected dubious ownership in repository at '/builds/ghc/ghc' To add an exception for this directory, call: git config --global --add safe.directory /builds/ghc/ghc inferred 9.7.20230113 checking for GHC Git commit id... fatal: detected dubious ownership in repository at '/builds/ghc/ghc' To add an exception for this directory, call: git config --global --add safe.directory /builds/ghc/ghc ``` - - - - - 4afb952c by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Don't build aarch64-deb10-llvm job on release pipelines Closes #22721 - - - - - 8039feb9 by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Change owner of files in test-bootstrap job - - - - - 0b358d0c by Matthew Pickering at 2023-01-16T20:51:25-05:00 rel_eng: Add release engineering scripts into ghc tree It is better to keep these scripts in the tree as they depend on the CI configuration and so on. By keeping them in tree we can keep them up-to-date as the CI config changes and also makes it easier to backport changes to the release script between release branches in future. The final motivation is that it makes generating GHCUp metadata possible. - - - - - 28cb2ed0 by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Don't use complicated image or clone in not-interruptible job This job exists only for the meta-reason of not allowing nightly pipelines to be cancelled. It was taking two minutes to run as in order to run "true" we would also clone the whole GHC repo. - - - - - eeea59bb by Matthew Pickering at 2023-01-16T20:51:26-05:00 Add scripts to generate ghcup metadata on nightly and release pipelines 1. A python script in .gitlab/rel_eng/mk-ghcup-metadata which generates suitable metadata for consumption by GHCUp for the relevant pipelines. - The script generates the metadata just as the ghcup maintainers want, without taking into account platform/library combinations. It is updated manually when the mapping changes. - The script downloads the bindists which ghcup wants to distribute, calculates the hash and generates the yaml in the correct structure. - The script is documented in the .gitlab/rel_eng/mk-ghcup-metadata/README.mk file 1a. The script requires us to understand the mapping from platform -> job. To choose the preferred bindist for each platform the .gitlab/gen_ci.hs script is modified to allow outputting a metadata file which answers the question about which job produces the bindist which we want to distribute to users for a specific platform. 2. Pipelines to run on nightly and release jobs to generate metadata - ghcup-metadata-nightly: Generates metadata which points directly to artifacts in the nightly job. - ghcup-metadata-release: Generates metadata suitable for inclusion directly in ghcup by pointing to the downloads folder where the bindist will be uploaded to. 2a. Trigger jobs which test the generated metadata in the downstream `ghccup-ci` repo. See that repo for documentation about what is tested and how but essentially we test in a variety of clean images that ghcup can download and install the bindists we say exist in our metadata. - - - - - 97bd4d8c by Andrew Lelechenko at 2023-01-16T20:52:04-05:00 Bump submodule parsec to 3.1.16.1 - - - - - 97ac8230 by Alan Zimmerman at 2023-01-16T20:52:39-05:00 EPA: Add annotation for 'type' in DataDecl Closes #22765 - - - - - dbbab95d by Ben Gamari at 2023-01-17T06:36:06-05:00 compiler: Small optimisation of assertM In #22739 @AndreasK noticed that assertM performed the action to compute the asserted predicate regardless of whether DEBUG is enabled. This is inconsistent with the other assertion operations and general convention. Fix this. Closes #22739. - - - - - fc02f3bb by Viktor Dukhovni at 2023-01-17T06:36:47-05:00 Avoid unnecessary printf warnings in EventLog.c Fixes #22778 - - - - - 003b6d44 by Simon Peyton Jones at 2023-01-17T16:33:05-05:00 Document the semantics of pattern bindings a bit better This MR is in response to the discussion on #22719 - - - - - f4d50baf by Vladislav Zavialov at 2023-01-17T16:33:41-05:00 Hadrian: fix warnings (#22783) This change fixes the following warnings when building Hadrian: src/Hadrian/Expression.hs:38:10: warning: [-Wredundant-constraints] src/Hadrian/Expression.hs:84:13: warning: [-Wtype-equality-requires-operators] src/Hadrian/Expression.hs:84:21: warning: [-Wtype-equality-requires-operators] src/Hadrian/Haskell/Cabal/Parse.hs:67:1: warning: [-Wunused-imports] - - - - - 06036d93 by Sylvain Henry at 2023-01-18T01:55:10-05:00 testsuite: req_smp --> req_target_smp, req_ghc_smp See #22630 and !9552 This commit: - splits req_smp into req_target_smp and req_ghc_smp - changes the testsuite driver to calculate req_ghc_smp - changes a handful of tests to use req_target_smp instead of req_smp - changes a handful of tests to use req_host_smp when needed The problem: - the problem this solves is the ambiguity surrounding req_smp - on master req_smp was used to express the constraint that the program being compiled supports smp _and_ that the host RTS (i.e., the RTS used to compile the program) supported smp. Normally that is fine, but in cross compilation this is not always the case as was discovered in #22630. The solution: - Differentiate the two constraints: - use req_target_smp to say the RTS the compiled program is linked with (and the platform) supports smp - use req_host_smp to say the RTS the host is linked with supports smp WIP: fix req_smp (target vs ghc) add flag to separate bootstrapper split req_smp -> req_target_smp and req_ghc_smp update tests smp flags cleanup and add some docstrings only set ghc_with_smp to bootstrapper on S1 or CC Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1 and cross compiling test the RTS in config/ghc not hadrian re-add ghc_with_smp fix and align req names fix T11760 to use req_host_smp test the rts directly, avoid python 3.5 limitation test the compiler in a try block align out of tree and in tree withSMP flags mark failing tests as host req smp testsuite: req_host_smp --> req_ghc_smp Fix ghc vs host, fix ghc_with_smp leftover - - - - - ee9b78aa by Krzysztof Gogolewski at 2023-01-18T01:55:45-05:00 Use -Wdefault when running Python testdriver (#22727) - - - - - e9c0537c by Vladislav Zavialov at 2023-01-18T01:56:22-05:00 Enable -Wstar-is-type by default (#22759) Following the plan in GHC Proposal #143 "Remove the * kind syntax", which states: In the next release (or 3 years in), enable -fwarn-star-is-type by default. The "next release" happens to be 9.6.1 I also moved the T21583 test case from should_fail to should_compile, because the only reason it was failing was -Werror=compat in our test suite configuration. - - - - - 4efee43d by Ryan Scott at 2023-01-18T01:56:59-05:00 Add missing parenthesizeHsType in cvtSigTypeKind We need to ensure that the output of `cvtSigTypeKind` is parenthesized (at precedence `sigPrec`) so that any type signatures with an outermost, explicit kind signature can parse correctly. Fixes #22784. - - - - - f891a442 by Ben Gamari at 2023-01-18T07:28:00-05:00 Bump ghc-tarballs to fix #22497 It turns out that gmp 6.2.1 uses the platform-reserved `x18` register on AArch64/Darwin. This was fixed in upstream changeset 18164:5f32dbc41afc, which was merged in 2020. Here I backport this patch although I do hope that a new release is forthcoming soon. Bumps gmp-tarballs submodule. Fixes #22497. - - - - - b13c6ea5 by Ben Gamari at 2023-01-18T07:28:00-05:00 Bump gmp-tarballs submodule This backports the upstream fix for CVE-2021-43618, fixing #22789. - - - - - c45a5fff by Cheng Shao at 2023-01-18T07:28:37-05:00 Fix typo in recent darwin tests fix Corrects a typo in !9647. Otherwise T18623 will still fail on darwin and stall other people's work. - - - - - b4c14c4b by Luite Stegeman at 2023-01-18T14:21:42-05:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - d0a63ef8 by Adam Gundry at 2023-01-18T14:22:26-05:00 Refactor warning flag parsing to add missing flags This adds `-Werror=<group>` and `-fwarn-<group>` flags for warning groups as well as individual warnings. Previously these were defined on an ad hoc basis so for example we had `-Werror=compat` but not `-Werror=unused-binds`, whereas we had `-fwarn-unused-binds` but not `-fwarn-compat`. Fixes #22182. - - - - - 7ed1b8ef by Adam Gundry at 2023-01-18T14:22:26-05:00 Minor corrections to comments - - - - - 5389681e by Adam Gundry at 2023-01-18T14:22:26-05:00 Revise warnings documentation in user's guide - - - - - ab0d5cda by Adam Gundry at 2023-01-18T14:22:26-05:00 Move documentation of deferred type error flags out of warnings section - - - - - eb5a6b91 by John Ericson at 2023-01-18T22:24:10-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - 32ab07bf by Andrew Lelechenko at 2023-01-18T22:24:51-05:00 ghc package does not have to depend on terminfo - - - - - 981ff7c4 by Andrew Lelechenko at 2023-01-18T22:24:51-05:00 ghc-pkg does not have to depend on terminfo - - - - - f058e367 by Ben Gamari at 2023-01-18T22:25:27-05:00 nativeGen/X86: MFENCE is unnecessary for release semantics In #22764 a user noticed that a program implementing a simple atomic counter via an STRef regressed significantly due to the introduction of necessary atomic operations in the MutVar# primops (#22468). This regression was caused by a bug in the NCG, which emitted an unnecessary MFENCE instruction for a release-ordered atomic write. MFENCE is rather only needed to achieve sequentially consistent ordering. Fixes #22764. - - - - - 154889db by Ryan Scott at 2023-01-18T22:26:03-05:00 Add regression test for #22151 Issue #22151 was coincidentally fixed in commit aed1974e92366ab8e117734f308505684f70cddf (`Refactor the treatment of loopy superclass dicts`). This adds a regression test to ensure that the issue remains fixed. Fixes #22151. - - - - - 14b5982a by Andrei Borzenkov at 2023-01-18T22:26:43-05:00 Fix printing of promoted MkSolo datacon (#22785) Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo, and Solo was turned into a pattern synonym for backwards compatibility. Since pattern synonyms can not be promoted, the old code that pretty-printed promoted single-element tuples started producing ill-typed code: t :: Proxy ('Solo Int) This fails with "Pattern synonym ‘Solo’ used as a type" The solution is to track the distinction between type constructors and data constructors more carefully when printing single-element tuples. - - - - - 1fe806d3 by Cheng Shao at 2023-01-23T04:48:47-05:00 hadrian: add hi_core flavour transformer The hi_core flavour transformer enables -fwrite-if-simplified-core for stage1 libraries, which emit core into interface files to make it possible to restart code generation. Building boot libs with it makes it easier to use GHC API to prototype experimental backends that needs core/stg at link time. - - - - - 317cad26 by Cheng Shao at 2023-01-23T04:48:47-05:00 hadrian: add missing docs for recently added flavour transformers - - - - - 658f4446 by Ben Gamari at 2023-01-23T04:49:23-05:00 gitlab-ci: Add Rocky8 jobs Addresses #22268. - - - - - a83ec778 by Vladislav Zavialov at 2023-01-23T04:49:58-05:00 Set "since: 9.8" for TypeAbstractions and -Wterm-variable-capture These flags did not make it into the 9.6 release series, so the "since" annotations must be corrected. - - - - - fec7c2ea by Alan Zimmerman at 2023-01-23T04:50:33-05:00 EPA: Add SourceText to HsOverLabel To be able to capture string literals with possible escape codes as labels. Close #22771 - - - - - 3efd1e99 by Ben Gamari at 2023-01-23T04:51:08-05:00 template-haskell: Bump version to 2.20.0.0 Updates `text` and `exceptions` submodules for bounds bumps. Addresses #22767. - - - - - 0900b584 by Cheng Shao at 2023-01-23T04:51:45-05:00 hadrian: disable alloca for in-tree GMP on wasm32 When building in-tree GMP for wasm32, disable its alloca usage, since it may potentially cause stack overflow (e.g. #22602). - - - - - db0f1bfd by Cheng Shao at 2023-01-23T04:52:21-05:00 Bump process submodule Includes a critical fix for wasm32, see https://github.com/haskell/process/pull/272 for details. Also changes the existing cross test to include process stuff and avoid future regression here. - - - - - 9222b167 by Matthew Pickering at 2023-01-23T04:52:57-05:00 ghcup metadata: Fix subdir for windows bindist - - - - - 9a9bec57 by Matthew Pickering at 2023-01-23T04:52:57-05:00 ghcup metadata: Remove viPostRemove field from generated metadata This has been removed from the downstream metadata. - - - - - 82884ce0 by Simon Peyton Jones at 2023-01-23T04:53:32-05:00 Fix #22742 runtimeRepLevity_maybe was panicing unnecessarily; and the error printing code made use of the case when it should return Nothing rather than panicing. For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime peak-megagbytes-used, on a single architecture (alpine). See !9753 for commentary, but I'm going to accept it. Metric Increase: T21839r - - - - - 2c6deb18 by Bryan Richter at 2023-01-23T14:12:22+02:00 codeowners: Add Ben, Matt, and Bryan to CI - - - - - eee3bf05 by Matthew Craven at 2023-01-23T21:46:41-05:00 Do not collect compile-time metrics for T21839r ...the testsuite doesn't handle this properly since it also collects run-time metrics. Compile-time metrics for this test are already tracked via T21839c. Metric Decrease: T21839r - - - - - 1d1dd3fb by Matthew Pickering at 2023-01-24T05:37:52-05:00 Fix recompilation checking for multiple home units The key part of this change is to store a UnitId in the `UsageHomeModule` and `UsageHomeModuleInterface`. * Fine-grained dependency tracking is used if the dependency comes from any home unit. * We actually look up the right module when checking whether we need to recompile in the `UsageHomeModuleInterface` case. These scenarios are both checked by the new tests ( multipleHomeUnits_recomp and multipleHomeUnits_recomp_th ) Fixes #22675 - - - - - 7bfb30f9 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Augment target filepath by working directory when checking if module satisfies target This fixes a spurious warning in -Wmissing-home-modules. This is a simple oversight where when looking for the target in the first place we augment the search by the -working-directory flag but then fail to do so when checking this warning. Fixes #22676 - - - - - 69500dd4 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Use NodeKey rather than ModuleName in pruneCache The `pruneCache` function assumes that the list of `CachedInfo` all have unique `ModuleName`, this is not true: * In normal compilation, the same module name can appear for a file and it's boot file. * In multiple home unit compilation the same ModuleName can appear in different units The fix is to use a `NodeKey` as the actual key for the interfaces which includes `ModuleName`, `IsBoot` and `UnitId`. Fixes #22677 - - - - - 336b2b1c by Matthew Pickering at 2023-01-24T05:37:52-05:00 Recompilation checking: Don't try to find artefacts for Interactive & hs-boot combo In interactive mode we don't produce any linkables for hs-boot files. So we also need to not going looking for them when we check to see if we have all the right objects needed for recompilation. Ticket #22669 - - - - - 6469fea7 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Don't write o-boot files in Interactive mode We should not be producing object files when in interactive mode but we still produced the dummy o-boot files. These never made it into a `Linkable` but then confused the recompilation checker. Fixes #22669 - - - - - 06cc0a95 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Improve driver diagnostic messages by including UnitId in message Currently the driver diagnostics don't give any indication about which unit they correspond to. For example `-Wmissing-home-modules` can fire multiple times for each different home unit and gives no indication about which unit it's actually reporting about. Perhaps a longer term fix is to generalise the providence information away from a SrcSpan so that these kind of whole project errors can be reported with an accurate provenance. For now we can just include the `UnitId` in the error message. Fixes #22678 - - - - - 4fe9eaff by Matthew Pickering at 2023-01-24T05:37:52-05:00 Key ModSummary cache by UnitId as well as FilePath Multiple units can refer to the same files without any problem. Just another assumption which needs to be updated when we may have multiple home units. However, there is the invariant that within each unit each file only maps to one module, so as long as we also key the cache by UnitId then we are all good. This led to some confusing behaviour in GHCi when reloading, multipleHomeUnits_shared distils the essence of what can go wrong. Fixes #22679 - - - - - ada29f5c by Matthew Pickering at 2023-01-24T05:37:52-05:00 Finder: Look in current unit before looking in any home package dependencies In order to preserve existing behaviour it's important to look within the current component before consideirng a module might come from an external component. This already happened by accident in `downsweep`, (because roots are used to repopulated the cache) but in the `Finder` the logic was the wrong way around. Fixes #22680 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp -------------------------p - - - - - be701cc6 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Debug: Print full NodeKey when pretty printing ModuleGraphNode This is helpful when debugging multiple component issues. - - - - - 34d2d463 by Krzysztof Gogolewski at 2023-01-24T05:38:32-05:00 Fix Lint check for duplicate external names Lint was checking for duplicate external names by calling removeDups, which needs a comparison function that is passed to Data.List.sortBy. But the comparison was not a valid ordering - it returned LT if one of the names was not external. For example, the previous implementation won't find a duplicate in [M.x, y, M.x]. Instead, we filter out non-external names before looking for duplicates. - - - - - 1c050ed2 by Matthew Pickering at 2023-01-24T05:39:08-05:00 Add test for T22671 This was fixed by b13c6ea5 Closes #22671 - - - - - 05e6a2d9 by Tom Ellis at 2023-01-24T12:10:52-05:00 Clarify where `f` is defined - - - - - d151546e by Cheng Shao at 2023-01-24T12:11:29-05:00 CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target We used to print the offset value to a platform word sized integer. This is incorrect when the offset is negative (e.g. output of cmm constant folding) and the register is 64-bit but on a 32-bit target, and may lead to incorrect runtime result (e.g. #22607). The fix is simple: just treat it as a proper MO_Add, with the correct width info inferred from the register itself. Metric Increase: T12707 T13379 T4801 T5321FD T5321Fun - - - - - e5383a29 by Wander Hillen at 2023-01-24T20:02:26-05:00 Allow waiting for timerfd to be interrupted during rts shutdown - - - - - 1957eda1 by Ryan Scott at 2023-01-24T20:03:01-05:00 Restore Compose's Read/Show behavior to match Read1/Show1 instances Fixes #22816. - - - - - 30972827 by Matthew Pickering at 2023-01-25T03:54:14-05:00 docs: Update INSTALL.md Removes references to make. Fixes #22480 - - - - - bc038c3b by Cheng Shao at 2023-01-25T03:54:50-05:00 compiler: fix handling of MO_F_Neg in wasm NCG In the wasm NCG, we used to compile MO_F_Neg to 0.0-x. It was an oversight, there actually exists f32.neg/f64.neg opcodes in the wasm spec and those should be used instead! The old behavior almost works, expect when GHC compiles the -0.0 literal, which will incorrectly become 0.0. - - - - - e987e345 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Hadrian: correctly detect AR at-file support Stage0's ar may not support at-files. Take it into account. Found while cross-compiling from Darwin to Windows. - - - - - 48131ee2 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Hadrian: fix Windows cross-compilation Decision to build either unix or Win32 package must be stage specific for cross-compilation to be supported. - - - - - 288fa017 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Fix RTS build on Windows This change fixes a cross-compilation issue from ArchLinux to Windows because these symbols weren't found. - - - - - 2fdf22ae by Sylvain Henry at 2023-01-25T14:47:41-05:00 configure: support "windows" as an OS - - - - - 13a0566b by Simon Peyton Jones at 2023-01-25T14:48:16-05:00 Fix in-scope set in specImports Nothing deep here; I had failed to bring some floated dictionary binders into scope. Exposed by -fspecialise-aggressively Fixes #22715. - - - - - b7efdb24 by Matthew Pickering at 2023-01-25T14:48:51-05:00 ci: Disable HLint job due to excessive runtime The HLint jobs takes much longer to run (20 minutes) after "Give the RTS it's own configure script" eb5a6b91 Now the CI job will build the stage0 compiler before it generates the necessary RTS headers. We either need to: * Fix the linting rules so they take much less time * Revert the commit * Remove the linting of base from the hlint job * Remove the hlint job This is highest priority as it is affecting all CI pipelines. For now I am just disabling the job because there are many more pressing matters at hand. Ticket #22830 - - - - - 1bd32a35 by Sylvain Henry at 2023-01-26T12:34:21-05:00 Factorize hptModulesBelow Create and use moduleGraphModulesBelow in GHC.Unit.Module.Graph that doesn't need anything from the driver to be used. - - - - - 1262d3f8 by Matthew Pickering at 2023-01-26T12:34:56-05:00 Store dehydrated data structures in CgModBreaks This fixes a tricky leak in GHCi where we were retaining old copies of HscEnvs when reloading. If not all modules were recompiled then these hydrated fields in break points would retain a reference to the old HscEnv which could double memory usage. Fixes #22530 - - - - - e27eb80c by Matthew Pickering at 2023-01-26T12:34:56-05:00 Force more in NFData Name instance Doesn't force the lazy `OccName` field (#19619) which is already known as a really bad source of leaks. When we slam the hammer storing Names on disk (in interface files or the like), all this should be forced as otherwise a `Name` can easily retain an `Id` and hence the entire world. Fixes #22833 - - - - - 3d004d5a by Matthew Pickering at 2023-01-26T12:34:56-05:00 Force OccName in tidyTopName This occname has just been derived from an `Id`, so need to force it promptly so we can release the Id back to the world. Another symptom of the bug caused by #19619 - - - - - f2a0fea0 by Matthew Pickering at 2023-01-26T12:34:56-05:00 Strict fields in ModNodeKey (otherwise retains HomeModInfo) Towards #22530 - - - - - 5640cb1d by Sylvain Henry at 2023-01-26T12:35:36-05:00 Hadrian: fix doc generation Was missing dependencies on files generated by templates (e.g. ghc.cabal) - - - - - 3e827c3f by Richard Eisenberg at 2023-01-26T20:06:53-05:00 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. Close #22519. - - - - - b3ef5c89 by doyougnu at 2023-01-26T20:07:48-05:00 tryFillBuffer: strictify more speculative bangs - - - - - d0d7ba0f by Vladislav Zavialov at 2023-01-26T20:08:25-05:00 base: NoImplicitPrelude in Data.Void and Data.Kind This change removes an unnecessary dependency on Prelude from two modules in the base package. - - - - - fa1db923 by Matthew Pickering at 2023-01-26T20:09:00-05:00 ci: Add ubuntu18_04 nightly and release jobs This adds release jobs for ubuntu18_04 which uses glibc 2.27 which is older than the 2.28 which is used by Rocky8 bindists. Ticket #22268 - - - - - 807310a1 by Matthew Pickering at 2023-01-26T20:09:00-05:00 rel-eng: Add missing rocky8 bindist We intend to release rocky8 bindist so the fetching script needs to know about them. - - - - - c7116b10 by Ben Gamari at 2023-01-26T20:09:35-05:00 base: Make changelog proposal references more consistent Addresses #22773. - - - - - 6932cfc7 by Sylvain Henry at 2023-01-26T20:10:27-05:00 Fix spurious change from !9568 - - - - - e480fbc2 by Ben Gamari at 2023-01-27T05:01:24-05:00 rts: Use C11-compliant static assertion syntax Previously we used `static_assert` which is only available in C23. By contrast, C11 only provides `_Static_assert`. Fixes #22777 - - - - - 2648c09c by Andrei Borzenkov at 2023-01-27T05:02:07-05:00 Replace errors from badOrigBinding with new one (#22839) Problem: in 02279a9c the type-level [] syntax was changed from a built-in name to an alias for the GHC.Types.List constructor. badOrigBinding assumes that if a name is not built-in then it must have come from TH quotation, but this is not necessarily the case with []. The outdated assumption in badOrigBinding leads to incorrect error messages. This code: data [] Fails with "Cannot redefine a Name retrieved by a Template Haskell quote: []" Unfortunately, there is not enough information in RdrName to directly determine if the name was constructed via TH or by the parser, so this patch changes the error message instead. It unifies TcRnIllegalBindingOfBuiltIn and TcRnNameByTemplateHaskellQuote into a new error TcRnBindingOfExistingName and changes its wording to avoid guessing the origin of the name. - - - - - 545bf8cf by Matthew Pickering at 2023-01-27T14:58:53+00:00 Revert "base: NoImplicitPrelude in Data.Void and Data.Kind" Fixes CI errors of the form. ``` ===> Command failed with error code: 1 ghc: panic! (the 'impossible' happened) GHC version 9.7.20230127: lookupGlobal Failed to load interface for ‘GHC.Num.BigNat’ There are files missing in the ‘ghc-bignum’ package, try running 'ghc-pkg check'. Use -v (or `:set -v` in ghci) to see a list of the files searched for. Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic pprPanic, called at compiler/GHC/Tc/Utils/Env.hs:154:32 in ghc:GHC.Tc.Utils.Env CallStack (from HasCallStack): panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` This reverts commit d0d7ba0fb053ebe7f919a5932066fbc776301ccd. The module now lacks a dependency on GHC.Num.BigNat which it implicitly depends on. It is causing all CI jobs to fail so we revert without haste whilst the patch can be fixed. Fixes #22848 - - - - - 638277ba by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Detect family instance orphans correctly We were treating a type-family instance as a non-orphan if there was a type constructor on its /right-hand side/ that was local. Boo! Utterly wrong. With this patch, we correctly check the /left-hand side/ instead! Fixes #22717 - - - - - 46a53bb2 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Report family instance orphans correctly This fixes the fact that we were not reporting orphan family instances at all. The fix here is easy, but touches a bit of code. I refactored the code to be much more similar to the way that class instances are done: - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst - Make newFamInst initialise this field, just like newClsInst - And make newFamInst report a warning for an orphan, just like newClsInst - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate, just like newClsInst. - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv - TcRnOrphanInstance and SuggestFixOrphanInstance are now parametrised over class instances vs type/data family instances. Fixes #19773 - - - - - faa300fb by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Avoid orphans in STG This patch removes some orphan instances in the STG namespace by introducing the GHC.Stg.Lift.Types module, which allows various type family instances to be moved to GHC.Stg.Syntax, avoiding orphan instances. - - - - - 0f25a13b by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Avoid orphans in the parser This moves Anno instances for PatBuilder from GHC.Parser.PostProcess to GHC.Parser.Types to avoid orphans. - - - - - 15750d33 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Accept an orphan declaration (sadly) This accepts the orphan type family instance type instance DsForeignHook = ... in GHC.HsToCore.Types. See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks - - - - - c9967d13 by Zubin Duggal at 2023-01-27T23:55:31-05:00 bindist configure: Fail if find not found (#22691) - - - - - ad8cfed4 by John Ericson at 2023-01-27T23:56:06-05:00 Put hadrian bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. - - - - - d0ddc01b by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Introduce threaded2_sanity way Incredibly, we previously did not have a single way which would test the threaded RTS with multiple capabilities and the sanity-checker enabled. - - - - - 38ad8351 by Ben Gamari at 2023-01-27T23:56:42-05:00 rts: Relax Messages assertion `doneWithMsgThrowTo` was previously too strict in asserting that the `Message` is locked. Specifically, it failed to consider that the `Message` may not be locked if we are deleting all threads during RTS shutdown. - - - - - a9fe81af by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Fix race in UnliftedTVar2 Previously UnliftedTVar2 would fail when run with multiple capabilities (and possibly even with one capability) as it would assume that `killThread#` would immediately kill the "increment" thread. Also, refactor the the executable to now succeed with no output and fails with an exit code. - - - - - 8519af60 by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Make listThreads more robust Previously it was sensitive to the labels of threads which it did not create (e.g. the IO manager event loop threads). Fix this. - - - - - 55a81995 by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix non-atomic mutation of enabled_capabilities - - - - - b5c75f1d by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix C++ compilation issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - c261b62f by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix typo "tracingAddCapabilities" was mis-named - - - - - 77fdbd3f by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Drop long-dead fallback definitions for INFINITY & NAN These are no longer necessary since we now compile as C99. - - - - - 56c1bd98 by Ben Gamari at 2023-01-28T02:57:59-05:00 Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)" This reverts commit 99aca26b652603bc62953157a48e419f737d352d. - - - - - b3a3534b by nineonine at 2023-01-28T02:57:59-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043. - - - - - 082b7d43 by Oleg Grenrus at 2023-01-28T02:58:38-05:00 Add Foldable1 Solo instance - - - - - 50b1e2e8 by Andrei Borzenkov at 2023-01-28T02:59:18-05:00 Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115) I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind module. Instead, these TcRnMessage messages were introduced: TcRnMultipleFixityDecls TcRnIllegalPatternSynonymDecl TcRnIllegalClassBiding TcRnOrphanCompletePragma TcRnEmptyCase TcRnNonStdGuards TcRnDuplicateSigDecl TcRnMisplacedSigDecl TcRnUnexpectedDefaultSig TcRnBindInBootFile TcRnDuplicateMinimalSig - - - - - 3330b819 by Matthew Pickering at 2023-01-28T02:59:54-05:00 hadrian: Fix library-dirs, dynamic-library-dirs and static-library-dirs in inplace .conf files Previously we were just throwing away the contents of the library-dirs fields but really we have to do the same thing as for include-dirs, relativise the paths into the current working directory and maintain any extra libraries the user has specified. Now the relevant section of the rts.conf file looks like: ``` library-dirs: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib library-dirs-static: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib dynamic-library-dirs: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib ``` Fixes #22209 - - - - - c9ad8852 by Andrew Lelechenko at 2023-01-28T03:00:33-05:00 Document differences between Data.{Monoid,Semigroup}.{First,Last} - - - - - 7e11c6dc by Cheng Shao at 2023-01-28T03:01:09-05:00 compiler: fix subword literal narrowing logic in the wasm NCG This patch fixes the W8/W16 literal narrowing logic in the wasm NCG, which used to lower it to something like i32.const -1, without properly zeroing-out the unused higher bits. Fixes #22608. - - - - - 6ea2aa02 by Cheng Shao at 2023-01-28T03:01:46-05:00 compiler: fix lowering of CmmBlock in the wasm NCG The CmmBlock datacon was not handled in lower_CmmLit, since I thought it would have been eliminated after proc-point splitting. Turns out it still occurs in very rare occasions, and this patch is needed to fix T9329 for wasm. - - - - - 2b62739d by Andrew Lelechenko at 2023-01-28T17:16:11-05:00 Assorted changes to avoid Data.List.{head,tail} - - - - - 78c07219 by Cheng Shao at 2023-01-28T17:16:48-05:00 compiler: properly handle ForeignHints in the wasm NCG Properly handle ForeignHints of ccall arguments/return value, insert sign extends and truncations when handling signed subwords. Fixes #22852. - - - - - 8bed166b by Ben Gamari at 2023-01-30T05:06:26-05:00 nativeGen: Disable asm-shortcutting on Darwin Asm-shortcutting may produce relative references to symbols defined in other compilation units. This is not something that MachO relocations support (see #21972). For this reason we disable the optimisation on Darwin. We do so without a warning since this flag is enabled by `-O2`. Another way to address this issue would be to rather implement a PLT-relocatable jump-table strategy. However, this would only benefit Darwin and does not seem worth the effort. Closes #21972. - - - - - da468391 by Cheng Shao at 2023-01-30T05:07:03-05:00 compiler: fix data section alignment in the wasm NCG Previously we tried to lower the alignment requirement as far as possible, based on the section kind inferred from the CLabel. For info tables, .p2align 1 was applied given the GC should only need the lowest bit to tag forwarding pointers. But this would lead to unaligned loads/stores, which has a performance penalty even if the wasm spec permits it. Furthermore, the test suite has shown memory corruption in a few cases when compacting gc is used. This patch takes a more conservative approach: all data sections except C strings align to word size. - - - - - 08ba8720 by Andreas Klebinger at 2023-01-30T21:18:45-05:00 ghc-the-library: Retain cafs in both static in dynamic builds. We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a __attribute__((constructor)) function. This broke for static builds where the linker discarded the object file since it was not reverenced from any exported code. We fix this by asserting that the flag is enabled using a function in the same module as the constructor. Which causes the object file to be retained by the linker, which in turn causes the constructor the be run in static builds. This changes nothing for dynamic builds using the ghc library. But causes static to also retain CAFs (as we expect them to). Fixes #22417. ------------------------- Metric Decrease: T21839r ------------------------- - - - - - 20598ef6 by Ryan Scott at 2023-01-30T21:19:20-05:00 Handle `type data` properly in tyThingParent_maybe Unlike most other data constructors, data constructors declared with `type data` are represented in `TyThing`s as `ATyCon` rather than `ADataCon`. The `ATyCon` case in `tyThingParent_maybe` previously did not consider the possibility of the underlying `TyCon` being a promoted data constructor, which led to the oddities observed in #22817. This patch adds a dedicated special case in `tyThingParent_maybe`'s `ATyCon` case for `type data` data constructors to fix these oddities. Fixes #22817. - - - - - 2f145052 by Ryan Scott at 2023-01-30T21:19:56-05:00 Fix two bugs in TypeData TH reification This patch fixes two issues in the way that `type data` declarations were reified with Template Haskell: * `type data` data constructors are now properly reified using `DataConI`. This is accomplished with a special case in `reifyTyCon`. Fixes #22818. * `type data` type constructors are now reified in `reifyTyCon` using `TypeDataD` instead of `DataD`. Fixes #22819. - - - - - d0f34f25 by Simon Peyton Jones at 2023-01-30T21:20:35-05:00 Take account of loop breakers in specLookupRule The key change is that in GHC.Core.Opt.Specialise.specLookupRule we were using realIdUnfolding, which ignores the loop-breaker flag. When given a loop breaker, rule matching therefore looped infinitely -- #22802. In fixing this I refactored a bit. * Define GHC.Core.InScopeEnv as a data type, and use it. (Previously it was a pair: hard to grep for.) * Put several functions returning an IdUnfoldingFun into GHC.Types.Id, namely idUnfolding alwaysActiveUnfoldingFun, whenActiveUnfoldingFun, noUnfoldingFun and use them. (The are all loop-breaker aware.) - - - - - de963cb6 by Matthew Pickering at 2023-01-30T21:21:11-05:00 ci: Remove FreeBSD job from release pipelines We no longer attempt to build or distribute this release - - - - - f26d27ec by Matthew Pickering at 2023-01-30T21:21:11-05:00 rel_eng: Add check to make sure that release jobs are downloaded by fetch-gitlab This check makes sure that if a job is a prefixed by "release-" then the script downloads it and understands how to map the job name to the platform. - - - - - 7619c0b4 by Matthew Pickering at 2023-01-30T21:21:11-05:00 rel_eng: Fix the name of the ubuntu-* jobs These were not uploaded for alpha1 Fixes #22844 - - - - - 68eb8877 by Matthew Pickering at 2023-01-30T21:21:11-05:00 gen_ci: Only consider release jobs for job metadata In particular we do not have a release job for FreeBSD so the generation of the platform mapping was failing. - - - - - b69461a0 by Jason Shipman at 2023-01-30T21:21:50-05:00 User's guide: Clarify overlapping instance candidate elimination This commit updates the user's guide section on overlapping instance candidate elimination to use "or" verbiage instead of "either/or" in regards to the current pair of candidates' being overlappable or overlapping. "Either IX is overlappable, or IY is overlapping" can cause confusion as it suggests "Either IX is overlappable, or IY is overlapping, but not both". This was initially discussed on this Discourse topic: https://discourse.haskell.org/t/clarification-on-overlapping-instance-candidate-elimination/5677 - - - - - 7cbdaad0 by Matthew Pickering at 2023-01-31T07:53:53-05:00 Fixes for cabal-reinstall CI job * Allow filepath to be reinstalled * Bump some version bounds to allow newer versions of libraries * Rework testing logic to avoid "install --lib" and package env files Fixes #22344 - - - - - fd8f32bf by Cheng Shao at 2023-01-31T07:54:29-05:00 rts: prevent potential divide-by-zero when tickInterval=0 This patch fixes a few places in RtsFlags.c that may result in divide-by-zero error when tickInterval=0, which is the default on wasm. Fixes #22603. - - - - - 085a6db6 by Joachim Breitner at 2023-01-31T07:55:05-05:00 Update note at beginning of GHC.Builtin.NAmes some things have been renamed since it was written, it seems. - - - - - 7716cbe6 by Cheng Shao at 2023-01-31T07:55:41-05:00 testsuite: use tgamma for cg007 gamma is a glibc-only deprecated function, use tgamma instead. It's required for fixing cg007 when testing the wasm unregisterised codegen. - - - - - 19c1fbcd by doyougnu at 2023-01-31T13:08:03-05:00 InfoTableProv: ShortText --> ShortByteString - - - - - 765fab98 by doyougnu at 2023-01-31T13:08:03-05:00 FastString: add fastStringToShorText - - - - - a83c810d by Simon Peyton Jones at 2023-01-31T13:08:38-05:00 Improve exprOkForSpeculation for classops This patch fixes #22745 and #15205, which are about GHC's failure to discard unnecessary superclass selections that yield coercions. See GHC.Core.Utils Note [exprOkForSpeculation and type classes] The main changes are: * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and refer to it * Define new function isTerminatingType, to identify those guaranteed-terminating dictionary types. * exprOkForSpeculation has a new (very simple) case for ClassOpId * ClassOpId has a new field that says if the return type is an unlifted type, or a terminating type. This was surprisingly tricky to get right. In particular note that unlifted types are not terminating types; you can write an expression of unlifted type, that diverges. Not so for dictionaries (or, more precisely, for the dictionaries that GHC constructs). Metric Decrease: LargeRecord - - - - - f83374f8 by Krzysztof Gogolewski at 2023-01-31T13:09:14-05:00 Support "unusable UNPACK pragma" warning with -O0 Fixes #11270 - - - - - a2d814dc by Ben Gamari at 2023-01-31T13:09:50-05:00 configure: Always create the VERSION file Teach the `configure` script to create the `VERSION` file. This will serve as the stable interface to allow the user to determine the version number of a working tree. Fixes #22322. - - - - - 5618fc21 by sheaf at 2023-01-31T15:51:06-05:00 Cmm: track the type of global registers This patch tracks the type of Cmm global registers. This is needed in order to lint uses of polymorphic registers, such as SIMD vector registers that can be used both for floating-point and integer values. This changes allows us to refactor VanillaReg to not store VGcPtr, as that information is instead stored in the type of the usage of the register. Fixes #22297 - - - - - 78b99430 by sheaf at 2023-01-31T15:51:06-05:00 Revert "Cmm Lint: relax SIMD register assignment check" This reverts commit 3be48877, which weakened a Cmm Lint check involving SIMD vectors. Now that we keep track of the type a global register is used at, we can restore the original stronger check. - - - - - be417a47 by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen/AArch64: Fix debugging output Previously various panics would rely on a half-written Show instance, leading to very unhelpful errors. Fix this. See #22798. - - - - - 30989d13 by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen: Teach graph-colouring allocator that x18 is unusable Previously trivColourable for AArch64 claimed that at 18 registers were trivially-colourable. This is incorrect as x18 is reserved by the platform on AArch64/Darwin. See #22798. - - - - - 7566fd9d by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen/AArch64: Fix graph-colouring allocator Previously various `Instr` queries used by the graph-colouring allocator failed to handle a few pseudo-instructions. This manifested in compiler panicks while compiling `SHA`, which uses `-fregs-graph`. Fixes #22798. - - - - - 2cb500a5 by Ben Gamari at 2023-01-31T15:51:45-05:00 testsuite: Add regression test for #22798 - - - - - 03d693b2 by Ben Gamari at 2023-01-31T15:52:32-05:00 Revert "Hadrian: fix doc generation" This is too large of a hammer. This reverts commit 5640cb1d84d3cce4ce0a9e90d29b2b20d2b38c2f. - - - - - f838815c by Ben Gamari at 2023-01-31T15:52:32-05:00 hadrian: Sphinx docs require templated cabal files The package-version discovery logic in `doc/users_guide/package_versions.py` uses packages' cabal files to determine package versions. Teach Sphinx about these dependencies in cases where the cabal files are generated by templates. - - - - - 2e48c19a by Ben Gamari at 2023-01-31T15:52:32-05:00 hadrian: Refactor templating logic This refactors Hadrian's autoconf-style templating logic to be explicit about which interpolation variables should be substituted in which files. This clears the way to fix #22714 without incurring rule cycles. - - - - - 93f0e3c4 by Ben Gamari at 2023-01-31T15:52:33-05:00 hadrian: Substitute LIBRARY_*_VERSION variables This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables in `libraries/prologue.txt`, fixing #22714. Fixes #22714. - - - - - 22089f69 by Ben Gamari at 2023-01-31T20:46:27-05:00 Bump transformers submodule to 0.6.0.6 Fixes #22862. - - - - - f0eefa3c by Cheng Shao at 2023-01-31T20:47:03-05:00 compiler: properly handle non-word-sized CmmSwitch scrutinees in the wasm NCG Currently, the wasm NCG has an implicit assumption: all CmmSwitch scrutinees are 32-bit integers. This is not always true; #22864 is one counter-example with a 64-bit scrutinee. This patch fixes the logic by explicitly converting the scrutinee to a word that can be used as a br_table operand. Fixes #22871. Also includes a regression test. - - - - - 9f95db54 by Simon Peyton Jones at 2023-02-01T08:55:08+00:00 Improve treatment of type applications in patterns This patch fixes a subtle bug in the typechecking of type applications in patterns, e.g. f (MkT @Int @a x y) = ... See Note [Type applications in patterns] in GHC.Tc.Gen.Pat. This fixes #19847, #22383, #19577, #21501 - - - - - 955a99ea by Simon Peyton Jones at 2023-02-01T12:31:23-05:00 Treat existentials correctly in dubiousDataConInstArgTys Consider (#22849) data T a where MkT :: forall k (t::k->*) (ix::k). t ix -> T @k a Then dubiousDataConInstArgTys MkT [Type, Foo] should return [Foo (ix::Type)] NOT [Foo (ix::k)] A bit of an obscure case, but it's an outright bug, and the fix is easy. - - - - - 0cc16aaf by Matthew Pickering at 2023-02-01T12:31:58-05:00 Bump supported LLVM range from 10 through 15 to 11 through 16 LLVM 15 turns on the new pass manager by default, which we have yet to migrate to so for new we pass the `-enable-new-pm-0` flag in our llvm-passes flag. LLVM 11 was the first version to support the `-enable-new-pm` flag so we bump the lowest supported version to 11. Our CI jobs are using LLVM 12 so they should continue to work despite this bump to the lower bound. Fixes #21936 - - - - - f94f1450 by Matthew Pickering at 2023-02-01T12:31:58-05:00 Bump DOCKER_REV to use alpine image without LLVM installed alpine_3_12 only supports LLVM 10, which is now outside the supported version range. - - - - - 083e26ed by Matthew Pickering at 2023-02-01T17:43:21-05:00 Remove tracing OPTIONS_GHC These were accidentally left over from !9542 - - - - - 354aa47d by Teo Camarasu at 2023-02-01T17:44:00-05:00 doc: fix gcdetails_block_fragmentation_bytes since annotation - - - - - 61ce5bf6 by Jaro Reinders at 2023-02-02T00:15:30-05:00 compiler: Implement higher order patterns in the rule matcher This implements proposal 555 and closes ticket #22465. See the proposal and ticket for motivation. The core changes of this patch are in the GHC.Core.Rules.match function and they are explained in the Note [Matching higher order patterns]. - - - - - 394b91ce by doyougnu at 2023-02-02T00:16:10-05:00 CI: JavaScript backend runs testsuite This MR runs the testsuite for the JS backend. Note that this is a temporary solution until !9515 is merged. Key point: The CI runs hadrian on the built cross compiler _but not_ on the bindist. Other Highlights: - stm submodule gets a bump to mark tests as broken - several tests are marked as broken or are fixed by adding more - conditions to their test runner instance. List of working commit messages: CI: test cross target _and_ emulator CI: JS: Try run testsuite with hadrian JS.CI: cleanup and simplify hadrian invocation use single bracket, print info JS CI: remove call to test_compiler from hadrian don't build haddock JS: mark more tests as broken Tracked in https://gitlab.haskell.org/ghc/ghc/-/issues/22576 JS testsuite: don't skip sum_mod test Its expected to fail, yet we skipped it which automatically makes it succeed leading to an unexpected success, JS testsuite: don't mark T12035j as skip leads to an unexpected pass JS testsuite: remove broken on T14075 leads to unexpected pass JS testsuite: mark more tests as broken JS testsuite: mark T11760 in base as broken JS testsuite: mark ManyUnbSums broken submodules: bump process and hpc for JS tests Both submodules has needed tests skipped or marked broken for th JS backend. This commit now adds these changes to GHC. See: HPC: https://gitlab.haskell.org/hpc/hpc/-/merge_requests/21 Process: https://github.com/haskell/process/pull/268 remove js_broken on now passing tests separate wasm and js backend ci test: T11760: add threaded, non-moving only_ways test: T10296a add req_c T13894: skip for JS backend tests: jspace, T22333: mark as js_broken(22573) test: T22513i mark as req_th stm submodule: mark stm055, T16707 broken for JS tests: js_broken(22374) on unpack_sums_6, T12010 dont run diff on JS CI, cleanup fixup: More CI cleanup fix: align text to master fix: align exceptions submodule to master CI: Bump DOCKER_REV Bump to ci-images commit that has a deb11 build with node. Required for !9552 testsuite: mark T22669 as js_skip See #22669 This test tests that .o-boot files aren't created when run in using the interpreter backend. Thus this is not relevant for the JS backend. testsuite: mark T22671 as broken on JS See #22835 base.testsuite: mark Chan002 fragile for JS see #22836 revert: submodule process bump bump stm submodule New hash includes skips for the JS backend. testsuite: mark RnPatternSynonymFail broken on JS Requires TH: - see !9779 - and #22261 compiler: GHC.hs ifdef import Utils.Panic.Plain - - - - - 1ffe770c by Cheng Shao at 2023-02-02T09:40:38+00:00 docs: 9.6 release notes for wasm backend - - - - - 0ada4547 by Matthew Pickering at 2023-02-02T11:39:44-05:00 Disable unfolding sharing for interface files with core definitions Ticket #22807 pointed out that the RHS sharing was not compatible with -fignore-interface-pragmas because the flag would remove unfoldings from identifiers before the `extra-decls` field was populated. For the 9.6 timescale the only solution is to disable this sharing, which will make interface files bigger but this is acceptable for the first release of `-fwrite-if-simplified-core`. For 9.8 it would be good to fix this by implementing #20056 due to the large number of other bugs that would fix. I also improved the error message in tc_iface_binding to avoid the "no match in record selector" error but it should never happen now as the entire sharing logic is disabled. Also added the currently broken test for #22807 which could be fixed by !6080 Fixes #22807 - - - - - 7e2d3eb5 by lrzlin at 2023-02-03T05:23:27-05:00 Enable tables next to code for LoongArch64 - - - - - 2931712a by Wander Hillen at 2023-02-03T05:24:06-05:00 Move pthread and timerfd ticker implementations to separate files - - - - - 41c4baf8 by Ben Gamari at 2023-02-03T05:24:44-05:00 base: Fix Note references in GHC.IO.Handle.Types - - - - - 31358198 by Andrew Lelechenko at 2023-02-03T05:25:22-05:00 Bump submodule containers to 0.6.7 Metric Decrease: ManyConstructors T10421 T12425 T12707 T13035 T13379 T15164 T1969 T783 T9198 T9961 WWRec - - - - - 8feb9301 by Ben Gamari at 2023-02-03T05:25:59-05:00 gitlab-ci: Eliminate redundant ghc --info output Previously ci.sh would emit the output of `ghc --info` every time it ran when using the nix toolchain. This produced a significant amount of noise. See #22861. - - - - - de1d1512 by Ryan Scott at 2023-02-03T14:07:30-05:00 Windows: Remove mingwex dependency The clang based toolchain uses ucrt as its math library and so mingwex is no longer needed. In fact using mingwex will cause incompatibilities as the default routines in both have differing ULPs and string formatting modifiers. ``` $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe [1 of 2] Compiling Main ( Bug.hs, Bug.o ) ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info' ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above. <no location info>: error: GHC.ByteCode.Linker.lookupCE During interactive linking, GHCi couldn't find the following symbol: templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` - - - - - 48e39195 by Tamar Christina at 2023-02-03T14:07:30-05:00 linker: Fix BFD import libraries This commit fixes the BFD style import library support in the runtime linker. This was accidentally broken during the refactoring to clang and went unnoticed because clang itself is unable to generate the BFD style import libraries. With this change we can not link against both GCC or Clang produced libraries again and intermix code produced by both compilers. - - - - - b2bb3e62 by Ben Gamari at 2023-02-03T14:07:30-05:00 Bump Windows toolchain Updates to LLVM 14, hopefully fixing #21964. - - - - - bf3f88a1 by Andreas Klebinger at 2023-02-03T14:08:07-05:00 Fix CallerCC potentially shadowing other cost centres. Add a CallerCC cost centre flavour for cost centres added by the CallerCC pass. This avoids potential accidental shadowing between CCs added by user annotations and ones added by CallerCC. - - - - - faea4bcd by j at 2023-02-03T14:08:47-05:00 Disable several ignore-warning flags in genapply. - - - - - 25537dfd by Ben Gamari at 2023-02-04T04:12:57-05:00 Revert "Use fix-sized bit-fiddling primops for fixed size boxed types" This reverts commit 4512ad2d6a8e65ea43c86c816411cb13b822f674. This was never applied to master/9.6 originally. (cherry picked from commit a44bdc2720015c03d57f470b759ece7fab29a57a) - - - - - 7612dc71 by Krzysztof Gogolewski at 2023-02-04T04:13:34-05:00 Minor refactor * Introduce refactorDupsOn f = refactorDups (comparing f) * Make mkBigTupleCase and coreCaseTuple monadic. Every call to those functions was preceded by calling newUniqueSupply. * Use mkUserLocalOrCoVar, which is equivalent to combining mkLocalIdOrCoVar with mkInternalName. - - - - - 5a54ac0b by Andrew Lelechenko at 2023-02-04T18:48:32-05:00 Fix colors in emacs terminal - - - - - 3c0f0c6d by Andrew Lelechenko at 2023-02-04T18:49:11-05:00 base changelog: move entries which were not backported to ghc-9.6 to base-4.19 section - - - - - b18fbf52 by Josh Meredith at 2023-02-06T07:47:57+00:00 Update JavaScript fileStat to match Emscripten layout - - - - - 6636b670 by Sylvain Henry at 2023-02-06T09:43:21-05:00 JS: replace "js" architecture with "javascript" Despite Cabal supporting any architecture name, `cabal --check` only supports a few built-in ones. Sadly `cabal --check` is used by Hackage hence using any non built-in name in a package (e.g. `arch(js)`) is rejected and the package is prevented from being uploaded on Hackage. Luckily built-in support for the `javascript` architecture was added for GHCJS a while ago. In order to allow newer `base` to be uploaded on Hackage we make the switch from `js` to `javascript` architecture. Fixes #22740. Co-authored-by: Ben Gamari <ben at smart-cactus.org> - - - - - 77a8234c by Luite Stegeman at 2023-02-06T09:43:59-05:00 Fix marking async exceptions in the JS backend Async exceptions are posted as a pair of the exception and the thread object. This fixes the marking pass to correctly follow the two elements of the pair. Potentially fixes #22836 - - - - - 3e09cf82 by Jan Hrček at 2023-02-06T09:44:38-05:00 Remove extraneous word in Roles user guide - - - - - b17fb3d9 by sheaf at 2023-02-07T10:51:33-05:00 Don't allow . in overloaded labels This patch removes . from the list of allowed characters in a non-quoted overloaded label, as it was realised this steals syntax, e.g. (#.). Users who want this functionality will have to add quotes around the label, e.g. `#"17.28"`. Fixes #22821 - - - - - 5dce04ee by romes at 2023-02-07T10:52:10-05:00 Update kinds in comments in GHC.Core.TyCon Use `Type` instead of star kind (*) Fix comment with incorrect kind * to have kind `Constraint` - - - - - 92916194 by Ben Gamari at 2023-02-07T10:52:48-05:00 Revert "Use fix-sized equality primops for fixed size boxed types" This reverts commit 024020c38126f3ce326ff56906d53525bc71690c. This was never applied to master/9.6 originally. See #20405 for why using these primops is a bad idea. (cherry picked from commit b1d109ad542e4c37ae5af6ace71baf2cb509d865) - - - - - c1670c6b by Sylvain Henry at 2023-02-07T21:25:18-05:00 JS: avoid head/tail and unpackFS - - - - - a9912de7 by Krzysztof Gogolewski at 2023-02-07T21:25:53-05:00 testsuite: Fix Python warnings (#22856) - - - - - 9ee761bf by sheaf at 2023-02-08T14:40:40-05:00 Fix tyvar scoping within class SPECIALISE pragmas Type variables from class/instance headers scope over class/instance method type signatures, but DO NOT scope over the type signatures in SPECIALISE and SPECIALISE instance pragmas. The logic in GHC.Rename.Bind.rnMethodBinds correctly accounted for SPECIALISE inline pragmas, but forgot to apply the same treatment to method SPECIALISE pragmas, which lead to a Core Lint failure with an out-of-scope type variable. This patch makes sure we apply the same logic for both cases. Fixes #22913 - - - - - 7eac2468 by Matthew Pickering at 2023-02-08T14:41:17-05:00 Revert "Don't keep exit join points so much" This reverts commit caced75765472a1a94453f2e5a439dba0d04a265. It seems the patch "Don't keep exit join points so much" is causing wide-spread regressions in the bytestring library benchmarks. If I revert it then the 9.6 numbers are better on average than 9.4. See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T12150 T13386 T13719 T21839c T3294 parsing001 ------------------------- - - - - - 633f2799 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: remove config.use_threads This patch simplifies the testsuite driver by removing the use_threads config field. It's just a degenerate case of threads=1. - - - - - ca6673e3 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: use concurrent.futures.ThreadPoolExecutor in the driver The testsuite driver used to create one thread per test case, and explicitly use semaphore and locks for rate limiting and synchronization. This is a bad practice in any language, and occasionally may result in livelock conditions (e.g. #22889). This patch uses concurrent.futures.ThreadPoolExecutor for scheduling test case runs, which is simpler and more robust. - - - - - f22cce70 by Alan Zimmerman at 2023-02-08T18:42:51-05:00 EPA: Comment between module and where should be in header comments Do not apply the heuristic to associate a comment with a prior declaration for the first declaration in the file. Closes #22919 - - - - - d69ecac2 by Josh Meredith at 2023-02-09T03:24:05-05:00 JS generated refs: update testsuite conditions - - - - - 2ea1a6bc by sheaf at 2023-02-09T03:24:44-05:00 Bump transformers to 0.6.1.0 This allows us to avoid orphans for Foldable1 instances, fixing #22898. Updates transformers submodule. - - - - - d9d0c28d by konsumlamm at 2023-02-09T14:07:48-05:00 Update `Data.List.singleton` doc comment - - - - - fe9cd6ef by Ben Gamari at 2023-02-09T14:08:23-05:00 gitlab-template: Emphasize `user facing` label My sense is that the current mention of the ~"user facing" label is overlooked by many MR authors. Let's move this point up in the list to make it more likely that it is seen. Also rephrase some of the points. - - - - - e45eb828 by Simon Peyton Jones at 2023-02-10T06:51:28-05:00 Refactor the simplifier a bit to fix #22761 The core change in this commit, which fixes #22761, is that * In a Core rule, ru_rhs is always occ-analysed. This means adding a couple of calls to occurAnalyseExpr when building a Rule, in * GHC.Core.Rules.mkRule * GHC.Core.Opt.Simplify.Iteration.simplRules But diagosing the bug made me stare carefully at the code of the Simplifier, and I ended up doing some only-loosely-related refactoring. * I think that RULES could be lost because not every code path did addBndrRules * The code around lambdas was very convoluted It's mainly moving deck chairs around, but I like it more now. - - - - - 11e0cacb by Rebecca Turner at 2023-02-10T06:52:09-05:00 Detect the `mold` linker Enables support for the `mold` linker by rui314. - - - - - 59556235 by parsonsmatt at 2023-02-10T09:53:11-05:00 Add Lift instance for Fixed - - - - - c44e5f30 by Sylvain Henry at 2023-02-10T09:53:51-05:00 Testsuite: decrease length001 timeout for JS (#22921) - - - - - 133516af by Zubin Duggal at 2023-02-10T09:54:27-05:00 compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData` instances This is a minor refactor that makes it easy to add and remove fields from `ModIface_` and `ModIfaceBackend`. Also change the formatting to make it clear exactly which fields are fully forced with `rnf` - - - - - 1e9eac1c by Matthew Pickering at 2023-02-13T11:36:41+01:00 Refresh profiling docs I went through the whole of the profiling docs and tried to amend them to reflect current best practices and tooling. In particular I removed some old references to tools such as hp2any and replaced them with references to eventlog2html. - - - - - da208b9a by Matthew Pickering at 2023-02-13T11:36:41+01:00 docs: Add section about profiling and foreign calls Previously there was no documentation for how foreign calls interacted with the profiler. This can be quite confusing for users so getting it into the user guide is the first step to a potentially better solution. See the ticket for more insightful discussion. Fixes #21764 - - - - - 081640f1 by Andrew Lelechenko at 2023-02-13T12:51:52-05:00 Document that -fproc-alignment was introduced only in GHC 8.6 - - - - - 16adc349 by Sven Tennie at 2023-02-14T11:26:31-05:00 Add clangd flag to include generated header files This enables clangd to correctly check C files that import Rts.h. (The added include directory contains ghcautoconf.h et. al.) - - - - - c399ccd9 by amesgen at 2023-02-14T11:27:14-05:00 Mention new `Foreign.Marshal.Pool` implementation in User's Guide - - - - - b9282cf7 by Ben Gamari at 2023-02-14T11:27:50-05:00 upload_ghc_libs: More control over which packages to operate on Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to limit which packages to upload. This is often necessary when one package is not uploadable (e.g. see #22740). - - - - - aa3a262d by PHO at 2023-02-14T11:28:29-05:00 Assume platforms support rpaths if they use either ELF or Mach-O Not only Linux, Darwin, and FreeBSD support rpaths. Determine the usability of rpaths based on the object format, not on OS. - - - - - 47716024 by PHO at 2023-02-14T11:29:09-05:00 RTS linker: Improve compatibility with NetBSD 1. Hint address to NetBSD mmap(2) has a different semantics from that of Linux. When a hint address is provided, mmap(2) searches for a free region at or below the hint but *never* above it. This means we can't reliably search for free regions incrementally on the userland, especially when ASLR is enabled. Let the kernel do it for us if we don't care where the mapped address is going to be. 2. NetBSD not only hates to map pages as rwx, but also disallows to switch pages from rw- to r-x unless the intention is declared when pages are initially requested. This means we need a new MemoryAccess mode for pages that are going to be changed to r-x. - - - - - 11de324a by Li-yao Xia at 2023-02-14T11:29:49-05:00 base: Move changelog entry to its place - - - - - 75930424 by Ben Gamari at 2023-02-14T11:30:27-05:00 nativeGen/AArch64: Emit Atomic{Read,Write} inline Previously the AtomicRead and AtomicWrite operations were emitted as out-of-line calls. However, these tend to be very important for performance, especially the RELAXED case (which only exists for ThreadSanitizer checking). Fixes #22115. - - - - - d6411d6c by Andreas Klebinger at 2023-02-14T11:31:04-05:00 Fix some correctness issues around tag inference when targeting the bytecode generator. * Let binders are now always assumed untagged for bytecode. * Imported referenced are now always assumed to be untagged for bytecode. Fixes #22840 - - - - - 9fb4ca89 by sheaf at 2023-02-14T11:31:49-05:00 Introduce warning for loopy superclass solve Commit aed1974e completely re-engineered the treatment of loopy superclass dictionaries in instance declarations. Unfortunately, it has the potential to break (albeit in a rather minor way) user code. To alleviate migration concerns, this commit re-introduces the old behaviour. Any reliance on this old behaviour triggers a warning, controlled by `-Wloopy-superclass-solve`. The warning text explains that GHC might produce bottoming evidence, and provides a migration strategy. This allows us to provide a graceful migration period, alerting users when they are relying on this unsound behaviour. Fixes #22912 #22891 #20666 #22894 #22905 - - - - - 1928c7f3 by Cheng Shao at 2023-02-14T11:32:26-05:00 rts: make it possible to change mblock size on 32-bit targets The MBLOCK_SHIFT macro must be the single source of truth for defining the mblock size, and changing it should only affect performance, not correctness. This patch makes it truly possible to reconfigure mblock size, at least on 32-bit targets, by fixing places which implicitly relied on the previous MBLOCK_SHIFT constant. Fixes #22901. - - - - - 78aa3b39 by Simon Hengel at 2023-02-14T11:33:06-05:00 Update outdated references to notes - - - - - e8baecd2 by meooow25 at 2023-02-14T11:33:49-05:00 Documentation: Improve Foldable1 documentation * Explain foldrMap1, foldlMap1, foldlMap1', and foldrMap1' in greater detail, the text is mostly adapted from documentation of Foldable. * Describe foldr1, foldl1, foldl1' and foldr1' in terms of the above functions instead of redoing the full explanation. * Small updates to documentation of fold1, foldMap1 and toNonEmpty, again adapting from Foldable. * Update the foldMap1 example to lists instead of Sum since this is recommended for lazy right-associative folds. Fixes #22847 - - - - - 85a1a575 by romes at 2023-02-14T11:34:25-05:00 fix: Mark ghci Prelude import as implicit Fixes #22829 In GHCi, we were creating an import declaration for Prelude but we were not setting it as an implicit declaration. Therefore, ghci's import of Prelude triggered -Wmissing-import-lists. Adds regression test T22829 to testsuite - - - - - 3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05:00 compiler: fix generateCgIPEStub for no-tables-next-to-code builds generateCgIPEStub already correctly implements the CmmTick finding logic for when tables-next-to-code is on/off, but it used the wrong predicate to decide when to switch between the two. Previously it switches based on whether the codegen is unregisterised, but there do exist registerised builds that disable tables-next-to-code! This patch corrects that problem. Fixes #22896. - - - - - 08c0822c by doyougnu at 2023-02-15T00:16:39-05:00 docs: release notes, user guide: add js backend Follow up from #21078 - - - - - 79d8fd65 by Bryan Richter at 2023-02-15T00:17:15-05:00 Allow failure in nightly-x86_64-linux-deb10-no_tntc-validate See #22343 - - - - - 9ca51f9e by Cheng Shao at 2023-02-15T00:17:53-05:00 rts: add the rts_clearMemory function This patch adds the rts_clearMemory function that does its best to zero out unused RTS memory for a wasm backend use case. See the comment above rts_clearMemory() prototype declaration for more detailed explanation. Closes #22920. - - - - - 26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00 Add -single-threaded flag to force single threaded rts This is the small part of implementing https://github.com/ghc-proposals/ghc-proposals/pull/240 - - - - - 631c6c72 by Cheng Shao at 2023-02-16T06:43:09-05:00 docs: add a section for the wasm backend Fixes #22658 - - - - - 1878e0bd by Bryan Richter at 2023-02-16T06:43:47-05:00 tests: Mark T12903 fragile everywhere See #21184 - - - - - b9420eac by Bryan Richter at 2023-02-16T06:43:47-05:00 Mark all T5435 variants as fragile See #22970. - - - - - df3d94bd by Sylvain Henry at 2023-02-16T06:44:33-05:00 Testsuite: mark T13167 as fragile for JS (#22921) - - - - - 324e925b by Sylvain Henry at 2023-02-16T06:45:15-05:00 JS: disable debugging info for heap objects - - - - - 518af814 by Josh Meredith at 2023-02-16T10:16:32-05:00 Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name caching - - - - - 34cd308e by Ben Gamari at 2023-02-16T10:17:08-05:00 base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog Fixes #22883. - - - - - 12965aba by Simon Peyton Jones at 2023-02-16T10:17:46-05:00 Narrow the dont-decompose-newtype test Following #22924 this patch narrows the test that stops us decomposing newtypes. The key change is the use of noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp. We went to and fro on the solution, as you can see in #22924. The result is carefully documented in Note [Decomoposing newtype equalities] On the way I had revert most of commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90 Author: Richard Eisenberg <rae at cs.brynmawr.edu> Date: Mon Dec 5 10:14:02 2022 -0500 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. It turns out that (a) 3e827c3f makes GHC behave worse on some recursive newtypes (see one of the tests on this commit) (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders 3e827c3f unnecessary - - - - - 5b038888 by Andrew Lelechenko at 2023-02-16T10:18:24-05:00 Documentation: add an example of SPEC usage - - - - - 681e0e8c by sheaf at 2023-02-16T14:09:56-05:00 No default finalizer exception handler Commit cfc8e2e2 introduced a mechanism for handling of exceptions that occur during Handle finalization, and 372cf730 set the default handler to print out the error to stderr. However, #21680 pointed out we might not want to set this by default, as it might pollute users' terminals with unwanted information. So, for the time being, the default handler discards the exception. Fixes #21680 - - - - - b3ac17ad by Matthew Pickering at 2023-02-16T14:10:31-05:00 unicode: Don't inline bitmap in generalCategory generalCategory contains a huge literal string but is marked INLINE, this will duplicate the string into any use site of generalCategory. In particular generalCategory is used in functions like isSpace and the literal gets inlined into this function which makes it massive. https://github.com/haskell/core-libraries-committee/issues/130 Fixes #22949 ------------------------- Metric Decrease: T4029 T18304 ------------------------- - - - - - 8988eeef by sheaf at 2023-02-16T20:32:27-05:00 Expand synonyms in RoughMap We were failing to expand type synonyms in the function GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the RoughMap infrastructure crucially relies on type synonym expansion to work. This patch adds the missing type-synonym expansion. Fixes #22985 - - - - - 3dd50e2f by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Add test artifact Add the released testsuite tarball to the generated ghcup metadata. - - - - - c6a967d9 by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Use Ubuntu and Rocky bindists Prefer to use the Ubuntu 20.04 and 18.04 binary distributions on Ubuntu and Linux Mint. Prefer to use the Rocky 8 binary distribution on unknown distributions. - - - - - be0b7209 by Matthew Pickering at 2023-02-17T09:37:16+00:00 Add INLINABLE pragmas to `generic*` functions in Data.OldList These functions are * recursive * overloaded So it's important to add an `INLINABLE` pragma to each so that they can be specialised at the use site when the specific numeric type is known. Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020) https://github.com/haskell/core-libraries-committee/issues/129 - - - - - a203ad85 by Sylvain Henry at 2023-02-17T15:59:16-05:00 Merge libiserv with ghci `libiserv` serves no purpose. As it depends on `ghci` and doesn't have more dependencies than the `ghci` package, its code could live in the `ghci` package too. This commit also moves most of the code from the `iserv` program into the `ghci` package as well so that it can be reused. This is especially useful for the implementation of TH for the JS backend (#22261, !9779). - - - - - 7080a93f by Simon Peyton Jones at 2023-02-20T12:06:32+01:00 Improve GHC.Tc.Gen.App.tcInstFun It wasn't behaving right when inst_final=False, and the function had no type variables f :: Foo => Int Rather a corner case, but we might as well do it right. Fixes #22908 Unexpectedly, three test cases (all using :type in GHCi) got slightly better output as a result: T17403, T14796, T12447 - - - - - 2592ab69 by Cheng Shao at 2023-02-20T10:35:30-05:00 compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping The wasm NCG used to map CCCS to a wasm global, based on the observation that CCCS is a transient register that's already handled by thread state load/store logic, so it doesn't need to be backed by the rCCCS field in the register table. Unfortunately, this is wrong, since even when Cmm execution hasn't yielded back to the scheduler, the Cmm code may call enterFunCCS, which does use rCCCS. This breaks cost centre profiling in a subtle way, resulting in inaccurate stack traces in some test cases. The fix is simple though: just remove the CCCS mapping. - - - - - 26243de1 by Alexis King at 2023-02-20T15:27:17-05:00 Handle top-level Addr# literals in the bytecode compiler Fixes #22376. - - - - - 0196cc2b by romes at 2023-02-20T15:27:52-05:00 fix: Explicitly flush stdout on plugin Because of #20791, the plugins tests often fail. This is a temporary fix to stop the tests from failing due to unflushed outputs on windows and the explicit flush should be removed when #20791 is fixed. - - - - - 4327d635 by Ryan Scott at 2023-02-20T20:44:34-05:00 Don't generate datacon wrappers for `type data` declarations Data constructor wrappers only make sense for _value_-level data constructors, but data constructors for `type data` declarations only exist at the _type_ level. This patch does the following: * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data constructor receives a wrapper now consider whether or not its parent data type was declared with `type data`, omitting a wrapper if this is the case. * Now that `type data` data constructors no longer receive wrappers, there is a spot of code in `refineDefaultAlt` that panics when it encounters a value headed by a `type data` type constructor. I've fixed this with a special case in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]` to explain why we do this. Fixes #22948. - - - - - 96dc58b9 by Ryan Scott at 2023-02-20T20:44:35-05:00 Treat type data declarations as empty when checking pattern-matching coverage The data constructors for a `type data` declaration don't exist at the value level, so we don't want GHC to warn users to match on them. Fixes #22964. - - - - - ff8e99f6 by Ryan Scott at 2023-02-20T20:44:35-05:00 Disallow `tagToEnum#` on `type data` types We don't want to allow users to conjure up values of a `type data` type using `tagToEnum#`, as these simply don't exist at the value level. - - - - - 8e765aff by Andrew Lelechenko at 2023-02-21T12:03:24-05:00 Bump submodule text to 2.0.2 - - - - - 172ff88f by Georgi Lyubenov at 2023-02-21T18:35:56-05:00 GHC proposal 496 - Nullary record wildcards This patch implements GHC proposal 496, which allows record wildcards to be used for nullary constructors, e.g. data A = MkA1 | MkA2 { fld1 :: Int } f :: A -> Int f (MkA1 {..}) = 0 f (MkA2 {..}) = fld1 To achieve this, we add arity information to the record field environment, so that we can accept a constructor which has no fields while continuing to reject non-record constructors with more than 1 field. See Note [Nullary constructors and empty record wildcards], as well as the more general overview in Note [Local constructor info in the renamer], both in the newly introduced GHC.Types.ConInfo module. Fixes #22161 - - - - - f70a0239 by sheaf at 2023-02-21T18:36:35-05:00 ghc-prim: levity-polymorphic array equality ops This patch changes the pointer-equality comparison operations in GHC.Prim.PtrEq to work with arrays of unlifted values, e.g. sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int# Fixes #22976 - - - - - 9296660b by Andreas Klebinger at 2023-02-21T23:58:05-05:00 base: Correct @since annotation for FP<->Integral bit cast operations. Fixes #22708 - - - - - f11d9c27 by romes at 2023-02-21T23:58:42-05:00 fix: Update documentation links Closes #23008 Additionally batches some fixes to pointers to the Note [Wired-in units], and a typo in said note. - - - - - fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00 Propagate failure if unable to push notes - - - - - 8e170f86 by Alexis King at 2023-02-23T16:59:22-05:00 rts: Fix `prompt#` when profiling is enabled This commit also adds a new -Dk RTS option to the debug RTS to assist debugging continuation captures. Currently, the printed information is quite minimal, but more can be added in the future if it proves to be useful when debugging future issues. fixes #23001 - - - - - e9e7a00d by sheaf at 2023-02-23T17:00:01-05:00 Explicit migration timeline for loopy SC solving This patch updates the warning message introduced in commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit migration timeline: GHC will no longer support this constraint solving mechanism starting from GHC 9.10. Fixes #22912 - - - - - 4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00 JS: make some arithmetic primops faster (#22835) Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump terminfo submodule to 0.4.1.6 - - - - - f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump unix submodule to 2.8.1.0 - - - - - 47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump deepseq submodule to 1.4.8.1 - - - - - d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump directory submodule to 1.3.8.1 - - - - - df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump process submodule to v1.6.17.0 - - - - - 4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump hsc2hs submodule to 0.68.8 - - - - - 81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump array submodule to 0.5.4.0 - - - - - 6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump Cabal submodule to 3.9 pre-release - - - - - 4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump filepath submodule to 1.4.100.1 - - - - - 2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump haskeline submodule to 0.8.2.1 - - - - - fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00 gitlab-ci: Run nix-build with -v0 This significantly cuts down on the amount of noise in the job log. Addresses #22861. - - - - - 69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00 Fix ParallelListComp out of scope suggestion This patch makes it so vars from one block of a parallel list comprehension are not in scope in a subsequent block during type checking. This was causing GHC to emit a faulty suggestion when an out of scope variable shared the occ name of a var from a different block. Fixes #22940 - - - - - ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-05:00 Fix shadowing bug in prepareAlts As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was using an OutType to construct an InAlt. When shadowing is in play, this is outright wrong. See Note [Shadowing in prepareAlts]. - - - - - 7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00 JS: Store CI perf results (fix #22923) - - - - - b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00 Don't specialise incoherent instance applications Using incoherent instances, there can be situations where two occurrences of the same overloaded function at the same type use two different instances (see #22448). For incoherently resolved instances, we must mark them with `nospec` to avoid the specialiser rewriting one to the other. This marking is done during the desugaring of the `WpEvApp` wrapper. Fixes #22448 Metric Increase: T15304 - - - - - d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00 Fix SCC grouping example - - - - - f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00 Mark setnumcapabilities001 fragile - - - - - 29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00 Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail See #22520 - - - - - 9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00 ghc-prim: fix hs_cmpxchg64 function prototype hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised builds, which go unnoticed at compile-time due to C implicit casting in .hc files. - - - - - 0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-05:00 Account for local rules in specImports As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were generating specialisations (a locally-define function) for imported functions; and then generating specialisations for those locally-defined functions. The RULE for the latter should be attached to the local Id, not put in the rules-for-imported-ids set. Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules - - - - - 8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-05:00 JS: fix for overlap with copyMutableByteArray# (#23033) The code wasn't taking into account some kind of overlap. cgrun070 has been extended to test the missing case. - - - - - 239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00 Testsuite: replace some js_skip with req_cmm req_cmm is more informative than js_skip - - - - - 7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-05:00 Take more care with unlifted bindings in the specialiser As #22998 showed, we were floating an unlifted binding to top level, which breaks a Core invariant. The fix is easy, albeit a little bit conservative. See Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise - - - - - bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-05:00 Account for TYPE vs CONSTRAINT in mkSelCo As #23018 showed, in mkRuntimeRepCo we need to account for coercions between TYPE and COERCION. See Note [mkRuntimeRepCo] in GHC.Core.Coercion. - - - - - 79ffa170 by Ben Gamari at 2023-03-01T04:17:20-05:00 hadrian: Add dependency from lib/settings to mk/config.mk In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253 by adding logic to the bindist Makefile to regenerate the `settings` file from information gleaned by the bindist `configure` script. However, this fix had no effect as `lib/settings` is shipped in the binary distribution (to allow in-place use of the binary distribution). As `lib/settings` already existed and its rule declared no dependencies, `make` would fail to use the added rule to regenerate it. Fix this by explicitly declaring a dependency from `lib/settings` on `mk/config.mk`. Fixes #22982. - - - - - a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-05:00 Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)" This reverts the bits affecting fusion of `drop` and `dropWhile` of commit 0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`. It also adds a new test for #23021 (which was the reason for reverting) as well as adds a clarifying comment to T18964. Fixes #23021, unfixes #18964. Metric Increase: T18964 Metric Decrease: T18964 - - - - - cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-05:00 Refine the test for naughty record selectors The test for naughtiness in record selectors is surprisingly subtle. See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils. Fixes #23038. - - - - - 86f240ca by romes at 2023-03-01T04:19:10-05:00 fix: Consider strictness annotation in rep_bind Fixes #23036 - - - - - 1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00 Don't suppress *all* Wanteds Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its rewriters have unfilled coercion holes; see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint. But if we thereby suppress *all* errors that's really confusing, and as #22707 shows, GHC goes on without even realising that the program is broken. Disaster. This MR arranges to un-suppress them all if they all get suppressed. Close #22707 - - - - - 8919f341 by Luite Stegeman at 2023-03-02T22:42:45-05:00 Check for platform support for JavaScript foreign imports GHC was accepting `foreign import javascript` declarations on non-JavaScript platforms. This adds a check so that these are only supported on an platform that supports the JavaScript calling convention. Fixes #22774 - - - - - db83f8bb by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Statically assert alignment of Capability In #22965 we noticed that changes in the size of `Capability` can result in unsound behavior due to the `align` pragma claiming an alignment which we don't in practice observe. Avoid this by statically asserting that the size is a multiple of the alignment. - - - - - 5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Introduce stgMallocAlignedBytes - - - - - 8a6f745d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Correctly align Capability allocations Previously we failed to tell the C allocator that `Capability`s needed to be aligned, resulting in #22965. Fixes #22965. Fixes #22975. - - - - - 5464c73f by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Drop no-alignment special case for Windows For reasons that aren't clear, we were previously not giving Capability the same favorable alignment on Windows that we provided on other platforms. Fix this. - - - - - a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-05:00 constant folding: Correct type of decodeDouble_Int64 rule The first argument is Int64# unconditionally, so we better produce something of that type. This fixes a core lint error found in the ad package. Fixes #23019 - - - - - 68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-05:00 ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and didn't completly fix the compiler panics when compiling with `-fregs-graph`. Fixes #23002 - - - - - 2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00 Get the right in-scope set in etaBodyForJoinPoint Fixes #23026 - - - - - 45af8482 by David Feuer at 2023-03-03T11:40:47-05:00 Export getSolo from Data.Tuple Proposed in [CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113) and [approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191) - - - - - 0c694895 by David Feuer at 2023-03-03T11:40:47-05:00 Document getSolo - - - - - bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00 More fixes for `type data` declarations This MR fixes #23022 and #23023. Specifically * Beef up Note [Type data declarations] in GHC.Rename.Module, to make invariant (I1) explicit, and to name the several wrinkles. And add references to these specific wrinkles. * Add a Lint check for invariant (I1) above. See GHC.Core.Lint.checkTypeDataConOcc * Disable the `caseRules` for dataToTag# for `type data` values. See Wrinkle (W2c) in the Note above. Fixes #23023. * Refine the assertion in dataConRepArgTys, so that it does not complain about the absence of a wrapper for a `type data` constructor Fixes #23022. Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00 Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT These all type-level equality decision procedures. Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98 - - - - - bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00 Add test for T22793 - - - - - c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00 Fix typo in docs referring to threadLabel - - - - - 232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00 Add regression test for #22328 - - - - - 5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Enable response files for linker if supported - - - - - 1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Synchronize `configure.ac` and `distrib/configure.ac.in` - - - - - 70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix `hadrian/bindist/config.mk.in` … as suggested by @bgamari - - - - - b042b125 by sheaf at 2023-03-06T17:06:50-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Try to create somewhat portable `ld` command I cannot figure out a good way to generate an `ld` command that works on both Linux and macOS. Normally you'd use something like `AC_LINK_IFELSE` for this purpose (I think), but that won't let us test response file support. - - - - - 83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Quote variables … as suggested by @bgamari - - - - - 845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix configure failure on alpine linux - - - - - c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Small fixes to configure script - - - - - cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00 Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115) I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnIllegalInstanceHeadDecl TcRnUnexpectedStandaloneDerivingDecl TcRnUnusedVariableInRuleDecl TcRnUnexpectedStandaloneKindSig TcRnIllegalRuleLhs TcRnBadAssocRhs TcRnDuplicateRoleAnnot TcRnDuplicateKindSig TcRnIllegalDerivStrategy TcRnIllegalMultipleDerivClauses TcRnNoDerivStratSpecified TcRnStupidThetaInGadt TcRnBadImplicitSplice TcRnShadowedTyVarNameInFamResult TcRnIncorrectTyVarOnLhsOfInjCond TcRnUnknownTyVarsOnRhsOfInjCond Was introduced one helper type: RuleLhsErrReason - - - - - c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00 Constraint simplification loop now depends on `ExpansionFuel` instead of a boolean flag for `CDictCan.cc_pend_sc`. Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1. This helps pending given constraints to keep up with pending wanted constraints in case of `UndecidableSuperClasses` and superclass expansions while simplifying the infered type. Adds 3 dynamic flags for controlling the fuels for each type of constraints `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints Fixes #21909 Added Tests T21909, T21909b Added Note [Expanding Recursive Superclasses and ExpansionFuel] - - - - - a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00 Documentation: describe laziness of several function from Data.List - - - - - fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00 Add `Data.Functor.unzip` This function is currently present in `Data.List.NonEmpty`, but `Data.Functor` is a better home for it. This change was discussed and approved by the CLC at https://github.com/haskell/core-libraries-committee/issues/88. - - - - - 2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00 Fix documentation for traceWith and friends - - - - - f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00 Remove utils/hpc subdirectory and its contents - - - - - cf98e286 by David Binder at 2023-03-08T01:24:17-05:00 Add git submodule for utils/hpc - - - - - 605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 606793d4 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 4158722a by Sylvain Henry at 2023-03-08T01:24:58-05:00 linker: fix linking with aligned sections (#23066) Take section alignment into account instead of assuming 16 bytes (which is wrong when the section requires 32 bytes, cf #23066). - - - - - 1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00 Change hostSupportsRPaths to report False on OpenBSD OpenBSD does support -rpath but ghc build process relies on some related features that don't work there. See ghc/ghc#23011 - - - - - bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00 bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args fixes #23068 - - - - - 321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Drop redundant prototype - - - - - abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix style - - - - - be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Deduplicate assertion - - - - - b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Use release ordering when storing thread labels Since this makes the ByteArray# visible from other cores. - - - - - 5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/BlockAlloc: Allow disabling of internal assertions These can be quite expensive and it is sometimes useful to compile a DEBUG RTS without them. - - - - - 6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - 9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - 0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00 Evac: Squash data race in eval_selector_chain - - - - - 7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify comment - - - - - bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't push empty arrays to update remembered set Previously the write barrier of resizeSmallArray# incorrectly handled resizing of zero-sized arrays, pushing an invalid pointer to the update remembered set. Fixes #22931. - - - - - 92227b60 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. - - - - - ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 71b038a1 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check mutable list Assert that entries in the nonmoving generation's generational remembered set (a.k.a. mutable list) live in nonmoving generation. - - - - - 99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix tracking of FILLED_SWEEPING segments Previously we only updated the state of the segment at the head of each allocator's filled list. - - - - - 58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Assert state of swept segments - - - - - 2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive We must conservatively assume that new closures are reachable since we are not guaranteed to mark such blocks. - - - - - e4c3249f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. Fixes #22927. - - - - - 1b069671 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. See the inline comments for details. Fixes #22930. - - - - - d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Post-sweep sanity checking - - - - - 0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Avoid n_caps race - - - - - 5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Be more paranoid in segment tracking Previously we left various segment link pointers dangling. None of this wrong per se, but it did make it harder than necessary to debug. - - - - - 7c817c0a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Sync-phase mark budgeting Here we significantly improve the bound on sync phase pause times by imposing a limit on the amount of work that we can perform during the sync. If we find that we have exceeded our marking budget then we allow the mutators to resume, return to concurrent marking, and try synchronizing again later. Fixes #22929. - - - - - ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Allow pinned gen0 objects to be WEAK keys - - - - - 78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Reenable assertion - - - - - b500867a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move current segment array into Capability The current segments are conceptually owned by the mutator, not the collector. Consequently, it was quite tricky to prove that the mutator would not race with the collect due to this shared state. It turns out that such races are possible: when resizing the current segment array we may concurrently try to take a heap census. This will attempt to walk the current segment array, causing a data race. Fix this by moving the current segment array into `Capability`, where it belongs. Fixes #22926. - - - - - 56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix Note references Some references to Note [Deadlock detection under the non-moving collector] were missing an article. - - - - - 4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts/Sanity: Fix block count assertion with non-moving collector The nonmoving collector does not use `oldest_gen->blocks` to track its block list. However, it nevertheless updates `oldest_gen->n_blocks` to ensure that its size is accounted for by the storage manager. Consequently, we must not attempt to assert consistency between the two. - - - - - 96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't call prepareUnloadCheck When the nonmoving GC is in use we do not call `checkUnload` (since we don't unload code) and therefore should not call `prepareUnloadCheck`, lest we run into assertions. - - - - - 6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Encapsulate block allocator spinlock This makes it a bit easier to add instrumentation on this spinlock while debugging. - - - - - e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip some tests when sanity checking is enabled - - - - - 3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix unregisterised build - - - - - 4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Ensure that sanity checker accounts for saved_filled segments - - - - - f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00 hadrian: Add +boot_nonmoving_gc flavour transformer For using GHC bootstrapping to validate the non-moving GC. - - - - - 581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00 gitlab-ci: Add job bootstrapping with nonmoving GC - - - - - 487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move allocator into new source file - - - - - 8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Split out nonmovingAllocateGC - - - - - 662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Only run T22795* in the normal way It doesn't make sense to run these in multiple ways as they merely test whether `-threaded`/`-single-threaded` flags. - - - - - 0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Rename clear_segment(_free_blocks)? To reflect the fact that these are to do with the nonmoving collector, now since they are exposed no longer static. - - - - - 7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Fix incorrect STATIC_INLINE This should be INLINE_HEADER lest we get unused declaration warnings. - - - - - f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Mark ffi023 as broken due to #23089 - - - - - a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip T7160 in the nonmoving way Finalization order is different under the nonmoving collector. - - - - - f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Capture GC configuration in a struct The number of distinct arguments passed to GarbageCollect was getting a bit out of hand. - - - - - ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Non-concurrent collection - - - - - 7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00 hadrian: Fix flavour compiler stage options off-by-one error !9193 pointed out that ghcDebugAssertions was supposed to be a predicate on the stage of the built compiler, but in practice it was a predicate on the stage of the compiler used to build. Unfortunately, while it fixed that issue for ghcDebugAssertions, it documented every other similar option as behaving the same way when in fact they all used the old behavior. The new behavior of ghcDebugAssertions seems more intuitive, so this commit changes the interpretation of every other option to match. It also improves the enableProfiledGhc and debugGhc flavour transformers by making them more selective about which stages in which they build additional library/RTS ways. - - - - - f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00 Delete created temporary subdirectories at end of session. This patch adds temporary subdirectories to the list of paths do clean up at the end of the GHC session. This fixes warnings about non-empty temporary directories. Fixes #22952 - - - - - 9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00 Fixes #19627. Previously the solver failed with an unhelpful "solver reached too may iterations" error. With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up. This commit adds: * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel] * Test `typecheck/should_fail/T19627.hs` for regression purposes - - - - - ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00 DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997) We should not panic in `add_demands` (now `set_lam_dmds`), because that code path is legimitely taken for OPAQUE PAP bindings, as in T22997. Fixes #22997. - - - - - 5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00 JS: remove dead code for old integer-gmp - - - - - bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00 JS: Fix implementation of MK_JSVAL - - - - - ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00 Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf. - - - - - 047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00 JS: fix implementation of forceBool to use JS backend syntax - - - - - 559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00 Simplifier: `countValArgs` should not count Type args (#23102) I observed miscompilations while working on !10088 caused by this. Fixes #23102. Metric Decrease: T10421 - - - - - 536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00 Bump Win32 to 2.13.4.0 Updates Win32 submodule - - - - - ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00 ghc-bignum: Drop redundant include-dirs field - - - - - c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00 Fix BCO creation setting caps when -j > -N * Remove calls to 'setNumCapabilities' in 'createBCOs' These calls exist to ensure that 'createBCOs' can benefit from parallelism. But this is not the right place to call `setNumCapabilities`. Furthermore the logic differs from that in the driver causing the capability count to be raised and lowered at each TH call if -j > -N. * Remove 'BCOOpts' No longer needed as it was only used to thread the job count down to `createBCOs` Resolves #23049 - - - - - 5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00 Add changelog entry for #23049 - - - - - 6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00 configure: Fix FIND_CXX_STD_LIB test on Darwin Annoyingly, Darwin's <cstddef> includes <version> and APFS is case-insensitive. Consequently, it will end up #including the `VERSION` file generated by the `configure` script on the second and subsequent runs of the `configure` script. See #23116. - - - - - 19d6d039 by sheaf at 2023-03-16T21:31:22+01:00 ghci: only keep the GlobalRdrEnv in ModInfo The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo, which includes a TypeEnv. This can easily cause space leaks as we have no way of forcing everything in a type environment. In GHC, we only use the GlobalRdrEnv, which we can force completely. So we only store that instead of a fully-fledged ModuleInfo. - - - - - 73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00 Add structured error messages for GHC.Tc.Utils.Backpack Tracking ticket: #20119 MR: !10127 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. One occurrence, when handing a nested error from the interface loading machinery, was omitted. It will be handled by a subsequent changeset that addresses interface errors. - - - - - a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00 Rename () into Unit, (,,...,,) into Tuple<n> (#21294) This patch implements a part of GHC Proposal #475. The key change is in GHC.Tuple.Prim: - data () = () - data (a,b) = (a,b) - data (a,b,c) = (a,b,c) ... + data Unit = () + data Tuple2 a b = (a,b) + data Tuple3 a b c = (a,b,c) ... And the rest of the patch makes sure that Unit and Tuple<n> are pretty-printed as () and (,,...,,) in various contexts. Updates the haddock submodule. Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - 23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: fix some wrongs in the eventlog format documentation - - - - - 90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: explain the BLOCK_MARKER event - - - - - ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add BlockedOnMVarRead thread status in eventlog encodings - - - - - 898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add TASK_DELETE event in eventlog encodings - - - - - bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add WALL_CLOCK_TIME event in eventlog encodings - - - - - eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00 Add structured error messages for GHC.Tc.Utils.Env Tracking ticket: #20119 MR: !10129 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00 Document pdep / pext primops - - - - - e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00 Allow LLVM backend to use HDoc for faster file generation. Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement. Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045) - - - - - ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00 Compute LambdaFormInfo when using JavaScript backend. CmmCgInfos is needed to write interface files, but the JavaScript backend does not generate it, causing "Name without LFInfo" warnings. This patch adds a conservative but always correct CmmCgInfos when the JavaScript backend is used. Fixes #23053 - - - - - 926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00 Be more careful about quantification This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole - - - - - 0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00 Testsuite: use appropriate predicate for ManyUbxSums test (#22576) - - - - - 048c881e by romes at 2023-03-22T01:04:24-04:00 fix: Incorrect @since annotations in GHC.TypeError Fixes #23128 - - - - - a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T16318 (#22370) - - - - - ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T20214 - - - - - e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00 Refactor the constraint solver pipeline The big change is to put the entire type-equality solver into GHC.Tc.Solver.Equality, rather than scattering it over Canonical and Interact. Other changes * EqCt becomes its own data type, a bit like QCInst. This is great because EqualCtList is then just [EqCt] * New module GHC.Tc.Solver.Dict has come of the class-contraint solver. In due course it will be all. One step at a time. This MR is intended to have zero change in behaviour: it is a pure refactor. It opens the way to subsequent tidying up, we believe. - - - - - cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00 Add structured error messages for GHC.Tc.Utils.TcMType Tracking ticket: #20119 MR: !10138 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00 Testsuite: use js_skip for T2615 (#22374) - - - - - 8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00 Optimized Foldable methods for Data.Functor.Compose Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/57 - - - - - bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00 Additional optimized versions - - - - - 80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Simplify minimum/maximum in instance Foldable (Compose f g) - - - - - 8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Update changelog to mention changes to instance Foldable (Compose f g) - - - - - e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00 Add structured error messages for GHC.Tc.TyCl.PatSyn Tracking ticket: #20117 MR: !10158 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00 Allow WARNING pragmas to be controlled with custom categories Closes #17209. This implements GHC Proposal 541, allowing a WARNING pragma to be annotated with a category like so: {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-} The user can then enable, disable and set the severity of such warnings using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on. There is a new warning group `-Wextended-warnings` containing all these warnings. Warnings without a category are treated as if the category was `deprecations`, and are (still) controlled by the flags `-Wdeprecations` and `-Wwarnings-deprecations`. Updates Haddock submodule. - - - - - 0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00 Move mention of warning groups change to 9.8.1 release notes - - - - - b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00 nativeGen/AArch64: Fix bitmask immediate predicate Previously the predicate for determining whether a logical instruction operand could be encoded as a bitmask immediate was far too conservative. This meant that, e.g., pointer untagged required five instructions whereas it should only require one. Fixes #23030. - - - - - 46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00 User's guide: Improve docs for -Wall previously it would list the warnings _not_ enabled by -Wall. That’s unnecessary round-about and was out of date. So let's just name the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`). - - - - - 509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00 codeGen/tsan: Disable instrumentation of unaligned stores There is some disagreement regarding the prototype of `__tsan_unaligned_write` (specifically whether it takes just the written address, or the address and the value as an argument). Moreover, I have observed crashes which appear to be due to it. Disable instrumentation of unaligned stores as a temporary mitigation. Fixes #23096. - - - - - 6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00 base: Document GHC versions associated with past base versions in the changelog - - - - - 43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00 Add regression test for #17574 This test currently fails in the nonmoving way - - - - - f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00 fix: account for large and compact object stats with nonmoving gc Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap. We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap. Resolves #17574 - - - - - 7131b705 by David Feuer at 2023-03-25T00:04:04-04:00 Modify ThreadId documentation and comments For a long time, `GHC.Conc.Sync` has said ```haskell -- ToDo: data ThreadId = ThreadId (Weak ThreadId#) -- But since ThreadId# is unlifted, the Weak type must use open -- type variables. ``` We are now actually capable of using `Weak# ThreadId#`, but the world has moved on. To support the `Show` and `Ord` instances, we'd need to store the thread ID number in the `ThreadId`. And it seems very difficult to continue to support `threadStatus` in that regime, since it needs to be able to explain how threads died. In addition, garbage collection of weak references can be quite expensive, and it would be hard to evaluate the cost over he whole ecosystem. As discussed in [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125), it doesn't seem very likely that we'll actually switch to weak references here. - - - - - c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00 rts: Fix barriers of IND and IND_STATIC Previously IND and IND_STATIC lacked the acquire barriers enjoyed by BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers], this barrier is critical to ensure that the indirectee is visible to the entering core. Fixes #22872. - - - - - 62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00 Improve documentation of atomicModifyMutVar2# - - - - - b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00 rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023 This patch does a few things: - Add the missing RtsSymbols.c entry of performBlockingMajorGC - Make hs_perform_gc call performBlockingMajorGC, which restores previous behavior - Use hs_perform_gc in ffi023 - Remove rts_clearMemory() call in ffi023, it now works again in some test ways previously marked as broken. Fixes #23089 - - - - - d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00 testsuite: add the rts_clearMemory test case This patch adds a standalone test case for rts_clearMemory that mimics how it's typically used by wasm backend users and ensures this RTS API isn't broken by future RTS refactorings. Fixes #23901. - - - - - 80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00 Improve documentation for resizing of byte arrays - - - - - c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00 rts: Don't rely on EXTERN_INLINE for slop-zeroing logic Previously we relied on calling EXTERN_INLINE functions defined in ClosureMacros.h from Cmm to zero slop. However, as far as I can tell, this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted in each compilation unit. Fix this by explicitly declaring a new set of non-inline functions in ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h definitions as INLINE_HEADER. In the future we should try to eliminate EXTERN_INLINE. - - - - - c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00 rts: Fix capability-count check in zeroSlop Previously `zeroSlop` examined `RtsFlags` to determine whether the program was single-threaded. This is wrong; a program may be started with `+RTS -N1` yet the process may later increase the capability count with `setNumCapabilities`. This lead to quite subtle and rare crashes. Fixes #23088. - - - - - 656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00 Add Eq/Ord instances for SSymbol, SChar, and SNat This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148). - - - - - 4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00 Update and expand atomic modification Haddocks * The documentation for `atomicModifyIORef` and `atomicModifyIORef'` were incomplete, and the documentation for `atomicModifyIORef` was out of date. Update and expand. * Remove a useless lazy pattern match in the definition of `atomicModifyIORef`. The pair it claims to match lazily was already forced by `atomicModifyIORef2`. - - - - - e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00 Document the constructor name for lists Derived `Data` instances use raw infix constructor names when applicable. The `Data.Data [a]` instance, if derived, would have a constructor name of `":"`. However, it actually uses constructor name `"(:)"`. Document this peculiarity. See https://github.com/haskell/core-libraries-committee/issues/147 - - - - - c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00 Make exprIsConApp_maybe a bit cleverer Addresses #23159. See Note Note [Exploit occ-info in exprIsConApp_maybe] in GHC.Core.SimpleOpt. Compile times go down very slightly, but always go down, never up. Good! Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -1.8% T15703(normal) -1.2% GOOD geo. mean -0.1% minimum -1.8% maximum +0.0% Metric Decrease: CoOpt_Singletons T15703 - - - - - 76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00 Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat This implements [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149). - - - - - 3f374399 by sheaf at 2023-03-29T13:57:33+02:00 Handle records in the renamer This patch moves the field-based logic for disambiguating record updates to the renamer. The type-directed logic, scheduled for removal, remains in the typechecker. To do this properly (and fix the myriad of bugs surrounding the treatment of duplicate record fields), we took the following main steps: 1. Create GREInfo, a renamer-level equivalent to TyThing which stores information pertinent to the renamer. This allows us to uniformly treat imported and local Names in the renamer, as described in Note [GREInfo]. 2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which distinguished between normal names and field names, we now store simple Names in GlobalRdrElt, along with the new GREInfo information which allows us to recover the FieldLabel for record fields. 3. Add namespacing for record fields, within the OccNames themselves. This allows us to remove the mangling of duplicate field selectors. This change ensures we don't print mangled names to the user in error messages, and allows us to handle duplicate record fields in Template Haskell. 4. Move record disambiguation to the renamer, and operate on the level of data constructors instead, to handle #21443. The error message text for ambiguous record updates has also been changed to reflect that type-directed disambiguation is on the way out. (3) means that OccEnv is now a bit more complex: we first key on the textual name, which gives an inner map keyed on NameSpace: OccEnv a ~ FastStringEnv (UniqFM NameSpace a) Note that this change, along with (2), both increase the memory residency of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to regress somewhat in compile-time allocation. Even though (3) simplified a lot of code (in particular the treatment of field selectors within Template Haskell and in error messages), it came with one important wrinkle: in the situation of -- M.hs-boot module M where { data A; foo :: A -> Int } -- M.hs module M where { data A = MkA { foo :: Int } } we have that M.hs-boot exports a variable foo, which is supposed to match with the record field foo that M exports. To solve this issue, we add a new impedance-matching binding to M foo{var} = foo{fld} This mimics the logic that existed already for impedance-binding DFunIds, but getting it right was a bit tricky. See Note [Record field impedance matching] in GHC.Tc.Module. We also needed to be careful to avoid introducing space leaks in GHCi. So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in ModIface. This means stubbing out all the GREInfo fields, with the function forceGlobalRdrEnv. When we read it back in, we rehydrate with rehydrateGlobalRdrEnv. This robustly avoids any space leaks caused by retaining old type environments. Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063 Updates haddock submodule ------------------------- Metric Increase: MultiComponentModules MultiLayerModules MultiLayerModulesDefsGhci MultiLayerModulesNoCode T13701 T14697 hard_hole_fits ------------------------- - - - - - 4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00 Avoid repeatedly shadowing in shadowNames This commit refactors GHC.Type.Name.Reader.shadowNames to first accumulate all the shadowing arising from the introduction of a new set of GREs, and then applies all the shadowing to the old GlobalRdrEnv in one go. - - - - - d246049c by sheaf at 2023-03-29T13:57:34+02:00 igre_prompt_env: discard "only-qualified" names We were unnecessarily carrying around names only available qualified in igre_prompt_env, violating the icReaderEnv invariant. We now get rid of these, as they aren't needed for the shadowing computation that igre_prompt_env exists for. Fixes #23177 ------------------------- Metric Decrease: T14052 T14052Type ------------------------- - - - - - 41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00 hadrian: Fix path to HpcParser.y The source for this project has been moved into a src/ folder so we also need to update this path. Fixes #23187 - - - - - b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00 js: split JMacro into JS eDSL and JS syntax This commit: Splits JExpr and JStat into two nearly identical DSLs: - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a value cannot be unsaturated, or, a value of this DSL is a witness that a value of GHC.JS.Unsat has been saturated - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation. Then all binary and outputable instances are changed to use GHC.JS.Syntax. This moves us closer to closing out #22736 and #22352. See #22736 for roadmap. ------------------------- Metric Increase: CoOpt_Read LargeRecord ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T10858 T11195 T11374 T11822 T12227 T12707 T13035 T13253 T13253-spj T13379 T14683 T15164 T15703 T16577 T17096 T17516 T17836 T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T4801 T5321FD T5321Fun T5631 T5642 T783 T9198 T9233 T9630 TcPlugin_RewritePerf WWRec ------------------------- - - - - - f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. Also used the opportunity to reenable 64-bit Word/Int tests - - - - - a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00 testsuite: Fix racing prints in T21465 As noted in #23155, we previously failed to add flushes necessary to ensure predictable output. Fixes #23155. - - - - - 98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00 Revert "ghc-heap: remove wrong Addr# coercion (#23181)" This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02. This fails to build with GHC-9.2 as a boot compiler. See #23195 for tracking this issue. - - - - - 61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Add {-# WARNING #-} to Data.List.{head,tail} - - - - - 8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-} - - - - - 7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Bump submodules - - - - - d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fix tests - - - - - 3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00 Proxies for head and tail: review suggestions - - - - - 930edcfd by sheaf at 2023-03-30T14:36:33-04:00 docs: move RecordUpd changelog entry to 9.8 This was accidentally included in the 9.6 changelog instead of the 9.6 changelog. - - - - - 6f885e65 by sheaf at 2023-03-30T14:37:09-04:00 Add LANGUAGE GADTs to GHC.Rename.Env We need to enable this extension for the file to compile with ghc 9.2, as we are pattern matching on a GADT and this required the GADT extension to be enabled until 9.4. - - - - - 6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: make lint-ci-config job fast again We don't pin our nixpkgs revision and tracks the default nixpkgs-unstable channel anyway. Instead of using haskell.packages.ghc924, we should be using haskell.packages.ghc92 to maximize the binary cache hit rate and make lint-ci-config job fast again. Also bumps the nix docker image to the latest revision. - - - - - ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: ensure that all non-i386 pipelines do parallel xz compression We can safely enable parallel xz compression for non-i386 pipelines. However, previously we didn't export XZ_OPT, so the xz process won't see it if XZ_OPT hasn't already been set in the current job. - - - - - 20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: unset CROSS_EMULATOR for js job - - - - - 4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: fix lint-testsuite job The list_broken make target will transitively depend on the calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It really should be TEST_HC since that's what get passed in the gitlab CI config. - - - - - cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: use alpine3_17-wasm image for wasm jobs Bump the ci-images dependency and use the new alpine3_17-wasm docker image for wasm jobs. - - - - - 79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Add basic support for testing cross-compilers - - - - - e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Normalize away differences in ghc executable name - - - - - ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00 hadrian: Pass CROSS_EMULATOR to runtests.py - - - - - 30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: don't add optllvm way for wasm32 - - - - - f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: normalize the .wasm extension - - - - - a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: strip the cross ghc prefix in output and error message - - - - - f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: handle target executable extension - - - - - 8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: mypy typing error fixes This patch fixes some mypy typing errors which weren't caught in previous linting jobs. - - - - - 0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: use context variable instead of thread-local variable This patch changes a thread-local variable to context variable instead, which works as intended when the testsuite transitions to use asyncio & coroutines instead of multi-threading to concurrently run test cases. Note that this also raises the minimum Python version to 3.7. - - - - - ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: asyncify the testsuite driver This patch refactors the testsuite driver, gets rid of multi-threading logic for running test cases concurrently, and uses asyncio & coroutines instead. This is not yak shaving for its own sake; the previous multi-threading logic is prone to livelock/deadlock conditions for some reason, even if the total number of threads is bounded to a thread pool's capacity. The asyncify change is an internal implementation detail of the testsuite driver and does not impact most GHC maintainers out there. The patch does not touch the .T files, test cases can be added/modified the exact same way as before. - - - - - 0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00 Add test for T23184 There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch: ``` commit 6656f0165a30fc2a22208532ba384fc8e2f11b46 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Jul 23 23:57:01 2021 +0100 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: ...lots of lines omitted... Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. ``` Note this "Fix a fairly longstanding outright bug". This is the specific fix ``` @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds -- let a = ...arg... -- in [...hole...] a -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable - do { let (dmd:_) = dmds -- Never fails - ; (floats1, cont') <- mkDupableContWithDmds env dmds cont + do { let (dmd:cont_dmds) = dmds -- Never fails + ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 ; (_, se', arg') <- simplArg env' dup se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ``` Ticket #23184 is a report of the bug that this diff fixes. - - - - - 62d25071 by mangoiv at 2023-04-01T04:20:01-04:00 [feat] make ($) representation polymorphic - this change was approved by the CLC in [1] following a CLC proposal [2] - make ($) representation polymorphic (adjust the type signature) - change ($) implementation to allow additional polymorphism - adjust the haddock of ($) to reflect these changes - add additional documentation to document these changes - add changelog entry - adjust tests (move now succeeding tests and adjust stdout of some tests) [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854 [2] https://github.com/haskell/core-libraries-committee/issues/132 - - - - - 77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00 User Guide: update copyright year: 2020->2023 - - - - - 3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00 driver: Unit State Data.Map -> GHC.Unique.UniqMap In pursuit of #22426. The driver and unit state are major contributors. This commit also bumps the haddock submodule to reflect the API changes in UniqMap. ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp T10421 T10547 T12150 T12234 T12425 T13035 T16875 T18140 T18304 T18698a T18698b T18923 T20049 T5837 T6048 T9198 ------------------------- - - - - - a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00 Add structured error messages for GHC.Tc.TyCl Tracking ticket: #20117 MR: !10183 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00 JS: Linker: use saturated JExpr Follow on to MR!10142 in pursuit of #22736 - - - - - 3da69346 by sheaf at 2023-04-01T18:28:37-04:00 Improve haddocks of template-haskell Con datatype This adds a bit more information, in particular about the lists of constructors in the GadtC and RecGadtC cases. - - - - - 3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00 TH: revert changes to GadtC & RecGadtC Commit 3f374399 included a breaking-change to the template-haskell library when it made the GadtC and RecGadtC constructors take non-empty lists of names. As this has the potential to break many users' packages, we decided to revert these changes for now. - - - - - f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00 Rework documentation for data Char - - - - - 43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00 cmm: implement parsing of MO_AtomicRMW from hand-written CMM files Fixes #23206 - - - - - ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. - - - - - 2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00 hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1 Also fixes the ./generate_bootstrap_plans script which was recently broken We can hopefully drop the 9.2 plans soon but they still work so kept them around for now. - - - - - c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00 ci: Add job to test 9.6 bootstrapping - - - - - 53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00 hadrian: Improve option parsing Several options in Hadrian had their argument marked as optional (`OptArg`), but if the argument wasn't there they were just giving an error. It's more idiomatic to mark the argument as required instead; the code uses less Maybes, the parser can enforce that the argument is present, --help gives better output. - - - - - a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00 JS: fix issues with FD api support - Add missing implementations for fcntl_read/write/lock - Fix fdGetMode These were found while implementing TH in !9779. These functions must be used somehow by the external interpreter code. - - - - - 8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00 Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnDataKindsError TcRnUnusedQuantifiedTypeVar TcRnIllegalKindSignature TcRnUnexpectedPatSigType TcRnSectionPrecedenceError TcRnPrecedenceParsingError TcRnIllegalKind TcRnNegativeNumTypeLiteral TcRnUnexpectedKindVar TcRnBindMultipleVariables TcRnBindVarAlreadyInScope - - - - - 220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00 Fixes around unsafeCoerce# 1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul in 74ad75e87317, `unsafeCoerce#` is no longer defined there. I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module. 2. The documentation of `unsafeCoerce#` stated that you should not cast a function to an algebraic type, even if you later cast it back before applying it. But ghci was doing that type of cast, as can be seen with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any following the documentation. - - - - - 9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00 Add a few more memcpy-ish primops * copyMutableByteArrayNonOverlapping# * copyAddrToAddr# * copyAddrToAddrNonOverlapping# * setAddrRange# The implementations of copyBytes, moveBytes, and fillBytes in base:Foreign.Marshal.Utils now use these new primops, which can cause us to work a bit harder generating code for them, resulting in the metric increase in T21839c observed by CI on some architectures. But in exchange, we get better code! Metric Increase: T21839c - - - - - f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00 StgToCmm: Upgrade -fcheck-prim-bounds behavior Fixes #21054. Additionally, we can now check for range overlap when generating Cmm for primops that use memcpy internally. - - - - - cd00e321 by sheaf at 2023-04-04T01:04:50-04:00 Relax assertion in varToRecFieldOcc When using Template Haskell, it is possible to re-parent a field OccName belonging to one data constructor to another data constructor. The lsp-types package did this in order to "extend" a data constructor with additional fields. This ran into an assertion in 'varToRecFieldOcc'. This assertion can simply be relaxed, as the resulting splices are perfectly sound. Fixes #23220 - - - - - eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00 GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201) - - - - - 071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00 Make INLINE pragmas for pattern synonyms work with TH Previously, the code for converting `INLINE <name>` pragmas from TH splices used `vNameN`, which assumed that `<name>` must live in the variable namespace. Pattern synonyms, on the other hand, live in the constructor namespace. I've fixed the issue by switching to `vcNameN` instead, which works for both the variable and constructor namespaces. Fixes #23203. - - - - - 7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00 Fix unification with oversaturated type families unify_ty was incorrectly saying that F x y ~ T x are surely apart, where F x y is an oversaturated type family and T x is a tyconapp. As a result, the simplifier dropped a live case alternative (#23134). - - - - - c165f079 by sheaf at 2023-04-04T17:13:40-04:00 Add testcase for #23192 This issue around solving of constraints arising from superclass expansion using other constraints also borned from superclass expansion was the topic of commit aed1974e. That commit made sure we don't emit a "redundant constraint" warning in a situation in which removing the constraint would cause errors. Fixes #23192 - - - - - d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00 nonmoving: Disable slop-zeroing As noted in #23170, the nonmoving GC can race with a mutator zeroing the slop of an updated thunk (in much the same way that two mutators would race). Consequently, we must disable slop-zeroing when the nonmoving GC is in use. Closes #23170 - - - - - 04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00 Fix reverse flag for -Wunsupported-llvm-version - - - - - 0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00 Add release note for GHC.Unicode refactor in base-4.18. Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in base-4.18 and add proper release date. - - - - - cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00 Improve documentation for ($) (#22963) - - - - - 5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00 Remove trailing whitespace from ($) commentary - - - - - b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00 Adjust wording wrt representation polymorphism of ($) - - - - - 6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00 Add structured error messages for GHC.Tc.TyCl.Utils Tracking ticket: #20117 MR: !10251 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00 Renamer: don't call addUsedGRE on an exact Name When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc, we could end up calling addUsedGRE on an exact Name, which would then lead to a panic in the bestImport function: it would be incapable of processing a GRE which is not local but also not brought into scope by any imports (as it is referred to by its unique instead). Fixes #23240 - - - - - bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add support for -debug in the testsuite Confusingly, GhcDebugged referred to GhcDebugAssertions. - - - - - b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add missing cases in -Di prettyprinter Fixes #23142 - - - - - 6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: make WasmCodeGenM an instance of MonadUnique - - - - - 05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: apply cmm node-splitting for wasm backend This patch applies cmm node-splitting for wasm32 NCG, which is required when handling irreducible CFGs. Fixes #23237. - - - - - f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00 Set base 'maintainer' field to CLC - - - - - ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00 Clarify a couple of Notes about 'nospec' - - - - - ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00 Allow generation of TTH syntax with TH In other words allow generation of typed splices and brackets with Untyped Template Haskell. That is useful in cases where a library is build with TTH in mind, but we still want to generate some auxiliary declarations, where TTH cannot help us, but untyped TH can. Such example is e.g. `staged-sop` which works with TTH, but we would like to derive `Generic` declarations with TH. An alternative approach is to use `unsafeCodeCoerce`, but then the derived `Generic` instances would be type-checked only at use sites, i.e. much later. Also `-ddump-splices` output is quite ugly: user-written instances would use TTH brackets, not `unsafeCodeCoerce`. This commit doesn't allow generating of untyped template splices and brackets with untyped TH, as I don't know why one would want to do that (instead of merging the splices, e.g.) - - - - - 690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00 Add regression test for #23229 - - - - - 59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quotRem rules (#22152) case quotRemInt# x y of (# q, _ #) -> body ====> case quotInt# x y of q -> body case quotRemInt# x y of (# _, r #) -> body ====> case remInt# x y of r -> body - - - - - 4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quot folding rule (#22152) (x / l1) / l2 l1 and l2 /= 0 l1*l2 doesn't overflow ==> x / (l1 * l2) - - - - - 1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make Int64/Word64 division ok for speculation too. Only when the divisor is definitely non-zero. - - - - - 8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make WordQuotRem2Op ok-for-speculation too - - - - - 27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00 Base/JS: GHC.JS.Foreign.Callback module (issue 23126) * Add the Callback module for "exporting" Haskell functions to be available to plain JavaScript code * Fix some primitives defined in GHC.JS.Prim * Add a JavaScript section to the user guide with instructions on how to use the JavaScript FFI, building up to using Callbacks to interact with the browser * Add tests for the JavaScript FFI and Callbacks - - - - - a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00 rts: improve memory ordering and add some comments in the StablePtr implementation - - - - - d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00 docs: Generate docs/index.html with version number * Generate docs/index.html to include the version of the ghc library * This also fixes the packageVersions interpolations which were - Missing an interpolation for `LIBRARY_ghc_VERSION` - Double quoting the version so that "9.7" was being inserted. Fixes #23121 - - - - - d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00 Stop if type constructors have kind errors Otherwise we get knock-on errors, such as #23252. This makes GHC fail a bit sooner, and I have not attempted to add recovery code, to add a fake TyCon place of the erroneous one, in an attempt to get more type errors in one pass. We could do that (perhaps) if there was a call for it. - - - - - 2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Major refactor in the handling of equality constraints This MR substantially refactors the way in which the constraint solver deals with equality constraints. The big thing is: * Intead of a pipeline in which we /first/ canonicalise and /then/ interact (the latter including performing unification) the two steps are more closely integreated into one. That avoids the current rather indirect communication between the two steps. The proximate cause for this refactoring is fixing #22194, which involve solving [W] alpha[2] ~ Maybe (F beta[4]) by doing this: alpha[2] := Maybe delta[2] [W] delta[2] ~ F beta[4] That is, we don't promote beta[4]! This is very like introducing a cycle breaker, and was very awkward to do before, but now it is all nice. See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and Note [Family applications in canonical constraints]. The big change is this: * Several canonicalisation checks (occurs-check, cycle-breaking, checking for concreteness) are combined into one new function: GHC.Tc.Utils.Unify.checkTyEqRhs This function is controlled by `TyEqFlags`, which says what to do for foralls, type families etc. * `canEqCanLHSFinish` now sees if unification is possible, and if so, actually does it: see `canEqCanLHSFinish_try_unification`. There are loads of smaller changes: * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a cheap-and-cheerful version of `checkTyEqRhs`, called `simpleUnifyCheck`. If `simpleUnifyCheck` succeeds, it can unify, otherwise it defers by emitting a constraint. This is simpler than before. * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`. Especially the nasty stuff involving `swap_for_occurs` and `canEqTyVarFunEq`. Much nicer now. See Note [Orienting TyVarLHS/TyFamLHS] Note [Orienting TyFamLHS/TyFamLHS] * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the problems that can be discovered by `checkTyEqRhs`. * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to to accept both cases in #22194 rather than rejecting both. Yet smaller: * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`) to reduce the need for synonym expansion when checking concreteness. Use it in `isConcreteType`. * Renamed `isConcrete` to `isConcreteType` * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient way to find if a particular type variable is used injectively than finding all the injective variables. It is called in `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a lot. * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the constraint solver. Fixes #22194, #23199 Compile times decrease by an average of 0.1%; but there is a 7.4% drop in compiler allocation on T15703. Metric Decrease: T15703 - - - - - 99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Add some documentation about redundant constraints - - - - - 3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Improve partial signatures This MR fixes #23223. The changes are in two places: * GHC.Tc.Bind.checkMonomorphismRestriction See the new `Note [When the MR applies]` We now no longer stupidly attempt to apply the MR when the user specifies a context, e.g. f :: Eq a => _ -> _ * GHC.Tc.Solver.decideQuantification See rewritten `Note [Constraints in partial type signatures]` Fixing this bug apparently breaks three tests: * partial-sigs/should_compile/T11192 * partial-sigs/should_fail/Defaulting1MROff * partial-sigs/should_fail/T11122 However they are all symptoms of #23232, so I'm marking them as expect_broken(23232). I feel happy about this MR. Nice. - - - - - 23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Make approximateWC a bit cleverer This MR fixes #23224: making approximateWC more clever See the long `Note [ApproximateWC]` in GHC.Tc.Solver All this is delicate and ad-hoc -- but it /has/ to be: we are talking about inferring a type for a binding in the presence of GADTs, type families and whatnot: known difficult territory. We just try as hard as we can. - - - - - 2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00 docs: Update template-haskell docs to use Code Q a rather than Q (TExp a) Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a rather than Q (TExp a). The documentation in the `template-haskell` library wasn't updated to reflect this change. Fixes #23148 - - - - - 0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00 Show an error when we cannot default a concrete tyvar Fixes #23153 - - - - - bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00 Handle ConcreteTvs in inferResultToType inferResultToType was discarding the ir_frr information, which meant some metavariables ended up being MetaTvs instead of ConcreteTvs. This function now creates new ConcreteTvs as necessary, instead of always creating MetaTvs. Fixes #23154 - - - - - 3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00 Transfer DFunId_ness onto specialised bindings Whether a binding is a DFunId or not has consequences for the `-fdicts-strict` flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does not apply because the constraint solver can create recursive groups of dictionaries. In #22549 this was fixed for the "normal" case, see Note [Do not strictify the argument dictionaries of a dfun]. However the loop still existed if the DFunId was being specialised. The problem was that the specialiser would specialise a DFunId and turn it into a VanillaId and so the demand analyser didn't know to apply special treatment to the binding anymore and the whole recursive group was optimised to bottom. The solution is to transfer over the DFunId-ness of the binding in the specialiser so that the demand analyser knows not to apply the `-fstrict-dicts`. Fixes #22549 - - - - - a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00 Add import lists to few GHC.Driver.Session imports Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261. There are a lot of GHC.Driver.Session which only use DynFlags, but not the parsing code. - - - - - 51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00 Account for special GHC.Prim import in warnUnusedPackages The GHC.Prim import is treated quite specially primarily because there isn't an interface file for GHC.Prim. Therefore we record separately in the ModSummary if it's imported or not so we don't go looking for it. This logic hasn't made it's way to `-Wunused-packages` so if you imported GHC.Prim then the warning would complain you didn't use `-package ghc-prim`. Fixes #23212 - - - - - 1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00 Add regression test for #23199 - - - - - 0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00 validDerivPred: Reject exotic constraints in IrredPreds This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely, we should reject `IrredPred`s that are inferred from `deriving` clauses whose arguments contain other type constructors, as described in `(VD2) Reject exotic constraints` of that Note. This has the nice property that `deriving` clauses whose inferred instance context mention `TypeError` will now emit the type error in the resulting error message, which better matches existing intuitions about how `TypeError` should work. While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]` was duplicated in a separate `Note [Exotic derived instance contexts]` in `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that there is a single authority on describing the conditions under which an inferred `deriving` constraint can be considered valid. This changes the behavior of `deriving` in a way that existing code might break, so I have made a mention of this in the GHC User's Guide. It seems very, very unlikely that much code is relying on this strange behavior, however, and even if there is, there is a clear, backwards-compatible migration path using `StandaloneDeriving`. Fixes #22696. - - - - - 10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00 Misc cleanup - Use dedicated list functions - Make cloneBndrs and cloneRecIdBndrs monadic - Fix invalid haddock comments in libraries/base - - - - - 5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00 Convert interface file loading errors into proper diagnostics This patch converts all the errors to do with loading interface files into proper structured diagnostics. * DriverMessage: Sometimes in the driver we attempt to load an interface file so we embed the IfaceMessage into the DriverMessage. * TcRnMessage: Most the time we are loading interface files during typechecking, so we embed the IfaceMessage This patch also removes the TcRnInterfaceLookupError constructor which is superceded by the IfaceMessage, which is now structured compared to just storing an SDoc before. - - - - - df1a5811 by sheaf at 2023-04-18T10:31:43-04:00 Don't panic in ltPatersonSize The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it encountered a type family on the RHS, as usually these are not allowed (type families are not allowed on the RHS of class instances or of quantified constraints). However, it is possible to still encounter type families on the RHS after doing a bit of constraint solving, as seen in test case T23171. This could trigger the panic in the call to ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which is involved in avoiding loopy superclass constraints. This patch simply changes ltPatersonSize to return "I don't know, because there's a type family involved" in these cases. Fixes #23171 - - - - - d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00 JS: fix thread-related primops - - - - - 7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00 CI: Disable abi-test-nightly See #23269 - - - - - ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00 Testsuite: don't use obsolescent egrep (#22351) Recent egrep displays the following message, breaking golden tests: egrep: warning: egrep is obsolescent; using grep -E Switch to using "grep -E" instead - - - - - f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00 hadrian: Pass haddock file arguments in a response file In !10119 CI was failing on windows because the command line was too long. We can mitigate this by passing the file arguments to haddock in a response file. We can't easily pass all the arguments in a response file because the `+RTS` arguments can't be placed in the response file. Fixes #23273 - - - - - 7012ec2f by tocic at 2023-04-20T11:01:42-04:00 Fix doc typo in GHC.Read.readList - - - - - 5c873124 by sheaf at 2023-04-20T18:33:34-04:00 Implement -jsem: parallelism controlled by semaphores See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a complete description for the motivation for this feature. The `-jsem` option allows a build tool to pass a semaphore to GHC which GHC can use in order to control how much parallelism it requests. GHC itself acts as a client in the GHC jobserver protocol. ``` GHC Jobserver Protocol ~~~~~~~~~~~~~~~~~~~~~~ This proposal introduces the GHC Jobserver Protocol. This protocol allows a server to dynamically invoke many instances of a client process, while restricting all of those instances to use no more than <n> capabilities. This is achieved by coordination over a system semaphore (either a POSIX semaphore [6]_ in the case of Linux and Darwin, or a Win32 semaphore [7]_ in the case of Windows platforms). There are two kinds of participants in the GHC Jobserver protocol: - The *jobserver* creates a system semaphore with a certain number of available tokens. Each time the jobserver wants to spawn a new jobclient subprocess, it **must** first acquire a single token from the semaphore, before spawning the subprocess. This token **must** be released once the subprocess terminates. Once work is finished, the jobserver **must** destroy the semaphore it created. - A *jobclient* is a subprocess spawned by the jobserver or another jobclient. Each jobclient starts with one available token (its *implicit token*, which was acquired by the parent which spawned it), and can request more tokens through the Jobserver Protocol by waiting on the semaphore. Each time a jobclient wants to spawn a new jobclient subprocess, it **must** pass on a single token to the child jobclient. This token can either be the jobclient's implicit token, or another token which the jobclient acquired from the semaphore. Each jobclient **must** release exactly as many tokens as it has acquired from the semaphore (this does not include the implicit tokens). ``` Build tools such as cabal act as jobservers in the protocol and are responsibile for correctly creating, cleaning up and managing the semaphore. Adds a new submodule (semaphore-compat) for managing and interacting with semaphores in a cross-platform way. Fixes #19349 - - - - - 52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00 rts: Initialize Array# header in listThreads# Previously the implementation of listThreads# failed to initialize the header of the created array, leading to various nastiness. Fixes #23071 - - - - - 1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00 testsuite: Add test for #23071 - - - - - dae514f9 by tocic at 2023-04-21T13:31:21-04:00 Fix doc typos in libraries/base/GHC - - - - - 113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00 Testsuite: replace some js_broken/js_skip predicates with req_c Using req_c is more precise. - - - - - 038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00 Minor doc fixes - Add docs/index.html to .gitignore. It is created by ./hadrian/build docs, and it was the only file in Hadrian's templateRules not present in .gitignore. - Mention that MultiWayIf supports non-boolean guards - Remove documentation of optdll - removed in 2007, 763daed95 - Fix markdown syntax - - - - - e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00 User's guide: DeepSubsumption is implied by Haskell{98,2010} - - - - - 499a1c20 by PHO at 2023-04-23T13:39:32-04:00 Implement executablePath for Solaris and make getBaseDir less platform-dependent Use base-4.17 executablePath when possible, and fall back on getExecutablePath when it's not available. The sole reason why getBaseDir had #ifdef's was apparently that getExecutablePath wasn't reliable, and we could reduce the number of CPP conditionals by making use of executablePath instead. Also export executablePath on js_HOST_ARCH. - - - - - 97a6f7bc by tocic at 2023-04-23T13:40:08-04:00 Fix doc typos in libraries/base - - - - - 787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00 testsuite/T20137: Avoid impl.-defined behavior Previously we would cast pointers to uint64_t. However, implementations are allowed to either zero- or sign-extend such casts. Instead cast to uintptr_t to avoid this. Fixes #23247. - - - - - 87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00 rts: always build 64-bit atomic ops This patch does a few things: - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit platforms - Remove legacy "64bit" cabal flag of rts package - Fix hs_xchg64 function prototype for 32-bit platforms - Fix AtomicFetch test for wasm32 - - - - - 2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00 compiler: don't install signal handlers when the host platform doesn't have signals Previously, large parts of GHC API will transitively invoke withSignalHandlers, which doesn't work on host platforms without signal functionality at all (e.g. wasm32-wasi). By making withSignalHandlers a no-op on those platforms, we can make more parts of GHC API work out of the box when signals aren't supported. - - - - - 1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00 hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC - - - - - 1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00 Add since pragma to Data.Functor.unzip - - - - - 0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00 More informative errors for bad imports (#21826) - - - - - ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00 JS/base: provide implementation for mkdir (issue 22374) - - - - - 8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00 JS: Fix h$base_access implementation (issue 22576) - - - - - 74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00 Give more guarntees about ImplicitParams (#23289) - Added new section in the GHC user's guide that legends behavior of nested implicit parameter bindings in these two cases: let ?f = 1 in let ?f = 2 in ?f and data T where MkT :: (?f :: Int) => T f :: T -> T -> Int f MkT MkT = ?f - Added new test case to examine this behavior. - - - - - c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00 DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208. - - - - - 77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00 Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364) Carry the actual type of an expression through the PreStgRhs and into GenStgRhs for use in later stages. Currently this is used in the JavaScript backend to fix some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2, T13822, T14749. - - - - - 052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00 EPA: Use ExplicitBraces only in HsModule !9018 brought in exact print annotations in LayoutInfo for open and close braces at the top level. But it retained them in the HsModule annotations too. Remove the originals, so exact printing uses LayoutInfo - - - - - d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: update ci.sh to actually run the entire testsuite for wasm backend For the time being, we still need to use in-tree mode and can't test the bindist yet. - - - - - 533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: additional wasm32 manual jobs in validate pipelines This patch enables bignum native & unregisterised wasm32 jobs as manual jobs in validate pipelines, which can be useful to prevent breakage when working on wasm32 related patches. - - - - - b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix cross prefix stripping This patch fixes cross prefix stripping in the testsuite driver. The normalization logic used to only handle prefixes of the triple form <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens in the prefix tuple, so the cross prefix stripping logic would work when ghc is configured with something like --target=wasm32-wasi. - - - - - 6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: include target exe extension in heap profile filenames This patch fixes hp2ps related framework failures when testing the wasm backend by including target exe extension in heap profile filenames. - - - - - e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: exclude ghci ways if no rts linker is present This patch implements logic to automatically exclude ghci ways when there is no rts linker. It's way better than having to annotate individual test cases. - - - - - 791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix permission bits in copy_files When the testsuite driver copy files instead of symlinking them, it should also copy the permission bits, otherwise there'll be permission denied errors. Also, enforce file copying when testing wasm32, since wasmtime doesn't handle host symlinks quite well (https://github.com/bytecodealliance/wasmtime/issues/6227). - - - - - aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_ghc_with_threaded_rts predicate This patch adds the req_ghc_with_threaded_rts predicate to the testsuite to assert the platform has threaded RTS, and mark some tests as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a config field instead of a global variable. - - - - - ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. - - - - - cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_host_target_ghc predicate This patch adds the req_host_target_ghc predicate to the testsuite to assert the ghc compiler being tested can compile both host/target code. When testing cross GHCs this is not supported yet, but it may change in the future. - - - - - b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add missing annotations for some tests This patch adds missing annotations (req_th, req_dynamic_lib_support, req_rts_linker) to some tests. They were discovered when testing wasm32, though it's better to be explicit about what features they require, rather than simply adding when(arch('wasm32'), skip). - - - - - bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: wasm32-specific fixes This patch includes all wasm32-specific testsuite fixes. - - - - - 4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00 JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304) - - - - - 57277662 by sheaf at 2023-04-29T20:23:06+02:00 Add the Unsatisfiable class This commit implements GHC proposal #433, adding the Unsatisfiable class to the GHC.TypeError module. This provides an alternative to TypeError for which error reporting is more predictable: we report it when we are reporting unsolved Wanted constraints. Fixes #14983 #16249 #16906 #18310 #20835 - - - - - 00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00 Add structured error messages for GHC.Rename.Names Tracking ticket: #20115 MR: !10336 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00 Add sized primitive literal syntax Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining unboxed numeric literals such as `0xFF#Word8 :: Word8#`. Implements GHC proposal 0451: https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst Fixes #21422. Bumps haddock submodule. Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00 Document instances of Double - - - - - 1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00 Bump Cabal submodule (#22356) - - - - - 4eafb52a by sheaf at 2023-05-03T20:18:16-04:00 Don't forget to check the parent in an export list Commit 3f374399 introduced a bug which caused us to forget to include the parent of an export item of the form T(..) (that is, IEThingAll) when checking for duplicate exports. Fixes #23318 - - - - - 8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00 Fix unlit path in cross bindists - - - - - 8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00 hadrian: Flavour: Change args -> extraArgs Previously in a flavour definition you could override all the flags which were passed to GHC. This causes issues when needed to compute a package hash because we need to know what these extra arguments are going to be before computing the hash. The solution is to modify flavour so that the arguments you pass here are just extra ones rather than all the arguments that you need to compile something. This makes things work more like how cabal.project files work when you give extra arguments to a package and also means that flavour transformers correctly affect the hash. - - - - - 3fdb18f8 by romes at 2023-05-04T14:58:14-04:00 Hardwire a better unit-id for ghc Previously, the unit-id of ghc-the-library was fixed as `ghc`. This was done primarily because the compiler must know the unit-id of some packages (including ghc) a-priori to define wired-in names. However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed to `ghc` might result in subtle bugs when different ghc's interact. A good example of this is having GHC_A load a plugin compiled by GHC_B, where GHC_A and GHC_B are linked to ghc-libraries that are ABI incompatible. Without a distinction between the unit-id of the ghc library GHC_A is linked against and the ghc library the plugin it is loading was compiled against, we can't check compatibility. This patch gives a slightly better unit-id to ghc (ghc-version) by (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0) (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id. (2.1) `GHC.Settings.Config` is generated by Hadrian (2.2) and also by cabal through `compiler/Setup.hs` This unit-id definition is imported by `GHC.Unit.Types` and used to set the wired-in unit-id of "ghc", which was previously fixed to "ghc" The commits following this one will improve the unit-id with a cabal-style package hash and check compatibility when loading plugins. Note that we also ensure that ghc's unit key matches unit id both when hadrian or cabal builds ghc, and in this way we no longer need to add `ghc` to the WiringMap. - - - - - 6689c9c6 by romes at 2023-05-04T14:58:14-04:00 Validate compatibility of ghcs when loading plugins Ensure, when loading plugins, that the ghc the plugin depends on is the ghc loading the plugin -- otherwise fail to load the plugin. Progress towards #20742. - - - - - db4be339 by romes at 2023-05-04T14:58:14-04:00 Add hashes to unit-ids created by hadrian This commit adds support for computing an inputs hash for packages compiled by hadrian. The result is that ABI incompatible packages should be given different hashes and therefore be distinct in a cabal store. Hashing is enabled by the `--flag`, and is off by default as the hash contains a hash of the source files. We enable it when we produce release builds so that the artifacts we distribute have the right unit ids. - - - - - 944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00 Use hash-unit-ids in release jobs Includes fix upload_ghc_libs glob - - - - - 116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00 JS: fix bounds checking (Issue 23123) * For ByteArray-based bounds-checking, the JavaScript backend must use the `len` field, instead of the inbuild JavaScript `length` field. * Range-based operations must also check both the start and end of the range for bounds * All indicies are valid for ranges of size zero, since they are essentially no-ops * For cases of ByteArray accesses (e.g. read as Int), the end index is (i * sizeof(type) + sizeof(type) - 1), while the previous implementation uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3) * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike the previous point), but now check both start and end indicies * Byte array copies now check if the arrays are the same by identity and then if the ranges overlap. - - - - - 2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00 Fix remaining issues with bound checking (#23123) While fixing these I've also changed the way we store addresses into ByteArray#. Addr# are composed of two parts: a JavaScript array and an offset (32-bit number). Suppose we want to store an Addr# in a ByteArray# foo at offset i. Before this patch, we were storing both fields as a tuple in the "arr" array field: foo.arr[i] = [addr_arr, addr_offset]; Now we only store the array part in the "arr" field and the offset directly in the array: foo.dv.setInt32(i, addr_offset): foo.arr[i] = addr_arr; It avoids wasting space for the tuple. - - - - - 98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00 JavaScript: Correct arguments to h$appendToHsStringA fixes #23278 - - - - - ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00 base/encoding: add an allocations performance test (#22946) - - - - - e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00 linear types: Don't add external names to the usage env This has no observable effect, but avoids storing useless data. - - - - - b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00 Improved documentation for the Data.OldList.nub function There was recomentation to use map head . group . sort instead of nub function, but containers library has more suitable and efficient analogue - - - - - e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00 Fix type variable substitution in gen_Newtype_fam_insts Previously, `gen_Newtype_fam_insts` was substituting the type variable binders of a type family instance using `substTyVars`, which failed to take type variable dependencies into account. There is similar code in `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly, so this patch: 1. Factors out this code into a top-level `substATBndrs` function, and 2. Uses `substATBndrs` in `gen_Newtype_fam_insts`. Fixes #23329. - - - - - 275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00 Add structured error messages for GHC.Rename.Utils Tracking ticket: #20115 MR: !10350 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00 Use TemplateHaskellQuotes in TH.Syntax to construct Names - - - - - a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00 driver: Use hooks from plugin_hsc_env This fixes a bug in oneshot mode where hooks modified in a plugin wouldn't be used in oneshot mode because we neglected to use the right hsc_env. This was observed by @csabahruska. - - - - - 18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00 Rework plugin initialisation points In general this patch pushes plugin initialisation points to earlier in the pipeline. As plugins can modify the `HscEnv`, it's imperative that the plugins are initialised as soon as possible and used thereafter. For example, there are some new tests which modify hsc_logger and other hooks which failed to fire before (and now do) One consequence of this change is that the error for specifying the usage of a HPT plugin from the command line has changed, because it's now attempted to be loaded at initialisation rather than causing a cyclic module import. Closes #21279 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00 docs: Add Note [Timing of plugin initialization] - - - - - e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00 Incrementally update ghcup metadata in ghc/ghcup-metadata This job paves the way for distributing nightly builds * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the metadata on the "updates" branch. * Each night this metadata is downloaded and the nightly builds are appended to the end of the metadata. * The update job only runs on the scheduled nightly pipeline, not just when NIGHTLY=1. Things which are not done yet * Modify the retention policy for nightly jobs * Think about building release flavour compilers to distribute nightly. Fixes #23334 - - - - - 8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00 docs: Remove mentions of ArrayArray# from unlifted FFI section Fixes #23277 - - - - - 994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00 Add structured error messages for GHC.Rename.Module Tracking ticket: #20115 MR: !10361 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. Only addresses the single warning missing from the previous MR. - - - - - 3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00 rts: Fix data-race in hs_init_ghc As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic increment/decrement on the RTS's initialization count. This may go wrong in a multithreaded program which initializes the runtime multiple times. Closes #22756. - - - - - 78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00 Add structured error messages for GHC.IfaceToCore Tracking ticket: #20114 MR: !10390 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00 Fix up rules for ghcup-metadata-nightly-push - - - - - b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00 testsuite: Add test for atomicSwapIORef - - - - - 81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00 compiler: Implement atomicSwapIORef with xchg As requested by @treeowl in CLC#139. - - - - - 6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00 Make atomicSwapMutVar# an inline primop - - - - - 64064cfe by doyougnu at 2023-05-09T18:40:01-04:00 JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt This MR changes some simple optimizations and is a first step in re-architecting the JS backend pipeline to add the optimizer. In particular it: - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module - adds module `GHC.JS.Optimizer` - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations - hooks the optimizer into code gen - adds FuncStat and ForStat constructors to the backend. Working Ticket: - #22736 Related MRs: - MR !10142 - MR !10000 ------------------------- Metric Decrease: CoOpt_Read ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T12707 T13253 T13253-spj T15164 T17516 T18140 T18282 T18698a T18698b T18923 T1969 T19695 T20049 T3064 T5321FD T5321Fun T783 T9198 T9233 T9630 ------------------------- - - - - - 6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00 Add a regression test for #21050 - - - - - b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00 nonmoving: Account for mutator allocations in bytes_allocated Previously we failed to account direct mutator allocations into the nonmoving heap against the mutator's allocation limit and `cap->total_allocated`. This only manifests during CAF evaluation (since we allocate the CAF's blackhole directly into the nonmoving heap). Fixes #23312. - - - - - 0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00 Adjust AArch64 stackFrameHeaderSize The prologue of each stack frame are the saved LR and FP registers, 8 byte each. I.e. the size of the stack frame header is 2 * 8 byte. - - - - - 7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00 Make `(&)` representation polymorphic in the return type - - - - - b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00 ghc-prim: Generalize keepAlive#/touch# in state token type Closes #23163. - - - - - 1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00 Bump hsc2hs submodule Fixes #22981. - - - - - 0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00 base: Export GHC.Conc.Sync.fromThreadId Closes #22706. - - - - - 29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00 Build vanilla alpine bindists We currently attempt to build and distribute fully static alpine bindists (ones which could be used on any linux platform) but most people who use the alpine bindists want to use alpine to build their own static applications (for which a fully static bindist is not necessary). We should build and distribute these bindists for these users whilst the fully-static bindist is still unusable. Fixes #23349 - - - - - 40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00 Look both ways when looking for quantified equalities When looking up (t1 ~# t2) in the quantified constraints, check both orientations. Forgetting this led to #23333. - - - - - c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00 Move "target has RTS linker" out of settings We move the "target has RTS linker" information out of configure into a predicate in GHC, and remove this option from the settings file where it is unnecessary -- it's information statically known from the platform. Note that previously we would consider `powerpc`s and `s390x`s other than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker, but the RTS linker supports neither platform. Closes #23361 - - - - - bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00 Add a test for #17284 Since !10123 we now reject this program. - - - - - 630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00 Document unlawfulness of instance Num Fixed Fixes #22712 - - - - - 87eebf98 by sheaf at 2023-05-11T11:55:22-04:00 Add fused multiply-add instructions This patch adds eight new primops that fuse a multiplication and an addition or subtraction: - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#` fmadd x y z is x * y + z, computed with a single rounding step. This patch implements code generation for these primops in the following backends: - X86, AArch64 and PowerPC NCG, - LLVM - C WASM uses the C implementation. The primops are unsupported in the JavaScript backend. The following constant folding rules are also provided: - compute a * b + c when a, b, c are all literals, - x * y + 0 ==> x * y, - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x. NB: the constant folding rules incorrectly handle signed zero. This is a known limitation with GHC's floating-point constant folding rules (#21227), which we hope to resolve in the future. - - - - - ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00 Add a test for #21278 - - - - - 05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00 rts: Refine memory retention behaviour to account for pinned/compacted objects When using the copying collector there is still a lot of data which isn't copied (such as pinned, compacted, large objects etc). The logic to decide how much memory to retain didn't take into account that these wouldn't be copied. Therefore we pessimistically retained 2* the amount of memory for these blocks even though they wouldn't be copied by the collector. The solution is to split up the heap into two parts, the parts which will be copied and the parts which won't be copied. Then the appropiate factor is applied to each part individually (2 * for copying and 1.2 * for not copying). The T23221 test demonstrates this improvement with a program which first allocates many unpinned ByteArray# followed by many pinned ByteArray# and observes the difference in the ultimate memory baseline between the two. There are some charts on #23221. Fixes #23221 - - - - - 1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00 hadrian: fix no_dynamic_libs flavour transformer This patch fixes the no_dynamic_libs flavour transformer and make fully_static reuse it. Previously building with no_dynamic_libs fails since ghc program is still dynamic and transitively brings in dyn ways of rts which are produced by no rules. - - - - - 0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00 JS: refactor jsSaturate to return a saturated JStat (#23328) - - - - - a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00 Doc: Fix out-of-sync using-optimisation page - Make explicit that default flag values correspond to their -O0 value. - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction, -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper. - - - - - c176ad18 by sheaf at 2023-05-12T06:10:57-04:00 Don't panic in mkNewTyConRhs This function could come across invalid newtype constructors, as we only perform validity checking of newtypes once we are outside the knot-tied typechecking loop. This patch changes this function to fake up a stub type in the case of an invalid newtype, instead of panicking. This patch also changes "checkNewDataCon" so that it reports as many errors as possible at once. Fixes #23308 - - - - - ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00 Allow Core optimizations when interpreting bytecode Tracking ticket: #23056 MR: !10399 This adds the flag `-funoptimized-core-for-interpreter`, permitting use of the `-O` flag to enable optimizations when compiling with the interpreter backend, like in ghci. - - - - - c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00 hadrian: Fix mention of non-existent removeFiles function Previously Hadrian's bindist Makefile referred to a `removeFiles` function that was previously defined by the `make` build system. Since the `make` build system is no longer around, this function is now undefined. Naturally, make being make, this appears to be silently ignored instead of producing an error. Fix this by rewriting it to `rm -f`. Closes #23373. - - - - - eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00 Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog - - - - - aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Ensure non-moving gc is not running when pausing - - - - - 5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Teach listAllBlocks about nonmoving heap List all blocks on the non-moving heap. Resolves #22627 - - - - - d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00 Fix coercion optimisation for SelCo (#23362) setNominalRole_maybe is supposed to output a nominal coercion. In the SelCo case, it was not updating the stored role to Nominal, causing #23362. - - - - - 59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00 hadrian: Fix linker script flag for MergeObjects builder This fixes what appears to have been a typo in !9530. The `-t` flag just enables tracing on all versions of `ld` I’ve looked at, while `-T` is used to specify a linker script. It seems that this worked anyway for some reason on some `ld` implementations (perhaps because they automatically detect linker scripts), but the missing `-T` argument causes `gold` to complain. - - - - - 4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00 Less coercion optimization for non-newtype axioms See Note [Push transitivity inside newtype axioms only] for an explanation of the change here. This change substantially improves the performance of coercion optimization for programs involving transitive type family reductions. ------------------------- Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12545 T13386 T15703 T5030 T8095 ------------------------- - - - - - dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00 Move checkAxInstCo to GHC.Core.Lint A consequence of the previous change is that checkAxInstCo is no longer called during coercion optimization, so it can be moved back where it belongs. Also includes some edits to Note [Conflict checking with AxiomInstCo] as suggested by @simonpj. - - - - - 8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00 Use the eager unifier in the constraint solver This patch continues the refactoring of the constraint solver described in #23070. The Big Deal in this patch is to call the regular, eager unifier from the constraint solver, when we want to create new equalities. This replaces the existing, unifyWanted which amounted to yet-another-unifier, so it reduces duplication of a rather subtle piece of technology. See * Note [The eager unifier] in GHC.Tc.Utils.Unify * GHC.Tc.Solver.Monad.wrapUnifierTcS I did lots of other refactoring along the way * I simplified the treatment of right hand sides that contain CoercionHoles. Now, a constraint that contains a hetero-kind CoercionHole is non-canonical, and cannot be used for rewriting or unification alike. This required me to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in GHC.Tc.Solver.Equality. * I refactored the StopOrContinue type to add StartAgain, so that after a fundep improvement (for example) we can simply start the pipeline again. * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions. With Richard I concluded that they are never needed. * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities. Quite a few error messages change, I think always for the better. Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836 Metric Decrease: T17836 T18223 - - - - - 5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00 Cleanup of dynflags override in export renaming The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean. - - - - - d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00 Use a uniform return convention in bytecode for unary results fixes #22958 - - - - - 8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00 Add more instances for Compose: Enum, Bounded, Num, Real, Integral See https://github.com/haskell/core-libraries-committee/issues/160 for discussion - - - - - 902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00 Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the table, failing to unpack arguments that are perfectly unpackable. The fix is pretty easy; see Note [Recursive unboxing] - - - - - a5451438 by sheaf at 2023-05-13T14:59:13-04:00 Fix bad multiplicity role in tyConAppFunCo_maybe The function tyConAppFunCo_maybe produces a multiplicity coercion for the multiplicity argument of the function arrow, except that it could be at the wrong role if asked to produce a representational coercion. We fix this by using the 'funRole' function, which computes the right roles for arguments to the function arrow TyCon. Fixes #23386 - - - - - 5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00 Turn "ambiguous import" error into a panic This error should never occur, as a lookup of a type or data constructor should never be ambiguous. This is because a single module cannot export multiple Names with the same OccName, as per item (1) of Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export. This code path was intended to handle duplicate record fields, but the rest of the code had since been refactored to handle those in a different way. We also remove the AmbiguousImport constructor of IELookupError, as it is no longer used. Fixes #23302 - - - - - e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00 Unbreak some tests with latest GNU grep, which now warns about stray '\'. Confusingly, the testsuite mangled the error to say "stray /". We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex. Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default). - - - - - 5ae81842 by sheaf at 2023-05-15T14:49:17-04:00 Improve "ambiguous occurrence" error messages This error was sometimes a bit confusing, especially when data families were involved. This commit improves the general presentation of the "ambiguous occurrence" error, and adds a bit of extra context in the case of data families. Fixes #23301 - - - - - 2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00 Fix GHCJS OS platform (fix #23346) - - - - - 86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00 Split DynFlags structure into own module This will allow to make command line parsing to depend on diagnostic system (which depends on dynflags) - - - - - fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00 Replace the implementation of CodeBuffers with unboxed types - - - - - 21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00 Use unboxed codebuffers in base Metric Decrease: encodingAllocations - - - - - 18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Weak pointer cleanups Various stylistic cleanups. No functional changes. - - - - - c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't force debug output to stderr Previously `+RTS -Dw -l` would emit debug output to the eventlog while `+RTS -l -Dw` would emit it to stderr. This was because the parser for `-D` would unconditionally override the debug output target. Now we instead only do so if no it is currently `TRACE_NONE`. - - - - - a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Forcibly flush eventlog on barf Previously we would attempt to flush via `endEventLogging` which can easily deadlock, e.g., if `barf` fails during GC. Using `flushEventLog` directly may result in slightly less consistent eventlog output (since we don't take all capabilities before flushing) but avoids deadlocking. - - - - - 73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Assert that pointers aren't cleared by -DZ This turns many segmentation faults into much easier-to-debug assertion failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns produced by `+RTS -DZ` clearing as invalid pointers. This is a bit ad-hoc but this is the debug runtime. - - - - - 37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Introduce printGlobalThreads - - - - - 451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't sanity-check StgTSO.global_link See Note [Avoid dangling global_link pointers]. Fixes #19146. - - - - - d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00 Split up tyThingToIfaceDecl from GHC.Iface.Make This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl from GHC.Iface.Make into GHC.Iface.Decl. This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl, transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad. - - - - - 4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00 Migrate errors to diagnostics in GHC.Tc.Module This commit migrates the errors in GHC.Tc.Module to use the new diagnostic infrastructure. It required a significant overhaul of the compatibility checks between an hs-boot or signature module and its implementation; we now use a Writer monad to accumulate errors; see the BootMismatch datatype in GHC.Tc.Errors.Types, with its panoply of subtypes. For the sake of readability, several local functions inside the 'checkBootTyCon' function were split off into top-level functions. We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file" datatype, as this mirrors the logic in several other places where we want to treat hs-boot and hsig files in a similar fashion. This commit also refactors the Backpack checks for type synonyms implementing abstract data, to correctly reject implementations that contain qualified or quantified types (this fixes #23342 and #23344). - - - - - d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00 configure: Drop unused AC_PROG_CPP In configure, we were calling `AC_PROG_CPP` but never making use of the $CPP variable it sets or reads. The issue is $CPP will show up in the --help output of configure, falsely advertising a configuration option that does nothing. The reason we don't use the $CPP variable is because HS_CPP_CMD is expected to be a single command (without flags), but AC_PROG_CPP, when CPP is unset, will set said variable to something like `/usr/bin/gcc -E`. Instead, we configure HS_CPP_CMD through $CC. - - - - - a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00 rts: fix --disable-large-address-space This patch moves ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from Storage.h to HeapAlloc.h. When --disable-large-address-space is passed to configure, the code in HeapAlloc.h makes use of these two macros. Fixes #23385. - - - - - bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00 Add -Wmissing-role-annotations Implements #22702 - - - - - 41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00 base: Export {get,set}ExceptionFinalizer from System.Mem.Weak As proposed in CLC Proposal #126 [1]. [1]: https://github.com/haskell/core-libraries-committee/issues/126 - - - - - 67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00 base: Introduce printToHandleFinalizerExceptionHandler - - - - - 5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00 JS: Implement h$clock_gettime in the JavaScript RTS (#23360) - - - - - 90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for SourceText SourceText is serialized along with INLINE pragmas into interface files. Many of these SourceTexts are identical, for example "{-# INLINE#". When deserialized, each such SourceText was previously expanded out into a [Char], which is highly wasteful of memory, and each such instance of the text would allocate an independent list with its contents as deserializing breaks any sharing that might have existed. Instead, we use a `FastString` to represent these, so that each instance unique text will be interned and stored in a memory efficient manner. - - - - - b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation/FastStrings for `SourceNote`s `SourceNote`s should not be stored as [Char] as this is highly wasteful and in certain scenarios can be highly duplicated. Metric Decrease: hard_hole_fits - - - - - 6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for UsageFile (#22744) Use FastString to store filepaths in interface files, as this data is highly redundant so we want to share all instances of filepaths in the compiler session. - - - - - 47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00 testsuite: add test for T22744 This test checks for #22744 by compiling 100 modules which each have a dependency on 1000 distinct external files. Previously, when loading these interfaces from disk, each individual instance of a filepath in the interface will would be allocated as an individual object on the heap, meaning we have heap objects for 100*1000 files, when there are only 1000 distinct files we care about. This test checks this by first compiling the module normally, then measuring the peak memory usage in a no-op recompile, as the recompilation checking will force the allocation of all these filepaths. - - - - - 0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00 users guide: Add glossary Currently this merely explains the meaning of "technology preview" in the context of released features. - - - - - 0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00 Update glossary.rst - - - - - 3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00 Use glossary directive - - - - - 2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00 JS: fix getpid (fix #23399) - - - - - 5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00 Use setSrcSpan rather than setLclEnv in solveForAll In subsequent MRs (#23409) we want to remove the TcLclEnv argument from a CtLoc. This MR prepares us for that by removing the one place where the entire TcLclEnv is used, by using it more precisely to just set the contexts source location. Fixes #23390 - - - - - 385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00 Update the users guide paragraph on -O in GHCi In relation to #23056 - - - - - 87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Add test for #13660 - - - - - 9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Move implementation of GHC.Foreign to GHC.Internal - - - - - 174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Introduce {new,with}CStringLen0 These are useful helpers for implementing the internal-NUL code unit check needed to fix #13660. - - - - - a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Clean up documentation - - - - - b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Ensure that FilePaths don't contain NULs POSIX filepaths may not contain the NUL octet but previously we did not reject such paths. This could be exploited by untrusted input to cause discrepancies between various `FilePath` queries and the opened filename. For instance, `readFile "hello.so\x00.txt"` would open the file `"hello.so"` yet `takeFileExtension` would return `".txt"`. The same argument applies to Windows FilePaths Fixes #13660. - - - - - 7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00 Allow the demand analyser to unpack tuple and equality dictionaries Addresses #23398. The demand analyser usually does not unpack class dictionaries: see Note [Do not unbox class dictionaries] in GHC.Core.Opt.DmdAnal. This patch makes an exception for tuple dictionaries and equality dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of the above Note. Compile times fall by 0.1% for some reason (max 0.7% on T18698b). - - - - - b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00 Use a simpler and more portable construct in ld.ldd check printf '%q\n' is a bash extension which led to incorrectly failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh - - - - - dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00 Update the warning about interpreter optimizations to reflect that they're not incompatible anymore, but guarded by a flag - - - - - 4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00 Remove stray dump flags in GHC.Rename.Names - - - - - 4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00 Make Warn = Located DriverMessage This change makes command line argument parsing use diagnostic framework for producing warnings. - - - - - 525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00 Type inference for data family newtype instances This patch addresses #23408, a tricky case with data family newtype instances. Consider type family TF a where TF Char = Bool data family DF a newtype instance DF Bool = MkDF Int and [W] Int ~R# DF (TF a), with a Given (a ~# Char). We must fully rewrite the Wanted so the tpye family can fire; that wasn't happening. - - - - - c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00 testsuite: fix predicate on rdynamic test Test rdynamic requires dynamic linking support, which is orthogonal to RTS linker support. Change the predicate accordingly. Fixes #23316 - - - - - 735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00 docs: Use ghc-ticket directive where appropiate in users guide Using the directive automatically formats and links the ticket appropiately. - - - - - b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00 NCG: remove useless .align directive (#20758) - - - - - 15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00 Add test for #23156 This program had exponential typechecking time in GHC 9.4 and 9.6 - - - - - 2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00 Revert "Change hostSupportsRPaths to report False on OpenBSD" This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2. - - - - - 882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00 Disable T17414 on OpenBSD Like on other systems it's not guaranteed that there's sufficient space in /tmp to write 2G out. - - - - - 9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00 Bring back getExecutablePath to getBaseDir on OpenBSD Fix #18173 - - - - - 9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00 Add an error origin for impedance matching (#23427) - - - - - 33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00 testsuite: Add tests for #23146 Both lifted and unlifted variants. - - - - - 76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Fix some Haddocks - - - - - 33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Give proper LFInfo to datacon wrappers As noted in `Note [Conveying CAF-info and LFInfo between modules]`, when importing a binding from another module we must ensure that it gets the appropriate `LambdaFormInfo` if it is in WHNF to ensure that references to it are tagged correctly. However, the implementation responsible for doing this, `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and not wrappers. This lead to the crash of this program in #23146: module B where type NP :: [UnliftedType] -> UnliftedType data NP xs where UNil :: NP '[] module A where import B fieldsSam :: NP xs -> NP xs -> Bool fieldsSam UNil UNil = True x = fieldsSam UNil UNil Due to its GADT nature, `UNil` produces a trivial wrapper $WUNil :: NP '[] $WUNil = UNil @'[] @~(<co:1>) which is referenced in the RHS of `A.x`. Due to the above-mentioned bug in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were not tagged. This is problematic as `fieldsSam` expected its arguments to be tagged as they are unlifted. The fix is straightforward: extend the logic in `mkLFImported` to cover (nullary) datacon wrappers as well as workers. This is safe because we know that the wrapper of a nullary datacon will be in WHNF, even if it includes equalities evidence (since such equalities are not runtime relevant). Thanks to @MangoIV for the great ticket and @alt-romes for his minimization and help debugging. Fixes #23146. - - - - - 2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 codeGen: Fix LFInfo of imported datacon wrappers As noted in #23231 and in the previous commit, we were failing to give a an LFInfo of LFCon to a nullary datacon wrapper from another module, failing to properly tag pointers which ultimately led to the segmentation fault in #23146. On top of the previous commit which now considers wrappers where we previously only considered workers, we change the order of the guards so that we check for the arity of the binding before we check whether it is a constructor. This allows us to (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was nullary, which we previously would fail to do (2) Remove the `isNullaryRepDataCon` predicate: (a) which was previously wrong, since it considered wrappers whose workers had zero-width arguments to be non-nullary and would fail to give `LFCon` to them (b) is now unnecessary, since arity == 0 guarantees - that the worker takes no arguments at all - and the wrapper takes no arguments and its RHS must be an application of the worker to zero-width-args only. - we lint these two items with an assertion that the datacon `hasNoNonZeroWidthArgs` We also update `isTagged` to use the new logic in determining the LFInfos of imported Ids. The creation of LFInfos for imported Ids and this detail are explained in Note [The LFInfo of Imported Ids]. Note that before the patch to those issues we would already consider these nullary wrappers to have `LFCon` lambda form info; but failed to re-construct that information in `mkLFImported` Closes #23231, #23146 (I've additionally batched some fixes to documentation I found while investigating this issue) - - - - - 0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Make LFInfos for DataCons on construction As a result of the discussion in !10165, we decided to amend the previous commit which fixed the logic of `mkLFImported` with regard to datacon workers and wrappers. Instead of having the logic for the LFInfo of datacons be in `mkLFImported`, we now construct an LFInfo for all data constructors on GHC.Types.Id.Make and store it in the `lfInfo` field. See the new Note [LFInfo of DataCon workers and wrappers] and ammendments to Note [The LFInfo of Imported Ids] - - - - - 12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Update Note [Core letrec invariant] Authored by @simonpj - - - - - e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Rename mkLFImported to importedIdLFInfo The `mkLFImported` sounded too much like a constructor of sorts, when really it got the `LFInfo` of an imported Id from its `lf_info` field when this existed, and otherwise returned a conservative estimate of that imported Id's LFInfo. This in contrast to functions such as `mkLFReEntrant` which really are about constructing an `LFInfo`. - - - - - e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Enforce invariant on typePrimRepArgs in the types As part of the documentation effort in !10165 I came across this invariant on 'typePrimRepArgs' which is easily expressed at the type-level through a NonEmpty list. It allowed us to remove one panic. - - - - - b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Merge outdated Note [Data con representation] into Note [Data constructor representation] Introduce new Note [Constructor applications in STG] to better support the merge, and reference it from the relevant bits in the STG syntax. - - - - - e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Add the SolverStage monad This refactoring makes a substantial improvement in the structure of the type-checker's constraint solver: #23070. Specifically: * Introduced the SolverStage monad. See GHC.Tc.Solver.Monad Note [The SolverStage monad] * Make each solver pipeline (equalities, dictionaries, irreds etc) deal with updating the inert set, as a separate SolverStage. There is sometimes special stuff to do, and it means that each full pipeline can have type SolverStage Void, indicating that they never return anything. * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage. Much nicer. * Combined the remnants of GHC.Tc.Solver.Canonical and GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve. (Interact and Canonical are removed.) * Gave the same treatment to dictionary and irred constraints as I have already done for equality constraints: * New types (akin to EqCt): IrredCt and DictCt * Ct is now just a simple sum type data Ct = CDictCan DictCt | CIrredCan IrredCt | CEqCan EqCt | CQuantCan QCInst | CNonCanonical CtEvidence * inert_dicts can now have the better type DictMap DictCt, instead of DictMap Ct; and similarly inert_irreds. * Significantly simplified the treatment of implicit parameters. Previously we had a number of special cases * interactGivenIP, an entire function * special case in maybeKickOut * special case in findDict, when looking up dictionaries But actually it's simpler than that. When adding a new Given, implicit parameter constraint to the InertSet, we just need to kick out any existing inert constraints that mention that implicit parameter. The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with its auxiliary GHC.Core.Predicate.mentionsIP. See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict. * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit. See Note [Fast path for tcCheckHoleFit]. This is a big win in some cases: test hard_hole_fits gets nearly 40% faster (at compile time). * Add a new fast-path for solving /boxed/ equality constraints (t1 ~ t2). See Note [Solving equality classes] in GHC.Tc.Solver.Dict. This makes a big difference too: test T17836 compiles 40% faster. * Implement the PermissivePlan of #23413, which concerns what happens with insoluble Givens. Our previous treatment was wildly inconsistent as that ticket pointed out. A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply don't run the ambiguity check at all if -XAllowAmbiguousTypes is on. Smaller points: * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for insoluble /occurs/ checks, broaden in to all insouluble constraints. Just generally better. See Note [Insoluble mis-match] in that module. As noted above, compile time perf gets better. Here are the changes over 0.5% on Fedora. (The figures are slightly larger on Windows for some reason.) Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -0.9% MultiLayerModulesTH_OneShot(normal) +0.5% T11822(normal) -0.6% T12227(normal) -1.8% GOOD T12545(normal) -0.5% T13035(normal) -0.6% T15703(normal) -1.4% GOOD T16875(normal) -0.5% T17836(normal) -40.7% GOOD T17836b(normal) -12.3% GOOD T17977b(normal) -0.5% T5837(normal) -1.1% T8095(normal) -2.7% GOOD T9020(optasm) -1.1% hard_hole_fits(normal) -37.0% GOOD geo. mean -1.3% minimum -40.7% maximum +0.5% Metric Decrease: T12227 T15703 T17836 T17836b T8095 hard_hole_fits LargeRecord T9198 T13035 - - - - - 6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Avoid an assertion failure in abstractFloats The function GHC.Core.Opt.Simplify.Utils.abstractFloats was carelessly calling lookupIdSubst_maybe on a CoVar; but a precondition of the latter is being given an Id. In fact it's harmless to call it on a CoVar, but still, the precondition on lookupIdSubst_maybe makes sense, so I added a test for CoVars. This avoids a crash in a DEBUG compiler, but otherwise has no effect. Fixes #23426. - - - - - 838aaf4b by hainq at 2023-05-24T12:41:19-04:00 Migrate errors in GHC.Tc.Validity This patch migrates the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It adds the constructors: - TcRnSimplifiableConstraint - TcRnArityMismatch - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors and fundep coverage condition errors. - - - - - 8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00 linear lint: Add missing processing of DEFAULT In this correct program f :: a %1 -> a f x = case x of x { _DEFAULT -> x } after checking the alternative we weren't popping the case binder 'x' from the usage environment, which meant that the lambda-bound 'x' was counted twice: in the scrutinee and (incorrectly) in the alternative. In fact, we weren't checking the usage of 'x' at all. Now the code for handling _DEFAULT is similar to the one handling data constructors. Fixes #23025. - - - - - ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00 Remove outdated "Don't check hs-boot type family instances too early" note This note was introduced in 25b70a29f623 which delayed performing some consistency checks for type families. However, the change was reverted later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not removed. I found it confusing when reading to code to try and work out what special behaviour there was for hs-boot files (when in-fact there isn't any). - - - - - 44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: Define ticky macro stubs These macros have long been undefined which has meant we were missing reporting these allocations in ticky profiles. The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was missing all the RTS calls to allocate, this leads to a the overall ALLOC_RTS_tot number to be severaly underreported. Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot counters which are useful to tracking stack allocations. Fixes #23421 - - - - - b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes more sense to name it after that rather than the suffix NOCTR, whose meaning has been lost to the mists of time. - - - - - eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00 users guide: A few small mark-up fixes - - - - - a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00 configure: Fix support check for response files. In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument to printf, the writing of the arguments response file always failed. The fix is to pass the arguments after `--` so that they are treated positional arguments rather than flags to printf. Closes #23435 - - - - - f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00 [feat] add .direnv to the .gitignore file - - - - - 36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00 Add Data.List.unsnoc See https://github.com/haskell/core-libraries-committee/issues/165 for discussion - - - - - c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00 Fix crash in backpack signature merging with -ddump-rn-trace In some cases, backpack signature merging could crash in addUsedGRE when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause unavailable interfaces to be loaded. This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE when -ddump-rn-trace is enabled. Fixes #23424 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - 5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00 Add a regression test for #13981 The panic was fixed by 6998772043a7f0b. Fixes #13981. - - - - - 182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00 Add a test for #23355 It was fixed by !10061, so I'm adding it in the same group. - - - - - 1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00 Migrate errors in GHC.Rename.Splice GHC.Rename.Pat This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat to use the new diagnostic infrastructure. - - - - - 56abe494 by sheaf at 2023-05-25T12:09:55+02:00 Common up Template Haskell errors in TcRnMessage This commit commons up the various Template Haskell errors into a single constructor, TcRnTHError, of TcRnMessage. - - - - - a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00 Enable ghci tests for unboxed tuples The tests were originally skipped because ghci used not to support unboxed tuples/sums. - - - - - dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00 rts: Build ticky GHC with single-threaded RTS The threaded RTS allows you to use ticky profiling but only for the counters in the generated code. The counters used in the C portion of the RTS are disabled. Updating the counters is also racy using the threaded RTS which can lead to misleading or incorrect ticky results. Therefore we change the hadrian flavour to build using the single-threaded RTS (mainly in order to get accurate C code counter increments) Fixes #23430 - - - - - fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00 Propagate long-distance info in generated code When desugaring generated pattern matches, we skip pattern match checks. However, this ended up also discarding long-distance information, which might be needed for user-written sub-expressions. Example: ```haskell okay (GADT di) cd = let sr_field :: () sr_field = case getFooBar di of { Foo -> () } in case cd of { SomeRec _ -> SomeRec sr_field } ``` With sr_field a generated FunBind, we still want to propagate the outer long-distance information from the GADT pattern match into the checks for the user-written RHS of sr_field. Fixes #23445 - - - - - f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00 Introduce GHCiMessage to wrap GhcMessage By introducing a wrapped message type we can control how certain messages are printed in GHCi (to add extra information for example) - - - - - 58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00 Generalise UnknownDiagnostic to allow embedded diagnostics to access parent diagnostic options. * Split default diagnostic options from Diagnostic class into HasDefaultDiagnosticOpts class. * Generalise UnknownDiagnostic to allow embedded diagnostics to access options. The principle idea here is that when wrapping an error message (such as GHCMessage to make GHCiMessage) then we need to also be able to lift the configuration when overriding how messages are printed (see load' for an example). - - - - - b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00 Allow API users to wrap error messages created during 'load' This allows API users to configure how messages are rendered when they are emitted from the load function. For an example see how 'loadWithCache' is used in GHCi. - - - - - 2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00 Abstract cantFindError and turn Opt_BuildingCabal into a print-time option * cantFindError is abstracted so that the parts which mention specific things about ghc/ghci are parameters. The intention being that GHC/GHCi can specify the right values to put here but otherwise display the same error message. * The BuildingCabalPackage argument from GenericMissing is removed and turned into a print-time option. The reason for the error is not dependent on whether `-fbuilding-cabal-package` is passed, so we don't want to store that in the error message. - - - - - 34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00 error messages: Don't display ghci specific hints for missing packages Tickets like #22884 suggest that it is confusing that GHC used on the command line can suggest options which only work in GHCi. This ticket uses the error message infrastructure to override certain error messages which displayed GHCi specific information so that this information is only showed when using GHCi. The main annoyance is that we mostly want to display errors in the same way as before, but with some additional information. This means that the error rendering code has to be exported from the Iface/Errors/Ppr.hs module. I am unsure about whether the approach taken here is the best or most maintainable solution. Fixes #22884 - - - - - 05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't override existing metadata if version already exists. If a nightly pipeline runs twice for some reason for the same version then we really don't want to override an existing entry with new bindists. This could cause ABI compatability issues for users or break ghcup's caching logic. - - - - - fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Use proper API url for bindist download Previously we were using links from the web interface, but it's more robust and future-proof to use the documented links to the artifacts. https://docs.gitlab.com/ee/api/job_artifacts.html - - - - - 5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Set Nightly and LatestNightly tags The latest nightly release needs the LatestNightly tag, and all other nightly releases need the Nightly tag. Therefore when the metadata is updated we need to replace all LatestNightly with Nightly.` - - - - - 914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download nightly metadata for correct date The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata with one metadata file per year. When we update the metadata we download and update the right file for the current year. - - - - - 16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download metadata and update for correct year something about pipeline date - - - - - 14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't skip CI On a push we now have a CI job which updates gitlab pages with the metadata files. - - - - - 1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add --date flag to specify the release date The ghcup-metadata now has a viReleaseDay field which needs to be populated with the day of the release. - - - - - bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add dlOutput field ghcup now requires us to add this field which specifies where it should download the bindist to. See https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more discussion. - - - - - 2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00 JS: Convert rendering to use HLine instead of SDoc (#22455) - - - - - abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00 testsuite: add WasmControlFlow test This patch adds the WasmControlFlow test to test the wasm backend's relooper component. - - - - - 07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00 Factorize getLinkDeps Prepare reuse of getLinkDeps for TH implementation in the JS backend (cf #22261 and review of !9779). - - - - - fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00 Change GHC.Driver.Session import to .DynFlags Also move targetPlatform selector Plenty of GHC needs just DynFlags. Even more can be made to use .DynFlags if more selectors is migrated. This is a low hanging fruit. - - - - - 69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00 EPA: Better fix for #22919 The original fix for #22919 simply removed the ability to match up prior comments with the first declaration in the file. Restore it, but add a check that the comment is on a single line, by ensuring that it comes immediately prior to the next thing (comment or start of declaration), and that the token preceding it is not on the same line. closes #22919 - - - - - 0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00 Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214) - - - - - b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00 testsuite: Pass -kb16k -kc128k for performance tests Setting a larger stack chunk size gives a greater protection from stack thrashing (where the repeated overflow/underflow allocates a lot of stack chunks which sigificantly impact allocations). This stabilises some tests against differences cause by more things being pushed onto the stack. The performance tests are generally testing work done by the compiler, using allocation as a proxy, so removing/stabilising the allocations due to the stack gives us more stable tests which are also more sensitive to actual changes in compiler performance. The tests which increase are ones where we compile a lot of modules, and for each module we spawn a thread to compile the module in. Therefore increasing these numbers has a multiplying effect on these tests because there are many more stacks which we can increase in size. The most significant improvements though are cases such as T8095 which reduce significantly in allocations (30%). This isn't a performance improvement really but just helps stabilise the test against this threshold set by the defaults. Fixes #23439 ------------------------- Metric Decrease: InstanceMatching T14683 T8095 T9872b_defer T9872d T9961 hie002 T19695 T3064 Metric Increase: MultiLayerModules T13701 T14697 ------------------------- - - - - - 6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00 Move via-C flags into GHC These were previously hardcoded in configure (with no option for overriding them) and simply passed onto ghc through the settings file. Since configure already guarantees gcc supports those flags, we simply move them into GHC. - - - - - 981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Allow CPR on unrestricted constructors Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will allow CPR to handle `Ur`, in particular. - - - - - bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Push coercions across multiplicity boundaries Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will avoid preventing inlinings and reductions and make linear programs more efficient. - - - - - d56dd695 by sheaf at 2023-05-31T11:37:12-04:00 Data.Bag: add INLINEABLE to polymorphic functions This commit allows polymorphic methods in GHC.Data.Bag to be specialised, avoiding having to pass explicit dictionaries when they are instantiated with e.g. a known monad. - - - - - 5366cd35 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcBinderStack into its own module This commit splits off TcBinderStack into its own module, to avoid module cycles: we might want to refer to it without also pulling in the TcM monad. - - - - - 09d4d307 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcRef into its own module This helps avoid pull in the full TcM monad when we just want access to mutable references in the typechecker. This facilitates later patches which introduce a slimmed down TcM monad for zonking. - - - - - 88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00 Introduce Codensity monad The Codensity monad is useful to write state-passing computations in continuation-passing style, e.g. to implement a State monad as continuation-passing style over a Reader monad. - - - - - f62d8195 by sheaf at 2023-05-31T11:37:12-04:00 Restructure the zonker This commit splits up the zonker into a few separate components, described in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`. 1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`, which has enough information for zonking types. This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`, which guarantees we don't throw an error while reporting an error. 2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines two zonking monad transformers, `ZonkT` and `ZonkBndrT`. `ZonkT` is a reader monad transformer over `ZonkEnv`. `ZonkBndrT m` is the codensity monad over `ZonkT m`. `ZonkBndrT` is used for computations that accumulate binders in the `ZonkEnv`. 3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use in the typechecker. It uses the `ZonkM` monad. 4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`, which has been refactored to use `ZonkTcM = ZonkT TcM` and `ZonkBndrTcM = ZonkBndrT TcM`. Allocations slightly decrease on the whole due to using continuation-passing style instead of manual state passing of ZonkEnv in the final zonking to Type. ------------------------- Metric Decrease: T4029 T8095 T14766 T15304 hard_hole_fits RecordUpdPerf Metric Increase: T10421 ------------------------- - - - - - 70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00 Update rdt-theme to latest upstream version Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444 - - - - - f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Restructure IPE buffer layout Reference ticket #21766 This commit restructures IPE buffer list entries to not contain references to their corresponding info tables. IPE buffer list nodes now point to two lists of equal length, one holding the list of info table pointers and one holding the corresponding entries for each info table. This will allow the entry data to be compressed without losing the references to the info tables. - - - - - 5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE compression to configure Reference ticket #21766 Adds an `--enable-ipe-data-compreesion` flag to the configure script which will check for libzstd and set the appropriate flags to allow for IPE data compression in the compiler - - - - - b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00 IPE data compression Reference ticket #21766 When IPE data compression is enabled, compress the emitted IPE buffer entries and decompress them in the RTS. - - - - - 5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix libzstd detection in configure and RTS Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases and properly check that before IPE data decompression in the RTS. See ticket #21766. - - - - - 69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add note describing IPE data compression See ticket #21766 - - - - - 7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix byte order of IPE data, fix IPE tests Make sure byte order of written IPE buffer entries matches target. Make sure the IPE-related tests properly access the fields of IPE buffer entry nodes with the new IPE layout. This commit also introduces checks to avoid importing modules if IPE compression is not enabled. See ticket #21766. - - - - - 0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix IPE data decompression buffer allocation Capacity of buffers allocated for decompressed IPE data was incorrect due to a misuse of the `ZSTD_findFrameCompressedSize` function. Fix by always storing decompressed size of IPE data in IPE buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine the size of the compressed data. See ticket #21766 - - - - - a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add optional dependencies to ./configure output Changes the configure script to indicate whether libnuma, libzstd, or libdw are being used as dependencies due to their optional features being enabled. - - - - - 09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE-enabled builds to CI - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label - Introduces CI logic to enable IPE data compression - Enables uncompressed IPE data on debug CI job - Regenerates jobs.yaml MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the images repository is meant to ensure that the proper images have libzstd-dev installed. - - - - - 3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Update user's guide and release notes, small fixes Add mention of IPE data compression to user's guide and the release notes for 9.8.1. Also note the impact compression has on binary size in both places. Change IpeBufferListNode compression check so only the value `1` indicates compression. See ticket #21766 - - - - - 41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Remove IPE enabled builds from CI We don't need to explicitly specify the +ipe transformer to test IPE data since there are tests which manually enable IPE information. This commit does leave zstd IPE data compression enabled on the debian CI jobs. - - - - - 982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00 Fix build with 9.2 GHC.Tc.Zonk.Type uses an equality constraint. ghc.nix currently provides 9.2. - - - - - 1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00 Output Lint errors to stderr instead of stdout This is a continuation of 7b095b99, which fixed warnings but not errors. Refs #13342 - - - - - 8e81f140 by sheaf at 2023-06-01T10:56:51-04:00 Refactor lookupExactOrOrig & friends This refactors the panoply of renamer lookup functions relating to lookupExactOrOrig to more graciously handle Exact and Orig names. In particular, we avoid the situation in which we would add Exact/Orig GREs to the tcg_used_gres field, which could cause a panic in bestImport like in #23240. Fixes #23428 - - - - - 5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00 Use the one-shot trick for UM and RewriteM functors As described in Note [The one-shot state monad trick], we shouldn't use derived Functor instances for monads using one-shot. This was done for most of them, but UM and RewriteM were missed. - - - - - 2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00 Fix testsuite skipping Lint setTestOpts() is used to modify the test options for an entire .T file, rather than a single test. If there was a test using collect_compiler_stats, all of the tests in the same file had lint disabled. Fixes #21247 - - - - - 00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00 Add testcases for already fixed #16432 They were fixed by 40c7daed0. Fixes #16432 - - - - - f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00 cleanup: Remove unused field from SelfBoot It is no longer needed since Note [Extra dependencies from .hs-boot files] was deleted in 6998772043. I've also added tildes to Note headers, otherwise they're not detected by the linter. - - - - - 82eacab6 by sheaf at 2023-06-02T09:08:01-04:00 Delete GHC.Tc.Utils.Zonk This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType in commit f62d8195, but I forgot to delete the original module - - - - - 4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00 base: Add build-order import of GHC.Types in GHC.IO.Handle.Types For reasons similar to those described in Note [Depend on GHC.Num.Integer]. Fixes #23411. - - - - - f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00 JS: fix and enhance non-minimized code generation (#22455) Flag -ddisable-js-minimizer was producing invalid code. Fix that and also a few other things to generate nicer JS code for debugging. The added test checks that we don't regress when using the flag. - - - - - f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00 [hadrian] Fix multiline synopsis rendering - - - - - b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00 Elaborate on performance properties of Data.List.++ - - - - - 7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00 Big TcLclEnv and CtLoc refactoring The overall goal of this refactoring is to reduce the dependency footprint of the parser and syntax tree. Good reasons include: - Better module graph parallelisability - Make it easier to migrate error messages without introducing module loops - Philosophically, there's not reason for the AST to depend on half the compiler. One of the key edges which added this dependency was > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv) As this in turn depending on TcM which depends on HscEnv and so on. Therefore the goal of this patch is to move `TcLclEnv` out of `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without incurring a huge dependency chain. The changes in this patch are: * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv * Create new smaller modules for the types used in TcLclEnv New Modules: - GHC.Tc.Types.ErrCtxt - GHC.Tc.Types.BasicTypes - GHC.Tc.Types.TH - GHC.Tc.Types.LclEnv - GHC.Tc.Types.CtLocEnv - GHC.Tc.Errors.Types.PromotionErr Removed Boot File: - {-# SOURCE #-} GHC.Tc.Types * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't participate in restoreLclEnv. * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the location of the implication and constraint. By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no longer depend on the TcM monad and all that entails. Fixes #23389 #23409 - - - - - 3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session This removes the usage of DynFlags from Tc.Utils.TcType so that it no longer depends on GHC.Driver.Session. In general we don't want anything which is a dependency of Language.Haskell.Syntax to depend on GHC.Driver.Session and removing this edge gets us closer to that goal. - - - - - 18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00 Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes Language.Haskell.Syntax end up depending on GHC.Driver.Session. - - - - - 12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session - - - - - eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00 hole fit plugins: Split definition into own module The hole fit plugins are defined in terms of TcM, a type we want to avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own module we can remove this dependency. It also simplifies the necessary boot file. - - - - - 9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Move GHC.Core.Opt.CallerCC Types into separate module This allows `GHC.Driver.DynFlags` to depend on these types without depending on CoreM and hence the entire simplifier pipeline. We can also remove a hs-boot file with this change. - - - - - 52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Remove unecessary SOURCE import - - - - - 698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00 testsuite: Accept new output for CountDepsAst and CountDepsParser tests These are in a separate commit as the improvement to these tests is the cumulative effect of the previous set of patches rather than just the responsibility of the last one in the patchset. - - - - - 58ccf02e by sheaf at 2023-06-05T16:00:47-04:00 TTG: only allow VarBind at GhcTc The VarBind constructor of HsBind is only used at the GhcTc stage. This commit makes that explicit by setting the extension field of VarBind to be DataConCantHappen at all other stages. This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind, and remove some panics. - - - - - 54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00 Generate Addr# access ops programmatically The existing utils/genprimopcode/gen_bytearray_ops.py was relocated and extended for this purpose. Additionally, hadrian now knows about this script and uses it when generating primops.txt - - - - - ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00 ghcup-metadata: Only add Nightly tag when replacing LatestNightly Previously we were always adding the Nightly tag, but this led to all the previous builds getting an increasing number of nightly tags over time. Now we just add it once, when we remove the LatestNightly tag. - - - - - 4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00 Invisible binders in type declarations (#22560) This patch implements @k-binders introduced in GHC Proposal #425 and guarded behind the TypeAbstractions extension: type D :: forall k j. k -> j -> Type data D @k @j a b = ... ^^ ^^ To represent the new syntax, we modify LHsQTyVars as follows: - hsq_explicit :: [LHsTyVarBndr () pass] + hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass] HsBndrVis is a new data type that records the distinction between type variable binders written with and without the @ sign: data HsBndrVis pass = HsBndrRequired | HsBndrInvisible (LHsToken "@" pass) The rest of the patch updates GHC, template-haskell, and haddock to handle the new syntax. Parser: The PsErrUnexpectedTypeAppInDecl error message is removed. The syntax it used to reject is now permitted. Renamer: The @ sign does not affect the scope of a binder, so the changes to the renamer are minimal. See rnLHsTyVarBndrVisFlag. Type checker: There are three code paths that were updated to deal with the newly introduced invisible type variable binders: 1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl 2. checking CUSK: see kcCheckDeclHeader_cusk 3. inference: see kcInferDeclHeader, rejectInvisibleBinders Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv are generalized to work with HsBndrVis. Updates the haddock submodule. Metric Increase: MultiLayerModulesTH_OneShot Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00 JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481) - - - - - e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00 Update CODEOWNERS - - - - - 960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Remove IPE enabled builds from CI" This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951. - - - - - bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Update user's guide and release notes, small fixes" This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7. - - - - - 12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE-enabled builds to CI" This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f. - - - - - dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add optional dependencies to ./configure output" This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58. - - - - - 240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix IPE data decompression buffer allocation" This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a. - - - - - 9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix byte order of IPE data, fix IPE tests" This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327. - - - - - 3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add note describing IPE data compression" This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0. - - - - - fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix libzstd detection in configure and RTS" This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0. - - - - - 1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "IPE data compression" This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553. - - - - - fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE compression to configure" This reverts commit 5d1f2411f4becea8650d12d168e989241edee186. - - - - - 2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Restructure IPE buffer layout" This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91. - - - - - 2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00 Don't report redundant Givens from quantified constraints This fixes #23323 See (RC4) in Note [Tracking redundant constraints] - - - - - 567b32e1 by David Binder at 2023-06-08T18:41:29-04:00 Update the outdated instructions in HACKING.md on how to compile GHC - - - - - 2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00 Restore mingwex dependency on Windows This partially reverts some of the changes in !9475 to make `base` and `ghc-prim` depend on the `mingwex` library on Windows. It also restores the RTS's stubs for `mingwex`-specific symbols such as `_lock_file`. This is done because the C runtime provides `libmingwex` nowadays, and moreoever, not linking against `mingwex` requires downstream users to link against it explicitly in difficult-to-predict circumstances. Better to always link against `mingwex` and prevent users from having to do the guesswork themselves. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for the discussion that led to this. - - - - - 28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00 RtsSymbols.c: Remove mingwex symbol stubs As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows, which means that the RTS no longer needs to declare stubs for the `__mingw_*` family of symbols. Let's remove these stubs to avoid confusion. Fixes #23309. - - - - - 3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00 Consistently use validity checks for TH conversion of data constructors We were checking that TH-spliced data declarations do not look like this: ```hs data D :: Type = MkD Int ``` But we were only doing so for `data` declarations' data constructors, not for `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out the necessary validity checks into its own `cvtDataDefnCons` function and uses it in all of the places where it needs to be. Fixes #22559. - - - - - a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00 Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC pragma for files with module level scope. Instead of simple not deleting the files, we also need to remove them from the TmpFs so they are not deleted later on when all the other files are deleted. There are additional complications because you also need to remove the directory where these files live from the TmpFs so we don't try to delete those later either. I added two tests. 1. Tests simply that -keep-tmp-files works at all with a single module and --make mode. 2. The other tests that temporary files are deleted for other modules which don't enable -keep-tmp-files. Fixes #23339 - - - - - dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00 withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free. Ticket #23305 reports an error where we were attempting to use the logger which was created by withDeferredDiagnostics after its scope had ended. This problem would have been caught by this patch and a validate build: ``` +*** Exception: Use after free +CallStack (from HasCallStack): + error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make ``` This general issue is tracked by #20981 - - - - - 432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00 Don't return complete HscEnv from upsweep By returning a complete HscEnv from upsweep the logger (as introduced by withDeferredDiagnostics) was escaping the scope of withDeferredDiagnostics and hence we were losing error messages. This is reminiscent of #20981, which also talks about writing errors into messages after their scope has ended. See #23305 for details. - - - - - 26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00 Dump `SpecConstr` specialisations separately Introduce a `-ddump-spec-constr` flag which debugs specialisations from `SpecConstr`. These are no longer shown when you use `-ddump-spec`. - - - - - 4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00 Add role annotations to SNat, SSymbol and SChar Ticket #23454 explained it was possible to implement unsafeCoerce because SNat was lacking a role annotation. As these are supposed to be singleton types but backed by an efficient representation the correct annotation is nominal to ensure these kinds of coerces are forbidden. These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85 which was implemented in 532de36870ed9e880d5f146a478453701e9db25d. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170 Fixes #23454 - - - - - 9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00 Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in This broke the sdist generation. Fixes #23489 - - - - - 273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00 Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver. - - - - - b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00 Fix -Wterm-variable-capture scope (#23434) -Wterm-variable-capture wasn't accordant with type variable scoping in associated types, in type classes. For example, this code produced the warning: k = 12 class C k a where type AT a :: k -> Type I solved this issue by reusing machinery of newTyVarNameRn function that is accordand with associated types: it does lookup for each free type variable when we are in the type class context. And in this patch I use result of this work to make sure that -Wterm-variable-capture warns only on implicitly quantified type variables. - - - - - 9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00 Remove redundant case statement in rts/js/mem.js. - - - - - a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00 Change WarningWithFlag to plural WarningWithFlags Resolves #22825 Now each diagnostic can name multiple different warning flags for its reason. There is currently one use case: missing signatures. Currently we need to check which warning flags are enabled when generating the diagnostic, which is against the declarative nature of the diagnostic framework. This patch allows a warning diagnostic to have multiple warning flags, which makes setup more declarative. The WarningWithFlag pattern synonym is added for backwards compatibility The 'msgEnvReason' field is added to MsgEnvelope to store the `ResolvedDiagnosticReason`, which accounts for the enabled flags, and then that is used for pretty printing the diagnostic. - - - - - ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00 Add a test Way for running ghci with Core optimizations Tracking ticket: #23059 This runs compile_and_run tests with optimised code with bytecode interpreter Changed submodules: hpc, process Co-authored-by: Torsten Schmits <git at tryp.io> - - - - - c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00 Configure -Qunused-arguments instead of hardcoding it When GHC invokes clang, it currently passes -Qunused-arguments to discard warnings resulting from GHC using multiple options that aren't used. In this commit, we configure -Qunused-arguments into the Cc options instead of checking if the compiler is clang at runtime and hardcoding the flag into GHC. This is part of the effort to centralise toolchain information in toolchain target files at configure time with the end goal of a runtime retargetable GHC. This also means we don't need to call getCompilerInfo ever, which improves performance considerably (see !10589). Metric Decrease: PmSeriesG T10421 T11303b T12150 T12227 T12234 T12425 T13035 T13253-spj T13386 T15703 T16875 T17836b T17977 T17977b T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T3064 T5030 T5321FD T5321Fun T5837 T6048 T9020 T9198 T9872d T9961 - - - - - 0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00 Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion between different precisions. - - - - - 95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00 Add regression test for #23143 !10541, the fix for #23323, also fixes #23143. Let's add a regression test to ensure that it stays fixed. Fixes #23143. - - - - - ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00 delete GHCi.UI.Tags module and remove remaining references Co-authored-by: Tilde Rose <t1lde at protonmail.com> - - - - - c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Add regression test for 17328 - - - - - de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Skip checking whether constructors are in scope when deriving newtype instances. Fixes #17328 - - - - - 5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00 Don't suggest `DeriveAnyClass` when instance can't be derived. Fixes #19692. Prototypical cases: class C1 a where x1 :: a -> Int data G1 = G1 deriving C1 class C2 a where x2 :: a -> Int x2 _ = 0 data G2 = G2 deriving C2 Both of these used to give this suggestion, but for C1 the suggestion would have failed (generated code with undefined methods, which compiles but warns). Now C2 still gives the suggestion but C1 doesn't. - - - - - 80a0b099 by David Binder at 2023-06-13T09:47:49-04:00 Add testcase for error GHC-00711 to testsuite - - - - - e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00 Add -Wmissing-poly-kind-signatures Implements #22826 This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types. - - - - - f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00 ci: special case in req_host_target_ghc for JS - - - - - b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00 When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions Fixes #23486 - - - - - c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00 Add a testcase for #20076 Remove 'recursive' in the error message, since the error can arise without recursion. - - - - - b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00 Use tcInferFRR to prevent bad generalisation Fixes #23176 - - - - - bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00 ci: Add dependenices on necessary aarch64 jobs for head.hackage ci These need to be added since we started testing aarch64 on head.hackage CI. The jobs will sometimes fail because they will start before the relevant aarch64 job has finished. Fixes #23511 - - - - - a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00 Add standalone kind signatures for Code and TExp CodeQ and TExpQ already had standalone kind signatures even before this change: type TExpQ :: TYPE r -> Kind.Type type CodeQ :: TYPE r -> Kind.Type Now Code and TExp have signatures too: type TExp :: TYPE r -> Kind.Type type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type This is a stylistic change. - - - - - e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeLits.Internal should not be used - - - - - 100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeNats.Internal should not be used - - - - - 078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add more flags for dumping core passes (#23491) - - - - - 1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add tests for dumping flags (#23491) - - - - - 42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00 Provide a demand signature for atomicModifyMutVar.# (#23047) Fixes #23047 - - - - - 8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00 compiler: Cross-reference Note [StgToJS design] In particular, the numeric representations are quite useful context in a few places. - - - - - a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00 Implement the -Wimplicit-rhs-quantification warning (#23510) GHC Proposal #425 "Invisible binders in type declarations" forbids implicit quantification of type variables that occur free on the right-hand side of a type synonym but are not mentioned on the left-hand side. The users are expected to rewrite this using invisible binders: type T1 :: forall a . Maybe a type T1 = 'Nothing :: Maybe a -- old type T1 @a = 'Nothing :: Maybe a -- new Since the @k-binders are a new feature, we need to wait for three releases before we require the use of the new syntax. In the meantime, we ought to provide users with a new warning, -Wimplicit-rhs-quantification, that would detect when such implicit quantification takes place, and include it in -Wcompat. - - - - - 0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00 Minor refactorings to mkSpillInstr and mkLoadInstr Better error messages. And, use the existing `off` constant to reduce duplication. - - - - - 1792b57a by doyougnu at 2023-06-15T03:12:17-04:00 JS: merge util modules Merge Core and StgUtil modules for StgToJS pass. Closes: #23473 - - - - - 469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00 Check visibility of nested foralls in can_eq_nc (#18863) Prior to this change, `can_eq_nc` checked the visibility of the outermost layer of foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here Then it delegated the rest of the work to `can_eq_nc_forall`, which split off all foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here This meant that some visibility flags were completely ignored. We fix this oversight by moving the check to `can_eq_nc_forall`. - - - - - 59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: use regular mask for blocking IO Blocking IO used uninterruptibleMask which should make any thread blocked on IO unreachable by async exceptions (such as those from timeout). This changes it to a regular mask. It's important to note that the nodejs runtime does not actually interrupt the blocking IO when the Haskell thread receives an async exception, and that file positions may be updated and buffers may be written after the Haskell thread has already resumed. Any file descriptor affected by an async exception interruption should therefore be used with caution. - - - - - 907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: nodejs: do not set 'readable' handler on stdin at startup The Haskell runtime used to install a 'readable' handler on stdin at startup in nodejs. This would cause the nodejs system to start buffering the stream, causing data loss if the stdin file descriptor is passed to another process. This change delays installation of the 'readable' handler until the first read of stdin by Haskell code. - - - - - a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: reserve one more virtual (negative) file descriptor This is needed for upcoming support of the process package - - - - - 78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00 Report scoped kind variables at the type-checking phase (#16635) This patch modifies the renamer to respect ScopedTypeVariables in kind signatures. This means that kind variables bound by the outermost `forall` now scope over the type: type F = '[Right @a @() () :: forall a. Either a ()] -- ^^^^^^^^^^^^^^^ ^^^ -- in scope here bound here However, any use of such variables is a type error, because we don't have type-level lambdas to bind them in Core. This is described in the new Note [Type variable scoping errors during type check] in GHC.Tc.Types. - - - - - 4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00 JS: testsuite: use correct ticket number Replace #22356 with #22349 for these tests because #22356 has been fixed but now these tests fail because of #22349. - - - - - 15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: testsuite: update ticket numbers - - - - - 08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: more triage - - - - - e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00 Fix test T18522-deb-ppr Fixes #23509 - - - - - 62c56416 by Ben Price at 2023-06-16T05:52:39-04:00 Lint: more details on "Occurrence is GlobalId, but binding is LocalId" This is helpful when debugging a pass which accidentally shadowed a binder. - - - - - d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00 Clean a stray bit of text in user guide - - - - - 93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00 testsuite: Add forall visibility test cases The added tests ensure that the type checker does not confuse visible and invisible foralls. VisFlag1: kind-checking type applications and inferred type variable instantiations VisFlag1_ql: kind-checking Quick Look instantiations VisFlag2: kind-checking type family instances VisFlag3: checking kind annotations on type parameters of associated type families VisFlag4: checking kind annotations on type parameters in type declarations with SAKS VisFlag5: checking the result kind annotation of data family instances - - - - - a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00 JS: factorize SaneDouble into its own module Follow-up of b159e0e9 whose ticket is #22736 - - - - - 0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00 Add tests for #21973 - - - - - 640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation for `<**>` - - - - - 2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00 Update text - - - - - 1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00 Update examples - - - - - 7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation to actually display code correctly - - - - - 800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00 Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512) GHC Proposal #425 "Invisible binders in type declarations" restricts the scope of type and data family instances as follows: In type family and data family instances, require that every variable mentioned on the RHS must also occur on the LHS. For example, here are three equivalent type instance definitions accepted before this patch: type family F1 a :: k type instance F1 Int = Any :: j -> j type family F2 a :: k type instance F2 @(j -> j) Int = Any :: j -> j type family F3 a :: k type instance forall j. F3 Int = Any :: j -> j - In F1, j is implicitly quantified and it occurs only on the RHS; - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS; - In F3, j is explicitly quantified. Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted. - - - - - 9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: testsuite: use correct ticket numbers - - - - - c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: don't dump eventlog to stderr by default Fix T16707 Bump stm submodule - - - - - 89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00 Fix TH name lookup for symbolic tycons (#23525) - - - - - cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00 IPE data compression IPE data resulting from the `-finfo-table-map` flag may now be compressed by configuring the GHC build with the `--enable-ipe-data-compression` flag. This results in about a 20% reduction in the size of IPE-enabled build results. The compression library, zstd, may optionally be statically linked by configuring with the `--enabled-static-libzstd` flag (on non-darwin platforms) libzstd version 1.4.0 or greater is required. - - - - - 0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00 Add `IfaceWarnings` to represent the `ModIface`-storable parts of a `Warnings GhcRn`. Fixes #23516 - - - - - 3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00 Avoid desugaring non-recursive lets into recursive lets This prepares for having linear let expressions in the frontend. When desugaring lets, SPECIALISE statements create more copies of a let binding. Because of the rewrite rules attached to the bindings, there are dependencies between the generated binds. Before this commit, we simply wrapped all these in a mutually recursive let block, and left it to the simplified to sort it out. With this commit: we are careful to generate the bindings in dependency order, so that we can wrap them in consecutive lets (if the source is non-recursive). - - - - - 9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00 rts: Do not call exit() from SIGINT handler Previously `shutdown_handler` would call `stg_exit` if the scheduler was Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However, `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit` handlers). The only safe thing to do in this situation is to call `_exit`, which terminates with minimal cleanup. Fixes #23417. - - - - - 7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00 Bump Cabal submodule This requires changing the recomp007 test because now cabal passes `this-unit-id` to executable components, and that unit-id contains a hash which includes the ABI of the dependencies. Therefore changing the dependencies means that -this-unit-id changes and recompilation is triggered. The spririt of the test is to test GHC's recompilation logic assuming that `-this-unit-id` is constant, so we explicitly pass `-ipid` to `./configure` rather than letting `Cabal` work it out. - - - - - 1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00 [feat] add a hint to `HasField` error message - add a hint that indicates that the record that the record dot is used on might just be missing a field - as the intention of the programmer is not entirely clear, it is only shown if the type is known - This addresses in part issue #22382 - - - - - b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00 rts/ipe: Fix unused lock warning - - - - - 6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00 rts/ProfilerReportJson: Fix memory leak - - - - - 1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Various warnings fixes - - - - - 471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix printf format mismatch - - - - - 80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect #include <sys/poll.h> According to Alpine's warnings and poll(2), <poll.h> should be preferred. - - - - - ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00 nonmoving: Fix unused definition warrnings - - - - - 6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00 Disable futimens on Darwin. See #22938 - - - - - b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect CPP guard - - - - - 94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00 hadrian: Ensure that -Werror is passed when compiling the RTS. Previously the `+werror` transformer would only pass `-Werror` to GHC, which does not ensure that the same is passed to the C compiler when building the RTS. Arguably this is itself a bug but for now we will just work around this by passing `-optc-Werror` to GHC. I tried to enable `-Werror` in all C compilations but the boot libraries are something of a portability nightmare. - - - - - 5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Disable `#pragma GCC`s on clang compilers Otherwise the build fails due to warnings. See #23530. - - - - - cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix capitalization of prototype - - - - - 17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect format specifier - - - - - 0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00 JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576) - - - - - 3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Memory usage fixes for Haddock - Do not include `mi_globals` in the `NoBackend` backend. It was only included for Haddock, but Haddock does not actually need it. This causes a 200MB reduction in max residency when generating haddocks on the Agda codebase (roughly 1GB to 800MB). - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to be written to interface files using `-fwrite-interface` Bumps haddock submodule. Metric Decrease: haddock.base - - - - - 8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Fix associated data family doc structure items Associated data families were being given their own export DocStructureItems, which resulted in them being documented separately from their classes in haddocks. This commit fixes it. - - - - - 4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: implement TH support - Add ghc-interp.js bootstrap script for the JS interpreter - Interactively link and execute iserv code from the ghci package - Incrementally load and run JS code for splices into the running iserv Co-authored-by: Luite Stegeman <stegeman at gmail.com> - - - - - 3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Don't use getKey - - - - - f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Stg: return imported FVs This is used to determine what to link when using the interpreter. For now it's only used by the JS interpreter but it could easily be used by the native interpreter too (instead of extracting names from compiled BCOs). - - - - - fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Fix some recompilation avoidance tests - - - - - a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00 TH_import_loop is now broken as expected - - - - - dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: always recompile when TH is enabled (cf #23013) - - - - - 711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00 Add support for deprecating exported items (proposal #134) This is an implementation of the deprecated exports proposal #134. The proposal introduces an ability to introduce warnings to exports. This allows for deprecating a name only when it is exported from a specific module, rather than always depreacting its usage. In this example: module A ({-# DEPRECATED "do not use" #-} x) where x = undefined --- module B where import A(x) `x` will emit a warning when it is explicitly imported. Like the declaration warnings, export warnings are first accumulated within the `Warnings` struct, then passed into the ModIface, from which they are then looked up and warned about in the importing module in the `lookup_ie` helpers of the `filterImports` function (for the explicitly imported names) and in the `addUsedGRE(s)` functions where they warn about regular usages of the imported name. In terms of the AST information, the custom warning is stored in the extension field of the variants of the `IE` type (see Trees that Grow for more information). The commit includes a bump to the haddock submodule added in MR #28 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00 configure: Bump version to 9.8 Bumps Haddock submodule - - - - - 4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00 configure: Bump version to 9.9 Bumps haddock submodule. - - - - - 5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00 rts: Work around missing prototypes errors Darwin's toolchain inexpliciably claims that `write_barrier` and friends have declarations without prototypes, despite the fact that (a) they are definitions, and (b) the prototypes appear only a few lines above. Work around this by making the definitions proper prototypes. - - - - - 43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00 ghcup-metadata: Fix date modifier (M = minutes, m = month) Fixes #23552 - - - - - 564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00 Support large stack frames/offsets in GHCi bytecode interpreter Bytecode instructions like PUSH_L (push a local variable) contain an operand that refers to the stack slot. Before this patch, the operand type was SmallOp (Word16), limiting the maximum stack offset to 65535 words. This could cause compiler panics in some cases (See #22888). This patch changes the operand type for stack offsets from SmallOp to Op, removing the stack offset limit. Fixes #22888 - - - - - 8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00 JS: support levity-polymorphic datatypes (#22360,#22291) - thread knowledge about levity into PrimRep instead of panicking - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.) Doing this also fixes #22291 (test added). There is a small performance hit (~1% more allocations). Metric Increase: T18698a T18698b - - - - - 5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00 MR Review Template: Mention "Blocked on Review" label In order to improve our MR review processes we now have the label "Blocked on Review" which allows people to signal that a MR is waiting on a review to happen. See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html - - - - - 4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00 Move MR template to Default.md This makes it more obvious what you have to modify to affect the default template rather than looking in the project settings. - - - - - 522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00 Revert "Avoid desugaring non-recursive lets into recursive lets" This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef. Fixes #23550 - - - - - c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00 Propagate breakpoint information when inlining across modules Tracking ticket: #23394 MR: !10448 * Add constructor `IfaceBreakpoint` to `IfaceTickish` * Store breakpoint data in interface files * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's state * Allocate module name in `ModBreaks`, like `BreakArray` * Lookup breakpoint by module name in GHCi * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the linker when breakpoints are enabled, and panicking when `ModBreaks` is missing - - - - - 6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00 Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's - - - - - e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00 Remove arity inference in type declarations (#23514) Arity inference in type declarations was introduced as a workaround for the lack of @k-binders. They were added in 4aea0a72040, so I simplified all of this by simply removing arity inference altogether. This is part of GHC Proposal #425 "Invisible binders in type declarations". - - - - - 459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00 Relax defaulting of RuntimeRep/Levity when printing Fixes #16468 MR: !10702 Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall - - - - - 151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00 Remove duplicate link label in linear types docs - - - - - ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00 Stop configuring unused Ld command in `settings` GHC has no direct dependence on the linker. Rather, we depend upon the C compiler for linking and an object-merging program (which is typically `ld`) for production of GHCi objects and merging of C stubs into final object files. Despite this, for historical reasons we still recorded information about the linker into `settings`. Remove these entries from `settings`, `hadrian/cfg/system.config`, as well as the `configure` logic responsible for this information. Closes #23566. - - - - - bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00 Remove extraneous debug output - - - - - 7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00 Work with unset vars in -e mode - - - - - 49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00 Pass positional arguments in their positions By quoting $cmd, the default "bash -i" is a single argument to run, and no file named "bash -i" actually exists to be run. - - - - - 887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00 Handle unset value in -e context - - - - - 5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00 Configure CPP into settings There is a distinction to be made between the Haskell Preprocessor and the C preprocessor. The former is used to preprocess Haskell files, while the latter is used in C preprocessing such as Cmm files. In practice, they are both the same program (usually the C compiler) but invoked with different flags. Previously we would, at configure time, configure the haskell preprocessor and save the configuration in the settings file, but, instead of doing the same for CPP, we had hardcoded in GHC that the CPP program was either `cc -E` or `cpp`. This commit fixes that asymmetry by also configuring CPP at configure time, and tries to make more explicit the difference between HsCpp and Cpp (see Note [Preprocessing invocations]). Note that we don't use the standard CPP and CPPFLAGS to configure Cpp, but instead use the non-standard --with-cpp and --with-cpp-flags. The reason is that autoconf sets CPP to "$CC -E", whereas we expect the CPP command to be configured as a standalone executable rather than a command. These are symmetrical with --with-hs-cpp and --with-hs-cpp-flags. Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP to be C99 compatible through -optP, since we now configure that into settings. Closes #23422 - - - - - 5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00 hadrian: Always canonicalize topDirectory Hadrian's `topDirectory` is intended to provide an absolute path to the root of the GHC tree. However, if the tree is reached via a symlink this One question here is whether the `canonicalizePath` call is expensive enough to warrant caching. In a quick microbenchmark I observed that `canonicalizePath "."` takes around 10us per call; this seems sufficiently low not to worry. Alternatively, another approach here would have been to rather move the canonicalization into `m4/fp_find_root.m4`. This would have avoided repeated canonicalization but sadly path canonicalization is a hard problem in POSIX shell. Addresses #22451. - - - - - b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00 Optimise ELF linker (#23464) - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF` - cache shndx table in ObjectCode - run `checkProddableBlock` only with debug rts - - - - - 30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE - - - - - b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Drop MO_WriteBarrier rts: Drop write_barrier - - - - - 7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00 rts: Drop load_store_barrier() This is no longer used. - - - - - d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop last instances of prim_{write,read}_barrier - - - - - 965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Eliminate remaining uses of load_load_barrier - - - - - 0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00 compiler: Drop MO_ReadBarrier - - - - - 7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop load_load_barrier This is no longer used. - - - - - 9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00 Delete write_barrier function - - - - - bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Make collectFreshWeakPtrs definition a prototype x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs needs to be a prototype. - - - - - ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00 Fix number of free double regs D1..D4 are defined for aarch64 and thus not free. - - - - - c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00 Fix typechecking of promoted empty lists The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of `'[]` (see the newly added `T23543` test case for an example), but the `'[]` case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type checker]`. There are some benign changes to test cases' expected output due to the new code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`. Fixes #23543. - - - - - fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00 Configure MergeObjs supports response files rather than Ld The previous configuration script to test whether Ld supported response files was * Incorrect (see #23542) * Used, in practice, to check if the *merge objects tool* supported response files. This commit modifies the macro to run the merge objects tool (rather than Ld), using a response file, and checking the result with $NM Fixes #23542 - - - - - 78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00 JS: fix JS stack printing (#23565) - - - - - 9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00 Add -fpolymorphic-specialisation flag (off by default at all optimisation levels) Polymorphic specialisation has led to a number of hard to diagnose incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so this commit introduces a flag `-fpolymorhphic-specialisation` which allows users to turn on this experimental optimisation if they are willing to buy into things going very wrong. Ticket #23469 - - - - - b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00 Rip out runtime linker/compiler checks We used to choose flags to pass to the toolchain at runtime based on the platform running GHC, and in this commit we drop all of those runtime linker checks Ultimately, this represents a change in policy: We no longer adapt at runtime to the toolchain being used, but rather make final decisions about the toolchain used at /configure time/ (we have deleted Note [Run-time linker info] altogether!). This works towards the goal of having all toolchain configuration logic living in the same place, which facilities the work towards a runtime-retargetable GHC (see #19877). As of this commit, the runtime linker/compiler logic was moved to autoconf, but soon it, and the rest of the existing toolchain configuration logic, will live in the standalone ghc-toolchain program (see !9263) In particular, what used to be done at runtime is now as follows: * The flags -Wl,--no-as-needed for needed shared libs are configured into settings * The flag -fstack-check is configured into settings * The check for broken tables-next-to-code was outdated * We use the configured c compiler by default as the assembler program * We drop `asmOpts` because we already configure -Qunused-arguments flag into settings (see !10589) Fixes #23562 Co-author: Rodrigo Mesquita (@alt-romes) - - - - - 8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00 Define FFI_GO_CLOSURES The libffi shipped with Apple's XCode toolchain does not contain a definition of the FFI_GO_CLOSURES macro, despite containing references to said macro. Work around this by defining the macro, following the model of a similar workaround in OpenJDK [1]. [1] https://github.com/openjdk/jdk17u-dev/pull/741/files - - - - - d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00 base: Fix incorrect CPP guard This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`. - - - - - 7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00 rts/Trace: Ensure that debugTrace arguments are used As debugTrace is a macro we must take care to ensure that the fact is clear to the compiler lest we see warnings. - - - - - cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00 rts: Various warnings fixes - - - - - dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00 hadrian: Ignore warnings in unix and semaphore-compat - - - - - d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00 hadrian: Fix dependencies of docs:* rule For the docs:* rule we need to actually build the package rather than just the haddocks for the dependent packages. Therefore we depend on the .conf files of the packages we are trying to build documentation for as well as the .haddock files. Fixes #23472 - - - - - cec90389 by sheaf at 2023-06-30T12:39:27-04:00 Add tests for #22106 Fixes #22106 - - - - - 083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 - - - - - fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00 rts: Ensure that pinned allocations respect block size Previously, it was possible for pinned, aligned allocation requests to allocate beyond the end of the pinned accumulator block. Specifically, we failed to account for the padding needed to achieve the requested alignment in the "large object" check. With large alignment requests, this can result in the allocator using the capability's pinned object accumulator block to service a request which is larger than `PINNED_EMPTY_SIZE`. To fix this we reorganize `allocatePinned` to consistently account for the alignment padding in all large object checks. This is a bit subtle as we must handle the case of a small allocation request filling the accumulator block, as well as large requests. Fixes #23400. - - - - - 98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00 testsuite: Add test for #23400 - - - - - 4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00 ghc-heap: Support for BLOCKING_QUEUE closures - - - - - 03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00 Add some structured diagnostics in Tc/Validity.hs This addresses the work of ticket #20118 Created the following constructors for TcRnMessage - TcRnInaccessibleCoAxBranch - TcRnPatersonCondFailure - - - - - 6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Add failing test case for #23492 - - - - - 356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Use generated src span for catch-all case of record selector functions This fixes #23492. The problem was that we used the real source span of the field declaration for the generated catch-all case in the selector function, in particular in the generated call to `recSelError`, which meant it was included in the HIE output. Using `generatedSrcSpan` instead means that it is not included. - - - - - 3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils - - - - - dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Construct catch-all default case using helpers GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors - - - - - 0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00 Add regression test for #23549 - - - - - 32741743 by Alexis King at 2023-07-03T03:31:36-04:00 perf tests: Increase default stack size for MultiLayerModules An unhelpfully small stack size appears to have been the real culprit behind the metric fluctuations in #19293. Debugging metric decreases triggered by !10729 helped to finally identify the problem. Metric Decrease: MultiLayerModules MultiLayerModulesTH_Make T13701 T14697 - - - - - 82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00 Add missing void prototypes to rts functions See #23561. - - - - - 6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00 gitlab-ci: Refactor compilation of gen_ci Flakify and document it, making it far less sensitive to the build environment. - - - - - aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00 testsuite: Update documentation - - - - - 924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00 Better error for data deriving of type synonym/family. Closes #23522 - - - - - 4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00 Fix some broken links and typos - - - - - de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00 configure: Rip out Solaris dyld check Solaris 11 was released over a decade ago and, moreover, I doubt we have any Solaris users - - - - - 59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00 CI: add JS release and debug builds, regen CI jobs - - - - - 679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00 testsuite: Do not require CUSKs Numerous tests make use of CUSKs (complete user-supplied kinds), a legacy feature scheduled for deprecation. In order to proceed with the said deprecation, the tests have been updated to use SAKS instead (standalone kind signatures). This also allows us to remove the Haskell2010 language pragmas that were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021. - - - - - 945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00 gitlab: Drop backport-for-8.8 MR template Its usefulness has long passed. - - - - - 66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00 EPA: Simplify GHC/Parser.y comb2 Use the HasLoc instance from Ast.hs to allow comb2 to work with anything with a SrcSpan This gets rid of the custom comb2A, comb2Al, comb2N functions, and removes various reLoc calls. - - - - - 2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00 Fix deprecation warning when deprecated identifier is from another module A stray 'Just' was being printed in the deprecation message. Fixes #23573 - - - - - 46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00 rts: Don't rely on initializers for sigaction_t As noted in #23577, CentOS's ancient toolchain throws spurious missing-field-initializer warnings. - - - - - ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Don't treat -Winline warnings as fatal Such warnings are highly dependent upon the toolchain, platform, and build configuration. It's simply too fragile to rely on these. - - - - - 3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Only pass -Wno-nonportable-include-path on Darwin This flag, which was introduced due to #17798, is only understood by Clang and consequently throws warnings on platforms using gcc. Sadly, there is no good way to treat such warnings as non-fatal with `-Werror` so for now we simply make this flag specific to platforms known to use Clang and case-insensitive filesystems (Darwin and Windows). See #23577. - - - - - 4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00 Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals - - - - - 2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00 compiler: Make OccSet opaque - - - - - cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00 Add Note about why we need forall in Code to be on the right - - - - - fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00 Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall. - - - - - 9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00 Improve the situation with the stimes cycle Currently the Semigroup stimes cycle is resolved in GHC.Base by importing stimes implementations from a hs-boot file. Resolve the cycle using hs-boot files for required classes (Num, Integral) instead. Now stimes can be defined directly in GHC.Base, making inlining and specialization possible. This leads to some new boot files for `GHC.Num` and `GHC.Real`, the methods for those are only used to implement `stimes` so it doesn't appear that these boot files will introduce any new performance traps. Metric Decrease: T13386 T8095 Metric Increase: T13253 T13386 T18698a T18698b T19695 T8095 - - - - - 9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00 Refactor Unique to be represented by Word64 In #22010 we established that Int was not always sufficient to store all the uniques we generate during compilation on 32-bit platforms. This commit addresses that problem by using Word64 instead of Int for uniques. The core of the change is in GHC.Core.Types.Unique and GHC.Core.Types.Unique.Supply. However, the representation of uniques is used in many other places, so those needed changes too. Additionally, the RTS has been extended with an atomic_inc64 operation. One major change from this commit is the introduction of the Word64Set and Word64Map data types. These are adapted versions of IntSet and IntMap from the containers package. These are planned to be upstreamed in the future. As a natural consequence of these changes, the compiler will be a bit slower and take more space on 32-bit platforms. Our CI tests indicate around a 5% residency increase. Metric Increase: CoOpt_Read CoOpt_Singletons LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot RecordUpdPerf T10421 T10547 T12150 T12227 T12234 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T13386 T13719 T14683 T14697 T14766 T15164 T15703 T16577 T16875 T17516 T18140 T18223 T18282 T18304 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T3294 T4801 T5030 T5321FD T5321Fun T5631 T5642 T5837 T6048 T783 T8095 T9020 T9198 T9233 T9630 T9675 T9872a T9872b T9872b_defer T9872c T9872d T9961 TcPlugin_RewritePerf UniqLoop WWRec hard_hole_fits - - - - - 6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00 Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro - - - - - 40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00 Substitute free variables captured by breakpoints in SpecConstr Fixes #23267 - - - - - 2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00 Reinstate untouchable variable error messages This extra bit of information was accidentally being discarded after a refactoring of the way we reported problems when unifying a type variable with another type. This patch rectifies that. - - - - - 53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00 configure: Drop Clang command from settings Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the `runClang` function, and no longer need to configure into settings the Clang command. We used to determine options at runtime to pass clang when it was used as an assembler, but now that we configure at configure time we no longer need to. - - - - - 6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00 Filter out nontrivial substituted expressions in substTickish Fixes #23272 - - - - - 41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: testsuite: use req_c predicate instead of js_broken - - - - - 74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: implement some file primitives (lstat,rmdir) (#22374) - Implement lstat and rmdir. - Implement base_c_s_is* functions (testing a file type) - Enable passing tests - - - - - 7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: cleanup utils (#23314) - Removed unused code - Don't export unused functions - Move toTypeList to Closure module - - - - - f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: rename VarType/Vt into JSRep - - - - - 19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: remove custom PrimRep conversion (#23314) We use the usual conversion to PrimRep and then we convert these PrimReps to JSReps. - - - - - d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: don't use isRuntimeRepKindedTy in JS FFI - - - - - 8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file Fixes #23600 - - - - - e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Use dynamically linked alpine bindists In theory these will work much better on alpine to allow people to build statically linked applications there. We don't need to distribute a statically linked application ourselves in order to allow that. Fixes #23602 - - - - - b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00 Drop circle-ci-job.sh - - - - - 9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00 testsuite: Allow preservation of unexpected output Here we introduce a new flag to the testsuite driver, --unexpected-output-dir=<dir>, which allows the user to ask the driver to preserve unexpected output from tests. The intent is for this to be used in CI to allow users to more easily fix unexpected platform-dependent output. - - - - - 48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00 gitlab-ci: Preserve unexpected output Here we enable use of the testsuite driver's `--unexpected-output-dir` flag by CI, preserving the result as an artifact for use by users. - - - - - 76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00 driver: Fix -S with .cmm files There was an oversight in the driver which assumed that you would always produce a `.o` file when compiling a .cmm file. Fixes #23610 - - - - - 6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00 Update Hadrian's stack.yaml - - - - - 1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00 compiler: Rework ShowSome Previously the field used to filter the sub-declarations to show was rather ad-hoc and was only able to show at most one sub-declaration. - - - - - 8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00 testsuite: Add test to catch changes in core libraries This adds testing infrastructure to ensure that changes in core libraries (e.g. `base` and `ghc-prim`) are caught in CI. - - - - - ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00 Deprecate Data.List.NonEmpty.unzip - - - - - 5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00 Drop latent mentions of -split-objs Closes #21134. - - - - - a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00 Add warn_and_run test kind This is a compile_and_run variant which also captures the GHC's stderr. The warn_and_run name is best I can come up with, as compile_and_run is taken. This is useful specifically for testing warnings. We want to test that when warning triggers, and it's not a false positive, i.e. that the runtime behaviour is indeed "incorrect". As an example a single test is altered to use warn_and_run - - - - - c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00 configure: Don't use ld.gold on i386 ld.gold appears to produce invalid static constructor tables on i386. While ideally we would add an autoconf check to check for this brokenness, sadly such a check isn't easy to compose. Instead to summarily reject such linkers on i386. Somewhat hackily closes #23579. - - - - - 054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00 Add since annotations for Data.Foldable1 - - - - - 550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00 JS: support -this-unit-id for programs in the linker (#23613) - - - - - d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00 Bump text submodule - - - - - 8e11630e by jade at 2023-07-10T16:58:40-04:00 Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007) As suggested in #20007 and implemented in !8895, trying to import type operators will suggest a fix to use the 'type' keyword, without considering whether ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled, alongside the suggestion of adding the 'type' keyword. - - - - - 61b1932e by sheaf at 2023-07-10T16:59:26-04:00 tyThingLocalGREs: include all DataCons for RecFlds The GREInfo for a record field should include the collection of all the data constructors of the parent TyCon that have this record field. This information was being incorrectly computed in the tyThingLocalGREs function for a DataCon, as we were not taking into account other DataCons with the same parent TyCon. Fixes #23546 - - - - - e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00 EPA: Simplify GHC/Parser.y comb3 A follow up to !10743 - - - - - ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00 Document that compareByteArrays# is available since ghc-prim-0.5.2.0 - - - - - 4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00 Revert "Bump text submodule" This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a. This commit requires that we bootstrap with ghc-9.4, which we do not require until #23195 has been completed. Subsequently this has broken nighty jobs such as the rocky8 job which in turn has broken nightly releases. - - - - - d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Fingerprint more code generation flags Previously our recompilation check was quite inconsistent in its coverage of non-optimisation code generation flags. Specifically, we failed to account for most flags that would affect the behavior of generated code in ways that might affect the result of a program's execution (e.g. `-feager-blackholing`, `-fstrict-dicts`) Closes #23369. - - - - - eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Record original thunk info tables on stack Here we introduce a new code generation option, `-forig-thunk-info`, which ensures that an `stg_orig_thunk_info` frame is pushed before every update frame. This can be invaluable when debugging thunk cycles and similar. See Note [Original thunk info table frames] for details. Closes #23255. - - - - - 4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00 Fix wrong MIN_VERSION_GLASGOW_HASKELL macros I forgot to change these after rebasing. - - - - - dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00 Hadrian: enable GHCi support on riscv64 - - - - - 09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00 JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628) - - - - - 29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00 Remove references to make build system in mk/build.mk Fixes #23636 - - - - - 630e3026 by sheaf at 2023-07-12T11:26:43-04:00 Valid hole fits: don't panic on a Given The function GHC.Tc.Errors.validHoleFits would end up panicking when encountering a Given constraint. To fix this, it suffices to filter out the Givens before continuing. Fixes #22684 - - - - - c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00 Use deb10 for i386 bindists deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10 Fixes #23585 - - - - - bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00 Fix #23567, a specializer bug Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834 The testcase isn't ideal because it doesn't detect the bug in master, unless doNotUnbox is removed as in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692. But I have confirmed that with that modification, it fails before and passes afterwards. - - - - - 84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 Comments - - - - - b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 updates to comments - - - - - 2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 changes - - - - - 6143838a by sheaf at 2023-07-13T08:02:17-04:00 Fix deprecation of record fields Commit 3f374399 inadvertently broke the deprecation/warning mechanism for record fields due to its introduction of record field namespaces. This patch ensures that, when a top-level deprecation is applied to an identifier, it applies to all the record fields as well. This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of NameSpaces but to look up all NameSpaces and filter out the irrelevant ones. - - - - - 6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00 Introduce greInfo, greParent These are simple helper functions that wrap the internal field names gre_info, gre_par. - - - - - 7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00 Refactor lookupGRE_... functions This commit consolidates all the logic for looking up something in the Global Reader Environment into the single function lookupGRE. This allows us to declaratively specify all the different modes of looking up in the GlobalRdrEnv, and avoids manually passing around filtering functions as was the case in e.g. the function GHC.Rename.Env.lookupSubBndrOcc_helper. ------------------------- Metric Decrease: T8095 ------------------------- ------------------------- Metric Increase: T8095 ------------------------- - - - - - 5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00 configure: Drop DllWrap command We used to configure into settings a DllWrap command for windows builds and distributions, however, we no longer do, and dllwrap is effectively unused. This simplification is motivated in part by the larger toolchain-selection project (#19877, !9263) - - - - - e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00 base: fix haddock syntax in GHC.Profiling - - - - - 0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00 Revert "CI: add JS release and debug builds, regen CI jobs" This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af. This commit added two duplicate jobs on all validate pipelines, so we are reverting for now whilst we work out what the best way forward is. Ticket #23618 - - - - - 54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00 EPA: Simplify GHC/Parser.y sLL Follow up to !10743 - - - - - c8863828 by sheaf at 2023-07-15T03:24:06-04:00 Configure: canonicalise PythonCmd on Windows This change makes PythonCmd resolve to a canonical absolute path on Windows, which prevents HLS getting confused (now that we have a build-time dependency on python). fixes #23652 - - - - - ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00 Improve Note [Binder-swap during float-out] - - - - - cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00 Equality of forall-types is visibility aware This patch finally (I hope) nails the question of whether (forall a. ty) and (forall a -> ty) are `eqType`: they aren't! There is a long discussion in #22762, plus useful Notes: * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare * Note [Comparing visiblities] in GHC.Core.TyCo.Compare * Note [ForAllCo] in GHC.Core.TyCo.Rep It also establishes a helpful new invariant for ForAllCo, and ForAllTy, when the bound variable is a CoVar:in that case the visibility must be coreTyLamForAllTyFlag. All this is well documented in revised Notes. - - - - - 7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00 List and Tuple<n>: update documentation Add the missing changelog.md entries and @since-annotations. - - - - - 2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00 Type patterns (#22478, #18986) Improved name resolution and type checking of type patterns in constructors: 1. HsTyPat: a new dedicated data type that represents type patterns in HsConPatDetails instead of reusing HsPatSigType 2. rnHsTyPat: a new function that renames a type pattern and collects its binders into three groups: - explicitly bound type variables, excluding locally bound variables - implicitly bound type variables from kind signatures (only if ScopedTypeVariables are enabled) - named wildcards (only from kind signatures) 2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat 2b. rnImplcitTvBndrs: removed because no longer needed 3. collect_pat: updated to collect type variable binders from type patterns (this means that types and terms use the same infrastructure to detect conflicting bindings, unused variables and name shadowing) 3a. CollVarTyVarBinders: a new CollectFlag constructor that enables collection of type variables 4. tcHsTyPat: a new function that typechecks type patterns, capable of handling polymorphic kinds. See Note [Type patterns: binders and unifiers] Examples of code that is now accepted: f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing g :: forall a. Proxy a -> ... g (P @a) = ... -- also triggers -Wname-shadowing h (P @($(TH.varT (TH.mkName "t")))) = ... -- t is bound at splice time j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected data T where MkT :: forall (f :: forall k. k -> Type). f Int -> f Maybe -> T k :: T -> () k (MkT @f (x :: f Int) (y :: f Maybe)) = () -- f :: forall k. k -> Type Examples of code that is rejected with better error messages: f (Left @a @a _) = ... -- new message: -- • Conflicting definitions for ‘a’ -- Bound at: Test.hs:1:11 -- Test.hs:1:14 Examples of code that is now rejected: {-# OPTIONS_GHC -Werror=unused-matches #-} f (P @a) = () -- Defined but not used: type variable ‘a’ - - - - - eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00 Don't use substTyUnchecked in newMetaTyVar There were some comments that explained that we needed to use an unchecked substitution function because of issue #12931, but that has since been fixed, so we should be able to use substTy instead now. - - - - - c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00 rnImports: var shouldn't import NoFldSelectors In an import declaration such as import M ( var ) the import of the variable "var" should **not** bring into scope record fields named "var" which are defined with NoFieldSelectors. Doing so can cause spurious "unused import" warnings, as reported in ticket #23557. Fixes #23557 - - - - - 1af2e773 by sheaf at 2023-07-17T02:48:19-04:00 Suggest similar names in imports This commit adds similar name suggestions when importing. For example module A where { spelling = 'o' } module B where { import B ( speling ) } will give rise to the error message: Module ‘A’ does not export ‘speling’. Suggested fix: Perhaps use ‘spelling’ This also provides hints when users try to import record fields defined with NoFieldSelectors. - - - - - 654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00 EPA: Store leading AnnSemi for decllist in al_rest This simplifies the markAnnListA implementation in ExactPrint - - - - - 22565506 by sheaf at 2023-07-17T21:12:59-04:00 base: add COMPLETE pragma to BufferCodec PatSyn This implements CLC proposal #178, rectifying an oversight in the implementation of CLC proposal #134 which could lead to spurious pattern match warnings. https://github.com/haskell/core-libraries-committee/issues/178 https://github.com/haskell/core-libraries-committee/issues/134 - - - - - 860f6269 by sheaf at 2023-07-17T21:13:00-04:00 exactprint: silence incomplete record update warnings - - - - - df706de3 by sheaf at 2023-07-17T21:13:00-04:00 Re-instate -Wincomplete-record-updates Commit e74fc066 refactored the handling of record updates to use the HsExpanded mechanism. This meant that the pattern matching inherent to a record update was considered to be "generated code", and thus we stopped emitting "incomplete record update" warnings entirely. This commit changes the "data Origin = Source | Generated" datatype, adding a field to the Generated constructor to indicate whether we still want to perform pattern-match checking. We also have to do a bit of plumbing with HsCase, to record that the HsCase arose from an HsExpansion of a RecUpd, so that the error message continues to mention record updates as opposed to a generic "incomplete pattern matches in case" error. Finally, this patch also changes the way we handle inaccessible code warnings. Commit e74fc066 was also a regression in this regard, as we were emitting "inaccessible code" warnings for case statements spuriously generated when desugaring a record update (remember: the desugaring mechanism happens before typechecking; it thus can't take into account e.g. GADT information in order to decide which constructors to include in the RHS of the desugaring of the record update). We fix this by changing the mechanism through which we disable inaccessible code warnings: we now check whether we are in generated code in GHC.Tc.Utils.TcMType.newImplication in order to determine whether to emit inaccessible code warnings. Fixes #23520 Updates haddock submodule, to avoid incomplete record update warnings - - - - - 1d05971e by sheaf at 2023-07-17T21:13:00-04:00 Propagate long-distance information in do-notation The preceding commit re-enabled pattern-match checking inside record updates. This revealed that #21360 was in fact NOT fixed by e74fc066. This commit makes sure we correctly propagate long-distance information in do blocks, e.g. in ```haskell data T = A { fld :: Int } | B f :: T -> Maybe T f r = do a at A{} <- Just r Just $ case a of { A _ -> A 9 } ``` we need to propagate the fact that "a" is headed by the constructor "A" to see that the case expression "case a of { A _ -> A 9 }" cannot fail. Fixes #21360 - - - - - bea0e323 by sheaf at 2023-07-17T21:13:00-04:00 Skip PMC for boring patterns Some patterns introduce no new information to the pattern-match checker (such as plain variable or wildcard patterns). We can thus skip doing any pattern-match checking on them when the sole purpose for doing so was introducing new long-distance information. See Note [Boring patterns] in GHC.Hs.Pat. Doing this avoids regressing in performance now that we do additional pattern-match checking inside do notation. - - - - - ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00 Split GHC.Platform.ArchOS from ghc-boot into ghc-platform Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package into this reinstallable standalone package which abides by the PVP, in part motivated by the ongoing work on `ghc-toolchain` towards runtime retargetability. - - - - - b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00 JS: better implementation for plusWord64 (#23597) - - - - - 889c2bbb by sheaf at 2023-07-18T06:37:32-04:00 Do primop rep-poly checks when instantiating This patch changes how we perform representation-polymorphism checking for primops (and other wired-in Ids such as coerce). When instantiating the primop, we check whether each type variable is required to instantiated to a concrete type, and if so we create a new concrete metavariable (a ConcreteTv) instead of a simple MetaTv. (A little subtlety is the need to apply the substitution obtained from instantiating to the ConcreteTvOrigins, see Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.) This allows us to prevent representation-polymorphism in non-argument position, as that is required for some of these primops. We can also remove the logic in tcRemainingValArgs, except for the part concerning representation-polymorphic unlifted newtypes. The function has been renamed rejectRepPolyNewtypes; all it does now is reject unsaturated occurrences of representation-polymorphic newtype constructors when the representation of its argument isn't a concrete RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check). The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head gives more explanation about a possible path to PHASE 2, which would be in line with the treatment for primops taken in this patch. We also update the Core Lint check to handle this new framework. This means Core Lint now checks representation-polymorphism in continuation position like needed for catch#. Fixes #21906 ------------------------- Metric Increase: LargeRecord ------------------------- - - - - - 00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00 Core Lint: distinguish let and letrec in locations Lint messages were saying "in the body of letrec" even for non-recursive let. I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no separate letrec. - - - - - 787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00 Use extended literals when deriving Show This implements GHC proposal https://github.com/ghc-proposals/ghc-proposals/pull/596 Also add support for Int64# and Word64#; see testcase ShowPrim. - - - - - 257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00 Add StgFromCore and StgCodeGen linting - - - - - 34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Strictness - - - - - c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Don't repeatedly construct UniqSets - - - - - b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00 compiler/Types: Ensure that fromList-type operations can fuse In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing it to do so makes a considerable difference in allocations due to the backend. Metric Decrease: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 Codegen: Implement MO_S_MulMayOflo for W16 - - - - - 5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64 It's useful to see which value made the pattern match fail. (If it ever occurs.) - - - - - e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: Implement MO_S_MulMayOflo for W8 This case wasn't handled before. But, the test-primops test suite showed that it actually might appear. - - - - - a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00 Add test for %mulmayoflo primop The test expects a perfect implementation with no false positives. - - - - - 38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00 lint-ci-config: Generate jobs-metadata.json We also now save the jobs-metadata.json and jobs.yaml file as artifacts as: * It might be useful for someone who is modifying CI to copy jobs.yaml if they are having trouble regenerating locally. * jobs-metadata.json is very useful for downstream pipelines to work out the right job to download. Fixes #23654 - - - - - 1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00 Initialize 9.10.1-notes.rst Create new release notes for the next GHC release (GHC 9.10) - - - - - 3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00 Prioritise Parent when looking up class sub-binder When we look up children GlobalRdrElts of a given Parent, we sometimes would rather prioritise those GlobalRdrElts which have the right Parent, and sometimes prioritise those that have the right NameSpace: - in export lists, we should prioritise NameSpace - for class/instance binders, we should prioritise Parent See Note [childGREPriority] in GHC.Types.Name.Reader. fixes #23664 - - - - - 9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00 EPA: Improve annotation management in getMonoBind Ensure the LHsDecl for a FunBind has the correct leading comments and trailing annotations. See the added note for details. - - - - - ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00 Remove unused files in .gitlab These were left over after 6078b429 - - - - - 29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00 gen_ci: Add hie.yaml file This allows you to load `gen_ci.hs` into HLS, and now it is a huge module, that is quite useful. - - - - - 808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00 ci: Make "fast-ci" the default validate configuration We are trying out a lighter weight validation pipeline where by default we just test on 5 platforms: * x86_64-deb10-slow-validate * windows * x86_64-fedora33-release * aarch64-darwin * aarch64-linux-deb10 In order to enable the "full" validation pipeline you can apply the `full-ci` label which will enable all the validation pipelines. All the validation jobs are still run on a marge batch. The goal is to reduce the overall CI capacity so that pipelines start faster for MRs and marge bot batches are faster. Fixes #23694 - - - - - 0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00 EPA: Simplify GHC/Parser.y sL1 This is the next patch in a series simplifying location management in GHC/Parser.y This one simplifies sL1, to use the HasLoc instances introduced in !10743 (closed) - - - - - 3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. - - - - - db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Set explicit section types on all platforms - - - - - b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00 Insert documentation into parsed signature modules Causes haddock comments in signature modules to be properly inserted into the AST (just as they are for regular modules) if the `-haddock` flag is given. Also adds a test that compares `-ddump-parsed-ast` output for a signature module to prevent further regressions. Fixes #23315 - - - - - c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00 primops: Introduce unsafeThawByteArray# This addresses an odd asymmetry in the ByteArray# primops, which previously provided unsafeFreezeByteArray# but no corresponding thaw operation. Closes #22710 - - - - - 87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00 testsuite: Elaborate in interface stability README This discussion didn't make it into the original MR. - - - - - e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00 Allow users to override non-essential haddock options in a Flavour We now supply the non-essential options to haddock using the `extraArgs` field, which can be specified in a Flavour so that if an advanced user wants to change how documentation is generated then they can use something other than the `defaultHaddockExtraArgs`. This does have the potential to regress some packaging if a user has overridden `extraArgs` themselves, because now they also need to add the haddock options to extraArgs. This can easily be done by appending `defaultHaddockExtraArgs` to their extraArgs invocation but someone might not notice this behaviour has changed. In any case, I think passing the non-essential options in this manner is the right thing to do and matches what we do for the "ghc" builder, which by default doesn't pass any optmisation levels, and would likewise be very bad if someone didn't pass suitable `-O` levels for builds. Fixes #23625 - - - - - fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00 ghc-prim: Link against libatomic Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures. Unfortunately this made GHC to fail to build on armel, since armel needs libatomic to support atomic operations on 64-bit word sizes. Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic, the same way as we do in rts/rts.cabal. - - - - - 4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00 simplifier: Correct InScopeSet in rule matching The in-scope set passedto the `exprIsLambda_maybe` call lacked all the in-scope binders. @simonpj suggests this fix where we augment the in-scope set with the free variables of expression which fixes this failure mode in quite a direct way. Fixes #23630 - - - - - 5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00 Add a test for #23413 It was fixed by commit e1590ddc661d6: Add the SolverStage monad. - - - - - 7e05f6df by sheaf at 2023-07-21T23:26:56-04:00 Finish migration of diagnostics in GHC.Tc.Validity This patch finishes migrating the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It also refactors the error message datatypes for class and family instances, to common them up under a single datatype as much as possible. - - - - - 4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00 ci: Enable some more jobs to run in a marge batch In !10907 I made the majority of jobs not run on a validate pipeline but then forgot to renable a select few jobs on the marge batch MR. - - - - - 026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00 user_guide/flags.py: python-3.12 no longer includes distutils packaging.version seems able to handle this fine - - - - - b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00 ci: Mention ~full-ci label in MR template We mention that if you need a full validation pipeline then you can apply the ~full-ci label to your MR in order to test against the full validation pipeline (like we do for marge). - - - - - 42b05e9b by sheaf at 2023-07-22T12:36:00-04:00 RTS: declare setKeepCAFs symbol Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on the symbol setKeepCAFs in the RTS, which led to undefined symbol errors on Windows, as exhibited by the testcase frontend001. Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix. Fixes #22961 - - - - - a72015d6 by sheaf at 2023-07-22T12:36:01-04:00 Mark plugins-external as broken on Windows This test is broken on Windows, so we explicitly mark it as such now that we stop skipping plugin tests on Windows. - - - - - cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00 Stop marking plugin tests as fragile on Windows Now that b2bb3e62 has landed we are in a better situation with regards to plugins on Windows, allowing us to unmark many plugin tests as fragile. Fixes #16405 - - - - - a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00 Misc cleanup - Remove unused RDR names - Fix typos in comments - Deriving: simplify boxConTbl and remove unused litConTbl - chmod -x GHC/Exts.hs, this seems accidental - - - - - 33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00 Visible forall in types of terms: Part 1 (#22326) This patch implements part 1 of GHC Proposal #281, introducing explicit `type` patterns and `type` arguments. Summary of the changes: 1. New extension flag: RequiredTypeArguments 2. New user-facing syntax: `type p` patterns (represented by EmbTyPat) `type e` expressions (represented by HsEmbTy) 3. Functions with required type arguments (visible forall) can now be defined and applied: idv :: forall a -> a -> a -- signature (relevant change: checkVdqOK in GHC/Tc/Validity.hs) idv (type a) (x :: a) = x -- definition (relevant change: tcPats in GHC/Tc/Gen/Pat.hs) x = idv (type Int) 42 -- usage (relevant change: tcInstFun in GHC/Tc/Gen/App.hs) 4. template-haskell support: TH.TypeE corresponds to HsEmbTy TH.TypeP corresponds to EmbTyPat 5. Test cases and a new User's Guide section Changes *not* included here are the t2t (term-to-type) transformation and term variable capture; those belong to part 2. - - - - - 73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00 Add test for #22424 This is a simple Template Haskell test in which we refer to record selectors by their exact Names, in two different ways. Fixes #22424 - - - - - 83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00 ghc-toolchain: Initial commit - - - - - 31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 ghc-toolchain: Toolchain Selection This commit integrates ghc-toolchain, the brand new way of configuring toolchains for GHC, with the Hadrian build system, with configure, and extends and improves the first iteration of ghc-toolchain. The general overview is * We introduce a program invoked `ghc-toolchain --triple=...` which, when run, produces a file with a `Target`. A `GHC.Toolchain.Target.Target` describes the properties of a target and the toolchain (executables and configured flags) to produce code for that target * Hadrian was modified to read Target files, and will both * Invoke the toolchain configured in the Target file as needed * Produce a `settings` file for GHC based on the Target file for that stage * `./configure` will invoke ghc-toolchain to generate target files, but it will also generate target files based on the flags configure itself configured (through `.in` files that are substituted) * By default, the Targets generated by configure are still (for now) the ones used by Hadrian * But we additionally validate the Target files generated by ghc-toolchain against the ones generated by configure, to get a head start on catching configuration bugs before we transition completely. * When we make that transition, we will want to drop a lot of the toolchain configuration logic from configure, but keep it otherwise. * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine) * We just have a HOST target file, which we use as the target for stage0 * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling) * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST * (for more details on cross-compilation see discussion on !9263) See also * Note [How we configure the bundled windows toolchain] * Note [ghc-toolchain consistency checking] * Note [ghc-toolchain overview] Ticket: #19877 MR: !9263 - - - - - a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Add flag to enable/disable ghc-toolchain based configurations This flag is disabled by default, and we'll use the configure-generated-toolchains by default until we remove the toolchain configuration logic from configure. - - - - - 61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Split ghc-toolchain executable to new packge In light of #23690, we split the ghc-toolchain executable out of the library package to be able to ship it in the bindist using Hadrian. Ideally, we eventually revert this commit. - - - - - 38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Ship ghc-toolchain in the bindist Add the ghc-toolchain binary to the binary distribution we ship to users, and teach the bindist configure to use the existing ghc-toolchain. - - - - - 32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00 Kill off gen_bytearray_addr_access_ops.py The relevant primop descriptions are now generated directly by genprimopcode. This makes progress toward fixing #23490, but it is not a complete fix since there is more than one way in which cabal-reinstall (hadrian/build build-cabal) is broken. - - - - - 02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00 compiler: Remove unused `containers.h` include Fixes #23712 - - - - - 822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00 Fix pretty printing of WARNING pragmas There is still something quite unsavoury going on with WARNING pragma printing because the printing relies on the fact that for decl deprecations the SourceText of WarningTxt is empty. However, I let that lion sleep and just fixed things directly. Fixes #23465 - - - - - e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00 ci-images: Bump to commit which has 9.6 image The test-bootstrap job has been failing for 9.6 because we accidentally used a non-master commit. - - - - - bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00 Update bootstrap plans for 9.6.2 and 9.4.5 - - - - - 355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00 EPA: Simplify GHC/Parser.y comb4/comb5 Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with anything with a SrcSpan Also get rid of some more now unnecessary reLoc calls. - - - - - 9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00 compiler: make -ddump-asm work with wasm backend NCG Fixes #23503. Now the `-ddump-asm` flag is respected in the wasm backend NCG, so developers can directly view the generated ASM instead of needing to pass `-S` or `-keep-tmp-files` and manually find & open the assembly file. Ideally, we should be able to output the assembly files in smaller chunks like in other NCG backends. This would also make dumping assembly stats easier. However, this would require a large refactoring, so for short-term debugging purposes I think the current approach works fine. Signed-off-by: Gavin Zhao <git at gzgz.dev> - - - - - 79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00 llvm: Restore accidentally deleted code in 0fc5cb97 Fixes #23711 - - - - - 20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00 configure: Default missing options to False when preparing ghc-toolchain Targets This commit fixes building ghc with 9.2 as the boostrap compiler. The ghc-toolchain patch assumed all _STAGE0 options were available, and forgot to account for this missing information in 9.2. Ghc 9.2 does not have in settings whether ar supports -l, hence can't report it with --info (unliked 9.4 upwards). The fix is to default the missing information (we default "ar supports -l" and other missing options to False) - - - - - fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00 docs: Fix typo - - - - - 503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00 This MR is an implementation of the proposal #516. It adds a warning -Wincomplete-record-selectors for usages of a record field access function (either a record selector or getField @"rec"), while trying to silence the warning whenever it can be sure that a constructor without the record field would not be invoked (which would otherwise cause the program to fail). For example: data T = T1 | T2 {x :: Bool} f a = x a -- this would throw an error g T1 = True g a = x a -- this would not throw an error h :: HasField "x" r Bool => r -> Bool h = getField @"x" j :: T -> Bool j = h -- this would throw an error because of the `HasField` -- constraint being solved See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning. See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details - - - - - af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00 Fix user-facing label in MR template - - - - - 5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00 ci: Test bootstrapping configurations with full-ci and on marge batches There have been two incidents recently where bootstrapping has been broken by removing support for building with 9.2.*. The process for bumping the minimum required version starts with bumping the configure version and then other CI jobs such as the bootstrap jobs have to be updated. We must not silently bump the minimum required version. Now we are running a slimmed down validate pipeline it seems worthwile to test these bootstrap configurations in the full-ci pipeline. - - - - - 25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Remove ghc-9_2_* plans We are anticipating shortly making it necessary to use ghc-9.4 to boot the compiler. - - - - - 2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00 Update bootstrap plans for ghc-platform and ghc-toolchain dependencies Fixes #23735 - - - - - c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Disable -selftest flag from bootstrap plans This saves on building one dependency (QuickCheck) which is unecessary for bootstrapping. - - - - - a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00 Link reference paper and package from System.Mem.{StableName,Weak} - - - - - a5319358 by David Knothe at 2023-07-28T13:13:10-04:00 Update Match Datatype EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation. All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list. We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows: data EquationInfo = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo } | EqnDone { eqn_rhs = MatchResult CoreExpr } An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated. - - - - - 86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00 Improve documentation for Data.Fixed - - - - - f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00 ghc-prim: Use C11 atomics Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*` family of C builtins. Here we refactor these to rather use the appropriate C11 atomic equivalents, allowing us to be more explicit about the expected ordering semantics. - - - - - 0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00 Include -haddock in DynFlags fingerprint The -haddock flag determines whether or not the resulting .hi files contain haddock documentation strings. If the existing .hi files do not contain haddock documentation strings and the user requests them, we should recompile. - - - - - 40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00 Bump filepath submodule to 1.4.100.4 Resolves #23741 Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T12234 T12425 T13035 T13701 T13719 T16875 T18304 T18698a T18698b T21839c T9198 TcPlugin_RewritePerf hard_hole_fits Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183 - - - - - ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00 Add since pragmas to GHC.IO.Handle.FD - - - - - d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00 Make the occurrence analyser smarter about join points This MR addresses #22404. There is a big Note Note [Occurrence analysis for join points] that explains it all. Significant changes * New field occ_join_points in OccEnv * The NonRec case of occAnalBind splits into two cases: one for existing join points (which does the special magic for Note [Occurrence analysis for join points], and one for other bindings. * mkOneOcc adds in info from occ_join_points. * All "bring into scope" activity is centralised in the new function `addInScope`. * I made a local data type LocalOcc for use inside the occurrence analyser It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn makes computationns over it simpler and more efficient. * I found quite a bit of allocation in GHC.Core.Rules.getRules so I optimised it a bit. More minor changes * I found I was using (Maybe Arity) a lot, so I defined a new data type JoinPointHood and used it everwhere. This touches a lot of non-occ-anal files, but it makes everything more perspicuous. * Renamed data constructor WithUsageDetails to WUD, and WithTailUsageDetails to WTUD This also fixes #21128, on the way. --------- Compiler perf ----------- I spent quite a time on performance tuning, so even though it does more than before, the occurrence analyser runs slightly faster on average. Here are the compile-time allocation changes over 0.5% CoOpt_Read(normal) ghc/alloc 766,025,520 754,561,992 -1.5% CoOpt_Singletons(normal) ghc/alloc 759,436,840 762,925,512 +0.5% LargeRecord(normal) ghc/alloc 1,814,482,440 1,799,530,456 -0.8% PmSeriesT(normal) ghc/alloc 68,159,272 67,519,720 -0.9% T10858(normal) ghc/alloc 120,805,224 118,746,968 -1.7% T11374(normal) ghc/alloc 164,901,104 164,070,624 -0.5% T11545(normal) ghc/alloc 79,851,808 78,964,704 -1.1% T12150(optasm) ghc/alloc 73,903,664 71,237,544 -3.6% GOOD T12227(normal) ghc/alloc 333,663,200 331,625,864 -0.6% T12234(optasm) ghc/alloc 52,583,224 52,340,344 -0.5% T12425(optasm) ghc/alloc 81,943,216 81,566,720 -0.5% T13056(optasm) ghc/alloc 294,517,928 289,642,512 -1.7% T13253-spj(normal) ghc/alloc 118,271,264 59,859,040 -49.4% GOOD T15164(normal) ghc/alloc 1,102,630,352 1,091,841,296 -1.0% T15304(normal) ghc/alloc 1,196,084,000 1,166,733,000 -2.5% T15630(normal) ghc/alloc 148,729,632 147,261,064 -1.0% T15703(normal) ghc/alloc 379,366,664 377,600,008 -0.5% T16875(normal) ghc/alloc 32,907,120 32,670,976 -0.7% T17516(normal) ghc/alloc 1,658,001,888 1,627,863,848 -1.8% T17836(normal) ghc/alloc 395,329,400 393,080,248 -0.6% T18140(normal) ghc/alloc 71,968,824 73,243,040 +1.8% T18223(normal) ghc/alloc 456,852,568 453,059,088 -0.8% T18282(normal) ghc/alloc 129,105,576 131,397,064 +1.8% T18304(normal) ghc/alloc 71,311,712 70,722,720 -0.8% T18698a(normal) ghc/alloc 208,795,112 210,102,904 +0.6% T18698b(normal) ghc/alloc 230,320,736 232,697,976 +1.0% BAD T19695(normal) ghc/alloc 1,483,648,128 1,504,702,976 +1.4% T20049(normal) ghc/alloc 85,612,024 85,114,376 -0.6% T21839c(normal) ghc/alloc 415,080,992 410,906,216 -1.0% GOOD T4801(normal) ghc/alloc 247,590,920 250,726,272 +1.3% T6048(optasm) ghc/alloc 95,699,416 95,080,680 -0.6% T783(normal) ghc/alloc 335,323,384 332,988,120 -0.7% T9233(normal) ghc/alloc 709,641,224 685,947,008 -3.3% GOOD T9630(normal) ghc/alloc 965,635,712 948,356,120 -1.8% T9675(optasm) ghc/alloc 444,604,152 428,987,216 -3.5% GOOD T9961(normal) ghc/alloc 303,064,592 308,798,800 +1.9% BAD WWRec(normal) ghc/alloc 503,728,832 498,102,272 -1.1% geo. mean -1.0% minimum -49.4% maximum +1.9% In fact these figures seem to vary between platforms; generally worse on i386 for some reason. The Windows numbers vary by 1% espec in benchmarks where the total allocation is low. But the geom mean stays solidly negative, which is good. The "increase/decrease" list below covers all platforms. The big win on T13253-spj comes because it has a big nest of join points, each occurring twice in the next one. The new occ-anal takes only one iteration of the simplifier to do the inlining; the old one took four. Moreover, we get much smaller code with the new one: New: Result size of Tidy Core = {terms: 429, types: 84, coercions: 0, joins: 14/14} Old: Result size of Tidy Core = {terms: 2,437, types: 304, coercions: 0, joins: 10/10} --------- Runtime perf ----------- No significant changes in nofib results, except a 1% reduction in compiler allocation. Metric Decrease: CoOpt_Read T13253-spj T9233 T9630 T9675 T12150 T21839c LargeRecord MultiComponentModulesRecomp T10421 T13701 T10421 T13701 T12425 Metric Increase: T18140 T9961 T18282 T18698a T18698b T19695 - - - - - 42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00 Improve documentation around IOException and ioe_filename See: * https://github.com/haskell/core-libraries-committee/issues/189 * https://github.com/haskell/unix/pull/279 * https://github.com/haskell/unix/pull/289 - - - - - 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - d77d8902 by Ben Gamari at 2023-10-03T12:49:25-04:00 hadrian/bindist: Ensure that phony rules are marked as such Otherwise make may not run the rule if file with the same name as the rule happens to exist. - - - - - 80ce1d34 by Ben Gamari at 2023-10-05T16:32:57-04:00 hadrian: Move hsc2hs wrapper generation to bindist installation We must generate the hsc2hs wrapper at bindist installation time since it must contain `--lflag` and `--cflag` arguments which depend upon the installation path. Fixes #24050. - - - - - 369453e5 by Ben Gamari at 2023-10-05T16:33:37-04:00 Bump unix submodule to v2.8.3.0 - - - - - 20 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - − .gitlab/circle-ci-job.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - + .gitlab/generate-ci/LICENSE - + .gitlab/generate-ci/README.mkd - + .gitlab/generate-ci/flake.lock - + .gitlab/generate-ci/flake.nix - .gitlab/gen_ci.hs → .gitlab/generate-ci/gen_ci.hs - + .gitlab/generate-ci/generate-ci.cabal - + .gitlab/generate-ci/generate-job-metadata - + .gitlab/generate-ci/generate-jobs - + .gitlab/generate-ci/hie.yaml - − .gitlab/generate_jobs - + .gitlab/hello.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/82aff8c253de96ea64a5a7eae5c3dfdda98ea46d...369453e555cc6701581fbc2bcbc407aa4471c408 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/82aff8c253de96ea64a5a7eae5c3dfdda98ea46d...369453e555cc6701581fbc2bcbc407aa4471c408 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 20:34:24 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 16:34:24 -0400 Subject: [Git][ghc/ghc][wip/bump-unix] 15 commits: Simplify and correct nasty case in coercion opt Message-ID: <651f1dd090c9d_18f529350a77f85299c2@gitlab.mail> Ben Gamari pushed to branch wip/bump-unix at Glasgow Haskell Compiler / GHC Commits: bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - f1907a93 by Ben Gamari at 2023-10-05T16:34:17-04:00 Bump unix submodule to v2.8.3.0 - - - - - 30 changed files: - .gitlab/test-metrics.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - docs/users_guide/using-warnings.rst - driver/ghci/ghci-wrapper.cabal.in - ghc/ghc-bin.cabal.in - hadrian/hadrian.cabal - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Packages.hs - libraries/bytestring - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - libraries/unix - m4/find_ld.m4 - rts/include/rts/ghc_ffi.h - rts/sm/NonMoving.h - − testsuite/tests/driver/T16737.hs - − testsuite/tests/driver/T16737.stdout - − testsuite/tests/driver/T16737include/T16737.h - testsuite/tests/driver/all.T - + testsuite/tests/rename/should_compile/T24037.hs - testsuite/tests/rename/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T21348.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/369453e555cc6701581fbc2bcbc407aa4471c408...f1907a939b7989779e2e67a1bff7376e6253dbbc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/369453e555cc6701581fbc2bcbc407aa4471c408...f1907a939b7989779e2e67a1bff7376e6253dbbc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 21:40:13 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 17:40:13 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] 9 commits: AArch64: Fix broken conditional jumps for offsets >= 1MB Message-ID: <651f2d3d92a75_18f52936d505f8535433@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC Commits: 8c4518f0 by Andreas Klebinger at 2023-10-05T17:40:00-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 (cherry picked from commit 2adc050857a9c1b992040fbfd55fbe65b2851b19) - - - - - d63240ba by Luite Stegeman at 2023-10-05T17:40:00-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 (cherry picked from commit 11ecc37bc27ffa1cf31358e21e09e140befa940c) - - - - - 2676cf15 by Ben Gamari at 2023-10-05T17:40:00-04:00 system-cxx-std-lib: Add license and description (cherry picked from commit 151187407b7b4bdda5b80bd7b8bdf96d05e278dd) - - - - - 2097ea0d by Torsten Schmits at 2023-10-05T17:40:00-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 (cherry picked from commit 083794b10dc27e9d97b62cc8b8eb4e1da162bf66) - - - - - cae1e800 by Alexis King at 2023-10-05T17:40:00-04:00 Don’t store the async exception masking state in CATCH frames (cherry picked from commit 8b61dfd6dfc78bfa6bb9449dac9a336e5d668b5e) - - - - - 5c64beb6 by Ben Gamari at 2023-10-05T17:40:00-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. (cherry picked from commit b35fd2cd7a12f3354a7fd2301bdf610c5d435017) - - - - - 11d24849 by Ben Gamari at 2023-10-05T17:40:00-04:00 Bump unix submodule to 2.8.3.0 - - - - - 93a06d3f by Ben Gamari at 2023-10-05T17:40:00-04:00 Bump stm submodule to 2.5.2.0 - - - - - b9c5acd2 by Ben Gamari at 2023-10-05T17:40:00-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 30 changed files: - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Config/HsToCore/Ticks.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/ghc.cabal.in - docs/users_guide/debug-info.rst - docs/users_guide/ghci.rst - docs/users_guide/phases.rst - ghc/Main.hs - libraries/base/configure.ac - libraries/base/jsbits/base.js - libraries/hpc - libraries/stm - libraries/unix - mk/system-cxx-std-lib-1.0.conf.in - rts/Continuation.c - rts/Exception.cmm - rts/RaiseAsync.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b33cbffdff0ffa30f3c281da70072a5575eb5b32...b9c5acd201738c05947176ad46f8ac0cb7530960 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b33cbffdff0ffa30f3c281da70072a5575eb5b32...b9c5acd201738c05947176ad46f8ac0cb7530960 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 21:41:50 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 17:41:50 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] 9 commits: AArch64: Fix broken conditional jumps for offsets >= 1MB Message-ID: <651f2d9ef2c11_18f52936fa649c535855@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC Commits: b3ab756f by Andreas Klebinger at 2023-10-05T17:41:42-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 (cherry picked from commit 2adc050857a9c1b992040fbfd55fbe65b2851b19) - - - - - 857967ae by Luite Stegeman at 2023-10-05T17:41:42-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 (cherry picked from commit 11ecc37bc27ffa1cf31358e21e09e140befa940c) - - - - - 81b1179d by Ben Gamari at 2023-10-05T17:41:42-04:00 system-cxx-std-lib: Add license and description (cherry picked from commit 151187407b7b4bdda5b80bd7b8bdf96d05e278dd) - - - - - 0fc4ce51 by Torsten Schmits at 2023-10-05T17:41:42-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 (cherry picked from commit 083794b10dc27e9d97b62cc8b8eb4e1da162bf66) - - - - - e538003c by Alexis King at 2023-10-05T17:41:42-04:00 Don’t store the async exception masking state in CATCH frames (cherry picked from commit 8b61dfd6dfc78bfa6bb9449dac9a336e5d668b5e) - - - - - 46896580 by Ben Gamari at 2023-10-05T17:41:42-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. (cherry picked from commit b35fd2cd7a12f3354a7fd2301bdf610c5d435017) - - - - - 34bd605d by Ben Gamari at 2023-10-05T17:41:42-04:00 Bump unix submodule to 2.8.3.0 - - - - - dfea05f1 by Ben Gamari at 2023-10-05T17:41:42-04:00 Bump stm submodule to 2.5.2.0 - - - - - 0dae4797 by Ben Gamari at 2023-10-05T17:41:42-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 30 changed files: - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Config/HsToCore/Ticks.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/ghc.cabal.in - docs/users_guide/debug-info.rst - docs/users_guide/ghci.rst - docs/users_guide/phases.rst - ghc/Main.hs - libraries/base/configure.ac - libraries/base/jsbits/base.js - libraries/hpc - libraries/stm - libraries/unix - mk/system-cxx-std-lib-1.0.conf.in - rts/Continuation.c - rts/Exception.cmm - rts/RaiseAsync.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9c5acd201738c05947176ad46f8ac0cb7530960...0dae479735936499a87a30a4ea59d1670bbb1ec9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9c5acd201738c05947176ad46f8ac0cb7530960...0dae479735936499a87a30a4ea59d1670bbb1ec9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 21:48:57 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 17:48:57 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] Bump hpc submodule to 0.7.0.0 Message-ID: <651f2f491953a_18f52936fa649c5392fb@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC Commits: 351c8e70 by Ben Gamari at 2023-10-05T17:48:50-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 3 changed files: - compiler/ghc.cabal.in - libraries/hpc - utils/hpc Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -105,7 +105,7 @@ Library array >= 0.1 && < 0.6, filepath >= 1 && < 1.5, template-haskell == 2.21.*, - hpc == 0.6.*, + hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, semaphore-compat, ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 50d520bf6002ab55032e233dced0556ad63ad0c0 +Subproject commit 6bc66b7ae490d28d6b17d01c2959d6c8ce3e7a79 ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit eb800fe76409f54660335496592f777ae215ff92 +Subproject commit 8688d7fb97a76b0cc49d647ea4745f4ed06e3fcc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/351c8e7021603ba0c2d69dee59854a639fda26df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/351c8e7021603ba0c2d69dee59854a639fda26df You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 22:32:51 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 18:32:51 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] Bump hpc submodule to 0.7.0.0 Message-ID: <651f39937c660_18f529381e9e6053968b@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC Commits: e81bde51 by Ben Gamari at 2023-10-05T18:32:42-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 4 changed files: - compiler/ghc.cabal.in - libraries/hpc - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -105,7 +105,7 @@ Library array >= 0.1 && < 0.6, filepath >= 1 && < 1.5, template-haskell == 2.21.*, - hpc == 0.6.*, + hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, semaphore-compat, ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 50d520bf6002ab55032e233dced0556ad63ad0c0 +Subproject commit 6bc66b7ae490d28d6b17d01c2959d6c8ce3e7a79 ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit eb800fe76409f54660335496592f777ae215ff92 +Subproject commit 8688d7fb97a76b0cc49d647ea4745f4ed06e3fcc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e81bde512d2efa10cffde9990e3735958b3b5fd2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e81bde512d2efa10cffde9990e3735958b3b5fd2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 22:36:25 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 18:36:25 -0400 Subject: [Git][ghc/ghc][wip/release-9.8.1] 10 commits: AArch64: Fix broken conditional jumps for offsets >= 1MB Message-ID: <651f3a69570fd_18f529387e583c5473b@gitlab.mail> Ben Gamari pushed to branch wip/release-9.8.1 at Glasgow Haskell Compiler / GHC Commits: b3ab756f by Andreas Klebinger at 2023-10-05T17:41:42-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 (cherry picked from commit 2adc050857a9c1b992040fbfd55fbe65b2851b19) - - - - - 857967ae by Luite Stegeman at 2023-10-05T17:41:42-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 (cherry picked from commit 11ecc37bc27ffa1cf31358e21e09e140befa940c) - - - - - 81b1179d by Ben Gamari at 2023-10-05T17:41:42-04:00 system-cxx-std-lib: Add license and description (cherry picked from commit 151187407b7b4bdda5b80bd7b8bdf96d05e278dd) - - - - - 0fc4ce51 by Torsten Schmits at 2023-10-05T17:41:42-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 (cherry picked from commit 083794b10dc27e9d97b62cc8b8eb4e1da162bf66) - - - - - e538003c by Alexis King at 2023-10-05T17:41:42-04:00 Don’t store the async exception masking state in CATCH frames (cherry picked from commit 8b61dfd6dfc78bfa6bb9449dac9a336e5d668b5e) - - - - - 46896580 by Ben Gamari at 2023-10-05T17:41:42-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. (cherry picked from commit b35fd2cd7a12f3354a7fd2301bdf610c5d435017) - - - - - 34bd605d by Ben Gamari at 2023-10-05T17:41:42-04:00 Bump unix submodule to 2.8.3.0 - - - - - dfea05f1 by Ben Gamari at 2023-10-05T17:41:42-04:00 Bump stm submodule to 2.5.2.0 - - - - - e81bde51 by Ben Gamari at 2023-10-05T18:32:42-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 5695bb42 by Ben Gamari at 2023-10-05T18:36:18-04:00 Release GHC 9.8.1 - - - - - 30 changed files: - .gitlab/rel_eng/upload_ghc_libs.py - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Config/HsToCore/Ticks.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/debug-info.rst - docs/users_guide/ghci.rst - docs/users_guide/phases.rst - ghc/Main.hs - libraries/base/configure.ac - libraries/base/jsbits/base.js - libraries/hpc - libraries/stm - libraries/unix - mk/system-cxx-std-lib-1.0.conf.in - rts/Continuation.c - rts/Exception.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7367ce5d99d7d0b1518d6222a69fba4f91a65228...5695bb42099077817e43a0a41d4f5526ac68550b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7367ce5d99d7d0b1518d6222a69fba4f91a65228...5695bb42099077817e43a0a41d4f5526ac68550b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 22:46:09 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 18:46:09 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] fixes Message-ID: <651f3cb11b2ba_18f52938aeb70c5503ad@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 7770b1b8 by GHC GitLab CI at 2023-10-05T22:45:47+00:00 fixes - - - - - 3 changed files: - .gitlab/ci.sh - distrib/configure.ac.in - hadrian/src/Packages.hs Changes: ===================================== .gitlab/ci.sh ===================================== @@ -592,15 +592,15 @@ function test_hadrian() { if [[ "${CROSS_EMULATOR:-}" == "NOT_SET" ]]; then info "Cannot test cross-compiled build without CROSS_EMULATOR being set." return - # special case for JS backend -# elif [ -n "${CROSS_TARGET:-}" ]; then -# local instdir="$TOP/_build/install" -# local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" -# install_bindist _build/bindist/ghc-*/ "$instdir" -# echo 'main = putStrLn "hello world"' > expected -# run "$test_compiler" -package ghc "$TOP/.gitlab/hello.hs" -o hello -# ${CROSS_EMULATOR:-} ./hello > actual -# run diff expected actual + # If we have set CROSS_EMULATOR, then can't test using normal testsuite. + elif [ -n "${CROSS_EMULATOR:-}" ]; then + local instdir="$TOP/_build/install" + local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" + install_bindist _build/bindist/ghc-*/ "$instdir" + echo 'main = putStrLn "hello world"' > expected + run "$test_compiler" -package ghc "$TOP/.gitlab/hello.hs" -o hello + ${CROSS_EMULATOR:-} ./hello > actual + run diff expected actual elif [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian \ test \ ===================================== distrib/configure.ac.in ===================================== @@ -11,6 +11,11 @@ AC_PREREQ([2.69]) AC_CONFIG_MACRO_DIRS([../m4]) +dnl this makes sure `./configure --target=` +dnl works as expected, since we're slightly modifying how Autoconf +dnl interprets build/host/target and how this interacts with $CC tests +test -n "$target_alias" && ac_tool_prefix=$target_alias- + dnl-------------------------------------------------------------------- dnl * Deal with arguments telling us gmp is somewhere odd dnl-------------------------------------------------------------------- ===================================== hadrian/src/Packages.hs ===================================== @@ -170,7 +170,8 @@ setPath pkg path = pkg { pkgPath = path } crossPrefix :: Stage -> Action String crossPrefix st = do cross <- crossStage st - targetPlatform <- targetPlatformTriple <$> targetStage (succStage st) + -- NB: If you modify this then it needs to align with CrossCompilePrefix in configure.ac + targetPlatform <- setting TargetPlatformFull return $ if cross then targetPlatform ++ "-" else "" -- | Given a 'Context', compute the name of the program that is built in it View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7770b1b84d77be3149f974efc12e09acc85f0f60 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7770b1b84d77be3149f974efc12e09acc85f0f60 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 23:04:15 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 19:04:15 -0400 Subject: [Git][ghc/ghc] Pushed new branch origin/wip/hadrian-cross-stage2 Message-ID: <651f40ef91a5b_18f529387eb50c55316b@gitlab.mail> Matthew Pickering pushed new branch origin/wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/origin/wip/hadrian-cross-stage2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 23:04:37 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 19:04:37 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 3 commits: Remove libbin copy Message-ID: <651f4105355f3_18f52938d850f85533ec@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: c555e89b by Matthew Pickering at 2023-10-06T00:03:38+01:00 Remove libbin copy - - - - - 746b0cbc by Matthew Pickering at 2023-10-06T00:03:38+01:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 5a8cfaa3 by Matthew Pickering at 2023-10-06T00:03:38+01:00 fix - - - - - 4 changed files: - hadrian/src/Packages.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs Changes: ===================================== hadrian/src/Packages.hs ===================================== @@ -26,7 +26,6 @@ import Hadrian.Utilities import Base import Context import Oracles.Setting -import GHC.Toolchain.Target (targetPlatformTriple) -- | These are all GHC packages we know about. Build rules will be generated for -- all of them. However, not all of these packages will be built. For example, @@ -206,14 +205,8 @@ programBasename way package -- | The 'FilePath' to a program executable in a given 'Context'. programPath :: Context -> Action FilePath programPath context at Context {..} = do - -- TODO: The @touchy@ utility lives in the @lib/bin@ directory instead of - -- @bin@, which is likely just a historical accident that should be fixed. - -- See: https://github.com/snowleopard/hadrian/issues/570 - -- Likewise for @iserv@ and @unlit at . name <- programName context - path <- if package `elem` [iserv, touchy, unlit] - then stageLibPath stage <&> (-/- "bin") - else stageBinPath stage + path <- stageBinPath stage return $ path -/- name <.> exe -- TODO: Move @timeout@ to the @util@ directory and build in a more standard ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -171,7 +171,6 @@ buildBinDistDir root conf at BindistConfig{..} = do -- let rtsDir = "rts" let ghcBuildDir = root -/- stageString library_stage - ghcLibBinBuildDir = root -/- stageString executable_stage -/- "lib" -/- "bin" bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform rtsIncludeDir = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir @@ -229,9 +228,6 @@ buildBinDistDir root conf at BindistConfig{..} = do IO.createFileLink version_prog versioned_runhaskell_path copyDirectory (ghcBuildDir -/- "lib") bindistFilesDir - ld <- liftIO $ IO.listDirectory ghcLibBinBuildDir - traceShowM ld - copyDirectory ghcLibBinBuildDir bindistFilesDir copyDirectory (rtsIncludeDir) bindistFilesDir when windowsHost $ createGhcii (bindistFilesDir -/- "bin") ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -402,7 +402,7 @@ generateSettings = do , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand) , ("windres command", queryTarget stage (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me. - , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) + , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) , ("cross compiling", expr $ yesNo <$> crossStage (predStage stage)) , ("target platform string", queryTarget stage targetPlatformTriple) , ("target os", queryTarget stage (show . archOS_OS . tgtArchOs)) ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -38,7 +38,7 @@ buildProgramRules rs = do -- Rules for programs that are actually built by hadrian. forM_ allStages $ \stage -> [ root -/- stageString stage -/- "bin" -/- "*" - , root -/- stageString stage -/- "lib/bin" -/- "*" ] |%> \bin -> do + ] |%> \bin -> do programContexts <- getProgramContexts stage case lookupProgramContext bin programContexts of Nothing -> error $ "Unknown program " ++ show bin @@ -97,13 +97,7 @@ buildProgram bin ctx@(Context{..}) rs = do -- so we use pkgRegisteredLibraryFile instead. registerPackages =<< contextDependencies ctx - cross <- flag CrossCompiling - case (cross, stage) of - -- MP: Why do we copy these? Seems like we should just build them again. - (False, s) | s > stage0InTree && (package `elem` [touchy, unlit]) -> do - srcDir <- stageLibPath stage0InTree <&> (-/- "bin") - copyFile (srcDir -/- takeFileName bin) bin - _ -> buildBinary rs bin ctx + buildBinary rs bin ctx buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action () buildBinary rs bin context at Context {..} = do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7770b1b84d77be3149f974efc12e09acc85f0f60...5a8cfaa30b12310321cd0db3086b5474d55255fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7770b1b84d77be3149f974efc12e09acc85f0f60...5a8cfaa30b12310321cd0db3086b5474d55255fa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 5 23:19:37 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 05 Oct 2023 19:19:37 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] fixes Message-ID: <651f44896f8f6_18f5293967e43455553b@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: fb7ad844 by Matthew Pickering at 2023-10-06T00:19:29+01:00 fixes - - - - - 2 changed files: - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Program.hs Changes: ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -19,7 +19,6 @@ import GHC.Toolchain (ccProgram, tgtCCompiler, ccLinkProgram, tgtCCompilerLink) import GHC.Toolchain.Program (prgFlags) import qualified Data.Set as Set import Oracles.Flavour -import Debug.Trace {- Note [Binary distributions] ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -8,7 +8,6 @@ import Hadrian.Haskell.Cabal.Type import Base import Context import Expression hiding (stage, way) -import Oracles.Flag import Oracles.ModuleFiles import Oracles.Setting (topDirectory) import Packages View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb7ad844ca1173a4d64a8c502da9e835757a69d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb7ad844ca1173a4d64a8c502da9e835757a69d5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 00:31:29 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 20:31:29 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] Deleted 1 commit: Bump hpc submodule to 0.7.0.0 Message-ID: <651f556193ad9_18f5293b3e97305587d0@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below. Deleted commits: e81bde51 by Ben Gamari at 2023-10-05T18:32:42-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 4 changed files: - compiler/ghc.cabal.in - libraries/hpc - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -105,7 +105,7 @@ Library array >= 0.1 && < 0.6, filepath >= 1 && < 1.5, template-haskell == 2.21.*, - hpc == 0.6.*, + hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, semaphore-compat, ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 50d520bf6002ab55032e233dced0556ad63ad0c0 +Subproject commit 6bc66b7ae490d28d6b17d01c2959d6c8ce3e7a79 ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit eb800fe76409f54660335496592f777ae215ff92 +Subproject commit 8688d7fb97a76b0cc49d647ea4745f4ed06e3fcc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e81bde512d2efa10cffde9990e3735958b3b5fd2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e81bde512d2efa10cffde9990e3735958b3b5fd2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 03:33:34 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 05 Oct 2023 23:33:34 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] 3 commits: Bump stm submodule to 2.5.2.0 Message-ID: <651f800e225af_18f5293f9353ac566542@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC Commits: 47b202a9 by Ben Gamari at 2023-10-05T23:32:49-04:00 Bump stm submodule to 2.5.2.0 - - - - - 31d4e495 by Ben Gamari at 2023-10-05T23:32:49-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 7c268df5 by Ben Gamari at 2023-10-05T23:32:54-04:00 Allow perf changes These appear to be spurious. Metric Decrease: MultiLayerModules T13701 T14697 - - - - - 5 changed files: - compiler/ghc.cabal.in - libraries/hpc - libraries/stm - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -105,7 +105,7 @@ Library array >= 0.1 && < 0.6, filepath >= 1 && < 1.5, template-haskell == 2.21.*, - hpc == 0.6.*, + hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, semaphore-compat, ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 50d520bf6002ab55032e233dced0556ad63ad0c0 +Subproject commit 6bc66b7ae490d28d6b17d01c2959d6c8ce3e7a79 ===================================== libraries/stm ===================================== @@ -1 +1 @@ -Subproject commit f8582bd6e31df73b4f18f676650ae183624d8eb2 +Subproject commit a1e91f4ea010be61a9c8a94d6a200bfb4dc6d049 ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit eb800fe76409f54660335496592f777ae215ff92 +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dfea05f15ccad75b4b439b8ae18eb3ab01007036...7c268df5d25cd2b938fcdda68e7a93d2dd07be6b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dfea05f15ccad75b4b439b8ae18eb3ab01007036...7c268df5d25cd2b938fcdda68e7a93d2dd07be6b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 03:46:39 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 05 Oct 2023 23:46:39 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" Message-ID: <651f831f544ec_18f52940155834574159@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 2b2352db by Ben Gamari at 2023-10-05T10:22:10+00:00 testsuite: Fix invalid string literal `"\+"` is not a valid Python string; this should have been `r"\+"`. - - - - - 2c8c8ce8 by Ben Gamari at 2023-10-05T10:22:10+00:00 rts/nonmoving: Reflow notes - - - - - 7ef28e05 by Ben Gamari at 2023-10-05T10:22:10+00:00 testsuite: Run some tests unconditionally in nonmoving ways Improve test coverage of the nonmoving collector by running a small subset of tests unconditionally with the nonmoving collector. Fixes #24052. - - - - - 742d819d by David Binder at 2023-10-05T23:45:51-04:00 Update hpc-bin submodule to 0.69 - - - - - 21 changed files: - .gitlab/test-metrics.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Driver/Pipeline/Execute.hs - driver/ghci/ghci-wrapper.cabal.in - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Settings/Packages.hs - rts/sm/NonMoving.c - rts/sm/NonMoving.h - testsuite/driver/testlib.py - testsuite/tests/array/should_run/all.T - testsuite/tests/concurrent/should_run/all.T - − testsuite/tests/driver/T16737.hs - − testsuite/tests/driver/T16737.stdout - − testsuite/tests/driver/T16737include/T16737.h - testsuite/tests/driver/all.T - testsuite/tests/hpc/T17073.stdout - + testsuite/tests/simplCore/should_compile/T21348.hs - testsuite/tests/simplCore/should_compile/all.T - + testsuite/tests/th/T24046.hs - testsuite/tests/th/all.T - utils/hpc Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -781,12 +781,12 @@ getRegister' config plat expr return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) -- 3. Logic &&, || - CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (AND (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg - CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (fromIntegral n) -> + CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (ORR (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg @@ -1070,13 +1070,16 @@ getRegister' config plat expr -- | Is a given number encodable as a bitmask immediate? -- -- https://stackoverflow.com/questions/30904718/range-of-immediate-values-in-armv8-a64-assembly -isAArch64Bitmask :: Integer -> Bool +isAArch64Bitmask :: Width -> Integer -> Bool -- N.B. zero and ~0 are not encodable as bitmask immediates -isAArch64Bitmask 0 = False -isAArch64Bitmask n - | n == bit 64 - 1 = False -isAArch64Bitmask n = - check 64 || check 32 || check 16 || check 8 +isAArch64Bitmask width n = + assert (width `elem` [W32,W64]) $ + case n of + 0 -> False + _ | n == bit (widthInBits width) - 1 + -> False -- 1111...1111 + | otherwise + -> (width == W64 && check 64) || check 32 || check 16 || check 8 where -- Check whether @n@ can be represented as a subpattern of the given -- width. ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -411,19 +411,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do includePathsQuoteImplicit cmdline_include_paths) let include_paths = include_paths_quote ++ include_paths_global - -- pass -D or -optP to preprocessor when compiling foreign C files - -- (#16737). Doing it in this way is simpler and also enable the C - -- compiler to perform preprocessing and parsing in a single pass, - -- but it may introduce inconsistency if a different pgm_P is specified. - let opts = getOpts dflags opt_P - aug_imports = augmentImports dflags opts - - more_preprocessor_opts = concat - [ ["-Xpreprocessor", i] - | not hcc - , i <- aug_imports - ] - let gcc_extra_viac_flags = extraGccViaCFlags dflags let pic_c_flags = picCCOpts dflags @@ -512,7 +499,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do ++ [ "-include", ghcVersionH ] ++ framework_paths ++ include_paths - ++ more_preprocessor_opts ++ pkg_extra_cc_opts )) ===================================== driver/ghci/ghci-wrapper.cabal.in ===================================== @@ -29,4 +29,4 @@ Executable ghci -- We need to call the versioned ghc executable because the unversioned -- GHC executable is a wrapper that doesn't call FreeConsole and so -- breaks an interactive process like GHCi. See #21889, #14150 and #13411 - CPP-Options: -DEXE_PATH="ghc- at ProjectVersion@" + cc-options: -DEXE_PATH="ghc- at ProjectVersion@" ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -515,8 +515,8 @@ createVersionWrapper pkg versioned_exe install_path = do | otherwise = 0 cmd ghcPath (["-no-hs-main", "-o", install_path, "-I"++version_wrapper_dir - , "-DEXE_PATH=\"" ++ versioned_exe ++ "\"" - , "-DINTERACTIVE_PROCESS=" ++ show interactive + , "-optc-DEXE_PATH=\"" ++ versioned_exe ++ "\"" + , "-optc-DINTERACTIVE_PROCESS=" ++ show interactive ] ++ wrapper_files) {- ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -297,14 +297,11 @@ rtsPackageArgs = package rts ? do libzstdIncludeDir <- getSetting LibZstdIncludeDir libzstdLibraryDir <- getSetting LibZstdLibDir + -- Arguments passed to GHC when compiling C and .cmm sources. let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\"" - -- Set the namespace for the rts fs functions - , arg $ "-DFS_NAMESPACE=rts" - , arg $ "-DCOMPILING_RTS" , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] @@ -333,9 +330,16 @@ rtsPackageArgs = package rts ? do , "-fno-omit-frame-pointer" , "-g3" , "-O0" ] + -- Set the namespace for the rts fs functions + , arg $ "-DFS_NAMESPACE=rts" + + , arg $ "-DCOMPILING_RTS" , inputs ["**/RtsMessages.c", "**/Trace.c"] ? - arg ("-DProjectVersion=" ++ show projectVersion) + pure + ["-DProjectVersion=" ++ show projectVersion + , "-DRtsWay=\"rts_" ++ show way ++ "\"" + ] , input "**/RtsUtils.c" ? pure [ "-DProjectVersion=" ++ show projectVersion @@ -353,6 +357,7 @@ rtsPackageArgs = package rts ? do , "-DTargetVendor=" ++ show targetVendor , "-DGhcUnregisterised=" ++ show ghcUnreg , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DRtsWay=\"rts_" ++ show way ++ "\"" ] -- We're after pur performance here. So make sure fast math and ===================================== rts/sm/NonMoving.c ===================================== @@ -151,9 +151,9 @@ static void nonmovingBumpEpoch(void) { * 3. [STW] Root collection: Here we walk over a variety of root sources * and add them to the mark queue (see nonmovingCollect). * - * 4. [CONC] Concurrent marking: Here we do the majority of marking concurrently - * with mutator execution (but with the write barrier enabled; see - * Note [Update remembered set]). + * 4. [CONC] Concurrent marking: Here we do the majority of marking + * concurrently with mutator execution (but with the write barrier enabled; + * see Note [Update remembered set]). * * 5. [STW] Final sync: Here we interrupt the mutators, ask them to * flush their final update remembered sets, and mark any new references @@ -218,9 +218,9 @@ static void nonmovingBumpEpoch(void) { * - Note [Concurrent read barrier on deRefWeak#] (NonMovingMark.c) describes * the read barrier on Weak# objects. * - * - Note [Unintentional marking in resurrectThreads] (NonMovingMark.c) describes - * a tricky interaction between the update remembered set flush and weak - * finalization. + * - Note [Unintentional marking in resurrectThreads] (NonMovingMark.c) + * describes a tricky interaction between the update remembered set flush and + * weak finalization. * * - Note [Origin references in the nonmoving collector] (NonMovingMark.h) * describes how we implement indirection short-cutting and the selector @@ -229,8 +229,8 @@ static void nonmovingBumpEpoch(void) { * - Note [StgStack dirtiness flags and concurrent marking] (TSO.h) describes * the protocol for concurrent marking of stacks. * - * - Note [Nonmoving write barrier in Perform{Put,Take}] (PrimOps.cmm) describes - * a tricky barrier necessary when resuming threads blocked on MVar + * - Note [Nonmoving write barrier in Perform{Put,Take}] (PrimOps.cmm) + * describes a tricky barrier necessary when resuming threads blocked on MVar * operations. * * - Note [Static objects under the nonmoving collector] (Storage.c) describes @@ -240,13 +240,17 @@ static void nonmovingBumpEpoch(void) { * how we use the DIRTY flags associated with MUT_VARs and TVARs to improve * barrier efficiency. * - * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) describes - * how weak pointers are handled when the non-moving GC is in use. + * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) + * describes how weak pointers are handled when the non-moving GC is in use. * * - Note [Sync phase marking budget] describes how we avoid long mutator * pauses during the sync phase * - * - Note [Allocator sizes] goes into detail about our choice of allocator sizes. + * - Note [Allocator sizes] goes into detail about our choice of allocator + * sizes. + * + * - Note [Testing the nonmoving collector] describes how we test the + * collector. * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage @@ -259,15 +263,15 @@ static void nonmovingBumpEpoch(void) { * Concurrency-control of non-moving garbage collection is a bit tricky. There * are a few things to keep in mind: * - * - Only one non-moving collection may be active at a time. This is enforced by the - * concurrent_coll_running flag, which is set when a collection is on-going. If - * we attempt to initiate a new collection while this is set we wait on the - * concurrent_coll_finished condition variable, which signals when the - * active collection finishes. + * - Only one non-moving collection may be active at a time. This is enforced + * by the concurrent_coll_running flag, which is set when a collection is + * on-going. If we attempt to initiate a new collection while this is set we + * wait on the concurrent_coll_finished condition variable, which signals + * when the active collection finishes. * - * - In between the mark and sweep phases the non-moving collector must synchronize - * with mutator threads to collect and mark their final update remembered - * sets. This is accomplished using + * - In between the mark and sweep phases the non-moving collector must + * synchronize with mutator threads to collect and mark their final update + * remembered sets. This is accomplished using * stopAllCapabilitiesWith(SYNC_FLUSH_UPD_REM_SET). Capabilities are held * the final mark has concluded. * @@ -361,9 +365,9 @@ static void nonmovingBumpEpoch(void) { * ╰─────────────────╯ * ┆ * - * In this case we have a TSO blocked on a dead MVar. Because the MVAR_TSO_QUEUE on - * which it is blocked lives in the moving heap, the TSO is necessarily on the - * oldest generation's mut_list. As in Note [Aging under the non-moving + * In this case we have a TSO blocked on a dead MVar. Because the MVAR_TSO_QUEUE + * on which it is blocked lives in the moving heap, the TSO is necessarily on + * the oldest generation's mut_list. As in Note [Aging under the non-moving * collector], the MVAR_TSO_QUEUE will be evacuated. If MVAR_TSO_QUEUE is aged * (e.g. evacuated to the young generation) then the MVAR will be added to the * mark queue. Consequently, we will falsely conclude that the MVAR is still @@ -387,9 +391,9 @@ static void nonmovingBumpEpoch(void) { * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The nonmoving collector uses an approximate heuristic for reporting live * data quantity. Specifically, during mark we record how much live data we - * find in nonmoving_segment_live_words. At the end of mark this is combined with nonmoving_large_words - * and nonmoving_compact_words, and we declare this amount to - * be how much live data we have on in the nonmoving heap (by setting + * find in nonmoving_segment_live_words. At the end of mark this is combined + * with nonmoving_large_words and nonmoving_compact_words, and we declare this + * amount to be how much live data we have on in the nonmoving heap (by setting * oldest_gen->live_estimate). * * In addition, we update oldest_gen->live_estimate every time we fill a @@ -413,10 +417,10 @@ static void nonmovingBumpEpoch(void) { * - Minor collections assume that all sparks living in the non-moving heap * are reachable. * - * - Major collections prune the spark queue during the final sync. This pruning - * assumes that all sparks in the young generations are reachable (since the - * BF_EVACUATED flag won't be set on the nursery blocks) and will consequently - * only prune dead sparks living in the non-moving heap. + * - Major collections prune the spark queue during the final sync. This + * pruning assumes that all sparks in the young generations are reachable (since + * the BF_EVACUATED flag won't be set on the nursery blocks) and will + * consequently only prune dead sparks living in the non-moving heap. * * * Note [Dirty flags in the non-moving collector] @@ -439,8 +443,8 @@ static void nonmovingBumpEpoch(void) { * In the non-moving collector we use the same dirty flag to implement a * related optimisation on the non-moving write barrier: Specifically, the * snapshot invariant only requires that the non-moving write barrier applies - * to the *first* mutation to an object after collection begins. To achieve this, - * we impose the following invariant: + * to the *first* mutation to an object after collection begins. To achieve + * this, we impose the following invariant: * * An object being marked as dirty implies that all of its fields are on * the mark queue (or, equivalently, update remembered set). @@ -492,8 +496,8 @@ static void nonmovingBumpEpoch(void) { * ┊ * * This is bad. When we resume mutation a mutator may mutate MVAR A; since it's - * already dirty we would fail to add Y to the update remembered set, breaking the - * snapshot invariant and potentially losing track of the liveness of Z. + * already dirty we would fail to add Y to the update remembered set, breaking + * the snapshot invariant and potentially losing track of the liveness of Z. * * To avoid this nonmovingScavengeOne we eagerly pushes the values of the * fields of all objects which it fails to evacuate (e.g. MVAR A) to the update @@ -535,8 +539,9 @@ static void nonmovingBumpEpoch(void) { * Note [Allocator sizes] * ~~~~~~~~~~~~~~~~~~~~~~ * Our choice of allocator sizes has to balance several considerations: - * - Allocator sizes should be available for the most commonly request block sizes, - * in order to avoid excessive waste from rounding up to the next size (internal fragmentation). + * - Allocator sizes should be available for the most commonly request block + * sizes, in order to avoid excessive waste from rounding up to the next size + * (internal fragmentation). * - It should be possible to efficiently determine which allocator services * a certain block size. * - The amount of allocators should be kept down to avoid overheads @@ -548,18 +553,37 @@ static void nonmovingBumpEpoch(void) { * arbitrary allocator sizes, we need to do some precomputation and make * use of the integer division by constants optimisation. * - * We currenlty try to balance these considerations by adopting the following scheme. - * We have nonmoving_alloca_dense_cnt "dense" allocators starting with size - * NONMOVING_ALLOCA0, and incrementing by NONMOVING_ALLOCA_DENSE_INCREMENT. + * We currenlty try to balance these considerations by adopting the following + * scheme. We have nonmoving_alloca_dense_cnt "dense" allocators starting with + * size NONMOVING_ALLOCA0, and incrementing by NONMOVING_ALLOCA_DENSE_INCREMENT. * These service the vast majority of allocations. * In practice, Haskell programs tend to allocate a lot of small objects. * - * Other allocations are handled by a family of "sparse" allocators, each providing - * blocks up to a power of 2. This places an upper bound on the waste at half the - * required block size. + * Other allocations are handled by a family of "sparse" allocators, each + * providing blocks up to a power of 2. This places an upper bound on the waste + * at half the required block size. * * See #23340 * + * + * Note [Testing the nonmoving collector] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * The testsuite has four "ways" which test the nonmoving collector: + * + * - nonmoving: runs tests under the nonmoving collector running in + * non-concurrent mode (i.e. using the non-threaded runtime) + * - nonmoving_thr: runs tests under the collector running in concurrent + * mode (with the threaded runtime) + * - nonmoving_thr_sanity: runs tests with concurrent collection and + * sanity checking (i.e. `+RTS -DS`) + * - nonmoving_thr_ghc: compiles tests with `ghc +RTS --nonmoving-gc -RTS` + * as GHC itself tends to be a good smoke test of the collector. + * + * To avoid blowing up validation times, we do not run any of these ways in the + * default "normal" test speed. To ensure that we catch regressions in during + * normal validation we do run a small number of tests in these ways. These + * tests are identified by the `nonmoving_test` test modifier. + * */ memcount nonmoving_segment_live_words = 0; ===================================== rts/sm/NonMoving.h ===================================== @@ -17,13 +17,13 @@ #include "BeginPrivate.h" // Segments -#define NONMOVING_SEGMENT_BITS 15UL // 2^15 = 32kByte +#define NONMOVING_SEGMENT_BITS 15ULL // 2^15 = 32kByte // Mask to find base of segment -#define NONMOVING_SEGMENT_MASK ((1UL << NONMOVING_SEGMENT_BITS) - 1) +#define NONMOVING_SEGMENT_MASK (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) - 1) // In bytes -#define NONMOVING_SEGMENT_SIZE (1UL << NONMOVING_SEGMENT_BITS) +#define NONMOVING_SEGMENT_SIZE ((uintptr_t)1 << NONMOVING_SEGMENT_BITS) // In words -#define NONMOVING_SEGMENT_SIZE_W ((1UL << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) +#define NONMOVING_SEGMENT_SIZE_W (((uintptr_t)1 << NONMOVING_SEGMENT_BITS) / SIZEOF_VOID_P) // In blocks #define NONMOVING_SEGMENT_BLOCKS (NONMOVING_SEGMENT_SIZE / BLOCK_SIZE) ===================================== testsuite/driver/testlib.py ===================================== @@ -149,6 +149,15 @@ def js_broken( bug: IssueNumber ): else: return normal; +def nonmoving_test( name, opts ): + """ + Always run the given test with the nonmoving collector, in addition to + the usual ways. + + See Note [Testing the nonmoving collector] in rts/sm/NonMoving.c. + """ + return extra_ways(['nonmoving', 'nonmoving_thr_sanity', 'nonmoving_thr_ghc'])(name, opts) + def expect_fail( name, opts ): # The compiler, testdriver, OS or platform is missing a certain # feature, and we don't plan to or can't fix it now or in the @@ -1023,8 +1032,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): ===================================== testsuite/tests/array/should_run/all.T ===================================== @@ -21,6 +21,6 @@ test('arr014', when(fast(), skip), compile_and_run, ['']) test('arr015', when(fast(), skip), compile_and_run, ['']) test('arr017', when(fast(), skip), compile_and_run, ['']) test('arr018', when(fast(), skip), compile_and_run, ['']) -test('arr019', normal, compile_and_run, ['']) -test('arr020', normal, compile_and_run, ['']) +test('arr019', nonmoving_test, compile_and_run, ['']) +test('arr020', nonmoving_test, compile_and_run, ['']) test('T21962', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -1,18 +1,18 @@ # ----------------------------------------------------------------------------- # These tests we do even for 'make fast' -test('conc003', normal, compile_and_run, ['']) -test('conc006', normal, compile_and_run, ['']) -test('conc027', normal, compile_and_run, ['']) -test('conc051', normal, compile_and_run, ['']) +test('conc003', nonmoving_test, compile_and_run, ['']) +test('conc006', nonmoving_test, compile_and_run, ['']) +test('conc027', nonmoving_test, compile_and_run, ['']) +test('conc051', nonmoving_test, compile_and_run, ['']) if ('threaded1' in config.run_ways): only_threaded_ways = only_ways(['ghci','threaded1','threaded2', 'nonmoving_thr']) else: only_threaded_ways = skip -test('conc069', only_threaded_ways, compile_and_run, ['']) -test('conc069a', only_threaded_ways, compile_and_run, ['']) +test('conc069', [nonmoving_test, only_threaded_ways], compile_and_run, ['']) +test('conc069a', [nonmoving_test, only_threaded_ways], compile_and_run, ['']) # this test gives slightly different results for non-threaded ways, so omit # those for now. test('conc070', only_threaded_ways, compile_and_run, ['']) @@ -47,8 +47,8 @@ test('T3429', [ extra_run_opts('+RTS -C0.001 -RTS'), # times out with ghci test('T4030', omit_ghci, compile_and_run, ['-O']) -test('throwto002', normal, compile_and_run, ['']) -test('throwto003', normal, compile_and_run, ['']) +test('throwto002', nonmoving_test, compile_and_run, ['']) +test('throwto003', nonmoving_test, compile_and_run, ['']) test('mask001', normal, compile_and_run, ['']) test('mask002', js_broken(22261), compile_and_run, ['']) @@ -81,9 +81,9 @@ test('T5611a', fragile(12751), compile_and_run, ['']) test('T5238', normal, compile_and_run, ['']) test('T5866', exit_code(1), compile_and_run, ['']) -test('readMVar1', normal, compile_and_run, ['']) -test('readMVar2', normal, compile_and_run, ['']) -test('readMVar3', normal, compile_and_run, ['']) +test('readMVar1', nonmoving_test, compile_and_run, ['']) +test('readMVar2', nonmoving_test, compile_and_run, ['']) +test('readMVar3', nonmoving_test, compile_and_run, ['']) test('tryReadMVar1', normal, compile_and_run, ['']) test('tryReadMVar2', normal, compile_and_run, ['']) @@ -121,9 +121,9 @@ test('allocLimit4', [ extra_run_opts('+RTS -xq300k -RTS'), setTestOpts(when(fast(), skip)) -test('conc001', normal, compile_and_run, ['']) -test('conc002', normal, compile_and_run, ['']) -test('conc004', normal, compile_and_run, ['']) +test('conc001', nonmoving_test, compile_and_run, ['']) +test('conc002', nonmoving_test, compile_and_run, ['']) +test('conc004', nonmoving_test, compile_and_run, ['']) test('conc007', extra_run_opts('+RTS -H128M -RTS'), compile_and_run, ['']) test('conc008', normal, compile_and_run, ['']) test('conc009', exit_code(1), compile_and_run, ['']) @@ -218,16 +218,17 @@ test('conc039', [omit_ways(ghci_ways + threaded_ways), js_skip], compile_and_run test('conc040', [exit_code(1), omit_ghci, js_skip], compile_and_run, ['']) # STM-related tests. -test('conc041', normal, compile_and_run, ['']) -test('conc042', normal, compile_and_run, ['']) -test('conc043', normal, compile_and_run, ['']) -test('conc044', normal, compile_and_run, ['']) -test('conc045', normal, compile_and_run, ['']) +test('conc041', nonmoving_test, compile_and_run, ['']) +test('conc042', nonmoving_test, compile_and_run, ['']) +test('conc043', nonmoving_test, compile_and_run, ['']) +test('conc044', nonmoving_test, compile_and_run, ['']) +test('conc045', nonmoving_test, compile_and_run, ['']) -test('conc058', normal, compile_and_run, ['']) +test('conc058', nonmoving_test, compile_and_run, ['']) test('conc059', [only_ways(['threaded1', 'threaded2', 'nonmoving_thr']), + nonmoving_test, pre_cmd('$MAKE -s --no-print-directory conc059_setup')], compile_and_run, ['conc059_c.c -no-hs-main']) ===================================== testsuite/tests/driver/T16737.hs deleted ===================================== @@ -1,32 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -DFOO=2 -optP=-DBAR=3 -optc=-DBAZ=5 -optcxx=-DBAZ=7 #-} - -import Language.Haskell.TH.Syntax - -do - let code = unlines - [ "#if defined(__cplusplus)" - , "extern \"C\" {" - , "#endif" - , "#include " - , "int FUN(void) {" - , " return FOO * BAR * BAZ;" - , "}" - , "#if defined(__cplusplus)" - , "}" - , "#endif" - ] - addForeignSource LangC code - addForeignSource LangCxx code - pure [] - -foreign import ccall unsafe "c_value" - c_value :: IO Int - -foreign import ccall unsafe "cxx_value" - cxx_value :: IO Int - -main :: IO () -main = do - print =<< c_value - print =<< cxx_value ===================================== testsuite/tests/driver/T16737.stdout deleted ===================================== @@ -1,2 +0,0 @@ -30 -42 ===================================== testsuite/tests/driver/T16737include/T16737.h deleted ===================================== @@ -1,7 +0,0 @@ -#pragma once - -#if defined(__cplusplus) -#define FUN cxx_value -#else -#define FUN c_value -#endif ===================================== testsuite/tests/driver/all.T ===================================== @@ -285,12 +285,6 @@ test('inline-check', [omit_ways(['hpc', 'profasm'])] test('T14452', js_broken(22261), makefile_test, []) test('T14923', normal, makefile_test, []) test('T15396', normal, compile_and_run, ['-package ghc']) -test('T16737', - [extra_files(['T16737include/']), - req_th, - req_c, - expect_broken_for(16541, ghci_ways)], - compile_and_run, ['-optP=-isystem -optP=T16737include']) test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== testsuite/tests/simplCore/should_compile/T21348.hs ===================================== @@ -0,0 +1,97 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableInstances #-} + +module T21348 where + +import qualified Data.Map as M +import Data.Kind (Type) + +newtype Parser a = Parser { + runParser :: () -> (a -> Int) -> Int + } deriving (Functor) + +instance Applicative Parser where + pure a = Parser $ \_path ks -> ks a + {-# INLINE pure #-} + (<*>) m e = Parser $ \path ks -> let ks' a = runParser (a <$> e) path ks + in runParser m path ks' + {-# INLINE (<*>) #-} + +data Value = Object (M.Map String Value) | Unused + +class FromJSON a where + parseJSON :: Value -> Parser a + _unused :: a -> a + +instance FromJSON Bool where + parseJSON _ = pure False + _unused = id + +data Pa a = MkPa Bool a + +class RecordFromJSON f where + recordParseJSON :: () -> M.Map String Value -> Parser (Pa f) + +class RecordFromJSON2 f where + recordParseJSON2 :: M.Map String Value -> Parser f + +instance (RecordFromJSON2 b) => RecordFromJSON b where + recordParseJSON _ obj = MkPa <$> pure False + <*> recordParseJSON2 obj + {-# INLINE recordParseJSON #-} + +instance (FromJSON a) => RecordFromJSON2 a where + recordParseJSON2 obj = pure () *> (id <$> (id <$> parseJSON (obj M.! "x"))) + {-# INLINE recordParseJSON2 #-} + +data Rec :: [Type] -> Type where + RNil :: Rec '[] + RCons :: Field r -> Rec rs -> Rec (r ': rs) + +data Rec2 :: [Type] -> Type where + RNil2 :: Rec2 '[] + RCons2 :: DocField r -> Rec2 rs -> Rec2 (r ': rs) + +data Field x = Field x + +newtype DocField x = DocField (Field x) + +instance FromJSON (Rec '[]) where + parseJSON _ = undefined + _unused = id + +instance (FromJSON t, FromJSON (Rec rs)) => FromJSON (Rec (t ': rs)) where + parseJSON v = rebuild <$> parseJSON v <*> parseJSON v + where rebuild m rest = Field m `RCons` rest + _unused = id + +instance (RMap rs, FromJSON (Rec rs)) => FromJSON (Rec2 rs) where + parseJSON v = rmap DocField <$> parseJSON v + _unused = id + +class RMap rs where + rmap :: (forall x. Field x -> DocField x) -> Rec rs -> Rec2 rs + +instance RMap '[] where + rmap _ RNil = RNil2 + {-# INLINE rmap #-} + +instance RMap xs => RMap (x ': xs) where + rmap f (x `RCons` xs) = f x `RCons2` rmap f xs + {-# INLINE rmap #-} + +g :: RecordFromJSON a => Value -> Parser (Pa a) +g (Object r) = recordParseJSON () r +g Unused = undefined + +bug :: Value -> Parser (Pa (Rec2 '[Bool, Bool, Bool, Bool])) +bug = g ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -503,3 +503,4 @@ test('T23922a', normal, compile, ['-O']) test('T23952', [extra_files(['T23952a.hs'])], multimod_compile, ['T23952', '-v0 -O']) test('T24014', normal, compile, ['-dcore-lint']) test('T24029', normal, compile, ['']) +test('T21348', normal, compile, ['-O']) ===================================== testsuite/tests/th/T24046.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T24046 where + +import Language.Haskell.TH.Syntax + +-- Test added in relation to this issue: https://gitlab.haskell.org/ghc/ghc/-/issues/24046 + +{-# NOINLINE foo #-} +foo = undefined + +$( let simplerule = [PragmaD $ RuleP "rejected-rule" Nothing foralld lhs rhs AllPhases] + + foralld = [RuleVar $ mkName "x", RuleVar $ mkName "y"] + + lhs = AppE (AppE (VarE $ mkName "foo") (VarE $ mkName "x")) (VarE $ mkName "y") + + rhs = AppE (AppE (VarE $ mkName "foo") (VarE $ mkName "y")) (VarE $ mkName "x") + in return simplerule) ===================================== testsuite/tests/th/all.T ===================================== @@ -146,6 +146,7 @@ test('T2817', normal, compile, ['-v0']) test('T2713', normal, compile_fail, ['-v0']) test('T2674', normal, compile_fail, ['-v0']) test('TH_emptycase', normal, compile, ['-v0']) +test('T24046', normal, compile, ['-v0']) test('T2386', [only_ways(['normal'])], makefile_test, ['T2386']) ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit 2d75eb33d4c179b1c21000d32c2906ad273de0de +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34f927525bdc679ac56f53993c7911bcf5f68832...742d819d67371ba2cbb6c49a0cf29ffdec69e2cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34f927525bdc679ac56f53993c7911bcf5f68832...742d819d67371ba2cbb6c49a0cf29ffdec69e2cd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 06:46:44 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Oct 2023 02:46:44 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Actually set hackage index state Message-ID: <651fad54b1ece_18f529442b0dec600895@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 69e2b2cf by Bryan Richter at 2023-10-06T02:46:36-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 9c9cd509 by Bryan Richter at 2023-10-06T02:46:36-04:00 Update hackage index state - - - - - 8a9dfa34 by Bryan Richter at 2023-10-06T02:46:36-04:00 Ensure hadrian uses CI's hackage index state - - - - - c8f77472 by David Binder at 2023-10-06T02:46:39-04:00 Update hpc-bin submodule to 0.69 - - - - - 4 changed files: - .gitlab/ci.sh - hadrian/cabal.project - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -230,7 +230,7 @@ function set_toolchain_paths() { function cabal_update() { # In principle -w shouldn't be necessary here but with # cabal-install 3.8.1.0 it is, due to cabal#8447. - run "$CABAL" update -w "$GHC" --index="$HACKAGE_INDEX_STATE" + run "$CABAL" update -w "$GHC" "hackage.haskell.org,${HACKAGE_INDEX_STATE}" } @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit 2d75eb33d4c179b1c21000d32c2906ad273de0de +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/742d819d67371ba2cbb6c49a0cf29ffdec69e2cd...c8f7747250bf10e0bf6737704b799e9bfd7e4883 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/742d819d67371ba2cbb6c49a0cf29ffdec69e2cd...c8f7747250bf10e0bf6737704b799e9bfd7e4883 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 08:53:31 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 06 Oct 2023 04:53:31 -0400 Subject: [Git][ghc/ghc][wip/backports-9.8] Work around perf note fetch failure Message-ID: <651fcb0aa11a7_18f529471e047862385@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC Commits: b238204e by Bryan Richter at 2023-10-06T04:53:24-04:00 Work around perf note fetch failure Addresses #24055. (cherry picked from commit 63afb701a1638d7bd32c34fb24a9fd3ff897b634) - - - - - 1 changed file: - .gitlab/test-metrics.sh Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b238204e4621f474393f4585fa1cce9c094b2885 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b238204e4621f474393f4585fa1cce9c094b2885 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 08:53:51 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 06 Oct 2023 04:53:51 -0400 Subject: [Git][ghc/ghc][wip/release-9.8.1] 5 commits: Bump stm submodule to 2.5.2.0 Message-ID: <651fcb1f7813e_18f529472072bc624230@gitlab.mail> Ben Gamari pushed to branch wip/release-9.8.1 at Glasgow Haskell Compiler / GHC Commits: 47b202a9 by Ben Gamari at 2023-10-05T23:32:49-04:00 Bump stm submodule to 2.5.2.0 - - - - - 31d4e495 by Ben Gamari at 2023-10-05T23:32:49-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 7c268df5 by Ben Gamari at 2023-10-05T23:32:54-04:00 Allow perf changes These appear to be spurious. Metric Decrease: MultiLayerModules T13701 T14697 - - - - - b238204e by Bryan Richter at 2023-10-06T04:53:24-04:00 Work around perf note fetch failure Addresses #24055. (cherry picked from commit 63afb701a1638d7bd32c34fb24a9fd3ff897b634) - - - - - 99cb835d by Ben Gamari at 2023-10-06T04:53:44-04:00 Release GHC 9.8.1 - - - - - 7 changed files: - .gitlab/test-metrics.sh - compiler/ghc.cabal.in - configure.ac - libraries/hpc - libraries/stm - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== .gitlab/test-metrics.sh ===================================== @@ -17,7 +17,12 @@ fail() { function pull() { local ref="refs/notes/$REF" - run git fetch -f "$NOTES_ORIGIN" "$ref:$ref" + # 2023-10-04: `git fetch` started failing, first on Darwin in CI and then on + # Linux locally, both using git version 2.40.1. See #24055. One workaround is + # to set a larger http.postBuffer, although this is definitely a workaround. + # The default should work just fine. The error could be in git, GitLab, or + # perhaps the networking tube (including all proxies etc) between the two. + run git -c http.postBuffer=2097152 fetch -f "$NOTES_ORIGIN" "$ref:$ref" echo "perf notes ref $ref is $(git rev-parse $ref)" } ===================================== compiler/ghc.cabal.in ===================================== @@ -105,7 +105,7 @@ Library array >= 0.1 && < 0.6, filepath >= 1 && < 1.5, template-haskell == 2.21.*, - hpc == 0.6.*, + hpc >= 0.6 && < 0.8, transformers >= 0.5 && < 0.7, exceptions == 0.10.*, semaphore-compat, ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.0], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -22,7 +22,7 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.0], [glasgow-has AC_CONFIG_MACRO_DIRS([m4]) # Set this to YES for a released version, otherwise NO -: ${RELEASE=NO} +: ${RELEASE=YES} # The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line # above. If this is not a released version, then we will append the ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 50d520bf6002ab55032e233dced0556ad63ad0c0 +Subproject commit 6bc66b7ae490d28d6b17d01c2959d6c8ce3e7a79 ===================================== libraries/stm ===================================== @@ -1 +1 @@ -Subproject commit f8582bd6e31df73b4f18f676650ae183624d8eb2 +Subproject commit a1e91f4ea010be61a9c8a94d6a200bfb4dc6d049 ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit eb800fe76409f54660335496592f777ae215ff92 +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5695bb42099077817e43a0a41d4f5526ac68550b...99cb835d46624c0ef81fa3a5a11513d402c58460 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5695bb42099077817e43a0a41d4f5526ac68550b...99cb835d46624c0ef81fa3a5a11513d402c58460 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 08:57:57 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Oct 2023 04:57:57 -0400 Subject: [Git][ghc/ghc][wip/libbin] hadrian: Build all executables in bin/ folder Message-ID: <651fcc15b17f8_18f529478079dc624661@gitlab.mail> Matthew Pickering pushed to branch wip/libbin at Glasgow Haskell Compiler / GHC Commits: 3820f5b3 by Matthew Pickering at 2023-10-06T09:57:48+01:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 4 changed files: - hadrian/bindist/Makefile - hadrian/src/Packages.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs Changes: ===================================== hadrian/bindist/Makefile ===================================== @@ -117,7 +117,7 @@ lib/settings : config.mk @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ - @echo ',("unlit command", "$$topdir/bin/$(CrossCompilePrefix)unlit")' >> $@ + @echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@ @echo ',("target os", "$(HaskellTargetOs)")' >> $@ @@ -188,7 +188,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - chmod ugo+rx "$$dest"/bin/* # Work around #17418 on Darwin if [ -e "${XATTR}" ]; then \ "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ ===================================== hadrian/src/Packages.hs ===================================== @@ -202,14 +202,8 @@ programName Context {..} = do -- | The 'FilePath' to a program executable in a given 'Context'. programPath :: Context -> Action FilePath programPath context at Context {..} = do - -- TODO: The @touchy@ utility lives in the @lib/bin@ directory instead of - -- @bin@, which is likely just a historical accident that should be fixed. - -- See: https://github.com/snowleopard/hadrian/issues/570 - -- Likewise for @iserv@ and @unlit at . name <- programName context - path <- if package `elem` [iserv, touchy, unlit] - then stageLibPath stage <&> (-/- "bin") - else stageBinPath stage + path <- stageBinPath stage return $ path -/- name <.> exe -- TODO: Move @timeout@ to the @util@ directory and build in a more standard ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -469,7 +469,7 @@ generateSettings = do , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand) , ("windres command", queryTarget (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me. - , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) + , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) , ("cross compiling", expr $ yesNo <$> flag CrossCompiling) , ("target platform string", queryTarget targetPlatformTriple) , ("target os", queryTarget (show . archOS_OS . tgtArchOs)) ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -38,7 +38,7 @@ buildProgramRules rs = do -- Rules for programs that are actually built by hadrian. forM_ allStages $ \stage -> [ root -/- stageString stage -/- "bin" -/- "*" - , root -/- stageString stage -/- "lib/bin" -/- "*" ] |%> \bin -> do + ] |%> \bin -> do programContexts <- getProgramContexts stage case lookupProgramContext bin programContexts of Nothing -> error $ "Unknown program " ++ show bin @@ -105,9 +105,6 @@ buildProgram bin ctx@(Context{..}) rs = do (True, s) | s > stage0InTree -> do srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin")) copyFile (srcDir -/- takeFileName bin) bin - (False, s) | s > stage0InTree && (package `elem` [touchy, unlit]) -> do - srcDir <- stageLibPath stage0InTree <&> (-/- "bin") - copyFile (srcDir -/- takeFileName bin) bin _ -> buildBinary rs bin ctx buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3820f5b30060e3ddb53594cca3a5557b73e9d216 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3820f5b30060e3ddb53594cca3a5557b73e9d216 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 09:02:43 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Oct 2023 05:02:43 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] fix CROSS_STAGE Message-ID: <651fcd3316453_18f529479dab8862815c@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 637eb8a6 by Matthew Pickering at 2023-10-06T10:02:35+01:00 fix CROSS_STAGE - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -490,7 +490,6 @@ function build_hadrian() { export XZ_OPT="${XZ_OPT:-} -T$cores" fi - echo "CROSS_STAGE: $CROSS_STAGE" case "${CROSS_STAGE:-2}" in 2) BINDIST_TARGET="binary-dist";; 3) BINDIST_TARGET="binary-dist-stage3";; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/637eb8a67e18a745c8325e7002a8f6dfd4bcc490 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/637eb8a67e18a745c8325e7002a8f6dfd4bcc490 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 10:27:16 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Oct 2023 06:27:16 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Actually set hackage index state Message-ID: <651fe104dbfd1_18f52949953910644219@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 1adcc15f by Bryan Richter at 2023-10-06T06:27:03-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 1cc334c6 by Bryan Richter at 2023-10-06T06:27:03-04:00 Update hackage index state - - - - - 370cc7cc by Bryan Richter at 2023-10-06T06:27:03-04:00 Ensure hadrian uses CI's hackage index state - - - - - 55b70f0b by David Binder at 2023-10-06T06:27:06-04:00 Update hpc-bin submodule to 0.69 - - - - - 4 changed files: - .gitlab/ci.sh - hadrian/cabal.project - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -230,7 +230,7 @@ function set_toolchain_paths() { function cabal_update() { # In principle -w shouldn't be necessary here but with # cabal-install 3.8.1.0 it is, due to cabal#8447. - run "$CABAL" update -w "$GHC" --index="$HACKAGE_INDEX_STATE" + run "$CABAL" update -w "$GHC" "hackage.haskell.org,${HACKAGE_INDEX_STATE}" } @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit 2d75eb33d4c179b1c21000d32c2906ad273de0de +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c8f7747250bf10e0bf6737704b799e9bfd7e4883...55b70f0b85665c3526ae9af2396b1d66cf0447ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c8f7747250bf10e0bf6737704b799e9bfd7e4883...55b70f0b85665c3526ae9af2396b1d66cf0447ad You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 10:36:24 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Oct 2023 06:36:24 -0400 Subject: [Git][ghc/ghc][wip/T23576] 389 commits: JS: implement getMonotonicTime (fix #23687) Message-ID: <651fe32871b15_18f52949c4234c6506ac@gitlab.mail> Matthew Pickering pushed to branch wip/T23576 at Glasgow Haskell Compiler / GHC Commits: 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 86934453 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Allow big arith on x86 - - - - - e20dba45 by Jaro Reinders at 2023-10-06T10:36:16+00:00 More detailed panic in iselExpr64 - - - - - 275f418c by Jaro Reinders at 2023-10-06T10:36:16+00:00 Better debug message attempt 2 - - - - - 78163383 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Implement negation - - - - - b069a73a by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add MO_Mul case in iselExpr64 - - - - - c2cebfa8 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Try fixing iselExpr64 for MO_Mul - - - - - 90a5c150 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix MO_Mul some more - - - - - 10cc1214 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add AllowBigQuot option to StgToCmm - - - - - c61c0d98 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Implement MO_Shl in iselExpr64 - - - - - 228bfd56 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add SHRD to regUsage - - - - - 81b36ff6 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add SHRD to patchRegs - - - - - 966e4e27 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add SHRD to pprInstr - - - - - d3305615 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add more shifts - - - - - 5434c30d by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add bitwise operations - - - - - 8d21d57b by Jaro Reinders at 2023-10-06T10:36:16+00:00 Insert unconditional jumps before NEWBLOCK - - - - - 074c893d by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix blocks - - - - - b8ebf595 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add condIntCode for 64-bit ints on i386 - - - - - 5525694d by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix typo - - - - - 52c03684 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add MO_UU_Conv W64 W8 - - - - - 25a0f8f5 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add CmmRegOff case to iselExpr64 - - - - - ba0de08c by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add MO_UU_Conv W64 W16 - - - - - 368dc233 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add MO_SS_Conv W16/W8 W64 - - - - - e330271b by Jaro Reinders at 2023-10-06T10:36:16+00:00 Revert confFltCode changes - - - - - 4ebc662a by Jaro Reinders at 2023-10-06T10:36:16+00:00 Remove whitespace and add temporary quottish cases - - - - - dd7ac01b by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fixes - - - - - 261b9331 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add MO_UU_Conv w W64 - - - - - b8df3f6a by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix MO_SS_Conv W8/16 W64 - - - - - 70a5225b by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix MO_SS_Conv W8/16 W64 again - - - - - 57b82bbc by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix MO_SS_Conv W8/16 W64 again again - - - - - 7ee6e7da by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix MO_SS_Conv W8/16 W64 again again again - - - - - 355118ea by Jaro Reinders at 2023-10-06T10:36:16+00:00 Remove temporary quottish ops - - - - - 95c07e1e by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix condIntCode' - - - - - e41d7e37 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix condIntCode' again - - - - - e43cb680 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Fix whitespace and update comment - - - - - bacf545b by Jaro Reinders at 2023-10-06T10:36:16+00:00 Remove workarounds - - - - - ebd24460 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Remove stray comment - - - - - 3d2ee298 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Remove redundant code and move note - - - - - 7c5a0da2 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Add comments and abstract over common case. - - - - - 31a4cc43 by Jaro Reinders at 2023-10-06T10:36:16+00:00 Remove SAL and use the equivalent SHL instead - - - - - 15 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/generate-ci/generate-job-metadata - .gitlab/generate-ci/generate-jobs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitlab/test-metrics.sh - README.md - compiler/CodeGen.Platform.h - compiler/GHC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23eabdf5b1123e489da5582b80f9c0fa6e52d205...31a4cc4384253321236a648b50818393351b4faf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23eabdf5b1123e489da5582b80f9c0fa6e52d205...31a4cc4384253321236a648b50818393351b4faf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 10:56:26 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 06 Oct 2023 06:56:26 -0400 Subject: [Git][ghc/ghc][wip/T23442] CorePrep: Refactor FloatingBind (#23442) Message-ID: <651fe7d9d7224_18f5294a53b7c8653235@gitlab.mail> Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC Commits: 076b2128 by Sebastian Graf at 2023-10-06T12:55:58+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- fulsom 0.0% -0.3% ida 0.0% +0.1% linear 0.0% +0.1% mandel2 0.0% -0.4% pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min -0.0% -1.7% Max +0.0% +0.1% Geometric Mean -0.0% -0.0% ``` - - - - - 2 changed files: - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,253 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec + * `CaseBound`: A (NonRec) case binding `case rhs of x -> { __DEFAULT -> .. }`. + Some (string literals, lifted bindings), but not all case-bound + things can go to top-level, hence it is similar to, but not the + same as `LazyContextFloatable :: FloatInfo` described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + NB: You might think this is the same as `CaseBound`, but it is not: + String literals and lifted, ok-for-spec-eval things are + `TopLvlFloatable` but are `CaseBound`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +All lifted bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2036,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2397,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/076b21288ca197ec5bcc74b8d8882cab662b408b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/076b21288ca197ec5bcc74b8d8882cab662b408b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 11:11:18 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Oct 2023 07:11:18 -0400 Subject: [Git][ghc/ghc][wip/libbin] hadrian: Build all executables in bin/ folder Message-ID: <651feb566bbae_18f5294abc3104660862@gitlab.mail> Matthew Pickering pushed to branch wip/libbin at Glasgow Haskell Compiler / GHC Commits: f7d4a061 by Matthew Pickering at 2023-10-06T12:11:03+01:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 5 changed files: - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Packages.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs Changes: ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -38,7 +38,7 @@ initSettings top_dir = do let installed :: FilePath -> FilePath installed file = top_dir file libexec :: FilePath -> FilePath - libexec file = top_dir "bin" file + libexec file = top_dir ".." "bin" file settingsFile = installed "settings" readFileSafe :: FilePath -> ExceptT SettingsError m String ===================================== hadrian/bindist/Makefile ===================================== @@ -117,7 +117,7 @@ lib/settings : config.mk @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ - @echo ',("unlit command", "$$topdir/bin/$(CrossCompilePrefix)unlit")' >> $@ + @echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@ @echo ',("target os", "$(HaskellTargetOs)")' >> $@ @@ -188,7 +188,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - chmod ugo+rx "$$dest"/bin/* # Work around #17418 on Darwin if [ -e "${XATTR}" ]; then \ "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ ===================================== hadrian/src/Packages.hs ===================================== @@ -202,14 +202,8 @@ programName Context {..} = do -- | The 'FilePath' to a program executable in a given 'Context'. programPath :: Context -> Action FilePath programPath context at Context {..} = do - -- TODO: The @touchy@ utility lives in the @lib/bin@ directory instead of - -- @bin@, which is likely just a historical accident that should be fixed. - -- See: https://github.com/snowleopard/hadrian/issues/570 - -- Likewise for @iserv@ and @unlit at . name <- programName context - path <- if package `elem` [iserv, touchy, unlit] - then stageLibPath stage <&> (-/- "bin") - else stageBinPath stage + path <- stageBinPath stage return $ path -/- name <.> exe -- TODO: Move @timeout@ to the @util@ directory and build in a more standard ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -469,7 +469,7 @@ generateSettings = do , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand) , ("windres command", queryTarget (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me. - , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) + , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) , ("cross compiling", expr $ yesNo <$> flag CrossCompiling) , ("target platform string", queryTarget targetPlatformTriple) , ("target os", queryTarget (show . archOS_OS . tgtArchOs)) ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -38,7 +38,7 @@ buildProgramRules rs = do -- Rules for programs that are actually built by hadrian. forM_ allStages $ \stage -> [ root -/- stageString stage -/- "bin" -/- "*" - , root -/- stageString stage -/- "lib/bin" -/- "*" ] |%> \bin -> do + ] |%> \bin -> do programContexts <- getProgramContexts stage case lookupProgramContext bin programContexts of Nothing -> error $ "Unknown program " ++ show bin @@ -105,9 +105,6 @@ buildProgram bin ctx@(Context{..}) rs = do (True, s) | s > stage0InTree -> do srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin")) copyFile (srcDir -/- takeFileName bin) bin - (False, s) | s > stage0InTree && (package `elem` [touchy, unlit]) -> do - srcDir <- stageLibPath stage0InTree <&> (-/- "bin") - copyFile (srcDir -/- takeFileName bin) bin _ -> buildBinary rs bin ctx buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7d4a06110babcb8113cf9ad9a23bc82ea76a2e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7d4a06110babcb8113cf9ad9a23bc82ea76a2e3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 11:35:40 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Oct 2023 07:35:40 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] fix libbin Message-ID: <651ff10c5cdeb_18f5294b7aa878663049@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 74ba41dd by Matthew Pickering at 2023-10-06T12:35:09+01:00 fix libbin - - - - - 1 changed file: - compiler/GHC/Settings/IO.hs Changes: ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -38,7 +38,7 @@ initSettings top_dir = do let installed :: FilePath -> FilePath installed file = top_dir file libexec :: FilePath -> FilePath - libexec file = top_dir "bin" file + libexec file = top_dir ".." "bin" file settingsFile = installed "settings" readFileSafe :: FilePath -> ExceptT SettingsError m String View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74ba41ddd2147f3e6aaf1cd2f2f2e7f3fb621f7f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74ba41ddd2147f3e6aaf1cd2f2f2e7f3fb621f7f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 11:36:25 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 06 Oct 2023 07:36:25 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 2 commits: fail when bindist configure fails Message-ID: <651ff139ec16_18f5294b78fc4466329c@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: b6410078 by GHC GitLab CI at 2023-10-06T11:36:06+00:00 fail when bindist configure fails - - - - - e8c6538d by GHC GitLab CI at 2023-10-06T11:36:06+00:00 Correctly propagate build/host/target to bindist - - - - - 4 changed files: - .gitlab/ci.sh - configure.ac - distrib/configure.ac.in - m4/fptools_set_platform_vars.m4 Changes: ===================================== .gitlab/ci.sh ===================================== @@ -560,7 +560,7 @@ function install_bindist() { run ${CONFIGURE_WRAPPER:-} ./configure \ --prefix="$instdir" \ - "${args[@]+"${args[@]}"}" + "${args[@]+"${args[@]}"}" || fail "bindist configure failed" make_install_destdir "$TOP"/destdir "$instdir" ;; esac ===================================== configure.ac ===================================== @@ -286,6 +286,7 @@ if test "${WithGhc}" != "" then bootstrap_host=`"${WithGhc}" +RTS --info | grep '^ ,("Host platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'` bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'` + bootstrap_build="$bootstrap_host" if test "$bootstrap_host" != "$bootstrap_target" then echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work" ===================================== distrib/configure.ac.in ===================================== @@ -21,6 +21,8 @@ dnl * Deal with arguments telling us gmp is somewhere odd dnl-------------------------------------------------------------------- dnl Various things from the source distribution configure +bootstrap_build=@BuildPlatform@ +bootstrap_host=@HostPlatform@ bootstrap_target=@TargetPlatform@ bootstrap_llvm_target=@LlvmTarget@ ===================================== m4/fptools_set_platform_vars.m4 ===================================== @@ -77,9 +77,9 @@ dnl fi # compiler's target platform. AC_DEFUN([FPTOOLS_OVERRIDE_PLATFORM_FROM_BOOTSTRAP], [ - if test "$bootstrap_target" != "" + if test "$bootstrap_$1" != "" then - $1=$bootstrap_target + $1=$bootstrap_$1 echo "$1 platform inferred as: [$]$1" else echo "Can't work out $1 platform" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/74ba41ddd2147f3e6aaf1cd2f2f2e7f3fb621f7f...e8c6538db02b9f463883902f5411066bd0944a20 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/74ba41ddd2147f3e6aaf1cd2f2f2e7f3fb621f7f...e8c6538db02b9f463883902f5411066bd0944a20 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 13:01:27 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 06 Oct 2023 09:01:27 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backports-9.8 Message-ID: <65200527d9bc5_18f5294d412c686727eb@gitlab.mail> Ben Gamari deleted branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 13:01:31 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 06 Oct 2023 09:01:31 -0400 Subject: [Git][ghc/ghc][ghc-9.8] 15 commits: configure: Fix #21712 again Message-ID: <6520052bab85a_18f5294d26b37467294e@gitlab.mail> Ben Gamari pushed to branch ghc-9.8 at Glasgow Haskell Compiler / GHC Commits: 2a51d113 by Ben Gamari at 2023-10-05T16:13:45-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. (cherry picked from commit f6b2751f58df5f4f83caa7a7ca56e66659d02b09) - - - - - 8ed7ffb6 by Ben Gamari at 2023-10-05T16:13:45-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. (cherry picked from commit 8f6010b98f560200997a9d84a4e07bfd0ad6e496) - - - - - 894b6027 by sheaf at 2023-10-05T16:13:45-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 (cherry picked from commit 8cee3fd7febdd97a9b4bcae7dddafe69b166149c) - - - - - 9fb11d4a by Andreas Klebinger at 2023-10-05T16:15:25-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig (cherry picked from commit b048bea095d48751e7c182f2837c4a31fcad8fd7) - - - - - b3ab756f by Andreas Klebinger at 2023-10-05T17:41:42-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 (cherry picked from commit 2adc050857a9c1b992040fbfd55fbe65b2851b19) - - - - - 857967ae by Luite Stegeman at 2023-10-05T17:41:42-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 (cherry picked from commit 11ecc37bc27ffa1cf31358e21e09e140befa940c) - - - - - 81b1179d by Ben Gamari at 2023-10-05T17:41:42-04:00 system-cxx-std-lib: Add license and description (cherry picked from commit 151187407b7b4bdda5b80bd7b8bdf96d05e278dd) - - - - - 0fc4ce51 by Torsten Schmits at 2023-10-05T17:41:42-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 (cherry picked from commit 083794b10dc27e9d97b62cc8b8eb4e1da162bf66) - - - - - e538003c by Alexis King at 2023-10-05T17:41:42-04:00 Don’t store the async exception masking state in CATCH frames (cherry picked from commit 8b61dfd6dfc78bfa6bb9449dac9a336e5d668b5e) - - - - - 46896580 by Ben Gamari at 2023-10-05T17:41:42-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. (cherry picked from commit b35fd2cd7a12f3354a7fd2301bdf610c5d435017) - - - - - 34bd605d by Ben Gamari at 2023-10-05T17:41:42-04:00 Bump unix submodule to 2.8.3.0 - - - - - 47b202a9 by Ben Gamari at 2023-10-05T23:32:49-04:00 Bump stm submodule to 2.5.2.0 - - - - - 31d4e495 by Ben Gamari at 2023-10-05T23:32:49-04:00 Bump hpc submodule to 0.7.0.0 - - - - - 7c268df5 by Ben Gamari at 2023-10-05T23:32:54-04:00 Allow perf changes These appear to be spurious. Metric Decrease: MultiLayerModules T13701 T14697 - - - - - b238204e by Bryan Richter at 2023-10-06T04:53:24-04:00 Work around perf note fetch failure Addresses #24055. (cherry picked from commit 63afb701a1638d7bd32c34fb24a9fd3ff897b634) - - - - - 30 changed files: - .gitlab/rel_eng/upload_ghc_libs.py - .gitlab/test-metrics.sh - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Config/HsToCore/Ticks.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - docs/users_guide/debug-info.rst - docs/users_guide/ghci.rst - docs/users_guide/phases.rst - ghc/Main.hs - libraries/base/configure.ac - libraries/base/jsbits/base.js - libraries/hpc - libraries/stm - libraries/unix - m4/find_ld.m4 - mk/system-cxx-std-lib-1.0.conf.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86c1bdc48a6d4bc059c3fffb5c27d4fd69fc81bc...b238204e4621f474393f4585fa1cce9c094b2885 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86c1bdc48a6d4bc059c3fffb5c27d4fd69fc81bc...b238204e4621f474393f4585fa1cce9c094b2885 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 14:27:43 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Oct 2023 10:27:43 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Actually set hackage index state Message-ID: <6520195f9ad06_18f5294f61a8886904f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0e42688b by Bryan Richter at 2023-10-06T10:27:32-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 6705eb9c by Bryan Richter at 2023-10-06T10:27:32-04:00 Update hackage index state - - - - - 1c870c1b by Bryan Richter at 2023-10-06T10:27:32-04:00 Ensure hadrian uses CI's hackage index state - - - - - a3b86389 by David Binder at 2023-10-06T10:27:35-04:00 Update hpc-bin submodule to 0.69 - - - - - 4 changed files: - .gitlab/ci.sh - hadrian/cabal.project - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -230,7 +230,7 @@ function set_toolchain_paths() { function cabal_update() { # In principle -w shouldn't be necessary here but with # cabal-install 3.8.1.0 it is, due to cabal#8447. - run "$CABAL" update -w "$GHC" --index="$HACKAGE_INDEX_STATE" + run "$CABAL" update -w "$GHC" "hackage.haskell.org,${HACKAGE_INDEX_STATE}" } @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit 2d75eb33d4c179b1c21000d32c2906ad273de0de +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/55b70f0b85665c3526ae9af2396b1d66cf0447ad...a3b863896fe178463362d9c734d15eda0cf13dbf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/55b70f0b85665c3526ae9af2396b1d66cf0447ad...a3b863896fe178463362d9c734d15eda0cf13dbf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 15:14:58 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 06 Oct 2023 11:14:58 -0400 Subject: [Git][ghc/ghc][wip/T24052] 3 commits: testsuite: Fix invalid string literal Message-ID: <652024725c274_18f52950526fe8709674@gitlab.mail> Ben Gamari pushed to branch wip/T24052 at Glasgow Haskell Compiler / GHC Commits: 39248140 by Ben Gamari at 2023-10-03T12:27:46-04:00 testsuite: Fix invalid string literal `"\+"` is not a valid Python string; this should have been `r"\+"`. - - - - - 610067f2 by Ben Gamari at 2023-10-03T12:27:46-04:00 rts/nonmoving: Reflow notes - - - - - cf4160cf by Ben Gamari at 2023-10-06T11:14:47-04:00 testsuite: Run some tests unconditionally in nonmoving ways Improve test coverage of the nonmoving collector by running a small subset of tests unconditionally with the nonmoving collector. Fixes #24052. - - - - - 4 changed files: - rts/sm/NonMoving.c - testsuite/driver/testlib.py - testsuite/tests/array/should_run/all.T - testsuite/tests/concurrent/should_run/all.T Changes: ===================================== rts/sm/NonMoving.c ===================================== @@ -151,9 +151,9 @@ static void nonmovingBumpEpoch(void) { * 3. [STW] Root collection: Here we walk over a variety of root sources * and add them to the mark queue (see nonmovingCollect). * - * 4. [CONC] Concurrent marking: Here we do the majority of marking concurrently - * with mutator execution (but with the write barrier enabled; see - * Note [Update remembered set]). + * 4. [CONC] Concurrent marking: Here we do the majority of marking + * concurrently with mutator execution (but with the write barrier enabled; + * see Note [Update remembered set]). * * 5. [STW] Final sync: Here we interrupt the mutators, ask them to * flush their final update remembered sets, and mark any new references @@ -218,9 +218,9 @@ static void nonmovingBumpEpoch(void) { * - Note [Concurrent read barrier on deRefWeak#] (NonMovingMark.c) describes * the read barrier on Weak# objects. * - * - Note [Unintentional marking in resurrectThreads] (NonMovingMark.c) describes - * a tricky interaction between the update remembered set flush and weak - * finalization. + * - Note [Unintentional marking in resurrectThreads] (NonMovingMark.c) + * describes a tricky interaction between the update remembered set flush and + * weak finalization. * * - Note [Origin references in the nonmoving collector] (NonMovingMark.h) * describes how we implement indirection short-cutting and the selector @@ -229,8 +229,8 @@ static void nonmovingBumpEpoch(void) { * - Note [StgStack dirtiness flags and concurrent marking] (TSO.h) describes * the protocol for concurrent marking of stacks. * - * - Note [Nonmoving write barrier in Perform{Put,Take}] (PrimOps.cmm) describes - * a tricky barrier necessary when resuming threads blocked on MVar + * - Note [Nonmoving write barrier in Perform{Put,Take}] (PrimOps.cmm) + * describes a tricky barrier necessary when resuming threads blocked on MVar * operations. * * - Note [Static objects under the nonmoving collector] (Storage.c) describes @@ -240,13 +240,17 @@ static void nonmovingBumpEpoch(void) { * how we use the DIRTY flags associated with MUT_VARs and TVARs to improve * barrier efficiency. * - * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) describes - * how weak pointers are handled when the non-moving GC is in use. + * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) + * describes how weak pointers are handled when the non-moving GC is in use. * * - Note [Sync phase marking budget] describes how we avoid long mutator * pauses during the sync phase * - * - Note [Allocator sizes] goes into detail about our choice of allocator sizes. + * - Note [Allocator sizes] goes into detail about our choice of allocator + * sizes. + * + * - Note [Testing the nonmoving collector] describes how we test the + * collector. * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage @@ -259,15 +263,15 @@ static void nonmovingBumpEpoch(void) { * Concurrency-control of non-moving garbage collection is a bit tricky. There * are a few things to keep in mind: * - * - Only one non-moving collection may be active at a time. This is enforced by the - * concurrent_coll_running flag, which is set when a collection is on-going. If - * we attempt to initiate a new collection while this is set we wait on the - * concurrent_coll_finished condition variable, which signals when the - * active collection finishes. + * - Only one non-moving collection may be active at a time. This is enforced + * by the concurrent_coll_running flag, which is set when a collection is + * on-going. If we attempt to initiate a new collection while this is set we + * wait on the concurrent_coll_finished condition variable, which signals + * when the active collection finishes. * - * - In between the mark and sweep phases the non-moving collector must synchronize - * with mutator threads to collect and mark their final update remembered - * sets. This is accomplished using + * - In between the mark and sweep phases the non-moving collector must + * synchronize with mutator threads to collect and mark their final update + * remembered sets. This is accomplished using * stopAllCapabilitiesWith(SYNC_FLUSH_UPD_REM_SET). Capabilities are held * the final mark has concluded. * @@ -361,9 +365,9 @@ static void nonmovingBumpEpoch(void) { * ╰─────────────────╯ * ┆ * - * In this case we have a TSO blocked on a dead MVar. Because the MVAR_TSO_QUEUE on - * which it is blocked lives in the moving heap, the TSO is necessarily on the - * oldest generation's mut_list. As in Note [Aging under the non-moving + * In this case we have a TSO blocked on a dead MVar. Because the MVAR_TSO_QUEUE + * on which it is blocked lives in the moving heap, the TSO is necessarily on + * the oldest generation's mut_list. As in Note [Aging under the non-moving * collector], the MVAR_TSO_QUEUE will be evacuated. If MVAR_TSO_QUEUE is aged * (e.g. evacuated to the young generation) then the MVAR will be added to the * mark queue. Consequently, we will falsely conclude that the MVAR is still @@ -387,9 +391,9 @@ static void nonmovingBumpEpoch(void) { * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The nonmoving collector uses an approximate heuristic for reporting live * data quantity. Specifically, during mark we record how much live data we - * find in nonmoving_segment_live_words. At the end of mark this is combined with nonmoving_large_words - * and nonmoving_compact_words, and we declare this amount to - * be how much live data we have on in the nonmoving heap (by setting + * find in nonmoving_segment_live_words. At the end of mark this is combined + * with nonmoving_large_words and nonmoving_compact_words, and we declare this + * amount to be how much live data we have on in the nonmoving heap (by setting * oldest_gen->live_estimate). * * In addition, we update oldest_gen->live_estimate every time we fill a @@ -413,10 +417,10 @@ static void nonmovingBumpEpoch(void) { * - Minor collections assume that all sparks living in the non-moving heap * are reachable. * - * - Major collections prune the spark queue during the final sync. This pruning - * assumes that all sparks in the young generations are reachable (since the - * BF_EVACUATED flag won't be set on the nursery blocks) and will consequently - * only prune dead sparks living in the non-moving heap. + * - Major collections prune the spark queue during the final sync. This + * pruning assumes that all sparks in the young generations are reachable (since + * the BF_EVACUATED flag won't be set on the nursery blocks) and will + * consequently only prune dead sparks living in the non-moving heap. * * * Note [Dirty flags in the non-moving collector] @@ -439,8 +443,8 @@ static void nonmovingBumpEpoch(void) { * In the non-moving collector we use the same dirty flag to implement a * related optimisation on the non-moving write barrier: Specifically, the * snapshot invariant only requires that the non-moving write barrier applies - * to the *first* mutation to an object after collection begins. To achieve this, - * we impose the following invariant: + * to the *first* mutation to an object after collection begins. To achieve + * this, we impose the following invariant: * * An object being marked as dirty implies that all of its fields are on * the mark queue (or, equivalently, update remembered set). @@ -492,8 +496,8 @@ static void nonmovingBumpEpoch(void) { * ┊ * * This is bad. When we resume mutation a mutator may mutate MVAR A; since it's - * already dirty we would fail to add Y to the update remembered set, breaking the - * snapshot invariant and potentially losing track of the liveness of Z. + * already dirty we would fail to add Y to the update remembered set, breaking + * the snapshot invariant and potentially losing track of the liveness of Z. * * To avoid this nonmovingScavengeOne we eagerly pushes the values of the * fields of all objects which it fails to evacuate (e.g. MVAR A) to the update @@ -535,8 +539,9 @@ static void nonmovingBumpEpoch(void) { * Note [Allocator sizes] * ~~~~~~~~~~~~~~~~~~~~~~ * Our choice of allocator sizes has to balance several considerations: - * - Allocator sizes should be available for the most commonly request block sizes, - * in order to avoid excessive waste from rounding up to the next size (internal fragmentation). + * - Allocator sizes should be available for the most commonly request block + * sizes, in order to avoid excessive waste from rounding up to the next size + * (internal fragmentation). * - It should be possible to efficiently determine which allocator services * a certain block size. * - The amount of allocators should be kept down to avoid overheads @@ -548,18 +553,37 @@ static void nonmovingBumpEpoch(void) { * arbitrary allocator sizes, we need to do some precomputation and make * use of the integer division by constants optimisation. * - * We currenlty try to balance these considerations by adopting the following scheme. - * We have nonmoving_alloca_dense_cnt "dense" allocators starting with size - * NONMOVING_ALLOCA0, and incrementing by NONMOVING_ALLOCA_DENSE_INCREMENT. + * We currenlty try to balance these considerations by adopting the following + * scheme. We have nonmoving_alloca_dense_cnt "dense" allocators starting with + * size NONMOVING_ALLOCA0, and incrementing by NONMOVING_ALLOCA_DENSE_INCREMENT. * These service the vast majority of allocations. * In practice, Haskell programs tend to allocate a lot of small objects. * - * Other allocations are handled by a family of "sparse" allocators, each providing - * blocks up to a power of 2. This places an upper bound on the waste at half the - * required block size. + * Other allocations are handled by a family of "sparse" allocators, each + * providing blocks up to a power of 2. This places an upper bound on the waste + * at half the required block size. * * See #23340 * + * + * Note [Testing the nonmoving collector] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * The testsuite has four "ways" which test the nonmoving collector: + * + * - nonmoving: runs tests under the nonmoving collector running in + * non-concurrent mode (i.e. using the non-threaded runtime) + * - nonmoving_thr: runs tests under the collector running in concurrent + * mode (with the threaded runtime) + * - nonmoving_thr_sanity: runs tests with concurrent collection and + * sanity checking (i.e. `+RTS -DS`) + * - nonmoving_thr_ghc: compiles tests with `ghc +RTS --nonmoving-gc -RTS` + * as GHC itself tends to be a good smoke test of the collector. + * + * To avoid blowing up validation times, we do not run any of these ways in the + * default "normal" test speed. To ensure that we catch regressions in during + * normal validation we do run a small number of tests in these ways. These + * tests are identified by the `nonmoving_test` test modifier. + * */ memcount nonmoving_segment_live_words = 0; ===================================== testsuite/driver/testlib.py ===================================== @@ -149,6 +149,18 @@ def js_broken( bug: IssueNumber ): else: return normal; +def nonmoving_test( name, opts ): + """ + Always run the given test with the nonmoving collector, in addition to + the usual ways. + + See Note [Testing the nonmoving collector] in rts/sm/NonMoving.c. + """ + ways = ['nonmoving'] + if config.ghc_with_threaded_rts: + ways += ['nonmoving_thr_sanity', 'nonmoving_thr_ghc'] + return extra_ways(ways)(name, opts) + def expect_fail( name, opts ): # The compiler, testdriver, OS or platform is missing a certain # feature, and we don't plan to or can't fix it now or in the @@ -1023,8 +1035,8 @@ def normalise_win32_io_errors(name, opts): def normalise_version_( *pkgs ): def normalise_version__( str ): # (name)(-version)(-hash)(-components) - return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', - '\\1--', str) + return re.sub('(' + '|'.join(map(re.escape,pkgs)) + r')-[0-9.]+(-[0-9a-zA-Z\+]+)?(-[0-9a-zA-Z]+)?', + r'\1--', str) return normalise_version__ def normalise_version( *pkgs ): ===================================== testsuite/tests/array/should_run/all.T ===================================== @@ -21,6 +21,6 @@ test('arr014', when(fast(), skip), compile_and_run, ['']) test('arr015', when(fast(), skip), compile_and_run, ['']) test('arr017', when(fast(), skip), compile_and_run, ['']) test('arr018', when(fast(), skip), compile_and_run, ['']) -test('arr019', normal, compile_and_run, ['']) -test('arr020', normal, compile_and_run, ['']) +test('arr019', nonmoving_test, compile_and_run, ['']) +test('arr020', nonmoving_test, compile_and_run, ['']) test('T21962', normal, compile_and_run, ['']) ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -1,18 +1,18 @@ # ----------------------------------------------------------------------------- # These tests we do even for 'make fast' -test('conc003', normal, compile_and_run, ['']) -test('conc006', normal, compile_and_run, ['']) -test('conc027', normal, compile_and_run, ['']) -test('conc051', normal, compile_and_run, ['']) +test('conc003', nonmoving_test, compile_and_run, ['']) +test('conc006', nonmoving_test, compile_and_run, ['']) +test('conc027', nonmoving_test, compile_and_run, ['']) +test('conc051', nonmoving_test, compile_and_run, ['']) if ('threaded1' in config.run_ways): only_threaded_ways = only_ways(['ghci','threaded1','threaded2', 'nonmoving_thr']) else: only_threaded_ways = skip -test('conc069', only_threaded_ways, compile_and_run, ['']) -test('conc069a', only_threaded_ways, compile_and_run, ['']) +test('conc069', [nonmoving_test, only_threaded_ways], compile_and_run, ['']) +test('conc069a', [nonmoving_test, only_threaded_ways], compile_and_run, ['']) # this test gives slightly different results for non-threaded ways, so omit # those for now. test('conc070', only_threaded_ways, compile_and_run, ['']) @@ -47,8 +47,8 @@ test('T3429', [ extra_run_opts('+RTS -C0.001 -RTS'), # times out with ghci test('T4030', omit_ghci, compile_and_run, ['-O']) -test('throwto002', normal, compile_and_run, ['']) -test('throwto003', normal, compile_and_run, ['']) +test('throwto002', nonmoving_test, compile_and_run, ['']) +test('throwto003', nonmoving_test, compile_and_run, ['']) test('mask001', normal, compile_and_run, ['']) test('mask002', js_broken(22261), compile_and_run, ['']) @@ -81,9 +81,9 @@ test('T5611a', fragile(12751), compile_and_run, ['']) test('T5238', normal, compile_and_run, ['']) test('T5866', exit_code(1), compile_and_run, ['']) -test('readMVar1', normal, compile_and_run, ['']) -test('readMVar2', normal, compile_and_run, ['']) -test('readMVar3', normal, compile_and_run, ['']) +test('readMVar1', nonmoving_test, compile_and_run, ['']) +test('readMVar2', nonmoving_test, compile_and_run, ['']) +test('readMVar3', nonmoving_test, compile_and_run, ['']) test('tryReadMVar1', normal, compile_and_run, ['']) test('tryReadMVar2', normal, compile_and_run, ['']) @@ -121,9 +121,9 @@ test('allocLimit4', [ extra_run_opts('+RTS -xq300k -RTS'), setTestOpts(when(fast(), skip)) -test('conc001', normal, compile_and_run, ['']) -test('conc002', normal, compile_and_run, ['']) -test('conc004', normal, compile_and_run, ['']) +test('conc001', nonmoving_test, compile_and_run, ['']) +test('conc002', nonmoving_test, compile_and_run, ['']) +test('conc004', nonmoving_test, compile_and_run, ['']) test('conc007', extra_run_opts('+RTS -H128M -RTS'), compile_and_run, ['']) test('conc008', normal, compile_and_run, ['']) test('conc009', exit_code(1), compile_and_run, ['']) @@ -218,16 +218,17 @@ test('conc039', [omit_ways(ghci_ways + threaded_ways), js_skip], compile_and_run test('conc040', [exit_code(1), omit_ghci, js_skip], compile_and_run, ['']) # STM-related tests. -test('conc041', normal, compile_and_run, ['']) -test('conc042', normal, compile_and_run, ['']) -test('conc043', normal, compile_and_run, ['']) -test('conc044', normal, compile_and_run, ['']) -test('conc045', normal, compile_and_run, ['']) +test('conc041', nonmoving_test, compile_and_run, ['']) +test('conc042', nonmoving_test, compile_and_run, ['']) +test('conc043', nonmoving_test, compile_and_run, ['']) +test('conc044', nonmoving_test, compile_and_run, ['']) +test('conc045', nonmoving_test, compile_and_run, ['']) -test('conc058', normal, compile_and_run, ['']) +test('conc058', nonmoving_test, compile_and_run, ['']) test('conc059', [only_ways(['threaded1', 'threaded2', 'nonmoving_thr']), + nonmoving_test, pre_cmd('$MAKE -s --no-print-directory conc059_setup')], compile_and_run, ['conc059_c.c -no-hs-main']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ef28e059328638c18acd75585c4837e5a8161ce...cf4160cf8ef96a30349957bab47a59e43f067d78 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ef28e059328638c18acd75585c4837e5a8161ce...cf4160cf8ef96a30349957bab47a59e43f067d78 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 15:37:18 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 06 Oct 2023 11:37:18 -0400 Subject: [Git][ghc/ghc][wip/T17910] 65 commits: Bump submodule text to 2.1 Message-ID: <652029ae3a646_18f529518219a471226d@gitlab.mail> Simon Peyton Jones pushed to branch wip/T17910 at Glasgow Haskell Compiler / GHC Commits: 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - b27d2f3a by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Be more careful about inlining top-level used-once things Addresses #17910 - - - - - c566e288 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Work in progress... - - - - - 810873e0 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Fix for #23813 Zap one-shot info when floating a join point to top level - - - - - a04d5b5d by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Subtle occurrence analyser point (make sure this is documented properly before landing all this) - - - - - 39a0af60 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Try switching off floatConstants in first FloatOut ...after all, in HEAD, they all get inlined back in! - - - - - f0faed8f by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Make floatConsts affects only lvlMFE, and even then not functions T5237 is a good example - - - - - 6d8d11b8 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Float bottoming expressions too! - - - - - 82291469 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Remove debug trace - - - - - cfcaa42b by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Try not doing floatConsts This avoid flattening, and generating lots of top level bindings. Instead do it in late-lambda-lift. I moved late-lambda-lift to run with -O because it is cheap and valuable. That's a somewhat orthogonal change, probably should test separately. - - - - - 31a25668 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Wibbles to late lambda lifting - - - - - 01c3bd36 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Wibbles to fix VSM SetLevels floats out top level things if: bottoming (possibly lambda) and non-strict expandable and not a con-app The not-con-app bit is to avoid flattening big data structures Expandable bit is because specConstr only deals with con-apps, not with fun-apps or lambdas. - - - - - 7b8afe4a by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Wibble unused variable - - - - - e8dd42a8 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Another wibble - - - - - 84ef4e81 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 Comments - - - - - c67bae67 by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 One more wibble - - - - - 81b089af by Simon Peyton Jones at 2023-10-05T13:01:45+01:00 More care with floating T5642 still floats out (from inside a lamdba) lvl = /\a. L1 @a (L1 @a X) which is flattened by the next simplifer run, which takes one extra iteration, but that's a corner case. - - - - - b4ce235a by Simon Peyton Jones at 2023-10-06T16:36:21+01:00 Wibble Don't float so much without floatConsts - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/test-metrics.sh - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/DynFlags.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/64b75bbff987aa46d7823cc2399604c44d5e331c...b4ce235a1871c89e61ad2d218f5673bff6e0a902 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/64b75bbff987aa46d7823cc2399604c44d5e331c...b4ce235a1871c89e61ad2d218f5673bff6e0a902 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 16:41:06 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 06 Oct 2023 12:41:06 -0400 Subject: [Git][ghc/ghc][wip/T23442] CorePrep: Refactor FloatingBind (#23442) Message-ID: <652038a1f3576_18f5295320af647218ca@gitlab.mail> Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC Commits: 92e82944 by Sebastian Graf at 2023-10-06T18:40:13+02:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 2 changed files: - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation produces a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,253 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec + * `CaseBound`: A (NonRec) case binding `case rhs of x -> { __DEFAULT -> .. }`. + Some (string literals, lifted bindings), but not all case-bound + things can go to top-level, hence it is similar to, but not the + same as `LazyContextFloatable :: FloatInfo` described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + NB: You might think this is the same as `CaseBound`, but it is not: + String literals and lifted, ok-for-spec-eval things are + `TopLvlFloatable` but are `CaseBound`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +All lifted bindings are `TopLvlFloatable`. +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2036,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2397,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/92e8294459aa64a108b863642d3810745c7dee71 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/92e8294459aa64a108b863642d3810745c7dee71 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 21:06:48 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Fri, 06 Oct 2023 17:06:48 -0400 Subject: [Git][ghc/ghc][wip/dict-ipe-spans] 47 commits: Move lib{numa,dw} defines to RTS configure Message-ID: <652076e87c2aa_18f5295918658875048a@gitlab.mail> Finley McIlwaine pushed to branch wip/dict-ipe-spans at Glasgow Haskell Compiler / GHC Commits: 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/test-metrics.sh - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/086d8e4c4a59622548579fa257724e8f6c535cb7...69abb1714ade3059593297f3a5faec4c07d1f984 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/086d8e4c4a59622548579fa257724e8f6c535cb7...69abb1714ade3059593297f3a5faec4c07d1f984 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 21:20:34 2023 From: gitlab at gitlab.haskell.org (Finley McIlwaine (@FinleyMcIlwaine)) Date: Fri, 06 Oct 2023 17:20:34 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/t24005-backport-ghc-9.6 Message-ID: <65207a22b8bd1_18f52959626214754024@gitlab.mail> Finley McIlwaine pushed new branch wip/t24005-backport-ghc-9.6 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t24005-backport-ghc-9.6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 21:28:36 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 06 Oct 2023 17:28:36 -0400 Subject: [Git][ghc/ghc][wip/release-9.8.1] 2 commits: hadrian: Fix hpc parser path Message-ID: <65207c04c86c3_18f52959f12a80757519@gitlab.mail> Ben Gamari pushed to branch wip/release-9.8.1 at Glasgow Haskell Compiler / GHC Commits: b06a4e39 by Ben Gamari at 2023-10-06T17:28:32-04:00 hadrian: Fix hpc parser path - - - - - 8f864a5d by Ben Gamari at 2023-10-06T17:28:32-04:00 Release GHC 9.8.1 - - - - - 2 changed files: - configure.ac - hadrian/src/Rules/SourceDist.hs Changes: ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.0], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -22,7 +22,7 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.0], [glasgow-has AC_CONFIG_MACRO_DIRS([m4]) # Set this to YES for a released version, otherwise NO -: ${RELEASE=NO} +: ${RELEASE=YES} # The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line # above. If this is not a released version, then we will append the ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -184,7 +184,7 @@ prepareTree dest = do , (stage0InTree , compiler, "GHC/Parser.y", "GHC/Parser.hs") , (stage0InTree , compiler, "GHC/Parser/Lexer.x", "GHC/Parser/Lexer.hs") , (stage0InTree , compiler, "GHC/Parser/HaddockLex.x", "GHC/Parser/HaddockLex.hs") - , (stage0InTree , hpcBin, "src/HpcParser.y", "src/HpcParser.hs") + , (stage0InTree , hpcBin, "src/Trace/Hpc/Parser.y", "src/Trace/Hpc/Parser.hs") , (stage0InTree , genprimopcode, "Parser.y", "Parser.hs") , (stage0InTree , genprimopcode, "Lexer.x", "Lexer.hs") ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/99cb835d46624c0ef81fa3a5a11513d402c58460...8f864a5d81ed951fa2e83b6b761e639400b3c439 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/99cb835d46624c0ef81fa3a5a11513d402c58460...8f864a5d81ed951fa2e83b6b761e639400b3c439 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 6 23:08:43 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 06 Oct 2023 19:08:43 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: rts: Split up rts/include/stg/MachRegs.h by arch Message-ID: <6520937b7dcf0_18f5295c3915dc7699f5@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: aa011893 by Andreas Klebinger at 2023-10-06T19:08:24-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 6d219fd1 by Bryan Richter at 2023-10-06T19:08:25-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - c2a00ae8 by Bryan Richter at 2023-10-06T19:08:25-04:00 Update hackage index state - - - - - aa9ca8f6 by Bryan Richter at 2023-10-06T19:08:25-04:00 Ensure hadrian uses CI's hackage index state - - - - - 17 changed files: - .gitignore - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/ghc.cabal.in - configure.ac - hadrian/cabal.project - rts/include/stg/MachRegs.h - + rts/include/stg/MachRegs/arm32.h - + rts/include/stg/MachRegs/arm64.h - + rts/include/stg/MachRegs/loongarch64.h - + rts/include/stg/MachRegs/ppc.h - + rts/include/stg/MachRegs/riscv64.h - + rts/include/stg/MachRegs/s390x.h - + rts/include/stg/MachRegs/wasm32.h - + rts/include/stg/MachRegs/x86.h - rts/rts.cabal.in Changes: ===================================== .gitignore ===================================== @@ -111,6 +111,7 @@ _darcs/ /compiler/ClosureTypes.h /compiler/FunTypes.h /compiler/MachRegs.h +/compiler/MachRegs /compiler/ghc-llvm-version.h /compiler/ghc.cabal /compiler/ghc.cabal.old ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -230,7 +230,7 @@ function set_toolchain_paths() { function cabal_update() { # In principle -w shouldn't be necessary here but with # cabal-install 3.8.1.0 it is, due to cabal#8447. - run "$CABAL" update -w "$GHC" --index="$HACKAGE_INDEX_STATE" + run "$CABAL" update -w "$GHC" "hackage.haskell.org,${HACKAGE_INDEX_STATE}" } @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== compiler/CodeGen.Platform.h ===================================== @@ -480,6 +480,7 @@ import GHC.Platform.Reg #endif +-- See also Note [Caller saves and callee-saves regs.] callerSaves :: GlobalReg -> Bool #if defined(CALLER_SAVES_Base) callerSaves BaseReg = True ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -15,7 +15,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnboxedTuples #-} --- | Native code generator +-- | Note [Native code generator] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- The native-code generator has machine-independent and -- machine-dependent modules. @@ -23,45 +24,39 @@ -- This module ("GHC.CmmToAsm") is the top-level machine-independent -- module. Before entering machine-dependent land, we do some -- machine-independent optimisations (defined below) on the --- 'CmmStmts's. +-- 'CmmStmts's. (Which ideally would be folded into CmmOpt ...) -- -- We convert to the machine-specific 'Instr' datatype with -- 'cmmCodeGen', assuming an infinite supply of registers. We then use --- a machine-independent register allocator ('regAlloc') to rejoin +-- a (mostly) machine-independent register allocator to rejoin -- reality. Obviously, 'regAlloc' has machine-specific helper --- functions (see about "RegAllocInfo" below). +-- functions (see the used register allocator for details). -- -- Finally, we order the basic blocks of the function so as to minimise -- the number of jumps between blocks, by utilising fallthrough wherever -- possible. -- --- The machine-dependent bits break down as follows: +-- The machine-dependent bits are generally contained under +-- GHC/CmmToAsm//* and generally breaks down as follows: -- --- * ["MachRegs"] Everything about the target platform's machine +-- * "Regs": Everything about the target platform's machine -- registers (and immediate operands, and addresses, which tend to -- intermingle/interact with registers). -- --- * ["MachInstrs"] Includes the 'Instr' datatype (possibly should --- have a module of its own), plus a miscellany of other things +-- * "Instr": Includes the 'Instr' datatype plus a miscellany of other things -- (e.g., 'targetDoubleSize', 'smStablePtrTable', ...) -- --- * ["MachCodeGen"] is where 'Cmm' stuff turns into +-- * "CodeGen": is where 'Cmm' stuff turns into -- machine instructions. -- --- * ["PprMach"] 'pprInstr' turns an 'Instr' into text (well, really +-- * "Ppr": 'pprInstr' turns an 'Instr' into text (well, really -- a 'SDoc'). -- --- * ["RegAllocInfo"] In the register allocator, we manipulate --- 'MRegsState's, which are 'BitSet's, one bit per machine register. --- When we want to say something about a specific machine register --- (e.g., ``it gets clobbered by this instruction''), we set/unset --- its bit. Obviously, we do this 'BitSet' thing for efficiency --- reasons. +-- The register allocators lives under GHC.CmmToAsm.Reg.*, there is both a Linear and a Graph +-- based register allocator. Both of which have their own notes describing them. They +-- are mostly platform independent but there are some platform specific files +-- encoding architecture details under Reg// -- --- The 'RegAllocInfo' module collects together the machine-specific --- info needed to do register allocation. --- --- * ["RegisterAlloc"] The (machine-independent) register allocator. -- -} -- module GHC.CmmToAsm ===================================== compiler/ghc.cabal.in ===================================== @@ -34,6 +34,14 @@ extra-source-files: ClosureTypes.h FunTypes.h MachRegs.h + MachRegs/arm32.h + MachRegs/arm64.h + MachRegs/loongarch64.h + MachRegs/ppc.h + MachRegs/riscv64.h + MachRegs/s390x.h + MachRegs/wasm32.h + MachRegs/x86.h ghc-llvm-version.h ===================================== configure.ac ===================================== @@ -578,6 +578,15 @@ ln -f rts/include/rts/Bytecodes.h compiler/ ln -f rts/include/rts/storage/ClosureTypes.h compiler/ ln -f rts/include/rts/storage/FunTypes.h compiler/ ln -f rts/include/stg/MachRegs.h compiler/ +mkdir -p compiler/MachRegs +ln -f rts/include/stg/MachRegs/arm32.h compiler/MachRegs/arm32.h +ln -f rts/include/stg/MachRegs/arm64.h compiler/MachRegs/arm64.h +ln -f rts/include/stg/MachRegs/loongarch64.h compiler/MachRegs/loongarch64.h +ln -f rts/include/stg/MachRegs/ppc.h compiler/MachRegs/ppc.h +ln -f rts/include/stg/MachRegs/riscv64.h compiler/MachRegs/riscv64.h +ln -f rts/include/stg/MachRegs/s390x.h compiler/MachRegs/s390x.h +ln -f rts/include/stg/MachRegs/wasm32.h compiler/MachRegs/wasm32.h +ln -f rts/include/stg/MachRegs/x86.h compiler/MachRegs/x86.h AC_MSG_NOTICE([done.]) dnl ** Copy the files from the "fs" utility into the right folders. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. ===================================== rts/include/stg/MachRegs.h ===================================== @@ -51,637 +51,54 @@ #elif MACHREGS_NO_REGS == 0 /* ---------------------------------------------------------------------------- - Caller saves and callee-saves regs. - + Note [Caller saves and callee-saves regs.] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Caller-saves regs have to be saved around C-calls made from STG land, so this file defines CALLER_SAVES_ for each that is designated caller-saves in that machine's C calling convention. + NB: Caller-saved registers not mapped to a STG register don't + require a CALLER_SAVES_ define. As it stands, the only registers that are ever marked caller saves - are the RX, FX, DX and USER registers; as a result, if you + are the RX, FX, DX, XMM and USER registers; as a result, if you decide to caller save a system register (e.g. SP, HP, etc), note that this code path is completely untested! -- EZY See Note [Register parameter passing] for details. -------------------------------------------------------------------------- */ -/* ----------------------------------------------------------------------------- - The x86 register mapping - - Ok, we've only got 6 general purpose registers, a frame pointer and a - stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, - hence they get trashed across ccalls and are caller saves. \tr{%ebx}, - \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. - - Reg STG-Reg - --------------- - ebx Base - ebp Sp - esi R1 - edi Hp - - Leaving SpLim out of the picture. - -------------------------------------------------------------------------- */ - -#if defined(MACHREGS_i386) - -#define REG(x) __asm__("%" #x) - -#if !defined(not_doing_dynamic_linking) -#define REG_Base ebx -#endif -#define REG_Sp ebp - -#if !defined(STOLEN_X86_REGS) -#define STOLEN_X86_REGS 4 -#endif - -#if STOLEN_X86_REGS >= 3 -# define REG_R1 esi -#endif - -#if STOLEN_X86_REGS >= 4 -# define REG_Hp edi -#endif -#define REG_MachSp esp - -#define REG_XMM1 xmm0 -#define REG_XMM2 xmm1 -#define REG_XMM3 xmm2 -#define REG_XMM4 xmm3 - -#define REG_YMM1 ymm0 -#define REG_YMM2 ymm1 -#define REG_YMM3 ymm2 -#define REG_YMM4 ymm3 - -#define REG_ZMM1 zmm0 -#define REG_ZMM2 zmm1 -#define REG_ZMM3 zmm2 -#define REG_ZMM4 zmm3 - -#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ -#define MAX_REAL_FLOAT_REG 0 -#define MAX_REAL_DOUBLE_REG 0 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 4 -#define MAX_REAL_YMM_REG 4 -#define MAX_REAL_ZMM_REG 4 - -/* ----------------------------------------------------------------------------- - The x86-64 register mapping - - %rax caller-saves, don't steal this one - %rbx YES - %rcx arg reg, caller-saves - %rdx arg reg, caller-saves - %rsi arg reg, caller-saves - %rdi arg reg, caller-saves - %rbp YES (our *prime* register) - %rsp (unavailable - stack pointer) - %r8 arg reg, caller-saves - %r9 arg reg, caller-saves - %r10 caller-saves - %r11 caller-saves - %r12 YES - %r13 YES - %r14 YES - %r15 YES - - %xmm0-7 arg regs, caller-saves - %xmm8-15 caller-saves - - Use the caller-saves regs for Rn, because we don't always have to - save those (as opposed to Sp/Hp/SpLim etc. which always have to be - saved). - - --------------------------------------------------------------------------- */ - -#elif defined(MACHREGS_x86_64) - -#define REG(x) __asm__("%" #x) - -#define REG_Base r13 -#define REG_Sp rbp -#define REG_Hp r12 -#define REG_R1 rbx -#define REG_R2 r14 -#define REG_R3 rsi -#define REG_R4 rdi -#define REG_R5 r8 -#define REG_R6 r9 -#define REG_SpLim r15 -#define REG_MachSp rsp - -/* -Map both Fn and Dn to register xmmn so that we can pass a function any -combination of up to six Float# or Double# arguments without touching -the stack. See Note [Overlapping global registers] for implications. -*/ - -#define REG_F1 xmm1 -#define REG_F2 xmm2 -#define REG_F3 xmm3 -#define REG_F4 xmm4 -#define REG_F5 xmm5 -#define REG_F6 xmm6 - -#define REG_D1 xmm1 -#define REG_D2 xmm2 -#define REG_D3 xmm3 -#define REG_D4 xmm4 -#define REG_D5 xmm5 -#define REG_D6 xmm6 - -#define REG_XMM1 xmm1 -#define REG_XMM2 xmm2 -#define REG_XMM3 xmm3 -#define REG_XMM4 xmm4 -#define REG_XMM5 xmm5 -#define REG_XMM6 xmm6 - -#define REG_YMM1 ymm1 -#define REG_YMM2 ymm2 -#define REG_YMM3 ymm3 -#define REG_YMM4 ymm4 -#define REG_YMM5 ymm5 -#define REG_YMM6 ymm6 - -#define REG_ZMM1 zmm1 -#define REG_ZMM2 zmm2 -#define REG_ZMM3 zmm3 -#define REG_ZMM4 zmm4 -#define REG_ZMM5 zmm5 -#define REG_ZMM6 zmm6 - -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_R3 -#define CALLER_SAVES_R4 -#endif -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 - -#define CALLER_SAVES_F1 -#define CALLER_SAVES_F2 -#define CALLER_SAVES_F3 -#define CALLER_SAVES_F4 -#define CALLER_SAVES_F5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_F6 -#endif - -#define CALLER_SAVES_D1 -#define CALLER_SAVES_D2 -#define CALLER_SAVES_D3 -#define CALLER_SAVES_D4 -#define CALLER_SAVES_D5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_D6 -#endif - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 -#define CALLER_SAVES_XMM3 -#define CALLER_SAVES_XMM4 -#define CALLER_SAVES_XMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_XMM6 -#endif - -#define CALLER_SAVES_YMM1 -#define CALLER_SAVES_YMM2 -#define CALLER_SAVES_YMM3 -#define CALLER_SAVES_YMM4 -#define CALLER_SAVES_YMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_YMM6 -#endif - -#define CALLER_SAVES_ZMM1 -#define CALLER_SAVES_ZMM2 -#define CALLER_SAVES_ZMM3 -#define CALLER_SAVES_ZMM4 -#define CALLER_SAVES_ZMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_ZMM6 -#endif - -#define MAX_REAL_VANILLA_REG 6 -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 6 -#define MAX_REAL_YMM_REG 6 -#define MAX_REAL_ZMM_REG 6 - -/* ----------------------------------------------------------------------------- - The PowerPC register mapping - - 0 system glue? (caller-save, volatile) - 1 SP (callee-save, non-volatile) - 2 AIX, powerpc64-linux: - RTOC (a strange special case) - powerpc32-linux: - reserved for use by system +/* Define STG <-> machine register mappings. */ +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) - 3-10 args/return (caller-save, volatile) - 11,12 system glue? (caller-save, volatile) - 13 on 64-bit: reserved for thread state pointer - on 32-bit: (callee-save, non-volatile) - 14-31 (callee-save, non-volatile) - - f0 (caller-save, volatile) - f1-f13 args/return (caller-save, volatile) - f14-f31 (callee-save, non-volatile) - - \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. - \tr{0}--\tr{12} are caller-save registers. - - \tr{%f14}--\tr{%f31} are callee-save floating-point registers. - - We can do the Whole Business with callee-save registers only! - -------------------------------------------------------------------------- */ +#include "MachRegs/x86.h" #elif defined(MACHREGS_powerpc) -#define REG(x) __asm__(#x) - -#define REG_R1 r14 -#define REG_R2 r15 -#define REG_R3 r16 -#define REG_R4 r17 -#define REG_R5 r18 -#define REG_R6 r19 -#define REG_R7 r20 -#define REG_R8 r21 -#define REG_R9 r22 -#define REG_R10 r23 - -#define REG_F1 fr14 -#define REG_F2 fr15 -#define REG_F3 fr16 -#define REG_F4 fr17 -#define REG_F5 fr18 -#define REG_F6 fr19 - -#define REG_D1 fr20 -#define REG_D2 fr21 -#define REG_D3 fr22 -#define REG_D4 fr23 -#define REG_D5 fr24 -#define REG_D6 fr25 - -#define REG_Sp r24 -#define REG_SpLim r25 -#define REG_Hp r26 -#define REG_Base r27 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 - -/* ----------------------------------------------------------------------------- - The ARM EABI register mapping - - Here we consider ARM mode (i.e. 32bit isns) - and also CPU with full VFPv3 implementation - - ARM registers (see Chapter 5.1 in ARM IHI 0042D and - Section 9.2.2 in ARM Software Development Toolkit Reference Guide) - - r15 PC The Program Counter. - r14 LR The Link Register. - r13 SP The Stack Pointer. - r12 IP The Intra-Procedure-call scratch register. - r11 v8/fp Variable-register 8. - r10 v7/sl Variable-register 7. - r9 v6/SB/TR Platform register. The meaning of this register is - defined by the platform standard. - r8 v5 Variable-register 5. - r7 v4 Variable register 4. - r6 v3 Variable register 3. - r5 v2 Variable register 2. - r4 v1 Variable register 1. - r3 a4 Argument / scratch register 4. - r2 a3 Argument / scratch register 3. - r1 a2 Argument / result / scratch register 2. - r0 a1 Argument / result / scratch register 1. - - VFPv2/VFPv3/NEON registers - s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers - s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across - subroutine calls) - - VFPv3/NEON registers (added to the VFPv2 registers set) - d16-d31/q8-q15 Argument / result/ scratch registers - ----------------------------------------------------------------------------- */ +#include "MachRegs/ppc.h" #elif defined(MACHREGS_arm) -#define REG(x) __asm__(#x) - -#define REG_Base r4 -#define REG_Sp r5 -#define REG_Hp r6 -#define REG_R1 r7 -#define REG_R2 r8 -#define REG_R3 r9 -#define REG_R4 r10 -#define REG_SpLim r11 - -#if !defined(arm_HOST_ARCH_PRE_ARMv6) -/* d8 */ -#define REG_F1 s16 -#define REG_F2 s17 -/* d9 */ -#define REG_F3 s18 -#define REG_F4 s19 - -#define REG_D1 d10 -#define REG_D2 d11 -#endif - -/* ----------------------------------------------------------------------------- - The ARMv8/AArch64 ABI register mapping - - The AArch64 provides 31 64-bit general purpose registers - and 32 128-bit SIMD/floating point registers. - - General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) - - Register | Special | Role in the procedure call standard - ---------+---------+------------------------------------ - SP | | The Stack Pointer - r30 | LR | The Link Register - r29 | FP | The Frame Pointer - r19-r28 | | Callee-saved registers - r18 | | The Platform Register, if needed; - | | or temporary register - r17 | IP1 | The second intra-procedure-call temporary register - r16 | IP0 | The first intra-procedure-call scratch register - r9-r15 | | Temporary registers - r8 | | Indirect result location register - r0-r7 | | Parameter/result registers - - - FPU/SIMD registers - - s/d/q/v0-v7 Argument / result/ scratch registers - s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, - but only bottom 64-bit value needs to be preserved) - s/d/q/v16-v31 temporary registers - - ----------------------------------------------------------------------------- */ +#include "MachRegs/arm32.h" #elif defined(MACHREGS_aarch64) -#define REG(x) __asm__(#x) - -#define REG_Base r19 -#define REG_Sp r20 -#define REG_Hp r21 -#define REG_R1 r22 -#define REG_R2 r23 -#define REG_R3 r24 -#define REG_R4 r25 -#define REG_R5 r26 -#define REG_R6 r27 -#define REG_SpLim r28 - -#define REG_F1 s8 -#define REG_F2 s9 -#define REG_F3 s10 -#define REG_F4 s11 - -#define REG_D1 d12 -#define REG_D2 d13 -#define REG_D3 d14 -#define REG_D4 d15 - -#define REG_XMM1 q4 -#define REG_XMM2 q5 - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 - -/* ----------------------------------------------------------------------------- - The s390x register mapping - - Register | Role(s) | Call effect - ------------+-------------------------------------+----------------- - r0,r1 | - | caller-saved - r2 | Argument / return value | caller-saved - r3,r4,r5 | Arguments | caller-saved - r6 | Argument | callee-saved - r7...r11 | - | callee-saved - r12 | (Commonly used as GOT pointer) | callee-saved - r13 | (Commonly used as literal pool pointer) | callee-saved - r14 | Return address | caller-saved - r15 | Stack pointer | callee-saved - f0 | Argument / return value | caller-saved - f2,f4,f6 | Arguments | caller-saved - f1,f3,f5,f7 | - | caller-saved - f8...f15 | - | callee-saved - v0...v31 | - | caller-saved - - Each general purpose register r0 through r15 as well as each floating-point - register f0 through f15 is 64 bits wide. Each vector register v0 through v31 - is 128 bits wide. - - Note, the vector registers v0 through v15 overlap with the floating-point - registers f0 through f15. - - -------------------------------------------------------------------------- */ +#include "MachRegs/arm64.h" #elif defined(MACHREGS_s390x) -#define REG(x) __asm__("%" #x) - -#define REG_Base r7 -#define REG_Sp r8 -#define REG_Hp r10 -#define REG_R1 r11 -#define REG_R2 r12 -#define REG_R3 r13 -#define REG_R4 r6 -#define REG_R5 r2 -#define REG_R6 r3 -#define REG_R7 r4 -#define REG_R8 r5 -#define REG_SpLim r9 -#define REG_MachSp r15 - -#define REG_F1 f8 -#define REG_F2 f9 -#define REG_F3 f10 -#define REG_F4 f11 -#define REG_F5 f0 -#define REG_F6 f1 - -#define REG_D1 f12 -#define REG_D2 f13 -#define REG_D3 f14 -#define REG_D4 f15 -#define REG_D5 f2 -#define REG_D6 f3 - -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 -#define CALLER_SAVES_R7 -#define CALLER_SAVES_R8 - -#define CALLER_SAVES_F5 -#define CALLER_SAVES_F6 - -#define CALLER_SAVES_D5 -#define CALLER_SAVES_D6 - -/* ----------------------------------------------------------------------------- - The riscv64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - sp | Stack pointer | callee-saved - gp | Global pointer | callee-saved - tp | Thread pointer | callee-saved - t0,t1,t2 | - | caller-saved - s0 | Frame pointer | callee-saved - s1 | - | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - s2..s11 | - | callee-saved - t3..t6 | - | caller-saved - ft0..ft7 | - | caller-saved - fs0,fs1 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - fs2..fs11 | - | callee-saved - ft8..ft11 | - | caller-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide. - - -------------------------------------------------------------------------- */ +#include "MachRegs/s390x.h" #elif defined(MACHREGS_riscv64) -#define REG(x) __asm__(#x) - -#define REG_Base s1 -#define REG_Sp s2 -#define REG_Hp s3 -#define REG_R1 s4 -#define REG_R2 s5 -#define REG_R3 s6 -#define REG_R4 s7 -#define REG_R5 s8 -#define REG_R6 s9 -#define REG_R7 s10 -#define REG_SpLim s11 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 -#define REG_F5 fs4 -#define REG_F6 fs5 - -#define REG_D1 fs6 -#define REG_D2 fs7 -#define REG_D3 fs8 -#define REG_D4 fs9 -#define REG_D5 fs10 -#define REG_D6 fs11 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 +#include "MachRegs/riscv64.h" #elif defined(MACHREGS_wasm32) -#define REG_R1 1 -#define REG_R2 2 -#define REG_R3 3 -#define REG_R4 4 -#define REG_R5 5 -#define REG_R6 6 -#define REG_R7 7 -#define REG_R8 8 -#define REG_R9 9 -#define REG_R10 10 - -#define REG_F1 11 -#define REG_F2 12 -#define REG_F3 13 -#define REG_F4 14 -#define REG_F5 15 -#define REG_F6 16 - -#define REG_D1 17 -#define REG_D2 18 -#define REG_D3 19 -#define REG_D4 20 -#define REG_D5 21 -#define REG_D6 22 - -#define REG_L1 23 - -#define REG_Sp 24 -#define REG_SpLim 25 -#define REG_Hp 26 -#define REG_HpLim 27 -#define REG_CCCS 28 - -/* ----------------------------------------------------------------------------- - The loongarch64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - tp | Thread pointer | - - sp | Stack pointer | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - t0..t8 | - | caller-saved - u0 | Reserve | - - fp | Frame pointer | callee-saved - s0..s8 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - ft0..ft15 | - | caller-saved - fs0..fs7 | - | callee-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide, also, the u0 register is called r21 in some cases. +#include "MachRegs/wasm32.h" - -------------------------------------------------------------------------- */ #elif defined(MACHREGS_loongarch64) -#define REG(x) __asm__("$" #x) - -#define REG_Base s0 -#define REG_Sp s1 -#define REG_Hp s2 -#define REG_R1 s3 -#define REG_R2 s4 -#define REG_R3 s5 -#define REG_R4 s6 -#define REG_R5 s7 -#define REG_SpLim s8 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 - -#define REG_D1 fs4 -#define REG_D2 fs5 -#define REG_D3 fs6 -#define REG_D4 fs7 - -#define MAX_REAL_FLOAT_REG 4 -#define MAX_REAL_DOUBLE_REG 4 +#include "MachRegs/loongarch64.h" #else ===================================== rts/include/stg/MachRegs/arm32.h ===================================== @@ -0,0 +1,60 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The ARM EABI register mapping + + Here we consider ARM mode (i.e. 32bit isns) + and also CPU with full VFPv3 implementation + + ARM registers (see Chapter 5.1 in ARM IHI 0042D and + Section 9.2.2 in ARM Software Development Toolkit Reference Guide) + + r15 PC The Program Counter. + r14 LR The Link Register. + r13 SP The Stack Pointer. + r12 IP The Intra-Procedure-call scratch register. + r11 v8/fp Variable-register 8. + r10 v7/sl Variable-register 7. + r9 v6/SB/TR Platform register. The meaning of this register is + defined by the platform standard. + r8 v5 Variable-register 5. + r7 v4 Variable register 4. + r6 v3 Variable register 3. + r5 v2 Variable register 2. + r4 v1 Variable register 1. + r3 a4 Argument / scratch register 4. + r2 a3 Argument / scratch register 3. + r1 a2 Argument / result / scratch register 2. + r0 a1 Argument / result / scratch register 1. + + VFPv2/VFPv3/NEON registers + s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers + s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across + subroutine calls) + + VFPv3/NEON registers (added to the VFPv2 registers set) + d16-d31/q8-q15 Argument / result/ scratch registers + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r4 +#define REG_Sp r5 +#define REG_Hp r6 +#define REG_R1 r7 +#define REG_R2 r8 +#define REG_R3 r9 +#define REG_R4 r10 +#define REG_SpLim r11 + +#if !defined(arm_HOST_ARCH_PRE_ARMv6) +/* d8 */ +#define REG_F1 s16 +#define REG_F2 s17 +/* d9 */ +#define REG_F3 s18 +#define REG_F4 s19 + +#define REG_D1 d10 +#define REG_D2 d11 +#endif \ No newline at end of file ===================================== rts/include/stg/MachRegs/arm64.h ===================================== @@ -0,0 +1,64 @@ +#pragma once + + +/* ----------------------------------------------------------------------------- + The ARMv8/AArch64 ABI register mapping + + The AArch64 provides 31 64-bit general purpose registers + and 32 128-bit SIMD/floating point registers. + + General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) + + Register | Special | Role in the procedure call standard + ---------+---------+------------------------------------ + SP | | The Stack Pointer + r30 | LR | The Link Register + r29 | FP | The Frame Pointer + r19-r28 | | Callee-saved registers + r18 | | The Platform Register, if needed; + | | or temporary register + r17 | IP1 | The second intra-procedure-call temporary register + r16 | IP0 | The first intra-procedure-call scratch register + r9-r15 | | Temporary registers + r8 | | Indirect result location register + r0-r7 | | Parameter/result registers + + + FPU/SIMD registers + + s/d/q/v0-v7 Argument / result/ scratch registers + s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, + but only bottom 64-bit value needs to be preserved) + s/d/q/v16-v31 temporary registers + + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r19 +#define REG_Sp r20 +#define REG_Hp r21 +#define REG_R1 r22 +#define REG_R2 r23 +#define REG_R3 r24 +#define REG_R4 r25 +#define REG_R5 r26 +#define REG_R6 r27 +#define REG_SpLim r28 + +#define REG_F1 s8 +#define REG_F2 s9 +#define REG_F3 s10 +#define REG_F4 s11 + +#define REG_D1 d12 +#define REG_D2 d13 +#define REG_D3 d14 +#define REG_D4 d15 + +#define REG_XMM1 q4 +#define REG_XMM2 q5 + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 + ===================================== rts/include/stg/MachRegs/loongarch64.h ===================================== @@ -0,0 +1,51 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The loongarch64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + tp | Thread pointer | - + sp | Stack pointer | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + t0..t8 | - | caller-saved + u0 | Reserve | - + fp | Frame pointer | callee-saved + s0..s8 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + ft0..ft15 | - | caller-saved + fs0..fs7 | - | callee-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide, also, the u0 register is called r21 in some cases. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__("$" #x) + +#define REG_Base s0 +#define REG_Sp s1 +#define REG_Hp s2 +#define REG_R1 s3 +#define REG_R2 s4 +#define REG_R3 s5 +#define REG_R4 s6 +#define REG_R5 s7 +#define REG_SpLim s8 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 + +#define REG_D1 fs4 +#define REG_D2 fs5 +#define REG_D3 fs6 +#define REG_D4 fs7 + +#define MAX_REAL_FLOAT_REG 4 +#define MAX_REAL_DOUBLE_REG 4 ===================================== rts/include/stg/MachRegs/ppc.h ===================================== @@ -0,0 +1,65 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The PowerPC register mapping + + 0 system glue? (caller-save, volatile) + 1 SP (callee-save, non-volatile) + 2 AIX, powerpc64-linux: + RTOC (a strange special case) + powerpc32-linux: + reserved for use by system + + 3-10 args/return (caller-save, volatile) + 11,12 system glue? (caller-save, volatile) + 13 on 64-bit: reserved for thread state pointer + on 32-bit: (callee-save, non-volatile) + 14-31 (callee-save, non-volatile) + + f0 (caller-save, volatile) + f1-f13 args/return (caller-save, volatile) + f14-f31 (callee-save, non-volatile) + + \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. + \tr{0}--\tr{12} are caller-save registers. + + \tr{%f14}--\tr{%f31} are callee-save floating-point registers. + + We can do the Whole Business with callee-save registers only! + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__(#x) + +#define REG_R1 r14 +#define REG_R2 r15 +#define REG_R3 r16 +#define REG_R4 r17 +#define REG_R5 r18 +#define REG_R6 r19 +#define REG_R7 r20 +#define REG_R8 r21 +#define REG_R9 r22 +#define REG_R10 r23 + +#define REG_F1 fr14 +#define REG_F2 fr15 +#define REG_F3 fr16 +#define REG_F4 fr17 +#define REG_F5 fr18 +#define REG_F6 fr19 + +#define REG_D1 fr20 +#define REG_D2 fr21 +#define REG_D3 fr22 +#define REG_D4 fr23 +#define REG_D5 fr24 +#define REG_D6 fr25 + +#define REG_Sp r24 +#define REG_SpLim r25 +#define REG_Hp r26 +#define REG_Base r27 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/riscv64.h ===================================== @@ -0,0 +1,61 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The riscv64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + sp | Stack pointer | callee-saved + gp | Global pointer | callee-saved + tp | Thread pointer | callee-saved + t0,t1,t2 | - | caller-saved + s0 | Frame pointer | callee-saved + s1 | - | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + s2..s11 | - | callee-saved + t3..t6 | - | caller-saved + ft0..ft7 | - | caller-saved + fs0,fs1 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + fs2..fs11 | - | callee-saved + ft8..ft11 | - | caller-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base s1 +#define REG_Sp s2 +#define REG_Hp s3 +#define REG_R1 s4 +#define REG_R2 s5 +#define REG_R3 s6 +#define REG_R4 s7 +#define REG_R5 s8 +#define REG_R6 s9 +#define REG_R7 s10 +#define REG_SpLim s11 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 +#define REG_F5 fs4 +#define REG_F6 fs5 + +#define REG_D1 fs6 +#define REG_D2 fs7 +#define REG_D3 fs8 +#define REG_D4 fs9 +#define REG_D5 fs10 +#define REG_D6 fs11 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/s390x.h ===================================== @@ -0,0 +1,72 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The s390x register mapping + + Register | Role(s) | Call effect + ------------+-------------------------------------+----------------- + r0,r1 | - | caller-saved + r2 | Argument / return value | caller-saved + r3,r4,r5 | Arguments | caller-saved + r6 | Argument | callee-saved + r7...r11 | - | callee-saved + r12 | (Commonly used as GOT pointer) | callee-saved + r13 | (Commonly used as literal pool pointer) | callee-saved + r14 | Return address | caller-saved + r15 | Stack pointer | callee-saved + f0 | Argument / return value | caller-saved + f2,f4,f6 | Arguments | caller-saved + f1,f3,f5,f7 | - | caller-saved + f8...f15 | - | callee-saved + v0...v31 | - | caller-saved + + Each general purpose register r0 through r15 as well as each floating-point + register f0 through f15 is 64 bits wide. Each vector register v0 through v31 + is 128 bits wide. + + Note, the vector registers v0 through v15 overlap with the floating-point + registers f0 through f15. + + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__("%" #x) + +#define REG_Base r7 +#define REG_Sp r8 +#define REG_Hp r10 +#define REG_R1 r11 +#define REG_R2 r12 +#define REG_R3 r13 +#define REG_R4 r6 +#define REG_R5 r2 +#define REG_R6 r3 +#define REG_R7 r4 +#define REG_R8 r5 +#define REG_SpLim r9 +#define REG_MachSp r15 + +#define REG_F1 f8 +#define REG_F2 f9 +#define REG_F3 f10 +#define REG_F4 f11 +#define REG_F5 f0 +#define REG_F6 f1 + +#define REG_D1 f12 +#define REG_D2 f13 +#define REG_D3 f14 +#define REG_D4 f15 +#define REG_D5 f2 +#define REG_D6 f3 + +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 +#define CALLER_SAVES_R7 +#define CALLER_SAVES_R8 + +#define CALLER_SAVES_F5 +#define CALLER_SAVES_F6 + +#define CALLER_SAVES_D5 +#define CALLER_SAVES_D6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/wasm32.h ===================================== ===================================== rts/include/stg/MachRegs/x86.h ===================================== @@ -0,0 +1,210 @@ +/* ----------------------------------------------------------------------------- + The x86 register mapping + + Ok, we've only got 6 general purpose registers, a frame pointer and a + stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, + hence they get trashed across ccalls and are caller saves. \tr{%ebx}, + \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. + + Reg STG-Reg + --------------- + ebx Base + ebp Sp + esi R1 + edi Hp + + Leaving SpLim out of the picture. + -------------------------------------------------------------------------- */ + +#if defined(MACHREGS_i386) + +#define REG(x) __asm__("%" #x) + +#if !defined(not_doing_dynamic_linking) +#define REG_Base ebx +#endif +#define REG_Sp ebp + +#if !defined(STOLEN_X86_REGS) +#define STOLEN_X86_REGS 4 +#endif + +#if STOLEN_X86_REGS >= 3 +# define REG_R1 esi +#endif + +#if STOLEN_X86_REGS >= 4 +# define REG_Hp edi +#endif +#define REG_MachSp esp + +#define REG_XMM1 xmm0 +#define REG_XMM2 xmm1 +#define REG_XMM3 xmm2 +#define REG_XMM4 xmm3 + +#define REG_YMM1 ymm0 +#define REG_YMM2 ymm1 +#define REG_YMM3 ymm2 +#define REG_YMM4 ymm3 + +#define REG_ZMM1 zmm0 +#define REG_ZMM2 zmm1 +#define REG_ZMM3 zmm2 +#define REG_ZMM4 zmm3 + +#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ +#define MAX_REAL_FLOAT_REG 0 +#define MAX_REAL_DOUBLE_REG 0 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 4 +#define MAX_REAL_YMM_REG 4 +#define MAX_REAL_ZMM_REG 4 + +/* ----------------------------------------------------------------------------- + The x86-64 register mapping + + %rax caller-saves, don't steal this one + %rbx YES + %rcx arg reg, caller-saves + %rdx arg reg, caller-saves + %rsi arg reg, caller-saves + %rdi arg reg, caller-saves + %rbp YES (our *prime* register) + %rsp (unavailable - stack pointer) + %r8 arg reg, caller-saves + %r9 arg reg, caller-saves + %r10 caller-saves + %r11 caller-saves + %r12 YES + %r13 YES + %r14 YES + %r15 YES + + %xmm0-7 arg regs, caller-saves + %xmm8-15 caller-saves + + Use the caller-saves regs for Rn, because we don't always have to + save those (as opposed to Sp/Hp/SpLim etc. which always have to be + saved). + + --------------------------------------------------------------------------- */ + +#elif defined(MACHREGS_x86_64) + +#define REG(x) __asm__("%" #x) + +#define REG_Base r13 +#define REG_Sp rbp +#define REG_Hp r12 +#define REG_R1 rbx +#define REG_R2 r14 +#define REG_R3 rsi +#define REG_R4 rdi +#define REG_R5 r8 +#define REG_R6 r9 +#define REG_SpLim r15 +#define REG_MachSp rsp + +/* +Map both Fn and Dn to register xmmn so that we can pass a function any +combination of up to six Float# or Double# arguments without touching +the stack. See Note [Overlapping global registers] for implications. +*/ + +#define REG_F1 xmm1 +#define REG_F2 xmm2 +#define REG_F3 xmm3 +#define REG_F4 xmm4 +#define REG_F5 xmm5 +#define REG_F6 xmm6 + +#define REG_D1 xmm1 +#define REG_D2 xmm2 +#define REG_D3 xmm3 +#define REG_D4 xmm4 +#define REG_D5 xmm5 +#define REG_D6 xmm6 + +#define REG_XMM1 xmm1 +#define REG_XMM2 xmm2 +#define REG_XMM3 xmm3 +#define REG_XMM4 xmm4 +#define REG_XMM5 xmm5 +#define REG_XMM6 xmm6 + +#define REG_YMM1 ymm1 +#define REG_YMM2 ymm2 +#define REG_YMM3 ymm3 +#define REG_YMM4 ymm4 +#define REG_YMM5 ymm5 +#define REG_YMM6 ymm6 + +#define REG_ZMM1 zmm1 +#define REG_ZMM2 zmm2 +#define REG_ZMM3 zmm3 +#define REG_ZMM4 zmm4 +#define REG_ZMM5 zmm5 +#define REG_ZMM6 zmm6 + +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_R3 +#define CALLER_SAVES_R4 +#endif +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 + +#define CALLER_SAVES_F1 +#define CALLER_SAVES_F2 +#define CALLER_SAVES_F3 +#define CALLER_SAVES_F4 +#define CALLER_SAVES_F5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_F6 +#endif + +#define CALLER_SAVES_D1 +#define CALLER_SAVES_D2 +#define CALLER_SAVES_D3 +#define CALLER_SAVES_D4 +#define CALLER_SAVES_D5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_D6 +#endif + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 +#define CALLER_SAVES_XMM3 +#define CALLER_SAVES_XMM4 +#define CALLER_SAVES_XMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_XMM6 +#endif + +#define CALLER_SAVES_YMM1 +#define CALLER_SAVES_YMM2 +#define CALLER_SAVES_YMM3 +#define CALLER_SAVES_YMM4 +#define CALLER_SAVES_YMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_YMM6 +#endif + +#define CALLER_SAVES_ZMM1 +#define CALLER_SAVES_ZMM2 +#define CALLER_SAVES_ZMM3 +#define CALLER_SAVES_ZMM4 +#define CALLER_SAVES_ZMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_ZMM6 +#endif + +#define MAX_REAL_VANILLA_REG 6 +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 6 +#define MAX_REAL_YMM_REG 6 +#define MAX_REAL_ZMM_REG 6 + +#endif /* MACHREGS_i386 || MACHREGS_x86_64 */ \ No newline at end of file ===================================== rts/rts.cabal.in ===================================== @@ -126,6 +126,14 @@ library ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h DerivedConstants.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/Types.h @@ -296,6 +304,14 @@ library rts/storage/TSO.h stg/DLL.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/MiscClosures.h stg/Prim.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a3b863896fe178463362d9c734d15eda0cf13dbf...aa9ca8f63691edee3d603b15a8fa5a68c83e9ff8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a3b863896fe178463362d9c734d15eda0cf13dbf...aa9ca8f63691edee3d603b15a8fa5a68c83e9ff8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 7 01:45:39 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 06 Oct 2023 21:45:39 -0400 Subject: [Git][ghc/ghc][ghc-9.8] Bump haddock submodule to 2.30 Message-ID: <6520b843dfac5_18f5296005f4dc7813cb@gitlab.mail> Ben Gamari pushed to branch ghc-9.8 at Glasgow Haskell Compiler / GHC Commits: bda60b3a by Ben Gamari at 2023-10-06T21:45:17-04:00 Bump haddock submodule to 2.30 - - - - - 1 changed file: - utils/haddock Changes: ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit fd959b46d61b8cf8afb1bb8a46bb9b5d44a509b3 +Subproject commit 994989ed3d535177e57b778629726aeabe8c7602 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bda60b3ae47b6d718e7652722560e6944209a364 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bda60b3ae47b6d718e7652722560e6944209a364 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 7 02:32:49 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 06 Oct 2023 22:32:49 -0400 Subject: [Git][ghc/ghc][wip/release-9.8.1] 3 commits: Bump haddock submodule to 2.30 Message-ID: <6520c351b8f6f_18f529612995d07837b7@gitlab.mail> Ben Gamari pushed to branch wip/release-9.8.1 at Glasgow Haskell Compiler / GHC Commits: bda60b3a by Ben Gamari at 2023-10-06T21:45:17-04:00 Bump haddock submodule to 2.30 - - - - - b2d15ab1 by Ben Gamari at 2023-10-06T21:45:48-04:00 hadrian: Fix hpc parser path - - - - - 443e870d by Ben Gamari at 2023-10-06T21:45:48-04:00 Release GHC 9.8.1 - - - - - 3 changed files: - configure.ac - hadrian/src/Rules/SourceDist.hs - utils/haddock Changes: ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.0], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -22,7 +22,7 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.0], [glasgow-has AC_CONFIG_MACRO_DIRS([m4]) # Set this to YES for a released version, otherwise NO -: ${RELEASE=NO} +: ${RELEASE=YES} # The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line # above. If this is not a released version, then we will append the ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -184,7 +184,7 @@ prepareTree dest = do , (stage0InTree , compiler, "GHC/Parser.y", "GHC/Parser.hs") , (stage0InTree , compiler, "GHC/Parser/Lexer.x", "GHC/Parser/Lexer.hs") , (stage0InTree , compiler, "GHC/Parser/HaddockLex.x", "GHC/Parser/HaddockLex.hs") - , (stage0InTree , hpcBin, "src/HpcParser.y", "src/HpcParser.hs") + , (stage0InTree , hpcBin, "src/Trace/Hpc/Parser.y", "src/Trace/Hpc/Parser.hs") , (stage0InTree , genprimopcode, "Parser.y", "Parser.hs") , (stage0InTree , genprimopcode, "Lexer.x", "Lexer.hs") ] ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit fd959b46d61b8cf8afb1bb8a46bb9b5d44a509b3 +Subproject commit 994989ed3d535177e57b778629726aeabe8c7602 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8f864a5d81ed951fa2e83b6b761e639400b3c439...443e870d977b1ab6fc05f47a9a17bc49296adbd6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8f864a5d81ed951fa2e83b6b761e639400b3c439...443e870d977b1ab6fc05f47a9a17bc49296adbd6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 7 06:29:36 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 07 Oct 2023 02:29:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Ensure unconstrained instance dictionaries get IPE info Message-ID: <6520fad0dc250_18f5296681b2b0796853@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 4d491d12 by Andreas Klebinger at 2023-10-07T02:29:14-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 34b23d18 by Bryan Richter at 2023-10-07T02:29:15-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - fe6acfed by Bryan Richter at 2023-10-07T02:29:15-04:00 Update hackage index state - - - - - e033e404 by Bryan Richter at 2023-10-07T02:29:15-04:00 Ensure hadrian uses CI's hackage index state - - - - - 21 changed files: - .gitignore - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/Stg/Debug.hs - compiler/ghc.cabal.in - configure.ac - hadrian/cabal.project - rts/include/stg/MachRegs.h - + rts/include/stg/MachRegs/arm32.h - + rts/include/stg/MachRegs/arm64.h - + rts/include/stg/MachRegs/loongarch64.h - + rts/include/stg/MachRegs/ppc.h - + rts/include/stg/MachRegs/riscv64.h - + rts/include/stg/MachRegs/s390x.h - + rts/include/stg/MachRegs/wasm32.h - + rts/include/stg/MachRegs/x86.h - rts/rts.cabal.in - + testsuite/tests/rts/ipe/T24005/all.T - + testsuite/tests/rts/ipe/T24005/t24005.hs - + testsuite/tests/rts/ipe/T24005/t24005.stdout Changes: ===================================== .gitignore ===================================== @@ -111,6 +111,7 @@ _darcs/ /compiler/ClosureTypes.h /compiler/FunTypes.h /compiler/MachRegs.h +/compiler/MachRegs /compiler/ghc-llvm-version.h /compiler/ghc.cabal /compiler/ghc.cabal.old ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -230,7 +230,7 @@ function set_toolchain_paths() { function cabal_update() { # In principle -w shouldn't be necessary here but with # cabal-install 3.8.1.0 it is, due to cabal#8447. - run "$CABAL" update -w "$GHC" --index="$HACKAGE_INDEX_STATE" + run "$CABAL" update -w "$GHC" "hackage.haskell.org,${HACKAGE_INDEX_STATE}" } @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== compiler/CodeGen.Platform.h ===================================== @@ -480,6 +480,7 @@ import GHC.Platform.Reg #endif +-- See also Note [Caller saves and callee-saves regs.] callerSaves :: GlobalReg -> Bool #if defined(CALLER_SAVES_Base) callerSaves BaseReg = True ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -15,7 +15,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnboxedTuples #-} --- | Native code generator +-- | Note [Native code generator] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- The native-code generator has machine-independent and -- machine-dependent modules. @@ -23,45 +24,39 @@ -- This module ("GHC.CmmToAsm") is the top-level machine-independent -- module. Before entering machine-dependent land, we do some -- machine-independent optimisations (defined below) on the --- 'CmmStmts's. +-- 'CmmStmts's. (Which ideally would be folded into CmmOpt ...) -- -- We convert to the machine-specific 'Instr' datatype with -- 'cmmCodeGen', assuming an infinite supply of registers. We then use --- a machine-independent register allocator ('regAlloc') to rejoin +-- a (mostly) machine-independent register allocator to rejoin -- reality. Obviously, 'regAlloc' has machine-specific helper --- functions (see about "RegAllocInfo" below). +-- functions (see the used register allocator for details). -- -- Finally, we order the basic blocks of the function so as to minimise -- the number of jumps between blocks, by utilising fallthrough wherever -- possible. -- --- The machine-dependent bits break down as follows: +-- The machine-dependent bits are generally contained under +-- GHC/CmmToAsm//* and generally breaks down as follows: -- --- * ["MachRegs"] Everything about the target platform's machine +-- * "Regs": Everything about the target platform's machine -- registers (and immediate operands, and addresses, which tend to -- intermingle/interact with registers). -- --- * ["MachInstrs"] Includes the 'Instr' datatype (possibly should --- have a module of its own), plus a miscellany of other things +-- * "Instr": Includes the 'Instr' datatype plus a miscellany of other things -- (e.g., 'targetDoubleSize', 'smStablePtrTable', ...) -- --- * ["MachCodeGen"] is where 'Cmm' stuff turns into +-- * "CodeGen": is where 'Cmm' stuff turns into -- machine instructions. -- --- * ["PprMach"] 'pprInstr' turns an 'Instr' into text (well, really +-- * "Ppr": 'pprInstr' turns an 'Instr' into text (well, really -- a 'SDoc'). -- --- * ["RegAllocInfo"] In the register allocator, we manipulate --- 'MRegsState's, which are 'BitSet's, one bit per machine register. --- When we want to say something about a specific machine register --- (e.g., ``it gets clobbered by this instruction''), we set/unset --- its bit. Obviously, we do this 'BitSet' thing for efficiency --- reasons. +-- The register allocators lives under GHC.CmmToAsm.Reg.*, there is both a Linear and a Graph +-- based register allocator. Both of which have their own notes describing them. They +-- are mostly platform independent but there are some platform specific files +-- encoding architecture details under Reg// -- --- The 'RegAllocInfo' module collects together the machine-specific --- info needed to do register allocation. --- --- * ["RegisterAlloc"] The (machine-independent) register allocator. -- -} -- module GHC.CmmToAsm ===================================== compiler/GHC/Stg/Debug.hs ===================================== @@ -68,21 +68,25 @@ collectStgBind (StgRec pairs) = do return (StgRec es) collectStgRhs :: Id -> StgRhs -> M StgRhs -collectStgRhs bndr (StgRhsClosure ext cc us bs e t) = do - let - name = idName bndr - -- If the name has a span, use that initially as the source position in-case - -- we don't get anything better. - with_span = case nameSrcSpan name of - RealSrcSpan pos _ -> withSpan (pos, LexicalFastString $ occNameFS (getOccName name)) - _ -> id - e' <- with_span $ collectExpr e - recordInfo bndr e' - return $ StgRhsClosure ext cc us bs e' t -collectStgRhs _bndr (StgRhsCon cc dc _mn ticks args typ) = do - n' <- numberDataCon dc ticks - return (StgRhsCon cc dc n' ticks args typ) - +collectStgRhs bndr rhs = + case rhs of + StgRhsClosure ext cc us bs e t -> do + e' <- with_span $ collectExpr e + recordInfo bndr e' + return $ StgRhsClosure ext cc us bs e' t + StgRhsCon cc dc _mn ticks args typ -> do + n' <- with_span $ numberDataCon dc ticks + return (StgRhsCon cc dc n' ticks args typ) + where + -- If the binder name has a span, use that initially as the source position + -- in case we don't get anything better + with_span :: M a -> M a + with_span = + let name = idName bndr in + case nameSrcSpan name of + RealSrcSpan pos _ -> + withSpan (pos, LexicalFastString $ occNameFS (getOccName name)) + _ -> id recordInfo :: Id -> StgExpr -> M () recordInfo bndr new_rhs = do ===================================== compiler/ghc.cabal.in ===================================== @@ -34,6 +34,14 @@ extra-source-files: ClosureTypes.h FunTypes.h MachRegs.h + MachRegs/arm32.h + MachRegs/arm64.h + MachRegs/loongarch64.h + MachRegs/ppc.h + MachRegs/riscv64.h + MachRegs/s390x.h + MachRegs/wasm32.h + MachRegs/x86.h ghc-llvm-version.h ===================================== configure.ac ===================================== @@ -578,6 +578,15 @@ ln -f rts/include/rts/Bytecodes.h compiler/ ln -f rts/include/rts/storage/ClosureTypes.h compiler/ ln -f rts/include/rts/storage/FunTypes.h compiler/ ln -f rts/include/stg/MachRegs.h compiler/ +mkdir -p compiler/MachRegs +ln -f rts/include/stg/MachRegs/arm32.h compiler/MachRegs/arm32.h +ln -f rts/include/stg/MachRegs/arm64.h compiler/MachRegs/arm64.h +ln -f rts/include/stg/MachRegs/loongarch64.h compiler/MachRegs/loongarch64.h +ln -f rts/include/stg/MachRegs/ppc.h compiler/MachRegs/ppc.h +ln -f rts/include/stg/MachRegs/riscv64.h compiler/MachRegs/riscv64.h +ln -f rts/include/stg/MachRegs/s390x.h compiler/MachRegs/s390x.h +ln -f rts/include/stg/MachRegs/wasm32.h compiler/MachRegs/wasm32.h +ln -f rts/include/stg/MachRegs/x86.h compiler/MachRegs/x86.h AC_MSG_NOTICE([done.]) dnl ** Copy the files from the "fs" utility into the right folders. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. ===================================== rts/include/stg/MachRegs.h ===================================== @@ -51,637 +51,54 @@ #elif MACHREGS_NO_REGS == 0 /* ---------------------------------------------------------------------------- - Caller saves and callee-saves regs. - + Note [Caller saves and callee-saves regs.] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Caller-saves regs have to be saved around C-calls made from STG land, so this file defines CALLER_SAVES_ for each that is designated caller-saves in that machine's C calling convention. + NB: Caller-saved registers not mapped to a STG register don't + require a CALLER_SAVES_ define. As it stands, the only registers that are ever marked caller saves - are the RX, FX, DX and USER registers; as a result, if you + are the RX, FX, DX, XMM and USER registers; as a result, if you decide to caller save a system register (e.g. SP, HP, etc), note that this code path is completely untested! -- EZY See Note [Register parameter passing] for details. -------------------------------------------------------------------------- */ -/* ----------------------------------------------------------------------------- - The x86 register mapping - - Ok, we've only got 6 general purpose registers, a frame pointer and a - stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, - hence they get trashed across ccalls and are caller saves. \tr{%ebx}, - \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. - - Reg STG-Reg - --------------- - ebx Base - ebp Sp - esi R1 - edi Hp - - Leaving SpLim out of the picture. - -------------------------------------------------------------------------- */ - -#if defined(MACHREGS_i386) - -#define REG(x) __asm__("%" #x) - -#if !defined(not_doing_dynamic_linking) -#define REG_Base ebx -#endif -#define REG_Sp ebp - -#if !defined(STOLEN_X86_REGS) -#define STOLEN_X86_REGS 4 -#endif - -#if STOLEN_X86_REGS >= 3 -# define REG_R1 esi -#endif - -#if STOLEN_X86_REGS >= 4 -# define REG_Hp edi -#endif -#define REG_MachSp esp - -#define REG_XMM1 xmm0 -#define REG_XMM2 xmm1 -#define REG_XMM3 xmm2 -#define REG_XMM4 xmm3 - -#define REG_YMM1 ymm0 -#define REG_YMM2 ymm1 -#define REG_YMM3 ymm2 -#define REG_YMM4 ymm3 - -#define REG_ZMM1 zmm0 -#define REG_ZMM2 zmm1 -#define REG_ZMM3 zmm2 -#define REG_ZMM4 zmm3 - -#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ -#define MAX_REAL_FLOAT_REG 0 -#define MAX_REAL_DOUBLE_REG 0 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 4 -#define MAX_REAL_YMM_REG 4 -#define MAX_REAL_ZMM_REG 4 - -/* ----------------------------------------------------------------------------- - The x86-64 register mapping - - %rax caller-saves, don't steal this one - %rbx YES - %rcx arg reg, caller-saves - %rdx arg reg, caller-saves - %rsi arg reg, caller-saves - %rdi arg reg, caller-saves - %rbp YES (our *prime* register) - %rsp (unavailable - stack pointer) - %r8 arg reg, caller-saves - %r9 arg reg, caller-saves - %r10 caller-saves - %r11 caller-saves - %r12 YES - %r13 YES - %r14 YES - %r15 YES - - %xmm0-7 arg regs, caller-saves - %xmm8-15 caller-saves - - Use the caller-saves regs for Rn, because we don't always have to - save those (as opposed to Sp/Hp/SpLim etc. which always have to be - saved). - - --------------------------------------------------------------------------- */ - -#elif defined(MACHREGS_x86_64) - -#define REG(x) __asm__("%" #x) - -#define REG_Base r13 -#define REG_Sp rbp -#define REG_Hp r12 -#define REG_R1 rbx -#define REG_R2 r14 -#define REG_R3 rsi -#define REG_R4 rdi -#define REG_R5 r8 -#define REG_R6 r9 -#define REG_SpLim r15 -#define REG_MachSp rsp - -/* -Map both Fn and Dn to register xmmn so that we can pass a function any -combination of up to six Float# or Double# arguments without touching -the stack. See Note [Overlapping global registers] for implications. -*/ - -#define REG_F1 xmm1 -#define REG_F2 xmm2 -#define REG_F3 xmm3 -#define REG_F4 xmm4 -#define REG_F5 xmm5 -#define REG_F6 xmm6 - -#define REG_D1 xmm1 -#define REG_D2 xmm2 -#define REG_D3 xmm3 -#define REG_D4 xmm4 -#define REG_D5 xmm5 -#define REG_D6 xmm6 - -#define REG_XMM1 xmm1 -#define REG_XMM2 xmm2 -#define REG_XMM3 xmm3 -#define REG_XMM4 xmm4 -#define REG_XMM5 xmm5 -#define REG_XMM6 xmm6 - -#define REG_YMM1 ymm1 -#define REG_YMM2 ymm2 -#define REG_YMM3 ymm3 -#define REG_YMM4 ymm4 -#define REG_YMM5 ymm5 -#define REG_YMM6 ymm6 - -#define REG_ZMM1 zmm1 -#define REG_ZMM2 zmm2 -#define REG_ZMM3 zmm3 -#define REG_ZMM4 zmm4 -#define REG_ZMM5 zmm5 -#define REG_ZMM6 zmm6 - -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_R3 -#define CALLER_SAVES_R4 -#endif -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 - -#define CALLER_SAVES_F1 -#define CALLER_SAVES_F2 -#define CALLER_SAVES_F3 -#define CALLER_SAVES_F4 -#define CALLER_SAVES_F5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_F6 -#endif - -#define CALLER_SAVES_D1 -#define CALLER_SAVES_D2 -#define CALLER_SAVES_D3 -#define CALLER_SAVES_D4 -#define CALLER_SAVES_D5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_D6 -#endif - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 -#define CALLER_SAVES_XMM3 -#define CALLER_SAVES_XMM4 -#define CALLER_SAVES_XMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_XMM6 -#endif - -#define CALLER_SAVES_YMM1 -#define CALLER_SAVES_YMM2 -#define CALLER_SAVES_YMM3 -#define CALLER_SAVES_YMM4 -#define CALLER_SAVES_YMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_YMM6 -#endif - -#define CALLER_SAVES_ZMM1 -#define CALLER_SAVES_ZMM2 -#define CALLER_SAVES_ZMM3 -#define CALLER_SAVES_ZMM4 -#define CALLER_SAVES_ZMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_ZMM6 -#endif - -#define MAX_REAL_VANILLA_REG 6 -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 6 -#define MAX_REAL_YMM_REG 6 -#define MAX_REAL_ZMM_REG 6 - -/* ----------------------------------------------------------------------------- - The PowerPC register mapping - - 0 system glue? (caller-save, volatile) - 1 SP (callee-save, non-volatile) - 2 AIX, powerpc64-linux: - RTOC (a strange special case) - powerpc32-linux: - reserved for use by system +/* Define STG <-> machine register mappings. */ +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) - 3-10 args/return (caller-save, volatile) - 11,12 system glue? (caller-save, volatile) - 13 on 64-bit: reserved for thread state pointer - on 32-bit: (callee-save, non-volatile) - 14-31 (callee-save, non-volatile) - - f0 (caller-save, volatile) - f1-f13 args/return (caller-save, volatile) - f14-f31 (callee-save, non-volatile) - - \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. - \tr{0}--\tr{12} are caller-save registers. - - \tr{%f14}--\tr{%f31} are callee-save floating-point registers. - - We can do the Whole Business with callee-save registers only! - -------------------------------------------------------------------------- */ +#include "MachRegs/x86.h" #elif defined(MACHREGS_powerpc) -#define REG(x) __asm__(#x) - -#define REG_R1 r14 -#define REG_R2 r15 -#define REG_R3 r16 -#define REG_R4 r17 -#define REG_R5 r18 -#define REG_R6 r19 -#define REG_R7 r20 -#define REG_R8 r21 -#define REG_R9 r22 -#define REG_R10 r23 - -#define REG_F1 fr14 -#define REG_F2 fr15 -#define REG_F3 fr16 -#define REG_F4 fr17 -#define REG_F5 fr18 -#define REG_F6 fr19 - -#define REG_D1 fr20 -#define REG_D2 fr21 -#define REG_D3 fr22 -#define REG_D4 fr23 -#define REG_D5 fr24 -#define REG_D6 fr25 - -#define REG_Sp r24 -#define REG_SpLim r25 -#define REG_Hp r26 -#define REG_Base r27 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 - -/* ----------------------------------------------------------------------------- - The ARM EABI register mapping - - Here we consider ARM mode (i.e. 32bit isns) - and also CPU with full VFPv3 implementation - - ARM registers (see Chapter 5.1 in ARM IHI 0042D and - Section 9.2.2 in ARM Software Development Toolkit Reference Guide) - - r15 PC The Program Counter. - r14 LR The Link Register. - r13 SP The Stack Pointer. - r12 IP The Intra-Procedure-call scratch register. - r11 v8/fp Variable-register 8. - r10 v7/sl Variable-register 7. - r9 v6/SB/TR Platform register. The meaning of this register is - defined by the platform standard. - r8 v5 Variable-register 5. - r7 v4 Variable register 4. - r6 v3 Variable register 3. - r5 v2 Variable register 2. - r4 v1 Variable register 1. - r3 a4 Argument / scratch register 4. - r2 a3 Argument / scratch register 3. - r1 a2 Argument / result / scratch register 2. - r0 a1 Argument / result / scratch register 1. - - VFPv2/VFPv3/NEON registers - s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers - s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across - subroutine calls) - - VFPv3/NEON registers (added to the VFPv2 registers set) - d16-d31/q8-q15 Argument / result/ scratch registers - ----------------------------------------------------------------------------- */ +#include "MachRegs/ppc.h" #elif defined(MACHREGS_arm) -#define REG(x) __asm__(#x) - -#define REG_Base r4 -#define REG_Sp r5 -#define REG_Hp r6 -#define REG_R1 r7 -#define REG_R2 r8 -#define REG_R3 r9 -#define REG_R4 r10 -#define REG_SpLim r11 - -#if !defined(arm_HOST_ARCH_PRE_ARMv6) -/* d8 */ -#define REG_F1 s16 -#define REG_F2 s17 -/* d9 */ -#define REG_F3 s18 -#define REG_F4 s19 - -#define REG_D1 d10 -#define REG_D2 d11 -#endif - -/* ----------------------------------------------------------------------------- - The ARMv8/AArch64 ABI register mapping - - The AArch64 provides 31 64-bit general purpose registers - and 32 128-bit SIMD/floating point registers. - - General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) - - Register | Special | Role in the procedure call standard - ---------+---------+------------------------------------ - SP | | The Stack Pointer - r30 | LR | The Link Register - r29 | FP | The Frame Pointer - r19-r28 | | Callee-saved registers - r18 | | The Platform Register, if needed; - | | or temporary register - r17 | IP1 | The second intra-procedure-call temporary register - r16 | IP0 | The first intra-procedure-call scratch register - r9-r15 | | Temporary registers - r8 | | Indirect result location register - r0-r7 | | Parameter/result registers - - - FPU/SIMD registers - - s/d/q/v0-v7 Argument / result/ scratch registers - s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, - but only bottom 64-bit value needs to be preserved) - s/d/q/v16-v31 temporary registers - - ----------------------------------------------------------------------------- */ +#include "MachRegs/arm32.h" #elif defined(MACHREGS_aarch64) -#define REG(x) __asm__(#x) - -#define REG_Base r19 -#define REG_Sp r20 -#define REG_Hp r21 -#define REG_R1 r22 -#define REG_R2 r23 -#define REG_R3 r24 -#define REG_R4 r25 -#define REG_R5 r26 -#define REG_R6 r27 -#define REG_SpLim r28 - -#define REG_F1 s8 -#define REG_F2 s9 -#define REG_F3 s10 -#define REG_F4 s11 - -#define REG_D1 d12 -#define REG_D2 d13 -#define REG_D3 d14 -#define REG_D4 d15 - -#define REG_XMM1 q4 -#define REG_XMM2 q5 - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 - -/* ----------------------------------------------------------------------------- - The s390x register mapping - - Register | Role(s) | Call effect - ------------+-------------------------------------+----------------- - r0,r1 | - | caller-saved - r2 | Argument / return value | caller-saved - r3,r4,r5 | Arguments | caller-saved - r6 | Argument | callee-saved - r7...r11 | - | callee-saved - r12 | (Commonly used as GOT pointer) | callee-saved - r13 | (Commonly used as literal pool pointer) | callee-saved - r14 | Return address | caller-saved - r15 | Stack pointer | callee-saved - f0 | Argument / return value | caller-saved - f2,f4,f6 | Arguments | caller-saved - f1,f3,f5,f7 | - | caller-saved - f8...f15 | - | callee-saved - v0...v31 | - | caller-saved - - Each general purpose register r0 through r15 as well as each floating-point - register f0 through f15 is 64 bits wide. Each vector register v0 through v31 - is 128 bits wide. - - Note, the vector registers v0 through v15 overlap with the floating-point - registers f0 through f15. - - -------------------------------------------------------------------------- */ +#include "MachRegs/arm64.h" #elif defined(MACHREGS_s390x) -#define REG(x) __asm__("%" #x) - -#define REG_Base r7 -#define REG_Sp r8 -#define REG_Hp r10 -#define REG_R1 r11 -#define REG_R2 r12 -#define REG_R3 r13 -#define REG_R4 r6 -#define REG_R5 r2 -#define REG_R6 r3 -#define REG_R7 r4 -#define REG_R8 r5 -#define REG_SpLim r9 -#define REG_MachSp r15 - -#define REG_F1 f8 -#define REG_F2 f9 -#define REG_F3 f10 -#define REG_F4 f11 -#define REG_F5 f0 -#define REG_F6 f1 - -#define REG_D1 f12 -#define REG_D2 f13 -#define REG_D3 f14 -#define REG_D4 f15 -#define REG_D5 f2 -#define REG_D6 f3 - -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 -#define CALLER_SAVES_R7 -#define CALLER_SAVES_R8 - -#define CALLER_SAVES_F5 -#define CALLER_SAVES_F6 - -#define CALLER_SAVES_D5 -#define CALLER_SAVES_D6 - -/* ----------------------------------------------------------------------------- - The riscv64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - sp | Stack pointer | callee-saved - gp | Global pointer | callee-saved - tp | Thread pointer | callee-saved - t0,t1,t2 | - | caller-saved - s0 | Frame pointer | callee-saved - s1 | - | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - s2..s11 | - | callee-saved - t3..t6 | - | caller-saved - ft0..ft7 | - | caller-saved - fs0,fs1 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - fs2..fs11 | - | callee-saved - ft8..ft11 | - | caller-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide. - - -------------------------------------------------------------------------- */ +#include "MachRegs/s390x.h" #elif defined(MACHREGS_riscv64) -#define REG(x) __asm__(#x) - -#define REG_Base s1 -#define REG_Sp s2 -#define REG_Hp s3 -#define REG_R1 s4 -#define REG_R2 s5 -#define REG_R3 s6 -#define REG_R4 s7 -#define REG_R5 s8 -#define REG_R6 s9 -#define REG_R7 s10 -#define REG_SpLim s11 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 -#define REG_F5 fs4 -#define REG_F6 fs5 - -#define REG_D1 fs6 -#define REG_D2 fs7 -#define REG_D3 fs8 -#define REG_D4 fs9 -#define REG_D5 fs10 -#define REG_D6 fs11 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 +#include "MachRegs/riscv64.h" #elif defined(MACHREGS_wasm32) -#define REG_R1 1 -#define REG_R2 2 -#define REG_R3 3 -#define REG_R4 4 -#define REG_R5 5 -#define REG_R6 6 -#define REG_R7 7 -#define REG_R8 8 -#define REG_R9 9 -#define REG_R10 10 - -#define REG_F1 11 -#define REG_F2 12 -#define REG_F3 13 -#define REG_F4 14 -#define REG_F5 15 -#define REG_F6 16 - -#define REG_D1 17 -#define REG_D2 18 -#define REG_D3 19 -#define REG_D4 20 -#define REG_D5 21 -#define REG_D6 22 - -#define REG_L1 23 - -#define REG_Sp 24 -#define REG_SpLim 25 -#define REG_Hp 26 -#define REG_HpLim 27 -#define REG_CCCS 28 - -/* ----------------------------------------------------------------------------- - The loongarch64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - tp | Thread pointer | - - sp | Stack pointer | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - t0..t8 | - | caller-saved - u0 | Reserve | - - fp | Frame pointer | callee-saved - s0..s8 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - ft0..ft15 | - | caller-saved - fs0..fs7 | - | callee-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide, also, the u0 register is called r21 in some cases. +#include "MachRegs/wasm32.h" - -------------------------------------------------------------------------- */ #elif defined(MACHREGS_loongarch64) -#define REG(x) __asm__("$" #x) - -#define REG_Base s0 -#define REG_Sp s1 -#define REG_Hp s2 -#define REG_R1 s3 -#define REG_R2 s4 -#define REG_R3 s5 -#define REG_R4 s6 -#define REG_R5 s7 -#define REG_SpLim s8 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 - -#define REG_D1 fs4 -#define REG_D2 fs5 -#define REG_D3 fs6 -#define REG_D4 fs7 - -#define MAX_REAL_FLOAT_REG 4 -#define MAX_REAL_DOUBLE_REG 4 +#include "MachRegs/loongarch64.h" #else ===================================== rts/include/stg/MachRegs/arm32.h ===================================== @@ -0,0 +1,60 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The ARM EABI register mapping + + Here we consider ARM mode (i.e. 32bit isns) + and also CPU with full VFPv3 implementation + + ARM registers (see Chapter 5.1 in ARM IHI 0042D and + Section 9.2.2 in ARM Software Development Toolkit Reference Guide) + + r15 PC The Program Counter. + r14 LR The Link Register. + r13 SP The Stack Pointer. + r12 IP The Intra-Procedure-call scratch register. + r11 v8/fp Variable-register 8. + r10 v7/sl Variable-register 7. + r9 v6/SB/TR Platform register. The meaning of this register is + defined by the platform standard. + r8 v5 Variable-register 5. + r7 v4 Variable register 4. + r6 v3 Variable register 3. + r5 v2 Variable register 2. + r4 v1 Variable register 1. + r3 a4 Argument / scratch register 4. + r2 a3 Argument / scratch register 3. + r1 a2 Argument / result / scratch register 2. + r0 a1 Argument / result / scratch register 1. + + VFPv2/VFPv3/NEON registers + s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers + s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across + subroutine calls) + + VFPv3/NEON registers (added to the VFPv2 registers set) + d16-d31/q8-q15 Argument / result/ scratch registers + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r4 +#define REG_Sp r5 +#define REG_Hp r6 +#define REG_R1 r7 +#define REG_R2 r8 +#define REG_R3 r9 +#define REG_R4 r10 +#define REG_SpLim r11 + +#if !defined(arm_HOST_ARCH_PRE_ARMv6) +/* d8 */ +#define REG_F1 s16 +#define REG_F2 s17 +/* d9 */ +#define REG_F3 s18 +#define REG_F4 s19 + +#define REG_D1 d10 +#define REG_D2 d11 +#endif \ No newline at end of file ===================================== rts/include/stg/MachRegs/arm64.h ===================================== @@ -0,0 +1,64 @@ +#pragma once + + +/* ----------------------------------------------------------------------------- + The ARMv8/AArch64 ABI register mapping + + The AArch64 provides 31 64-bit general purpose registers + and 32 128-bit SIMD/floating point registers. + + General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) + + Register | Special | Role in the procedure call standard + ---------+---------+------------------------------------ + SP | | The Stack Pointer + r30 | LR | The Link Register + r29 | FP | The Frame Pointer + r19-r28 | | Callee-saved registers + r18 | | The Platform Register, if needed; + | | or temporary register + r17 | IP1 | The second intra-procedure-call temporary register + r16 | IP0 | The first intra-procedure-call scratch register + r9-r15 | | Temporary registers + r8 | | Indirect result location register + r0-r7 | | Parameter/result registers + + + FPU/SIMD registers + + s/d/q/v0-v7 Argument / result/ scratch registers + s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, + but only bottom 64-bit value needs to be preserved) + s/d/q/v16-v31 temporary registers + + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r19 +#define REG_Sp r20 +#define REG_Hp r21 +#define REG_R1 r22 +#define REG_R2 r23 +#define REG_R3 r24 +#define REG_R4 r25 +#define REG_R5 r26 +#define REG_R6 r27 +#define REG_SpLim r28 + +#define REG_F1 s8 +#define REG_F2 s9 +#define REG_F3 s10 +#define REG_F4 s11 + +#define REG_D1 d12 +#define REG_D2 d13 +#define REG_D3 d14 +#define REG_D4 d15 + +#define REG_XMM1 q4 +#define REG_XMM2 q5 + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 + ===================================== rts/include/stg/MachRegs/loongarch64.h ===================================== @@ -0,0 +1,51 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The loongarch64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + tp | Thread pointer | - + sp | Stack pointer | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + t0..t8 | - | caller-saved + u0 | Reserve | - + fp | Frame pointer | callee-saved + s0..s8 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + ft0..ft15 | - | caller-saved + fs0..fs7 | - | callee-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide, also, the u0 register is called r21 in some cases. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__("$" #x) + +#define REG_Base s0 +#define REG_Sp s1 +#define REG_Hp s2 +#define REG_R1 s3 +#define REG_R2 s4 +#define REG_R3 s5 +#define REG_R4 s6 +#define REG_R5 s7 +#define REG_SpLim s8 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 + +#define REG_D1 fs4 +#define REG_D2 fs5 +#define REG_D3 fs6 +#define REG_D4 fs7 + +#define MAX_REAL_FLOAT_REG 4 +#define MAX_REAL_DOUBLE_REG 4 ===================================== rts/include/stg/MachRegs/ppc.h ===================================== @@ -0,0 +1,65 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The PowerPC register mapping + + 0 system glue? (caller-save, volatile) + 1 SP (callee-save, non-volatile) + 2 AIX, powerpc64-linux: + RTOC (a strange special case) + powerpc32-linux: + reserved for use by system + + 3-10 args/return (caller-save, volatile) + 11,12 system glue? (caller-save, volatile) + 13 on 64-bit: reserved for thread state pointer + on 32-bit: (callee-save, non-volatile) + 14-31 (callee-save, non-volatile) + + f0 (caller-save, volatile) + f1-f13 args/return (caller-save, volatile) + f14-f31 (callee-save, non-volatile) + + \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. + \tr{0}--\tr{12} are caller-save registers. + + \tr{%f14}--\tr{%f31} are callee-save floating-point registers. + + We can do the Whole Business with callee-save registers only! + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__(#x) + +#define REG_R1 r14 +#define REG_R2 r15 +#define REG_R3 r16 +#define REG_R4 r17 +#define REG_R5 r18 +#define REG_R6 r19 +#define REG_R7 r20 +#define REG_R8 r21 +#define REG_R9 r22 +#define REG_R10 r23 + +#define REG_F1 fr14 +#define REG_F2 fr15 +#define REG_F3 fr16 +#define REG_F4 fr17 +#define REG_F5 fr18 +#define REG_F6 fr19 + +#define REG_D1 fr20 +#define REG_D2 fr21 +#define REG_D3 fr22 +#define REG_D4 fr23 +#define REG_D5 fr24 +#define REG_D6 fr25 + +#define REG_Sp r24 +#define REG_SpLim r25 +#define REG_Hp r26 +#define REG_Base r27 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/riscv64.h ===================================== @@ -0,0 +1,61 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The riscv64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + sp | Stack pointer | callee-saved + gp | Global pointer | callee-saved + tp | Thread pointer | callee-saved + t0,t1,t2 | - | caller-saved + s0 | Frame pointer | callee-saved + s1 | - | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + s2..s11 | - | callee-saved + t3..t6 | - | caller-saved + ft0..ft7 | - | caller-saved + fs0,fs1 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + fs2..fs11 | - | callee-saved + ft8..ft11 | - | caller-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base s1 +#define REG_Sp s2 +#define REG_Hp s3 +#define REG_R1 s4 +#define REG_R2 s5 +#define REG_R3 s6 +#define REG_R4 s7 +#define REG_R5 s8 +#define REG_R6 s9 +#define REG_R7 s10 +#define REG_SpLim s11 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 +#define REG_F5 fs4 +#define REG_F6 fs5 + +#define REG_D1 fs6 +#define REG_D2 fs7 +#define REG_D3 fs8 +#define REG_D4 fs9 +#define REG_D5 fs10 +#define REG_D6 fs11 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/s390x.h ===================================== @@ -0,0 +1,72 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The s390x register mapping + + Register | Role(s) | Call effect + ------------+-------------------------------------+----------------- + r0,r1 | - | caller-saved + r2 | Argument / return value | caller-saved + r3,r4,r5 | Arguments | caller-saved + r6 | Argument | callee-saved + r7...r11 | - | callee-saved + r12 | (Commonly used as GOT pointer) | callee-saved + r13 | (Commonly used as literal pool pointer) | callee-saved + r14 | Return address | caller-saved + r15 | Stack pointer | callee-saved + f0 | Argument / return value | caller-saved + f2,f4,f6 | Arguments | caller-saved + f1,f3,f5,f7 | - | caller-saved + f8...f15 | - | callee-saved + v0...v31 | - | caller-saved + + Each general purpose register r0 through r15 as well as each floating-point + register f0 through f15 is 64 bits wide. Each vector register v0 through v31 + is 128 bits wide. + + Note, the vector registers v0 through v15 overlap with the floating-point + registers f0 through f15. + + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__("%" #x) + +#define REG_Base r7 +#define REG_Sp r8 +#define REG_Hp r10 +#define REG_R1 r11 +#define REG_R2 r12 +#define REG_R3 r13 +#define REG_R4 r6 +#define REG_R5 r2 +#define REG_R6 r3 +#define REG_R7 r4 +#define REG_R8 r5 +#define REG_SpLim r9 +#define REG_MachSp r15 + +#define REG_F1 f8 +#define REG_F2 f9 +#define REG_F3 f10 +#define REG_F4 f11 +#define REG_F5 f0 +#define REG_F6 f1 + +#define REG_D1 f12 +#define REG_D2 f13 +#define REG_D3 f14 +#define REG_D4 f15 +#define REG_D5 f2 +#define REG_D6 f3 + +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 +#define CALLER_SAVES_R7 +#define CALLER_SAVES_R8 + +#define CALLER_SAVES_F5 +#define CALLER_SAVES_F6 + +#define CALLER_SAVES_D5 +#define CALLER_SAVES_D6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/wasm32.h ===================================== ===================================== rts/include/stg/MachRegs/x86.h ===================================== @@ -0,0 +1,210 @@ +/* ----------------------------------------------------------------------------- + The x86 register mapping + + Ok, we've only got 6 general purpose registers, a frame pointer and a + stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, + hence they get trashed across ccalls and are caller saves. \tr{%ebx}, + \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. + + Reg STG-Reg + --------------- + ebx Base + ebp Sp + esi R1 + edi Hp + + Leaving SpLim out of the picture. + -------------------------------------------------------------------------- */ + +#if defined(MACHREGS_i386) + +#define REG(x) __asm__("%" #x) + +#if !defined(not_doing_dynamic_linking) +#define REG_Base ebx +#endif +#define REG_Sp ebp + +#if !defined(STOLEN_X86_REGS) +#define STOLEN_X86_REGS 4 +#endif + +#if STOLEN_X86_REGS >= 3 +# define REG_R1 esi +#endif + +#if STOLEN_X86_REGS >= 4 +# define REG_Hp edi +#endif +#define REG_MachSp esp + +#define REG_XMM1 xmm0 +#define REG_XMM2 xmm1 +#define REG_XMM3 xmm2 +#define REG_XMM4 xmm3 + +#define REG_YMM1 ymm0 +#define REG_YMM2 ymm1 +#define REG_YMM3 ymm2 +#define REG_YMM4 ymm3 + +#define REG_ZMM1 zmm0 +#define REG_ZMM2 zmm1 +#define REG_ZMM3 zmm2 +#define REG_ZMM4 zmm3 + +#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ +#define MAX_REAL_FLOAT_REG 0 +#define MAX_REAL_DOUBLE_REG 0 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 4 +#define MAX_REAL_YMM_REG 4 +#define MAX_REAL_ZMM_REG 4 + +/* ----------------------------------------------------------------------------- + The x86-64 register mapping + + %rax caller-saves, don't steal this one + %rbx YES + %rcx arg reg, caller-saves + %rdx arg reg, caller-saves + %rsi arg reg, caller-saves + %rdi arg reg, caller-saves + %rbp YES (our *prime* register) + %rsp (unavailable - stack pointer) + %r8 arg reg, caller-saves + %r9 arg reg, caller-saves + %r10 caller-saves + %r11 caller-saves + %r12 YES + %r13 YES + %r14 YES + %r15 YES + + %xmm0-7 arg regs, caller-saves + %xmm8-15 caller-saves + + Use the caller-saves regs for Rn, because we don't always have to + save those (as opposed to Sp/Hp/SpLim etc. which always have to be + saved). + + --------------------------------------------------------------------------- */ + +#elif defined(MACHREGS_x86_64) + +#define REG(x) __asm__("%" #x) + +#define REG_Base r13 +#define REG_Sp rbp +#define REG_Hp r12 +#define REG_R1 rbx +#define REG_R2 r14 +#define REG_R3 rsi +#define REG_R4 rdi +#define REG_R5 r8 +#define REG_R6 r9 +#define REG_SpLim r15 +#define REG_MachSp rsp + +/* +Map both Fn and Dn to register xmmn so that we can pass a function any +combination of up to six Float# or Double# arguments without touching +the stack. See Note [Overlapping global registers] for implications. +*/ + +#define REG_F1 xmm1 +#define REG_F2 xmm2 +#define REG_F3 xmm3 +#define REG_F4 xmm4 +#define REG_F5 xmm5 +#define REG_F6 xmm6 + +#define REG_D1 xmm1 +#define REG_D2 xmm2 +#define REG_D3 xmm3 +#define REG_D4 xmm4 +#define REG_D5 xmm5 +#define REG_D6 xmm6 + +#define REG_XMM1 xmm1 +#define REG_XMM2 xmm2 +#define REG_XMM3 xmm3 +#define REG_XMM4 xmm4 +#define REG_XMM5 xmm5 +#define REG_XMM6 xmm6 + +#define REG_YMM1 ymm1 +#define REG_YMM2 ymm2 +#define REG_YMM3 ymm3 +#define REG_YMM4 ymm4 +#define REG_YMM5 ymm5 +#define REG_YMM6 ymm6 + +#define REG_ZMM1 zmm1 +#define REG_ZMM2 zmm2 +#define REG_ZMM3 zmm3 +#define REG_ZMM4 zmm4 +#define REG_ZMM5 zmm5 +#define REG_ZMM6 zmm6 + +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_R3 +#define CALLER_SAVES_R4 +#endif +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 + +#define CALLER_SAVES_F1 +#define CALLER_SAVES_F2 +#define CALLER_SAVES_F3 +#define CALLER_SAVES_F4 +#define CALLER_SAVES_F5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_F6 +#endif + +#define CALLER_SAVES_D1 +#define CALLER_SAVES_D2 +#define CALLER_SAVES_D3 +#define CALLER_SAVES_D4 +#define CALLER_SAVES_D5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_D6 +#endif + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 +#define CALLER_SAVES_XMM3 +#define CALLER_SAVES_XMM4 +#define CALLER_SAVES_XMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_XMM6 +#endif + +#define CALLER_SAVES_YMM1 +#define CALLER_SAVES_YMM2 +#define CALLER_SAVES_YMM3 +#define CALLER_SAVES_YMM4 +#define CALLER_SAVES_YMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_YMM6 +#endif + +#define CALLER_SAVES_ZMM1 +#define CALLER_SAVES_ZMM2 +#define CALLER_SAVES_ZMM3 +#define CALLER_SAVES_ZMM4 +#define CALLER_SAVES_ZMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_ZMM6 +#endif + +#define MAX_REAL_VANILLA_REG 6 +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 6 +#define MAX_REAL_YMM_REG 6 +#define MAX_REAL_ZMM_REG 6 + +#endif /* MACHREGS_i386 || MACHREGS_x86_64 */ \ No newline at end of file ===================================== rts/rts.cabal.in ===================================== @@ -126,6 +126,14 @@ library ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h DerivedConstants.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/Types.h @@ -296,6 +304,14 @@ library rts/storage/TSO.h stg/DLL.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/MiscClosures.h stg/Prim.h ===================================== testsuite/tests/rts/ipe/T24005/all.T ===================================== @@ -0,0 +1 @@ +test('t24005', [ js_skip ], compile_and_run, ['-finfo-table-map -fdistinct-constructor-tables']) ===================================== testsuite/tests/rts/ipe/T24005/t24005.hs ===================================== @@ -0,0 +1,36 @@ +{-# LANGUAGE AllowAmbiguousTypes #-} + +module Main where + +import GHC.InfoProv +import Unsafe.Coerce + +-- Boilerplate to help us access the literal dictionaries + +data Dict c where + Dict :: forall c. c => Dict c + +data Box where + Box :: forall a. a -> Box + +mkBox :: forall a. a => Box +mkBox = unsafeCoerce (Dict @a) + +-- Interesting bit + +data A = A +data B a = B a + +-- Becomes a `StgRhsCon`, which used to not get IPE estimate based on Name +instance Show A where + show = undefined + +-- Becomes a `StgRhsClosure`, which does get IPE estimate based on Name +instance Show a => Show (B a) where + show = undefined + +main :: IO () +main = do + -- Should both result in InfoProvs with correct source locations + (\(Box d) -> print =<< whereFrom d) $ mkBox @(Show A) + (\(Box d) -> print =<< whereFrom d) $ mkBox @(Show (B A)) ===================================== testsuite/tests/rts/ipe/T24005/t24005.stdout ===================================== @@ -0,0 +1,2 @@ +Just (InfoProv {ipName = "C:Show_Main_1_con_info", ipDesc = "1", ipTyDesc = "Show", ipLabel = "$fShowA", ipMod = "Main", ipSrcFile = "t24005.hs", ipSrcSpan = "25:10-15"}) +Just (InfoProv {ipName = "C:Show_Main_0_con_info", ipDesc = "1", ipTyDesc = "Show", ipLabel = "$fShowB", ipMod = "Main", ipSrcFile = "t24005.hs", ipSrcSpan = "29:10-29"}) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aa9ca8f63691edee3d603b15a8fa5a68c83e9ff8...e033e404517dd5d77be4c2956c30c620a30596bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aa9ca8f63691edee3d603b15a8fa5a68c83e9ff8...e033e404517dd5d77be4c2956c30c620a30596bb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 7 11:29:58 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 07 Oct 2023 07:29:58 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: rts: Split up rts/include/stg/MachRegs.h by arch Message-ID: <65214135ea821_18f5296dd3aeb081746@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0787bef5 by Andreas Klebinger at 2023-10-07T07:29:40-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - b3a33751 by Bryan Richter at 2023-10-07T07:29:40-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - d1858289 by Bryan Richter at 2023-10-07T07:29:40-04:00 Update hackage index state - - - - - f828f48f by Bryan Richter at 2023-10-07T07:29:40-04:00 Ensure hadrian uses CI's hackage index state - - - - - 17 changed files: - .gitignore - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/ghc.cabal.in - configure.ac - hadrian/cabal.project - rts/include/stg/MachRegs.h - + rts/include/stg/MachRegs/arm32.h - + rts/include/stg/MachRegs/arm64.h - + rts/include/stg/MachRegs/loongarch64.h - + rts/include/stg/MachRegs/ppc.h - + rts/include/stg/MachRegs/riscv64.h - + rts/include/stg/MachRegs/s390x.h - + rts/include/stg/MachRegs/wasm32.h - + rts/include/stg/MachRegs/x86.h - rts/rts.cabal.in Changes: ===================================== .gitignore ===================================== @@ -111,6 +111,7 @@ _darcs/ /compiler/ClosureTypes.h /compiler/FunTypes.h /compiler/MachRegs.h +/compiler/MachRegs /compiler/ghc-llvm-version.h /compiler/ghc.cabal /compiler/ghc.cabal.old ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -230,7 +230,7 @@ function set_toolchain_paths() { function cabal_update() { # In principle -w shouldn't be necessary here but with # cabal-install 3.8.1.0 it is, due to cabal#8447. - run "$CABAL" update -w "$GHC" --index="$HACKAGE_INDEX_STATE" + run "$CABAL" update -w "$GHC" "hackage.haskell.org,${HACKAGE_INDEX_STATE}" } @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== compiler/CodeGen.Platform.h ===================================== @@ -480,6 +480,7 @@ import GHC.Platform.Reg #endif +-- See also Note [Caller saves and callee-saves regs.] callerSaves :: GlobalReg -> Bool #if defined(CALLER_SAVES_Base) callerSaves BaseReg = True ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -15,7 +15,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnboxedTuples #-} --- | Native code generator +-- | Note [Native code generator] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- The native-code generator has machine-independent and -- machine-dependent modules. @@ -23,45 +24,39 @@ -- This module ("GHC.CmmToAsm") is the top-level machine-independent -- module. Before entering machine-dependent land, we do some -- machine-independent optimisations (defined below) on the --- 'CmmStmts's. +-- 'CmmStmts's. (Which ideally would be folded into CmmOpt ...) -- -- We convert to the machine-specific 'Instr' datatype with -- 'cmmCodeGen', assuming an infinite supply of registers. We then use --- a machine-independent register allocator ('regAlloc') to rejoin +-- a (mostly) machine-independent register allocator to rejoin -- reality. Obviously, 'regAlloc' has machine-specific helper --- functions (see about "RegAllocInfo" below). +-- functions (see the used register allocator for details). -- -- Finally, we order the basic blocks of the function so as to minimise -- the number of jumps between blocks, by utilising fallthrough wherever -- possible. -- --- The machine-dependent bits break down as follows: +-- The machine-dependent bits are generally contained under +-- GHC/CmmToAsm//* and generally breaks down as follows: -- --- * ["MachRegs"] Everything about the target platform's machine +-- * "Regs": Everything about the target platform's machine -- registers (and immediate operands, and addresses, which tend to -- intermingle/interact with registers). -- --- * ["MachInstrs"] Includes the 'Instr' datatype (possibly should --- have a module of its own), plus a miscellany of other things +-- * "Instr": Includes the 'Instr' datatype plus a miscellany of other things -- (e.g., 'targetDoubleSize', 'smStablePtrTable', ...) -- --- * ["MachCodeGen"] is where 'Cmm' stuff turns into +-- * "CodeGen": is where 'Cmm' stuff turns into -- machine instructions. -- --- * ["PprMach"] 'pprInstr' turns an 'Instr' into text (well, really +-- * "Ppr": 'pprInstr' turns an 'Instr' into text (well, really -- a 'SDoc'). -- --- * ["RegAllocInfo"] In the register allocator, we manipulate --- 'MRegsState's, which are 'BitSet's, one bit per machine register. --- When we want to say something about a specific machine register --- (e.g., ``it gets clobbered by this instruction''), we set/unset --- its bit. Obviously, we do this 'BitSet' thing for efficiency --- reasons. +-- The register allocators lives under GHC.CmmToAsm.Reg.*, there is both a Linear and a Graph +-- based register allocator. Both of which have their own notes describing them. They +-- are mostly platform independent but there are some platform specific files +-- encoding architecture details under Reg// -- --- The 'RegAllocInfo' module collects together the machine-specific --- info needed to do register allocation. --- --- * ["RegisterAlloc"] The (machine-independent) register allocator. -- -} -- module GHC.CmmToAsm ===================================== compiler/ghc.cabal.in ===================================== @@ -34,6 +34,14 @@ extra-source-files: ClosureTypes.h FunTypes.h MachRegs.h + MachRegs/arm32.h + MachRegs/arm64.h + MachRegs/loongarch64.h + MachRegs/ppc.h + MachRegs/riscv64.h + MachRegs/s390x.h + MachRegs/wasm32.h + MachRegs/x86.h ghc-llvm-version.h ===================================== configure.ac ===================================== @@ -578,6 +578,15 @@ ln -f rts/include/rts/Bytecodes.h compiler/ ln -f rts/include/rts/storage/ClosureTypes.h compiler/ ln -f rts/include/rts/storage/FunTypes.h compiler/ ln -f rts/include/stg/MachRegs.h compiler/ +mkdir -p compiler/MachRegs +ln -f rts/include/stg/MachRegs/arm32.h compiler/MachRegs/arm32.h +ln -f rts/include/stg/MachRegs/arm64.h compiler/MachRegs/arm64.h +ln -f rts/include/stg/MachRegs/loongarch64.h compiler/MachRegs/loongarch64.h +ln -f rts/include/stg/MachRegs/ppc.h compiler/MachRegs/ppc.h +ln -f rts/include/stg/MachRegs/riscv64.h compiler/MachRegs/riscv64.h +ln -f rts/include/stg/MachRegs/s390x.h compiler/MachRegs/s390x.h +ln -f rts/include/stg/MachRegs/wasm32.h compiler/MachRegs/wasm32.h +ln -f rts/include/stg/MachRegs/x86.h compiler/MachRegs/x86.h AC_MSG_NOTICE([done.]) dnl ** Copy the files from the "fs" utility into the right folders. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. ===================================== rts/include/stg/MachRegs.h ===================================== @@ -51,637 +51,54 @@ #elif MACHREGS_NO_REGS == 0 /* ---------------------------------------------------------------------------- - Caller saves and callee-saves regs. - + Note [Caller saves and callee-saves regs.] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Caller-saves regs have to be saved around C-calls made from STG land, so this file defines CALLER_SAVES_ for each that is designated caller-saves in that machine's C calling convention. + NB: Caller-saved registers not mapped to a STG register don't + require a CALLER_SAVES_ define. As it stands, the only registers that are ever marked caller saves - are the RX, FX, DX and USER registers; as a result, if you + are the RX, FX, DX, XMM and USER registers; as a result, if you decide to caller save a system register (e.g. SP, HP, etc), note that this code path is completely untested! -- EZY See Note [Register parameter passing] for details. -------------------------------------------------------------------------- */ -/* ----------------------------------------------------------------------------- - The x86 register mapping - - Ok, we've only got 6 general purpose registers, a frame pointer and a - stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, - hence they get trashed across ccalls and are caller saves. \tr{%ebx}, - \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. - - Reg STG-Reg - --------------- - ebx Base - ebp Sp - esi R1 - edi Hp - - Leaving SpLim out of the picture. - -------------------------------------------------------------------------- */ - -#if defined(MACHREGS_i386) - -#define REG(x) __asm__("%" #x) - -#if !defined(not_doing_dynamic_linking) -#define REG_Base ebx -#endif -#define REG_Sp ebp - -#if !defined(STOLEN_X86_REGS) -#define STOLEN_X86_REGS 4 -#endif - -#if STOLEN_X86_REGS >= 3 -# define REG_R1 esi -#endif - -#if STOLEN_X86_REGS >= 4 -# define REG_Hp edi -#endif -#define REG_MachSp esp - -#define REG_XMM1 xmm0 -#define REG_XMM2 xmm1 -#define REG_XMM3 xmm2 -#define REG_XMM4 xmm3 - -#define REG_YMM1 ymm0 -#define REG_YMM2 ymm1 -#define REG_YMM3 ymm2 -#define REG_YMM4 ymm3 - -#define REG_ZMM1 zmm0 -#define REG_ZMM2 zmm1 -#define REG_ZMM3 zmm2 -#define REG_ZMM4 zmm3 - -#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ -#define MAX_REAL_FLOAT_REG 0 -#define MAX_REAL_DOUBLE_REG 0 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 4 -#define MAX_REAL_YMM_REG 4 -#define MAX_REAL_ZMM_REG 4 - -/* ----------------------------------------------------------------------------- - The x86-64 register mapping - - %rax caller-saves, don't steal this one - %rbx YES - %rcx arg reg, caller-saves - %rdx arg reg, caller-saves - %rsi arg reg, caller-saves - %rdi arg reg, caller-saves - %rbp YES (our *prime* register) - %rsp (unavailable - stack pointer) - %r8 arg reg, caller-saves - %r9 arg reg, caller-saves - %r10 caller-saves - %r11 caller-saves - %r12 YES - %r13 YES - %r14 YES - %r15 YES - - %xmm0-7 arg regs, caller-saves - %xmm8-15 caller-saves - - Use the caller-saves regs for Rn, because we don't always have to - save those (as opposed to Sp/Hp/SpLim etc. which always have to be - saved). - - --------------------------------------------------------------------------- */ - -#elif defined(MACHREGS_x86_64) - -#define REG(x) __asm__("%" #x) - -#define REG_Base r13 -#define REG_Sp rbp -#define REG_Hp r12 -#define REG_R1 rbx -#define REG_R2 r14 -#define REG_R3 rsi -#define REG_R4 rdi -#define REG_R5 r8 -#define REG_R6 r9 -#define REG_SpLim r15 -#define REG_MachSp rsp - -/* -Map both Fn and Dn to register xmmn so that we can pass a function any -combination of up to six Float# or Double# arguments without touching -the stack. See Note [Overlapping global registers] for implications. -*/ - -#define REG_F1 xmm1 -#define REG_F2 xmm2 -#define REG_F3 xmm3 -#define REG_F4 xmm4 -#define REG_F5 xmm5 -#define REG_F6 xmm6 - -#define REG_D1 xmm1 -#define REG_D2 xmm2 -#define REG_D3 xmm3 -#define REG_D4 xmm4 -#define REG_D5 xmm5 -#define REG_D6 xmm6 - -#define REG_XMM1 xmm1 -#define REG_XMM2 xmm2 -#define REG_XMM3 xmm3 -#define REG_XMM4 xmm4 -#define REG_XMM5 xmm5 -#define REG_XMM6 xmm6 - -#define REG_YMM1 ymm1 -#define REG_YMM2 ymm2 -#define REG_YMM3 ymm3 -#define REG_YMM4 ymm4 -#define REG_YMM5 ymm5 -#define REG_YMM6 ymm6 - -#define REG_ZMM1 zmm1 -#define REG_ZMM2 zmm2 -#define REG_ZMM3 zmm3 -#define REG_ZMM4 zmm4 -#define REG_ZMM5 zmm5 -#define REG_ZMM6 zmm6 - -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_R3 -#define CALLER_SAVES_R4 -#endif -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 - -#define CALLER_SAVES_F1 -#define CALLER_SAVES_F2 -#define CALLER_SAVES_F3 -#define CALLER_SAVES_F4 -#define CALLER_SAVES_F5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_F6 -#endif - -#define CALLER_SAVES_D1 -#define CALLER_SAVES_D2 -#define CALLER_SAVES_D3 -#define CALLER_SAVES_D4 -#define CALLER_SAVES_D5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_D6 -#endif - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 -#define CALLER_SAVES_XMM3 -#define CALLER_SAVES_XMM4 -#define CALLER_SAVES_XMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_XMM6 -#endif - -#define CALLER_SAVES_YMM1 -#define CALLER_SAVES_YMM2 -#define CALLER_SAVES_YMM3 -#define CALLER_SAVES_YMM4 -#define CALLER_SAVES_YMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_YMM6 -#endif - -#define CALLER_SAVES_ZMM1 -#define CALLER_SAVES_ZMM2 -#define CALLER_SAVES_ZMM3 -#define CALLER_SAVES_ZMM4 -#define CALLER_SAVES_ZMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_ZMM6 -#endif - -#define MAX_REAL_VANILLA_REG 6 -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 6 -#define MAX_REAL_YMM_REG 6 -#define MAX_REAL_ZMM_REG 6 - -/* ----------------------------------------------------------------------------- - The PowerPC register mapping - - 0 system glue? (caller-save, volatile) - 1 SP (callee-save, non-volatile) - 2 AIX, powerpc64-linux: - RTOC (a strange special case) - powerpc32-linux: - reserved for use by system +/* Define STG <-> machine register mappings. */ +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) - 3-10 args/return (caller-save, volatile) - 11,12 system glue? (caller-save, volatile) - 13 on 64-bit: reserved for thread state pointer - on 32-bit: (callee-save, non-volatile) - 14-31 (callee-save, non-volatile) - - f0 (caller-save, volatile) - f1-f13 args/return (caller-save, volatile) - f14-f31 (callee-save, non-volatile) - - \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. - \tr{0}--\tr{12} are caller-save registers. - - \tr{%f14}--\tr{%f31} are callee-save floating-point registers. - - We can do the Whole Business with callee-save registers only! - -------------------------------------------------------------------------- */ +#include "MachRegs/x86.h" #elif defined(MACHREGS_powerpc) -#define REG(x) __asm__(#x) - -#define REG_R1 r14 -#define REG_R2 r15 -#define REG_R3 r16 -#define REG_R4 r17 -#define REG_R5 r18 -#define REG_R6 r19 -#define REG_R7 r20 -#define REG_R8 r21 -#define REG_R9 r22 -#define REG_R10 r23 - -#define REG_F1 fr14 -#define REG_F2 fr15 -#define REG_F3 fr16 -#define REG_F4 fr17 -#define REG_F5 fr18 -#define REG_F6 fr19 - -#define REG_D1 fr20 -#define REG_D2 fr21 -#define REG_D3 fr22 -#define REG_D4 fr23 -#define REG_D5 fr24 -#define REG_D6 fr25 - -#define REG_Sp r24 -#define REG_SpLim r25 -#define REG_Hp r26 -#define REG_Base r27 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 - -/* ----------------------------------------------------------------------------- - The ARM EABI register mapping - - Here we consider ARM mode (i.e. 32bit isns) - and also CPU with full VFPv3 implementation - - ARM registers (see Chapter 5.1 in ARM IHI 0042D and - Section 9.2.2 in ARM Software Development Toolkit Reference Guide) - - r15 PC The Program Counter. - r14 LR The Link Register. - r13 SP The Stack Pointer. - r12 IP The Intra-Procedure-call scratch register. - r11 v8/fp Variable-register 8. - r10 v7/sl Variable-register 7. - r9 v6/SB/TR Platform register. The meaning of this register is - defined by the platform standard. - r8 v5 Variable-register 5. - r7 v4 Variable register 4. - r6 v3 Variable register 3. - r5 v2 Variable register 2. - r4 v1 Variable register 1. - r3 a4 Argument / scratch register 4. - r2 a3 Argument / scratch register 3. - r1 a2 Argument / result / scratch register 2. - r0 a1 Argument / result / scratch register 1. - - VFPv2/VFPv3/NEON registers - s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers - s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across - subroutine calls) - - VFPv3/NEON registers (added to the VFPv2 registers set) - d16-d31/q8-q15 Argument / result/ scratch registers - ----------------------------------------------------------------------------- */ +#include "MachRegs/ppc.h" #elif defined(MACHREGS_arm) -#define REG(x) __asm__(#x) - -#define REG_Base r4 -#define REG_Sp r5 -#define REG_Hp r6 -#define REG_R1 r7 -#define REG_R2 r8 -#define REG_R3 r9 -#define REG_R4 r10 -#define REG_SpLim r11 - -#if !defined(arm_HOST_ARCH_PRE_ARMv6) -/* d8 */ -#define REG_F1 s16 -#define REG_F2 s17 -/* d9 */ -#define REG_F3 s18 -#define REG_F4 s19 - -#define REG_D1 d10 -#define REG_D2 d11 -#endif - -/* ----------------------------------------------------------------------------- - The ARMv8/AArch64 ABI register mapping - - The AArch64 provides 31 64-bit general purpose registers - and 32 128-bit SIMD/floating point registers. - - General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) - - Register | Special | Role in the procedure call standard - ---------+---------+------------------------------------ - SP | | The Stack Pointer - r30 | LR | The Link Register - r29 | FP | The Frame Pointer - r19-r28 | | Callee-saved registers - r18 | | The Platform Register, if needed; - | | or temporary register - r17 | IP1 | The second intra-procedure-call temporary register - r16 | IP0 | The first intra-procedure-call scratch register - r9-r15 | | Temporary registers - r8 | | Indirect result location register - r0-r7 | | Parameter/result registers - - - FPU/SIMD registers - - s/d/q/v0-v7 Argument / result/ scratch registers - s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, - but only bottom 64-bit value needs to be preserved) - s/d/q/v16-v31 temporary registers - - ----------------------------------------------------------------------------- */ +#include "MachRegs/arm32.h" #elif defined(MACHREGS_aarch64) -#define REG(x) __asm__(#x) - -#define REG_Base r19 -#define REG_Sp r20 -#define REG_Hp r21 -#define REG_R1 r22 -#define REG_R2 r23 -#define REG_R3 r24 -#define REG_R4 r25 -#define REG_R5 r26 -#define REG_R6 r27 -#define REG_SpLim r28 - -#define REG_F1 s8 -#define REG_F2 s9 -#define REG_F3 s10 -#define REG_F4 s11 - -#define REG_D1 d12 -#define REG_D2 d13 -#define REG_D3 d14 -#define REG_D4 d15 - -#define REG_XMM1 q4 -#define REG_XMM2 q5 - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 - -/* ----------------------------------------------------------------------------- - The s390x register mapping - - Register | Role(s) | Call effect - ------------+-------------------------------------+----------------- - r0,r1 | - | caller-saved - r2 | Argument / return value | caller-saved - r3,r4,r5 | Arguments | caller-saved - r6 | Argument | callee-saved - r7...r11 | - | callee-saved - r12 | (Commonly used as GOT pointer) | callee-saved - r13 | (Commonly used as literal pool pointer) | callee-saved - r14 | Return address | caller-saved - r15 | Stack pointer | callee-saved - f0 | Argument / return value | caller-saved - f2,f4,f6 | Arguments | caller-saved - f1,f3,f5,f7 | - | caller-saved - f8...f15 | - | callee-saved - v0...v31 | - | caller-saved - - Each general purpose register r0 through r15 as well as each floating-point - register f0 through f15 is 64 bits wide. Each vector register v0 through v31 - is 128 bits wide. - - Note, the vector registers v0 through v15 overlap with the floating-point - registers f0 through f15. - - -------------------------------------------------------------------------- */ +#include "MachRegs/arm64.h" #elif defined(MACHREGS_s390x) -#define REG(x) __asm__("%" #x) - -#define REG_Base r7 -#define REG_Sp r8 -#define REG_Hp r10 -#define REG_R1 r11 -#define REG_R2 r12 -#define REG_R3 r13 -#define REG_R4 r6 -#define REG_R5 r2 -#define REG_R6 r3 -#define REG_R7 r4 -#define REG_R8 r5 -#define REG_SpLim r9 -#define REG_MachSp r15 - -#define REG_F1 f8 -#define REG_F2 f9 -#define REG_F3 f10 -#define REG_F4 f11 -#define REG_F5 f0 -#define REG_F6 f1 - -#define REG_D1 f12 -#define REG_D2 f13 -#define REG_D3 f14 -#define REG_D4 f15 -#define REG_D5 f2 -#define REG_D6 f3 - -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 -#define CALLER_SAVES_R7 -#define CALLER_SAVES_R8 - -#define CALLER_SAVES_F5 -#define CALLER_SAVES_F6 - -#define CALLER_SAVES_D5 -#define CALLER_SAVES_D6 - -/* ----------------------------------------------------------------------------- - The riscv64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - sp | Stack pointer | callee-saved - gp | Global pointer | callee-saved - tp | Thread pointer | callee-saved - t0,t1,t2 | - | caller-saved - s0 | Frame pointer | callee-saved - s1 | - | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - s2..s11 | - | callee-saved - t3..t6 | - | caller-saved - ft0..ft7 | - | caller-saved - fs0,fs1 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - fs2..fs11 | - | callee-saved - ft8..ft11 | - | caller-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide. - - -------------------------------------------------------------------------- */ +#include "MachRegs/s390x.h" #elif defined(MACHREGS_riscv64) -#define REG(x) __asm__(#x) - -#define REG_Base s1 -#define REG_Sp s2 -#define REG_Hp s3 -#define REG_R1 s4 -#define REG_R2 s5 -#define REG_R3 s6 -#define REG_R4 s7 -#define REG_R5 s8 -#define REG_R6 s9 -#define REG_R7 s10 -#define REG_SpLim s11 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 -#define REG_F5 fs4 -#define REG_F6 fs5 - -#define REG_D1 fs6 -#define REG_D2 fs7 -#define REG_D3 fs8 -#define REG_D4 fs9 -#define REG_D5 fs10 -#define REG_D6 fs11 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 +#include "MachRegs/riscv64.h" #elif defined(MACHREGS_wasm32) -#define REG_R1 1 -#define REG_R2 2 -#define REG_R3 3 -#define REG_R4 4 -#define REG_R5 5 -#define REG_R6 6 -#define REG_R7 7 -#define REG_R8 8 -#define REG_R9 9 -#define REG_R10 10 - -#define REG_F1 11 -#define REG_F2 12 -#define REG_F3 13 -#define REG_F4 14 -#define REG_F5 15 -#define REG_F6 16 - -#define REG_D1 17 -#define REG_D2 18 -#define REG_D3 19 -#define REG_D4 20 -#define REG_D5 21 -#define REG_D6 22 - -#define REG_L1 23 - -#define REG_Sp 24 -#define REG_SpLim 25 -#define REG_Hp 26 -#define REG_HpLim 27 -#define REG_CCCS 28 - -/* ----------------------------------------------------------------------------- - The loongarch64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - tp | Thread pointer | - - sp | Stack pointer | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - t0..t8 | - | caller-saved - u0 | Reserve | - - fp | Frame pointer | callee-saved - s0..s8 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - ft0..ft15 | - | caller-saved - fs0..fs7 | - | callee-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide, also, the u0 register is called r21 in some cases. +#include "MachRegs/wasm32.h" - -------------------------------------------------------------------------- */ #elif defined(MACHREGS_loongarch64) -#define REG(x) __asm__("$" #x) - -#define REG_Base s0 -#define REG_Sp s1 -#define REG_Hp s2 -#define REG_R1 s3 -#define REG_R2 s4 -#define REG_R3 s5 -#define REG_R4 s6 -#define REG_R5 s7 -#define REG_SpLim s8 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 - -#define REG_D1 fs4 -#define REG_D2 fs5 -#define REG_D3 fs6 -#define REG_D4 fs7 - -#define MAX_REAL_FLOAT_REG 4 -#define MAX_REAL_DOUBLE_REG 4 +#include "MachRegs/loongarch64.h" #else ===================================== rts/include/stg/MachRegs/arm32.h ===================================== @@ -0,0 +1,60 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The ARM EABI register mapping + + Here we consider ARM mode (i.e. 32bit isns) + and also CPU with full VFPv3 implementation + + ARM registers (see Chapter 5.1 in ARM IHI 0042D and + Section 9.2.2 in ARM Software Development Toolkit Reference Guide) + + r15 PC The Program Counter. + r14 LR The Link Register. + r13 SP The Stack Pointer. + r12 IP The Intra-Procedure-call scratch register. + r11 v8/fp Variable-register 8. + r10 v7/sl Variable-register 7. + r9 v6/SB/TR Platform register. The meaning of this register is + defined by the platform standard. + r8 v5 Variable-register 5. + r7 v4 Variable register 4. + r6 v3 Variable register 3. + r5 v2 Variable register 2. + r4 v1 Variable register 1. + r3 a4 Argument / scratch register 4. + r2 a3 Argument / scratch register 3. + r1 a2 Argument / result / scratch register 2. + r0 a1 Argument / result / scratch register 1. + + VFPv2/VFPv3/NEON registers + s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers + s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across + subroutine calls) + + VFPv3/NEON registers (added to the VFPv2 registers set) + d16-d31/q8-q15 Argument / result/ scratch registers + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r4 +#define REG_Sp r5 +#define REG_Hp r6 +#define REG_R1 r7 +#define REG_R2 r8 +#define REG_R3 r9 +#define REG_R4 r10 +#define REG_SpLim r11 + +#if !defined(arm_HOST_ARCH_PRE_ARMv6) +/* d8 */ +#define REG_F1 s16 +#define REG_F2 s17 +/* d9 */ +#define REG_F3 s18 +#define REG_F4 s19 + +#define REG_D1 d10 +#define REG_D2 d11 +#endif \ No newline at end of file ===================================== rts/include/stg/MachRegs/arm64.h ===================================== @@ -0,0 +1,64 @@ +#pragma once + + +/* ----------------------------------------------------------------------------- + The ARMv8/AArch64 ABI register mapping + + The AArch64 provides 31 64-bit general purpose registers + and 32 128-bit SIMD/floating point registers. + + General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) + + Register | Special | Role in the procedure call standard + ---------+---------+------------------------------------ + SP | | The Stack Pointer + r30 | LR | The Link Register + r29 | FP | The Frame Pointer + r19-r28 | | Callee-saved registers + r18 | | The Platform Register, if needed; + | | or temporary register + r17 | IP1 | The second intra-procedure-call temporary register + r16 | IP0 | The first intra-procedure-call scratch register + r9-r15 | | Temporary registers + r8 | | Indirect result location register + r0-r7 | | Parameter/result registers + + + FPU/SIMD registers + + s/d/q/v0-v7 Argument / result/ scratch registers + s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, + but only bottom 64-bit value needs to be preserved) + s/d/q/v16-v31 temporary registers + + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r19 +#define REG_Sp r20 +#define REG_Hp r21 +#define REG_R1 r22 +#define REG_R2 r23 +#define REG_R3 r24 +#define REG_R4 r25 +#define REG_R5 r26 +#define REG_R6 r27 +#define REG_SpLim r28 + +#define REG_F1 s8 +#define REG_F2 s9 +#define REG_F3 s10 +#define REG_F4 s11 + +#define REG_D1 d12 +#define REG_D2 d13 +#define REG_D3 d14 +#define REG_D4 d15 + +#define REG_XMM1 q4 +#define REG_XMM2 q5 + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 + ===================================== rts/include/stg/MachRegs/loongarch64.h ===================================== @@ -0,0 +1,51 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The loongarch64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + tp | Thread pointer | - + sp | Stack pointer | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + t0..t8 | - | caller-saved + u0 | Reserve | - + fp | Frame pointer | callee-saved + s0..s8 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + ft0..ft15 | - | caller-saved + fs0..fs7 | - | callee-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide, also, the u0 register is called r21 in some cases. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__("$" #x) + +#define REG_Base s0 +#define REG_Sp s1 +#define REG_Hp s2 +#define REG_R1 s3 +#define REG_R2 s4 +#define REG_R3 s5 +#define REG_R4 s6 +#define REG_R5 s7 +#define REG_SpLim s8 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 + +#define REG_D1 fs4 +#define REG_D2 fs5 +#define REG_D3 fs6 +#define REG_D4 fs7 + +#define MAX_REAL_FLOAT_REG 4 +#define MAX_REAL_DOUBLE_REG 4 ===================================== rts/include/stg/MachRegs/ppc.h ===================================== @@ -0,0 +1,65 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The PowerPC register mapping + + 0 system glue? (caller-save, volatile) + 1 SP (callee-save, non-volatile) + 2 AIX, powerpc64-linux: + RTOC (a strange special case) + powerpc32-linux: + reserved for use by system + + 3-10 args/return (caller-save, volatile) + 11,12 system glue? (caller-save, volatile) + 13 on 64-bit: reserved for thread state pointer + on 32-bit: (callee-save, non-volatile) + 14-31 (callee-save, non-volatile) + + f0 (caller-save, volatile) + f1-f13 args/return (caller-save, volatile) + f14-f31 (callee-save, non-volatile) + + \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. + \tr{0}--\tr{12} are caller-save registers. + + \tr{%f14}--\tr{%f31} are callee-save floating-point registers. + + We can do the Whole Business with callee-save registers only! + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__(#x) + +#define REG_R1 r14 +#define REG_R2 r15 +#define REG_R3 r16 +#define REG_R4 r17 +#define REG_R5 r18 +#define REG_R6 r19 +#define REG_R7 r20 +#define REG_R8 r21 +#define REG_R9 r22 +#define REG_R10 r23 + +#define REG_F1 fr14 +#define REG_F2 fr15 +#define REG_F3 fr16 +#define REG_F4 fr17 +#define REG_F5 fr18 +#define REG_F6 fr19 + +#define REG_D1 fr20 +#define REG_D2 fr21 +#define REG_D3 fr22 +#define REG_D4 fr23 +#define REG_D5 fr24 +#define REG_D6 fr25 + +#define REG_Sp r24 +#define REG_SpLim r25 +#define REG_Hp r26 +#define REG_Base r27 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/riscv64.h ===================================== @@ -0,0 +1,61 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The riscv64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + sp | Stack pointer | callee-saved + gp | Global pointer | callee-saved + tp | Thread pointer | callee-saved + t0,t1,t2 | - | caller-saved + s0 | Frame pointer | callee-saved + s1 | - | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + s2..s11 | - | callee-saved + t3..t6 | - | caller-saved + ft0..ft7 | - | caller-saved + fs0,fs1 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + fs2..fs11 | - | callee-saved + ft8..ft11 | - | caller-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base s1 +#define REG_Sp s2 +#define REG_Hp s3 +#define REG_R1 s4 +#define REG_R2 s5 +#define REG_R3 s6 +#define REG_R4 s7 +#define REG_R5 s8 +#define REG_R6 s9 +#define REG_R7 s10 +#define REG_SpLim s11 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 +#define REG_F5 fs4 +#define REG_F6 fs5 + +#define REG_D1 fs6 +#define REG_D2 fs7 +#define REG_D3 fs8 +#define REG_D4 fs9 +#define REG_D5 fs10 +#define REG_D6 fs11 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/s390x.h ===================================== @@ -0,0 +1,72 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The s390x register mapping + + Register | Role(s) | Call effect + ------------+-------------------------------------+----------------- + r0,r1 | - | caller-saved + r2 | Argument / return value | caller-saved + r3,r4,r5 | Arguments | caller-saved + r6 | Argument | callee-saved + r7...r11 | - | callee-saved + r12 | (Commonly used as GOT pointer) | callee-saved + r13 | (Commonly used as literal pool pointer) | callee-saved + r14 | Return address | caller-saved + r15 | Stack pointer | callee-saved + f0 | Argument / return value | caller-saved + f2,f4,f6 | Arguments | caller-saved + f1,f3,f5,f7 | - | caller-saved + f8...f15 | - | callee-saved + v0...v31 | - | caller-saved + + Each general purpose register r0 through r15 as well as each floating-point + register f0 through f15 is 64 bits wide. Each vector register v0 through v31 + is 128 bits wide. + + Note, the vector registers v0 through v15 overlap with the floating-point + registers f0 through f15. + + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__("%" #x) + +#define REG_Base r7 +#define REG_Sp r8 +#define REG_Hp r10 +#define REG_R1 r11 +#define REG_R2 r12 +#define REG_R3 r13 +#define REG_R4 r6 +#define REG_R5 r2 +#define REG_R6 r3 +#define REG_R7 r4 +#define REG_R8 r5 +#define REG_SpLim r9 +#define REG_MachSp r15 + +#define REG_F1 f8 +#define REG_F2 f9 +#define REG_F3 f10 +#define REG_F4 f11 +#define REG_F5 f0 +#define REG_F6 f1 + +#define REG_D1 f12 +#define REG_D2 f13 +#define REG_D3 f14 +#define REG_D4 f15 +#define REG_D5 f2 +#define REG_D6 f3 + +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 +#define CALLER_SAVES_R7 +#define CALLER_SAVES_R8 + +#define CALLER_SAVES_F5 +#define CALLER_SAVES_F6 + +#define CALLER_SAVES_D5 +#define CALLER_SAVES_D6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/wasm32.h ===================================== ===================================== rts/include/stg/MachRegs/x86.h ===================================== @@ -0,0 +1,210 @@ +/* ----------------------------------------------------------------------------- + The x86 register mapping + + Ok, we've only got 6 general purpose registers, a frame pointer and a + stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, + hence they get trashed across ccalls and are caller saves. \tr{%ebx}, + \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. + + Reg STG-Reg + --------------- + ebx Base + ebp Sp + esi R1 + edi Hp + + Leaving SpLim out of the picture. + -------------------------------------------------------------------------- */ + +#if defined(MACHREGS_i386) + +#define REG(x) __asm__("%" #x) + +#if !defined(not_doing_dynamic_linking) +#define REG_Base ebx +#endif +#define REG_Sp ebp + +#if !defined(STOLEN_X86_REGS) +#define STOLEN_X86_REGS 4 +#endif + +#if STOLEN_X86_REGS >= 3 +# define REG_R1 esi +#endif + +#if STOLEN_X86_REGS >= 4 +# define REG_Hp edi +#endif +#define REG_MachSp esp + +#define REG_XMM1 xmm0 +#define REG_XMM2 xmm1 +#define REG_XMM3 xmm2 +#define REG_XMM4 xmm3 + +#define REG_YMM1 ymm0 +#define REG_YMM2 ymm1 +#define REG_YMM3 ymm2 +#define REG_YMM4 ymm3 + +#define REG_ZMM1 zmm0 +#define REG_ZMM2 zmm1 +#define REG_ZMM3 zmm2 +#define REG_ZMM4 zmm3 + +#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ +#define MAX_REAL_FLOAT_REG 0 +#define MAX_REAL_DOUBLE_REG 0 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 4 +#define MAX_REAL_YMM_REG 4 +#define MAX_REAL_ZMM_REG 4 + +/* ----------------------------------------------------------------------------- + The x86-64 register mapping + + %rax caller-saves, don't steal this one + %rbx YES + %rcx arg reg, caller-saves + %rdx arg reg, caller-saves + %rsi arg reg, caller-saves + %rdi arg reg, caller-saves + %rbp YES (our *prime* register) + %rsp (unavailable - stack pointer) + %r8 arg reg, caller-saves + %r9 arg reg, caller-saves + %r10 caller-saves + %r11 caller-saves + %r12 YES + %r13 YES + %r14 YES + %r15 YES + + %xmm0-7 arg regs, caller-saves + %xmm8-15 caller-saves + + Use the caller-saves regs for Rn, because we don't always have to + save those (as opposed to Sp/Hp/SpLim etc. which always have to be + saved). + + --------------------------------------------------------------------------- */ + +#elif defined(MACHREGS_x86_64) + +#define REG(x) __asm__("%" #x) + +#define REG_Base r13 +#define REG_Sp rbp +#define REG_Hp r12 +#define REG_R1 rbx +#define REG_R2 r14 +#define REG_R3 rsi +#define REG_R4 rdi +#define REG_R5 r8 +#define REG_R6 r9 +#define REG_SpLim r15 +#define REG_MachSp rsp + +/* +Map both Fn and Dn to register xmmn so that we can pass a function any +combination of up to six Float# or Double# arguments without touching +the stack. See Note [Overlapping global registers] for implications. +*/ + +#define REG_F1 xmm1 +#define REG_F2 xmm2 +#define REG_F3 xmm3 +#define REG_F4 xmm4 +#define REG_F5 xmm5 +#define REG_F6 xmm6 + +#define REG_D1 xmm1 +#define REG_D2 xmm2 +#define REG_D3 xmm3 +#define REG_D4 xmm4 +#define REG_D5 xmm5 +#define REG_D6 xmm6 + +#define REG_XMM1 xmm1 +#define REG_XMM2 xmm2 +#define REG_XMM3 xmm3 +#define REG_XMM4 xmm4 +#define REG_XMM5 xmm5 +#define REG_XMM6 xmm6 + +#define REG_YMM1 ymm1 +#define REG_YMM2 ymm2 +#define REG_YMM3 ymm3 +#define REG_YMM4 ymm4 +#define REG_YMM5 ymm5 +#define REG_YMM6 ymm6 + +#define REG_ZMM1 zmm1 +#define REG_ZMM2 zmm2 +#define REG_ZMM3 zmm3 +#define REG_ZMM4 zmm4 +#define REG_ZMM5 zmm5 +#define REG_ZMM6 zmm6 + +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_R3 +#define CALLER_SAVES_R4 +#endif +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 + +#define CALLER_SAVES_F1 +#define CALLER_SAVES_F2 +#define CALLER_SAVES_F3 +#define CALLER_SAVES_F4 +#define CALLER_SAVES_F5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_F6 +#endif + +#define CALLER_SAVES_D1 +#define CALLER_SAVES_D2 +#define CALLER_SAVES_D3 +#define CALLER_SAVES_D4 +#define CALLER_SAVES_D5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_D6 +#endif + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 +#define CALLER_SAVES_XMM3 +#define CALLER_SAVES_XMM4 +#define CALLER_SAVES_XMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_XMM6 +#endif + +#define CALLER_SAVES_YMM1 +#define CALLER_SAVES_YMM2 +#define CALLER_SAVES_YMM3 +#define CALLER_SAVES_YMM4 +#define CALLER_SAVES_YMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_YMM6 +#endif + +#define CALLER_SAVES_ZMM1 +#define CALLER_SAVES_ZMM2 +#define CALLER_SAVES_ZMM3 +#define CALLER_SAVES_ZMM4 +#define CALLER_SAVES_ZMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_ZMM6 +#endif + +#define MAX_REAL_VANILLA_REG 6 +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 6 +#define MAX_REAL_YMM_REG 6 +#define MAX_REAL_ZMM_REG 6 + +#endif /* MACHREGS_i386 || MACHREGS_x86_64 */ \ No newline at end of file ===================================== rts/rts.cabal.in ===================================== @@ -126,6 +126,14 @@ library ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h DerivedConstants.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/Types.h @@ -296,6 +304,14 @@ library rts/storage/TSO.h stg/DLL.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/MiscClosures.h stg/Prim.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e033e404517dd5d77be4c2956c30c620a30596bb...f828f48ffc74d9eaaac6db61a7a8675cd57185a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e033e404517dd5d77be4c2956c30c620a30596bb...f828f48ffc74d9eaaac6db61a7a8675cd57185a5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 7 14:00:53 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 07 Oct 2023 10:00:53 -0400 Subject: [Git][ghc/ghc][master] Ensure unconstrained instance dictionaries get IPE info Message-ID: <652164959aa72_18f52970f95310832153@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 4 changed files: - compiler/GHC/Stg/Debug.hs - + testsuite/tests/rts/ipe/T24005/all.T - + testsuite/tests/rts/ipe/T24005/t24005.hs - + testsuite/tests/rts/ipe/T24005/t24005.stdout Changes: ===================================== compiler/GHC/Stg/Debug.hs ===================================== @@ -68,21 +68,25 @@ collectStgBind (StgRec pairs) = do return (StgRec es) collectStgRhs :: Id -> StgRhs -> M StgRhs -collectStgRhs bndr (StgRhsClosure ext cc us bs e t) = do - let - name = idName bndr - -- If the name has a span, use that initially as the source position in-case - -- we don't get anything better. - with_span = case nameSrcSpan name of - RealSrcSpan pos _ -> withSpan (pos, LexicalFastString $ occNameFS (getOccName name)) - _ -> id - e' <- with_span $ collectExpr e - recordInfo bndr e' - return $ StgRhsClosure ext cc us bs e' t -collectStgRhs _bndr (StgRhsCon cc dc _mn ticks args typ) = do - n' <- numberDataCon dc ticks - return (StgRhsCon cc dc n' ticks args typ) - +collectStgRhs bndr rhs = + case rhs of + StgRhsClosure ext cc us bs e t -> do + e' <- with_span $ collectExpr e + recordInfo bndr e' + return $ StgRhsClosure ext cc us bs e' t + StgRhsCon cc dc _mn ticks args typ -> do + n' <- with_span $ numberDataCon dc ticks + return (StgRhsCon cc dc n' ticks args typ) + where + -- If the binder name has a span, use that initially as the source position + -- in case we don't get anything better + with_span :: M a -> M a + with_span = + let name = idName bndr in + case nameSrcSpan name of + RealSrcSpan pos _ -> + withSpan (pos, LexicalFastString $ occNameFS (getOccName name)) + _ -> id recordInfo :: Id -> StgExpr -> M () recordInfo bndr new_rhs = do ===================================== testsuite/tests/rts/ipe/T24005/all.T ===================================== @@ -0,0 +1 @@ +test('t24005', [ js_skip ], compile_and_run, ['-finfo-table-map -fdistinct-constructor-tables']) ===================================== testsuite/tests/rts/ipe/T24005/t24005.hs ===================================== @@ -0,0 +1,36 @@ +{-# LANGUAGE AllowAmbiguousTypes #-} + +module Main where + +import GHC.InfoProv +import Unsafe.Coerce + +-- Boilerplate to help us access the literal dictionaries + +data Dict c where + Dict :: forall c. c => Dict c + +data Box where + Box :: forall a. a -> Box + +mkBox :: forall a. a => Box +mkBox = unsafeCoerce (Dict @a) + +-- Interesting bit + +data A = A +data B a = B a + +-- Becomes a `StgRhsCon`, which used to not get IPE estimate based on Name +instance Show A where + show = undefined + +-- Becomes a `StgRhsClosure`, which does get IPE estimate based on Name +instance Show a => Show (B a) where + show = undefined + +main :: IO () +main = do + -- Should both result in InfoProvs with correct source locations + (\(Box d) -> print =<< whereFrom d) $ mkBox @(Show A) + (\(Box d) -> print =<< whereFrom d) $ mkBox @(Show (B A)) ===================================== testsuite/tests/rts/ipe/T24005/t24005.stdout ===================================== @@ -0,0 +1,2 @@ +Just (InfoProv {ipName = "C:Show_Main_1_con_info", ipDesc = "1", ipTyDesc = "Show", ipLabel = "$fShowA", ipMod = "Main", ipSrcFile = "t24005.hs", ipSrcSpan = "25:10-15"}) +Just (InfoProv {ipName = "C:Show_Main_0_con_info", ipDesc = "1", ipTyDesc = "Show", ipLabel = "$fShowB", ipMod = "Main", ipSrcFile = "t24005.hs", ipSrcSpan = "29:10-29"}) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69abb1714ade3059593297f3a5faec4c07d1f984 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69abb1714ade3059593297f3a5faec4c07d1f984 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 7 14:01:37 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 07 Oct 2023 10:01:37 -0400 Subject: [Git][ghc/ghc][master] rts: Split up rts/include/stg/MachRegs.h by arch Message-ID: <652164c17eef7_18f529711250a483549@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 15 changed files: - .gitignore - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/ghc.cabal.in - configure.ac - rts/include/stg/MachRegs.h - + rts/include/stg/MachRegs/arm32.h - + rts/include/stg/MachRegs/arm64.h - + rts/include/stg/MachRegs/loongarch64.h - + rts/include/stg/MachRegs/ppc.h - + rts/include/stg/MachRegs/riscv64.h - + rts/include/stg/MachRegs/s390x.h - + rts/include/stg/MachRegs/wasm32.h - + rts/include/stg/MachRegs/x86.h - rts/rts.cabal.in Changes: ===================================== .gitignore ===================================== @@ -111,6 +111,7 @@ _darcs/ /compiler/ClosureTypes.h /compiler/FunTypes.h /compiler/MachRegs.h +/compiler/MachRegs /compiler/ghc-llvm-version.h /compiler/ghc.cabal /compiler/ghc.cabal.old ===================================== compiler/CodeGen.Platform.h ===================================== @@ -480,6 +480,7 @@ import GHC.Platform.Reg #endif +-- See also Note [Caller saves and callee-saves regs.] callerSaves :: GlobalReg -> Bool #if defined(CALLER_SAVES_Base) callerSaves BaseReg = True ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -15,7 +15,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnboxedTuples #-} --- | Native code generator +-- | Note [Native code generator] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- The native-code generator has machine-independent and -- machine-dependent modules. @@ -23,45 +24,39 @@ -- This module ("GHC.CmmToAsm") is the top-level machine-independent -- module. Before entering machine-dependent land, we do some -- machine-independent optimisations (defined below) on the --- 'CmmStmts's. +-- 'CmmStmts's. (Which ideally would be folded into CmmOpt ...) -- -- We convert to the machine-specific 'Instr' datatype with -- 'cmmCodeGen', assuming an infinite supply of registers. We then use --- a machine-independent register allocator ('regAlloc') to rejoin +-- a (mostly) machine-independent register allocator to rejoin -- reality. Obviously, 'regAlloc' has machine-specific helper --- functions (see about "RegAllocInfo" below). +-- functions (see the used register allocator for details). -- -- Finally, we order the basic blocks of the function so as to minimise -- the number of jumps between blocks, by utilising fallthrough wherever -- possible. -- --- The machine-dependent bits break down as follows: +-- The machine-dependent bits are generally contained under +-- GHC/CmmToAsm//* and generally breaks down as follows: -- --- * ["MachRegs"] Everything about the target platform's machine +-- * "Regs": Everything about the target platform's machine -- registers (and immediate operands, and addresses, which tend to -- intermingle/interact with registers). -- --- * ["MachInstrs"] Includes the 'Instr' datatype (possibly should --- have a module of its own), plus a miscellany of other things +-- * "Instr": Includes the 'Instr' datatype plus a miscellany of other things -- (e.g., 'targetDoubleSize', 'smStablePtrTable', ...) -- --- * ["MachCodeGen"] is where 'Cmm' stuff turns into +-- * "CodeGen": is where 'Cmm' stuff turns into -- machine instructions. -- --- * ["PprMach"] 'pprInstr' turns an 'Instr' into text (well, really +-- * "Ppr": 'pprInstr' turns an 'Instr' into text (well, really -- a 'SDoc'). -- --- * ["RegAllocInfo"] In the register allocator, we manipulate --- 'MRegsState's, which are 'BitSet's, one bit per machine register. --- When we want to say something about a specific machine register --- (e.g., ``it gets clobbered by this instruction''), we set/unset --- its bit. Obviously, we do this 'BitSet' thing for efficiency --- reasons. +-- The register allocators lives under GHC.CmmToAsm.Reg.*, there is both a Linear and a Graph +-- based register allocator. Both of which have their own notes describing them. They +-- are mostly platform independent but there are some platform specific files +-- encoding architecture details under Reg// -- --- The 'RegAllocInfo' module collects together the machine-specific --- info needed to do register allocation. --- --- * ["RegisterAlloc"] The (machine-independent) register allocator. -- -} -- module GHC.CmmToAsm ===================================== compiler/ghc.cabal.in ===================================== @@ -34,6 +34,14 @@ extra-source-files: ClosureTypes.h FunTypes.h MachRegs.h + MachRegs/arm32.h + MachRegs/arm64.h + MachRegs/loongarch64.h + MachRegs/ppc.h + MachRegs/riscv64.h + MachRegs/s390x.h + MachRegs/wasm32.h + MachRegs/x86.h ghc-llvm-version.h ===================================== configure.ac ===================================== @@ -578,6 +578,15 @@ ln -f rts/include/rts/Bytecodes.h compiler/ ln -f rts/include/rts/storage/ClosureTypes.h compiler/ ln -f rts/include/rts/storage/FunTypes.h compiler/ ln -f rts/include/stg/MachRegs.h compiler/ +mkdir -p compiler/MachRegs +ln -f rts/include/stg/MachRegs/arm32.h compiler/MachRegs/arm32.h +ln -f rts/include/stg/MachRegs/arm64.h compiler/MachRegs/arm64.h +ln -f rts/include/stg/MachRegs/loongarch64.h compiler/MachRegs/loongarch64.h +ln -f rts/include/stg/MachRegs/ppc.h compiler/MachRegs/ppc.h +ln -f rts/include/stg/MachRegs/riscv64.h compiler/MachRegs/riscv64.h +ln -f rts/include/stg/MachRegs/s390x.h compiler/MachRegs/s390x.h +ln -f rts/include/stg/MachRegs/wasm32.h compiler/MachRegs/wasm32.h +ln -f rts/include/stg/MachRegs/x86.h compiler/MachRegs/x86.h AC_MSG_NOTICE([done.]) dnl ** Copy the files from the "fs" utility into the right folders. ===================================== rts/include/stg/MachRegs.h ===================================== @@ -51,637 +51,54 @@ #elif MACHREGS_NO_REGS == 0 /* ---------------------------------------------------------------------------- - Caller saves and callee-saves regs. - + Note [Caller saves and callee-saves regs.] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Caller-saves regs have to be saved around C-calls made from STG land, so this file defines CALLER_SAVES_ for each that is designated caller-saves in that machine's C calling convention. + NB: Caller-saved registers not mapped to a STG register don't + require a CALLER_SAVES_ define. As it stands, the only registers that are ever marked caller saves - are the RX, FX, DX and USER registers; as a result, if you + are the RX, FX, DX, XMM and USER registers; as a result, if you decide to caller save a system register (e.g. SP, HP, etc), note that this code path is completely untested! -- EZY See Note [Register parameter passing] for details. -------------------------------------------------------------------------- */ -/* ----------------------------------------------------------------------------- - The x86 register mapping - - Ok, we've only got 6 general purpose registers, a frame pointer and a - stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, - hence they get trashed across ccalls and are caller saves. \tr{%ebx}, - \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. - - Reg STG-Reg - --------------- - ebx Base - ebp Sp - esi R1 - edi Hp - - Leaving SpLim out of the picture. - -------------------------------------------------------------------------- */ - -#if defined(MACHREGS_i386) - -#define REG(x) __asm__("%" #x) - -#if !defined(not_doing_dynamic_linking) -#define REG_Base ebx -#endif -#define REG_Sp ebp - -#if !defined(STOLEN_X86_REGS) -#define STOLEN_X86_REGS 4 -#endif - -#if STOLEN_X86_REGS >= 3 -# define REG_R1 esi -#endif - -#if STOLEN_X86_REGS >= 4 -# define REG_Hp edi -#endif -#define REG_MachSp esp - -#define REG_XMM1 xmm0 -#define REG_XMM2 xmm1 -#define REG_XMM3 xmm2 -#define REG_XMM4 xmm3 - -#define REG_YMM1 ymm0 -#define REG_YMM2 ymm1 -#define REG_YMM3 ymm2 -#define REG_YMM4 ymm3 - -#define REG_ZMM1 zmm0 -#define REG_ZMM2 zmm1 -#define REG_ZMM3 zmm2 -#define REG_ZMM4 zmm3 - -#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ -#define MAX_REAL_FLOAT_REG 0 -#define MAX_REAL_DOUBLE_REG 0 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 4 -#define MAX_REAL_YMM_REG 4 -#define MAX_REAL_ZMM_REG 4 - -/* ----------------------------------------------------------------------------- - The x86-64 register mapping - - %rax caller-saves, don't steal this one - %rbx YES - %rcx arg reg, caller-saves - %rdx arg reg, caller-saves - %rsi arg reg, caller-saves - %rdi arg reg, caller-saves - %rbp YES (our *prime* register) - %rsp (unavailable - stack pointer) - %r8 arg reg, caller-saves - %r9 arg reg, caller-saves - %r10 caller-saves - %r11 caller-saves - %r12 YES - %r13 YES - %r14 YES - %r15 YES - - %xmm0-7 arg regs, caller-saves - %xmm8-15 caller-saves - - Use the caller-saves regs for Rn, because we don't always have to - save those (as opposed to Sp/Hp/SpLim etc. which always have to be - saved). - - --------------------------------------------------------------------------- */ - -#elif defined(MACHREGS_x86_64) - -#define REG(x) __asm__("%" #x) - -#define REG_Base r13 -#define REG_Sp rbp -#define REG_Hp r12 -#define REG_R1 rbx -#define REG_R2 r14 -#define REG_R3 rsi -#define REG_R4 rdi -#define REG_R5 r8 -#define REG_R6 r9 -#define REG_SpLim r15 -#define REG_MachSp rsp - -/* -Map both Fn and Dn to register xmmn so that we can pass a function any -combination of up to six Float# or Double# arguments without touching -the stack. See Note [Overlapping global registers] for implications. -*/ - -#define REG_F1 xmm1 -#define REG_F2 xmm2 -#define REG_F3 xmm3 -#define REG_F4 xmm4 -#define REG_F5 xmm5 -#define REG_F6 xmm6 - -#define REG_D1 xmm1 -#define REG_D2 xmm2 -#define REG_D3 xmm3 -#define REG_D4 xmm4 -#define REG_D5 xmm5 -#define REG_D6 xmm6 - -#define REG_XMM1 xmm1 -#define REG_XMM2 xmm2 -#define REG_XMM3 xmm3 -#define REG_XMM4 xmm4 -#define REG_XMM5 xmm5 -#define REG_XMM6 xmm6 - -#define REG_YMM1 ymm1 -#define REG_YMM2 ymm2 -#define REG_YMM3 ymm3 -#define REG_YMM4 ymm4 -#define REG_YMM5 ymm5 -#define REG_YMM6 ymm6 - -#define REG_ZMM1 zmm1 -#define REG_ZMM2 zmm2 -#define REG_ZMM3 zmm3 -#define REG_ZMM4 zmm4 -#define REG_ZMM5 zmm5 -#define REG_ZMM6 zmm6 - -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_R3 -#define CALLER_SAVES_R4 -#endif -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 - -#define CALLER_SAVES_F1 -#define CALLER_SAVES_F2 -#define CALLER_SAVES_F3 -#define CALLER_SAVES_F4 -#define CALLER_SAVES_F5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_F6 -#endif - -#define CALLER_SAVES_D1 -#define CALLER_SAVES_D2 -#define CALLER_SAVES_D3 -#define CALLER_SAVES_D4 -#define CALLER_SAVES_D5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_D6 -#endif - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 -#define CALLER_SAVES_XMM3 -#define CALLER_SAVES_XMM4 -#define CALLER_SAVES_XMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_XMM6 -#endif - -#define CALLER_SAVES_YMM1 -#define CALLER_SAVES_YMM2 -#define CALLER_SAVES_YMM3 -#define CALLER_SAVES_YMM4 -#define CALLER_SAVES_YMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_YMM6 -#endif - -#define CALLER_SAVES_ZMM1 -#define CALLER_SAVES_ZMM2 -#define CALLER_SAVES_ZMM3 -#define CALLER_SAVES_ZMM4 -#define CALLER_SAVES_ZMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_ZMM6 -#endif - -#define MAX_REAL_VANILLA_REG 6 -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 6 -#define MAX_REAL_YMM_REG 6 -#define MAX_REAL_ZMM_REG 6 - -/* ----------------------------------------------------------------------------- - The PowerPC register mapping - - 0 system glue? (caller-save, volatile) - 1 SP (callee-save, non-volatile) - 2 AIX, powerpc64-linux: - RTOC (a strange special case) - powerpc32-linux: - reserved for use by system +/* Define STG <-> machine register mappings. */ +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) - 3-10 args/return (caller-save, volatile) - 11,12 system glue? (caller-save, volatile) - 13 on 64-bit: reserved for thread state pointer - on 32-bit: (callee-save, non-volatile) - 14-31 (callee-save, non-volatile) - - f0 (caller-save, volatile) - f1-f13 args/return (caller-save, volatile) - f14-f31 (callee-save, non-volatile) - - \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. - \tr{0}--\tr{12} are caller-save registers. - - \tr{%f14}--\tr{%f31} are callee-save floating-point registers. - - We can do the Whole Business with callee-save registers only! - -------------------------------------------------------------------------- */ +#include "MachRegs/x86.h" #elif defined(MACHREGS_powerpc) -#define REG(x) __asm__(#x) - -#define REG_R1 r14 -#define REG_R2 r15 -#define REG_R3 r16 -#define REG_R4 r17 -#define REG_R5 r18 -#define REG_R6 r19 -#define REG_R7 r20 -#define REG_R8 r21 -#define REG_R9 r22 -#define REG_R10 r23 - -#define REG_F1 fr14 -#define REG_F2 fr15 -#define REG_F3 fr16 -#define REG_F4 fr17 -#define REG_F5 fr18 -#define REG_F6 fr19 - -#define REG_D1 fr20 -#define REG_D2 fr21 -#define REG_D3 fr22 -#define REG_D4 fr23 -#define REG_D5 fr24 -#define REG_D6 fr25 - -#define REG_Sp r24 -#define REG_SpLim r25 -#define REG_Hp r26 -#define REG_Base r27 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 - -/* ----------------------------------------------------------------------------- - The ARM EABI register mapping - - Here we consider ARM mode (i.e. 32bit isns) - and also CPU with full VFPv3 implementation - - ARM registers (see Chapter 5.1 in ARM IHI 0042D and - Section 9.2.2 in ARM Software Development Toolkit Reference Guide) - - r15 PC The Program Counter. - r14 LR The Link Register. - r13 SP The Stack Pointer. - r12 IP The Intra-Procedure-call scratch register. - r11 v8/fp Variable-register 8. - r10 v7/sl Variable-register 7. - r9 v6/SB/TR Platform register. The meaning of this register is - defined by the platform standard. - r8 v5 Variable-register 5. - r7 v4 Variable register 4. - r6 v3 Variable register 3. - r5 v2 Variable register 2. - r4 v1 Variable register 1. - r3 a4 Argument / scratch register 4. - r2 a3 Argument / scratch register 3. - r1 a2 Argument / result / scratch register 2. - r0 a1 Argument / result / scratch register 1. - - VFPv2/VFPv3/NEON registers - s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers - s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across - subroutine calls) - - VFPv3/NEON registers (added to the VFPv2 registers set) - d16-d31/q8-q15 Argument / result/ scratch registers - ----------------------------------------------------------------------------- */ +#include "MachRegs/ppc.h" #elif defined(MACHREGS_arm) -#define REG(x) __asm__(#x) - -#define REG_Base r4 -#define REG_Sp r5 -#define REG_Hp r6 -#define REG_R1 r7 -#define REG_R2 r8 -#define REG_R3 r9 -#define REG_R4 r10 -#define REG_SpLim r11 - -#if !defined(arm_HOST_ARCH_PRE_ARMv6) -/* d8 */ -#define REG_F1 s16 -#define REG_F2 s17 -/* d9 */ -#define REG_F3 s18 -#define REG_F4 s19 - -#define REG_D1 d10 -#define REG_D2 d11 -#endif - -/* ----------------------------------------------------------------------------- - The ARMv8/AArch64 ABI register mapping - - The AArch64 provides 31 64-bit general purpose registers - and 32 128-bit SIMD/floating point registers. - - General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) - - Register | Special | Role in the procedure call standard - ---------+---------+------------------------------------ - SP | | The Stack Pointer - r30 | LR | The Link Register - r29 | FP | The Frame Pointer - r19-r28 | | Callee-saved registers - r18 | | The Platform Register, if needed; - | | or temporary register - r17 | IP1 | The second intra-procedure-call temporary register - r16 | IP0 | The first intra-procedure-call scratch register - r9-r15 | | Temporary registers - r8 | | Indirect result location register - r0-r7 | | Parameter/result registers - - - FPU/SIMD registers - - s/d/q/v0-v7 Argument / result/ scratch registers - s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, - but only bottom 64-bit value needs to be preserved) - s/d/q/v16-v31 temporary registers - - ----------------------------------------------------------------------------- */ +#include "MachRegs/arm32.h" #elif defined(MACHREGS_aarch64) -#define REG(x) __asm__(#x) - -#define REG_Base r19 -#define REG_Sp r20 -#define REG_Hp r21 -#define REG_R1 r22 -#define REG_R2 r23 -#define REG_R3 r24 -#define REG_R4 r25 -#define REG_R5 r26 -#define REG_R6 r27 -#define REG_SpLim r28 - -#define REG_F1 s8 -#define REG_F2 s9 -#define REG_F3 s10 -#define REG_F4 s11 - -#define REG_D1 d12 -#define REG_D2 d13 -#define REG_D3 d14 -#define REG_D4 d15 - -#define REG_XMM1 q4 -#define REG_XMM2 q5 - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 - -/* ----------------------------------------------------------------------------- - The s390x register mapping - - Register | Role(s) | Call effect - ------------+-------------------------------------+----------------- - r0,r1 | - | caller-saved - r2 | Argument / return value | caller-saved - r3,r4,r5 | Arguments | caller-saved - r6 | Argument | callee-saved - r7...r11 | - | callee-saved - r12 | (Commonly used as GOT pointer) | callee-saved - r13 | (Commonly used as literal pool pointer) | callee-saved - r14 | Return address | caller-saved - r15 | Stack pointer | callee-saved - f0 | Argument / return value | caller-saved - f2,f4,f6 | Arguments | caller-saved - f1,f3,f5,f7 | - | caller-saved - f8...f15 | - | callee-saved - v0...v31 | - | caller-saved - - Each general purpose register r0 through r15 as well as each floating-point - register f0 through f15 is 64 bits wide. Each vector register v0 through v31 - is 128 bits wide. - - Note, the vector registers v0 through v15 overlap with the floating-point - registers f0 through f15. - - -------------------------------------------------------------------------- */ +#include "MachRegs/arm64.h" #elif defined(MACHREGS_s390x) -#define REG(x) __asm__("%" #x) - -#define REG_Base r7 -#define REG_Sp r8 -#define REG_Hp r10 -#define REG_R1 r11 -#define REG_R2 r12 -#define REG_R3 r13 -#define REG_R4 r6 -#define REG_R5 r2 -#define REG_R6 r3 -#define REG_R7 r4 -#define REG_R8 r5 -#define REG_SpLim r9 -#define REG_MachSp r15 - -#define REG_F1 f8 -#define REG_F2 f9 -#define REG_F3 f10 -#define REG_F4 f11 -#define REG_F5 f0 -#define REG_F6 f1 - -#define REG_D1 f12 -#define REG_D2 f13 -#define REG_D3 f14 -#define REG_D4 f15 -#define REG_D5 f2 -#define REG_D6 f3 - -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 -#define CALLER_SAVES_R7 -#define CALLER_SAVES_R8 - -#define CALLER_SAVES_F5 -#define CALLER_SAVES_F6 - -#define CALLER_SAVES_D5 -#define CALLER_SAVES_D6 - -/* ----------------------------------------------------------------------------- - The riscv64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - sp | Stack pointer | callee-saved - gp | Global pointer | callee-saved - tp | Thread pointer | callee-saved - t0,t1,t2 | - | caller-saved - s0 | Frame pointer | callee-saved - s1 | - | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - s2..s11 | - | callee-saved - t3..t6 | - | caller-saved - ft0..ft7 | - | caller-saved - fs0,fs1 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - fs2..fs11 | - | callee-saved - ft8..ft11 | - | caller-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide. - - -------------------------------------------------------------------------- */ +#include "MachRegs/s390x.h" #elif defined(MACHREGS_riscv64) -#define REG(x) __asm__(#x) - -#define REG_Base s1 -#define REG_Sp s2 -#define REG_Hp s3 -#define REG_R1 s4 -#define REG_R2 s5 -#define REG_R3 s6 -#define REG_R4 s7 -#define REG_R5 s8 -#define REG_R6 s9 -#define REG_R7 s10 -#define REG_SpLim s11 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 -#define REG_F5 fs4 -#define REG_F6 fs5 - -#define REG_D1 fs6 -#define REG_D2 fs7 -#define REG_D3 fs8 -#define REG_D4 fs9 -#define REG_D5 fs10 -#define REG_D6 fs11 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 +#include "MachRegs/riscv64.h" #elif defined(MACHREGS_wasm32) -#define REG_R1 1 -#define REG_R2 2 -#define REG_R3 3 -#define REG_R4 4 -#define REG_R5 5 -#define REG_R6 6 -#define REG_R7 7 -#define REG_R8 8 -#define REG_R9 9 -#define REG_R10 10 - -#define REG_F1 11 -#define REG_F2 12 -#define REG_F3 13 -#define REG_F4 14 -#define REG_F5 15 -#define REG_F6 16 - -#define REG_D1 17 -#define REG_D2 18 -#define REG_D3 19 -#define REG_D4 20 -#define REG_D5 21 -#define REG_D6 22 - -#define REG_L1 23 - -#define REG_Sp 24 -#define REG_SpLim 25 -#define REG_Hp 26 -#define REG_HpLim 27 -#define REG_CCCS 28 - -/* ----------------------------------------------------------------------------- - The loongarch64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - tp | Thread pointer | - - sp | Stack pointer | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - t0..t8 | - | caller-saved - u0 | Reserve | - - fp | Frame pointer | callee-saved - s0..s8 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - ft0..ft15 | - | caller-saved - fs0..fs7 | - | callee-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide, also, the u0 register is called r21 in some cases. +#include "MachRegs/wasm32.h" - -------------------------------------------------------------------------- */ #elif defined(MACHREGS_loongarch64) -#define REG(x) __asm__("$" #x) - -#define REG_Base s0 -#define REG_Sp s1 -#define REG_Hp s2 -#define REG_R1 s3 -#define REG_R2 s4 -#define REG_R3 s5 -#define REG_R4 s6 -#define REG_R5 s7 -#define REG_SpLim s8 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 - -#define REG_D1 fs4 -#define REG_D2 fs5 -#define REG_D3 fs6 -#define REG_D4 fs7 - -#define MAX_REAL_FLOAT_REG 4 -#define MAX_REAL_DOUBLE_REG 4 +#include "MachRegs/loongarch64.h" #else ===================================== rts/include/stg/MachRegs/arm32.h ===================================== @@ -0,0 +1,60 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The ARM EABI register mapping + + Here we consider ARM mode (i.e. 32bit isns) + and also CPU with full VFPv3 implementation + + ARM registers (see Chapter 5.1 in ARM IHI 0042D and + Section 9.2.2 in ARM Software Development Toolkit Reference Guide) + + r15 PC The Program Counter. + r14 LR The Link Register. + r13 SP The Stack Pointer. + r12 IP The Intra-Procedure-call scratch register. + r11 v8/fp Variable-register 8. + r10 v7/sl Variable-register 7. + r9 v6/SB/TR Platform register. The meaning of this register is + defined by the platform standard. + r8 v5 Variable-register 5. + r7 v4 Variable register 4. + r6 v3 Variable register 3. + r5 v2 Variable register 2. + r4 v1 Variable register 1. + r3 a4 Argument / scratch register 4. + r2 a3 Argument / scratch register 3. + r1 a2 Argument / result / scratch register 2. + r0 a1 Argument / result / scratch register 1. + + VFPv2/VFPv3/NEON registers + s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers + s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across + subroutine calls) + + VFPv3/NEON registers (added to the VFPv2 registers set) + d16-d31/q8-q15 Argument / result/ scratch registers + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r4 +#define REG_Sp r5 +#define REG_Hp r6 +#define REG_R1 r7 +#define REG_R2 r8 +#define REG_R3 r9 +#define REG_R4 r10 +#define REG_SpLim r11 + +#if !defined(arm_HOST_ARCH_PRE_ARMv6) +/* d8 */ +#define REG_F1 s16 +#define REG_F2 s17 +/* d9 */ +#define REG_F3 s18 +#define REG_F4 s19 + +#define REG_D1 d10 +#define REG_D2 d11 +#endif \ No newline at end of file ===================================== rts/include/stg/MachRegs/arm64.h ===================================== @@ -0,0 +1,64 @@ +#pragma once + + +/* ----------------------------------------------------------------------------- + The ARMv8/AArch64 ABI register mapping + + The AArch64 provides 31 64-bit general purpose registers + and 32 128-bit SIMD/floating point registers. + + General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) + + Register | Special | Role in the procedure call standard + ---------+---------+------------------------------------ + SP | | The Stack Pointer + r30 | LR | The Link Register + r29 | FP | The Frame Pointer + r19-r28 | | Callee-saved registers + r18 | | The Platform Register, if needed; + | | or temporary register + r17 | IP1 | The second intra-procedure-call temporary register + r16 | IP0 | The first intra-procedure-call scratch register + r9-r15 | | Temporary registers + r8 | | Indirect result location register + r0-r7 | | Parameter/result registers + + + FPU/SIMD registers + + s/d/q/v0-v7 Argument / result/ scratch registers + s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, + but only bottom 64-bit value needs to be preserved) + s/d/q/v16-v31 temporary registers + + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r19 +#define REG_Sp r20 +#define REG_Hp r21 +#define REG_R1 r22 +#define REG_R2 r23 +#define REG_R3 r24 +#define REG_R4 r25 +#define REG_R5 r26 +#define REG_R6 r27 +#define REG_SpLim r28 + +#define REG_F1 s8 +#define REG_F2 s9 +#define REG_F3 s10 +#define REG_F4 s11 + +#define REG_D1 d12 +#define REG_D2 d13 +#define REG_D3 d14 +#define REG_D4 d15 + +#define REG_XMM1 q4 +#define REG_XMM2 q5 + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 + ===================================== rts/include/stg/MachRegs/loongarch64.h ===================================== @@ -0,0 +1,51 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The loongarch64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + tp | Thread pointer | - + sp | Stack pointer | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + t0..t8 | - | caller-saved + u0 | Reserve | - + fp | Frame pointer | callee-saved + s0..s8 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + ft0..ft15 | - | caller-saved + fs0..fs7 | - | callee-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide, also, the u0 register is called r21 in some cases. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__("$" #x) + +#define REG_Base s0 +#define REG_Sp s1 +#define REG_Hp s2 +#define REG_R1 s3 +#define REG_R2 s4 +#define REG_R3 s5 +#define REG_R4 s6 +#define REG_R5 s7 +#define REG_SpLim s8 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 + +#define REG_D1 fs4 +#define REG_D2 fs5 +#define REG_D3 fs6 +#define REG_D4 fs7 + +#define MAX_REAL_FLOAT_REG 4 +#define MAX_REAL_DOUBLE_REG 4 ===================================== rts/include/stg/MachRegs/ppc.h ===================================== @@ -0,0 +1,65 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The PowerPC register mapping + + 0 system glue? (caller-save, volatile) + 1 SP (callee-save, non-volatile) + 2 AIX, powerpc64-linux: + RTOC (a strange special case) + powerpc32-linux: + reserved for use by system + + 3-10 args/return (caller-save, volatile) + 11,12 system glue? (caller-save, volatile) + 13 on 64-bit: reserved for thread state pointer + on 32-bit: (callee-save, non-volatile) + 14-31 (callee-save, non-volatile) + + f0 (caller-save, volatile) + f1-f13 args/return (caller-save, volatile) + f14-f31 (callee-save, non-volatile) + + \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. + \tr{0}--\tr{12} are caller-save registers. + + \tr{%f14}--\tr{%f31} are callee-save floating-point registers. + + We can do the Whole Business with callee-save registers only! + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__(#x) + +#define REG_R1 r14 +#define REG_R2 r15 +#define REG_R3 r16 +#define REG_R4 r17 +#define REG_R5 r18 +#define REG_R6 r19 +#define REG_R7 r20 +#define REG_R8 r21 +#define REG_R9 r22 +#define REG_R10 r23 + +#define REG_F1 fr14 +#define REG_F2 fr15 +#define REG_F3 fr16 +#define REG_F4 fr17 +#define REG_F5 fr18 +#define REG_F6 fr19 + +#define REG_D1 fr20 +#define REG_D2 fr21 +#define REG_D3 fr22 +#define REG_D4 fr23 +#define REG_D5 fr24 +#define REG_D6 fr25 + +#define REG_Sp r24 +#define REG_SpLim r25 +#define REG_Hp r26 +#define REG_Base r27 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/riscv64.h ===================================== @@ -0,0 +1,61 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The riscv64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + sp | Stack pointer | callee-saved + gp | Global pointer | callee-saved + tp | Thread pointer | callee-saved + t0,t1,t2 | - | caller-saved + s0 | Frame pointer | callee-saved + s1 | - | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + s2..s11 | - | callee-saved + t3..t6 | - | caller-saved + ft0..ft7 | - | caller-saved + fs0,fs1 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + fs2..fs11 | - | callee-saved + ft8..ft11 | - | caller-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base s1 +#define REG_Sp s2 +#define REG_Hp s3 +#define REG_R1 s4 +#define REG_R2 s5 +#define REG_R3 s6 +#define REG_R4 s7 +#define REG_R5 s8 +#define REG_R6 s9 +#define REG_R7 s10 +#define REG_SpLim s11 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 +#define REG_F5 fs4 +#define REG_F6 fs5 + +#define REG_D1 fs6 +#define REG_D2 fs7 +#define REG_D3 fs8 +#define REG_D4 fs9 +#define REG_D5 fs10 +#define REG_D6 fs11 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/s390x.h ===================================== @@ -0,0 +1,72 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The s390x register mapping + + Register | Role(s) | Call effect + ------------+-------------------------------------+----------------- + r0,r1 | - | caller-saved + r2 | Argument / return value | caller-saved + r3,r4,r5 | Arguments | caller-saved + r6 | Argument | callee-saved + r7...r11 | - | callee-saved + r12 | (Commonly used as GOT pointer) | callee-saved + r13 | (Commonly used as literal pool pointer) | callee-saved + r14 | Return address | caller-saved + r15 | Stack pointer | callee-saved + f0 | Argument / return value | caller-saved + f2,f4,f6 | Arguments | caller-saved + f1,f3,f5,f7 | - | caller-saved + f8...f15 | - | callee-saved + v0...v31 | - | caller-saved + + Each general purpose register r0 through r15 as well as each floating-point + register f0 through f15 is 64 bits wide. Each vector register v0 through v31 + is 128 bits wide. + + Note, the vector registers v0 through v15 overlap with the floating-point + registers f0 through f15. + + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__("%" #x) + +#define REG_Base r7 +#define REG_Sp r8 +#define REG_Hp r10 +#define REG_R1 r11 +#define REG_R2 r12 +#define REG_R3 r13 +#define REG_R4 r6 +#define REG_R5 r2 +#define REG_R6 r3 +#define REG_R7 r4 +#define REG_R8 r5 +#define REG_SpLim r9 +#define REG_MachSp r15 + +#define REG_F1 f8 +#define REG_F2 f9 +#define REG_F3 f10 +#define REG_F4 f11 +#define REG_F5 f0 +#define REG_F6 f1 + +#define REG_D1 f12 +#define REG_D2 f13 +#define REG_D3 f14 +#define REG_D4 f15 +#define REG_D5 f2 +#define REG_D6 f3 + +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 +#define CALLER_SAVES_R7 +#define CALLER_SAVES_R8 + +#define CALLER_SAVES_F5 +#define CALLER_SAVES_F6 + +#define CALLER_SAVES_D5 +#define CALLER_SAVES_D6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/wasm32.h ===================================== ===================================== rts/include/stg/MachRegs/x86.h ===================================== @@ -0,0 +1,210 @@ +/* ----------------------------------------------------------------------------- + The x86 register mapping + + Ok, we've only got 6 general purpose registers, a frame pointer and a + stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, + hence they get trashed across ccalls and are caller saves. \tr{%ebx}, + \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. + + Reg STG-Reg + --------------- + ebx Base + ebp Sp + esi R1 + edi Hp + + Leaving SpLim out of the picture. + -------------------------------------------------------------------------- */ + +#if defined(MACHREGS_i386) + +#define REG(x) __asm__("%" #x) + +#if !defined(not_doing_dynamic_linking) +#define REG_Base ebx +#endif +#define REG_Sp ebp + +#if !defined(STOLEN_X86_REGS) +#define STOLEN_X86_REGS 4 +#endif + +#if STOLEN_X86_REGS >= 3 +# define REG_R1 esi +#endif + +#if STOLEN_X86_REGS >= 4 +# define REG_Hp edi +#endif +#define REG_MachSp esp + +#define REG_XMM1 xmm0 +#define REG_XMM2 xmm1 +#define REG_XMM3 xmm2 +#define REG_XMM4 xmm3 + +#define REG_YMM1 ymm0 +#define REG_YMM2 ymm1 +#define REG_YMM3 ymm2 +#define REG_YMM4 ymm3 + +#define REG_ZMM1 zmm0 +#define REG_ZMM2 zmm1 +#define REG_ZMM3 zmm2 +#define REG_ZMM4 zmm3 + +#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ +#define MAX_REAL_FLOAT_REG 0 +#define MAX_REAL_DOUBLE_REG 0 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 4 +#define MAX_REAL_YMM_REG 4 +#define MAX_REAL_ZMM_REG 4 + +/* ----------------------------------------------------------------------------- + The x86-64 register mapping + + %rax caller-saves, don't steal this one + %rbx YES + %rcx arg reg, caller-saves + %rdx arg reg, caller-saves + %rsi arg reg, caller-saves + %rdi arg reg, caller-saves + %rbp YES (our *prime* register) + %rsp (unavailable - stack pointer) + %r8 arg reg, caller-saves + %r9 arg reg, caller-saves + %r10 caller-saves + %r11 caller-saves + %r12 YES + %r13 YES + %r14 YES + %r15 YES + + %xmm0-7 arg regs, caller-saves + %xmm8-15 caller-saves + + Use the caller-saves regs for Rn, because we don't always have to + save those (as opposed to Sp/Hp/SpLim etc. which always have to be + saved). + + --------------------------------------------------------------------------- */ + +#elif defined(MACHREGS_x86_64) + +#define REG(x) __asm__("%" #x) + +#define REG_Base r13 +#define REG_Sp rbp +#define REG_Hp r12 +#define REG_R1 rbx +#define REG_R2 r14 +#define REG_R3 rsi +#define REG_R4 rdi +#define REG_R5 r8 +#define REG_R6 r9 +#define REG_SpLim r15 +#define REG_MachSp rsp + +/* +Map both Fn and Dn to register xmmn so that we can pass a function any +combination of up to six Float# or Double# arguments without touching +the stack. See Note [Overlapping global registers] for implications. +*/ + +#define REG_F1 xmm1 +#define REG_F2 xmm2 +#define REG_F3 xmm3 +#define REG_F4 xmm4 +#define REG_F5 xmm5 +#define REG_F6 xmm6 + +#define REG_D1 xmm1 +#define REG_D2 xmm2 +#define REG_D3 xmm3 +#define REG_D4 xmm4 +#define REG_D5 xmm5 +#define REG_D6 xmm6 + +#define REG_XMM1 xmm1 +#define REG_XMM2 xmm2 +#define REG_XMM3 xmm3 +#define REG_XMM4 xmm4 +#define REG_XMM5 xmm5 +#define REG_XMM6 xmm6 + +#define REG_YMM1 ymm1 +#define REG_YMM2 ymm2 +#define REG_YMM3 ymm3 +#define REG_YMM4 ymm4 +#define REG_YMM5 ymm5 +#define REG_YMM6 ymm6 + +#define REG_ZMM1 zmm1 +#define REG_ZMM2 zmm2 +#define REG_ZMM3 zmm3 +#define REG_ZMM4 zmm4 +#define REG_ZMM5 zmm5 +#define REG_ZMM6 zmm6 + +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_R3 +#define CALLER_SAVES_R4 +#endif +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 + +#define CALLER_SAVES_F1 +#define CALLER_SAVES_F2 +#define CALLER_SAVES_F3 +#define CALLER_SAVES_F4 +#define CALLER_SAVES_F5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_F6 +#endif + +#define CALLER_SAVES_D1 +#define CALLER_SAVES_D2 +#define CALLER_SAVES_D3 +#define CALLER_SAVES_D4 +#define CALLER_SAVES_D5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_D6 +#endif + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 +#define CALLER_SAVES_XMM3 +#define CALLER_SAVES_XMM4 +#define CALLER_SAVES_XMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_XMM6 +#endif + +#define CALLER_SAVES_YMM1 +#define CALLER_SAVES_YMM2 +#define CALLER_SAVES_YMM3 +#define CALLER_SAVES_YMM4 +#define CALLER_SAVES_YMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_YMM6 +#endif + +#define CALLER_SAVES_ZMM1 +#define CALLER_SAVES_ZMM2 +#define CALLER_SAVES_ZMM3 +#define CALLER_SAVES_ZMM4 +#define CALLER_SAVES_ZMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_ZMM6 +#endif + +#define MAX_REAL_VANILLA_REG 6 +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 6 +#define MAX_REAL_YMM_REG 6 +#define MAX_REAL_ZMM_REG 6 + +#endif /* MACHREGS_i386 || MACHREGS_x86_64 */ \ No newline at end of file ===================================== rts/rts.cabal.in ===================================== @@ -126,6 +126,14 @@ library ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h DerivedConstants.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/Types.h @@ -296,6 +304,14 @@ library rts/storage/TSO.h stg/DLL.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/MiscClosures.h stg/Prim.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/390443b7b5835cdd971e23452941f1955773a77b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/390443b7b5835cdd971e23452941f1955773a77b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 7 14:02:06 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 07 Oct 2023 10:02:06 -0400 Subject: [Git][ghc/ghc][master] 3 commits: Actually set hackage index state Message-ID: <652164de3cac2_18f529713bdc808356fe@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - 2 changed files: - .gitlab/ci.sh - hadrian/cabal.project Changes: ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -230,7 +230,7 @@ function set_toolchain_paths() { function cabal_update() { # In principle -w shouldn't be necessary here but with # cabal-install 3.8.1.0 it is, due to cabal#8447. - run "$CABAL" update -w "$GHC" --index="$HACKAGE_INDEX_STATE" + run "$CABAL" update -w "$GHC" "hackage.haskell.org,${HACKAGE_INDEX_STATE}" } @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/390443b7b5835cdd971e23452941f1955773a77b...d4b037decd5fcfdff8e32cd9e28d6e9e213592b9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/390443b7b5835cdd971e23452941f1955773a77b...d4b037decd5fcfdff8e32cd9e28d6e9e213592b9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 7 19:55:22 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 07 Oct 2023 15:55:22 -0400 Subject: [Git][ghc/ghc][wip/base-src] base: Introduce move modules into src Message-ID: <6521b7aa9bb97_18f52979c7a8c0848122@gitlab.mail> Ben Gamari pushed to branch wip/base-src at Glasgow Haskell Compiler / GHC Commits: 85bb0bae by Ben Gamari at 2023-10-07T15:54:37-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - 30 changed files: - libraries/base/base.cabal - libraries/base/Control/Applicative.hs → libraries/base/src/Control/Applicative.hs - libraries/base/Control/Arrow.hs → libraries/base/src/Control/Arrow.hs - libraries/base/Control/Category.hs → libraries/base/src/Control/Category.hs - libraries/base/Control/Concurrent.hs → libraries/base/src/Control/Concurrent.hs - libraries/base/Control/Concurrent.hs-boot → libraries/base/src/Control/Concurrent.hs-boot - libraries/base/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs - libraries/base/Control/Concurrent/MVar.hs → libraries/base/src/Control/Concurrent/MVar.hs - libraries/base/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs - libraries/base/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs - libraries/base/Control/Exception.hs → libraries/base/src/Control/Exception.hs - libraries/base/Control/Exception/Base.hs → libraries/base/src/Control/Exception/Base.hs - libraries/base/Control/Monad.hs → libraries/base/src/Control/Monad.hs - libraries/base/Control/Monad/Fail.hs → libraries/base/src/Control/Monad/Fail.hs - libraries/base/Control/Monad/Fix.hs → libraries/base/src/Control/Monad/Fix.hs - libraries/base/Control/Monad/IO/Class.hs → libraries/base/src/Control/Monad/IO/Class.hs - libraries/base/Control/Monad/Instances.hs → libraries/base/src/Control/Monad/Instances.hs - libraries/base/Control/Monad/ST.hs → libraries/base/src/Control/Monad/ST.hs - libraries/base/Control/Monad/ST/Imp.hs → libraries/base/src/Control/Monad/ST/Imp.hs - libraries/base/Control/Monad/ST/Lazy.hs → libraries/base/src/Control/Monad/ST/Lazy.hs - libraries/base/Control/Monad/ST/Lazy/Imp.hs → libraries/base/src/Control/Monad/ST/Lazy/Imp.hs - libraries/base/Control/Monad/ST/Lazy/Safe.hs → libraries/base/src/Control/Monad/ST/Lazy/Safe.hs - libraries/base/Control/Monad/ST/Lazy/Unsafe.hs → libraries/base/src/Control/Monad/ST/Lazy/Unsafe.hs - libraries/base/Control/Monad/ST/Safe.hs → libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/Control/Monad/ST/Strict.hs → libraries/base/src/Control/Monad/ST/Strict.hs - libraries/base/Control/Monad/ST/Unsafe.hs → libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/Control/Monad/Zip.hs → libraries/base/src/Control/Monad/Zip.hs - libraries/base/Data/Array/Byte.hs → libraries/base/src/Data/Array/Byte.hs - libraries/base/Data/Bifoldable.hs → libraries/base/src/Data/Bifoldable.hs - libraries/base/Data/Bifoldable1.hs → libraries/base/src/Data/Bifoldable1.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85bb0bae755c26b571f86a9855f1985057ddd48a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85bb0bae755c26b571f86a9855f1985057ddd48a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 8 16:16:36 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 08 Oct 2023 12:16:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: rts: Split up rts/include/stg/MachRegs.h by arch Message-ID: <6522d5e417c8d_1b931c19eca7c08635b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - 3a82c4b5 by Andrew Lelechenko at 2023-10-08T12:16:02-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - 92df8027 by David Binder at 2023-10-08T12:16:05-04:00 Update hpc-bin submodule to 0.69 - - - - - 36ef6720 by David Binder at 2023-10-08T12:16:05-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 22 changed files: - .gitignore - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/ghc.cabal.in - configure.ac - hadrian/cabal.project - hadrian/src/Rules/SourceDist.hs - libraries/base/GHC/IO/FD.hs - libraries/base/changelog.md - rts/include/stg/MachRegs.h - + rts/include/stg/MachRegs/arm32.h - + rts/include/stg/MachRegs/arm64.h - + rts/include/stg/MachRegs/loongarch64.h - + rts/include/stg/MachRegs/ppc.h - + rts/include/stg/MachRegs/riscv64.h - + rts/include/stg/MachRegs/s390x.h - + rts/include/stg/MachRegs/wasm32.h - + rts/include/stg/MachRegs/x86.h - rts/rts.cabal.in - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== .gitignore ===================================== @@ -111,6 +111,7 @@ _darcs/ /compiler/ClosureTypes.h /compiler/FunTypes.h /compiler/MachRegs.h +/compiler/MachRegs /compiler/ghc-llvm-version.h /compiler/ghc.cabal /compiler/ghc.cabal.old ===================================== .gitlab/ci.sh ===================================== @@ -7,7 +7,7 @@ set -Eeuo pipefail # Configuration: -HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" +HACKAGE_INDEX_STATE="2023-10-05T11:38:51Z" MIN_HAPPY_VERSION="1.20" MIN_ALEX_VERSION="3.2.6" @@ -230,7 +230,7 @@ function set_toolchain_paths() { function cabal_update() { # In principle -w shouldn't be necessary here but with # cabal-install 3.8.1.0 it is, due to cabal#8447. - run "$CABAL" update -w "$GHC" --index="$HACKAGE_INDEX_STATE" + run "$CABAL" update -w "$GHC" "hackage.haskell.org,${HACKAGE_INDEX_STATE}" } @@ -480,6 +480,9 @@ function build_hadrian() { check_release_build + # Just to be sure, use the same hackage index state when building Hadrian. + echo "index-state: $HACKAGE_INDEX_STATE" > hadrian/cabal.project.local + # We can safely enable parallel compression for x64. By the time # hadrian calls tar/xz to produce bindist, there's no other build # work taking place. ===================================== compiler/CodeGen.Platform.h ===================================== @@ -480,6 +480,7 @@ import GHC.Platform.Reg #endif +-- See also Note [Caller saves and callee-saves regs.] callerSaves :: GlobalReg -> Bool #if defined(CALLER_SAVES_Base) callerSaves BaseReg = True ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -15,7 +15,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnboxedTuples #-} --- | Native code generator +-- | Note [Native code generator] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- The native-code generator has machine-independent and -- machine-dependent modules. @@ -23,45 +24,39 @@ -- This module ("GHC.CmmToAsm") is the top-level machine-independent -- module. Before entering machine-dependent land, we do some -- machine-independent optimisations (defined below) on the --- 'CmmStmts's. +-- 'CmmStmts's. (Which ideally would be folded into CmmOpt ...) -- -- We convert to the machine-specific 'Instr' datatype with -- 'cmmCodeGen', assuming an infinite supply of registers. We then use --- a machine-independent register allocator ('regAlloc') to rejoin +-- a (mostly) machine-independent register allocator to rejoin -- reality. Obviously, 'regAlloc' has machine-specific helper --- functions (see about "RegAllocInfo" below). +-- functions (see the used register allocator for details). -- -- Finally, we order the basic blocks of the function so as to minimise -- the number of jumps between blocks, by utilising fallthrough wherever -- possible. -- --- The machine-dependent bits break down as follows: +-- The machine-dependent bits are generally contained under +-- GHC/CmmToAsm//* and generally breaks down as follows: -- --- * ["MachRegs"] Everything about the target platform's machine +-- * "Regs": Everything about the target platform's machine -- registers (and immediate operands, and addresses, which tend to -- intermingle/interact with registers). -- --- * ["MachInstrs"] Includes the 'Instr' datatype (possibly should --- have a module of its own), plus a miscellany of other things +-- * "Instr": Includes the 'Instr' datatype plus a miscellany of other things -- (e.g., 'targetDoubleSize', 'smStablePtrTable', ...) -- --- * ["MachCodeGen"] is where 'Cmm' stuff turns into +-- * "CodeGen": is where 'Cmm' stuff turns into -- machine instructions. -- --- * ["PprMach"] 'pprInstr' turns an 'Instr' into text (well, really +-- * "Ppr": 'pprInstr' turns an 'Instr' into text (well, really -- a 'SDoc'). -- --- * ["RegAllocInfo"] In the register allocator, we manipulate --- 'MRegsState's, which are 'BitSet's, one bit per machine register. --- When we want to say something about a specific machine register --- (e.g., ``it gets clobbered by this instruction''), we set/unset --- its bit. Obviously, we do this 'BitSet' thing for efficiency --- reasons. +-- The register allocators lives under GHC.CmmToAsm.Reg.*, there is both a Linear and a Graph +-- based register allocator. Both of which have their own notes describing them. They +-- are mostly platform independent but there are some platform specific files +-- encoding architecture details under Reg// -- --- The 'RegAllocInfo' module collects together the machine-specific --- info needed to do register allocation. --- --- * ["RegisterAlloc"] The (machine-independent) register allocator. -- -} -- module GHC.CmmToAsm ===================================== compiler/ghc.cabal.in ===================================== @@ -34,6 +34,14 @@ extra-source-files: ClosureTypes.h FunTypes.h MachRegs.h + MachRegs/arm32.h + MachRegs/arm64.h + MachRegs/loongarch64.h + MachRegs/ppc.h + MachRegs/riscv64.h + MachRegs/s390x.h + MachRegs/wasm32.h + MachRegs/x86.h ghc-llvm-version.h ===================================== configure.ac ===================================== @@ -578,6 +578,15 @@ ln -f rts/include/rts/Bytecodes.h compiler/ ln -f rts/include/rts/storage/ClosureTypes.h compiler/ ln -f rts/include/rts/storage/FunTypes.h compiler/ ln -f rts/include/stg/MachRegs.h compiler/ +mkdir -p compiler/MachRegs +ln -f rts/include/stg/MachRegs/arm32.h compiler/MachRegs/arm32.h +ln -f rts/include/stg/MachRegs/arm64.h compiler/MachRegs/arm64.h +ln -f rts/include/stg/MachRegs/loongarch64.h compiler/MachRegs/loongarch64.h +ln -f rts/include/stg/MachRegs/ppc.h compiler/MachRegs/ppc.h +ln -f rts/include/stg/MachRegs/riscv64.h compiler/MachRegs/riscv64.h +ln -f rts/include/stg/MachRegs/s390x.h compiler/MachRegs/s390x.h +ln -f rts/include/stg/MachRegs/wasm32.h compiler/MachRegs/wasm32.h +ln -f rts/include/stg/MachRegs/x86.h compiler/MachRegs/x86.h AC_MSG_NOTICE([done.]) dnl ** Copy the files from the "fs" utility into the right folders. ===================================== hadrian/cabal.project ===================================== @@ -3,7 +3,8 @@ packages: ./ ../libraries/ghc-platform/ -- This essentially freezes the build plan for hadrian -index-state: 2023-09-18T18:43:12Z +-- It would be wise to keep this up to date with the state set in ci.sh +index-state: 2023-10-05T11:38:51Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -184,7 +184,7 @@ prepareTree dest = do , (stage0InTree , compiler, "GHC/Parser.y", "GHC/Parser.hs") , (stage0InTree , compiler, "GHC/Parser/Lexer.x", "GHC/Parser/Lexer.hs") , (stage0InTree , compiler, "GHC/Parser/HaddockLex.x", "GHC/Parser/HaddockLex.hs") - , (stage0InTree , hpcBin, "src/HpcParser.y", "src/HpcParser.hs") + , (stage0InTree , hpcBin, "src/Trace/Hpc/Parser.y", "src/Trace/Hpc/Parser.hs") , (stage0InTree , genprimopcode, "Parser.y", "Parser.hs") , (stage0InTree , genprimopcode, "Lexer.x", "Lexer.hs") , (stage0InTree , cabalSyntax , "src/Distribution/Fields/Lexer.x", "src/Distribution/Fields/Lexer.hs") ===================================== libraries/base/GHC/IO/FD.hs ===================================== @@ -82,13 +82,19 @@ clampReadSize = min 0x7ffff000 data FD = FD { fdFD :: {-# UNPACK #-} !CInt, #if defined(mingw32_HOST_OS) - -- On Windows, a socket file descriptor needs to be read and written + -- | On Windows, a socket file descriptor needs to be read and written -- using different functions (send/recv). fdIsSocket_ :: {-# UNPACK #-} !Int #else - -- On Unix we need to know whether this FD has O_NONBLOCK set. - -- If it has, then we can use more efficient routines to read/write to it. - -- It is always safe for this to be off. + -- | On Unix we need to know whether this 'FD' has @O_NONBLOCK@ set. + -- If it has, then we can use more efficient routines (namely, unsafe FFI) + -- to read/write to it. Otherwise safe FFI is used. + -- + -- @O_NONBLOCK@ has no effect on regular files and block devices at the moment, + -- thus this flag should be off for them. While reading from a file cannot + -- block indefinitely (as opposed to reading from a socket or a pipe), it can block + -- the entire runtime for a "brief" moment of time: you cannot read a file from + -- a floppy drive or network share without delay. fdIsNonBlocking :: {-# UNPACK #-} !Int #endif } @@ -197,6 +203,9 @@ openFileWith :: FilePath -- ^ file to open -> IOMode -- ^ mode in which to open the file -> Bool -- ^ open the file in non-blocking mode? + -- This has no effect on regular files and block devices: + -- they are always opened in blocking mode. + -- See 'fdIsNonBlocking' for more discussion. -> (FD -> IODeviceType -> IO r) -- ^ @act1@: An action to perform -- on the file descriptor with the masking state -- restored and an exception handler that closes @@ -332,7 +341,11 @@ mkFD fd iomode mb_stat is_socket is_nonblock = do return (FD{ fdFD = fd, #if !defined(mingw32_HOST_OS) - fdIsNonBlocking = fromEnum is_nonblock + -- As https://man7.org/linux/man-pages/man2/open.2.html explains, + -- O_NONBLOCK has no effect on regular files and block devices; + -- utilities inspecting fdIsNonBlocking (such as readRawBufferPtr) + -- should not be tricked to think otherwise. + fdIsNonBlocking = fromEnum (is_nonblock && fd_type /= RegularFile && fd_type /= RawDevice) #else fdIsSocket_ = fromEnum is_socket #endif @@ -452,11 +465,19 @@ dup2 fd fdto = do setNonBlockingMode :: FD -> Bool -> IO FD setNonBlockingMode fd set = do - setNonBlockingFD (fdFD fd) set + -- This mirrors the behaviour of mkFD: + -- O_NONBLOCK has no effect on regular files and block devices; + -- utilities inspecting fdIsNonBlocking (such as readRawBufferPtr) + -- should not be tricked to think otherwise. + is_nonblock <- if set then do + (fd_type, _, _) <- fdStat (fdFD fd) + pure $ fd_type /= RegularFile && fd_type /= RawDevice + else pure False + setNonBlockingFD (fdFD fd) is_nonblock #if defined(mingw32_HOST_OS) return fd #else - return fd{ fdIsNonBlocking = fromEnum set } + return fd{ fdIsNonBlocking = fromEnum is_nonblock } #endif ready :: FD -> Bool -> Int -> IO Bool ===================================== libraries/base/changelog.md ===================================== @@ -5,6 +5,9 @@ * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). + * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` + * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. + ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) ## 4.19.0.0 *TBA* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. ===================================== rts/include/stg/MachRegs.h ===================================== @@ -51,637 +51,54 @@ #elif MACHREGS_NO_REGS == 0 /* ---------------------------------------------------------------------------- - Caller saves and callee-saves regs. - + Note [Caller saves and callee-saves regs.] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Caller-saves regs have to be saved around C-calls made from STG land, so this file defines CALLER_SAVES_ for each that is designated caller-saves in that machine's C calling convention. + NB: Caller-saved registers not mapped to a STG register don't + require a CALLER_SAVES_ define. As it stands, the only registers that are ever marked caller saves - are the RX, FX, DX and USER registers; as a result, if you + are the RX, FX, DX, XMM and USER registers; as a result, if you decide to caller save a system register (e.g. SP, HP, etc), note that this code path is completely untested! -- EZY See Note [Register parameter passing] for details. -------------------------------------------------------------------------- */ -/* ----------------------------------------------------------------------------- - The x86 register mapping - - Ok, we've only got 6 general purpose registers, a frame pointer and a - stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, - hence they get trashed across ccalls and are caller saves. \tr{%ebx}, - \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. - - Reg STG-Reg - --------------- - ebx Base - ebp Sp - esi R1 - edi Hp - - Leaving SpLim out of the picture. - -------------------------------------------------------------------------- */ - -#if defined(MACHREGS_i386) - -#define REG(x) __asm__("%" #x) - -#if !defined(not_doing_dynamic_linking) -#define REG_Base ebx -#endif -#define REG_Sp ebp - -#if !defined(STOLEN_X86_REGS) -#define STOLEN_X86_REGS 4 -#endif - -#if STOLEN_X86_REGS >= 3 -# define REG_R1 esi -#endif - -#if STOLEN_X86_REGS >= 4 -# define REG_Hp edi -#endif -#define REG_MachSp esp - -#define REG_XMM1 xmm0 -#define REG_XMM2 xmm1 -#define REG_XMM3 xmm2 -#define REG_XMM4 xmm3 - -#define REG_YMM1 ymm0 -#define REG_YMM2 ymm1 -#define REG_YMM3 ymm2 -#define REG_YMM4 ymm3 - -#define REG_ZMM1 zmm0 -#define REG_ZMM2 zmm1 -#define REG_ZMM3 zmm2 -#define REG_ZMM4 zmm3 - -#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ -#define MAX_REAL_FLOAT_REG 0 -#define MAX_REAL_DOUBLE_REG 0 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 4 -#define MAX_REAL_YMM_REG 4 -#define MAX_REAL_ZMM_REG 4 - -/* ----------------------------------------------------------------------------- - The x86-64 register mapping - - %rax caller-saves, don't steal this one - %rbx YES - %rcx arg reg, caller-saves - %rdx arg reg, caller-saves - %rsi arg reg, caller-saves - %rdi arg reg, caller-saves - %rbp YES (our *prime* register) - %rsp (unavailable - stack pointer) - %r8 arg reg, caller-saves - %r9 arg reg, caller-saves - %r10 caller-saves - %r11 caller-saves - %r12 YES - %r13 YES - %r14 YES - %r15 YES - - %xmm0-7 arg regs, caller-saves - %xmm8-15 caller-saves - - Use the caller-saves regs for Rn, because we don't always have to - save those (as opposed to Sp/Hp/SpLim etc. which always have to be - saved). - - --------------------------------------------------------------------------- */ - -#elif defined(MACHREGS_x86_64) - -#define REG(x) __asm__("%" #x) - -#define REG_Base r13 -#define REG_Sp rbp -#define REG_Hp r12 -#define REG_R1 rbx -#define REG_R2 r14 -#define REG_R3 rsi -#define REG_R4 rdi -#define REG_R5 r8 -#define REG_R6 r9 -#define REG_SpLim r15 -#define REG_MachSp rsp - -/* -Map both Fn and Dn to register xmmn so that we can pass a function any -combination of up to six Float# or Double# arguments without touching -the stack. See Note [Overlapping global registers] for implications. -*/ - -#define REG_F1 xmm1 -#define REG_F2 xmm2 -#define REG_F3 xmm3 -#define REG_F4 xmm4 -#define REG_F5 xmm5 -#define REG_F6 xmm6 - -#define REG_D1 xmm1 -#define REG_D2 xmm2 -#define REG_D3 xmm3 -#define REG_D4 xmm4 -#define REG_D5 xmm5 -#define REG_D6 xmm6 - -#define REG_XMM1 xmm1 -#define REG_XMM2 xmm2 -#define REG_XMM3 xmm3 -#define REG_XMM4 xmm4 -#define REG_XMM5 xmm5 -#define REG_XMM6 xmm6 - -#define REG_YMM1 ymm1 -#define REG_YMM2 ymm2 -#define REG_YMM3 ymm3 -#define REG_YMM4 ymm4 -#define REG_YMM5 ymm5 -#define REG_YMM6 ymm6 - -#define REG_ZMM1 zmm1 -#define REG_ZMM2 zmm2 -#define REG_ZMM3 zmm3 -#define REG_ZMM4 zmm4 -#define REG_ZMM5 zmm5 -#define REG_ZMM6 zmm6 - -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_R3 -#define CALLER_SAVES_R4 -#endif -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 - -#define CALLER_SAVES_F1 -#define CALLER_SAVES_F2 -#define CALLER_SAVES_F3 -#define CALLER_SAVES_F4 -#define CALLER_SAVES_F5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_F6 -#endif - -#define CALLER_SAVES_D1 -#define CALLER_SAVES_D2 -#define CALLER_SAVES_D3 -#define CALLER_SAVES_D4 -#define CALLER_SAVES_D5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_D6 -#endif - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 -#define CALLER_SAVES_XMM3 -#define CALLER_SAVES_XMM4 -#define CALLER_SAVES_XMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_XMM6 -#endif - -#define CALLER_SAVES_YMM1 -#define CALLER_SAVES_YMM2 -#define CALLER_SAVES_YMM3 -#define CALLER_SAVES_YMM4 -#define CALLER_SAVES_YMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_YMM6 -#endif - -#define CALLER_SAVES_ZMM1 -#define CALLER_SAVES_ZMM2 -#define CALLER_SAVES_ZMM3 -#define CALLER_SAVES_ZMM4 -#define CALLER_SAVES_ZMM5 -#if !defined(mingw32_HOST_OS) -#define CALLER_SAVES_ZMM6 -#endif - -#define MAX_REAL_VANILLA_REG 6 -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 -#define MAX_REAL_LONG_REG 0 -#define MAX_REAL_XMM_REG 6 -#define MAX_REAL_YMM_REG 6 -#define MAX_REAL_ZMM_REG 6 - -/* ----------------------------------------------------------------------------- - The PowerPC register mapping - - 0 system glue? (caller-save, volatile) - 1 SP (callee-save, non-volatile) - 2 AIX, powerpc64-linux: - RTOC (a strange special case) - powerpc32-linux: - reserved for use by system +/* Define STG <-> machine register mappings. */ +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) - 3-10 args/return (caller-save, volatile) - 11,12 system glue? (caller-save, volatile) - 13 on 64-bit: reserved for thread state pointer - on 32-bit: (callee-save, non-volatile) - 14-31 (callee-save, non-volatile) - - f0 (caller-save, volatile) - f1-f13 args/return (caller-save, volatile) - f14-f31 (callee-save, non-volatile) - - \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. - \tr{0}--\tr{12} are caller-save registers. - - \tr{%f14}--\tr{%f31} are callee-save floating-point registers. - - We can do the Whole Business with callee-save registers only! - -------------------------------------------------------------------------- */ +#include "MachRegs/x86.h" #elif defined(MACHREGS_powerpc) -#define REG(x) __asm__(#x) - -#define REG_R1 r14 -#define REG_R2 r15 -#define REG_R3 r16 -#define REG_R4 r17 -#define REG_R5 r18 -#define REG_R6 r19 -#define REG_R7 r20 -#define REG_R8 r21 -#define REG_R9 r22 -#define REG_R10 r23 - -#define REG_F1 fr14 -#define REG_F2 fr15 -#define REG_F3 fr16 -#define REG_F4 fr17 -#define REG_F5 fr18 -#define REG_F6 fr19 - -#define REG_D1 fr20 -#define REG_D2 fr21 -#define REG_D3 fr22 -#define REG_D4 fr23 -#define REG_D5 fr24 -#define REG_D6 fr25 - -#define REG_Sp r24 -#define REG_SpLim r25 -#define REG_Hp r26 -#define REG_Base r27 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 - -/* ----------------------------------------------------------------------------- - The ARM EABI register mapping - - Here we consider ARM mode (i.e. 32bit isns) - and also CPU with full VFPv3 implementation - - ARM registers (see Chapter 5.1 in ARM IHI 0042D and - Section 9.2.2 in ARM Software Development Toolkit Reference Guide) - - r15 PC The Program Counter. - r14 LR The Link Register. - r13 SP The Stack Pointer. - r12 IP The Intra-Procedure-call scratch register. - r11 v8/fp Variable-register 8. - r10 v7/sl Variable-register 7. - r9 v6/SB/TR Platform register. The meaning of this register is - defined by the platform standard. - r8 v5 Variable-register 5. - r7 v4 Variable register 4. - r6 v3 Variable register 3. - r5 v2 Variable register 2. - r4 v1 Variable register 1. - r3 a4 Argument / scratch register 4. - r2 a3 Argument / scratch register 3. - r1 a2 Argument / result / scratch register 2. - r0 a1 Argument / result / scratch register 1. - - VFPv2/VFPv3/NEON registers - s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers - s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across - subroutine calls) - - VFPv3/NEON registers (added to the VFPv2 registers set) - d16-d31/q8-q15 Argument / result/ scratch registers - ----------------------------------------------------------------------------- */ +#include "MachRegs/ppc.h" #elif defined(MACHREGS_arm) -#define REG(x) __asm__(#x) - -#define REG_Base r4 -#define REG_Sp r5 -#define REG_Hp r6 -#define REG_R1 r7 -#define REG_R2 r8 -#define REG_R3 r9 -#define REG_R4 r10 -#define REG_SpLim r11 - -#if !defined(arm_HOST_ARCH_PRE_ARMv6) -/* d8 */ -#define REG_F1 s16 -#define REG_F2 s17 -/* d9 */ -#define REG_F3 s18 -#define REG_F4 s19 - -#define REG_D1 d10 -#define REG_D2 d11 -#endif - -/* ----------------------------------------------------------------------------- - The ARMv8/AArch64 ABI register mapping - - The AArch64 provides 31 64-bit general purpose registers - and 32 128-bit SIMD/floating point registers. - - General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) - - Register | Special | Role in the procedure call standard - ---------+---------+------------------------------------ - SP | | The Stack Pointer - r30 | LR | The Link Register - r29 | FP | The Frame Pointer - r19-r28 | | Callee-saved registers - r18 | | The Platform Register, if needed; - | | or temporary register - r17 | IP1 | The second intra-procedure-call temporary register - r16 | IP0 | The first intra-procedure-call scratch register - r9-r15 | | Temporary registers - r8 | | Indirect result location register - r0-r7 | | Parameter/result registers - - - FPU/SIMD registers - - s/d/q/v0-v7 Argument / result/ scratch registers - s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, - but only bottom 64-bit value needs to be preserved) - s/d/q/v16-v31 temporary registers - - ----------------------------------------------------------------------------- */ +#include "MachRegs/arm32.h" #elif defined(MACHREGS_aarch64) -#define REG(x) __asm__(#x) - -#define REG_Base r19 -#define REG_Sp r20 -#define REG_Hp r21 -#define REG_R1 r22 -#define REG_R2 r23 -#define REG_R3 r24 -#define REG_R4 r25 -#define REG_R5 r26 -#define REG_R6 r27 -#define REG_SpLim r28 - -#define REG_F1 s8 -#define REG_F2 s9 -#define REG_F3 s10 -#define REG_F4 s11 - -#define REG_D1 d12 -#define REG_D2 d13 -#define REG_D3 d14 -#define REG_D4 d15 - -#define REG_XMM1 q4 -#define REG_XMM2 q5 - -#define CALLER_SAVES_XMM1 -#define CALLER_SAVES_XMM2 - -/* ----------------------------------------------------------------------------- - The s390x register mapping - - Register | Role(s) | Call effect - ------------+-------------------------------------+----------------- - r0,r1 | - | caller-saved - r2 | Argument / return value | caller-saved - r3,r4,r5 | Arguments | caller-saved - r6 | Argument | callee-saved - r7...r11 | - | callee-saved - r12 | (Commonly used as GOT pointer) | callee-saved - r13 | (Commonly used as literal pool pointer) | callee-saved - r14 | Return address | caller-saved - r15 | Stack pointer | callee-saved - f0 | Argument / return value | caller-saved - f2,f4,f6 | Arguments | caller-saved - f1,f3,f5,f7 | - | caller-saved - f8...f15 | - | callee-saved - v0...v31 | - | caller-saved - - Each general purpose register r0 through r15 as well as each floating-point - register f0 through f15 is 64 bits wide. Each vector register v0 through v31 - is 128 bits wide. - - Note, the vector registers v0 through v15 overlap with the floating-point - registers f0 through f15. - - -------------------------------------------------------------------------- */ +#include "MachRegs/arm64.h" #elif defined(MACHREGS_s390x) -#define REG(x) __asm__("%" #x) - -#define REG_Base r7 -#define REG_Sp r8 -#define REG_Hp r10 -#define REG_R1 r11 -#define REG_R2 r12 -#define REG_R3 r13 -#define REG_R4 r6 -#define REG_R5 r2 -#define REG_R6 r3 -#define REG_R7 r4 -#define REG_R8 r5 -#define REG_SpLim r9 -#define REG_MachSp r15 - -#define REG_F1 f8 -#define REG_F2 f9 -#define REG_F3 f10 -#define REG_F4 f11 -#define REG_F5 f0 -#define REG_F6 f1 - -#define REG_D1 f12 -#define REG_D2 f13 -#define REG_D3 f14 -#define REG_D4 f15 -#define REG_D5 f2 -#define REG_D6 f3 - -#define CALLER_SAVES_R5 -#define CALLER_SAVES_R6 -#define CALLER_SAVES_R7 -#define CALLER_SAVES_R8 - -#define CALLER_SAVES_F5 -#define CALLER_SAVES_F6 - -#define CALLER_SAVES_D5 -#define CALLER_SAVES_D6 - -/* ----------------------------------------------------------------------------- - The riscv64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - sp | Stack pointer | callee-saved - gp | Global pointer | callee-saved - tp | Thread pointer | callee-saved - t0,t1,t2 | - | caller-saved - s0 | Frame pointer | callee-saved - s1 | - | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - s2..s11 | - | callee-saved - t3..t6 | - | caller-saved - ft0..ft7 | - | caller-saved - fs0,fs1 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - fs2..fs11 | - | callee-saved - ft8..ft11 | - | caller-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide. - - -------------------------------------------------------------------------- */ +#include "MachRegs/s390x.h" #elif defined(MACHREGS_riscv64) -#define REG(x) __asm__(#x) - -#define REG_Base s1 -#define REG_Sp s2 -#define REG_Hp s3 -#define REG_R1 s4 -#define REG_R2 s5 -#define REG_R3 s6 -#define REG_R4 s7 -#define REG_R5 s8 -#define REG_R6 s9 -#define REG_R7 s10 -#define REG_SpLim s11 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 -#define REG_F5 fs4 -#define REG_F6 fs5 - -#define REG_D1 fs6 -#define REG_D2 fs7 -#define REG_D3 fs8 -#define REG_D4 fs9 -#define REG_D5 fs10 -#define REG_D6 fs11 - -#define MAX_REAL_FLOAT_REG 6 -#define MAX_REAL_DOUBLE_REG 6 +#include "MachRegs/riscv64.h" #elif defined(MACHREGS_wasm32) -#define REG_R1 1 -#define REG_R2 2 -#define REG_R3 3 -#define REG_R4 4 -#define REG_R5 5 -#define REG_R6 6 -#define REG_R7 7 -#define REG_R8 8 -#define REG_R9 9 -#define REG_R10 10 - -#define REG_F1 11 -#define REG_F2 12 -#define REG_F3 13 -#define REG_F4 14 -#define REG_F5 15 -#define REG_F6 16 - -#define REG_D1 17 -#define REG_D2 18 -#define REG_D3 19 -#define REG_D4 20 -#define REG_D5 21 -#define REG_D6 22 - -#define REG_L1 23 - -#define REG_Sp 24 -#define REG_SpLim 25 -#define REG_Hp 26 -#define REG_HpLim 27 -#define REG_CCCS 28 - -/* ----------------------------------------------------------------------------- - The loongarch64 register mapping - - Register | Role(s) | Call effect - ------------+-----------------------------------------+------------- - zero | Hard-wired zero | - - ra | Return address | caller-saved - tp | Thread pointer | - - sp | Stack pointer | callee-saved - a0,a1 | Arguments / return values | caller-saved - a2..a7 | Arguments | caller-saved - t0..t8 | - | caller-saved - u0 | Reserve | - - fp | Frame pointer | callee-saved - s0..s8 | - | callee-saved - fa0,fa1 | Arguments / return values | caller-saved - fa2..fa7 | Arguments | caller-saved - ft0..ft15 | - | caller-saved - fs0..fs7 | - | callee-saved - - Each general purpose register as well as each floating-point - register is 64 bits wide, also, the u0 register is called r21 in some cases. +#include "MachRegs/wasm32.h" - -------------------------------------------------------------------------- */ #elif defined(MACHREGS_loongarch64) -#define REG(x) __asm__("$" #x) - -#define REG_Base s0 -#define REG_Sp s1 -#define REG_Hp s2 -#define REG_R1 s3 -#define REG_R2 s4 -#define REG_R3 s5 -#define REG_R4 s6 -#define REG_R5 s7 -#define REG_SpLim s8 - -#define REG_F1 fs0 -#define REG_F2 fs1 -#define REG_F3 fs2 -#define REG_F4 fs3 - -#define REG_D1 fs4 -#define REG_D2 fs5 -#define REG_D3 fs6 -#define REG_D4 fs7 - -#define MAX_REAL_FLOAT_REG 4 -#define MAX_REAL_DOUBLE_REG 4 +#include "MachRegs/loongarch64.h" #else ===================================== rts/include/stg/MachRegs/arm32.h ===================================== @@ -0,0 +1,60 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The ARM EABI register mapping + + Here we consider ARM mode (i.e. 32bit isns) + and also CPU with full VFPv3 implementation + + ARM registers (see Chapter 5.1 in ARM IHI 0042D and + Section 9.2.2 in ARM Software Development Toolkit Reference Guide) + + r15 PC The Program Counter. + r14 LR The Link Register. + r13 SP The Stack Pointer. + r12 IP The Intra-Procedure-call scratch register. + r11 v8/fp Variable-register 8. + r10 v7/sl Variable-register 7. + r9 v6/SB/TR Platform register. The meaning of this register is + defined by the platform standard. + r8 v5 Variable-register 5. + r7 v4 Variable register 4. + r6 v3 Variable register 3. + r5 v2 Variable register 2. + r4 v1 Variable register 1. + r3 a4 Argument / scratch register 4. + r2 a3 Argument / scratch register 3. + r1 a2 Argument / result / scratch register 2. + r0 a1 Argument / result / scratch register 1. + + VFPv2/VFPv3/NEON registers + s0-s15/d0-d7/q0-q3 Argument / result/ scratch registers + s16-s31/d8-d15/q4-q7 callee-saved registers (must be preserved across + subroutine calls) + + VFPv3/NEON registers (added to the VFPv2 registers set) + d16-d31/q8-q15 Argument / result/ scratch registers + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r4 +#define REG_Sp r5 +#define REG_Hp r6 +#define REG_R1 r7 +#define REG_R2 r8 +#define REG_R3 r9 +#define REG_R4 r10 +#define REG_SpLim r11 + +#if !defined(arm_HOST_ARCH_PRE_ARMv6) +/* d8 */ +#define REG_F1 s16 +#define REG_F2 s17 +/* d9 */ +#define REG_F3 s18 +#define REG_F4 s19 + +#define REG_D1 d10 +#define REG_D2 d11 +#endif \ No newline at end of file ===================================== rts/include/stg/MachRegs/arm64.h ===================================== @@ -0,0 +1,64 @@ +#pragma once + + +/* ----------------------------------------------------------------------------- + The ARMv8/AArch64 ABI register mapping + + The AArch64 provides 31 64-bit general purpose registers + and 32 128-bit SIMD/floating point registers. + + General purpose registers (see Chapter 5.1.1 in ARM IHI 0055B) + + Register | Special | Role in the procedure call standard + ---------+---------+------------------------------------ + SP | | The Stack Pointer + r30 | LR | The Link Register + r29 | FP | The Frame Pointer + r19-r28 | | Callee-saved registers + r18 | | The Platform Register, if needed; + | | or temporary register + r17 | IP1 | The second intra-procedure-call temporary register + r16 | IP0 | The first intra-procedure-call scratch register + r9-r15 | | Temporary registers + r8 | | Indirect result location register + r0-r7 | | Parameter/result registers + + + FPU/SIMD registers + + s/d/q/v0-v7 Argument / result/ scratch registers + s/d/q/v8-v15 callee-saved registers (must be preserved across subroutine calls, + but only bottom 64-bit value needs to be preserved) + s/d/q/v16-v31 temporary registers + + ----------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base r19 +#define REG_Sp r20 +#define REG_Hp r21 +#define REG_R1 r22 +#define REG_R2 r23 +#define REG_R3 r24 +#define REG_R4 r25 +#define REG_R5 r26 +#define REG_R6 r27 +#define REG_SpLim r28 + +#define REG_F1 s8 +#define REG_F2 s9 +#define REG_F3 s10 +#define REG_F4 s11 + +#define REG_D1 d12 +#define REG_D2 d13 +#define REG_D3 d14 +#define REG_D4 d15 + +#define REG_XMM1 q4 +#define REG_XMM2 q5 + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 + ===================================== rts/include/stg/MachRegs/loongarch64.h ===================================== @@ -0,0 +1,51 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The loongarch64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + tp | Thread pointer | - + sp | Stack pointer | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + t0..t8 | - | caller-saved + u0 | Reserve | - + fp | Frame pointer | callee-saved + s0..s8 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + ft0..ft15 | - | caller-saved + fs0..fs7 | - | callee-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide, also, the u0 register is called r21 in some cases. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__("$" #x) + +#define REG_Base s0 +#define REG_Sp s1 +#define REG_Hp s2 +#define REG_R1 s3 +#define REG_R2 s4 +#define REG_R3 s5 +#define REG_R4 s6 +#define REG_R5 s7 +#define REG_SpLim s8 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 + +#define REG_D1 fs4 +#define REG_D2 fs5 +#define REG_D3 fs6 +#define REG_D4 fs7 + +#define MAX_REAL_FLOAT_REG 4 +#define MAX_REAL_DOUBLE_REG 4 ===================================== rts/include/stg/MachRegs/ppc.h ===================================== @@ -0,0 +1,65 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The PowerPC register mapping + + 0 system glue? (caller-save, volatile) + 1 SP (callee-save, non-volatile) + 2 AIX, powerpc64-linux: + RTOC (a strange special case) + powerpc32-linux: + reserved for use by system + + 3-10 args/return (caller-save, volatile) + 11,12 system glue? (caller-save, volatile) + 13 on 64-bit: reserved for thread state pointer + on 32-bit: (callee-save, non-volatile) + 14-31 (callee-save, non-volatile) + + f0 (caller-save, volatile) + f1-f13 args/return (caller-save, volatile) + f14-f31 (callee-save, non-volatile) + + \tr{14}--\tr{31} are wonderful callee-save registers on all ppc OSes. + \tr{0}--\tr{12} are caller-save registers. + + \tr{%f14}--\tr{%f31} are callee-save floating-point registers. + + We can do the Whole Business with callee-save registers only! + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__(#x) + +#define REG_R1 r14 +#define REG_R2 r15 +#define REG_R3 r16 +#define REG_R4 r17 +#define REG_R5 r18 +#define REG_R6 r19 +#define REG_R7 r20 +#define REG_R8 r21 +#define REG_R9 r22 +#define REG_R10 r23 + +#define REG_F1 fr14 +#define REG_F2 fr15 +#define REG_F3 fr16 +#define REG_F4 fr17 +#define REG_F5 fr18 +#define REG_F6 fr19 + +#define REG_D1 fr20 +#define REG_D2 fr21 +#define REG_D3 fr22 +#define REG_D4 fr23 +#define REG_D5 fr24 +#define REG_D6 fr25 + +#define REG_Sp r24 +#define REG_SpLim r25 +#define REG_Hp r26 +#define REG_Base r27 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/riscv64.h ===================================== @@ -0,0 +1,61 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The riscv64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + sp | Stack pointer | callee-saved + gp | Global pointer | callee-saved + tp | Thread pointer | callee-saved + t0,t1,t2 | - | caller-saved + s0 | Frame pointer | callee-saved + s1 | - | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + s2..s11 | - | callee-saved + t3..t6 | - | caller-saved + ft0..ft7 | - | caller-saved + fs0,fs1 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + fs2..fs11 | - | callee-saved + ft8..ft11 | - | caller-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide. + + -------------------------------------------------------------------------- */ + +#define REG(x) __asm__(#x) + +#define REG_Base s1 +#define REG_Sp s2 +#define REG_Hp s3 +#define REG_R1 s4 +#define REG_R2 s5 +#define REG_R3 s6 +#define REG_R4 s7 +#define REG_R5 s8 +#define REG_R6 s9 +#define REG_R7 s10 +#define REG_SpLim s11 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 +#define REG_F5 fs4 +#define REG_F6 fs5 + +#define REG_D1 fs6 +#define REG_D2 fs7 +#define REG_D3 fs8 +#define REG_D4 fs9 +#define REG_D5 fs10 +#define REG_D6 fs11 + +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/s390x.h ===================================== @@ -0,0 +1,72 @@ +#pragma once + +/* ----------------------------------------------------------------------------- + The s390x register mapping + + Register | Role(s) | Call effect + ------------+-------------------------------------+----------------- + r0,r1 | - | caller-saved + r2 | Argument / return value | caller-saved + r3,r4,r5 | Arguments | caller-saved + r6 | Argument | callee-saved + r7...r11 | - | callee-saved + r12 | (Commonly used as GOT pointer) | callee-saved + r13 | (Commonly used as literal pool pointer) | callee-saved + r14 | Return address | caller-saved + r15 | Stack pointer | callee-saved + f0 | Argument / return value | caller-saved + f2,f4,f6 | Arguments | caller-saved + f1,f3,f5,f7 | - | caller-saved + f8...f15 | - | callee-saved + v0...v31 | - | caller-saved + + Each general purpose register r0 through r15 as well as each floating-point + register f0 through f15 is 64 bits wide. Each vector register v0 through v31 + is 128 bits wide. + + Note, the vector registers v0 through v15 overlap with the floating-point + registers f0 through f15. + + -------------------------------------------------------------------------- */ + + +#define REG(x) __asm__("%" #x) + +#define REG_Base r7 +#define REG_Sp r8 +#define REG_Hp r10 +#define REG_R1 r11 +#define REG_R2 r12 +#define REG_R3 r13 +#define REG_R4 r6 +#define REG_R5 r2 +#define REG_R6 r3 +#define REG_R7 r4 +#define REG_R8 r5 +#define REG_SpLim r9 +#define REG_MachSp r15 + +#define REG_F1 f8 +#define REG_F2 f9 +#define REG_F3 f10 +#define REG_F4 f11 +#define REG_F5 f0 +#define REG_F6 f1 + +#define REG_D1 f12 +#define REG_D2 f13 +#define REG_D3 f14 +#define REG_D4 f15 +#define REG_D5 f2 +#define REG_D6 f3 + +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 +#define CALLER_SAVES_R7 +#define CALLER_SAVES_R8 + +#define CALLER_SAVES_F5 +#define CALLER_SAVES_F6 + +#define CALLER_SAVES_D5 +#define CALLER_SAVES_D6 \ No newline at end of file ===================================== rts/include/stg/MachRegs/wasm32.h ===================================== ===================================== rts/include/stg/MachRegs/x86.h ===================================== @@ -0,0 +1,210 @@ +/* ----------------------------------------------------------------------------- + The x86 register mapping + + Ok, we've only got 6 general purpose registers, a frame pointer and a + stack pointer. \tr{%eax} and \tr{%edx} are return values from C functions, + hence they get trashed across ccalls and are caller saves. \tr{%ebx}, + \tr{%esi}, \tr{%edi}, \tr{%ebp} are all callee-saves. + + Reg STG-Reg + --------------- + ebx Base + ebp Sp + esi R1 + edi Hp + + Leaving SpLim out of the picture. + -------------------------------------------------------------------------- */ + +#if defined(MACHREGS_i386) + +#define REG(x) __asm__("%" #x) + +#if !defined(not_doing_dynamic_linking) +#define REG_Base ebx +#endif +#define REG_Sp ebp + +#if !defined(STOLEN_X86_REGS) +#define STOLEN_X86_REGS 4 +#endif + +#if STOLEN_X86_REGS >= 3 +# define REG_R1 esi +#endif + +#if STOLEN_X86_REGS >= 4 +# define REG_Hp edi +#endif +#define REG_MachSp esp + +#define REG_XMM1 xmm0 +#define REG_XMM2 xmm1 +#define REG_XMM3 xmm2 +#define REG_XMM4 xmm3 + +#define REG_YMM1 ymm0 +#define REG_YMM2 ymm1 +#define REG_YMM3 ymm2 +#define REG_YMM4 ymm3 + +#define REG_ZMM1 zmm0 +#define REG_ZMM2 zmm1 +#define REG_ZMM3 zmm2 +#define REG_ZMM4 zmm3 + +#define MAX_REAL_VANILLA_REG 1 /* always, since it defines the entry conv */ +#define MAX_REAL_FLOAT_REG 0 +#define MAX_REAL_DOUBLE_REG 0 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 4 +#define MAX_REAL_YMM_REG 4 +#define MAX_REAL_ZMM_REG 4 + +/* ----------------------------------------------------------------------------- + The x86-64 register mapping + + %rax caller-saves, don't steal this one + %rbx YES + %rcx arg reg, caller-saves + %rdx arg reg, caller-saves + %rsi arg reg, caller-saves + %rdi arg reg, caller-saves + %rbp YES (our *prime* register) + %rsp (unavailable - stack pointer) + %r8 arg reg, caller-saves + %r9 arg reg, caller-saves + %r10 caller-saves + %r11 caller-saves + %r12 YES + %r13 YES + %r14 YES + %r15 YES + + %xmm0-7 arg regs, caller-saves + %xmm8-15 caller-saves + + Use the caller-saves regs for Rn, because we don't always have to + save those (as opposed to Sp/Hp/SpLim etc. which always have to be + saved). + + --------------------------------------------------------------------------- */ + +#elif defined(MACHREGS_x86_64) + +#define REG(x) __asm__("%" #x) + +#define REG_Base r13 +#define REG_Sp rbp +#define REG_Hp r12 +#define REG_R1 rbx +#define REG_R2 r14 +#define REG_R3 rsi +#define REG_R4 rdi +#define REG_R5 r8 +#define REG_R6 r9 +#define REG_SpLim r15 +#define REG_MachSp rsp + +/* +Map both Fn and Dn to register xmmn so that we can pass a function any +combination of up to six Float# or Double# arguments without touching +the stack. See Note [Overlapping global registers] for implications. +*/ + +#define REG_F1 xmm1 +#define REG_F2 xmm2 +#define REG_F3 xmm3 +#define REG_F4 xmm4 +#define REG_F5 xmm5 +#define REG_F6 xmm6 + +#define REG_D1 xmm1 +#define REG_D2 xmm2 +#define REG_D3 xmm3 +#define REG_D4 xmm4 +#define REG_D5 xmm5 +#define REG_D6 xmm6 + +#define REG_XMM1 xmm1 +#define REG_XMM2 xmm2 +#define REG_XMM3 xmm3 +#define REG_XMM4 xmm4 +#define REG_XMM5 xmm5 +#define REG_XMM6 xmm6 + +#define REG_YMM1 ymm1 +#define REG_YMM2 ymm2 +#define REG_YMM3 ymm3 +#define REG_YMM4 ymm4 +#define REG_YMM5 ymm5 +#define REG_YMM6 ymm6 + +#define REG_ZMM1 zmm1 +#define REG_ZMM2 zmm2 +#define REG_ZMM3 zmm3 +#define REG_ZMM4 zmm4 +#define REG_ZMM5 zmm5 +#define REG_ZMM6 zmm6 + +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_R3 +#define CALLER_SAVES_R4 +#endif +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 + +#define CALLER_SAVES_F1 +#define CALLER_SAVES_F2 +#define CALLER_SAVES_F3 +#define CALLER_SAVES_F4 +#define CALLER_SAVES_F5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_F6 +#endif + +#define CALLER_SAVES_D1 +#define CALLER_SAVES_D2 +#define CALLER_SAVES_D3 +#define CALLER_SAVES_D4 +#define CALLER_SAVES_D5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_D6 +#endif + +#define CALLER_SAVES_XMM1 +#define CALLER_SAVES_XMM2 +#define CALLER_SAVES_XMM3 +#define CALLER_SAVES_XMM4 +#define CALLER_SAVES_XMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_XMM6 +#endif + +#define CALLER_SAVES_YMM1 +#define CALLER_SAVES_YMM2 +#define CALLER_SAVES_YMM3 +#define CALLER_SAVES_YMM4 +#define CALLER_SAVES_YMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_YMM6 +#endif + +#define CALLER_SAVES_ZMM1 +#define CALLER_SAVES_ZMM2 +#define CALLER_SAVES_ZMM3 +#define CALLER_SAVES_ZMM4 +#define CALLER_SAVES_ZMM5 +#if !defined(mingw32_HOST_OS) +#define CALLER_SAVES_ZMM6 +#endif + +#define MAX_REAL_VANILLA_REG 6 +#define MAX_REAL_FLOAT_REG 6 +#define MAX_REAL_DOUBLE_REG 6 +#define MAX_REAL_LONG_REG 0 +#define MAX_REAL_XMM_REG 6 +#define MAX_REAL_YMM_REG 6 +#define MAX_REAL_ZMM_REG 6 + +#endif /* MACHREGS_i386 || MACHREGS_x86_64 */ \ No newline at end of file ===================================== rts/rts.cabal.in ===================================== @@ -126,6 +126,14 @@ library ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h DerivedConstants.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/Types.h @@ -296,6 +304,14 @@ library rts/storage/TSO.h stg/DLL.h stg/MachRegs.h + stg/MachRegs/arm32.h + stg/MachRegs/arm64.h + stg/MachRegs/loongarch64.h + stg/MachRegs/ppc.h + stg/MachRegs/riscv64.h + stg/MachRegs/s390x.h + stg/MachRegs/wasm32.h + stg/MachRegs/x86.h stg/MachRegsForHost.h stg/MiscClosures.h stg/Prim.h ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit 2d75eb33d4c179b1c21000d32c2906ad273de0de +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f828f48ffc74d9eaaac6db61a7a8675cd57185a5...36ef67208607261d445263e9579355b4fc57ca58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f828f48ffc74d9eaaac6db61a7a8675cd57185a5...36ef67208607261d445263e9579355b4fc57ca58 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 8 19:06:36 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 08 Oct 2023 15:06:36 -0400 Subject: [Git][ghc/ghc][master] Do not use O_NONBLOCK on regular files or block devices Message-ID: <6522fdbcb9705_1b931c1db000a0964a6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - 2 changed files: - libraries/base/GHC/IO/FD.hs - libraries/base/changelog.md Changes: ===================================== libraries/base/GHC/IO/FD.hs ===================================== @@ -82,13 +82,19 @@ clampReadSize = min 0x7ffff000 data FD = FD { fdFD :: {-# UNPACK #-} !CInt, #if defined(mingw32_HOST_OS) - -- On Windows, a socket file descriptor needs to be read and written + -- | On Windows, a socket file descriptor needs to be read and written -- using different functions (send/recv). fdIsSocket_ :: {-# UNPACK #-} !Int #else - -- On Unix we need to know whether this FD has O_NONBLOCK set. - -- If it has, then we can use more efficient routines to read/write to it. - -- It is always safe for this to be off. + -- | On Unix we need to know whether this 'FD' has @O_NONBLOCK@ set. + -- If it has, then we can use more efficient routines (namely, unsafe FFI) + -- to read/write to it. Otherwise safe FFI is used. + -- + -- @O_NONBLOCK@ has no effect on regular files and block devices at the moment, + -- thus this flag should be off for them. While reading from a file cannot + -- block indefinitely (as opposed to reading from a socket or a pipe), it can block + -- the entire runtime for a "brief" moment of time: you cannot read a file from + -- a floppy drive or network share without delay. fdIsNonBlocking :: {-# UNPACK #-} !Int #endif } @@ -197,6 +203,9 @@ openFileWith :: FilePath -- ^ file to open -> IOMode -- ^ mode in which to open the file -> Bool -- ^ open the file in non-blocking mode? + -- This has no effect on regular files and block devices: + -- they are always opened in blocking mode. + -- See 'fdIsNonBlocking' for more discussion. -> (FD -> IODeviceType -> IO r) -- ^ @act1@: An action to perform -- on the file descriptor with the masking state -- restored and an exception handler that closes @@ -332,7 +341,11 @@ mkFD fd iomode mb_stat is_socket is_nonblock = do return (FD{ fdFD = fd, #if !defined(mingw32_HOST_OS) - fdIsNonBlocking = fromEnum is_nonblock + -- As https://man7.org/linux/man-pages/man2/open.2.html explains, + -- O_NONBLOCK has no effect on regular files and block devices; + -- utilities inspecting fdIsNonBlocking (such as readRawBufferPtr) + -- should not be tricked to think otherwise. + fdIsNonBlocking = fromEnum (is_nonblock && fd_type /= RegularFile && fd_type /= RawDevice) #else fdIsSocket_ = fromEnum is_socket #endif @@ -452,11 +465,19 @@ dup2 fd fdto = do setNonBlockingMode :: FD -> Bool -> IO FD setNonBlockingMode fd set = do - setNonBlockingFD (fdFD fd) set + -- This mirrors the behaviour of mkFD: + -- O_NONBLOCK has no effect on regular files and block devices; + -- utilities inspecting fdIsNonBlocking (such as readRawBufferPtr) + -- should not be tricked to think otherwise. + is_nonblock <- if set then do + (fd_type, _, _) <- fdStat (fdFD fd) + pure $ fd_type /= RegularFile && fd_type /= RawDevice + else pure False + setNonBlockingFD (fdFD fd) is_nonblock #if defined(mingw32_HOST_OS) return fd #else - return fd{ fdIsNonBlocking = fromEnum set } + return fd{ fdIsNonBlocking = fromEnum is_nonblock } #endif ready :: FD -> Bool -> Int -> IO Bool ===================================== libraries/base/changelog.md ===================================== @@ -5,6 +5,9 @@ * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). + * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` + * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. + ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) ## 4.19.0.0 *TBA* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e206be6470d6c1d4a5ed80615c8dc830efe011ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e206be6470d6c1d4a5ed80615c8dc830efe011ea You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 8 19:07:35 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 08 Oct 2023 15:07:35 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Update hpc-bin submodule to 0.69 Message-ID: <6522fdf7c99ac_1b931c1dafd8f099997@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 3 changed files: - hadrian/src/Rules/SourceDist.hs - testsuite/tests/hpc/T17073.stdout - utils/hpc Changes: ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -184,7 +184,7 @@ prepareTree dest = do , (stage0InTree , compiler, "GHC/Parser.y", "GHC/Parser.hs") , (stage0InTree , compiler, "GHC/Parser/Lexer.x", "GHC/Parser/Lexer.hs") , (stage0InTree , compiler, "GHC/Parser/HaddockLex.x", "GHC/Parser/HaddockLex.hs") - , (stage0InTree , hpcBin, "src/HpcParser.y", "src/HpcParser.hs") + , (stage0InTree , hpcBin, "src/Trace/Hpc/Parser.y", "src/Trace/Hpc/Parser.hs") , (stage0InTree , genprimopcode, "Parser.y", "Parser.hs") , (stage0InTree , genprimopcode, "Lexer.x", "Lexer.hs") , (stage0InTree , cabalSyntax , "src/Distribution/Fields/Lexer.x", "src/Distribution/Fields/Lexer.hs") ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit 2d75eb33d4c179b1c21000d32c2906ad273de0de +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e206be6470d6c1d4a5ed80615c8dc830efe011ea...ed6785b671d537a6866f2a83e08ed43c88f60adc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e206be6470d6c1d4a5ed80615c8dc830efe011ea...ed6785b671d537a6866f2a83e08ed43c88f60adc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 09:28:58 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Mon, 09 Oct 2023 05:28:58 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/32bit-cmm Message-ID: <6523c7da2c767_1b931c31a4c5a013999c@gitlab.mail> Moritz Angermann pushed new branch wip/angerman/32bit-cmm at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/32bit-cmm You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 09:51:17 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Mon, 09 Oct 2023 05:51:17 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/no-null-deref Message-ID: <6523cd157143_1b931c3246544c1530d@gitlab.mail> Moritz Angermann pushed new branch wip/angerman/no-null-deref at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/no-null-deref You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 10:06:00 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Mon, 09 Oct 2023 06:06:00 -0400 Subject: [Git][ghc/ghc][wip/angerman/32bit-cmm] Apply 1 suggestion(s) to 1 file(s) Message-ID: <6523d088e0c22_1b931c327b0bc41592b@gitlab.mail> Moritz Angermann pushed to branch wip/angerman/32bit-cmm at Glasgow Haskell Compiler / GHC Commits: 3f437af1 by Sylvain Henry at 2023-10-09T10:05:50+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/StgToCmm/CgUtils.hs Changes: ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -184,7 +184,7 @@ fixStgRegStmt platform stmt = fixAssign $ mapExpDeep fixExpr stmt -- NB: to ensure type correctness we need to ensure the Add -- as well as the Int need to be of the same size as the -- register. - case reg `elem` activeStgRegs platform of + case globalRegUseGlobalReg reg `elem` activeStgRegs platform of True -> expr False -> CmmMachOp (MO_Add (cmmRegWidth platform greg)) [ fixExpr (CmmReg greg), View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f437af101316fcdea7c8351868394cd53b2b132 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f437af101316fcdea7c8351868394cd53b2b132 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 10:57:00 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 09 Oct 2023 06:57:00 -0400 Subject: [Git][ghc/ghc][wip/T17910] 2 commits: Wibbles (comments etc) Message-ID: <6523dc7cbf65e_1b931c341374bc161174@gitlab.mail> Simon Peyton Jones pushed to branch wip/T17910 at Glasgow Haskell Compiler / GHC Commits: db318730 by Simon Peyton Jones at 2023-10-09T10:54:40+01:00 Wibbles (comments etc) and remove shrinking of LargeRecord - - - - - 3ffe97ea by Simon Peyton Jones at 2023-10-09T11:56:33+01:00 Inline naturally occurring top level 'build's - - - - - 3 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - testsuite/tests/perf/compiler/LargeRecord.hs Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -231,7 +231,7 @@ typeOneShot ty -- See Note [The state-transformer hack] in "GHC.Core.Opt.Arity" idStateHackOneShotInfo :: Id -> OneShotInfo idStateHackOneShotInfo id - = case idOneShotInfo id of + = case idOneShotInfo id of -- Test idOneShotInfo first because it is fast OneShotLam -> OneShotLam NoOneShotInfo | isStateHackType (idType id) -> OneShotLam | otherwise -> NoOneShotInfo ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1423,8 +1423,14 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env one_occ OneOcc{ occ_n_br = 1, occ_in_lam = in_lam, occ_int_cxt = int_cxt } | is_value_lam rhs, IsInteresting <- int_cxt = True - | NotInsideLam <- in_lam -- Once things are flattened to top level, don't - , not (isTopLevel top_lvl) -- re-inline them. See Note [Floating to the top] + | NotInsideLam <- in_lam + , not (isTopLevel top_lvl) || not (exprIsExpandable rhs) + -- Inline used-once things; except expandable things at top level + -- These may arise from user code e.g. + -- x = [1,2,3] + -- y = length x -- Want this to fuse + -- Real world example: the [1..] in 'preparse' in nofibl/real/cacheprof + -- See Note [Floating to the top] = True | otherwise = False @@ -1436,7 +1442,6 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env {- one_occ OneOcc{ occ_n_br = 1 - , occ_in_lam = NotInsideLam } = isNotTopLevel top_lvl || early_phase one_occ OneOcc{ occ_n_br = 1 , occ_in_lam = IsInsideLam ===================================== testsuite/tests/perf/compiler/LargeRecord.hs ===================================== @@ -60,7 +60,6 @@ type BigFieldList = '[ "f1" := Int , "f2" := Int , "f3" := Int -{- , "f4" := Int , "f5" := Int , "f6" := Int @@ -73,7 +72,6 @@ type BigFieldList = , "f13" := Int , "f14" := Int , "f15" := Int --} ] bigRec :: Record BigFieldList @@ -81,7 +79,6 @@ bigRec = #f1 := 1 & #f2 := 2 & #f3 := 3 -{- & #f4 := 4 & #f5 := 5 & #f6 := 6 @@ -94,7 +91,6 @@ bigRec = & #f13 := 13 & #f14 := 14 & #f15 := 15 --} & rnil main :: IO () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b4ce235a1871c89e61ad2d218f5673bff6e0a902...3ffe97ea452cd9aa8c4a4233c4c7b1994aaa81ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b4ce235a1871c89e61ad2d218f5673bff6e0a902...3ffe97ea452cd9aa8c4a4233c4c7b1994aaa81ce You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 12:03:46 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Mon, 09 Oct 2023 08:03:46 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-Wloopy-superclass-solve Message-ID: <6523ec22885db_1b931c3598b2841730cd@gitlab.mail> Matthew Craven pushed new branch wip/fix-Wloopy-superclass-solve at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-Wloopy-superclass-solve You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 12:06:04 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Oct 2023 08:06:04 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 2 commits: fix source dist Message-ID: <6523ecacaeae1_1b931c357994941749fb@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: cca0c584 by Matthew Pickering at 2023-10-09T13:05:45+01:00 fix source dist - - - - - bcf28efa by Matthew Pickering at 2023-10-09T13:05:45+01:00 MP: HACK? Use the target file for building things on the host when host=target Perhaps another way to achieve this is to copy the target target file on top of the host when host=target. - - - - - 2 changed files: - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Rules/SourceDist.hs Changes: ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -100,7 +100,15 @@ getBuildTarget = getTargetConfig buildTargetFile -- | Get the host target configuration through 'getTargetConfig' getHostTarget :: Action Toolchain.Target -getHostTarget = getTargetConfig hostTargetFile +getHostTarget = do + -- MP: If we are not cross compiling then we should use the target file in order to + -- build things for the host, in particular we want to use the configured values for the + -- target for building the RTS (ie are we using Libffi for adjustors, and the wordsize) + ht <- getTargetConfig hostTargetFile + tt <- getTargetConfig targetTargetFile + if (Toolchain.targetPlatformTriple ht) == (Toolchain.targetPlatformTriple tt) + then return tt + else return ht -- where -- msg = "The host's target configuration file " ++ quote hostTargetFile ++ " does not exist! ghc-toolchain might have failed to generate it." ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -156,7 +156,7 @@ prepareTree dest = do , pkgPath terminfo -/- "configure" , "configure" , "aclocal.m4" - , "mk" -/- "config.h.in" ] + ] copyAlexHappyFiles = forM_ alexHappyFiles $ \(stg, pkg, inp, out) -> do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8c6538db02b9f463883902f5411066bd0944a20...bcf28efa32a93b82e0690697cca74935700e13ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8c6538db02b9f463883902f5411066bd0944a20...bcf28efa32a93b82e0690697cca74935700e13ed You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 12:22:28 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 09 Oct 2023 08:22:28 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24064 Message-ID: <6523f084821bc_1b931c364884981755e4@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/T24064 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24064 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 12:35:55 2023 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Mon, 09 Oct 2023 08:35:55 -0400 Subject: [Git][ghc/ghc][wip/stability-flag] WIP Message-ID: <6523f3abede35_1b931c3683552818169d@gitlab.mail> Josh Meredith pushed to branch wip/stability-flag at Glasgow Haskell Compiler / GHC Commits: ed0ddfc6 by Josh Meredith at 2023-10-09T23:35:41+11:00 WIP - - - - - 5 changed files: - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Stability.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Types/Stability.hs Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -137,6 +137,7 @@ import GHC.Driver.Config.Diagnostic import GHC.Driver.Config.Tidy import GHC.Driver.Hooks import GHC.Driver.GenerateCgIPEStub (generateCgIPEStub, lookupEstimatedTicks) +import GHC.Driver.Stability import GHC.Runtime.Context import GHC.Runtime.Interpreter @@ -1098,12 +1099,14 @@ hscDesugarAndSimplify summary (FrontendTypecheck tc_result) tc_warnings mb_old_h (cg_guts, details) <- liftIO $ hscTidy hsc_env simplified_guts - !partial_iface <- + stability <- checkStability_ hsc_env (mg_deps simplified_guts) (mg_module simplified_guts) + + let !partial_iface = {-# SCC "GHC.Driver.Main.mkPartialIface" #-} -- This `force` saves 2M residency in test T10370 -- See Note [Avoiding space leaks in toIface*] for details. - liftIO $ force <$> - mkPartialIface hsc_env (cg_binds cg_guts) details summary simplified_guts + force $ + mkPartialIface hsc_env (cg_binds cg_guts) details summary stability simplified_guts return HscRecomp { hscs_guts = cg_guts, hscs_mod_location = ms_location summary, ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -517,7 +517,17 @@ setSafeHaskell s = updM f _ -> return $ dfs { safeHaskell = safeM } setStability :: String -> DynP () -setStability "experimental" = updM (\d -> return $ d { stabilityMode = StabilityExperimental }) + +setStability "experimental" = updM setExperimental + where + setExperimental d = case stabilityMode d of + StabilityRestricted StabilityExperimental + -> panic "Cannot set -std=experimental with -std=-experimental" + _ + -> return d { stabilityMode = StabilityNonstable StabilityExperimental} + +setStability "-experimental" = updM (\d -> return $ d { stabilityMode = StabilityRestricted StabilityExperimental }) + setStability l = addErr $ "Unknown stability level: " ++ l -- | Are all direct imports required to be safe for this Safe Haskell mode? ===================================== compiler/GHC/Driver/Stability.hs ===================================== @@ -1,6 +1,8 @@ +{-# LANGUAGE LambdaCase #-} + module GHC.Driver.Stability ( - checkStability, + checkStability, checkStability_, module GHC.Types.Stability @@ -9,6 +11,7 @@ module GHC.Driver.Stability ( import GHC.Driver.DynFlags import GHC.Driver.Env import GHC.LanguageExtensions +import GHC.Tc.Module import GHC.Types.Stability import GHC.Unit.Module.Deps import GHC.Unit.Module.Env @@ -20,26 +23,42 @@ import GHC.Unit.Types import GHC.Data.EnumSet as EnumSet import GHC.IORef +import GHC.Utils.Panic import qualified Data.Set as Set import Data.List (singleton) import Data.Maybe +import Control.Monad.IO.Class + import GHC.Prelude extensionStability :: Extension -> StabilityMode extensionStability _ = StabilityDefault +checkStability_ :: MonadIO m => HscEnv -> Dependencies -> Module -> m StabilityMode +checkStability_ hsc_env deps m = liftIO (checkStability hsc_env deps m) >>= \case + Just s -> return s + Nothing -> panic $ "Failed stability check for " ++ (show $ moduleName m) + checkStability :: HscEnv -> Dependencies -> Module -> IO (Maybe StabilityMode) checkStability hsc_env deps m = do - external_graph <- hscEPS hsc_env - let - home_graph = hsc_HUG hsc_env - hu_deps = hptSomeThingsBelowUs (singleton . mi_stability . hm_iface) - True hsc_env (moduleUnitId m) (GWIB (moduleName m) NotBoot) + ifaceMs <- mapM (getModuleInterface hsc_env) dep_mods + let ifaces = catMaybes $ map snd ifaceMs + + -- external_graph <- hscEPS hsc_env + -- let + -- home_graph = hsc_HUG hsc_env + -- hu_deps = hptSomeThingsBelowUs (singleton . mi_stability . hm_iface) + -- True hsc_env (moduleUnitId m) (GWIB (moduleName m) IsBoot) - return $ checkStability' flagMode exts (hu_deps ++ []) + return $ checkStability' flagMode exts (map mi_stability ifaces) where + dep_mods = catMaybes + . map toModule + $ Set.toList (dep_direct_mods deps) + toModule (_ , GWIB _ IsBoot ) = Nothing + toModule (uid, GWIB m NotBoot) = Just $ Module (RealUnit $ Definite uid) m dflags = hsc_dflags hsc_env flagMode = stabilityMode dflags exts = EnumSet.toList $ extensionFlags dflags ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -108,9 +108,10 @@ mkPartialIface :: HscEnv -> CoreProgram -> ModDetails -> ModSummary + -> StabilityMode -> ModGuts - -> IO PartialModIface -mkPartialIface hsc_env core_prog mod_details mod_summary + -> PartialModIface +mkPartialIface hsc_env core_prog mod_details mod_summary stability_mode ModGuts{ mg_module = this_mod , mg_hsc_src = hsc_src , mg_usages = usages @@ -125,7 +126,7 @@ mkPartialIface hsc_env core_prog mod_details mod_summary , mg_docs = docs } = mkIface_ hsc_env this_mod core_prog hsc_src used_th deps rdr_env fix_env warns hpc_info self_trust - safe_mode usages docs mod_summary mod_details + safe_mode stability_mode usages docs mod_summary mod_details -- | Fully instantiate an interface. Adds fingerprints and potentially code -- generator produced information. @@ -232,12 +233,14 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program docs <- extractDocs (ms_hspp_opts mod_summary) tc_result - partial_iface <- mkIface_ hsc_env + stability_mode <- checkStability_ hsc_env deps this_mod + + let partial_iface = mkIface_ hsc_env this_mod (fromMaybe [] mb_program) hsc_src used_th deps rdr_env fix_env warns hpc_info - (imp_trust_own_pkg imports) safe_mode usages - docs mod_summary + (imp_trust_own_pkg imports) safe_mode stability_mode + usages docs mod_summary mod_details mkFullIface hsc_env partial_iface Nothing Nothing @@ -247,14 +250,15 @@ mkIface_ :: HscEnv -> Module -> CoreProgram -> HscSource -> NameEnv FixItem -> Warnings GhcRn -> HpcInfo -> Bool -> SafeHaskellMode + -> StabilityMode -> [Usage] -> Maybe Docs -> ModSummary -> ModDetails - -> IO PartialModIface + -> PartialModIface mkIface_ hsc_env this_mod core_prog hsc_src used_th deps rdr_env fix_env src_warns - hpc_info pkg_trust_req safe_mode usages + hpc_info pkg_trust_req safe_mode stability_mode usages docs mod_summary ModDetails{ md_insts = insts, md_fam_insts = fam_insts, @@ -303,11 +307,8 @@ mkIface_ hsc_env annotations = map mkIfaceAnnotation anns icomplete_matches = map mkIfaceCompleteMatch complete_matches !rdrs = maybeGlobalRdrEnv rdr_env - stability <- checkStability hsc_env deps this_mod >>= \case - Just s -> return s - Nothing -> panic $ "Failed stability check for " ++ (show $ ms_mod_name mod_summary) - return ModIface { + ModIface { mi_module = this_mod, -- Need to record this because it depends on the -instantiated-with flag -- which could change @@ -335,7 +336,7 @@ mkIface_ hsc_env mi_hpc = isHpcUsed hpc_info, mi_trust = trust_info, mi_trust_pkg = pkg_trust_req, - mi_stability = stability, + mi_stability = stability_mode, mi_complete_matches = icomplete_matches, mi_docs = docs, mi_final_exts = (), ===================================== compiler/GHC/Types/Stability.hs ===================================== @@ -1,15 +1,27 @@ +{-# LANGUAGE LambdaCase #-} + module GHC.Types.Stability where import GHC.Utils.Binary import GHC.Prelude - data StabilityMode - = StabilityDefault - | StabilityExperimental + = StabilityDefault + | StabilityRestricted ExperimentalLevel + | StabilityNonstable ExperimentalLevel + deriving (Eq, Ord) + +data ExperimentalLevel + = StabilityExperimental deriving (Enum, Eq, Ord) instance Binary StabilityMode where - put_ bh m = putByte bh (fromIntegral (fromEnum m)) - get bh = do m <- getByte bh; return $! (toEnum (fromIntegral m)) \ No newline at end of file + put_ bh = \case + StabilityDefault -> putByte bh 0 + StabilityRestricted StabilityExperimental -> putByte bh 1 + StabilityNonstable StabilityExperimental -> putByte bh 2 + get bh = getByte bh >>= return . \case + 0 -> StabilityDefault + 1 -> StabilityRestricted StabilityExperimental + 2 -> StabilityNonstable StabilityExperimental \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed0ddfc6bec549def09e46420b0755b177ea75eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed0ddfc6bec549def09e46420b0755b177ea75eb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 13:04:21 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 09 Oct 2023 09:04:21 -0400 Subject: [Git][ghc/ghc][wip/libbin] hadrian: Build all executables in bin/ folder Message-ID: <6523fa55c9dc6_1b931c373f29881853d3@gitlab.mail> Matthew Pickering pushed to branch wip/libbin at Glasgow Haskell Compiler / GHC Commits: 56d4f184 by Matthew Pickering at 2023-10-09T14:03:42+01:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - 6 changed files: - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Packages.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs - m4/fp_settings.m4 Changes: ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -38,7 +38,7 @@ initSettings top_dir = do let installed :: FilePath -> FilePath installed file = top_dir file libexec :: FilePath -> FilePath - libexec file = top_dir "bin" file + libexec file = top_dir ".." "bin" file settingsFile = installed "settings" readFileSafe :: FilePath -> ExceptT SettingsError m String ===================================== hadrian/bindist/Makefile ===================================== @@ -117,7 +117,7 @@ lib/settings : config.mk @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ - @echo ',("unlit command", "$$topdir/bin/$(CrossCompilePrefix)unlit")' >> $@ + @echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@ @echo ',("target os", "$(HaskellTargetOs)")' >> $@ @@ -188,7 +188,6 @@ install_lib: lib/settings $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ esac; \ done; \ - chmod ugo+rx "$$dest"/bin/* # Work around #17418 on Darwin if [ -e "${XATTR}" ]; then \ "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ ===================================== hadrian/src/Packages.hs ===================================== @@ -202,14 +202,8 @@ programName Context {..} = do -- | The 'FilePath' to a program executable in a given 'Context'. programPath :: Context -> Action FilePath programPath context at Context {..} = do - -- TODO: The @touchy@ utility lives in the @lib/bin@ directory instead of - -- @bin@, which is likely just a historical accident that should be fixed. - -- See: https://github.com/snowleopard/hadrian/issues/570 - -- Likewise for @iserv@ and @unlit at . name <- programName context - path <- if package `elem` [iserv, touchy, unlit] - then stageLibPath stage <&> (-/- "bin") - else stageBinPath stage + path <- stageBinPath stage return $ path -/- name <.> exe -- TODO: Move @timeout@ to the @util@ directory and build in a more standard ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -469,7 +469,7 @@ generateSettings = do , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand) , ("windres command", queryTarget (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me. - , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) + , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) , ("cross compiling", expr $ yesNo <$> flag CrossCompiling) , ("target platform string", queryTarget targetPlatformTriple) , ("target os", queryTarget (show . archOS_OS . tgtArchOs)) ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -38,7 +38,7 @@ buildProgramRules rs = do -- Rules for programs that are actually built by hadrian. forM_ allStages $ \stage -> [ root -/- stageString stage -/- "bin" -/- "*" - , root -/- stageString stage -/- "lib/bin" -/- "*" ] |%> \bin -> do + ] |%> \bin -> do programContexts <- getProgramContexts stage case lookupProgramContext bin programContexts of Nothing -> error $ "Unknown program " ++ show bin @@ -105,9 +105,6 @@ buildProgram bin ctx@(Context{..}) rs = do (True, s) | s > stage0InTree -> do srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin")) copyFile (srcDir -/- takeFileName bin) bin - (False, s) | s > stage0InTree && (package `elem` [touchy, unlit]) -> do - srcDir <- stageLibPath stage0InTree <&> (-/- "bin") - copyFile (srcDir -/- takeFileName bin) bin _ -> buildBinary rs bin ctx buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action () ===================================== m4/fp_settings.m4 ===================================== @@ -75,7 +75,7 @@ AC_DEFUN([FP_SETTINGS], fi if test "$HostOS" = "mingw32"; then - SettingsTouchCommand='$$topdir/bin/touchy.exe' + SettingsTouchCommand='$$topdir/../bin/touchy.exe' else SettingsTouchCommand='touch' fi @@ -109,7 +109,7 @@ AC_DEFUN([FP_SETTINGS], SUBST_TOOLDIR([SettingsArCommand]) SUBST_TOOLDIR([SettingsRanlibCommand]) SUBST_TOOLDIR([SettingsWindresCommand]) - SettingsTouchCommand='$$topdir/bin/touchy.exe' + SettingsTouchCommand='$$topdir/../bin/touchy.exe' fi # LLVM backend tools View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/56d4f18418dc8d9f524b765adbb19c1655184e40 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/56d4f18418dc8d9f524b765adbb19c1655184e40 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 14:15:52 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Oct 2023 10:15:52 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Do not use O_NONBLOCK on regular files or block devices Message-ID: <65240b18466f7_1b931c38f1c3e41920a3@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 986c1a4d by Alan Zimmerman at 2023-10-09T10:15:40-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - a703f290 by Ben Gamari at 2023-10-09T10:15:40-04:00 Bump unix submodule to v2.8.3.0 - - - - - 16 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/ThToHs.hs - hadrian/src/Rules/SourceDist.hs - libraries/base/GHC/IO/FD.hs - libraries/base/changelog.md - libraries/unix - testsuite/tests/hpc/T17073.stdout - utils/check-exact/Orphans.hs - utils/check-exact/Utils.hs - utils/hpc Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2187,6 +2187,6 @@ type instance Anno FastString = SrcAnn NoEpAnns type instance Anno (DotFieldOcc (GhcPass p)) = SrcAnn NoEpAnns -instance (Anno a ~ SrcSpanAnn' (EpAnn an)) +instance (Anno a ~ SrcSpanAnn' (EpAnn an), NoAnn an) => WrapXRec (GhcPass p) a where wrapXRec = noLocA ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -108,6 +108,7 @@ type instance Anno Name = SrcSpanAnnN type instance Anno Id = SrcSpanAnnN type IsSrcSpanAnn p a = ( Anno (IdGhcP p) ~ SrcSpanAnn' (EpAnn a), + NoAnn a, IsPass p) instance UnXRec (GhcPass p) where ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -541,7 +541,7 @@ mkHsOpTy prom ty1 op ty2 = HsOpTy noAnn prom ty1 op ty2 mkHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppTy t1 t2 - = addCLocAA t1 t2 (HsAppTy noExtField t1 (parenthesizeHsType appPrec t2)) + = addCLocA t1 t2 (HsAppTy noExtField t1 (parenthesizeHsType appPrec t2)) mkHsAppTys :: LHsType (GhcPass p) -> [LHsType (GhcPass p)] -> LHsType (GhcPass p) @@ -550,7 +550,7 @@ mkHsAppTys = foldl' mkHsAppTy mkHsAppKindTy :: LHsType (GhcPass p) -> LHsToken "@" (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppKindTy ty at k - = addCLocAA ty k (HsAppKindTy noExtField ty at k) + = addCLocA ty k (HsAppKindTy noExtField ty at k) {- ************************************************************************ ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -232,14 +232,14 @@ mkLamCaseMatchGroup origin lam_variant (L l matches) = mkMatchGroup origin (L l $ map fixCtxt matches) where fixCtxt (L a match) = L a match{m_ctxt = LamAlt lam_variant} -mkLocatedList :: Semigroup a +mkLocatedList :: (Semigroup a, NoAnn an) => [GenLocated (SrcAnn a) e2] -> LocatedAn an [GenLocated (SrcAnn a) e2] mkLocatedList ms = case nonEmpty ms of Nothing -> noLocA [] Just ms1 -> L (noAnnSrcSpan $ locA $ combineLocsA (NE.head ms1) (NE.last ms1)) ms mkHsApp :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -mkHsApp e1 e2 = addCLocAA e1 e2 (HsApp noComments e1 e2) +mkHsApp e1 e2 = addCLocA e1 e2 (HsApp noComments e1 e2) mkHsAppWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) @@ -250,7 +250,7 @@ mkHsAppWith mkLocated e1 e2 = mkLocated e1 e2 (HsApp noAnn e1 e2) mkHsApps :: LHsExpr (GhcPass id) -> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id) -mkHsApps = mkHsAppsWith addCLocAA +mkHsApps = mkHsAppsWith addCLocA mkHsAppsWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) @@ -260,7 +260,7 @@ mkHsAppsWith mkHsAppsWith mkLocated = foldl' (mkHsAppWith mkLocated) mkHsAppType :: LHsExpr GhcRn -> LHsWcType GhcRn -> LHsExpr GhcRn -mkHsAppType e t = addCLocAA t_body e (HsAppType noExtField e noHsTok paren_wct) +mkHsAppType e t = addCLocA t_body e (HsAppType noExtField e noHsTok paren_wct) where t_body = hswc_body t paren_wct = t { hswc_body = parenthesizeHsType appPrec t_body } @@ -1832,5 +1832,3 @@ rec_field_expl_impl rec_flds (RecFieldsDotDot { .. }) = ImplicitFieldBinders { implFlBndr_field = foExt fld , implFlBndr_binders = collectPatBinders CollNoDictBinders rhs } - - ===================================== compiler/GHC/Parser.y ===================================== @@ -4120,7 +4120,7 @@ sL1 :: HasLoc a => a -> b -> Located b sL1 x = sL (getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1a #-} -sL1a :: HasLoc a => a -> b -> LocatedAn t b +sL1a :: (HasLoc a, HasAnnotation t) => a -> b -> GenLocated t b sL1a x = sL (noAnnSrcSpan $ getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1n #-} @@ -4132,7 +4132,7 @@ sLL :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c sLL x y = sL (comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLa #-} -sLLa :: (HasLoc a, HasLoc b) => a -> b -> c -> LocatedAn t c +sLLa :: (HasLoc a, HasLoc b, NoAnn t) => a -> b -> c -> LocatedAn t c sLLa x y = sL (noAnnSrcSpan $ comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLl #-} ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -71,13 +71,14 @@ module GHC.Parser.Annotation ( mapLocA, combineLocsA, combineSrcSpansA, - addCLocA, addCLocAA, + addCLocA, -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. - noLocA, getLocA, + HasAnnotation(..), + noLocA, + getLocA, noSrcSpanA, - noAnnSrcSpan, -- ** Working with comments in annotations noComments, comment, addCommentsToSrcAnn, setCommentsSrcAnn, @@ -994,15 +995,15 @@ la2na l = noAnnSrcSpan (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -la2la :: LocatedAn ann1 a2 -> LocatedAn ann2 a2 +la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 la2la (L la a) = L (noAnnSrcSpan (locA la)) a l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = noAnnSrcSpan (locA l) +l2l l = SrcSpanAnn EpAnnNotUsed (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -na2la :: SrcSpanAnn' a -> SrcAnn ann +na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) reLoc :: LocatedAn a e -> Located e @@ -1022,18 +1023,21 @@ reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- -noLocA :: a -> LocatedAn an a -noLocA = L (SrcSpanAnn EpAnnNotUsed noSrcSpan) +class HasAnnotation e where + noAnnSrcSpan :: SrcSpan -> e + +instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where + noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l + +noLocA :: (HasAnnotation e) => a -> GenLocated e a +noLocA = L (noAnnSrcSpan noSrcSpan) getLocA :: GenLocated (SrcSpanAnn' a) e -> SrcSpan getLocA = getHasLoc -noSrcSpanA :: SrcAnn ann +noSrcSpanA :: (HasAnnotation e) => e noSrcSpanA = noAnnSrcSpan noSrcSpan -noAnnSrcSpan :: SrcSpan -> SrcAnn ann -noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l - -- --------------------------------------------------------------------- class NoAnn a where @@ -1163,7 +1167,7 @@ epAnnComments (EpAnn _ _ cs) = cs sortLocatedA :: [GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e] sortLocatedA = sortBy (leftmost_smallest `on` getLocA) -mapLocA :: (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b +mapLocA :: (NoAnn ann) => (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b mapLocA f (L l a) = L (noAnnSrcSpan l) (f a) -- AZ:TODO: move this somewhere sane @@ -1179,11 +1183,9 @@ combineSrcSpansA (SrcSpanAnn aa la) (SrcSpanAnn ab lb) SrcSpanAnn (EpAnn (widenAnchorR anc (realSrcSpan l)) an cs) l -- | Combine locations from two 'Located' things and add them to a third thing -addCLocA :: GenLocated (SrcSpanAnn' a) e1 -> GenLocated SrcSpan e2 -> e3 -> GenLocated (SrcAnn ann) e3 -addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (getLoc b)) c - -addCLocAA :: GenLocated (SrcSpanAnn' a1) e1 -> GenLocated (SrcSpanAnn' a2) e2 -> e3 -> GenLocated (SrcAnn ann) e3 -addCLocAA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (locA $ getLoc b)) c +addCLocA :: (HasLoc a, HasLoc b, HasAnnotation l) + => a -> b -> c -> GenLocated l c +addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (getHasLoc a) (getHasLoc b)) c -- --------------------------------------------------------------------- -- Utilities for manipulating EpAnnComments @@ -1332,26 +1334,33 @@ instance Semigroup EpAnnComments where EpaCommentsBalanced cs1 as1 <> EpaCommentsBalanced cs2 as2 = EpaCommentsBalanced (cs1 ++ cs2) (as1++as2) -instance NoAnn NoEpAnns where - noAnn = NoEpAnns - instance Semigroup AnnListItem where (AnnListItem l1) <> (AnnListItem l2) = AnnListItem (l1 <> l2) -instance NoAnn AnnListItem where - noAnn = AnnListItem [] - - instance Semigroup (AnnSortKey tag) where NoAnnSortKey <> x = x x <> NoAnnSortKey = x AnnSortKey ls1 <> AnnSortKey ls2 = AnnSortKey (ls1 <> ls2) +instance Monoid (AnnSortKey tag) where + mempty = NoAnnSortKey + +-- --------------------------------------------------------------------- +-- NoAnn instances + +instance NoAnn NoEpAnns where + noAnn = NoEpAnns + +instance NoAnn AnnListItem where + noAnn = AnnListItem [] + +instance NoAnn AnnContext where + noAnn = AnnContext Nothing [] [] + instance NoAnn AnnList where noAnn = AnnList Nothing Nothing Nothing [] [] -instance Monoid (AnnSortKey tag) where - mempty = NoAnnSortKey +-- --------------------------------------------------------------------- instance NoAnn NameAnn where noAnn = NameAnnTrailing [] ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -714,7 +714,7 @@ checkCTupSize tup_size * * ********************************************************************* -} -wrapGenSpan :: a -> LocatedAn an a +wrapGenSpan :: (NoAnn an) => a -> LocatedAn an a -- Wrap something in a "generatedSrcSpan" -- See Note [Rebindable syntax and HsExpansion] wrapGenSpan x = L (noAnnSrcSpan generatedSrcSpan) x @@ -742,10 +742,10 @@ genHsVar nm = HsVar noExtField $ wrapGenSpan nm genAppType :: HsExpr GhcRn -> HsType (NoGhcTc GhcRn) -> HsExpr GhcRn genAppType expr ty = HsAppType noExtField (wrapGenSpan expr) noHsTok (mkEmptyWildCardBndrs (wrapGenSpan ty)) -genLHsLit :: HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) +genLHsLit :: (NoAnn an) => HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) genLHsLit = wrapGenSpan . HsLit noAnn -genHsIntegralLit :: IntegralLit -> LocatedAn an (HsExpr GhcRn) +genHsIntegralLit :: (NoAnn an) => IntegralLit -> LocatedAn an (HsExpr GhcRn) genHsIntegralLit = genLHsLit . HsInt noExtField genHsTyLit :: FastString -> HsType GhcRn @@ -767,11 +767,15 @@ genWildPat = wrapGenSpan $ WildPat noExtField genSimpleFunBind :: Name -> [LPat GhcRn] -> LHsExpr GhcRn -> LHsBind GhcRn genSimpleFunBind fun pats expr - = L gen $ genFunBind (L gen fun) - [mkMatch (mkPrefixFunRhs (L gen fun)) pats expr + = L genA $ genFunBind (L genN fun) + [mkMatch (mkPrefixFunRhs (L genN fun)) pats expr emptyLocalBinds] where - gen = noAnnSrcSpan generatedSrcSpan + genA :: SrcSpanAnnA + genA = noAnnSrcSpan generatedSrcSpan + + genN :: SrcSpanAnnN + genN = noAnnSrcSpan generatedSrcSpan genFunBind :: LocatedN Name -> [LMatch GhcRn (LHsExpr GhcRn)] -> HsBind GhcRn ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -142,13 +142,13 @@ getL = CvtM (\_ loc -> Right (loc,loc)) setL :: SrcSpan -> CvtM () setL loc = CvtM (\_ _ -> Right (loc, ())) -returnLA :: e -> CvtM (LocatedAn ann e) +returnLA :: (NoAnn ann) => e -> CvtM (LocatedAn ann e) returnLA x = CvtM (\_ loc -> Right (loc, L (noAnnSrcSpan loc) x)) returnJustLA :: a -> CvtM (Maybe (LocatedA a)) returnJustLA = fmap Just . returnLA -wrapParLA :: (LocatedAn ann a -> b) -> a -> CvtM b +wrapParLA :: (NoAnn ann) => (LocatedAn ann a -> b) -> a -> CvtM b wrapParLA add_par x = CvtM (\_ loc -> Right (loc, add_par (L (noAnnSrcSpan loc) x))) wrapMsg :: ThingBeingConverted -> CvtM' ConversionFailReason a -> CvtM' RunSpliceFailReason a ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -184,7 +184,7 @@ prepareTree dest = do , (stage0InTree , compiler, "GHC/Parser.y", "GHC/Parser.hs") , (stage0InTree , compiler, "GHC/Parser/Lexer.x", "GHC/Parser/Lexer.hs") , (stage0InTree , compiler, "GHC/Parser/HaddockLex.x", "GHC/Parser/HaddockLex.hs") - , (stage0InTree , hpcBin, "src/HpcParser.y", "src/HpcParser.hs") + , (stage0InTree , hpcBin, "src/Trace/Hpc/Parser.y", "src/Trace/Hpc/Parser.hs") , (stage0InTree , genprimopcode, "Parser.y", "Parser.hs") , (stage0InTree , genprimopcode, "Lexer.x", "Lexer.hs") , (stage0InTree , cabalSyntax , "src/Distribution/Fields/Lexer.x", "src/Distribution/Fields/Lexer.hs") ===================================== libraries/base/GHC/IO/FD.hs ===================================== @@ -82,13 +82,19 @@ clampReadSize = min 0x7ffff000 data FD = FD { fdFD :: {-# UNPACK #-} !CInt, #if defined(mingw32_HOST_OS) - -- On Windows, a socket file descriptor needs to be read and written + -- | On Windows, a socket file descriptor needs to be read and written -- using different functions (send/recv). fdIsSocket_ :: {-# UNPACK #-} !Int #else - -- On Unix we need to know whether this FD has O_NONBLOCK set. - -- If it has, then we can use more efficient routines to read/write to it. - -- It is always safe for this to be off. + -- | On Unix we need to know whether this 'FD' has @O_NONBLOCK@ set. + -- If it has, then we can use more efficient routines (namely, unsafe FFI) + -- to read/write to it. Otherwise safe FFI is used. + -- + -- @O_NONBLOCK@ has no effect on regular files and block devices at the moment, + -- thus this flag should be off for them. While reading from a file cannot + -- block indefinitely (as opposed to reading from a socket or a pipe), it can block + -- the entire runtime for a "brief" moment of time: you cannot read a file from + -- a floppy drive or network share without delay. fdIsNonBlocking :: {-# UNPACK #-} !Int #endif } @@ -197,6 +203,9 @@ openFileWith :: FilePath -- ^ file to open -> IOMode -- ^ mode in which to open the file -> Bool -- ^ open the file in non-blocking mode? + -- This has no effect on regular files and block devices: + -- they are always opened in blocking mode. + -- See 'fdIsNonBlocking' for more discussion. -> (FD -> IODeviceType -> IO r) -- ^ @act1@: An action to perform -- on the file descriptor with the masking state -- restored and an exception handler that closes @@ -332,7 +341,11 @@ mkFD fd iomode mb_stat is_socket is_nonblock = do return (FD{ fdFD = fd, #if !defined(mingw32_HOST_OS) - fdIsNonBlocking = fromEnum is_nonblock + -- As https://man7.org/linux/man-pages/man2/open.2.html explains, + -- O_NONBLOCK has no effect on regular files and block devices; + -- utilities inspecting fdIsNonBlocking (such as readRawBufferPtr) + -- should not be tricked to think otherwise. + fdIsNonBlocking = fromEnum (is_nonblock && fd_type /= RegularFile && fd_type /= RawDevice) #else fdIsSocket_ = fromEnum is_socket #endif @@ -452,11 +465,19 @@ dup2 fd fdto = do setNonBlockingMode :: FD -> Bool -> IO FD setNonBlockingMode fd set = do - setNonBlockingFD (fdFD fd) set + -- This mirrors the behaviour of mkFD: + -- O_NONBLOCK has no effect on regular files and block devices; + -- utilities inspecting fdIsNonBlocking (such as readRawBufferPtr) + -- should not be tricked to think otherwise. + is_nonblock <- if set then do + (fd_type, _, _) <- fdStat (fdFD fd) + pure $ fd_type /= RegularFile && fd_type /= RawDevice + else pure False + setNonBlockingFD (fdFD fd) is_nonblock #if defined(mingw32_HOST_OS) return fd #else - return fd{ fdIsNonBlocking = fromEnum set } + return fd{ fdIsNonBlocking = fromEnum is_nonblock } #endif ready :: FD -> Bool -> Int -> IO Bool ===================================== libraries/base/changelog.md ===================================== @@ -5,6 +5,9 @@ * Add a `RULE` to `Prelude.lookup`, allowing it to participate in list fusion ([CLC proposal #174](https://github.com/haskell/core-libraries-committee/issues/175)) * The `Enum Int64` and `Enum Word64` instances now use native operations on 32-bit platforms, increasing performance by up to 1.5x on i386 and up to 5.6x with the JavaScript backend. ([CLC proposal #187](https://github.com/haskell/core-libraries-committee/issues/187)) * Update to [Unicode 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/). + * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` + * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. + ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) ## 4.19.0.0 *TBA* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3f0d217b5b3de5ccec54154d5cd5c7b0d07708df +Subproject commit 5211c230903aee8c09485e8246993e2a1eb74563 ===================================== testsuite/tests/hpc/T17073.stdout ===================================== @@ -7,7 +7,7 @@ 100% alternatives used (0/0) 100% local declarations used (0/0) 100% top-level declarations used (1/1) -hpc tools, version 0.68 +hpc tools, version 0.69 Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html ===================================== utils/check-exact/Orphans.hs ===================================== @@ -62,9 +62,6 @@ instance NoAnn AddEpAnn where instance NoAnn AnnKeywordId where noAnn = Annlarrowtail {- gotta pick one -} -instance NoAnn AnnContext where - noAnn = AnnContext Nothing [] [] - instance NoAnn EpAnnSumPat where noAnn = EpAnnSumPat noAnn noAnn noAnn ===================================== utils/check-exact/Utils.hs ===================================== @@ -371,9 +371,9 @@ setAnchorHsModule hsmod anc cs = hsmod { hsmodExt = (hsmodExt hsmod) {hsmodAnn = -- |Version of l2l that preserves the anchor, immportant if it has an -- updated AnchorOperation -moveAnchor :: Monoid b => SrcAnn a -> SrcAnn b +moveAnchor :: NoAnn b => SrcAnn a -> SrcAnn b moveAnchor (SrcSpanAnn EpAnnNotUsed l) = noAnnSrcSpan l -moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc mempty cs) l +moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc noAnn cs) l -- --------------------------------------------------------------------- ===================================== utils/hpc ===================================== @@ -1 +1 @@ -Subproject commit 2d75eb33d4c179b1c21000d32c2906ad273de0de +Subproject commit 4b46380a06c16e38a5b9d623ab85538ee4b2319d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36ef67208607261d445263e9579355b4fc57ca58...a703f29084c7e4580bf9f55a5b8ed5a6d87a5566 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36ef67208607261d445263e9579355b4fc57ca58...a703f29084c7e4580bf9f55a5b8ed5a6d87a5566 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 14:56:51 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 09 Oct 2023 10:56:51 -0400 Subject: [Git][ghc/ghc][ghc-9.8] 2 commits: hadrian: Fix hpc parser path Message-ID: <652414b331212_1b931c3a4c4f842058db@gitlab.mail> Ben Gamari pushed to branch ghc-9.8 at Glasgow Haskell Compiler / GHC Commits: b2d15ab1 by Ben Gamari at 2023-10-06T21:45:48-04:00 hadrian: Fix hpc parser path - - - - - 443e870d by Ben Gamari at 2023-10-06T21:45:48-04:00 Release GHC 9.8.1 - - - - - 2 changed files: - configure.ac - hadrian/src/Rules/SourceDist.hs Changes: ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.0], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -22,7 +22,7 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.8.0], [glasgow-has AC_CONFIG_MACRO_DIRS([m4]) # Set this to YES for a released version, otherwise NO -: ${RELEASE=NO} +: ${RELEASE=YES} # The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line # above. If this is not a released version, then we will append the ===================================== hadrian/src/Rules/SourceDist.hs ===================================== @@ -184,7 +184,7 @@ prepareTree dest = do , (stage0InTree , compiler, "GHC/Parser.y", "GHC/Parser.hs") , (stage0InTree , compiler, "GHC/Parser/Lexer.x", "GHC/Parser/Lexer.hs") , (stage0InTree , compiler, "GHC/Parser/HaddockLex.x", "GHC/Parser/HaddockLex.hs") - , (stage0InTree , hpcBin, "src/HpcParser.y", "src/HpcParser.hs") + , (stage0InTree , hpcBin, "src/Trace/Hpc/Parser.y", "src/Trace/Hpc/Parser.hs") , (stage0InTree , genprimopcode, "Parser.y", "Parser.hs") , (stage0InTree , genprimopcode, "Lexer.x", "Lexer.hs") ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bda60b3ae47b6d718e7652722560e6944209a364...443e870d977b1ab6fc05f47a9a17bc49296adbd6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bda60b3ae47b6d718e7652722560e6944209a364...443e870d977b1ab6fc05f47a9a17bc49296adbd6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 16:41:20 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 09 Oct 2023 12:41:20 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 286 commits: Serialize CmmRetInfo in .rodata Message-ID: <65242d30860e3_1b931c3c18adbc2161a@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - ec5314a5 by Simon Peyton Jones at 2023-10-09T17:30:03+01:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 37ea9daf by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The net result is good: a 2% improvement in compile time. The table below shows changes over 1%. The main changes are: * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * When making join points, don't do so if the join point is so small it will immediately be inlined. See Note [Duplicating alternatives] * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * Many new or rewritten Notes. E.g. Note [Avoiding simplifying repeatedly] I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I added an INLINE pragma to it. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -4.3% GOOD LargeRecord(normal) -23.3% GOOD PmSeriesS(normal) -2.4% T11195(normal) -1.7% T12227(normal) -20.0% GOOD T12545(normal) -5.4% T13253-spj(normal) -50.7% GOOD T13386(normal) -5.1% GOOD T14766(normal) -2.4% GOOD T15164(normal) -1.7% T15304(normal) +1.0% T15630(normal) -7.7% T15630a(normal) NEW T15703(normal) -7.5% GOOD T16577(normal) -5.1% GOOD T17516(normal) -3.6% T18223(normal) -16.8% GOOD T18282(normal) -1.5% T18304(normal) +1.9% T21839c(normal) -3.5% GOOD T3064(normal) -1.5% T5030(normal) -16.2% GOOD T5321Fun(normal) -1.6% T6048(optasm) -2.1% GOOD T8095(normal) -6.1% GOOD T9630(normal) -5.1% GOOD WWRec(normal) -1.6% geo. mean -2.1% minimum -50.7% maximum +1.9% Metric Decrease: CoOpt_Singletons LargeRecord T12227 T13253-spj T13386 T14766 T15703 T16577 T18223 T21839c T5030 T6048 T8095 T9630 - - - - - a57fd42c by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 Improve postInlineUnconditionally This commit adds two things to postInlineUnconditionally: 1. Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. 2. Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. - - - - - 498d8293 by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 Update testsuite output - - - - - 4a16ecd9 by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 Try effect of * making multi-branch cases not work free (fixes #22423) * use plan A for dataToTag and tagToEnum - - - - - 6517a2ff by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 More changes * No floating at all for join points * Never inline j x = I x Example: integerSignum !j = IS (integerSignum# j) We want this to inline and then cancel with an enclosing case. But it won't if we have changed it to integerSignum x = case x of IN a -> IS (...) IS b -> IS (...) IP c -> IS (...) This involved changing - UnfoldingGuidance to not say always-inline for j x = Ix - callSiteInline to inline join points only if there is a real benefit - ok_to_dup_alt in Simplify.Iteration * Row back (for now) on changes to GHC.Core.Utils.ExprIsCheap - - - - - 4c867702 by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 Wibble - - - - - f875ef1c by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 Wibble - - - - - 7514e8de by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 Further wibbles - - - - - cb5f2a8e by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 One more wibble Don't float an unlifted join point - - - - - af4f30b1 by Simon Peyton Jones at 2023-10-09T17:31:06+01:00 Small wibbles The most significant change is to mkSelCo. - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/generate-ci/generate-job-metadata - .gitlab/generate-ci/generate-jobs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitlab/test-metrics.sh - README.md - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7aa729774b16bf33ce3dbb4f2cfb69f9ec35e706...af4f30b1f4f21f02d8c4f6ce778a7453832239b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7aa729774b16bf33ce3dbb4f2cfb69f9ec35e706...af4f30b1f4f21f02d8c4f6ce778a7453832239b3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 9 21:17:18 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 09 Oct 2023 17:17:18 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-9.8.1-release Message-ID: <65246dde79e5f_1b931c4279588c2265de@gitlab.mail> Ben Gamari pushed new tag ghc-9.8.1-release at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.8.1-release You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 01:36:27 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Oct 2023 21:36:27 -0400 Subject: [Git][ghc/ghc][master] EPA: Introduce HasAnnotation class Message-ID: <6524aa9b47269_1b931c491f2270246498@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 10 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/ThToHs.hs - utils/check-exact/Orphans.hs - utils/check-exact/Utils.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2187,6 +2187,6 @@ type instance Anno FastString = SrcAnn NoEpAnns type instance Anno (DotFieldOcc (GhcPass p)) = SrcAnn NoEpAnns -instance (Anno a ~ SrcSpanAnn' (EpAnn an)) +instance (Anno a ~ SrcSpanAnn' (EpAnn an), NoAnn an) => WrapXRec (GhcPass p) a where wrapXRec = noLocA ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -108,6 +108,7 @@ type instance Anno Name = SrcSpanAnnN type instance Anno Id = SrcSpanAnnN type IsSrcSpanAnn p a = ( Anno (IdGhcP p) ~ SrcSpanAnn' (EpAnn a), + NoAnn a, IsPass p) instance UnXRec (GhcPass p) where ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -541,7 +541,7 @@ mkHsOpTy prom ty1 op ty2 = HsOpTy noAnn prom ty1 op ty2 mkHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppTy t1 t2 - = addCLocAA t1 t2 (HsAppTy noExtField t1 (parenthesizeHsType appPrec t2)) + = addCLocA t1 t2 (HsAppTy noExtField t1 (parenthesizeHsType appPrec t2)) mkHsAppTys :: LHsType (GhcPass p) -> [LHsType (GhcPass p)] -> LHsType (GhcPass p) @@ -550,7 +550,7 @@ mkHsAppTys = foldl' mkHsAppTy mkHsAppKindTy :: LHsType (GhcPass p) -> LHsToken "@" (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppKindTy ty at k - = addCLocAA ty k (HsAppKindTy noExtField ty at k) + = addCLocA ty k (HsAppKindTy noExtField ty at k) {- ************************************************************************ ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -232,14 +232,14 @@ mkLamCaseMatchGroup origin lam_variant (L l matches) = mkMatchGroup origin (L l $ map fixCtxt matches) where fixCtxt (L a match) = L a match{m_ctxt = LamAlt lam_variant} -mkLocatedList :: Semigroup a +mkLocatedList :: (Semigroup a, NoAnn an) => [GenLocated (SrcAnn a) e2] -> LocatedAn an [GenLocated (SrcAnn a) e2] mkLocatedList ms = case nonEmpty ms of Nothing -> noLocA [] Just ms1 -> L (noAnnSrcSpan $ locA $ combineLocsA (NE.head ms1) (NE.last ms1)) ms mkHsApp :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -mkHsApp e1 e2 = addCLocAA e1 e2 (HsApp noComments e1 e2) +mkHsApp e1 e2 = addCLocA e1 e2 (HsApp noComments e1 e2) mkHsAppWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) @@ -250,7 +250,7 @@ mkHsAppWith mkLocated e1 e2 = mkLocated e1 e2 (HsApp noAnn e1 e2) mkHsApps :: LHsExpr (GhcPass id) -> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id) -mkHsApps = mkHsAppsWith addCLocAA +mkHsApps = mkHsAppsWith addCLocA mkHsAppsWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) @@ -260,7 +260,7 @@ mkHsAppsWith mkHsAppsWith mkLocated = foldl' (mkHsAppWith mkLocated) mkHsAppType :: LHsExpr GhcRn -> LHsWcType GhcRn -> LHsExpr GhcRn -mkHsAppType e t = addCLocAA t_body e (HsAppType noExtField e noHsTok paren_wct) +mkHsAppType e t = addCLocA t_body e (HsAppType noExtField e noHsTok paren_wct) where t_body = hswc_body t paren_wct = t { hswc_body = parenthesizeHsType appPrec t_body } @@ -1832,5 +1832,3 @@ rec_field_expl_impl rec_flds (RecFieldsDotDot { .. }) = ImplicitFieldBinders { implFlBndr_field = foExt fld , implFlBndr_binders = collectPatBinders CollNoDictBinders rhs } - - ===================================== compiler/GHC/Parser.y ===================================== @@ -4120,7 +4120,7 @@ sL1 :: HasLoc a => a -> b -> Located b sL1 x = sL (getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1a #-} -sL1a :: HasLoc a => a -> b -> LocatedAn t b +sL1a :: (HasLoc a, HasAnnotation t) => a -> b -> GenLocated t b sL1a x = sL (noAnnSrcSpan $ getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1n #-} @@ -4132,7 +4132,7 @@ sLL :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c sLL x y = sL (comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLa #-} -sLLa :: (HasLoc a, HasLoc b) => a -> b -> c -> LocatedAn t c +sLLa :: (HasLoc a, HasLoc b, NoAnn t) => a -> b -> c -> LocatedAn t c sLLa x y = sL (noAnnSrcSpan $ comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLl #-} ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -71,13 +71,14 @@ module GHC.Parser.Annotation ( mapLocA, combineLocsA, combineSrcSpansA, - addCLocA, addCLocAA, + addCLocA, -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. - noLocA, getLocA, + HasAnnotation(..), + noLocA, + getLocA, noSrcSpanA, - noAnnSrcSpan, -- ** Working with comments in annotations noComments, comment, addCommentsToSrcAnn, setCommentsSrcAnn, @@ -994,15 +995,15 @@ la2na l = noAnnSrcSpan (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -la2la :: LocatedAn ann1 a2 -> LocatedAn ann2 a2 +la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 la2la (L la a) = L (noAnnSrcSpan (locA la)) a l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = noAnnSrcSpan (locA l) +l2l l = SrcSpanAnn EpAnnNotUsed (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -na2la :: SrcSpanAnn' a -> SrcAnn ann +na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) reLoc :: LocatedAn a e -> Located e @@ -1022,18 +1023,21 @@ reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- -noLocA :: a -> LocatedAn an a -noLocA = L (SrcSpanAnn EpAnnNotUsed noSrcSpan) +class HasAnnotation e where + noAnnSrcSpan :: SrcSpan -> e + +instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where + noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l + +noLocA :: (HasAnnotation e) => a -> GenLocated e a +noLocA = L (noAnnSrcSpan noSrcSpan) getLocA :: GenLocated (SrcSpanAnn' a) e -> SrcSpan getLocA = getHasLoc -noSrcSpanA :: SrcAnn ann +noSrcSpanA :: (HasAnnotation e) => e noSrcSpanA = noAnnSrcSpan noSrcSpan -noAnnSrcSpan :: SrcSpan -> SrcAnn ann -noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l - -- --------------------------------------------------------------------- class NoAnn a where @@ -1163,7 +1167,7 @@ epAnnComments (EpAnn _ _ cs) = cs sortLocatedA :: [GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e] sortLocatedA = sortBy (leftmost_smallest `on` getLocA) -mapLocA :: (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b +mapLocA :: (NoAnn ann) => (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b mapLocA f (L l a) = L (noAnnSrcSpan l) (f a) -- AZ:TODO: move this somewhere sane @@ -1179,11 +1183,9 @@ combineSrcSpansA (SrcSpanAnn aa la) (SrcSpanAnn ab lb) SrcSpanAnn (EpAnn (widenAnchorR anc (realSrcSpan l)) an cs) l -- | Combine locations from two 'Located' things and add them to a third thing -addCLocA :: GenLocated (SrcSpanAnn' a) e1 -> GenLocated SrcSpan e2 -> e3 -> GenLocated (SrcAnn ann) e3 -addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (getLoc b)) c - -addCLocAA :: GenLocated (SrcSpanAnn' a1) e1 -> GenLocated (SrcSpanAnn' a2) e2 -> e3 -> GenLocated (SrcAnn ann) e3 -addCLocAA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (locA $ getLoc b)) c +addCLocA :: (HasLoc a, HasLoc b, HasAnnotation l) + => a -> b -> c -> GenLocated l c +addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (getHasLoc a) (getHasLoc b)) c -- --------------------------------------------------------------------- -- Utilities for manipulating EpAnnComments @@ -1332,26 +1334,33 @@ instance Semigroup EpAnnComments where EpaCommentsBalanced cs1 as1 <> EpaCommentsBalanced cs2 as2 = EpaCommentsBalanced (cs1 ++ cs2) (as1++as2) -instance NoAnn NoEpAnns where - noAnn = NoEpAnns - instance Semigroup AnnListItem where (AnnListItem l1) <> (AnnListItem l2) = AnnListItem (l1 <> l2) -instance NoAnn AnnListItem where - noAnn = AnnListItem [] - - instance Semigroup (AnnSortKey tag) where NoAnnSortKey <> x = x x <> NoAnnSortKey = x AnnSortKey ls1 <> AnnSortKey ls2 = AnnSortKey (ls1 <> ls2) +instance Monoid (AnnSortKey tag) where + mempty = NoAnnSortKey + +-- --------------------------------------------------------------------- +-- NoAnn instances + +instance NoAnn NoEpAnns where + noAnn = NoEpAnns + +instance NoAnn AnnListItem where + noAnn = AnnListItem [] + +instance NoAnn AnnContext where + noAnn = AnnContext Nothing [] [] + instance NoAnn AnnList where noAnn = AnnList Nothing Nothing Nothing [] [] -instance Monoid (AnnSortKey tag) where - mempty = NoAnnSortKey +-- --------------------------------------------------------------------- instance NoAnn NameAnn where noAnn = NameAnnTrailing [] ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -714,7 +714,7 @@ checkCTupSize tup_size * * ********************************************************************* -} -wrapGenSpan :: a -> LocatedAn an a +wrapGenSpan :: (NoAnn an) => a -> LocatedAn an a -- Wrap something in a "generatedSrcSpan" -- See Note [Rebindable syntax and HsExpansion] wrapGenSpan x = L (noAnnSrcSpan generatedSrcSpan) x @@ -742,10 +742,10 @@ genHsVar nm = HsVar noExtField $ wrapGenSpan nm genAppType :: HsExpr GhcRn -> HsType (NoGhcTc GhcRn) -> HsExpr GhcRn genAppType expr ty = HsAppType noExtField (wrapGenSpan expr) noHsTok (mkEmptyWildCardBndrs (wrapGenSpan ty)) -genLHsLit :: HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) +genLHsLit :: (NoAnn an) => HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) genLHsLit = wrapGenSpan . HsLit noAnn -genHsIntegralLit :: IntegralLit -> LocatedAn an (HsExpr GhcRn) +genHsIntegralLit :: (NoAnn an) => IntegralLit -> LocatedAn an (HsExpr GhcRn) genHsIntegralLit = genLHsLit . HsInt noExtField genHsTyLit :: FastString -> HsType GhcRn @@ -767,11 +767,15 @@ genWildPat = wrapGenSpan $ WildPat noExtField genSimpleFunBind :: Name -> [LPat GhcRn] -> LHsExpr GhcRn -> LHsBind GhcRn genSimpleFunBind fun pats expr - = L gen $ genFunBind (L gen fun) - [mkMatch (mkPrefixFunRhs (L gen fun)) pats expr + = L genA $ genFunBind (L genN fun) + [mkMatch (mkPrefixFunRhs (L genN fun)) pats expr emptyLocalBinds] where - gen = noAnnSrcSpan generatedSrcSpan + genA :: SrcSpanAnnA + genA = noAnnSrcSpan generatedSrcSpan + + genN :: SrcSpanAnnN + genN = noAnnSrcSpan generatedSrcSpan genFunBind :: LocatedN Name -> [LMatch GhcRn (LHsExpr GhcRn)] -> HsBind GhcRn ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -142,13 +142,13 @@ getL = CvtM (\_ loc -> Right (loc,loc)) setL :: SrcSpan -> CvtM () setL loc = CvtM (\_ _ -> Right (loc, ())) -returnLA :: e -> CvtM (LocatedAn ann e) +returnLA :: (NoAnn ann) => e -> CvtM (LocatedAn ann e) returnLA x = CvtM (\_ loc -> Right (loc, L (noAnnSrcSpan loc) x)) returnJustLA :: a -> CvtM (Maybe (LocatedA a)) returnJustLA = fmap Just . returnLA -wrapParLA :: (LocatedAn ann a -> b) -> a -> CvtM b +wrapParLA :: (NoAnn ann) => (LocatedAn ann a -> b) -> a -> CvtM b wrapParLA add_par x = CvtM (\_ loc -> Right (loc, add_par (L (noAnnSrcSpan loc) x))) wrapMsg :: ThingBeingConverted -> CvtM' ConversionFailReason a -> CvtM' RunSpliceFailReason a ===================================== utils/check-exact/Orphans.hs ===================================== @@ -62,9 +62,6 @@ instance NoAnn AddEpAnn where instance NoAnn AnnKeywordId where noAnn = Annlarrowtail {- gotta pick one -} -instance NoAnn AnnContext where - noAnn = AnnContext Nothing [] [] - instance NoAnn EpAnnSumPat where noAnn = EpAnnSumPat noAnn noAnn noAnn ===================================== utils/check-exact/Utils.hs ===================================== @@ -371,9 +371,9 @@ setAnchorHsModule hsmod anc cs = hsmod { hsmodExt = (hsmodExt hsmod) {hsmodAnn = -- |Version of l2l that preserves the anchor, immportant if it has an -- updated AnchorOperation -moveAnchor :: Monoid b => SrcAnn a -> SrcAnn b +moveAnchor :: NoAnn b => SrcAnn a -> SrcAnn b moveAnchor (SrcSpanAnn EpAnnNotUsed l) = noAnnSrcSpan l -moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc mempty cs) l +moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc noAnn cs) l -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/94066d583dbbaa2bc4768d57da4c96c0bbe7fb3f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/94066d583dbbaa2bc4768d57da4c96c0bbe7fb3f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 01:37:03 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Oct 2023 21:37:03 -0400 Subject: [Git][ghc/ghc][master] Bump unix submodule to v2.8.3.0 Message-ID: <6524aabf5002f_1b931c49016d982496c4@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - 1 changed file: - libraries/unix Changes: ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3f0d217b5b3de5ccec54154d5cd5c7b0d07708df +Subproject commit 5211c230903aee8c09485e8246993e2a1eb74563 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8792a1bc704ceb16892f5bed7b2a21a559e0e908 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8792a1bc704ceb16892f5bed7b2a21a559e0e908 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 02:08:12 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 09 Oct 2023 22:08:12 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: EPA: Introduce HasAnnotation class Message-ID: <6524b20c95de1_1b931c4a6120e825233b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - 6b62df36 by Sebastian Graf at 2023-10-09T22:07:38-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - 9bea471d by doyougnu at 2023-10-09T22:07:53-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - e37a1a3c by Matthew Craven at 2023-10-09T22:07:53-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - 16 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Types.hs - libraries/unix - utils/check-exact/Orphans.hs - utils/check-exact/Utils.hs Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -604,6 +604,7 @@ data Rule = ReleaseOnly -- ^ Only run this job in a release pipeline data ValidateRule = FullCI -- ^ Run this job when the "full-ci" label is present. | LLVMBackend -- ^ Run this job when the "LLVM backend" label is present + | JSBackend -- ^ Run this job when the "javascript" label is present | FreeBSDLabel -- ^ Run this job when the "FreeBSD" label is set. | NonmovingGc -- ^ Run this job when the "non-moving GC" label is set. | IpeData -- ^ Run this job when the "IPE" label is set @@ -648,11 +649,12 @@ validateRuleString FullCI = or_all ([ labelString "full-ci" , branchStringLike "ghc-[0-9]+\\.[0-9]+" ]) -validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString JSBackend = labelString "javascript" validateRuleString FreeBSDLabel = labelString "FreeBSD" -validateRuleString NonmovingGc = labelString "non-moving GC" -validateRuleString IpeData = labelString "IPE" -validateRuleString TestPrimops = labelString "test-primops" +validateRuleString NonmovingGc = labelString "non-moving GC" +validateRuleString IpeData = labelString "IPE" +validateRuleString TestPrimops = labelString "test-primops" -- | A 'Job' is the description of a single job in a gitlab pipeline. The -- job contains all the information about how to do the build but can be further @@ -1010,10 +1012,9 @@ job_groups = , disableValidate (standardBuildsWithConfig AArch64 (Linux Alpine318) (splitSectionsBroken vanilla)) , fullyStaticBrokenTests (disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine312) staticNativeInt))) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure") - ) - { bignumBackend = Native - } + + , addValidateRule JSBackend (validateBuilds Amd64 (Linux Debian11) javascriptConfig) + , make_wasm_jobs wasm_build_config , modifyValidateJobs manual $ make_wasm_jobs wasm_build_config {bignumBackend = Native} @@ -1024,6 +1025,8 @@ job_groups = ] where + javascriptConfig = (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure")) + { bignumBackend = Native } -- ghcilink002 broken due to #17869 -- ===================================== .gitlab/jobs.yaml ===================================== @@ -5255,7 +5255,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -695,7 +695,7 @@ data WarningFlag = | Opt_WarnIncompleteRecordSelectors -- Since 9.10 | Opt_WarnBadlyStagedTypes -- Since 9.10 | Opt_WarnInconsistentFlags -- Since 9.8 - deriving (Eq, Ord, Show, Enum) + deriving (Eq, Ord, Show, Enum, Bounded) -- | Return the names of a WarningFlag -- ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2165,127 +2165,125 @@ wWarningFlags :: [FlagSpec WarningFlag] wWarningFlags = map snd (sortBy (comparing fst) wWarningFlagsDeps) wWarningFlagsDeps :: [(Deprecation, FlagSpec WarningFlag)] -wWarningFlagsDeps = mconcat [ +wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of -- See Note [Updating flag description in the User's Guide] -- See Note [Supporting CLI completion] --- Please keep the list of flags below sorted alphabetically - warnSpec Opt_WarnAlternativeLayoutRuleTransitional, - warnSpec Opt_WarnAmbiguousFields, - depWarnSpec Opt_WarnAutoOrphans - "it has no effect", - warnSpec Opt_WarnCPPUndef, - warnSpec Opt_WarnUnbangedStrictPatterns, - warnSpec Opt_WarnDeferredTypeErrors, - warnSpec Opt_WarnDeferredOutOfScopeVariables, - warnSpec Opt_WarnDeprecatedFlags, - warnSpec Opt_WarnDerivingDefaults, - warnSpec Opt_WarnDerivingTypeable, - warnSpec Opt_WarnDodgyExports, - warnSpec Opt_WarnDodgyForeignImports, - warnSpec Opt_WarnDodgyImports, - warnSpec Opt_WarnEmptyEnumerations, - subWarnSpec "duplicate-constraints" - Opt_WarnDuplicateConstraints - "it is subsumed by -Wredundant-constraints", - warnSpec Opt_WarnRedundantConstraints, - warnSpec Opt_WarnDuplicateExports, - depWarnSpec Opt_WarnHiShadows - "it is not used, and was never implemented", - warnSpec Opt_WarnInaccessibleCode, - warnSpec Opt_WarnImplicitPrelude, - depWarnSpec Opt_WarnImplicitKindVars - "it is now an error", - warnSpec Opt_WarnIncompletePatterns, - warnSpec Opt_WarnIncompletePatternsRecUpd, - warnSpec Opt_WarnIncompleteUniPatterns, - warnSpec Opt_WarnInlineRuleShadowing, - warnSpec Opt_WarnIdentities, - warnSpec Opt_WarnMissingFields, - warnSpec Opt_WarnMissingImportList, - warnSpec Opt_WarnMissingExportList, - subWarnSpec "missing-local-sigs" - Opt_WarnMissingLocalSignatures - "it is replaced by -Wmissing-local-signatures", - warnSpec Opt_WarnMissingLocalSignatures, - warnSpec Opt_WarnMissingMethods, - depWarnSpec Opt_WarnMissingMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnSemigroup, - warnSpec Opt_WarnMissingSignatures, - warnSpec Opt_WarnMissingKindSignatures, - warnSpec Opt_WarnMissingPolyKindSignatures, - subWarnSpec "missing-exported-sigs" - Opt_WarnMissingExportedSignatures - "it is replaced by -Wmissing-exported-signatures", - warnSpec Opt_WarnMissingExportedSignatures, - warnSpec Opt_WarnMonomorphism, - warnSpec Opt_WarnNameShadowing, - warnSpec Opt_WarnNonCanonicalMonadInstances, - depWarnSpec Opt_WarnNonCanonicalMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnNonCanonicalMonoidInstances, - warnSpec Opt_WarnOrphans, - warnSpec Opt_WarnOverflowedLiterals, - warnSpec Opt_WarnOverlappingPatterns, - warnSpec Opt_WarnMissedSpecs, - warnSpec Opt_WarnAllMissedSpecs, - warnSpec' Opt_WarnSafe setWarnSafe, - warnSpec Opt_WarnTrustworthySafe, - warnSpec Opt_WarnInferredSafeImports, - warnSpec Opt_WarnMissingSafeHaskellMode, - warnSpec Opt_WarnTabs, - warnSpec Opt_WarnTypeDefaults, - warnSpec Opt_WarnTypedHoles, - warnSpec Opt_WarnPartialTypeSignatures, - warnSpec Opt_WarnUnrecognisedPragmas, - warnSpec Opt_WarnMisplacedPragmas, - warnSpec' Opt_WarnUnsafe setWarnUnsafe, - warnSpec Opt_WarnUnsupportedCallingConventions, - warnSpec Opt_WarnUnsupportedLlvmVersion, - warnSpec Opt_WarnMissedExtraSharedLib, - warnSpec Opt_WarnUntickedPromotedConstructors, - warnSpec Opt_WarnUnusedDoBind, - warnSpec Opt_WarnUnusedForalls, - warnSpec Opt_WarnUnusedImports, - warnSpec Opt_WarnUnusedLocalBinds, - warnSpec Opt_WarnUnusedMatches, - warnSpec Opt_WarnUnusedPatternBinds, - warnSpec Opt_WarnUnusedTopBinds, - warnSpec Opt_WarnUnusedTypePatterns, - warnSpec Opt_WarnUnusedRecordWildcards, - warnSpec Opt_WarnRedundantBangPatterns, - warnSpec Opt_WarnRedundantRecordWildcards, - warnSpec Opt_WarnRedundantStrictnessFlags, - warnSpec Opt_WarnWrongDoBind, - warnSpec Opt_WarnMissingPatternSynonymSignatures, - warnSpec Opt_WarnMissingDerivingStrategies, - warnSpec Opt_WarnSimplifiableClassConstraints, - warnSpec Opt_WarnMissingHomeModules, - warnSpec Opt_WarnUnrecognisedWarningFlags, - warnSpec Opt_WarnStarBinder, - warnSpec Opt_WarnStarIsType, - depWarnSpec Opt_WarnSpaceAfterBang - "bang patterns can no longer be written with a space", - warnSpec Opt_WarnPartialFields, - warnSpec Opt_WarnPrepositiveQualifiedModule, - warnSpec Opt_WarnUnusedPackages, - warnSpec Opt_WarnCompatUnqualifiedImports, - warnSpec Opt_WarnInvalidHaddock, - warnSpec Opt_WarnOperatorWhitespaceExtConflict, - warnSpec Opt_WarnOperatorWhitespace, - warnSpec Opt_WarnImplicitLift, - warnSpec Opt_WarnMissingExportedPatternSynonymSignatures, - warnSpec Opt_WarnForallIdentifier, - warnSpec Opt_WarnUnicodeBidirectionalFormatCharacters, - warnSpec Opt_WarnGADTMonoLocalBinds, - warnSpec Opt_WarnTypeEqualityOutOfScope, - warnSpec Opt_WarnTypeEqualityRequiresOperators, - warnSpec Opt_WarnTermVariableCapture, - warnSpec Opt_WarnMissingRoleAnnotations, - warnSpec Opt_WarnImplicitRhsQuantification, - warnSpec Opt_WarnIncompleteExportWarnings, - warnSpec Opt_WarnIncompleteRecordSelectors - ] + Opt_WarnAlternativeLayoutRuleTransitional -> warnSpec x + Opt_WarnAmbiguousFields -> warnSpec x + Opt_WarnAutoOrphans -> depWarnSpec x "it has no effect" + Opt_WarnCPPUndef -> warnSpec x + Opt_WarnBadlyStagedTypes -> warnSpec x + Opt_WarnUnbangedStrictPatterns -> warnSpec x + Opt_WarnDeferredTypeErrors -> warnSpec x + Opt_WarnDeferredOutOfScopeVariables -> warnSpec x + Opt_WarnDeprecatedFlags -> warnSpec x + Opt_WarnDerivingDefaults -> warnSpec x + Opt_WarnDerivingTypeable -> warnSpec x + Opt_WarnDodgyExports -> warnSpec x + Opt_WarnDodgyForeignImports -> warnSpec x + Opt_WarnDodgyImports -> warnSpec x + Opt_WarnEmptyEnumerations -> warnSpec x + Opt_WarnDuplicateConstraints + -> subWarnSpec "duplicate-constraints" x "it is subsumed by -Wredundant-constraints" + Opt_WarnRedundantConstraints -> warnSpec x + Opt_WarnDuplicateExports -> warnSpec x + Opt_WarnHiShadows + -> depWarnSpec x "it is not used, and was never implemented" + Opt_WarnInaccessibleCode -> warnSpec x + Opt_WarnImplicitPrelude -> warnSpec x + Opt_WarnImplicitKindVars -> depWarnSpec x "it is now an error" + Opt_WarnIncompletePatterns -> warnSpec x + Opt_WarnIncompletePatternsRecUpd -> warnSpec x + Opt_WarnIncompleteUniPatterns -> warnSpec x + Opt_WarnInconsistentFlags -> warnSpec x + Opt_WarnInlineRuleShadowing -> warnSpec x + Opt_WarnIdentities -> warnSpec x + Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnMissingFields -> warnSpec x + Opt_WarnMissingImportList -> warnSpec x + Opt_WarnMissingExportList -> warnSpec x + Opt_WarnMissingLocalSignatures + -> subWarnSpec "missing-local-sigs" x + "it is replaced by -Wmissing-local-signatures" + ++ warnSpec x + Opt_WarnMissingMethods -> warnSpec x + Opt_WarnMissingMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnSemigroup -> warnSpec x + Opt_WarnMissingSignatures -> warnSpec x + Opt_WarnMissingKindSignatures -> warnSpec x + Opt_WarnMissingPolyKindSignatures -> warnSpec x + Opt_WarnMissingExportedSignatures + -> subWarnSpec "missing-exported-sigs" x + "it is replaced by -Wmissing-exported-signatures" + ++ warnSpec x + Opt_WarnMonomorphism -> warnSpec x + Opt_WarnNameShadowing -> warnSpec x + Opt_WarnNonCanonicalMonadInstances -> warnSpec x + Opt_WarnNonCanonicalMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnNonCanonicalMonoidInstances -> warnSpec x + Opt_WarnOrphans -> warnSpec x + Opt_WarnOverflowedLiterals -> warnSpec x + Opt_WarnOverlappingPatterns -> warnSpec x + Opt_WarnMissedSpecs -> warnSpec x + Opt_WarnAllMissedSpecs -> warnSpec x + Opt_WarnSafe -> warnSpec' x setWarnSafe + Opt_WarnTrustworthySafe -> warnSpec x + Opt_WarnInferredSafeImports -> warnSpec x + Opt_WarnMissingSafeHaskellMode -> warnSpec x + Opt_WarnTabs -> warnSpec x + Opt_WarnTypeDefaults -> warnSpec x + Opt_WarnTypedHoles -> warnSpec x + Opt_WarnPartialTypeSignatures -> warnSpec x + Opt_WarnUnrecognisedPragmas -> warnSpec x + Opt_WarnMisplacedPragmas -> warnSpec x + Opt_WarnUnsafe -> warnSpec' x setWarnUnsafe + Opt_WarnUnsupportedCallingConventions -> warnSpec x + Opt_WarnUnsupportedLlvmVersion -> warnSpec x + Opt_WarnMissedExtraSharedLib -> warnSpec x + Opt_WarnUntickedPromotedConstructors -> warnSpec x + Opt_WarnUnusedDoBind -> warnSpec x + Opt_WarnUnusedForalls -> warnSpec x + Opt_WarnUnusedImports -> warnSpec x + Opt_WarnUnusedLocalBinds -> warnSpec x + Opt_WarnUnusedMatches -> warnSpec x + Opt_WarnUnusedPatternBinds -> warnSpec x + Opt_WarnUnusedTopBinds -> warnSpec x + Opt_WarnUnusedTypePatterns -> warnSpec x + Opt_WarnUnusedRecordWildcards -> warnSpec x + Opt_WarnRedundantBangPatterns -> warnSpec x + Opt_WarnRedundantRecordWildcards -> warnSpec x + Opt_WarnRedundantStrictnessFlags -> warnSpec x + Opt_WarnWrongDoBind -> warnSpec x + Opt_WarnMissingPatternSynonymSignatures -> warnSpec x + Opt_WarnMissingDerivingStrategies -> warnSpec x + Opt_WarnSimplifiableClassConstraints -> warnSpec x + Opt_WarnMissingHomeModules -> warnSpec x + Opt_WarnUnrecognisedWarningFlags -> warnSpec x + Opt_WarnStarBinder -> warnSpec x + Opt_WarnStarIsType -> warnSpec x + Opt_WarnSpaceAfterBang + -> depWarnSpec x "bang patterns can no longer be written with a space" + Opt_WarnPartialFields -> warnSpec x + Opt_WarnPrepositiveQualifiedModule -> warnSpec x + Opt_WarnUnusedPackages -> warnSpec x + Opt_WarnCompatUnqualifiedImports -> warnSpec x + Opt_WarnInvalidHaddock -> warnSpec x + Opt_WarnOperatorWhitespaceExtConflict -> warnSpec x + Opt_WarnOperatorWhitespace -> warnSpec x + Opt_WarnImplicitLift -> warnSpec x + Opt_WarnMissingExportedPatternSynonymSignatures -> warnSpec x + Opt_WarnForallIdentifier -> warnSpec x + Opt_WarnUnicodeBidirectionalFormatCharacters -> warnSpec x + Opt_WarnGADTMonoLocalBinds -> warnSpec x + Opt_WarnTypeEqualityOutOfScope -> warnSpec x + Opt_WarnTypeEqualityRequiresOperators -> warnSpec x + Opt_WarnTermVariableCapture -> warnSpec x + Opt_WarnMissingRoleAnnotations -> warnSpec x + Opt_WarnImplicitRhsQuantification -> warnSpec x + Opt_WarnIncompleteExportWarnings -> warnSpec x + Opt_WarnIncompleteRecordSelectors -> warnSpec x warningGroupsDeps :: [(Deprecation, FlagSpec WarningGroup)] warningGroupsDeps = map mk warningGroups ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -2187,6 +2187,6 @@ type instance Anno FastString = SrcAnn NoEpAnns type instance Anno (DotFieldOcc (GhcPass p)) = SrcAnn NoEpAnns -instance (Anno a ~ SrcSpanAnn' (EpAnn an)) +instance (Anno a ~ SrcSpanAnn' (EpAnn an), NoAnn an) => WrapXRec (GhcPass p) a where wrapXRec = noLocA ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -108,6 +108,7 @@ type instance Anno Name = SrcSpanAnnN type instance Anno Id = SrcSpanAnnN type IsSrcSpanAnn p a = ( Anno (IdGhcP p) ~ SrcSpanAnn' (EpAnn a), + NoAnn a, IsPass p) instance UnXRec (GhcPass p) where ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -541,7 +541,7 @@ mkHsOpTy prom ty1 op ty2 = HsOpTy noAnn prom ty1 op ty2 mkHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppTy t1 t2 - = addCLocAA t1 t2 (HsAppTy noExtField t1 (parenthesizeHsType appPrec t2)) + = addCLocA t1 t2 (HsAppTy noExtField t1 (parenthesizeHsType appPrec t2)) mkHsAppTys :: LHsType (GhcPass p) -> [LHsType (GhcPass p)] -> LHsType (GhcPass p) @@ -550,7 +550,7 @@ mkHsAppTys = foldl' mkHsAppTy mkHsAppKindTy :: LHsType (GhcPass p) -> LHsToken "@" (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppKindTy ty at k - = addCLocAA ty k (HsAppKindTy noExtField ty at k) + = addCLocA ty k (HsAppKindTy noExtField ty at k) {- ************************************************************************ ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -232,14 +232,14 @@ mkLamCaseMatchGroup origin lam_variant (L l matches) = mkMatchGroup origin (L l $ map fixCtxt matches) where fixCtxt (L a match) = L a match{m_ctxt = LamAlt lam_variant} -mkLocatedList :: Semigroup a +mkLocatedList :: (Semigroup a, NoAnn an) => [GenLocated (SrcAnn a) e2] -> LocatedAn an [GenLocated (SrcAnn a) e2] mkLocatedList ms = case nonEmpty ms of Nothing -> noLocA [] Just ms1 -> L (noAnnSrcSpan $ locA $ combineLocsA (NE.head ms1) (NE.last ms1)) ms mkHsApp :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -mkHsApp e1 e2 = addCLocAA e1 e2 (HsApp noComments e1 e2) +mkHsApp e1 e2 = addCLocA e1 e2 (HsApp noComments e1 e2) mkHsAppWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) @@ -250,7 +250,7 @@ mkHsAppWith mkLocated e1 e2 = mkLocated e1 e2 (HsApp noAnn e1 e2) mkHsApps :: LHsExpr (GhcPass id) -> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id) -mkHsApps = mkHsAppsWith addCLocAA +mkHsApps = mkHsAppsWith addCLocA mkHsAppsWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) @@ -260,7 +260,7 @@ mkHsAppsWith mkHsAppsWith mkLocated = foldl' (mkHsAppWith mkLocated) mkHsAppType :: LHsExpr GhcRn -> LHsWcType GhcRn -> LHsExpr GhcRn -mkHsAppType e t = addCLocAA t_body e (HsAppType noExtField e noHsTok paren_wct) +mkHsAppType e t = addCLocA t_body e (HsAppType noExtField e noHsTok paren_wct) where t_body = hswc_body t paren_wct = t { hswc_body = parenthesizeHsType appPrec t_body } @@ -1832,5 +1832,3 @@ rec_field_expl_impl rec_flds (RecFieldsDotDot { .. }) = ImplicitFieldBinders { implFlBndr_field = foExt fld , implFlBndr_binders = collectPatBinders CollNoDictBinders rhs } - - ===================================== compiler/GHC/Parser.y ===================================== @@ -4120,7 +4120,7 @@ sL1 :: HasLoc a => a -> b -> Located b sL1 x = sL (getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1a #-} -sL1a :: HasLoc a => a -> b -> LocatedAn t b +sL1a :: (HasLoc a, HasAnnotation t) => a -> b -> GenLocated t b sL1a x = sL (noAnnSrcSpan $ getHasLoc x) -- #define sL1 sL (getLoc $1) {-# INLINE sL1n #-} @@ -4132,7 +4132,7 @@ sLL :: (HasLoc a, HasLoc b) => a -> b -> c -> Located c sLL x y = sL (comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLa #-} -sLLa :: (HasLoc a, HasLoc b) => a -> b -> c -> LocatedAn t c +sLLa :: (HasLoc a, HasLoc b, NoAnn t) => a -> b -> c -> LocatedAn t c sLLa x y = sL (noAnnSrcSpan $ comb2 x y) -- #define LL sL (comb2 $1 $>) {-# INLINE sLLl #-} ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -71,13 +71,14 @@ module GHC.Parser.Annotation ( mapLocA, combineLocsA, combineSrcSpansA, - addCLocA, addCLocAA, + addCLocA, -- ** Constructing 'GenLocated' annotation types when we do not care -- about annotations. - noLocA, getLocA, + HasAnnotation(..), + noLocA, + getLocA, noSrcSpanA, - noAnnSrcSpan, -- ** Working with comments in annotations noComments, comment, addCommentsToSrcAnn, setCommentsSrcAnn, @@ -994,15 +995,15 @@ la2na l = noAnnSrcSpan (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -la2la :: LocatedAn ann1 a2 -> LocatedAn ann2 a2 +la2la :: (NoAnn ann2) => LocatedAn ann1 a2 -> LocatedAn ann2 a2 la2la (L la a) = L (noAnnSrcSpan (locA la)) a l2l :: SrcSpanAnn' a -> SrcAnn ann -l2l l = noAnnSrcSpan (locA l) +l2l l = SrcSpanAnn EpAnnNotUsed (locA l) -- |Helper function (temporary) during transition of names -- Discards any annotations -na2la :: SrcSpanAnn' a -> SrcAnn ann +na2la :: (NoAnn ann) => SrcSpanAnn' a -> SrcAnn ann na2la l = noAnnSrcSpan (locA l) reLoc :: LocatedAn a e -> Located e @@ -1022,18 +1023,21 @@ reLocN (L (SrcSpanAnn _ l) a) = L l a -- --------------------------------------------------------------------- -noLocA :: a -> LocatedAn an a -noLocA = L (SrcSpanAnn EpAnnNotUsed noSrcSpan) +class HasAnnotation e where + noAnnSrcSpan :: SrcSpan -> e + +instance (NoAnn ann) => HasAnnotation (SrcSpanAnn' (EpAnn ann)) where + noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l + +noLocA :: (HasAnnotation e) => a -> GenLocated e a +noLocA = L (noAnnSrcSpan noSrcSpan) getLocA :: GenLocated (SrcSpanAnn' a) e -> SrcSpan getLocA = getHasLoc -noSrcSpanA :: SrcAnn ann +noSrcSpanA :: (HasAnnotation e) => e noSrcSpanA = noAnnSrcSpan noSrcSpan -noAnnSrcSpan :: SrcSpan -> SrcAnn ann -noAnnSrcSpan l = SrcSpanAnn EpAnnNotUsed l - -- --------------------------------------------------------------------- class NoAnn a where @@ -1163,7 +1167,7 @@ epAnnComments (EpAnn _ _ cs) = cs sortLocatedA :: [GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e] sortLocatedA = sortBy (leftmost_smallest `on` getLocA) -mapLocA :: (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b +mapLocA :: (NoAnn ann) => (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b mapLocA f (L l a) = L (noAnnSrcSpan l) (f a) -- AZ:TODO: move this somewhere sane @@ -1179,11 +1183,9 @@ combineSrcSpansA (SrcSpanAnn aa la) (SrcSpanAnn ab lb) SrcSpanAnn (EpAnn (widenAnchorR anc (realSrcSpan l)) an cs) l -- | Combine locations from two 'Located' things and add them to a third thing -addCLocA :: GenLocated (SrcSpanAnn' a) e1 -> GenLocated SrcSpan e2 -> e3 -> GenLocated (SrcAnn ann) e3 -addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (getLoc b)) c - -addCLocAA :: GenLocated (SrcSpanAnn' a1) e1 -> GenLocated (SrcSpanAnn' a2) e2 -> e3 -> GenLocated (SrcAnn ann) e3 -addCLocAA a b c = L (noAnnSrcSpan $ combineSrcSpans (locA $ getLoc a) (locA $ getLoc b)) c +addCLocA :: (HasLoc a, HasLoc b, HasAnnotation l) + => a -> b -> c -> GenLocated l c +addCLocA a b c = L (noAnnSrcSpan $ combineSrcSpans (getHasLoc a) (getHasLoc b)) c -- --------------------------------------------------------------------- -- Utilities for manipulating EpAnnComments @@ -1332,26 +1334,33 @@ instance Semigroup EpAnnComments where EpaCommentsBalanced cs1 as1 <> EpaCommentsBalanced cs2 as2 = EpaCommentsBalanced (cs1 ++ cs2) (as1++as2) -instance NoAnn NoEpAnns where - noAnn = NoEpAnns - instance Semigroup AnnListItem where (AnnListItem l1) <> (AnnListItem l2) = AnnListItem (l1 <> l2) -instance NoAnn AnnListItem where - noAnn = AnnListItem [] - - instance Semigroup (AnnSortKey tag) where NoAnnSortKey <> x = x x <> NoAnnSortKey = x AnnSortKey ls1 <> AnnSortKey ls2 = AnnSortKey (ls1 <> ls2) +instance Monoid (AnnSortKey tag) where + mempty = NoAnnSortKey + +-- --------------------------------------------------------------------- +-- NoAnn instances + +instance NoAnn NoEpAnns where + noAnn = NoEpAnns + +instance NoAnn AnnListItem where + noAnn = AnnListItem [] + +instance NoAnn AnnContext where + noAnn = AnnContext Nothing [] [] + instance NoAnn AnnList where noAnn = AnnList Nothing Nothing Nothing [] [] -instance Monoid (AnnSortKey tag) where - mempty = NoAnnSortKey +-- --------------------------------------------------------------------- instance NoAnn NameAnn where noAnn = NameAnnTrailing [] ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -714,7 +714,7 @@ checkCTupSize tup_size * * ********************************************************************* -} -wrapGenSpan :: a -> LocatedAn an a +wrapGenSpan :: (NoAnn an) => a -> LocatedAn an a -- Wrap something in a "generatedSrcSpan" -- See Note [Rebindable syntax and HsExpansion] wrapGenSpan x = L (noAnnSrcSpan generatedSrcSpan) x @@ -742,10 +742,10 @@ genHsVar nm = HsVar noExtField $ wrapGenSpan nm genAppType :: HsExpr GhcRn -> HsType (NoGhcTc GhcRn) -> HsExpr GhcRn genAppType expr ty = HsAppType noExtField (wrapGenSpan expr) noHsTok (mkEmptyWildCardBndrs (wrapGenSpan ty)) -genLHsLit :: HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) +genLHsLit :: (NoAnn an) => HsLit GhcRn -> LocatedAn an (HsExpr GhcRn) genLHsLit = wrapGenSpan . HsLit noAnn -genHsIntegralLit :: IntegralLit -> LocatedAn an (HsExpr GhcRn) +genHsIntegralLit :: (NoAnn an) => IntegralLit -> LocatedAn an (HsExpr GhcRn) genHsIntegralLit = genLHsLit . HsInt noExtField genHsTyLit :: FastString -> HsType GhcRn @@ -767,11 +767,15 @@ genWildPat = wrapGenSpan $ WildPat noExtField genSimpleFunBind :: Name -> [LPat GhcRn] -> LHsExpr GhcRn -> LHsBind GhcRn genSimpleFunBind fun pats expr - = L gen $ genFunBind (L gen fun) - [mkMatch (mkPrefixFunRhs (L gen fun)) pats expr + = L genA $ genFunBind (L genN fun) + [mkMatch (mkPrefixFunRhs (L genN fun)) pats expr emptyLocalBinds] where - gen = noAnnSrcSpan generatedSrcSpan + genA :: SrcSpanAnnA + genA = noAnnSrcSpan generatedSrcSpan + + genN :: SrcSpanAnnN + genN = noAnnSrcSpan generatedSrcSpan genFunBind :: LocatedN Name -> [LMatch GhcRn (LHsExpr GhcRn)] -> HsBind GhcRn ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -142,13 +142,13 @@ getL = CvtM (\_ loc -> Right (loc,loc)) setL :: SrcSpan -> CvtM () setL loc = CvtM (\_ _ -> Right (loc, ())) -returnLA :: e -> CvtM (LocatedAn ann e) +returnLA :: (NoAnn ann) => e -> CvtM (LocatedAn ann e) returnLA x = CvtM (\_ loc -> Right (loc, L (noAnnSrcSpan loc) x)) returnJustLA :: a -> CvtM (Maybe (LocatedA a)) returnJustLA = fmap Just . returnLA -wrapParLA :: (LocatedAn ann a -> b) -> a -> CvtM b +wrapParLA :: (NoAnn ann) => (LocatedAn ann a -> b) -> a -> CvtM b wrapParLA add_par x = CvtM (\_ loc -> Right (loc, add_par (L (noAnnSrcSpan loc) x))) wrapMsg :: ThingBeingConverted -> CvtM' ConversionFailReason a -> CvtM' RunSpliceFailReason a ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -149,7 +149,8 @@ instance Uniquable Module where instance Binary a => Binary (GenModule a) where put_ bh (Module p n) = put_ bh p >> put_ bh n - get bh = do p <- get bh; n <- get bh; return (Module p n) + -- Module has strict fields, so use $! in order not to allocate a thunk + get bh = do p <- get bh; n <- get bh; return $! Module p n instance NFData (GenModule a) where rnf (Module unit name) = unit `seq` name `seq` () @@ -317,13 +318,14 @@ instance Binary InstantiatedUnit where cid <- get bh insts <- get bh let fs = mkInstantiatedUnitHash cid insts - return InstantiatedUnit { - instUnitInstanceOf = cid, - instUnitInsts = insts, - instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), - instUnitFS = fs, - instUnitKey = getUnique fs - } + -- InstantiatedUnit has strict fields, so use $! in order not to allocate a thunk + return $! InstantiatedUnit { + instUnitInstanceOf = cid, + instUnitInsts = insts, + instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), + instUnitFS = fs, + instUnitKey = getUnique fs + } instance IsUnitId u => Eq (GenUnit u) where uid1 == uid2 = unitUnique uid1 == unitUnique uid2 @@ -369,10 +371,12 @@ instance Binary Unit where put_ bh HoleUnit = putByte bh 2 get bh = do b <- getByte bh - case b of + u <- case b of 0 -> fmap RealUnit (get bh) 1 -> fmap VirtUnit (get bh) _ -> pure HoleUnit + -- Unit has strict fields that need forcing; otherwise we allocate a thunk. + pure $! u -- | Retrieve the set of free module holes of a 'Unit'. unitFreeModuleHoles :: GenUnit u -> UniqDSet ModuleName ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3f0d217b5b3de5ccec54154d5cd5c7b0d07708df +Subproject commit 5211c230903aee8c09485e8246993e2a1eb74563 ===================================== utils/check-exact/Orphans.hs ===================================== @@ -62,9 +62,6 @@ instance NoAnn AddEpAnn where instance NoAnn AnnKeywordId where noAnn = Annlarrowtail {- gotta pick one -} -instance NoAnn AnnContext where - noAnn = AnnContext Nothing [] [] - instance NoAnn EpAnnSumPat where noAnn = EpAnnSumPat noAnn noAnn noAnn ===================================== utils/check-exact/Utils.hs ===================================== @@ -371,9 +371,9 @@ setAnchorHsModule hsmod anc cs = hsmod { hsmodExt = (hsmodExt hsmod) {hsmodAnn = -- |Version of l2l that preserves the anchor, immportant if it has an -- updated AnchorOperation -moveAnchor :: Monoid b => SrcAnn a -> SrcAnn b +moveAnchor :: NoAnn b => SrcAnn a -> SrcAnn b moveAnchor (SrcSpanAnn EpAnnNotUsed l) = noAnnSrcSpan l -moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc mempty cs) l +moveAnchor (SrcSpanAnn (EpAnn anc _ cs) l) = SrcSpanAnn (EpAnn anc noAnn cs) l -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a703f29084c7e4580bf9f55a5b8ed5a6d87a5566...e37a1a3cdfaa6b44888b18526c5e1567fddf7733 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a703f29084c7e4580bf9f55a5b8ed5a6d87a5566...e37a1a3cdfaa6b44888b18526c5e1567fddf7733 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 03:58:41 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Mon, 09 Oct 2023 23:58:41 -0400 Subject: [Git][ghc/ghc][wip/angerman/32bit-cmm] Update CgUtils.hs Message-ID: <6524cbf1796f6_1b931c4d1efd0026964e@gitlab.mail> Moritz Angermann pushed to branch wip/angerman/32bit-cmm at Glasgow Haskell Compiler / GHC Commits: bd759277 by Moritz Angermann at 2023-10-10T03:58:39+00:00 Update CgUtils.hs - - - - - 1 changed file: - compiler/GHC/StgToCmm/CgUtils.hs Changes: ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -184,11 +184,12 @@ fixStgRegStmt platform stmt = fixAssign $ mapExpDeep fixExpr stmt -- NB: to ensure type correctness we need to ensure the Add -- as well as the Int need to be of the same size as the -- register. + let greg' = CmmReg greg in case globalRegUseGlobalReg reg `elem` activeStgRegs platform of True -> expr - False -> CmmMachOp (MO_Add (cmmRegWidth platform greg)) [ - fixExpr (CmmReg greg), + False -> CmmMachOp (MO_Add (cmmRegWidth platform greg')) [ + fixExpr greg', CmmLit (CmmInt (fromIntegral offset) - (cmmRegWidth platform greg))] + (cmmRegWidth platform greg'))] other_expr -> other_expr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd7592779d224deb1d5da19168738f27a30a3429 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd7592779d224deb1d5da19168738f27a30a3429 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 06:17:48 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Tue, 10 Oct 2023 02:17:48 -0400 Subject: [Git][ghc/ghc][wip/angerman/32bit-cmm] Update CgUtils.hs Message-ID: <6524ec8c59f_1b931c5053177c27955@gitlab.mail> Moritz Angermann pushed to branch wip/angerman/32bit-cmm at Glasgow Haskell Compiler / GHC Commits: dc22814f by Moritz Angermann at 2023-10-10T06:17:45+00:00 Update CgUtils.hs - - - - - 1 changed file: - compiler/GHC/StgToCmm/CgUtils.hs Changes: ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -184,12 +184,12 @@ fixStgRegStmt platform stmt = fixAssign $ mapExpDeep fixExpr stmt -- NB: to ensure type correctness we need to ensure the Add -- as well as the Int need to be of the same size as the -- register. - let greg' = CmmReg greg in + let greg' = CmmReg greg in case globalRegUseGlobalReg reg `elem` activeStgRegs platform of True -> expr - False -> CmmMachOp (MO_Add (cmmRegWidth platform greg')) [ + False -> CmmMachOp (MO_Add (cmmRegWidth greg')) [ fixExpr greg', CmmLit (CmmInt (fromIntegral offset) - (cmmRegWidth platform greg'))] + (cmmRegWidth greg'))] other_expr -> other_expr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc22814f06378c10a46ae4f28ead05830dd2ef7f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc22814f06378c10a46ae4f28ead05830dd2ef7f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 06:25:39 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Tue, 10 Oct 2023 02:25:39 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/no-section-attr-for-text Message-ID: <6524ee6355eb2_1b931c50535d402799d5@gitlab.mail> Moritz Angermann pushed new branch wip/angerman/no-section-attr-for-text at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/no-section-attr-for-text You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 06:36:15 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Tue, 10 Oct 2023 02:36:15 -0400 Subject: [Git][ghc/ghc][wip/angerman/32bit-cmm] Update CgUtils.hs Message-ID: <6524f0dfda708_1b931c509f4e582852d9@gitlab.mail> Moritz Angermann pushed to branch wip/angerman/32bit-cmm at Glasgow Haskell Compiler / GHC Commits: 9def8ce6 by Moritz Angermann at 2023-10-10T06:36:13+00:00 Update CgUtils.hs - - - - - 1 changed file: - compiler/GHC/StgToCmm/CgUtils.hs Changes: ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -184,12 +184,11 @@ fixStgRegStmt platform stmt = fixAssign $ mapExpDeep fixExpr stmt -- NB: to ensure type correctness we need to ensure the Add -- as well as the Int need to be of the same size as the -- register. - let greg' = CmmReg greg in case globalRegUseGlobalReg reg `elem` activeStgRegs platform of True -> expr - False -> CmmMachOp (MO_Add (cmmRegWidth greg')) [ - fixExpr greg', + False -> CmmMachOp (MO_Add (cmmRegWidth greg)) [ + fixExpr (CmmReg greg), CmmLit (CmmInt (fromIntegral offset) - (cmmRegWidth greg'))] + (cmmRegWidth greg))] other_expr -> other_expr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9def8ce6d81c3897f1b8ab3f0acc2a246c0f2745 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9def8ce6d81c3897f1b8ab3f0acc2a246c0f2745 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 08:08:53 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 04:08:53 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Stricter Binary.get in GHC.Types.Unit (#23964) Message-ID: <65250695e556b_1b931c53485e1030478b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a0ab7850 by Sebastian Graf at 2023-10-10T04:08:41-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - b952dcc3 by doyougnu at 2023-10-10T04:08:44-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - 60ce84eb by Matthew Craven at 2023-10-10T04:08:44-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - 5 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Unit/Types.hs Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -604,6 +604,7 @@ data Rule = ReleaseOnly -- ^ Only run this job in a release pipeline data ValidateRule = FullCI -- ^ Run this job when the "full-ci" label is present. | LLVMBackend -- ^ Run this job when the "LLVM backend" label is present + | JSBackend -- ^ Run this job when the "javascript" label is present | FreeBSDLabel -- ^ Run this job when the "FreeBSD" label is set. | NonmovingGc -- ^ Run this job when the "non-moving GC" label is set. | IpeData -- ^ Run this job when the "IPE" label is set @@ -648,11 +649,12 @@ validateRuleString FullCI = or_all ([ labelString "full-ci" , branchStringLike "ghc-[0-9]+\\.[0-9]+" ]) -validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString JSBackend = labelString "javascript" validateRuleString FreeBSDLabel = labelString "FreeBSD" -validateRuleString NonmovingGc = labelString "non-moving GC" -validateRuleString IpeData = labelString "IPE" -validateRuleString TestPrimops = labelString "test-primops" +validateRuleString NonmovingGc = labelString "non-moving GC" +validateRuleString IpeData = labelString "IPE" +validateRuleString TestPrimops = labelString "test-primops" -- | A 'Job' is the description of a single job in a gitlab pipeline. The -- job contains all the information about how to do the build but can be further @@ -1010,10 +1012,9 @@ job_groups = , disableValidate (standardBuildsWithConfig AArch64 (Linux Alpine318) (splitSectionsBroken vanilla)) , fullyStaticBrokenTests (disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine312) staticNativeInt))) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure") - ) - { bignumBackend = Native - } + + , addValidateRule JSBackend (validateBuilds Amd64 (Linux Debian11) javascriptConfig) + , make_wasm_jobs wasm_build_config , modifyValidateJobs manual $ make_wasm_jobs wasm_build_config {bignumBackend = Native} @@ -1024,6 +1025,8 @@ job_groups = ] where + javascriptConfig = (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure")) + { bignumBackend = Native } -- ghcilink002 broken due to #17869 -- ===================================== .gitlab/jobs.yaml ===================================== @@ -5255,7 +5255,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -695,7 +695,7 @@ data WarningFlag = | Opt_WarnIncompleteRecordSelectors -- Since 9.10 | Opt_WarnBadlyStagedTypes -- Since 9.10 | Opt_WarnInconsistentFlags -- Since 9.8 - deriving (Eq, Ord, Show, Enum) + deriving (Eq, Ord, Show, Enum, Bounded) -- | Return the names of a WarningFlag -- ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2165,127 +2165,125 @@ wWarningFlags :: [FlagSpec WarningFlag] wWarningFlags = map snd (sortBy (comparing fst) wWarningFlagsDeps) wWarningFlagsDeps :: [(Deprecation, FlagSpec WarningFlag)] -wWarningFlagsDeps = mconcat [ +wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of -- See Note [Updating flag description in the User's Guide] -- See Note [Supporting CLI completion] --- Please keep the list of flags below sorted alphabetically - warnSpec Opt_WarnAlternativeLayoutRuleTransitional, - warnSpec Opt_WarnAmbiguousFields, - depWarnSpec Opt_WarnAutoOrphans - "it has no effect", - warnSpec Opt_WarnCPPUndef, - warnSpec Opt_WarnUnbangedStrictPatterns, - warnSpec Opt_WarnDeferredTypeErrors, - warnSpec Opt_WarnDeferredOutOfScopeVariables, - warnSpec Opt_WarnDeprecatedFlags, - warnSpec Opt_WarnDerivingDefaults, - warnSpec Opt_WarnDerivingTypeable, - warnSpec Opt_WarnDodgyExports, - warnSpec Opt_WarnDodgyForeignImports, - warnSpec Opt_WarnDodgyImports, - warnSpec Opt_WarnEmptyEnumerations, - subWarnSpec "duplicate-constraints" - Opt_WarnDuplicateConstraints - "it is subsumed by -Wredundant-constraints", - warnSpec Opt_WarnRedundantConstraints, - warnSpec Opt_WarnDuplicateExports, - depWarnSpec Opt_WarnHiShadows - "it is not used, and was never implemented", - warnSpec Opt_WarnInaccessibleCode, - warnSpec Opt_WarnImplicitPrelude, - depWarnSpec Opt_WarnImplicitKindVars - "it is now an error", - warnSpec Opt_WarnIncompletePatterns, - warnSpec Opt_WarnIncompletePatternsRecUpd, - warnSpec Opt_WarnIncompleteUniPatterns, - warnSpec Opt_WarnInlineRuleShadowing, - warnSpec Opt_WarnIdentities, - warnSpec Opt_WarnMissingFields, - warnSpec Opt_WarnMissingImportList, - warnSpec Opt_WarnMissingExportList, - subWarnSpec "missing-local-sigs" - Opt_WarnMissingLocalSignatures - "it is replaced by -Wmissing-local-signatures", - warnSpec Opt_WarnMissingLocalSignatures, - warnSpec Opt_WarnMissingMethods, - depWarnSpec Opt_WarnMissingMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnSemigroup, - warnSpec Opt_WarnMissingSignatures, - warnSpec Opt_WarnMissingKindSignatures, - warnSpec Opt_WarnMissingPolyKindSignatures, - subWarnSpec "missing-exported-sigs" - Opt_WarnMissingExportedSignatures - "it is replaced by -Wmissing-exported-signatures", - warnSpec Opt_WarnMissingExportedSignatures, - warnSpec Opt_WarnMonomorphism, - warnSpec Opt_WarnNameShadowing, - warnSpec Opt_WarnNonCanonicalMonadInstances, - depWarnSpec Opt_WarnNonCanonicalMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnNonCanonicalMonoidInstances, - warnSpec Opt_WarnOrphans, - warnSpec Opt_WarnOverflowedLiterals, - warnSpec Opt_WarnOverlappingPatterns, - warnSpec Opt_WarnMissedSpecs, - warnSpec Opt_WarnAllMissedSpecs, - warnSpec' Opt_WarnSafe setWarnSafe, - warnSpec Opt_WarnTrustworthySafe, - warnSpec Opt_WarnInferredSafeImports, - warnSpec Opt_WarnMissingSafeHaskellMode, - warnSpec Opt_WarnTabs, - warnSpec Opt_WarnTypeDefaults, - warnSpec Opt_WarnTypedHoles, - warnSpec Opt_WarnPartialTypeSignatures, - warnSpec Opt_WarnUnrecognisedPragmas, - warnSpec Opt_WarnMisplacedPragmas, - warnSpec' Opt_WarnUnsafe setWarnUnsafe, - warnSpec Opt_WarnUnsupportedCallingConventions, - warnSpec Opt_WarnUnsupportedLlvmVersion, - warnSpec Opt_WarnMissedExtraSharedLib, - warnSpec Opt_WarnUntickedPromotedConstructors, - warnSpec Opt_WarnUnusedDoBind, - warnSpec Opt_WarnUnusedForalls, - warnSpec Opt_WarnUnusedImports, - warnSpec Opt_WarnUnusedLocalBinds, - warnSpec Opt_WarnUnusedMatches, - warnSpec Opt_WarnUnusedPatternBinds, - warnSpec Opt_WarnUnusedTopBinds, - warnSpec Opt_WarnUnusedTypePatterns, - warnSpec Opt_WarnUnusedRecordWildcards, - warnSpec Opt_WarnRedundantBangPatterns, - warnSpec Opt_WarnRedundantRecordWildcards, - warnSpec Opt_WarnRedundantStrictnessFlags, - warnSpec Opt_WarnWrongDoBind, - warnSpec Opt_WarnMissingPatternSynonymSignatures, - warnSpec Opt_WarnMissingDerivingStrategies, - warnSpec Opt_WarnSimplifiableClassConstraints, - warnSpec Opt_WarnMissingHomeModules, - warnSpec Opt_WarnUnrecognisedWarningFlags, - warnSpec Opt_WarnStarBinder, - warnSpec Opt_WarnStarIsType, - depWarnSpec Opt_WarnSpaceAfterBang - "bang patterns can no longer be written with a space", - warnSpec Opt_WarnPartialFields, - warnSpec Opt_WarnPrepositiveQualifiedModule, - warnSpec Opt_WarnUnusedPackages, - warnSpec Opt_WarnCompatUnqualifiedImports, - warnSpec Opt_WarnInvalidHaddock, - warnSpec Opt_WarnOperatorWhitespaceExtConflict, - warnSpec Opt_WarnOperatorWhitespace, - warnSpec Opt_WarnImplicitLift, - warnSpec Opt_WarnMissingExportedPatternSynonymSignatures, - warnSpec Opt_WarnForallIdentifier, - warnSpec Opt_WarnUnicodeBidirectionalFormatCharacters, - warnSpec Opt_WarnGADTMonoLocalBinds, - warnSpec Opt_WarnTypeEqualityOutOfScope, - warnSpec Opt_WarnTypeEqualityRequiresOperators, - warnSpec Opt_WarnTermVariableCapture, - warnSpec Opt_WarnMissingRoleAnnotations, - warnSpec Opt_WarnImplicitRhsQuantification, - warnSpec Opt_WarnIncompleteExportWarnings, - warnSpec Opt_WarnIncompleteRecordSelectors - ] + Opt_WarnAlternativeLayoutRuleTransitional -> warnSpec x + Opt_WarnAmbiguousFields -> warnSpec x + Opt_WarnAutoOrphans -> depWarnSpec x "it has no effect" + Opt_WarnCPPUndef -> warnSpec x + Opt_WarnBadlyStagedTypes -> warnSpec x + Opt_WarnUnbangedStrictPatterns -> warnSpec x + Opt_WarnDeferredTypeErrors -> warnSpec x + Opt_WarnDeferredOutOfScopeVariables -> warnSpec x + Opt_WarnDeprecatedFlags -> warnSpec x + Opt_WarnDerivingDefaults -> warnSpec x + Opt_WarnDerivingTypeable -> warnSpec x + Opt_WarnDodgyExports -> warnSpec x + Opt_WarnDodgyForeignImports -> warnSpec x + Opt_WarnDodgyImports -> warnSpec x + Opt_WarnEmptyEnumerations -> warnSpec x + Opt_WarnDuplicateConstraints + -> subWarnSpec "duplicate-constraints" x "it is subsumed by -Wredundant-constraints" + Opt_WarnRedundantConstraints -> warnSpec x + Opt_WarnDuplicateExports -> warnSpec x + Opt_WarnHiShadows + -> depWarnSpec x "it is not used, and was never implemented" + Opt_WarnInaccessibleCode -> warnSpec x + Opt_WarnImplicitPrelude -> warnSpec x + Opt_WarnImplicitKindVars -> depWarnSpec x "it is now an error" + Opt_WarnIncompletePatterns -> warnSpec x + Opt_WarnIncompletePatternsRecUpd -> warnSpec x + Opt_WarnIncompleteUniPatterns -> warnSpec x + Opt_WarnInconsistentFlags -> warnSpec x + Opt_WarnInlineRuleShadowing -> warnSpec x + Opt_WarnIdentities -> warnSpec x + Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnMissingFields -> warnSpec x + Opt_WarnMissingImportList -> warnSpec x + Opt_WarnMissingExportList -> warnSpec x + Opt_WarnMissingLocalSignatures + -> subWarnSpec "missing-local-sigs" x + "it is replaced by -Wmissing-local-signatures" + ++ warnSpec x + Opt_WarnMissingMethods -> warnSpec x + Opt_WarnMissingMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnSemigroup -> warnSpec x + Opt_WarnMissingSignatures -> warnSpec x + Opt_WarnMissingKindSignatures -> warnSpec x + Opt_WarnMissingPolyKindSignatures -> warnSpec x + Opt_WarnMissingExportedSignatures + -> subWarnSpec "missing-exported-sigs" x + "it is replaced by -Wmissing-exported-signatures" + ++ warnSpec x + Opt_WarnMonomorphism -> warnSpec x + Opt_WarnNameShadowing -> warnSpec x + Opt_WarnNonCanonicalMonadInstances -> warnSpec x + Opt_WarnNonCanonicalMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnNonCanonicalMonoidInstances -> warnSpec x + Opt_WarnOrphans -> warnSpec x + Opt_WarnOverflowedLiterals -> warnSpec x + Opt_WarnOverlappingPatterns -> warnSpec x + Opt_WarnMissedSpecs -> warnSpec x + Opt_WarnAllMissedSpecs -> warnSpec x + Opt_WarnSafe -> warnSpec' x setWarnSafe + Opt_WarnTrustworthySafe -> warnSpec x + Opt_WarnInferredSafeImports -> warnSpec x + Opt_WarnMissingSafeHaskellMode -> warnSpec x + Opt_WarnTabs -> warnSpec x + Opt_WarnTypeDefaults -> warnSpec x + Opt_WarnTypedHoles -> warnSpec x + Opt_WarnPartialTypeSignatures -> warnSpec x + Opt_WarnUnrecognisedPragmas -> warnSpec x + Opt_WarnMisplacedPragmas -> warnSpec x + Opt_WarnUnsafe -> warnSpec' x setWarnUnsafe + Opt_WarnUnsupportedCallingConventions -> warnSpec x + Opt_WarnUnsupportedLlvmVersion -> warnSpec x + Opt_WarnMissedExtraSharedLib -> warnSpec x + Opt_WarnUntickedPromotedConstructors -> warnSpec x + Opt_WarnUnusedDoBind -> warnSpec x + Opt_WarnUnusedForalls -> warnSpec x + Opt_WarnUnusedImports -> warnSpec x + Opt_WarnUnusedLocalBinds -> warnSpec x + Opt_WarnUnusedMatches -> warnSpec x + Opt_WarnUnusedPatternBinds -> warnSpec x + Opt_WarnUnusedTopBinds -> warnSpec x + Opt_WarnUnusedTypePatterns -> warnSpec x + Opt_WarnUnusedRecordWildcards -> warnSpec x + Opt_WarnRedundantBangPatterns -> warnSpec x + Opt_WarnRedundantRecordWildcards -> warnSpec x + Opt_WarnRedundantStrictnessFlags -> warnSpec x + Opt_WarnWrongDoBind -> warnSpec x + Opt_WarnMissingPatternSynonymSignatures -> warnSpec x + Opt_WarnMissingDerivingStrategies -> warnSpec x + Opt_WarnSimplifiableClassConstraints -> warnSpec x + Opt_WarnMissingHomeModules -> warnSpec x + Opt_WarnUnrecognisedWarningFlags -> warnSpec x + Opt_WarnStarBinder -> warnSpec x + Opt_WarnStarIsType -> warnSpec x + Opt_WarnSpaceAfterBang + -> depWarnSpec x "bang patterns can no longer be written with a space" + Opt_WarnPartialFields -> warnSpec x + Opt_WarnPrepositiveQualifiedModule -> warnSpec x + Opt_WarnUnusedPackages -> warnSpec x + Opt_WarnCompatUnqualifiedImports -> warnSpec x + Opt_WarnInvalidHaddock -> warnSpec x + Opt_WarnOperatorWhitespaceExtConflict -> warnSpec x + Opt_WarnOperatorWhitespace -> warnSpec x + Opt_WarnImplicitLift -> warnSpec x + Opt_WarnMissingExportedPatternSynonymSignatures -> warnSpec x + Opt_WarnForallIdentifier -> warnSpec x + Opt_WarnUnicodeBidirectionalFormatCharacters -> warnSpec x + Opt_WarnGADTMonoLocalBinds -> warnSpec x + Opt_WarnTypeEqualityOutOfScope -> warnSpec x + Opt_WarnTypeEqualityRequiresOperators -> warnSpec x + Opt_WarnTermVariableCapture -> warnSpec x + Opt_WarnMissingRoleAnnotations -> warnSpec x + Opt_WarnImplicitRhsQuantification -> warnSpec x + Opt_WarnIncompleteExportWarnings -> warnSpec x + Opt_WarnIncompleteRecordSelectors -> warnSpec x warningGroupsDeps :: [(Deprecation, FlagSpec WarningGroup)] warningGroupsDeps = map mk warningGroups ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -149,7 +149,8 @@ instance Uniquable Module where instance Binary a => Binary (GenModule a) where put_ bh (Module p n) = put_ bh p >> put_ bh n - get bh = do p <- get bh; n <- get bh; return (Module p n) + -- Module has strict fields, so use $! in order not to allocate a thunk + get bh = do p <- get bh; n <- get bh; return $! Module p n instance NFData (GenModule a) where rnf (Module unit name) = unit `seq` name `seq` () @@ -317,13 +318,14 @@ instance Binary InstantiatedUnit where cid <- get bh insts <- get bh let fs = mkInstantiatedUnitHash cid insts - return InstantiatedUnit { - instUnitInstanceOf = cid, - instUnitInsts = insts, - instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), - instUnitFS = fs, - instUnitKey = getUnique fs - } + -- InstantiatedUnit has strict fields, so use $! in order not to allocate a thunk + return $! InstantiatedUnit { + instUnitInstanceOf = cid, + instUnitInsts = insts, + instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), + instUnitFS = fs, + instUnitKey = getUnique fs + } instance IsUnitId u => Eq (GenUnit u) where uid1 == uid2 = unitUnique uid1 == unitUnique uid2 @@ -369,10 +371,12 @@ instance Binary Unit where put_ bh HoleUnit = putByte bh 2 get bh = do b <- getByte bh - case b of + u <- case b of 0 -> fmap RealUnit (get bh) 1 -> fmap VirtUnit (get bh) _ -> pure HoleUnit + -- Unit has strict fields that need forcing; otherwise we allocate a thunk. + pure $! u -- | Retrieve the set of free module holes of a 'Unit'. unitFreeModuleHoles :: GenUnit u -> UniqDSet ModuleName View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e37a1a3cdfaa6b44888b18526c5e1567fddf7733...60ce84eb9e1ff7abb8c2ee4d67eb958581fc8dff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e37a1a3cdfaa6b44888b18526c5e1567fddf7733...60ce84eb9e1ff7abb8c2ee4d67eb958581fc8dff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 08:09:36 2023 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Tue, 10 Oct 2023 04:09:36 -0400 Subject: [Git][ghc/ghc][wip/upload.sh-cleanups] rel_eng/upload.sh cleanups Message-ID: <652506c0e3126_1b931c534824043127f6@gitlab.mail> Bryan R pushed to branch wip/upload.sh-cleanups at Glasgow Haskell Compiler / GHC Commits: d638df45 by Bryan Richter at 2023-10-10T11:08:41+03:00 rel_eng/upload.sh cleanups - - - - - 1 changed file: - .gitlab/rel_eng/upload.sh Changes: ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -1,6 +1,7 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p moreutils lzip zip lftp gnupg -set -e +set -Eeuo pipefail # This is a script for preparing and uploading a release of GHC. # @@ -30,21 +31,15 @@ set -e # # Prerequisites: moreutils -if [ -z "$SIGNING_KEY" ]; then - SIGNING_KEY="=Benjamin Gamari " -fi +: ${SIGNING_KEY:="=Benjamin Gamari "} # Infer release name from directory name -if [ -z "$rel_name" ]; then - rel_name="$(basename $(pwd))" -fi +: ${rel_name:=$(basename $(pwd))} # Infer version from tarball names -if [ -z "$ver" ]; then - ver="$(ls ghc-*.tar.* | sed -ne 's/ghc-\([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).\+/\1/p' | head -n1)" - if [ -z "$ver" ]; then echo "Failed to infer \$ver"; exit 1; fi -fi +: ${ver:=$(ls ghc-*.tar.* | sed -ne 's/ghc-\([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).\+/\1/p' | head -n1)} +if [ -z "$ver" ]; then echo "Failed to infer \$ver"; exit 1; fi host="gitlab-storage.haskell.org" @@ -141,6 +136,7 @@ function upload() { } function purge_all() { + dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -196,6 +192,7 @@ function prepare_docs() { } function recompress() { + set -Eeuo pipefail combine <(basename -s .xz *.xz) not <(basename -s .lz *.lz) | \ parallel 'echo "Recompressing {}.xz to {}.lz"; unxz -c {}.xz | lzip - -o {}.lz' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d638df45b2d4956edac4e3354ddf73f2135a88b1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d638df45b2d4956edac4e3354ddf73f2135a88b1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 08:35:30 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Oct 2023 04:35:30 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] Temporarily add -DDEBUG to Coercion.hs Message-ID: <65250cd213544_1b931c53e8fb40320414@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 9c7acc26 by Simon Peyton Jones at 2023-10-10T09:35:00+01:00 Temporarily add -DDEBUG to Coercion.hs - - - - - 1 changed file: - compiler/GHC/Core/Coercion.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -DDEBUG #-} {- (c) The University of Glasgow 2006 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c7acc264e761f2ffb10c7c88c64f30871be4e74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c7acc264e761f2ffb10c7c88c64f30871be4e74 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 09:08:48 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 10 Oct 2023 05:08:48 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/no-lint Message-ID: <652514a0545f3_1b931c54cc03e0324982@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/no-lint at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/no-lint You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 09:19:59 2023 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Tue, 10 Oct 2023 05:19:59 -0400 Subject: [Git][ghc/ghc][wip/or-pats] 30 commits: Simplify and correct nasty case in coercion opt Message-ID: <6525173f29048_1b931c551025e83251c0@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - 3094c1d8 by David Knothe at 2023-10-10T10:53:07+02:00 Implement Or Patterns (Proposal 0522) This commit introduces a language extension, `OrPatterns`, as described in proposal 0522. It extends the syntax by the production `pat -> (one of pat1, ..., patk)`. The or-pattern `pat` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order. Currently, or-patterns cannot bind variables. They are still of great use as they discourage the use of wildcard patterns in favour of writing out all "default" cases explicitly: ``` isIrrefutableHsPat pat = case pat of ... (one of WildPat{}, VarPat{}, LazyPat{}) = True (one of PArrPat{}, ConPatIn{}, LitPat{}, NPat{}, NPlusKPat{}, ListPat{}) = False ``` This makes code safer where data types are extended now and then - just like GHC's `Pat` in the example when adding the new `OrPat` constructor. This would be catched by `-fwarn-incomplete-patterns`, but not when a wildcard pattern was used. - Update submodule haddock. stuff Implement empty one of Prohibit TyApps Remove unused update submodule haddock Update tests Parser.y - - - - - 8c7afd88 by David Knothe at 2023-10-10T10:53:07+02:00 infixpat - - - - - 5c86df56 by David Knothe at 2023-10-10T10:53:07+02:00 ppr&tests - - - - - f409d40f by David Knothe at 2023-10-10T10:53:08+02:00 Fix PatSyn tests - - - - - 1ac71769 by David Knothe at 2023-10-10T10:53:08+02:00 Revert "Fix PatSyn tests" This reverts commit af82f8db8f7e03e130c28ef09a2a2c9c5fffaa5a. - - - - - faa3b8cd by David Knothe at 2023-10-10T10:53:08+02:00 Nonbreaking parser change - - - - - 30 changed files: - .gitignore - .gitlab/ci.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Check.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Pmc/Types.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Bind.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fb611a120ed20a2b6fae7c93b9940d66db0c49b...faa3b8cdeeedc8f5b52f9460ac85731f0565ac02 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fb611a120ed20a2b6fae7c93b9940d66db0c49b...faa3b8cdeeedc8f5b52f9460ac85731f0565ac02 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 10:35:48 2023 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 10 Oct 2023 06:35:48 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/reopt_immediates Message-ID: <65252904c43e6_1b931c56ea609034685e@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/reopt_immediates at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/reopt_immediates You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 11:19:27 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 07:19:27 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Stricter Binary.get in GHC.Types.Unit (#23964) Message-ID: <6525333fbe514_1b931c580aa764366050@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e7cfe4a8 by Sebastian Graf at 2023-10-10T07:19:09-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - bc6a8975 by Bryan Richter at 2023-10-10T07:19:09-04:00 rel_eng/upload.sh cleanups - - - - - 94eeb16a by doyougnu at 2023-10-10T07:19:12-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - 265e36bf by Matthew Craven at 2023-10-10T07:19:12-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - 6 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Unit/Types.hs Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -604,6 +604,7 @@ data Rule = ReleaseOnly -- ^ Only run this job in a release pipeline data ValidateRule = FullCI -- ^ Run this job when the "full-ci" label is present. | LLVMBackend -- ^ Run this job when the "LLVM backend" label is present + | JSBackend -- ^ Run this job when the "javascript" label is present | FreeBSDLabel -- ^ Run this job when the "FreeBSD" label is set. | NonmovingGc -- ^ Run this job when the "non-moving GC" label is set. | IpeData -- ^ Run this job when the "IPE" label is set @@ -648,11 +649,12 @@ validateRuleString FullCI = or_all ([ labelString "full-ci" , branchStringLike "ghc-[0-9]+\\.[0-9]+" ]) -validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString JSBackend = labelString "javascript" validateRuleString FreeBSDLabel = labelString "FreeBSD" -validateRuleString NonmovingGc = labelString "non-moving GC" -validateRuleString IpeData = labelString "IPE" -validateRuleString TestPrimops = labelString "test-primops" +validateRuleString NonmovingGc = labelString "non-moving GC" +validateRuleString IpeData = labelString "IPE" +validateRuleString TestPrimops = labelString "test-primops" -- | A 'Job' is the description of a single job in a gitlab pipeline. The -- job contains all the information about how to do the build but can be further @@ -1010,10 +1012,9 @@ job_groups = , disableValidate (standardBuildsWithConfig AArch64 (Linux Alpine318) (splitSectionsBroken vanilla)) , fullyStaticBrokenTests (disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine312) staticNativeInt))) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure") - ) - { bignumBackend = Native - } + + , addValidateRule JSBackend (validateBuilds Amd64 (Linux Debian11) javascriptConfig) + , make_wasm_jobs wasm_build_config , modifyValidateJobs manual $ make_wasm_jobs wasm_build_config {bignumBackend = Native} @@ -1024,6 +1025,8 @@ job_groups = ] where + javascriptConfig = (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure")) + { bignumBackend = Native } -- ghcilink002 broken due to #17869 -- ===================================== .gitlab/jobs.yaml ===================================== @@ -5255,7 +5255,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -1,6 +1,7 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p moreutils lzip zip lftp gnupg -set -e +set -Eeuo pipefail # This is a script for preparing and uploading a release of GHC. # @@ -30,21 +31,15 @@ set -e # # Prerequisites: moreutils -if [ -z "$SIGNING_KEY" ]; then - SIGNING_KEY="=Benjamin Gamari " -fi +: ${SIGNING_KEY:="=Benjamin Gamari "} # Infer release name from directory name -if [ -z "$rel_name" ]; then - rel_name="$(basename $(pwd))" -fi +: ${rel_name:=$(basename $(pwd))} # Infer version from tarball names -if [ -z "$ver" ]; then - ver="$(ls ghc-*.tar.* | sed -ne 's/ghc-\([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).\+/\1/p' | head -n1)" - if [ -z "$ver" ]; then echo "Failed to infer \$ver"; exit 1; fi -fi +: ${ver:=$(ls ghc-*.tar.* | sed -ne 's/ghc-\([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).\+/\1/p' | head -n1)} +if [ -z "$ver" ]; then echo "Failed to infer \$ver"; exit 1; fi host="gitlab-storage.haskell.org" @@ -141,6 +136,7 @@ function upload() { } function purge_all() { + dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -196,6 +192,7 @@ function prepare_docs() { } function recompress() { + set -Eeuo pipefail combine <(basename -s .xz *.xz) not <(basename -s .lz *.lz) | \ parallel 'echo "Recompressing {}.xz to {}.lz"; unxz -c {}.xz | lzip - -o {}.lz' ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -695,7 +695,7 @@ data WarningFlag = | Opt_WarnIncompleteRecordSelectors -- Since 9.10 | Opt_WarnBadlyStagedTypes -- Since 9.10 | Opt_WarnInconsistentFlags -- Since 9.8 - deriving (Eq, Ord, Show, Enum) + deriving (Eq, Ord, Show, Enum, Bounded) -- | Return the names of a WarningFlag -- ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2165,127 +2165,125 @@ wWarningFlags :: [FlagSpec WarningFlag] wWarningFlags = map snd (sortBy (comparing fst) wWarningFlagsDeps) wWarningFlagsDeps :: [(Deprecation, FlagSpec WarningFlag)] -wWarningFlagsDeps = mconcat [ +wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of -- See Note [Updating flag description in the User's Guide] -- See Note [Supporting CLI completion] --- Please keep the list of flags below sorted alphabetically - warnSpec Opt_WarnAlternativeLayoutRuleTransitional, - warnSpec Opt_WarnAmbiguousFields, - depWarnSpec Opt_WarnAutoOrphans - "it has no effect", - warnSpec Opt_WarnCPPUndef, - warnSpec Opt_WarnUnbangedStrictPatterns, - warnSpec Opt_WarnDeferredTypeErrors, - warnSpec Opt_WarnDeferredOutOfScopeVariables, - warnSpec Opt_WarnDeprecatedFlags, - warnSpec Opt_WarnDerivingDefaults, - warnSpec Opt_WarnDerivingTypeable, - warnSpec Opt_WarnDodgyExports, - warnSpec Opt_WarnDodgyForeignImports, - warnSpec Opt_WarnDodgyImports, - warnSpec Opt_WarnEmptyEnumerations, - subWarnSpec "duplicate-constraints" - Opt_WarnDuplicateConstraints - "it is subsumed by -Wredundant-constraints", - warnSpec Opt_WarnRedundantConstraints, - warnSpec Opt_WarnDuplicateExports, - depWarnSpec Opt_WarnHiShadows - "it is not used, and was never implemented", - warnSpec Opt_WarnInaccessibleCode, - warnSpec Opt_WarnImplicitPrelude, - depWarnSpec Opt_WarnImplicitKindVars - "it is now an error", - warnSpec Opt_WarnIncompletePatterns, - warnSpec Opt_WarnIncompletePatternsRecUpd, - warnSpec Opt_WarnIncompleteUniPatterns, - warnSpec Opt_WarnInlineRuleShadowing, - warnSpec Opt_WarnIdentities, - warnSpec Opt_WarnMissingFields, - warnSpec Opt_WarnMissingImportList, - warnSpec Opt_WarnMissingExportList, - subWarnSpec "missing-local-sigs" - Opt_WarnMissingLocalSignatures - "it is replaced by -Wmissing-local-signatures", - warnSpec Opt_WarnMissingLocalSignatures, - warnSpec Opt_WarnMissingMethods, - depWarnSpec Opt_WarnMissingMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnSemigroup, - warnSpec Opt_WarnMissingSignatures, - warnSpec Opt_WarnMissingKindSignatures, - warnSpec Opt_WarnMissingPolyKindSignatures, - subWarnSpec "missing-exported-sigs" - Opt_WarnMissingExportedSignatures - "it is replaced by -Wmissing-exported-signatures", - warnSpec Opt_WarnMissingExportedSignatures, - warnSpec Opt_WarnMonomorphism, - warnSpec Opt_WarnNameShadowing, - warnSpec Opt_WarnNonCanonicalMonadInstances, - depWarnSpec Opt_WarnNonCanonicalMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnNonCanonicalMonoidInstances, - warnSpec Opt_WarnOrphans, - warnSpec Opt_WarnOverflowedLiterals, - warnSpec Opt_WarnOverlappingPatterns, - warnSpec Opt_WarnMissedSpecs, - warnSpec Opt_WarnAllMissedSpecs, - warnSpec' Opt_WarnSafe setWarnSafe, - warnSpec Opt_WarnTrustworthySafe, - warnSpec Opt_WarnInferredSafeImports, - warnSpec Opt_WarnMissingSafeHaskellMode, - warnSpec Opt_WarnTabs, - warnSpec Opt_WarnTypeDefaults, - warnSpec Opt_WarnTypedHoles, - warnSpec Opt_WarnPartialTypeSignatures, - warnSpec Opt_WarnUnrecognisedPragmas, - warnSpec Opt_WarnMisplacedPragmas, - warnSpec' Opt_WarnUnsafe setWarnUnsafe, - warnSpec Opt_WarnUnsupportedCallingConventions, - warnSpec Opt_WarnUnsupportedLlvmVersion, - warnSpec Opt_WarnMissedExtraSharedLib, - warnSpec Opt_WarnUntickedPromotedConstructors, - warnSpec Opt_WarnUnusedDoBind, - warnSpec Opt_WarnUnusedForalls, - warnSpec Opt_WarnUnusedImports, - warnSpec Opt_WarnUnusedLocalBinds, - warnSpec Opt_WarnUnusedMatches, - warnSpec Opt_WarnUnusedPatternBinds, - warnSpec Opt_WarnUnusedTopBinds, - warnSpec Opt_WarnUnusedTypePatterns, - warnSpec Opt_WarnUnusedRecordWildcards, - warnSpec Opt_WarnRedundantBangPatterns, - warnSpec Opt_WarnRedundantRecordWildcards, - warnSpec Opt_WarnRedundantStrictnessFlags, - warnSpec Opt_WarnWrongDoBind, - warnSpec Opt_WarnMissingPatternSynonymSignatures, - warnSpec Opt_WarnMissingDerivingStrategies, - warnSpec Opt_WarnSimplifiableClassConstraints, - warnSpec Opt_WarnMissingHomeModules, - warnSpec Opt_WarnUnrecognisedWarningFlags, - warnSpec Opt_WarnStarBinder, - warnSpec Opt_WarnStarIsType, - depWarnSpec Opt_WarnSpaceAfterBang - "bang patterns can no longer be written with a space", - warnSpec Opt_WarnPartialFields, - warnSpec Opt_WarnPrepositiveQualifiedModule, - warnSpec Opt_WarnUnusedPackages, - warnSpec Opt_WarnCompatUnqualifiedImports, - warnSpec Opt_WarnInvalidHaddock, - warnSpec Opt_WarnOperatorWhitespaceExtConflict, - warnSpec Opt_WarnOperatorWhitespace, - warnSpec Opt_WarnImplicitLift, - warnSpec Opt_WarnMissingExportedPatternSynonymSignatures, - warnSpec Opt_WarnForallIdentifier, - warnSpec Opt_WarnUnicodeBidirectionalFormatCharacters, - warnSpec Opt_WarnGADTMonoLocalBinds, - warnSpec Opt_WarnTypeEqualityOutOfScope, - warnSpec Opt_WarnTypeEqualityRequiresOperators, - warnSpec Opt_WarnTermVariableCapture, - warnSpec Opt_WarnMissingRoleAnnotations, - warnSpec Opt_WarnImplicitRhsQuantification, - warnSpec Opt_WarnIncompleteExportWarnings, - warnSpec Opt_WarnIncompleteRecordSelectors - ] + Opt_WarnAlternativeLayoutRuleTransitional -> warnSpec x + Opt_WarnAmbiguousFields -> warnSpec x + Opt_WarnAutoOrphans -> depWarnSpec x "it has no effect" + Opt_WarnCPPUndef -> warnSpec x + Opt_WarnBadlyStagedTypes -> warnSpec x + Opt_WarnUnbangedStrictPatterns -> warnSpec x + Opt_WarnDeferredTypeErrors -> warnSpec x + Opt_WarnDeferredOutOfScopeVariables -> warnSpec x + Opt_WarnDeprecatedFlags -> warnSpec x + Opt_WarnDerivingDefaults -> warnSpec x + Opt_WarnDerivingTypeable -> warnSpec x + Opt_WarnDodgyExports -> warnSpec x + Opt_WarnDodgyForeignImports -> warnSpec x + Opt_WarnDodgyImports -> warnSpec x + Opt_WarnEmptyEnumerations -> warnSpec x + Opt_WarnDuplicateConstraints + -> subWarnSpec "duplicate-constraints" x "it is subsumed by -Wredundant-constraints" + Opt_WarnRedundantConstraints -> warnSpec x + Opt_WarnDuplicateExports -> warnSpec x + Opt_WarnHiShadows + -> depWarnSpec x "it is not used, and was never implemented" + Opt_WarnInaccessibleCode -> warnSpec x + Opt_WarnImplicitPrelude -> warnSpec x + Opt_WarnImplicitKindVars -> depWarnSpec x "it is now an error" + Opt_WarnIncompletePatterns -> warnSpec x + Opt_WarnIncompletePatternsRecUpd -> warnSpec x + Opt_WarnIncompleteUniPatterns -> warnSpec x + Opt_WarnInconsistentFlags -> warnSpec x + Opt_WarnInlineRuleShadowing -> warnSpec x + Opt_WarnIdentities -> warnSpec x + Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnMissingFields -> warnSpec x + Opt_WarnMissingImportList -> warnSpec x + Opt_WarnMissingExportList -> warnSpec x + Opt_WarnMissingLocalSignatures + -> subWarnSpec "missing-local-sigs" x + "it is replaced by -Wmissing-local-signatures" + ++ warnSpec x + Opt_WarnMissingMethods -> warnSpec x + Opt_WarnMissingMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnSemigroup -> warnSpec x + Opt_WarnMissingSignatures -> warnSpec x + Opt_WarnMissingKindSignatures -> warnSpec x + Opt_WarnMissingPolyKindSignatures -> warnSpec x + Opt_WarnMissingExportedSignatures + -> subWarnSpec "missing-exported-sigs" x + "it is replaced by -Wmissing-exported-signatures" + ++ warnSpec x + Opt_WarnMonomorphism -> warnSpec x + Opt_WarnNameShadowing -> warnSpec x + Opt_WarnNonCanonicalMonadInstances -> warnSpec x + Opt_WarnNonCanonicalMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnNonCanonicalMonoidInstances -> warnSpec x + Opt_WarnOrphans -> warnSpec x + Opt_WarnOverflowedLiterals -> warnSpec x + Opt_WarnOverlappingPatterns -> warnSpec x + Opt_WarnMissedSpecs -> warnSpec x + Opt_WarnAllMissedSpecs -> warnSpec x + Opt_WarnSafe -> warnSpec' x setWarnSafe + Opt_WarnTrustworthySafe -> warnSpec x + Opt_WarnInferredSafeImports -> warnSpec x + Opt_WarnMissingSafeHaskellMode -> warnSpec x + Opt_WarnTabs -> warnSpec x + Opt_WarnTypeDefaults -> warnSpec x + Opt_WarnTypedHoles -> warnSpec x + Opt_WarnPartialTypeSignatures -> warnSpec x + Opt_WarnUnrecognisedPragmas -> warnSpec x + Opt_WarnMisplacedPragmas -> warnSpec x + Opt_WarnUnsafe -> warnSpec' x setWarnUnsafe + Opt_WarnUnsupportedCallingConventions -> warnSpec x + Opt_WarnUnsupportedLlvmVersion -> warnSpec x + Opt_WarnMissedExtraSharedLib -> warnSpec x + Opt_WarnUntickedPromotedConstructors -> warnSpec x + Opt_WarnUnusedDoBind -> warnSpec x + Opt_WarnUnusedForalls -> warnSpec x + Opt_WarnUnusedImports -> warnSpec x + Opt_WarnUnusedLocalBinds -> warnSpec x + Opt_WarnUnusedMatches -> warnSpec x + Opt_WarnUnusedPatternBinds -> warnSpec x + Opt_WarnUnusedTopBinds -> warnSpec x + Opt_WarnUnusedTypePatterns -> warnSpec x + Opt_WarnUnusedRecordWildcards -> warnSpec x + Opt_WarnRedundantBangPatterns -> warnSpec x + Opt_WarnRedundantRecordWildcards -> warnSpec x + Opt_WarnRedundantStrictnessFlags -> warnSpec x + Opt_WarnWrongDoBind -> warnSpec x + Opt_WarnMissingPatternSynonymSignatures -> warnSpec x + Opt_WarnMissingDerivingStrategies -> warnSpec x + Opt_WarnSimplifiableClassConstraints -> warnSpec x + Opt_WarnMissingHomeModules -> warnSpec x + Opt_WarnUnrecognisedWarningFlags -> warnSpec x + Opt_WarnStarBinder -> warnSpec x + Opt_WarnStarIsType -> warnSpec x + Opt_WarnSpaceAfterBang + -> depWarnSpec x "bang patterns can no longer be written with a space" + Opt_WarnPartialFields -> warnSpec x + Opt_WarnPrepositiveQualifiedModule -> warnSpec x + Opt_WarnUnusedPackages -> warnSpec x + Opt_WarnCompatUnqualifiedImports -> warnSpec x + Opt_WarnInvalidHaddock -> warnSpec x + Opt_WarnOperatorWhitespaceExtConflict -> warnSpec x + Opt_WarnOperatorWhitespace -> warnSpec x + Opt_WarnImplicitLift -> warnSpec x + Opt_WarnMissingExportedPatternSynonymSignatures -> warnSpec x + Opt_WarnForallIdentifier -> warnSpec x + Opt_WarnUnicodeBidirectionalFormatCharacters -> warnSpec x + Opt_WarnGADTMonoLocalBinds -> warnSpec x + Opt_WarnTypeEqualityOutOfScope -> warnSpec x + Opt_WarnTypeEqualityRequiresOperators -> warnSpec x + Opt_WarnTermVariableCapture -> warnSpec x + Opt_WarnMissingRoleAnnotations -> warnSpec x + Opt_WarnImplicitRhsQuantification -> warnSpec x + Opt_WarnIncompleteExportWarnings -> warnSpec x + Opt_WarnIncompleteRecordSelectors -> warnSpec x warningGroupsDeps :: [(Deprecation, FlagSpec WarningGroup)] warningGroupsDeps = map mk warningGroups ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -149,7 +149,8 @@ instance Uniquable Module where instance Binary a => Binary (GenModule a) where put_ bh (Module p n) = put_ bh p >> put_ bh n - get bh = do p <- get bh; n <- get bh; return (Module p n) + -- Module has strict fields, so use $! in order not to allocate a thunk + get bh = do p <- get bh; n <- get bh; return $! Module p n instance NFData (GenModule a) where rnf (Module unit name) = unit `seq` name `seq` () @@ -317,13 +318,14 @@ instance Binary InstantiatedUnit where cid <- get bh insts <- get bh let fs = mkInstantiatedUnitHash cid insts - return InstantiatedUnit { - instUnitInstanceOf = cid, - instUnitInsts = insts, - instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), - instUnitFS = fs, - instUnitKey = getUnique fs - } + -- InstantiatedUnit has strict fields, so use $! in order not to allocate a thunk + return $! InstantiatedUnit { + instUnitInstanceOf = cid, + instUnitInsts = insts, + instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), + instUnitFS = fs, + instUnitKey = getUnique fs + } instance IsUnitId u => Eq (GenUnit u) where uid1 == uid2 = unitUnique uid1 == unitUnique uid2 @@ -369,10 +371,12 @@ instance Binary Unit where put_ bh HoleUnit = putByte bh 2 get bh = do b <- getByte bh - case b of + u <- case b of 0 -> fmap RealUnit (get bh) 1 -> fmap VirtUnit (get bh) _ -> pure HoleUnit + -- Unit has strict fields that need forcing; otherwise we allocate a thunk. + pure $! u -- | Retrieve the set of free module holes of a 'Unit'. unitFreeModuleHoles :: GenUnit u -> UniqDSet ModuleName View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/60ce84eb9e1ff7abb8c2ee4d67eb958581fc8dff...265e36bf780ae0cb3b2214f699d51af124e82a8e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/60ce84eb9e1ff7abb8c2ee4d67eb958581fc8dff...265e36bf780ae0cb3b2214f699d51af124e82a8e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 12:56:58 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 10 Oct 2023 08:56:58 -0400 Subject: [Git][ghc/ghc][wip/hadrian-windows-bindist-cross] 41 commits: Simplify and correct nasty case in coercion opt Message-ID: <65254a1abdd09_1b931c5b36ed08404442@gitlab.mail> Ben Gamari pushed to branch wip/hadrian-windows-bindist-cross at Glasgow Haskell Compiler / GHC Commits: bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - c83ae3b8 by Matthew Pickering at 2023-10-10T12:56:54+00:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 8fbe6b29 by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - d4cd6785 by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 671bb1ce by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 4725c6b7 by Matthew Pickering at 2023-10-10T12:56:54+00:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - ab592988 by Ben Gamari at 2023-10-10T12:56:54+00:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - 10db17bc by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - 28db40d3 by Matthew Pickering at 2023-10-10T12:56:54+00:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 822ac14d by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 7c8219c3 by Matthew Pickering at 2023-10-10T12:56:54+00:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 72d251fb by Matthew Pickering at 2023-10-10T12:56:54+00:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - e2381d3c by Matthew Pickering at 2023-10-10T12:56:54+00:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - edddacd5 by Matthew Pickering at 2023-10-10T12:56:54+00:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 3888d96e by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 2862475a by Ben Gamari at 2023-10-10T12:56:54+00:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 1dc979f4 by Matthew Pickering at 2023-10-10T12:56:54+00:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - f42c4bfa by Ben Gamari at 2023-10-10T12:56:54+00:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 30 changed files: - .gitignore - .gitlab/ci.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Debug.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Name/Reader.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/using-warnings.rst - driver/ghci/ghci-wrapper.cabal.in - ghc/ghc-bin.cabal.in - hadrian/cabal.project - hadrian/hadrian.cabal - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Rules/ToolArgs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef5ac0722fd55f3d3c0eba0c56c74c4724efc783...f42c4bfa46cb2710ae83d6e517231d354cd2cf3f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef5ac0722fd55f3d3c0eba0c56c74c4724efc783...f42c4bfa46cb2710ae83d6e517231d354cd2cf3f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 14:57:47 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Oct 2023 10:57:47 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] Fix a missing zonk in before mkSelCo Message-ID: <6525666add967_1b931c5e2186904827e8@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 735951dd by Simon Peyton Jones at 2023-10-10T15:57:04+01:00 Fix a missing zonk in before mkSelCo - - - - - 2 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Tc/Solver/Equality.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1141,16 +1141,27 @@ mkTransCo (GRefl r t1 (MCo co1)) (GRefl _ _ (MCo co2)) mkTransCo co1 co2 = TransCo co1 co2 -------------------- +{- Note [mkSelCo precondition] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +To satisfy the Purely Kinded Type Invariant (PKTI), we require that + in any call (mkSelCo cs co) + * selectFromType cs (coercionLKind co) works + * selectFromType cs (coercionRKind co) works + * and hence coercionKind (SelCo cs co) works (PKTI) +-} + mkSelCo :: HasDebugCallStack => CoSel -> Coercion -> Coercion +-- See Note [mkSelCo precondition] mkSelCo n co = mkSelCo_maybe n co `orElse` SelCo n co mkSelCo_maybe :: HasDebugCallStack => CoSel -> Coercion -> Maybe Coercion +-- Note [mkSelCo precondition] mkSelCo_maybe cs co = assertPpr (good_call cs) bad_call_msg $ go cs co @@ -1196,6 +1207,7 @@ mkSelCo_maybe cs co | otherwise = Nothing ----------- Assertion checking -------------- + -- NB: using coercionKind requires Note [mkSelCo precondition] Pair ty1 ty2 = coercionKind co bad_call_msg = vcat [ text "Coercion =" <+> ppr co , text "LHS ty =" <+> ppr ty1 ===================================== compiler/GHC/Tc/Solver/Equality.hs ===================================== @@ -104,12 +104,7 @@ solveEquality :: CtEvidence -> EqRel -> Type -> Type -> SolverStage Void solveEquality ev eq_rel ty1 ty2 = do { Pair ty1' ty2' <- zonkEqTypes ev eq_rel ty1 ty2 - ; let ev' | debugIsOn = setCtEvPredType ev $ - mkPrimEqPredRole (eqRelRole eq_rel) ty1' ty2' - | otherwise = ev - -- ev': satisfy the precondition of can_eq_nc - - ; mb_canon <- canonicaliseEquality ev' eq_rel ty1' ty2' + ; mb_canon <- canonicaliseEquality ev eq_rel ty1' ty2' ; case mb_canon of { @@ -289,10 +284,10 @@ canonicaliseEquality :: CtEvidence -> EqRel -> Type -> Type -- LHS and RHS -> SolverStage (Either IrredCt EqCt) --- Precondition: in DEBUG mode, the `ctev_pred` of `ev` is (ps_ty1 ~# ps_ty2), --- without zonking --- This precondition is needed (only in DEBUG) to satisfy the assertions --- in mkSelCo, called in canDecomposableTyConAppOK and canDecomposableFunTy +-- Nota Bene: `ty1` and `ty2` may be more-zonked than `ev` +-- This matters when calling mkSelCo, in canDecomposableTyConAppOK and +-- canDecomposableFunTy, when we need the precondition of mkSelCo to +-- hold. canonicaliseEquality ev eq_rel ty1 ty2 = Stage $ do { traceTcS "canonicaliseEquality" $ @@ -362,10 +357,10 @@ can_eq_nc _rewritten _rdr_env _envs ev eq_rel ty1@(LitTy l1) _ (LitTy l2) _ -- Decompose FunTy: (s -> t) and (c => t) -- NB: don't decompose (Int -> blah) ~ (Show a => blah) can_eq_nc _rewritten _rdr_env _envs ev eq_rel - (FunTy { ft_mult = am1, ft_af = af1, ft_arg = ty1a, ft_res = ty1b }) _ps_ty1 - (FunTy { ft_mult = am2, ft_af = af2, ft_arg = ty2a, ft_res = ty2b }) _ps_ty2 + ty1@(FunTy { ft_mult = am1, ft_af = af1, ft_arg = ty1a, ft_res = ty1b }) _ps_ty1 + ty2@(FunTy { ft_mult = am2, ft_af = af2, ft_arg = ty2a, ft_res = ty2b }) _ps_ty2 | af1 == af2 -- See Note [Decomposing FunTy] - = canDecomposableFunTy ev eq_rel af1 (am1,ty1a,ty1b) (am2,ty2a,ty2b) + = canDecomposableFunTy ev eq_rel af1 (ty1,am1,ty1a,ty1b) (ty2,am2,ty2a,ty2b) -- Decompose type constructor applications -- NB: we have expanded type synonyms already @@ -384,7 +379,7 @@ can_eq_nc rewritten _rdr_env _envs ev eq_rel ty1 _ ty2 _ , let role = eqRelRole eq_rel both_generative = isGenerativeTyCon tc1 role && isGenerativeTyCon tc2 role , rewritten || both_generative - = canTyConApp ev eq_rel both_generative tc1 tys1 tc2 tys2 + = canTyConApp ev eq_rel both_generative (ty1,tc1,tys1) (ty2,tc2,tys2) can_eq_nc _rewritten _rdr_env _envs ev eq_rel s1 at ForAllTy{} _ @@ -822,19 +817,19 @@ canEqCast rewritten rdr_env envs ev eq_rel swapped ty1 co1 ty2 ps_ty2 ------------------------ canTyConApp :: CtEvidence -> EqRel - -> Bool -- Both TyCons are generative - -> TyCon -> [TcType] - -> TyCon -> [TcType] + -> Bool -- True <=> both TyCons are generative + -> (Type,TyCon,[TcType]) + -> (Type,TyCon,[TcType]) -> TcS (StopOrContinue (Either IrredCt EqCt)) -- See Note [Decomposing TyConApp equalities] -- Neither tc1 nor tc2 is a saturated funTyCon, nor a type family -- But they can be data families. -canTyConApp ev eq_rel both_generative tc1 tys1 tc2 tys2 +canTyConApp ev eq_rel both_generative (ty1,tc1,tys1) (ty2,tc2,tys2) | tc1 == tc2 , tys1 `equalLength` tys2 = do { inerts <- getInertSet ; if can_decompose inerts - then canDecomposableTyConAppOK ev eq_rel tc1 tys1 tys2 + then canDecomposableTyConAppOK ev eq_rel tc1 (ty1,tys1) (ty2,tys2) else canEqSoftFailure ev eq_rel ty1 ty2 } -- See Note [Skolem abstract data] in GHC.Core.Tycon @@ -1307,10 +1302,11 @@ Extra points -} canDecomposableTyConAppOK :: CtEvidence -> EqRel - -> TyCon -> [TcType] -> [TcType] + -> TyCon + -> (Type,[TcType]) -> (Type,[TcType]) -> TcS (StopOrContinue a) -- Precondition: tys1 and tys2 are the same finite length, hence "OK" -canDecomposableTyConAppOK ev eq_rel tc tys1 tys2 +canDecomposableTyConAppOK ev eq_rel tc (ty1,tys1) (ty2,tys2) = assert (tys1 `equalLength` tys2) $ do { traceTcS "canDecomposableTyConAppOK" (ppr ev $$ ppr eq_rel $$ ppr tc $$ ppr tys1 $$ ppr tys2) @@ -1327,7 +1323,11 @@ canDecomposableTyConAppOK ev eq_rel tc tys1 tys2 ; setWantedEq dest co } CtGiven { ctev_evar = evar } - | let ev_co = mkCoVarCo evar + | let pred_ty = mkPrimEqPredRole (eqRelRole eq_rel) ty1 ty2 + ev_co = mkCoVarCo (setVarType evar pred_ty) + -- setVarType: satisfy Note [mkSelCo precondition] in Coercion.hs + -- Remember: ty1/ty2 may be more fully zonked than evar + -- See the call to canonicaliseEquality in solveEquality. -> emitNewGivens loc [ (r, ty1, ty2, mkSelCo (SelTyCon i r) ev_co) | (r, ty1, ty2, i) <- zip4 tc_roles tys1 tys2 [0..] @@ -1363,10 +1363,10 @@ canDecomposableTyConAppOK ev eq_rel tc tys1 tys2 ++ repeat loc canDecomposableFunTy :: CtEvidence -> EqRel -> FunTyFlag - -> (Type,Type,Type) -- (multiplicity,arg,res) - -> (Type,Type,Type) -- (multiplicity,arg,res) + -> (Type,Type,Type,Type) -- (fun_ty,multiplicity,arg,res) + -> (Type,Type,Type,Type) -- (fun_ty,multiplicity,arg,res) -> TcS (StopOrContinue a) -canDecomposableFunTy ev eq_rel af f1@(m1,a1,r1) f2@(m2,a2,r2) +canDecomposableFunTy ev eq_rel af f1@(ty1,m1,a1,r1) f2@(ty2,m2,a2,r2) = do { traceTcS "canDecomposableFunTy" (ppr ev $$ ppr eq_rel $$ ppr f1 $$ ppr f2) ; case ev of @@ -1381,7 +1381,11 @@ canDecomposableFunTy ev eq_rel af f1@(m1,a1,r1) f2@(m2,a2,r2) ; setWantedEq dest co } CtGiven { ctev_evar = evar } - | let ev_co = mkCoVarCo evar + | let pred_ty = mkPrimEqPredRole (eqRelRole eq_rel) ty1 ty2 + ev_co = mkCoVarCo (setVarType evar pred_ty) + -- setVarType: satisfy Note [mkSelCo precondition] in Coercion.hs + -- Remember: ty1/ty2 may be more fully zonked than evar + -- See the call to canonicaliseEquality in solveEquality. -> emitNewGivens loc [ (funRole role fs, ty1, ty2, mkSelCo (SelFun fs) ev_co) | (fs, ty1, ty2) <- [ (SelMult, m1, m2) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/735951ddd7b86a8c5979ffea394797d49314c0fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/735951ddd7b86a8c5979ffea394797d49314c0fc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 15:26:59 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Oct 2023 11:26:59 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 2 commits: Wibbles Message-ID: <65256d4387a18_1b931c5f08db6c4943a9@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 12609f12 by Simon Peyton Jones at 2023-10-10T16:26:33+01:00 Wibbles - - - - - d5d52467 by Simon Peyton Jones at 2023-10-10T16:26:42+01:00 Tickish comment - - - - - 3 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Tc/Solver/Equality.hs - compiler/GHC/Types/Tickish.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -2490,6 +2490,20 @@ But it is not necessary to gather CoVars from the types of other binders. * For case-alt binders, if the type mentions a CoVar, so will the scrutinee (since it has the same type) + +Note [Simplifying ticks] +~~~~~~~~~~~~~~~~~~~~~~~~ +Here's a worry I tripped over, but have not actioned (#24078). Consider + f (Tick t e) +where f is strict. According to GHC.Core.Opt.Simplify.Iteraion.simplTick, +if (t `tickishScopesLike` SoftScope) we will float the tick to the outside: + Tick t (f e) +Fine for counting ticks, not for scoped ticks. + +Now suppose `f` is a join point `$j`. That should not lose the tail-call-ness. +We care just counting t. But here we zap tail calls precisely for + (t `tickishScopesLike` SoftScope) +To me it looks as if we should zap with precisely the negation! -} occAnal env (Tick tickish body) @@ -2499,7 +2513,7 @@ occAnal env (Tick tickish body) -- If we drop a tick due to the issues described below it's -- not the end of the world. - | tickish `tickishScopesLike` SoftScope + | tickish `tickishScopesLike` SoftScope -- Worry: see Note [Simplifying ticks] = WUD (markAllNonTail usage) (Tick tickish body') | Breakpoint _ _ ids _ <- tickish @@ -3827,7 +3841,8 @@ tagRecBinders lvl body_uds details_s , AlwaysTailCalled arity <- lookupTailCallInfo unadj_uds bndr = JoinPoint arity | otherwise - = assert (not will_be_joins) -- Should be AlwaysTailCalled if + = warnPprTrace (will_be_joins) "tagRecBinders" (ppr bndr $$ ppr bndrs) $ + -- Should be AlwaysTailCalled if NotJoinPoint -- we are making join points! -- 2. Adjust usage details of each RHS, taking into account the ===================================== compiler/GHC/Tc/Solver/Equality.hs ===================================== @@ -49,7 +49,6 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Misc import GHC.Utils.Monad -import GHC.Utils.Constants( debugIsOn ) import GHC.Data.Pair import GHC.Data.Bag @@ -843,13 +842,6 @@ canTyConApp ev eq_rel both_generative (ty1,tc1,tys1) (ty2,tc2,tys2) then canEqHardFailure ev ty1 ty2 else canEqSoftFailure ev eq_rel ty1 ty2 where - -- Reconstruct the types for error messages. This would do - -- the wrong thing (from a pretty printing point of view) - -- for functions, because we've lost the FunTyFlag; but - -- in fact we never call canTyConApp on a saturated FunTyCon - ty1 = mkTyConApp tc1 tys1 - ty2 = mkTyConApp tc2 tys2 - -- See Note [Decomposing TyConApp equalities] -- and Note [Decomposing newtype equalities] can_decompose inerts ===================================== compiler/GHC/Types/Tickish.hs ===================================== @@ -106,9 +106,11 @@ data GenTickish pass = -- the user. ProfNote { profNoteCC :: CostCentre, -- ^ the cost centre + profNoteCount :: !Bool, -- ^ bump the entry count? profNoteScope :: !Bool -- ^ scopes over the enclosed expression -- (i.e. not just a tick) + -- Invariant: the False/False case never happens } -- | A "tick" used by HPC to track the execution of each View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/735951ddd7b86a8c5979ffea394797d49314c0fc...d5d5246735d309504863bfc1066b40e2beda2a62 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/735951ddd7b86a8c5979ffea394797d49314c0fc...d5d5246735d309504863bfc1066b40e2beda2a62 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 15:44:37 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Oct 2023 11:44:37 -0400 Subject: [Git][ghc/ghc][wip/andreask/keep-auto-rules] 17 commits: Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" Message-ID: <65257165467af_1b931c5f5450d8502993@gitlab.mail> Simon Peyton Jones pushed to branch wip/andreask/keep-auto-rules at Glasgow Haskell Compiler / GHC Commits: 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 30 changed files: - .gitignore - .gitlab/ci.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Debug.hs - compiler/GHC/ThToHs.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/using-optimisation.rst - driver/ghci/ghci-wrapper.cabal.in - hadrian/cabal.project - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Settings/Packages.hs - libraries/base/GHC/IO/FD.hs - libraries/base/changelog.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a72a7ade0d6414376dea23396086115d6b089d6...e96c51cbd137113ec953d8b7b0817d2d268f3c96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a72a7ade0d6414376dea23396086115d6b089d6...e96c51cbd137113ec953d8b7b0817d2d268f3c96 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 16:06:08 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 10 Oct 2023 12:06:08 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22423 Message-ID: <65257670a71a6_1b931c600133ac520462@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22423 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22423 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 16:10:49 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 12:10:49 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 24 commits: hadrian: Add ghcToolchain to tool args list Message-ID: <65257789bbf7_1b931c600dfee852858d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c83ae3b8 by Matthew Pickering at 2023-10-10T12:56:54+00:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 8fbe6b29 by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - d4cd6785 by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 671bb1ce by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 4725c6b7 by Matthew Pickering at 2023-10-10T12:56:54+00:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - ab592988 by Ben Gamari at 2023-10-10T12:56:54+00:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - 10db17bc by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - 28db40d3 by Matthew Pickering at 2023-10-10T12:56:54+00:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 822ac14d by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 7c8219c3 by Matthew Pickering at 2023-10-10T12:56:54+00:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 72d251fb by Matthew Pickering at 2023-10-10T12:56:54+00:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - e2381d3c by Matthew Pickering at 2023-10-10T12:56:54+00:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - edddacd5 by Matthew Pickering at 2023-10-10T12:56:54+00:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 3888d96e by Matthew Pickering at 2023-10-10T12:56:54+00:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 2862475a by Ben Gamari at 2023-10-10T12:56:54+00:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 1dc979f4 by Matthew Pickering at 2023-10-10T12:56:54+00:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - f42c4bfa by Ben Gamari at 2023-10-10T12:56:54+00:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 062beed5 by Sebastian Graf at 2023-10-10T12:09:57-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - 4c55ca63 by Bryan Richter at 2023-10-10T12:09:58-04:00 rel_eng/upload.sh cleanups - - - - - 48b0ed9f by doyougnu at 2023-10-10T12:10:01-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - 55d56ef3 by Matthew Craven at 2023-10-10T12:10:01-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - 8d49938a by Andreas Klebinger at 2023-10-10T12:10:01-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 97d065ee by Andreas Klebinger at 2023-10-10T12:10:01-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - c48f2a4f by Andreas Klebinger at 2023-10-10T12:10:01-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 28 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Unit/Types.hs - configure.ac - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Builders/Cabal.hs - m4/find_merge_objects.m4 - m4/fp_cc_supports_target.m4 - m4/fp_gcc_supports_no_pie.m4 - + m4/fp_prog_cc_linker_target.m4 - m4/ghc_toolchain.m4 - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/ghc-toolchain.cabal - + utils/ghc-toolchain/src/GHC/Toolchain/NormaliseTriple.hs - utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs - utils/ghc-toolchain/src/GHC/Toolchain/PlatformDetails.hs - utils/ghc-toolchain/src/GHC/Toolchain/Program.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -604,6 +604,7 @@ data Rule = ReleaseOnly -- ^ Only run this job in a release pipeline data ValidateRule = FullCI -- ^ Run this job when the "full-ci" label is present. | LLVMBackend -- ^ Run this job when the "LLVM backend" label is present + | JSBackend -- ^ Run this job when the "javascript" label is present | FreeBSDLabel -- ^ Run this job when the "FreeBSD" label is set. | NonmovingGc -- ^ Run this job when the "non-moving GC" label is set. | IpeData -- ^ Run this job when the "IPE" label is set @@ -648,11 +649,12 @@ validateRuleString FullCI = or_all ([ labelString "full-ci" , branchStringLike "ghc-[0-9]+\\.[0-9]+" ]) -validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString JSBackend = labelString "javascript" validateRuleString FreeBSDLabel = labelString "FreeBSD" -validateRuleString NonmovingGc = labelString "non-moving GC" -validateRuleString IpeData = labelString "IPE" -validateRuleString TestPrimops = labelString "test-primops" +validateRuleString NonmovingGc = labelString "non-moving GC" +validateRuleString IpeData = labelString "IPE" +validateRuleString TestPrimops = labelString "test-primops" -- | A 'Job' is the description of a single job in a gitlab pipeline. The -- job contains all the information about how to do the build but can be further @@ -1010,10 +1012,9 @@ job_groups = , disableValidate (standardBuildsWithConfig AArch64 (Linux Alpine318) (splitSectionsBroken vanilla)) , fullyStaticBrokenTests (disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine312) staticNativeInt))) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure") - ) - { bignumBackend = Native - } + + , addValidateRule JSBackend (validateBuilds Amd64 (Linux Debian11) javascriptConfig) + , make_wasm_jobs wasm_build_config , modifyValidateJobs manual $ make_wasm_jobs wasm_build_config {bignumBackend = Native} @@ -1024,6 +1025,8 @@ job_groups = ] where + javascriptConfig = (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure")) + { bignumBackend = Native } -- ghcilink002 broken due to #17869 -- ===================================== .gitlab/jobs.yaml ===================================== @@ -5255,7 +5255,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -1,6 +1,7 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p moreutils lzip zip lftp gnupg -set -e +set -Eeuo pipefail # This is a script for preparing and uploading a release of GHC. # @@ -30,21 +31,15 @@ set -e # # Prerequisites: moreutils -if [ -z "$SIGNING_KEY" ]; then - SIGNING_KEY="=Benjamin Gamari " -fi +: ${SIGNING_KEY:="=Benjamin Gamari "} # Infer release name from directory name -if [ -z "$rel_name" ]; then - rel_name="$(basename $(pwd))" -fi +: ${rel_name:=$(basename $(pwd))} # Infer version from tarball names -if [ -z "$ver" ]; then - ver="$(ls ghc-*.tar.* | sed -ne 's/ghc-\([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).\+/\1/p' | head -n1)" - if [ -z "$ver" ]; then echo "Failed to infer \$ver"; exit 1; fi -fi +: ${ver:=$(ls ghc-*.tar.* | sed -ne 's/ghc-\([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).\+/\1/p' | head -n1)} +if [ -z "$ver" ]; then echo "Failed to infer \$ver"; exit 1; fi host="gitlab-storage.haskell.org" @@ -141,6 +136,7 @@ function upload() { } function purge_all() { + dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -196,6 +192,7 @@ function prepare_docs() { } function recompress() { + set -Eeuo pipefail combine <(basename -s .xz *.xz) not <(basename -s .lz *.lz) | \ parallel 'echo "Recompressing {}.xz to {}.lz"; unxz -c {}.xz | lzip - -o {}.lz' ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -380,6 +380,114 @@ getSomeReg expr = do Fixed rep reg code -> return (reg, rep, code) +{- Note [Aarch64 immediates] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Aarch64 with it's fixed width instruction encoding uses leftover space for +immediates. +If you want the full rundown consult the arch reference document: +"Arm® Architecture Reference Manual" - "C3.4 Data processing - immediate" + +The gist of it is that different instructions allow for different immediate encodings. +The ones we care about for better code generation are: + +* Simple but potentially repeated bit-patterns for logic instructions. +* 16bit numbers shifted by multiples of 16. +* 12 bit numbers optionally shifted by 12 bits. + +It might seem like the ISA allows for 64bit immediates but this isn't the case. +Rather there are some instruction aliases which allow for large unencoded immediates +which will then be transalted to one of the immediate encodings implicitly. + +For example mov x1, #0x10000 is allowed but will be assembled to movz x1, #0x1, lsl #16 +-} + +-- | Move (wide immediate) +-- Allows for 16bit immediate which can be shifted by 0/16/32/48 bits. +-- Used with MOVZ,MOVN, MOVK +-- See Note [Aarch64 immediates] +getMovWideImm :: Integer -> Width -> Maybe Operand +getMovWideImm n w + -- TODO: Handle sign extension/negatives + | n <= 0 + = Nothing + -- Fits in 16 bits + | sized_n < 2^(16 :: Int) + = Just $ OpImm (ImmInteger truncated) + + -- 0x0000 0000 xxxx 0000 + | trailing_zeros >= 16 && sized_n < 2^(32 :: Int) + = Just $ OpImmShift (ImmInteger $ truncated `shiftR` 16) SLSL 16 + + -- 0x 0000 xxxx 0000 0000 + | trailing_zeros >= 32 && sized_n < 2^(48 :: Int) + = Just $ OpImmShift (ImmInteger $ truncated `shiftR` 32) SLSL 32 + + -- 0x xxxx 0000 0000 0000 + | trailing_zeros >= 48 + = Just $ OpImmShift (ImmInteger $ truncated `shiftR` 48) SLSL 48 + + | otherwise + = Nothing + where + truncated = narrowU w n + sized_n = fromIntegral truncated :: Word64 + trailing_zeros = countTrailingZeros sized_n + +-- | Arithmetic(immediate) +-- Allows for 12bit immediates which can be shifted by 0 or 12 bits. +-- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- See Note [Aarch64 immediates] +getArithImm :: Integer -> Width -> Maybe Operand +getArithImm n w + -- TODO: Handle sign extension + | n <= 0 + = Nothing + -- Fits in 16 bits + -- Fits in 12 bits + | sized_n < 2^(12::Int) + = Just $ OpImm (ImmInteger truncated) + + -- 12 bits shifted by 12 places. + | trailing_zeros >= 12 && sized_n < 2^(24::Int) + = Just $ OpImmShift (ImmInteger $ truncated `shiftR` 12) SLSL 12 + + | otherwise + = Nothing + where + sized_n = fromIntegral truncated :: Word64 + truncated = narrowU w n + trailing_zeros = countTrailingZeros sized_n + +-- | Logical (immediate) +-- Allows encoding of some repeated bitpatterns +-- Used with AND, ANDS, EOR, ORR, TST +-- and their aliases which includes at least MOV (bitmask immediate) +-- See Note [Aarch64 immediates] +getBitmaskImm :: Integer -> Width -> Maybe Operand +getBitmaskImm n w + | isAArch64Bitmask (opRegWidth w) truncated = Just $ OpImm (ImmInteger truncated) + | otherwise = Nothing + where + truncated = narrowU w n + +-- | Load/store immediate. +-- Depends on the width of the store to some extent. +isOffsetImm :: Int -> Width -> Bool +isOffsetImm off w + -- 8 bits + sign for unscaled offsets + | -256 <= off, off <= 255 = True + -- Offset using 12-bit positive immediate, scaled by width + -- LDR/STR: imm12: if reg is 32bit: 0 -- 16380 in multiples of 4 + -- LDR/STR: imm12: if reg is 64bit: 0 -- 32760 in multiples of 8 + -- 16-bit: 0 .. 8188, 8-bit: 0 -- 4095 + | 0 <= off, off < 4096 * byte_width, off `mod` byte_width == 0 = True + | otherwise = False + where + byte_width = widthInBytes w + + + + -- TODO OPT: we might be able give getRegister -- a hint, what kind of register we want. getFloatReg :: HasCallStack => CmmExpr -> NatM (Reg, Format, InstrBlock) @@ -502,8 +610,14 @@ getRegister' config plat expr CmmLit lit -> case lit of - -- TODO handle CmmInt 0 specially, use wzr or xzr. - + -- Use wzr xzr for CmmInt 0 if the width matches up, otherwise do a move. + -- TODO: Reenable after https://gitlab.haskell.org/ghc/ghc/-/issues/23632 is fixed. + -- CmmInt 0 W32 -> do + -- let format = intFormat W32 + -- return (Fixed format reg_zero (unitOL $ (COMMENT ((text . show $ expr))) )) + -- CmmInt 0 W64 -> do + -- let format = intFormat W64 + -- return (Fixed format reg_zero (unitOL $ (COMMENT ((text . show $ expr))) )) CmmInt i W8 | i >= 0 -> do return (Any (intFormat W8) (\dst -> unitOL $ annExpr expr (MOV (OpReg W8 dst) (OpImm (ImmInteger (narrowU W8 i)))))) CmmInt i W16 | i >= 0 -> do @@ -518,8 +632,13 @@ getRegister' config plat expr -- Those need the upper bits set. We'd either have to explicitly sign -- or figure out something smarter. Lowered to -- `MOV dst XZR` + CmmInt i w | i >= 0 + , Just imm_op <- getMovWideImm i w -> do + return (Any (intFormat w) (\dst -> unitOL $ annExpr expr (MOVZ (OpReg w dst) imm_op))) + CmmInt i w | isNbitEncodeable 16 i, i >= 0 -> do return (Any (intFormat w) (\dst -> unitOL $ annExpr expr (MOV (OpReg W16 dst) (OpImm (ImmInteger i))))) + CmmInt i w | isNbitEncodeable 32 i, i >= 0 -> do let half0 = fromIntegral (fromIntegral i :: Word16) half1 = fromIntegral (fromIntegral (i `shiftR` 16) :: Word16) @@ -594,7 +713,6 @@ getRegister' config plat expr (op, imm_code) <- litToImm' lit let rep = cmmLitType plat lit format = cmmTypeFormat rep - -- width = typeWidth rep return (Any format (\dst -> imm_code `snocOL` LDR format (OpReg (formatToWidth format) dst) op)) CmmLabelOff lbl off -> do @@ -618,18 +736,11 @@ getRegister' config plat expr -> return (Fixed (cmmTypeFormat (cmmRegType reg)) (getRegisterReg plat reg) nilOL) - CmmRegOff reg off | isNbitEncodeable 12 (fromIntegral off) -> do - getRegister' config plat $ - CmmMachOp (MO_Add width) [CmmReg reg, CmmLit (CmmInt (fromIntegral off) width)] - where width = typeWidth (cmmRegType reg) - - CmmRegOff reg off -> do - (off_r, _off_format, off_code) <- getSomeReg $ CmmLit (CmmInt (fromIntegral off) width) - (reg, _format, code) <- getSomeReg $ CmmReg reg - return $ Any (intFormat width) (\dst -> off_code `appOL` code `snocOL` ADD (OpReg width dst) (OpReg width reg) (OpReg width off_r)) - where width = typeWidth (cmmRegType reg) - - + CmmRegOff reg off -> + -- If we got here we will load the address into a register either way. So we might as well just expand + -- and re-use the existing code path to handle "reg + off". + let !width = cmmRegWidth reg + in getRegister' config plat (CmmMachOp (MO_Add width) [CmmReg reg, CmmLit (CmmInt (fromIntegral off) width)]) -- for MachOps, see GHC.Cmm.MachOp -- For CmmMachOp, see GHC.Cmm.Expr @@ -701,33 +812,25 @@ getRegister' config plat expr -- 0. TODO This should not exist! Rewrite: Reg +- 0 -> Reg CmmMachOp (MO_Add _) [expr'@(CmmReg (CmmGlobal _r)), CmmLit (CmmInt 0 _)] -> getRegister' config plat expr' CmmMachOp (MO_Sub _) [expr'@(CmmReg (CmmGlobal _r)), CmmLit (CmmInt 0 _)] -> getRegister' config plat expr' - -- 1. Compute Reg +/- n directly. - -- For Add/Sub we can directly encode 12bits, or 12bits lsl #12. - CmmMachOp (MO_Add w) [(CmmReg reg), CmmLit (CmmInt n _)] - | n > 0 && n < 4096 -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (ADD (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) - -- TODO: 12bits lsl #12; e.g. lower 12 bits of n are 0; shift n >> 12, and set lsl to #12. - where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) - r' = getRegisterReg plat reg - CmmMachOp (MO_Sub w) [(CmmReg reg), CmmLit (CmmInt n _)] - | n > 0 && n < 4096 -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (SUB (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) - -- TODO: 12bits lsl #12; e.g. lower 12 bits of n are 0; shift n >> 12, and set lsl to #12. - where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) - r' = getRegisterReg plat reg + -- Immediates are handled via `getArithImm` in the generic code path. CmmMachOp (MO_U_Quot w) [x, y] | w == W8 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (UXTB (OpReg w reg_y) (OpReg w reg_y)) `snocOL` (UDIV (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (UXTB (OpReg w reg_y) (OpReg w reg_y)) `snocOL` + (UDIV (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) CmmMachOp (MO_U_Quot w) [x, y] | w == W16 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (UXTH (OpReg w reg_y) (OpReg w reg_y)) `snocOL` (UDIV (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (UXTH (OpReg w reg_y) (OpReg w reg_y)) `snocOL` + (UDIV (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) -- 2. Shifts. x << n, x >> n. - CmmMachOp (MO_Shl w) [x, (CmmLit (CmmInt n _))] | w == W32, 0 <= n, n < 32 -> do - (reg_x, _format_x, code_x) <- getSomeReg x - return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) - CmmMachOp (MO_Shl w) [x, (CmmLit (CmmInt n _))] | w == W64, 0 <= n, n < 64 -> do + CmmMachOp (MO_Shl w) [x, (CmmLit (CmmInt n _))] + | w == W32 || w == W64 + , 0 <= n, n < fromIntegral (widthInBits w) -> do (reg_x, _format_x, code_x) <- getSomeReg x return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) @@ -737,7 +840,8 @@ getRegister' config plat expr CmmMachOp (MO_S_Shr w) [x, y] | w == W8 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (SXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (SXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) CmmMachOp (MO_S_Shr w) [x, (CmmLit (CmmInt n _))] | w == W16, 0 <= n, n < 16 -> do (reg_x, _format_x, code_x) <- getSomeReg x @@ -745,24 +849,23 @@ getRegister' config plat expr CmmMachOp (MO_S_Shr w) [x, y] | w == W16 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (SXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) - - CmmMachOp (MO_S_Shr w) [x, (CmmLit (CmmInt n _))] | w == W32, 0 <= n, n < 32 -> do - (reg_x, _format_x, code_x) <- getSomeReg x - return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (ASR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (SXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) - CmmMachOp (MO_S_Shr w) [x, (CmmLit (CmmInt n _))] | w == W64, 0 <= n, n < 64 -> do + CmmMachOp (MO_S_Shr w) [x, (CmmLit (CmmInt n _))] + | w == W32 || w == W64 + , 0 <= n, n < fromIntegral (widthInBits w) -> do (reg_x, _format_x, code_x) <- getSomeReg x return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (ASR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) - CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] | w == W8, 0 <= n, n < 8 -> do (reg_x, _format_x, code_x) <- getSomeReg x return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (UBFX (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)) (OpImm (ImmInteger (8-n))))) CmmMachOp (MO_U_Shr w) [x, y] | w == W8 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] | w == W16, 0 <= n, n < 16 -> do (reg_x, _format_x, code_x) <- getSomeReg x @@ -770,13 +873,12 @@ getRegister' config plat expr CmmMachOp (MO_U_Shr w) [x, y] | w == W16 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTH (OpReg w reg_x) (OpReg w reg_x)) + `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) - CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] | w == W32, 0 <= n, n < 32 -> do - (reg_x, _format_x, code_x) <- getSomeReg x - return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) - - CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] | w == W64, 0 <= n, n < 64 -> do + CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] + | w == W32 || w == W64 + , 0 <= n, n < fromIntegral (widthInBits w) -> do (reg_x, _format_x, code_x) <- getSomeReg x return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) @@ -799,17 +901,51 @@ getRegister' config plat expr -- withTempFloatReg w op = OpReg w <$> getNewRegNat (floatFormat w) >>= op -- A "plain" operation. - bitOp w op = do + bitOpImm w op encode_imm = do -- compute x <- x -- compute x <- y -- x, x, x (reg_x, format_x, code_x) <- getSomeReg x - (reg_y, format_y, code_y) <- getSomeReg y - massertPpr (isIntFormat format_x == isIntFormat format_y) $ text "bitOp: incompatible" + (op_y, format_y, code_y) <- case y of + CmmLit (CmmInt n w) + | Just imm_operand_y <- encode_imm n w + -> return (imm_operand_y, intFormat w, nilOL) + _ -> do + (reg_y, format_y, code_y) <- getSomeReg y + return (OpReg w reg_y, format_y, code_y) + massertPpr (isIntFormat format_x == isIntFormat format_y) $ text "bitOpImm: incompatible" return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `appOL` - op (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y)) + op (OpReg w dst) (OpReg w reg_x) op_y) + + -- A (potentially signed) integer operation. + -- In the case of 8- and 16-bit signed arithmetic we must first + -- sign-extend both arguments to 32-bits. + -- See Note [Signed arithmetic on AArch64]. + intOpImm :: Bool -> Width -> (Operand -> Operand -> Operand -> OrdList Instr) -> (Integer -> Width -> Maybe Operand) -> NatM (Register) + intOpImm {- is signed -} True w op _encode_imm = intOp True w op + intOpImm False w op encode_imm = do + -- compute x <- x + -- compute x <- y + -- x, x, x + (reg_x, format_x, code_x) <- getSomeReg x + (op_y, format_y, code_y) <- case y of + CmmLit (CmmInt n w) + | Just imm_operand_y <- encode_imm n w + -> return (imm_operand_y, intFormat w, nilOL) + _ -> do + (reg_y, format_y, code_y) <- getSomeReg y + return (OpReg w reg_y, format_y, code_y) + massertPpr (isIntFormat format_x && isIntFormat format_y) $ text "intOp: non-int" + -- This is the width of the registers on which the operation + -- should be performed. + let w' = opRegWidth w + return $ Any (intFormat w) $ \dst -> + code_x `appOL` + code_y `appOL` + op (OpReg w' dst) (OpReg w' reg_x) (op_y) `appOL` + truncateReg w' w dst -- truncate back to the operand's original width -- A (potentially signed) integer operation. -- In the case of 8- and 16-bit signed arithmetic we must first @@ -855,9 +991,9 @@ getRegister' config plat expr case op of -- Integer operations -- Add/Sub should only be Integer Options. - MO_Add w -> intOp False w (\d x y -> unitOL $ annExpr expr (ADD d x y)) + MO_Add w -> intOpImm False w (\d x y -> unitOL $ annExpr expr (ADD d x y)) getArithImm -- TODO: Handle sub-word case - MO_Sub w -> intOp False w (\d x y -> unitOL $ annExpr expr (SUB d x y)) + MO_Sub w -> intOpImm False w (\d x y -> unitOL $ annExpr expr (SUB d x y)) getArithImm -- Note [CSET] -- ~~~~~~~~~~~ @@ -899,8 +1035,8 @@ getRegister' config plat expr -- N.B. We needn't sign-extend sub-word size (in)equality comparisons -- since we don't care about ordering. - MO_Eq w -> bitOp w (\d x y -> toOL [ CMP x y, CSET d EQ ]) - MO_Ne w -> bitOp w (\d x y -> toOL [ CMP x y, CSET d NE ]) + MO_Eq w -> bitOpImm w (\d x y -> toOL [ CMP x y, CSET d EQ ]) getArithImm + MO_Ne w -> bitOpImm w (\d x y -> toOL [ CMP x y, CSET d NE ]) getArithImm -- Signed multiply/divide MO_Mul w -> intOp True w (\d x y -> unitOL $ MUL d x y) @@ -929,10 +1065,10 @@ getRegister' config plat expr MO_S_Lt w -> intOp True w (\d x y -> toOL [ CMP x y, CSET d SLT ]) -- Unsigned comparisons - MO_U_Ge w -> intOp False w (\d x y -> toOL [ CMP x y, CSET d UGE ]) - MO_U_Le w -> intOp False w (\d x y -> toOL [ CMP x y, CSET d ULE ]) - MO_U_Gt w -> intOp False w (\d x y -> toOL [ CMP x y, CSET d UGT ]) - MO_U_Lt w -> intOp False w (\d x y -> toOL [ CMP x y, CSET d ULT ]) + MO_U_Ge w -> intOpImm False w (\d x y -> toOL [ CMP x y, CSET d UGE ]) getArithImm + MO_U_Le w -> intOpImm False w (\d x y -> toOL [ CMP x y, CSET d ULE ]) getArithImm + MO_U_Gt w -> intOpImm False w (\d x y -> toOL [ CMP x y, CSET d UGT ]) getArithImm + MO_U_Lt w -> intOpImm False w (\d x y -> toOL [ CMP x y, CSET d ULT ]) getArithImm -- Floating point arithmetic MO_F_Add w -> floatOp w (\d x y -> unitOL $ ADD d x y) @@ -955,9 +1091,9 @@ getRegister' config plat expr MO_F_Lt w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d OLT ]) -- x < y <=> y >= x -- Bitwise operations - MO_And w -> bitOp w (\d x y -> unitOL $ AND d x y) - MO_Or w -> bitOp w (\d x y -> unitOL $ ORR d x y) - MO_Xor w -> bitOp w (\d x y -> unitOL $ EOR d x y) + MO_And w -> bitOpImm w (\d x y -> unitOL $ AND d x y) getBitmaskImm + MO_Or w -> bitOpImm w (\d x y -> unitOL $ ORR d x y) getBitmaskImm + MO_Xor w -> bitOpImm w (\d x y -> unitOL $ EOR d x y) getBitmaskImm MO_Shl w -> intOp False w (\d x y -> unitOL $ LSL d x y) MO_U_Shr w -> intOp False w (\d x y -> unitOL $ LSR d x y) MO_S_Shr w -> intOp True w (\d x y -> unitOL $ ASR d x y) @@ -1007,7 +1143,7 @@ getRegister' config plat expr where isNbitEncodeable :: Int -> Integer -> Bool - isNbitEncodeable n i = let shift = n - 1 in (-1 `shiftL` shift) <= i && i < (1 `shiftL` shift) + isNbitEncodeable n_bits i = let shift = n_bits - 1 in (-1 `shiftL` shift) <= i && i < (1 `shiftL` shift) -- N.B. MUL does not set the overflow flag. -- These implementations are based on output from GCC 11. @@ -1146,20 +1282,8 @@ getAmode :: Platform -- OPTIMIZATION WARNING: Addressing modes. -- Addressing options: --- LDUR/STUR: imm9: -256 - 255 -getAmode platform _ (CmmRegOff reg off) | -256 <= off, off <= 255 - = return $ Amode (AddrRegImm reg' off') nilOL - where reg' = getRegisterReg platform reg - off' = ImmInt off --- LDR/STR: imm12: if reg is 32bit: 0 -- 16380 in multiples of 4 -getAmode platform W32 (CmmRegOff reg off) - | 0 <= off, off <= 16380, off `mod` 4 == 0 - = return $ Amode (AddrRegImm reg' off') nilOL - where reg' = getRegisterReg platform reg - off' = ImmInt off --- LDR/STR: imm12: if reg is 64bit: 0 -- 32760 in multiples of 8 -getAmode platform W64 (CmmRegOff reg off) - | 0 <= off, off <= 32760, off `mod` 8 == 0 +getAmode platform w (CmmRegOff reg off) + | isOffsetImm off w = return $ Amode (AddrRegImm reg' off') nilOL where reg' = getRegisterReg platform reg off' = ImmInt off @@ -1168,15 +1292,15 @@ getAmode platform W64 (CmmRegOff reg off) -- CmmStore (CmmMachOp (MO_Add w) [CmmLoad expr, CmmLit (CmmInt n w')]) (expr2) -- E.g. a CmmStoreOff really. This can be translated to `str $expr2, [$expr, #n ] -- for `n` in range. -getAmode _platform _ (CmmMachOp (MO_Add _w) [expr, CmmLit (CmmInt off _w')]) - | -256 <= off, off <= 255 +getAmode _platform w (CmmMachOp (MO_Add _w) [expr, CmmLit (CmmInt off _w')]) + | isOffsetImm (fromIntegral off) w = do (reg, _format, code) <- getSomeReg expr return $ Amode (AddrRegImm reg (ImmInteger off)) code -getAmode _platform _ (CmmMachOp (MO_Sub _w) [expr, CmmLit (CmmInt off _w')]) - | -256 <= -off, -off <= 255 +getAmode _platform w (CmmMachOp (MO_Sub _w) [expr, CmmLit (CmmInt off _w')]) + | isOffsetImm (fromIntegral $ -off) w = do (reg, _format, code) <- getSomeReg expr - return $ Amode (AddrRegImm reg (ImmInteger (-off))) code + return $ Amode (AddrRegImm reg (ImmInteger $ -off)) code -- Generic case getAmode _platform _ expr ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -110,6 +110,7 @@ regUsageOfInstr platform instr = case instr of LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) MOV dst src -> usage (regOp src, regOp dst) MOVK dst src -> usage (regOp src, regOp dst) + MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -251,6 +252,7 @@ patchRegsOfInstr instr env = case instr of LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) MOV o1 o2 -> MOV (patchOp o1) (patchOp o2) MOVK o1 o2 -> MOVK (patchOp o1) (patchOp o2) + MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) @@ -381,9 +383,8 @@ mkSpillInstr config reg delta slot = where a .&~. b = a .&. (complement b) - fmt = case reg of - RegReal (RealRegSingle n) | n < 32 -> II64 - _ -> FF64 + fmt = fmtOfRealReg (case reg of { RegReal r -> r; _ -> panic "Expected real reg"}) + mkIp0SpillAddr imm = ANN (text "Spill: IP0 <- SP + " <> int imm) $ ADD ip0 sp (OpImm (ImmInt imm)) mkStrSp imm = ANN (text "Spill@" <> int (off - delta)) $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt imm))) mkStrIp0 imm = ANN (text "Spill@" <> int (off - delta)) $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 16) (ImmInt imm))) @@ -408,9 +409,7 @@ mkLoadInstr config reg delta slot = where a .&~. b = a .&. (complement b) - fmt = case reg of - RegReal (RealRegSingle n) | n < 32 -> II64 - _ -> FF64 + fmt = fmtOfRealReg (case reg of { RegReal r -> r; _ -> panic "Expected real reg"}) mkIp0SpillAddr imm = ANN (text "Reload: IP0 <- SP + " <> int imm) $ ADD ip0 sp (OpImm (ImmInt imm)) mkLdrSp imm = ANN (text "Reload@" <> int (off - delta)) $ LDR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt imm))) @@ -619,7 +618,7 @@ data Instr | MOV Operand Operand -- rd = rn or rd = #i | MOVK Operand Operand -- | MOVN Operand Operand - -- | MOVZ Operand Operand + | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 @@ -708,6 +707,7 @@ instrCon i = LSR{} -> "LSR" MOV{} -> "MOV" MOVK{} -> "MOVK" + MOVZ{} -> "MOVZ" MVN{} -> "MVN" ORN{} -> "ORN" ORR{} -> "ORR" @@ -783,6 +783,9 @@ wzr = OpReg W32 (RegReal (RealRegSingle (-1))) sp = OpReg W64 (RegReal (RealRegSingle 31)) ip0 = OpReg W64 (RegReal (RealRegSingle 16)) +reg_zero :: Reg +reg_zero = RegReal (RealRegSingle (-1)) + _x :: Int -> Operand _x i = OpReg W64 (RegReal (RealRegSingle i)) x0, x1, x2, x3, x4, x5, x6, x7 :: Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -418,6 +418,7 @@ pprInstr platform instr = case instr of | isFloatOp o1 || isFloatOp o2 -> op2 (text "\tfmov") o1 o2 | otherwise -> op2 (text "\tmov") o1 o2 MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 + MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 ===================================== compiler/GHC/CmmToAsm/AArch64/Regs.hs ===================================== @@ -77,6 +77,8 @@ litToImm (CmmInt i w) = ImmInteger (narrowS w i) -- narrow to the width: a CmmInt might be out of -- range, but we assume that ImmInteger only contains -- in-range values. A signed value should be fine here. + -- AK: We do call this with out of range values, however + -- it just truncates as we would expect. litToImm (CmmFloat f W32) = ImmFloat f litToImm (CmmFloat f W64) = ImmDouble f litToImm (CmmLabel l) = ImmCLbl l @@ -147,6 +149,13 @@ classOfRealReg (RealRegSingle i) | i < 32 = RcInteger | otherwise = RcDouble +fmtOfRealReg :: RealReg -> Format +fmtOfRealReg real_reg = + case classOfRealReg real_reg of + RcInteger -> II64 + RcDouble -> FF64 + RcFloat -> panic "No float regs on arm" + regDotColor :: RealReg -> SDoc regDotColor reg = case classOfRealReg reg of ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -695,7 +695,7 @@ data WarningFlag = | Opt_WarnIncompleteRecordSelectors -- Since 9.10 | Opt_WarnBadlyStagedTypes -- Since 9.10 | Opt_WarnInconsistentFlags -- Since 9.8 - deriving (Eq, Ord, Show, Enum) + deriving (Eq, Ord, Show, Enum, Bounded) -- | Return the names of a WarningFlag -- ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2165,127 +2165,125 @@ wWarningFlags :: [FlagSpec WarningFlag] wWarningFlags = map snd (sortBy (comparing fst) wWarningFlagsDeps) wWarningFlagsDeps :: [(Deprecation, FlagSpec WarningFlag)] -wWarningFlagsDeps = mconcat [ +wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of -- See Note [Updating flag description in the User's Guide] -- See Note [Supporting CLI completion] --- Please keep the list of flags below sorted alphabetically - warnSpec Opt_WarnAlternativeLayoutRuleTransitional, - warnSpec Opt_WarnAmbiguousFields, - depWarnSpec Opt_WarnAutoOrphans - "it has no effect", - warnSpec Opt_WarnCPPUndef, - warnSpec Opt_WarnUnbangedStrictPatterns, - warnSpec Opt_WarnDeferredTypeErrors, - warnSpec Opt_WarnDeferredOutOfScopeVariables, - warnSpec Opt_WarnDeprecatedFlags, - warnSpec Opt_WarnDerivingDefaults, - warnSpec Opt_WarnDerivingTypeable, - warnSpec Opt_WarnDodgyExports, - warnSpec Opt_WarnDodgyForeignImports, - warnSpec Opt_WarnDodgyImports, - warnSpec Opt_WarnEmptyEnumerations, - subWarnSpec "duplicate-constraints" - Opt_WarnDuplicateConstraints - "it is subsumed by -Wredundant-constraints", - warnSpec Opt_WarnRedundantConstraints, - warnSpec Opt_WarnDuplicateExports, - depWarnSpec Opt_WarnHiShadows - "it is not used, and was never implemented", - warnSpec Opt_WarnInaccessibleCode, - warnSpec Opt_WarnImplicitPrelude, - depWarnSpec Opt_WarnImplicitKindVars - "it is now an error", - warnSpec Opt_WarnIncompletePatterns, - warnSpec Opt_WarnIncompletePatternsRecUpd, - warnSpec Opt_WarnIncompleteUniPatterns, - warnSpec Opt_WarnInlineRuleShadowing, - warnSpec Opt_WarnIdentities, - warnSpec Opt_WarnMissingFields, - warnSpec Opt_WarnMissingImportList, - warnSpec Opt_WarnMissingExportList, - subWarnSpec "missing-local-sigs" - Opt_WarnMissingLocalSignatures - "it is replaced by -Wmissing-local-signatures", - warnSpec Opt_WarnMissingLocalSignatures, - warnSpec Opt_WarnMissingMethods, - depWarnSpec Opt_WarnMissingMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnSemigroup, - warnSpec Opt_WarnMissingSignatures, - warnSpec Opt_WarnMissingKindSignatures, - warnSpec Opt_WarnMissingPolyKindSignatures, - subWarnSpec "missing-exported-sigs" - Opt_WarnMissingExportedSignatures - "it is replaced by -Wmissing-exported-signatures", - warnSpec Opt_WarnMissingExportedSignatures, - warnSpec Opt_WarnMonomorphism, - warnSpec Opt_WarnNameShadowing, - warnSpec Opt_WarnNonCanonicalMonadInstances, - depWarnSpec Opt_WarnNonCanonicalMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnNonCanonicalMonoidInstances, - warnSpec Opt_WarnOrphans, - warnSpec Opt_WarnOverflowedLiterals, - warnSpec Opt_WarnOverlappingPatterns, - warnSpec Opt_WarnMissedSpecs, - warnSpec Opt_WarnAllMissedSpecs, - warnSpec' Opt_WarnSafe setWarnSafe, - warnSpec Opt_WarnTrustworthySafe, - warnSpec Opt_WarnInferredSafeImports, - warnSpec Opt_WarnMissingSafeHaskellMode, - warnSpec Opt_WarnTabs, - warnSpec Opt_WarnTypeDefaults, - warnSpec Opt_WarnTypedHoles, - warnSpec Opt_WarnPartialTypeSignatures, - warnSpec Opt_WarnUnrecognisedPragmas, - warnSpec Opt_WarnMisplacedPragmas, - warnSpec' Opt_WarnUnsafe setWarnUnsafe, - warnSpec Opt_WarnUnsupportedCallingConventions, - warnSpec Opt_WarnUnsupportedLlvmVersion, - warnSpec Opt_WarnMissedExtraSharedLib, - warnSpec Opt_WarnUntickedPromotedConstructors, - warnSpec Opt_WarnUnusedDoBind, - warnSpec Opt_WarnUnusedForalls, - warnSpec Opt_WarnUnusedImports, - warnSpec Opt_WarnUnusedLocalBinds, - warnSpec Opt_WarnUnusedMatches, - warnSpec Opt_WarnUnusedPatternBinds, - warnSpec Opt_WarnUnusedTopBinds, - warnSpec Opt_WarnUnusedTypePatterns, - warnSpec Opt_WarnUnusedRecordWildcards, - warnSpec Opt_WarnRedundantBangPatterns, - warnSpec Opt_WarnRedundantRecordWildcards, - warnSpec Opt_WarnRedundantStrictnessFlags, - warnSpec Opt_WarnWrongDoBind, - warnSpec Opt_WarnMissingPatternSynonymSignatures, - warnSpec Opt_WarnMissingDerivingStrategies, - warnSpec Opt_WarnSimplifiableClassConstraints, - warnSpec Opt_WarnMissingHomeModules, - warnSpec Opt_WarnUnrecognisedWarningFlags, - warnSpec Opt_WarnStarBinder, - warnSpec Opt_WarnStarIsType, - depWarnSpec Opt_WarnSpaceAfterBang - "bang patterns can no longer be written with a space", - warnSpec Opt_WarnPartialFields, - warnSpec Opt_WarnPrepositiveQualifiedModule, - warnSpec Opt_WarnUnusedPackages, - warnSpec Opt_WarnCompatUnqualifiedImports, - warnSpec Opt_WarnInvalidHaddock, - warnSpec Opt_WarnOperatorWhitespaceExtConflict, - warnSpec Opt_WarnOperatorWhitespace, - warnSpec Opt_WarnImplicitLift, - warnSpec Opt_WarnMissingExportedPatternSynonymSignatures, - warnSpec Opt_WarnForallIdentifier, - warnSpec Opt_WarnUnicodeBidirectionalFormatCharacters, - warnSpec Opt_WarnGADTMonoLocalBinds, - warnSpec Opt_WarnTypeEqualityOutOfScope, - warnSpec Opt_WarnTypeEqualityRequiresOperators, - warnSpec Opt_WarnTermVariableCapture, - warnSpec Opt_WarnMissingRoleAnnotations, - warnSpec Opt_WarnImplicitRhsQuantification, - warnSpec Opt_WarnIncompleteExportWarnings, - warnSpec Opt_WarnIncompleteRecordSelectors - ] + Opt_WarnAlternativeLayoutRuleTransitional -> warnSpec x + Opt_WarnAmbiguousFields -> warnSpec x + Opt_WarnAutoOrphans -> depWarnSpec x "it has no effect" + Opt_WarnCPPUndef -> warnSpec x + Opt_WarnBadlyStagedTypes -> warnSpec x + Opt_WarnUnbangedStrictPatterns -> warnSpec x + Opt_WarnDeferredTypeErrors -> warnSpec x + Opt_WarnDeferredOutOfScopeVariables -> warnSpec x + Opt_WarnDeprecatedFlags -> warnSpec x + Opt_WarnDerivingDefaults -> warnSpec x + Opt_WarnDerivingTypeable -> warnSpec x + Opt_WarnDodgyExports -> warnSpec x + Opt_WarnDodgyForeignImports -> warnSpec x + Opt_WarnDodgyImports -> warnSpec x + Opt_WarnEmptyEnumerations -> warnSpec x + Opt_WarnDuplicateConstraints + -> subWarnSpec "duplicate-constraints" x "it is subsumed by -Wredundant-constraints" + Opt_WarnRedundantConstraints -> warnSpec x + Opt_WarnDuplicateExports -> warnSpec x + Opt_WarnHiShadows + -> depWarnSpec x "it is not used, and was never implemented" + Opt_WarnInaccessibleCode -> warnSpec x + Opt_WarnImplicitPrelude -> warnSpec x + Opt_WarnImplicitKindVars -> depWarnSpec x "it is now an error" + Opt_WarnIncompletePatterns -> warnSpec x + Opt_WarnIncompletePatternsRecUpd -> warnSpec x + Opt_WarnIncompleteUniPatterns -> warnSpec x + Opt_WarnInconsistentFlags -> warnSpec x + Opt_WarnInlineRuleShadowing -> warnSpec x + Opt_WarnIdentities -> warnSpec x + Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnMissingFields -> warnSpec x + Opt_WarnMissingImportList -> warnSpec x + Opt_WarnMissingExportList -> warnSpec x + Opt_WarnMissingLocalSignatures + -> subWarnSpec "missing-local-sigs" x + "it is replaced by -Wmissing-local-signatures" + ++ warnSpec x + Opt_WarnMissingMethods -> warnSpec x + Opt_WarnMissingMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnSemigroup -> warnSpec x + Opt_WarnMissingSignatures -> warnSpec x + Opt_WarnMissingKindSignatures -> warnSpec x + Opt_WarnMissingPolyKindSignatures -> warnSpec x + Opt_WarnMissingExportedSignatures + -> subWarnSpec "missing-exported-sigs" x + "it is replaced by -Wmissing-exported-signatures" + ++ warnSpec x + Opt_WarnMonomorphism -> warnSpec x + Opt_WarnNameShadowing -> warnSpec x + Opt_WarnNonCanonicalMonadInstances -> warnSpec x + Opt_WarnNonCanonicalMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnNonCanonicalMonoidInstances -> warnSpec x + Opt_WarnOrphans -> warnSpec x + Opt_WarnOverflowedLiterals -> warnSpec x + Opt_WarnOverlappingPatterns -> warnSpec x + Opt_WarnMissedSpecs -> warnSpec x + Opt_WarnAllMissedSpecs -> warnSpec x + Opt_WarnSafe -> warnSpec' x setWarnSafe + Opt_WarnTrustworthySafe -> warnSpec x + Opt_WarnInferredSafeImports -> warnSpec x + Opt_WarnMissingSafeHaskellMode -> warnSpec x + Opt_WarnTabs -> warnSpec x + Opt_WarnTypeDefaults -> warnSpec x + Opt_WarnTypedHoles -> warnSpec x + Opt_WarnPartialTypeSignatures -> warnSpec x + Opt_WarnUnrecognisedPragmas -> warnSpec x + Opt_WarnMisplacedPragmas -> warnSpec x + Opt_WarnUnsafe -> warnSpec' x setWarnUnsafe + Opt_WarnUnsupportedCallingConventions -> warnSpec x + Opt_WarnUnsupportedLlvmVersion -> warnSpec x + Opt_WarnMissedExtraSharedLib -> warnSpec x + Opt_WarnUntickedPromotedConstructors -> warnSpec x + Opt_WarnUnusedDoBind -> warnSpec x + Opt_WarnUnusedForalls -> warnSpec x + Opt_WarnUnusedImports -> warnSpec x + Opt_WarnUnusedLocalBinds -> warnSpec x + Opt_WarnUnusedMatches -> warnSpec x + Opt_WarnUnusedPatternBinds -> warnSpec x + Opt_WarnUnusedTopBinds -> warnSpec x + Opt_WarnUnusedTypePatterns -> warnSpec x + Opt_WarnUnusedRecordWildcards -> warnSpec x + Opt_WarnRedundantBangPatterns -> warnSpec x + Opt_WarnRedundantRecordWildcards -> warnSpec x + Opt_WarnRedundantStrictnessFlags -> warnSpec x + Opt_WarnWrongDoBind -> warnSpec x + Opt_WarnMissingPatternSynonymSignatures -> warnSpec x + Opt_WarnMissingDerivingStrategies -> warnSpec x + Opt_WarnSimplifiableClassConstraints -> warnSpec x + Opt_WarnMissingHomeModules -> warnSpec x + Opt_WarnUnrecognisedWarningFlags -> warnSpec x + Opt_WarnStarBinder -> warnSpec x + Opt_WarnStarIsType -> warnSpec x + Opt_WarnSpaceAfterBang + -> depWarnSpec x "bang patterns can no longer be written with a space" + Opt_WarnPartialFields -> warnSpec x + Opt_WarnPrepositiveQualifiedModule -> warnSpec x + Opt_WarnUnusedPackages -> warnSpec x + Opt_WarnCompatUnqualifiedImports -> warnSpec x + Opt_WarnInvalidHaddock -> warnSpec x + Opt_WarnOperatorWhitespaceExtConflict -> warnSpec x + Opt_WarnOperatorWhitespace -> warnSpec x + Opt_WarnImplicitLift -> warnSpec x + Opt_WarnMissingExportedPatternSynonymSignatures -> warnSpec x + Opt_WarnForallIdentifier -> warnSpec x + Opt_WarnUnicodeBidirectionalFormatCharacters -> warnSpec x + Opt_WarnGADTMonoLocalBinds -> warnSpec x + Opt_WarnTypeEqualityOutOfScope -> warnSpec x + Opt_WarnTypeEqualityRequiresOperators -> warnSpec x + Opt_WarnTermVariableCapture -> warnSpec x + Opt_WarnMissingRoleAnnotations -> warnSpec x + Opt_WarnImplicitRhsQuantification -> warnSpec x + Opt_WarnIncompleteExportWarnings -> warnSpec x + Opt_WarnIncompleteRecordSelectors -> warnSpec x warningGroupsDeps :: [(Deprecation, FlagSpec WarningGroup)] warningGroupsDeps = map mk warningGroups ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -149,7 +149,8 @@ instance Uniquable Module where instance Binary a => Binary (GenModule a) where put_ bh (Module p n) = put_ bh p >> put_ bh n - get bh = do p <- get bh; n <- get bh; return (Module p n) + -- Module has strict fields, so use $! in order not to allocate a thunk + get bh = do p <- get bh; n <- get bh; return $! Module p n instance NFData (GenModule a) where rnf (Module unit name) = unit `seq` name `seq` () @@ -317,13 +318,14 @@ instance Binary InstantiatedUnit where cid <- get bh insts <- get bh let fs = mkInstantiatedUnitHash cid insts - return InstantiatedUnit { - instUnitInstanceOf = cid, - instUnitInsts = insts, - instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), - instUnitFS = fs, - instUnitKey = getUnique fs - } + -- InstantiatedUnit has strict fields, so use $! in order not to allocate a thunk + return $! InstantiatedUnit { + instUnitInstanceOf = cid, + instUnitInsts = insts, + instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), + instUnitFS = fs, + instUnitKey = getUnique fs + } instance IsUnitId u => Eq (GenUnit u) where uid1 == uid2 = unitUnique uid1 == unitUnique uid2 @@ -369,10 +371,12 @@ instance Binary Unit where put_ bh HoleUnit = putByte bh 2 get bh = do b <- getByte bh - case b of + u <- case b of 0 -> fmap RealUnit (get bh) 1 -> fmap VirtUnit (get bh) _ -> pure HoleUnit + -- Unit has strict fields that need forcing; otherwise we allocate a thunk. + pure $! u -- | Retrieve the set of free module holes of a 'Unit'. unitFreeModuleHoles :: GenUnit u -> UniqDSet ModuleName ===================================== configure.ac ===================================== @@ -55,6 +55,8 @@ USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2" USER_CONF_CXX_OPTS_STAGE2="$CONF_CXX_OPTS_STAGE2" USER_CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2" +USER_LD="$LD" + dnl ---------------------------------------------------------- dnl ** Find unixy sort and find commands, dnl ** which are needed by FP_SETUP_PROJECT_VERSION @@ -491,6 +493,7 @@ FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST + dnl ** Which nm to use? dnl -------------------------------------------------------------- FP_FIND_NM @@ -624,8 +627,6 @@ dnl If gcc, make sure it's at least 4.7 dnl FP_GCC_VERSION -dnl ** See whether cc supports -no-pie -FP_GCC_SUPPORTS_NO_PIE dnl ** Check support for the extra flags passed by GHC when compiling via C FP_GCC_SUPPORTS_VIA_C_FLAGS @@ -665,9 +666,16 @@ AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. -FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) -FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) -FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) +FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0]) +FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1]) +FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2]) + +FP_PROG_CC_LINKER_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) + +dnl ** See whether cc used as a linker supports -no-pie +FP_GCC_SUPPORTS_NO_PIE dnl Pass -Qunused-arguments or otherwise GHC will have very noisy invocations of Clang dnl TODO: Do we need -Qunused-arguments in CXX and GCC linker too? ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -159,6 +159,8 @@ toolTargets = [ binary , ghcBoot , ghcBootTh , ghcPlatform + , ghcToolchain + , ghcToolchainBin , ghcHeap , ghci , ghcPkg -- # executable ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -188,11 +188,9 @@ configureArgs cFlags' ldFlags' = do , cFlags' ] ldFlags = ldArgs <> ldFlags' - cldFlags <- unwords <$> (cFlags <> ldFlags) mconcat [ conf "CFLAGS" cFlags , conf "LDFLAGS" ldFlags - , not (null cldFlags) ? arg ("--gcc-options=" ++ cldFlags) , conf "--with-iconv-includes" $ arg =<< getSetting IconvIncludeDir , conf "--with-iconv-libraries" $ arg =<< getSetting IconvLibDir , conf "--with-gmp-includes" $ arg =<< getSetting GmpIncludeDir ===================================== m4/find_merge_objects.m4 ===================================== @@ -45,7 +45,7 @@ AC_DEFUN([FIND_MERGE_OBJECTS],[ if test "$result" = "1"; then AC_MSG_NOTICE([$MergeObjsCmd is broken due to binutils 22266, looking for another linker...]) MergeObjsCmd="" - AC_CHECK_TARGET_TOOL([MergeObjsCmd], [ld]) + AC_PATH_TARGET_TOOL([MergeObjsCmd], [ld]) CHECK_FOR_GOLD_T22266($MergeObjsCmd) if test "$result" = "1"; then AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the MergeObjsCmd variable to a functional linker.]) ===================================== m4/fp_cc_supports_target.m4 ===================================== @@ -10,13 +10,17 @@ # $1 = CC # $2 = CC_OPTS variable # $3 = CXX_OPTS variable -# $4 = GCC_LINK_OPTS variable AC_DEFUN([FP_CC_SUPPORTS_TARGET], [ AC_REQUIRE([GHC_LLVM_TARGET_SET_VAR]) AC_MSG_CHECKING([whether $1 supports --target]) + echo 'int main() { return 0; }' > conftest.c - if $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then + if test "$target_cpu" = "javascript" ; then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then CONF_CC_SUPPORTS_TARGET=YES AC_MSG_RESULT([yes]) else @@ -28,7 +32,6 @@ AC_DEFUN([FP_CC_SUPPORTS_TARGET], if test $CONF_CC_SUPPORTS_TARGET = YES ; then $2="--target=$LlvmTarget $$2" $3="--target=$LlvmTarget $$3" - $4="--target=$LlvmTarget $$4" fi ]) ===================================== m4/fp_gcc_supports_no_pie.m4 ===================================== @@ -7,8 +7,9 @@ AC_DEFUN([FP_GCC_SUPPORTS_NO_PIE], AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING([whether CC supports -no-pie]) echo 'int main() { return 0; }' > conftest.c + "$CC" $CONF_GCC_CC_OPTS_STAGE2 -c conftest.c # Some GCC versions only warn when passed an unrecognized flag. - if $CC -no-pie -Werror -x c conftest.c -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then + if "$CC" $CONF_GCC_LINKER_OPTS_STAGE2 -no-pie -Werror conftest.o -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then CONF_GCC_SUPPORTS_NO_PIE=YES AC_MSG_RESULT([yes]) else ===================================== m4/fp_prog_cc_linker_target.m4 ===================================== @@ -0,0 +1,31 @@ +# FP_PROG_CC_LINKER_TARGET +# ------------------- +# Check to see if the C compiler used as a linker supports `--target` +# +# $1 - The compiler +# $2 - Variable which contains the options passed to the C compiler when compiling a C file +# $3 - Variable which contains the options passed to the C compiler when used as +# a linker +AC_DEFUN([FP_PROG_CC_LINKER_TARGET], +[ + AC_MSG_CHECKING([whether $CC used as a linker understands --target]) + + echo 'int foo() { return 0; }' > conftest1.c + echo 'int main() { return 0; }' > conftest2.c + "$1" $$2 -c conftest1.c || AC_MSG_ERROR([Failed to compile conftest1.c]) + "$1" $$2 -c conftest2.c || AC_MSG_ERROR([Failed to compile conftest2.c]) + + if test "$target_cpu" = "javascript" + then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif "$CC" $$3 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; + then + $3="--target=$LlvmTarget $$3" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + rm -rf conftest* +])# FP_PROG_CC_LINKER_TARGET ===================================== m4/ghc_toolchain.m4 ===================================== @@ -106,6 +106,10 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN], echo "--readelf=$READELF" >> acargs echo "--windres=$WindresCmd" >> acargs + if test -n "$USER_LD"; then + echo "--ld=$USER_LD" >> acargs + fi + ENABLE_GHC_TOOLCHAIN_NOT_ARG([locally-executable], [$CrossCompiling]) ENABLE_GHC_TOOLCHAIN_ARG([unregisterised], [$Unregisterised]) ENABLE_GHC_TOOLCHAIN_ARG([tables-next-to-code], [$TablesNextToCode]) @@ -144,7 +148,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN_BIN],[ -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \ -XNoImplicitPrelude \ -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \ - utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain + utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain || AC_MSG_ERROR([Could not compile ghc-toolchain]) GHC_TOOLCHAIN_BIN="./acghc-toolchain" ;; *) ===================================== utils/ghc-toolchain/exe/Main.hs ===================================== @@ -31,6 +31,7 @@ import GHC.Toolchain.Tools.Ranlib import GHC.Toolchain.Tools.Nm import GHC.Toolchain.Tools.MergeObjs import GHC.Toolchain.Tools.Readelf +import GHC.Toolchain.NormaliseTriple (normaliseTriple) data Opts = Opts { optTriple :: String @@ -49,6 +50,9 @@ data Opts = Opts , optReadelf :: ProgOpt , optMergeObjs :: ProgOpt , optWindres :: ProgOpt + -- Note we don't actually configure LD into anything but + -- see #23857 and #22550 for the very unfortunate story. + , optLd :: ProgOpt , optUnregisterised :: Maybe Bool , optTablesNextToCode :: Maybe Bool , optUseLibFFIForAdjustors :: Maybe Bool @@ -91,6 +95,7 @@ emptyOpts = Opts , optReadelf = po0 , optMergeObjs = po0 , optWindres = po0 + , optLd = po0 , optUnregisterised = Nothing , optTablesNextToCode = Nothing , optUseLibFFIForAdjustors = Nothing @@ -102,7 +107,7 @@ emptyOpts = Opts po0 = emptyProgOpt _optCc, _optCxx, _optCpp, _optHsCpp, _optCcLink, _optAr, _optRanlib, _optNm, - _optReadelf, _optMergeObjs, _optWindres + _optReadelf, _optMergeObjs, _optWindres, _optLd :: Lens Opts ProgOpt _optCc = Lens optCc (\x o -> o {optCc=x}) _optCxx = Lens optCxx (\x o -> o {optCxx=x}) @@ -115,6 +120,7 @@ _optNm = Lens optNm (\x o -> o {optNm=x}) _optReadelf = Lens optReadelf (\x o -> o {optReadelf=x}) _optMergeObjs = Lens optMergeObjs (\x o -> o {optMergeObjs=x}) _optWindres = Lens optWindres (\x o -> o {optWindres=x}) +_optLd = Lens optLd (\x o -> o {optLd= x}) _optTriple :: Lens Opts String _optTriple = Lens optTriple (\x o -> o {optTriple=x}) @@ -169,6 +175,7 @@ options = , progOpts "readelf" "readelf utility" _optReadelf , progOpts "merge-objs" "linker for merging objects" _optMergeObjs , progOpts "windres" "windres utility" _optWindres + , progOpts "ld" "linker" _optLd ] where progOpts :: String -> String -> Lens Opts ProgOpt -> [OptDescr (Opts -> Opts)] @@ -367,18 +374,24 @@ ldOverrideWhitelist a = _ -> False + mkTarget :: Opts -> M Target mkTarget opts = do + normalised_triple <- normaliseTriple (optTriple opts) -- Use Llvm target if specified, otherwise use triple as llvm target - let tgtLlvmTarget = fromMaybe (optTriple opts) (optLlvmTriple opts) - cc0 <- findCc tgtLlvmTarget (optCc opts) - cxx <- findCxx tgtLlvmTarget (optCxx opts) + let tgtLlvmTarget = fromMaybe normalised_triple (optLlvmTriple opts) + + (archOs, tgtVendor) <- do + cc0 <- findBasicCc (optCc opts) + parseTriple cc0 normalised_triple + + cc0 <- findCc archOs tgtLlvmTarget (optCc opts) + cxx <- findCxx archOs tgtLlvmTarget (optCxx opts) cpp <- findCpp (optCpp opts) cc0 hsCpp <- findHsCpp (optHsCpp opts) cc0 - (archOs, tgtVendor) <- parseTriple cc0 (optTriple opts) cc <- addPlatformDepCcFlags archOs cc0 readelf <- optional $ findReadelf (optReadelf opts) - ccLink <- findCcLink tgtLlvmTarget (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf + ccLink <- findCcLink tgtLlvmTarget (optLd opts) (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf ar <- findAr tgtVendor (optAr opts) -- TODO: We could have ===================================== utils/ghc-toolchain/ghc-toolchain.cabal ===================================== @@ -17,6 +17,7 @@ library GHC.Toolchain.Prelude, GHC.Toolchain.Program, GHC.Toolchain.ParseTriple, + GHC.Toolchain.NormaliseTriple, GHC.Toolchain.CheckArm, GHC.Toolchain.Target, GHC.Toolchain.Tools.Ar, ===================================== utils/ghc-toolchain/src/GHC/Toolchain/NormaliseTriple.hs ===================================== @@ -0,0 +1,13 @@ +module GHC.Toolchain.NormaliseTriple where + +import GHC.Toolchain.Prelude +import GHC.Toolchain.Program +import Data.Text (strip, pack, unpack) + +-- | Normalise the triple by calling `config.sub` on the given triple. +normaliseTriple :: String -> M String +normaliseTriple triple = do + let norm = unpack . strip . pack + normalised_triple <- norm <$> readProgramStdout shProgram ["config.sub", triple] + logInfo $ unwords ["Normalised triple:", triple, "~>", normalised_triple] + return normalised_triple ===================================== utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs ===================================== @@ -20,12 +20,12 @@ parseTriple cc triple | [archName, vendorName, osName] <- parts = do arch <- parseArch cc archName os <- parseOs osName - return (ArchOS arch os, Just vendorName) + return (ArchOS arch os, Just (parseVendor vendorName)) | [archName, vendorName, osName, _abi] <- parts = do arch <- parseArch cc archName os <- parseOs osName - return (ArchOS arch os, Just vendorName) + return (ArchOS arch os, Just (parseVendor vendorName)) | otherwise = throwE $ "malformed triple " ++ triple @@ -54,6 +54,7 @@ parseArch cc arch = "hppa" -> pure ArchUnknown "wasm32" -> pure ArchWasm32 "javascript" -> pure ArchJavaScript + "loongarch64" -> pure ArchLoongArch64 _ -> throwE $ "Unknown architecture " ++ arch parseOs :: String -> M OS @@ -80,6 +81,20 @@ parseOs os = "ghcjs" -> pure OSGhcjs _ -> throwE $ "Unknown operating system " ++ os +parseVendor :: String -> String +parseVendor vendor = + case vendor of + -- like i686-pc-linux-gnu, i686-gentoo-freebsd8, x86_64-w64-mingw32 + "pc" -> "unknown" + "gentoo" -> "unknown" + "w64" -> "unknown" + -- like armv5tel-softfloat-linux-gnueabi + "softfloat" -> "unknown" + -- like armv7a-hardfloat-linux-gnueabi + "hardfloat" -> "unknown" + -- Pass through by default + _ -> vendor + splitOn :: Char -> String -> [String] splitOn sep = go where ===================================== utils/ghc-toolchain/src/GHC/Toolchain/PlatformDetails.hs ===================================== @@ -46,7 +46,7 @@ checkWordSize cc = checking "word size" $ do checkEndianness :: Cc -> M Endianness checkEndianness cc = do - checkEndiannessParamH cc <|> checkEndiannessLimitsH cc + checkEndiannessParamH cc <|> checkEndiannessLimitsH cc <|> checkEndianness__BYTE_ORDER__ cc checkEndiannessParamH :: Cc -> M Endianness checkEndiannessParamH cc = checking "endianness (param.h)" $ do @@ -92,6 +92,28 @@ checkEndiannessLimitsH cc = checking "endianness (limits.h)" $ do , "#endif" ] +checkEndianness__BYTE_ORDER__ :: Cc -> M Endianness +checkEndianness__BYTE_ORDER__ cc = checking "endianness (__BYTE_ORDER__)" $ do + out <- preprocess cc prog + case reverse $ lines out of + "big":_ -> return BigEndian + "little":_ -> return LittleEndian + "unknown":_ -> throwE "unknown endianness" + _ -> throwE "unrecognized output" + where + prog = unlines + [ "#include " + , "#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__" + , "little" + , "#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__" + , "big" + , "#else" + , "unknown" + , "#endif" + ] + + + checkLeadingUnderscore :: Cc -> Nm -> M Bool checkLeadingUnderscore cc nm = checking ctxt $ withTempDir $ \dir -> do let test_o = dir "test.o" ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Program.hs ===================================== @@ -1,5 +1,6 @@ module GHC.Toolchain.Program ( Program(..) + , shProgram , _prgPath , _prgFlags , addFlagIfNew @@ -29,6 +30,7 @@ import System.Directory import System.Exit import System.Process hiding (env) +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Utils @@ -37,6 +39,9 @@ data Program = Program { prgPath :: FilePath } deriving (Read, Eq, Ord) +shProgram :: Program +shProgram = Program "sh" [] + instance Show Program where -- Normalise filepaths before showing to aid with diffing the target files. show (Program p f) = unwords @@ -178,17 +183,37 @@ compile ext extraFlags lens c outPath program = do callProgram (view lens c) $ extraFlags ++ ["-o", outPath, srcPath] expectFileExists outPath "compiler produced no output" +-- Note [Don't pass --target to emscripten toolchain] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Emscripten's CC wrapper is a bit wonky in that it accepts the `--target` +-- flag when used as a linker yet rejects it as a compiler (e.g. with `-c`). +-- This is exacerbated by the fact that Cabal currently in some cases +-- combines (and therefore conflates) link and compilation flags. +-- +-- Ultimately this should be fixed in Cabal but in the meantime we work around it +-- by handling this toolchain specifically in the various +-- "supports --target" checks in `configure` and `ghc-toolchain`. +-- +-- Fixes #23744. + -- | Does compiler program support the @--target=@ option? If so, we should -- pass it whenever possible to avoid ambiguity and potential compile-time -- errors (e.g. see #20162). -supportsTarget :: Lens compiler Program +supportsTarget :: ArchOS + -> Lens compiler Program -> (compiler -> M ()) -- ^ Action to check if compiler with @--target@ flag works -> String -- ^ The LLVM target to use if @cc@ supports @--target@ -> compiler -- ^ The compiler to check @--target@ support for -> M compiler -- ^ Return compiler with @--target@ flag if supported -supportsTarget lens checkWorks llvmTarget c --- TODO: #23603 - | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) = return c +supportsTarget archOs lens checkWorks llvmTarget c + -- See Note [Don't pass --target to emscripten toolchain]. + | ArchJavaScript <- archOS_arch archOs + = return c + + -- No reason to check if the options already contain a --target flag + | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) + = return c + | otherwise = let c' = over (lens % _prgFlags) (("--target="++llvmTarget):) c in (c' <$ checkWorks (over (lens % _prgFlags) ("-Werror":) c')) <|> return c ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs ===================================== @@ -4,12 +4,14 @@ module GHC.Toolchain.Tools.Cc ( Cc(..) , _ccProgram + , findBasicCc , findCc -- * Helpful utilities , preprocess , compileC , compileAsm , addPlatformDepCcFlags + , checkC99Support ) where import Control.Monad @@ -32,19 +34,29 @@ _ccProgram = Lens ccProgram (\x o -> o{ccProgram=x}) _ccFlags :: Lens Cc [String] _ccFlags = _ccProgram % _prgFlags -findCc :: String -- ^ The llvm target to use if Cc supports --target - -> ProgOpt -> M Cc -findCc llvmTarget progOpt = checking "for C compiler" $ do +-- We use this to find a minimally-functional compiler needed to call +-- parseTriple. +findBasicCc :: ProgOpt -> M Cc +findBasicCc progOpt = checking "for C compiler" $ do -- TODO: We keep the candidate order we had in configure, but perhaps -- there's a more optimal one ccProgram <- findProgram "C compiler" progOpt ["gcc", "clang", "cc"] + return $ Cc{ccProgram} - cc' <- ignoreUnusedArgs $ Cc {ccProgram} - cc <- ccSupportsTarget llvmTarget cc' - checking "whether Cc works" $ checkCcWorks cc - checkC99Support cc - checkCcSupportsExtraViaCFlags cc - return cc +findCc :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target + -> ProgOpt -> M Cc +findCc archOs llvmTarget progOpt = do + cc0 <- findBasicCc progOpt + cc1 <- ignoreUnusedArgs cc0 + cc2 <- ccSupportsTarget archOs llvmTarget cc1 + checking "whether Cc works" $ checkCcWorks cc2 + cc3 <- oneOf "cc doesn't support C99" $ map checkC99Support + [ cc2 + , cc2 & _ccFlags %++ "-std=gnu99" + ] + checkCcSupportsExtraViaCFlags cc3 + return cc3 checkCcWorks :: Cc -> M () checkCcWorks cc = withTempDir $ \dir -> do @@ -71,11 +83,12 @@ ignoreUnusedArgs cc -- Does Cc support the --target= option? If so, we should pass it -- whenever possible to avoid ambiguity and potential compile-time errors (e.g. -- see #20162). -ccSupportsTarget :: String -> Cc -> M Cc -ccSupportsTarget target cc = checking "whether Cc supports --target" $ - supportsTarget _ccProgram checkCcWorks target cc +ccSupportsTarget :: ArchOS -> String -> Cc -> M Cc +ccSupportsTarget archOs target cc = + checking "whether Cc supports --target" $ + supportsTarget archOs _ccProgram checkCcWorks target cc -checkC99Support :: Cc -> M () +checkC99Support :: Cc -> M Cc checkC99Support cc = checking "for C99 support" $ withTempDir $ \dir -> do let test_o = dir "test.o" compileC cc test_o $ unlines @@ -84,6 +97,7 @@ checkC99Support cc = checking "for C99 support" $ withTempDir $ \dir -> do , "# error \"Compiler does not advertise C99 conformance\"" , "#endif" ] + return cc checkCcSupportsExtraViaCFlags :: Cc -> M () checkCcSupportsExtraViaCFlags cc = checking "whether cc supports extra via-c flags" $ withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs ===================================== @@ -10,7 +10,7 @@ import GHC.Toolchain.Prelude import GHC.Toolchain.Program import GHC.Toolchain.Tools.Cc -import GHC.Toolchain.Utils (withTempDir) +import GHC.Toolchain.Utils (withTempDir, oneOf) newtype Cpp = Cpp { cppProgram :: Program } @@ -83,7 +83,12 @@ findCpp :: ProgOpt -> Cc -> M Cpp findCpp progOpt cc = checking "for C preprocessor" $ do -- Use the specified CPP or try to use the c compiler foundCppProg <- findProgram "C preprocessor" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) []) + -- Check whether the C preprocessor needs -std=gnu99 (only very old toolchains need this) + Cc cpp2 <- oneOf "cc doesn't support C99" $ map checkC99Support + [ Cc foundCppProg + , Cc (foundCppProg & _prgFlags %++ "-std=gnu99") + ] -- Always add the -E flag to the CPP, regardless of the user options - let cppProgram = addFlagIfNew "-E" foundCppProg + let cppProgram = addFlagIfNew "-E" cpp2 return Cpp{cppProgram} ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs ===================================== @@ -8,6 +8,8 @@ module GHC.Toolchain.Tools.Cxx ) where import System.FilePath + +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Program import GHC.Toolchain.Utils @@ -19,18 +21,20 @@ newtype Cxx = Cxx { cxxProgram :: Program _cxxProgram :: Lens Cxx Program _cxxProgram = Lens cxxProgram (\x o -> o{cxxProgram=x}) -findCxx :: String -- ^ The llvm target to use if Cc supports --target +findCxx :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target -> ProgOpt -> M Cxx -findCxx target progOpt = checking "for C++ compiler" $ do +findCxx archOs target progOpt = checking "for C++ compiler" $ do -- TODO: We use the search order in configure, but there could be a more optimal one cxxProgram <- findProgram "C++ compiler" progOpt ["g++", "clang++", "c++"] - cxx <- cxxSupportsTarget target Cxx{cxxProgram} + cxx <- cxxSupportsTarget archOs target Cxx{cxxProgram} checkCxxWorks cxx return cxx -cxxSupportsTarget :: String -> Cxx -> M Cxx -cxxSupportsTarget target cxx = checking "whether C++ supports --target" $ - supportsTarget _cxxProgram checkCxxWorks target cxx +cxxSupportsTarget :: ArchOS -> String -> Cxx -> M Cxx +cxxSupportsTarget archOs target cxx = + checking "whether C++ supports --target" $ + supportsTarget archOs _cxxProgram checkCxxWorks target cxx checkCxxWorks :: Cxx -> M () checkCxxWorks cxx = withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -42,21 +42,28 @@ _ccLinkProgram :: Lens CcLink Program _ccLinkProgram = Lens ccLinkProgram (\x o -> o{ccLinkProgram=x}) findCcLink :: String -- ^ The llvm target to use if CcLink supports --target + -> ProgOpt -> ProgOpt -> Bool -- ^ Whether we should search for a more efficient linker -> ArchOS -> Cc -> Maybe Readelf -> M CcLink -findCcLink target progOpt ldOverride archOs cc readelf = checking "for C compiler for linking command" $ do +findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C compiler for linking command" $ do -- Use the specified linker or try using the C compiler rawCcLink <- findProgram "C compiler for linking" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) []) - ccLinkProgram <- case poFlags progOpt of - Just _ -> + -- See #23857 for why we check to see if LD is set here + -- TLDR: If the user explicitly sets LD then in ./configure + -- we don't perform a linker search (and set -fuse-ld), so + -- we do the same here for consistency. + ccLinkProgram <- case (poPath ld, poFlags progOpt) of + (_, Just _) -> -- If the user specified linker flags don't second-guess them pure rawCcLink - Nothing -> do + (Just {}, _) -> + pure rawCcLink + _ -> do -- If not then try to find decent linker flags findLinkFlags ldOverride cc rawCcLink <|> pure rawCcLink ccLinkProgram <- linkSupportsTarget archOs cc target ccLinkProgram - ccLinkSupportsNoPie <- checkSupportsNoPie ccLinkProgram + ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram ccLinkIsGnu <- checkLinkIsGnu archOs ccLinkProgram @@ -90,12 +97,9 @@ findLinkFlags enableOverride cc ccLink linkSupportsTarget :: ArchOS -> Cc -> String -> Program -> M Program -- Javascript toolchain provided by emsdk just ignores --target flag so -- we have this special case to match with ./configure (#23744) -linkSupportsTarget archOS _ _ c - | ArchJavaScript <- archOS_arch archOS - = return c -linkSupportsTarget _ cc target link - = checking "whether cc linker supports --target" $ - supportsTarget (Lens id const) (checkLinkWorks cc) target link +linkSupportsTarget archOs cc target link = + checking "whether cc linker supports --target" $ + supportsTarget archOs (Lens id const) (checkLinkWorks cc) target link -- | Should we attempt to find a more efficient linker on this platform? -- @@ -112,16 +116,15 @@ doLinkerSearch = False #endif -- | See Note [No PIE when linking] in GHC.Driver.Session -checkSupportsNoPie :: Program -> M Bool -checkSupportsNoPie ccLink = checking "whether the cc linker supports -no-pie" $ +checkSupportsNoPie :: Cc -> Program -> M Bool +checkSupportsNoPie cc ccLink = checking "whether the cc linker supports -no-pie" $ withTempDir $ \dir -> do - let test_c = dir "test.c" - writeFile test_c "int main() { return 0; }" - + let test_o = dir "test.o" let test = dir "test" + compileC cc test_o "int main() { return 0; }" -- Check output as some GCC versions only warn and don't respect -Werror -- when passed an unrecognized flag. - (code, out, err) <- readProgram ccLink ["-no-pie", "-Werror", "-x", "c", test_c, "-o", test] + (code, out, err) <- readProgram ccLink ["-no-pie", "-Werror", test_o, "-o", test] return (isSuccess code && not ("unrecognized" `isInfixOf` out) && not ("unrecognized" `isInfixOf` err)) -- ROMES:TODO: This check is wrong here and in configure because with ld.gold parses "-n" "o_compact_unwind" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/265e36bf780ae0cb3b2214f699d51af124e82a8e...c48f2a4f2b07a049bbe12c7da64fd362b430c290 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/265e36bf780ae0cb3b2214f699d51af124e82a8e...c48f2a4f2b07a049bbe12c7da64fd362b430c290 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 17:41:08 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 10 Oct 2023 13:41:08 -0400 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 36 commits: EPA Some tweaks to annotations Message-ID: <65258cb4b1eed_1b931c61f3da705567a4@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC Commits: e93b3ade by Alan Zimmerman at 2023-10-03T17:59:49+01:00 EPA Some tweaks to annotations - Fix span for GRHS - Move TrailingAnns from last match to FunBind - Fix GADT where clause span - Capture full range for a CaseAlt Match info: patch template saved to `-` - - - - - 173a1ed1 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA Use full range for Anchor, and do not widen for [TrailingAnn] Known failures at the end of this Ppr023 Ppr034 TestBoolFormula Fixed in subsequent commits - - - - - 43aebc56 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Use the current Anchor end as prior end Use the original anchor location end as the source of truth for calculating print deltas. This allows original spacing to apply in most cases, only changed AST items need initial delta positions. [2023-08-14 Mon] 121 unexpected failures - - - - - eb98101f by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Add DArrow to TrailingAnn - - - - - 106c588d by Alan Zimmerman at 2023-10-03T19:48:46+01:00 [EPA] Introduce HasTrailing in ExactPrint 29 Failing tests by 4600 processed info: patch template saved to `-` - - - - - e553183f by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA use [TrailingAnn] in enterAnn And remove it from ExactPrint (LocatedN RdrName) - - - - - e88c53da by Alan Zimmerman at 2023-10-03T19:48:46+01:00 Summary: Patch: epa-in-hsdo-put-trailinganns Author: Alan Zimmerman <alan.zimm at gmail.com> Date: 2023-07-03 22:33:49 +0100 EPA: In HsDo, put TrailingAnns at top of LastStmt Failures 5300 of 9700 [0, 103, 0] - - - - - 244d6c54 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: do not convert comments to deltas when balancing. It seems its not needed with the new approach [2023-08-15 Tue] 104 unexpected failures - - - - - 2f48e12a by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: deal with fallout from getMonoBind - - - - - fd4c0093 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA fix captureLineSpacing - - - - - b2410c51 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA print any comments in the span before exiting it - - - - - 4e62ec08 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: getting rid of tweakDelta WIP at present - - - - - b0aa41c9 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: tweaks to ExactPrint - - - - - b9f701fa by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Fix warnings in check-exact - - - - - 958d229a by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Add comments to AnchorOperation 6000 of 9700 [0, 14, 0] Failures seem to be mainly in transform tests - - - - - e8e72908 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: remove AnnEofComment It is no longer used At this point just failures HsDocTy [2023-08-31 Thu] And no warnings in check-exact - - - - - 6d6b7542 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: make locA a function, not a field name - - - - - 0c222121 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: generalise reLoc [2023-10-01 Sun] Failures HsDocTy - - - - - 039fcc5c by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: get rid of l2l and friends - - - - - ae0b9ebd by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: get rid of l2l and friends - - - - - 55d420aa by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: harmonise acsa and acsA [2023-10-01 Sun] Failing tests HsDocTy - - - - - 94b6c439 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Replace Anchor with EpaLocation [2023-09-21 Thu] Only test failing is HsDocTy - - - - - 19f57cd0 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: get rid of AnchorOperation [2023-09-21 Thu] Only error is HsDocTy - - - - - 81c8d0e1 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: splitLHsForAllTyInvis no ann returned - - - - - c68d5384 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Replace Monoid with NoAnn [2023-08-19 Sat] AddClassMethod fails - - - - - 4b6c4554 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Use SrcSpan in EpaSpan [2023-09-04 Mon] No errors or warnings in check-exact [2023-09-21 Thu] Test failures HsDocTy - - - - - 83295f93 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Present no longer has annotation - - - - - c9756b55 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: empty tup_tail has no ann Parser.y: tup_tail rule was | {- empty -} %shift { return [Left noAnn] } This means we add an extra Missing constructor if the last item was a comma. Change the annotation type to a Bool to indicate this, and use the EpAnn Anchor for the print location for the others. - - - - - aa93f36a by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Remove parenthesizeHsType - - - - - 69ec0cd0 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Remove EpAnnNotUsed [2023-10-01 Sun] Failures HsDocTy T15242 - - - - - 79a8289a by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Remove SrcSpanAnn - - - - - bd6b5623 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Remove SrcSpanAnn completely - - - - - 6814d972 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 Clean up mkScope - - - - - c0e17d8a by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: Clean up TC Monad Utils - - - - - 3ad70bc6 by Alan Zimmerman at 2023-10-03T19:48:46+01:00 EPA: EpaDelta for comment has no comments [2023-09-23 Sat] Current failures HsDocTy T15242 - - - - - d035f64f by Alan Zimmerman at 2023-10-03T19:50:56+01:00 Semigroup instances for AnnList and AnnContext - - - - - 16 changed files: - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Parser.y The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2cffd697d8198920a4262b612d4d892dbc4b78ce...d035f64f27874c44ab1422ebe348b5f601f04dda -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2cffd697d8198920a4262b612d4d892dbc4b78ce...d035f64f27874c44ab1422ebe348b5f601f04dda You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 19:03:29 2023 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 10 Oct 2023 15:03:29 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-annotations-tweaks Message-ID: <6525a00177c86_1b931c64201a985596de@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-annotations-tweaks at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-annotations-tweaks You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 20:21:06 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 16:21:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 26 commits: Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. Message-ID: <6525b2322c7b4_1b931c65dafc1858851c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - d0d1c883 by Matthew Pickering at 2023-10-10T16:20:28-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 360bfffb by Matthew Pickering at 2023-10-10T16:20:28-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 4f8710e9 by Matthew Pickering at 2023-10-10T16:20:28-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - a9746fb9 by Matthew Pickering at 2023-10-10T16:20:28-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 9f8adb91 by Matthew Pickering at 2023-10-10T16:20:28-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 40cf1ecc by Ben Gamari at 2023-10-10T16:20:28-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - ff687a58 by Matthew Pickering at 2023-10-10T16:20:28-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - 1a13593a by Matthew Pickering at 2023-10-10T16:20:28-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 94a6bbea by Matthew Pickering at 2023-10-10T16:20:28-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 6fd435eb by Matthew Pickering at 2023-10-10T16:20:28-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 11259d4d by Matthew Pickering at 2023-10-10T16:20:28-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 95c45b78 by Matthew Pickering at 2023-10-10T16:20:28-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 3cc115a2 by Matthew Pickering at 2023-10-10T16:20:28-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - bff6f7a9 by Matthew Pickering at 2023-10-10T16:20:28-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 078c6ef4 by Ben Gamari at 2023-10-10T16:20:28-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 2e4ef24d by Matthew Pickering at 2023-10-10T16:20:28-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - 8646a3a3 by Ben Gamari at 2023-10-10T16:20:28-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 4f95a137 by Sebastian Graf at 2023-10-10T16:20:29-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - 7647e0de by Bryan Richter at 2023-10-10T16:20:30-04:00 rel_eng/upload.sh cleanups - - - - - 50cd1c3f by doyougnu at 2023-10-10T16:20:33-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - 7328c718 by Matthew Craven at 2023-10-10T16:20:33-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - b86acacd by Jan Hrček at 2023-10-10T16:20:38-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - fec59481 by Andreas Klebinger at 2023-10-10T16:20:39-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - a75b56d9 by Andreas Klebinger at 2023-10-10T16:20:39-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 36a26049 by Andreas Klebinger at 2023-10-10T16:20:39-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Types.hs - configure.ac - docs/users_guide/using-optimisation.rst - hadrian/doc/testsuite.md - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Builders/Cabal.hs - m4/find_merge_objects.m4 - m4/fp_cc_supports_target.m4 - m4/fp_gcc_supports_no_pie.m4 - + m4/fp_prog_cc_linker_target.m4 - m4/ghc_toolchain.m4 - + testsuite/tests/simplCore/should_compile/T21917.hs - + testsuite/tests/simplCore/should_compile/T21917.stderr - testsuite/tests/simplCore/should_compile/all.T - + testsuite/tests/th/T24074.hs - + testsuite/tests/th/T24074.stderr - testsuite/tests/th/all.T - utils/ghc-toolchain/exe/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c48f2a4f2b07a049bbe12c7da64fd362b430c290...36a260492ffea091ee3ace7c78b0c824ab54e9ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c48f2a4f2b07a049bbe12c7da64fd362b430c290...36a260492ffea091ee3ace7c78b0c824ab54e9ec You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 23:01:17 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 19:01:17 -0400 Subject: [Git][ghc/ghc][master] Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. Message-ID: <6525d7bd948b_1b931c696b8bcc6192a0@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 8 changed files: - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Tidy.hs - docs/users_guide/using-optimisation.rst - + testsuite/tests/simplCore/should_compile/T21917.hs - + testsuite/tests/simplCore/should_compile/T21917.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Driver/Config/Tidy.hs ===================================== @@ -40,6 +40,7 @@ initTidyOpts hsc_env = do , opt_expose_rules = not (gopt Opt_OmitInterfacePragmas dflags) , opt_trim_ids = gopt Opt_OmitInterfacePragmas dflags , opt_static_ptr_opts = static_ptr_opts + , opt_keep_auto_rules = gopt Opt_KeepAutoRules dflags } initStaticPtrOpts :: HscEnv -> IO StaticPtrOpts ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -323,6 +323,7 @@ data GeneralFlag | Opt_IgnoreInterfacePragmas | Opt_OmitInterfacePragmas | Opt_ExposeAllUnfoldings + | Opt_KeepAutoRules -- ^Keep auto-generated rules even if they seem to have become useless | Opt_WriteInterface -- forces .hi files to be written even with -fno-code | Opt_WriteHie -- generate .hie files ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2371,6 +2371,7 @@ fFlagsDeps = [ flagSpec "error-spans" Opt_ErrorSpans, flagSpec "excess-precision" Opt_ExcessPrecision, flagSpec "expose-all-unfoldings" Opt_ExposeAllUnfoldings, + flagSpec "keep-auto-rules" Opt_KeepAutoRules, flagSpec "expose-internal-symbols" Opt_ExposeInternalSymbols, flagSpec "external-dynamic-refs" Opt_ExternalDynamicRefs, flagSpec "external-interpreter" Opt_ExternalInterpreter, ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -384,6 +384,7 @@ data TidyOpts = TidyOpts -- ^ Are rules exposed or not? , opt_static_ptr_opts :: !(Maybe StaticPtrOpts) -- ^ Options for generated static pointers, if enabled (/= Nothing). + , opt_keep_auto_rules :: !Bool } tidyProgram :: TidyOpts -> ModGuts -> IO (CgGuts, ModDetails) @@ -418,6 +419,8 @@ tidyProgram opts (ModGuts { mg_module = mod Nothing -> pure ([], Nothing, tidy_binds) Just sopts -> sptCreateStaticBinds sopts mod tidy_binds + -- pprTraceM "trimmed_rules" (ppr trimmed_rules) + let all_foreign_stubs = case mcstub of Nothing -> foreign_stubs Just cstub -> foreign_stubs `appendStubC` cstub @@ -989,12 +992,18 @@ called in the final code), we keep the rule too. This stuff is the only reason for the ru_auto field in a Rule. -NB: In #18532 we looked at keeping auto-rules and it turned out to just make -compiler performance worse while increasing code sizes at the same time. The impact -varied. Compiling Cabal got ~3% slower, allocated ~3% more and wrote 15% more code to disk. -Nofib only saw 0.7% more compiler allocations and executable file size growth. But given -there was no difference in runtime for these benchmarks it turned out to be flat out worse. -See the ticket for more details. +We discard auto-rules by default, but keep them if -fkeep-auto-rules is on. + +* Discard by default: in #18532 we looked at keeping auto-rules and it turned out to just make + compiler performance worse while increasing code sizes at the same time. The + impact varied. Compiling Cabal got ~3% slower, allocated ~3% more and wrote 15% + more code to disk. Nofib only saw 0.7% more compiler allocations and executable + file size growth. But given there was no difference in runtime for these + benchmarks it turned out to be flat out worse. See the ticket for more details. + +* Keep with -fkeep-auto-rules: in #21917 we found cases where we get a lot code + duplication when we discard specialisations. Agda is a case in point. Having + a flag gives us control over the rule-trimming decision. -} findExternalRules :: TidyOpts @@ -1006,11 +1015,12 @@ findExternalRules :: TidyOpts findExternalRules opts binds imp_id_rules unfold_env = (trimmed_binds, filter keep_rule all_rules) where - imp_rules | (opt_expose_rules opts) = filter expose_rule imp_id_rules - | otherwise = [] + imp_rules | opt_expose_rules opts = filter expose_rule imp_id_rules + | otherwise = [] imp_user_rule_fvs = mapUnionVarSet user_rule_rhs_fvs imp_rules - user_rule_rhs_fvs rule | isAutoRule rule = emptyVarSet + user_rule_rhs_fvs rule | isAutoRule rule && not (opt_keep_auto_rules opts) + = emptyVarSet | otherwise = ruleRhsFreeVars rule (trimmed_binds, local_bndrs, _, all_rules) = trim_binds binds @@ -1071,7 +1081,7 @@ findExternalRules opts binds imp_id_rules unfold_env -- In needed_fvs', we don't bother to delete binders from the fv set local_rules = [ rule - | (opt_expose_rules opts) + | opt_expose_rules opts , id <- bndrs , is_external_id id -- Only collect rules for external Ids , rule <- idCoreRules id ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -621,6 +621,24 @@ as such you shouldn't need to set any of them explicitly. A flag strictness information for a function, GHC will ignore that information. +.. ghc-flag:: -fkeep-auto-rules + :shortdesc: Keep all "auto" rules, generated by specialisation + :type: dynamic + :reverse: -fno-keep-auto-rules + :category: + + :default: off + + The type-class specialiser and call-pattern specialisation both + generate so-called "auto" RULES. These rules are usually exposed + to importing modules in the interface file. But an auto rule is the + sole reason for keeping a function alive, both the rule and the function + are discarded, by default. That reduces code bloat, but risks the same + function being specialised again in an importing module. + + You can change this behaviour with :ghc-flag:`-fkeep-auto-rules`. Switching + it on keeps all auto-generated rules. + .. ghc-flag:: -flate-dmd-anal :shortdesc: Run demand analysis again, at the end of the simplification pipeline ===================================== testsuite/tests/simplCore/should_compile/T21917.hs ===================================== @@ -0,0 +1,21 @@ +-- With -fkeep-auto-rules we should get an externally-visible +-- specialisation. See #21917 +-- +-- "SPEC foo @IO @Int" +-- forall ($dMonad :: Monad IO) ($dIntegral :: Integral Int). +-- foo1 @IO @Int $dMonad $dIntegral = foo_$sfoo + +module T21917 where + +{-# INLINABLE foo #-} +foo :: (Monad m, Integral a) => a -> a -> a -> IO (a,a,a,a,a, m a) +foo x y z = do + let !x1 = x+1 + let !x2 = x+2 + let !x3 = x+3 + let !x4 = x+4 + let !x5 = x+5 + pure (x1, x2, x3, x4, x5, pure (x1+x2)) + +bar :: Int -> IO (Int,Int,Int,Int,Int, IO Int) +bar = foo 1 2 ===================================== testsuite/tests/simplCore/should_compile/T21917.stderr ===================================== @@ -0,0 +1,8 @@ + +==================== Tidy Core rules ==================== +"SPEC foo @IO @Int" + forall ($dMonad :: Monad IO) ($dIntegral :: Integral Int). + foo1 @IO @Int $dMonad $dIntegral + = foo_$sfoo + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -504,3 +504,5 @@ test('T23952', [extra_files(['T23952a.hs'])], multimod_compile, ['T23952', '-v0 test('T24014', normal, compile, ['-dcore-lint']) test('T24029', normal, compile, ['']) test('T21348', normal, compile, ['-O']) +test('T21917', normal, compile, ['-O -fkeep-auto-rules -ddump-rules']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e96c51cbd137113ec953d8b7b0817d2d268f3c96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e96c51cbd137113ec953d8b7b0817d2d268f3c96 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 23:02:34 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 19:02:34 -0400 Subject: [Git][ghc/ghc][master] 17 commits: hadrian: Add ghcToolchain to tool args list Message-ID: <6525d80aa6c30_1b931c696b8bcc6294ee@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 18 changed files: - configure.ac - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Builders/Cabal.hs - m4/find_merge_objects.m4 - m4/fp_cc_supports_target.m4 - m4/fp_gcc_supports_no_pie.m4 - + m4/fp_prog_cc_linker_target.m4 - m4/ghc_toolchain.m4 - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/ghc-toolchain.cabal - + utils/ghc-toolchain/src/GHC/Toolchain/NormaliseTriple.hs - utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs - utils/ghc-toolchain/src/GHC/Toolchain/PlatformDetails.hs - utils/ghc-toolchain/src/GHC/Toolchain/Program.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs - utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs Changes: ===================================== configure.ac ===================================== @@ -55,6 +55,8 @@ USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2" USER_CONF_CXX_OPTS_STAGE2="$CONF_CXX_OPTS_STAGE2" USER_CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2" +USER_LD="$LD" + dnl ---------------------------------------------------------- dnl ** Find unixy sort and find commands, dnl ** which are needed by FP_SETUP_PROJECT_VERSION @@ -491,6 +493,7 @@ FP_PROG_LD_IS_GNU FP_PROG_LD_NO_COMPACT_UNWIND FP_PROG_LD_FILELIST + dnl ** Which nm to use? dnl -------------------------------------------------------------- FP_FIND_NM @@ -624,8 +627,6 @@ dnl If gcc, make sure it's at least 4.7 dnl FP_GCC_VERSION -dnl ** See whether cc supports -no-pie -FP_GCC_SUPPORTS_NO_PIE dnl ** Check support for the extra flags passed by GHC when compiling via C FP_GCC_SUPPORTS_VIA_C_FLAGS @@ -665,9 +666,16 @@ AC_SUBST(LlvmTarget) dnl ** See whether cc supports --target= and set dnl CONF_CC_OPTS_STAGE[012] accordingly. -FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) -FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) -FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) +FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0]) +FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1]) +FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2]) + +FP_PROG_CC_LINKER_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) +FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) +FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) + +dnl ** See whether cc used as a linker supports -no-pie +FP_GCC_SUPPORTS_NO_PIE dnl Pass -Qunused-arguments or otherwise GHC will have very noisy invocations of Clang dnl TODO: Do we need -Qunused-arguments in CXX and GCC linker too? ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -159,6 +159,8 @@ toolTargets = [ binary , ghcBoot , ghcBootTh , ghcPlatform + , ghcToolchain + , ghcToolchainBin , ghcHeap , ghci , ghcPkg -- # executable ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -188,11 +188,9 @@ configureArgs cFlags' ldFlags' = do , cFlags' ] ldFlags = ldArgs <> ldFlags' - cldFlags <- unwords <$> (cFlags <> ldFlags) mconcat [ conf "CFLAGS" cFlags , conf "LDFLAGS" ldFlags - , not (null cldFlags) ? arg ("--gcc-options=" ++ cldFlags) , conf "--with-iconv-includes" $ arg =<< getSetting IconvIncludeDir , conf "--with-iconv-libraries" $ arg =<< getSetting IconvLibDir , conf "--with-gmp-includes" $ arg =<< getSetting GmpIncludeDir ===================================== m4/find_merge_objects.m4 ===================================== @@ -45,7 +45,7 @@ AC_DEFUN([FIND_MERGE_OBJECTS],[ if test "$result" = "1"; then AC_MSG_NOTICE([$MergeObjsCmd is broken due to binutils 22266, looking for another linker...]) MergeObjsCmd="" - AC_CHECK_TARGET_TOOL([MergeObjsCmd], [ld]) + AC_PATH_TARGET_TOOL([MergeObjsCmd], [ld]) CHECK_FOR_GOLD_T22266($MergeObjsCmd) if test "$result" = "1"; then AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the MergeObjsCmd variable to a functional linker.]) ===================================== m4/fp_cc_supports_target.m4 ===================================== @@ -10,13 +10,17 @@ # $1 = CC # $2 = CC_OPTS variable # $3 = CXX_OPTS variable -# $4 = GCC_LINK_OPTS variable AC_DEFUN([FP_CC_SUPPORTS_TARGET], [ AC_REQUIRE([GHC_LLVM_TARGET_SET_VAR]) AC_MSG_CHECKING([whether $1 supports --target]) + echo 'int main() { return 0; }' > conftest.c - if $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then + if test "$target_cpu" = "javascript" ; then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif $1 --target=$LlvmTarget -Werror conftest.c > /dev/null 2>&1 ; then CONF_CC_SUPPORTS_TARGET=YES AC_MSG_RESULT([yes]) else @@ -28,7 +32,6 @@ AC_DEFUN([FP_CC_SUPPORTS_TARGET], if test $CONF_CC_SUPPORTS_TARGET = YES ; then $2="--target=$LlvmTarget $$2" $3="--target=$LlvmTarget $$3" - $4="--target=$LlvmTarget $$4" fi ]) ===================================== m4/fp_gcc_supports_no_pie.m4 ===================================== @@ -7,8 +7,9 @@ AC_DEFUN([FP_GCC_SUPPORTS_NO_PIE], AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING([whether CC supports -no-pie]) echo 'int main() { return 0; }' > conftest.c + "$CC" $CONF_GCC_CC_OPTS_STAGE2 -c conftest.c # Some GCC versions only warn when passed an unrecognized flag. - if $CC -no-pie -Werror -x c conftest.c -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then + if "$CC" $CONF_GCC_LINKER_OPTS_STAGE2 -no-pie -Werror conftest.o -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then CONF_GCC_SUPPORTS_NO_PIE=YES AC_MSG_RESULT([yes]) else ===================================== m4/fp_prog_cc_linker_target.m4 ===================================== @@ -0,0 +1,31 @@ +# FP_PROG_CC_LINKER_TARGET +# ------------------- +# Check to see if the C compiler used as a linker supports `--target` +# +# $1 - The compiler +# $2 - Variable which contains the options passed to the C compiler when compiling a C file +# $3 - Variable which contains the options passed to the C compiler when used as +# a linker +AC_DEFUN([FP_PROG_CC_LINKER_TARGET], +[ + AC_MSG_CHECKING([whether $CC used as a linker understands --target]) + + echo 'int foo() { return 0; }' > conftest1.c + echo 'int main() { return 0; }' > conftest2.c + "$1" $$2 -c conftest1.c || AC_MSG_ERROR([Failed to compile conftest1.c]) + "$1" $$2 -c conftest2.c || AC_MSG_ERROR([Failed to compile conftest2.c]) + + if test "$target_cpu" = "javascript" + then + # See Note [Don't pass --target to emscripten toolchain] in GHC.Toolchain.Program + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + elif "$CC" $$3 --target=$LlvmTarget -o conftest conftest1.o conftest2.o; + then + $3="--target=$LlvmTarget $$3" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + rm -rf conftest* +])# FP_PROG_CC_LINKER_TARGET ===================================== m4/ghc_toolchain.m4 ===================================== @@ -106,6 +106,10 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN], echo "--readelf=$READELF" >> acargs echo "--windres=$WindresCmd" >> acargs + if test -n "$USER_LD"; then + echo "--ld=$USER_LD" >> acargs + fi + ENABLE_GHC_TOOLCHAIN_NOT_ARG([locally-executable], [$CrossCompiling]) ENABLE_GHC_TOOLCHAIN_ARG([unregisterised], [$Unregisterised]) ENABLE_GHC_TOOLCHAIN_ARG([tables-next-to-code], [$TablesNextToCode]) @@ -144,7 +148,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN_BIN],[ -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \ -XNoImplicitPrelude \ -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \ - utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain + utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain || AC_MSG_ERROR([Could not compile ghc-toolchain]) GHC_TOOLCHAIN_BIN="./acghc-toolchain" ;; *) ===================================== utils/ghc-toolchain/exe/Main.hs ===================================== @@ -31,6 +31,7 @@ import GHC.Toolchain.Tools.Ranlib import GHC.Toolchain.Tools.Nm import GHC.Toolchain.Tools.MergeObjs import GHC.Toolchain.Tools.Readelf +import GHC.Toolchain.NormaliseTriple (normaliseTriple) data Opts = Opts { optTriple :: String @@ -49,6 +50,9 @@ data Opts = Opts , optReadelf :: ProgOpt , optMergeObjs :: ProgOpt , optWindres :: ProgOpt + -- Note we don't actually configure LD into anything but + -- see #23857 and #22550 for the very unfortunate story. + , optLd :: ProgOpt , optUnregisterised :: Maybe Bool , optTablesNextToCode :: Maybe Bool , optUseLibFFIForAdjustors :: Maybe Bool @@ -91,6 +95,7 @@ emptyOpts = Opts , optReadelf = po0 , optMergeObjs = po0 , optWindres = po0 + , optLd = po0 , optUnregisterised = Nothing , optTablesNextToCode = Nothing , optUseLibFFIForAdjustors = Nothing @@ -102,7 +107,7 @@ emptyOpts = Opts po0 = emptyProgOpt _optCc, _optCxx, _optCpp, _optHsCpp, _optCcLink, _optAr, _optRanlib, _optNm, - _optReadelf, _optMergeObjs, _optWindres + _optReadelf, _optMergeObjs, _optWindres, _optLd :: Lens Opts ProgOpt _optCc = Lens optCc (\x o -> o {optCc=x}) _optCxx = Lens optCxx (\x o -> o {optCxx=x}) @@ -115,6 +120,7 @@ _optNm = Lens optNm (\x o -> o {optNm=x}) _optReadelf = Lens optReadelf (\x o -> o {optReadelf=x}) _optMergeObjs = Lens optMergeObjs (\x o -> o {optMergeObjs=x}) _optWindres = Lens optWindres (\x o -> o {optWindres=x}) +_optLd = Lens optLd (\x o -> o {optLd= x}) _optTriple :: Lens Opts String _optTriple = Lens optTriple (\x o -> o {optTriple=x}) @@ -169,6 +175,7 @@ options = , progOpts "readelf" "readelf utility" _optReadelf , progOpts "merge-objs" "linker for merging objects" _optMergeObjs , progOpts "windres" "windres utility" _optWindres + , progOpts "ld" "linker" _optLd ] where progOpts :: String -> String -> Lens Opts ProgOpt -> [OptDescr (Opts -> Opts)] @@ -367,18 +374,24 @@ ldOverrideWhitelist a = _ -> False + mkTarget :: Opts -> M Target mkTarget opts = do + normalised_triple <- normaliseTriple (optTriple opts) -- Use Llvm target if specified, otherwise use triple as llvm target - let tgtLlvmTarget = fromMaybe (optTriple opts) (optLlvmTriple opts) - cc0 <- findCc tgtLlvmTarget (optCc opts) - cxx <- findCxx tgtLlvmTarget (optCxx opts) + let tgtLlvmTarget = fromMaybe normalised_triple (optLlvmTriple opts) + + (archOs, tgtVendor) <- do + cc0 <- findBasicCc (optCc opts) + parseTriple cc0 normalised_triple + + cc0 <- findCc archOs tgtLlvmTarget (optCc opts) + cxx <- findCxx archOs tgtLlvmTarget (optCxx opts) cpp <- findCpp (optCpp opts) cc0 hsCpp <- findHsCpp (optHsCpp opts) cc0 - (archOs, tgtVendor) <- parseTriple cc0 (optTriple opts) cc <- addPlatformDepCcFlags archOs cc0 readelf <- optional $ findReadelf (optReadelf opts) - ccLink <- findCcLink tgtLlvmTarget (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf + ccLink <- findCcLink tgtLlvmTarget (optLd opts) (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf ar <- findAr tgtVendor (optAr opts) -- TODO: We could have ===================================== utils/ghc-toolchain/ghc-toolchain.cabal ===================================== @@ -17,6 +17,7 @@ library GHC.Toolchain.Prelude, GHC.Toolchain.Program, GHC.Toolchain.ParseTriple, + GHC.Toolchain.NormaliseTriple, GHC.Toolchain.CheckArm, GHC.Toolchain.Target, GHC.Toolchain.Tools.Ar, ===================================== utils/ghc-toolchain/src/GHC/Toolchain/NormaliseTriple.hs ===================================== @@ -0,0 +1,13 @@ +module GHC.Toolchain.NormaliseTriple where + +import GHC.Toolchain.Prelude +import GHC.Toolchain.Program +import Data.Text (strip, pack, unpack) + +-- | Normalise the triple by calling `config.sub` on the given triple. +normaliseTriple :: String -> M String +normaliseTriple triple = do + let norm = unpack . strip . pack + normalised_triple <- norm <$> readProgramStdout shProgram ["config.sub", triple] + logInfo $ unwords ["Normalised triple:", triple, "~>", normalised_triple] + return normalised_triple ===================================== utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs ===================================== @@ -20,12 +20,12 @@ parseTriple cc triple | [archName, vendorName, osName] <- parts = do arch <- parseArch cc archName os <- parseOs osName - return (ArchOS arch os, Just vendorName) + return (ArchOS arch os, Just (parseVendor vendorName)) | [archName, vendorName, osName, _abi] <- parts = do arch <- parseArch cc archName os <- parseOs osName - return (ArchOS arch os, Just vendorName) + return (ArchOS arch os, Just (parseVendor vendorName)) | otherwise = throwE $ "malformed triple " ++ triple @@ -54,6 +54,7 @@ parseArch cc arch = "hppa" -> pure ArchUnknown "wasm32" -> pure ArchWasm32 "javascript" -> pure ArchJavaScript + "loongarch64" -> pure ArchLoongArch64 _ -> throwE $ "Unknown architecture " ++ arch parseOs :: String -> M OS @@ -80,6 +81,20 @@ parseOs os = "ghcjs" -> pure OSGhcjs _ -> throwE $ "Unknown operating system " ++ os +parseVendor :: String -> String +parseVendor vendor = + case vendor of + -- like i686-pc-linux-gnu, i686-gentoo-freebsd8, x86_64-w64-mingw32 + "pc" -> "unknown" + "gentoo" -> "unknown" + "w64" -> "unknown" + -- like armv5tel-softfloat-linux-gnueabi + "softfloat" -> "unknown" + -- like armv7a-hardfloat-linux-gnueabi + "hardfloat" -> "unknown" + -- Pass through by default + _ -> vendor + splitOn :: Char -> String -> [String] splitOn sep = go where ===================================== utils/ghc-toolchain/src/GHC/Toolchain/PlatformDetails.hs ===================================== @@ -46,7 +46,7 @@ checkWordSize cc = checking "word size" $ do checkEndianness :: Cc -> M Endianness checkEndianness cc = do - checkEndiannessParamH cc <|> checkEndiannessLimitsH cc + checkEndiannessParamH cc <|> checkEndiannessLimitsH cc <|> checkEndianness__BYTE_ORDER__ cc checkEndiannessParamH :: Cc -> M Endianness checkEndiannessParamH cc = checking "endianness (param.h)" $ do @@ -92,6 +92,28 @@ checkEndiannessLimitsH cc = checking "endianness (limits.h)" $ do , "#endif" ] +checkEndianness__BYTE_ORDER__ :: Cc -> M Endianness +checkEndianness__BYTE_ORDER__ cc = checking "endianness (__BYTE_ORDER__)" $ do + out <- preprocess cc prog + case reverse $ lines out of + "big":_ -> return BigEndian + "little":_ -> return LittleEndian + "unknown":_ -> throwE "unknown endianness" + _ -> throwE "unrecognized output" + where + prog = unlines + [ "#include " + , "#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__" + , "little" + , "#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__" + , "big" + , "#else" + , "unknown" + , "#endif" + ] + + + checkLeadingUnderscore :: Cc -> Nm -> M Bool checkLeadingUnderscore cc nm = checking ctxt $ withTempDir $ \dir -> do let test_o = dir "test.o" ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Program.hs ===================================== @@ -1,5 +1,6 @@ module GHC.Toolchain.Program ( Program(..) + , shProgram , _prgPath , _prgFlags , addFlagIfNew @@ -29,6 +30,7 @@ import System.Directory import System.Exit import System.Process hiding (env) +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Utils @@ -37,6 +39,9 @@ data Program = Program { prgPath :: FilePath } deriving (Read, Eq, Ord) +shProgram :: Program +shProgram = Program "sh" [] + instance Show Program where -- Normalise filepaths before showing to aid with diffing the target files. show (Program p f) = unwords @@ -178,17 +183,37 @@ compile ext extraFlags lens c outPath program = do callProgram (view lens c) $ extraFlags ++ ["-o", outPath, srcPath] expectFileExists outPath "compiler produced no output" +-- Note [Don't pass --target to emscripten toolchain] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- Emscripten's CC wrapper is a bit wonky in that it accepts the `--target` +-- flag when used as a linker yet rejects it as a compiler (e.g. with `-c`). +-- This is exacerbated by the fact that Cabal currently in some cases +-- combines (and therefore conflates) link and compilation flags. +-- +-- Ultimately this should be fixed in Cabal but in the meantime we work around it +-- by handling this toolchain specifically in the various +-- "supports --target" checks in `configure` and `ghc-toolchain`. +-- +-- Fixes #23744. + -- | Does compiler program support the @--target=@ option? If so, we should -- pass it whenever possible to avoid ambiguity and potential compile-time -- errors (e.g. see #20162). -supportsTarget :: Lens compiler Program +supportsTarget :: ArchOS + -> Lens compiler Program -> (compiler -> M ()) -- ^ Action to check if compiler with @--target@ flag works -> String -- ^ The LLVM target to use if @cc@ supports @--target@ -> compiler -- ^ The compiler to check @--target@ support for -> M compiler -- ^ Return compiler with @--target@ flag if supported -supportsTarget lens checkWorks llvmTarget c --- TODO: #23603 - | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) = return c +supportsTarget archOs lens checkWorks llvmTarget c + -- See Note [Don't pass --target to emscripten toolchain]. + | ArchJavaScript <- archOS_arch archOs + = return c + + -- No reason to check if the options already contain a --target flag + | any ("--target=" `isPrefixOf`) (view (lens % _prgFlags) c) + = return c + | otherwise = let c' = over (lens % _prgFlags) (("--target="++llvmTarget):) c in (c' <$ checkWorks (over (lens % _prgFlags) ("-Werror":) c')) <|> return c ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs ===================================== @@ -4,12 +4,14 @@ module GHC.Toolchain.Tools.Cc ( Cc(..) , _ccProgram + , findBasicCc , findCc -- * Helpful utilities , preprocess , compileC , compileAsm , addPlatformDepCcFlags + , checkC99Support ) where import Control.Monad @@ -32,19 +34,29 @@ _ccProgram = Lens ccProgram (\x o -> o{ccProgram=x}) _ccFlags :: Lens Cc [String] _ccFlags = _ccProgram % _prgFlags -findCc :: String -- ^ The llvm target to use if Cc supports --target - -> ProgOpt -> M Cc -findCc llvmTarget progOpt = checking "for C compiler" $ do +-- We use this to find a minimally-functional compiler needed to call +-- parseTriple. +findBasicCc :: ProgOpt -> M Cc +findBasicCc progOpt = checking "for C compiler" $ do -- TODO: We keep the candidate order we had in configure, but perhaps -- there's a more optimal one ccProgram <- findProgram "C compiler" progOpt ["gcc", "clang", "cc"] + return $ Cc{ccProgram} - cc' <- ignoreUnusedArgs $ Cc {ccProgram} - cc <- ccSupportsTarget llvmTarget cc' - checking "whether Cc works" $ checkCcWorks cc - checkC99Support cc - checkCcSupportsExtraViaCFlags cc - return cc +findCc :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target + -> ProgOpt -> M Cc +findCc archOs llvmTarget progOpt = do + cc0 <- findBasicCc progOpt + cc1 <- ignoreUnusedArgs cc0 + cc2 <- ccSupportsTarget archOs llvmTarget cc1 + checking "whether Cc works" $ checkCcWorks cc2 + cc3 <- oneOf "cc doesn't support C99" $ map checkC99Support + [ cc2 + , cc2 & _ccFlags %++ "-std=gnu99" + ] + checkCcSupportsExtraViaCFlags cc3 + return cc3 checkCcWorks :: Cc -> M () checkCcWorks cc = withTempDir $ \dir -> do @@ -71,11 +83,12 @@ ignoreUnusedArgs cc -- Does Cc support the --target= option? If so, we should pass it -- whenever possible to avoid ambiguity and potential compile-time errors (e.g. -- see #20162). -ccSupportsTarget :: String -> Cc -> M Cc -ccSupportsTarget target cc = checking "whether Cc supports --target" $ - supportsTarget _ccProgram checkCcWorks target cc +ccSupportsTarget :: ArchOS -> String -> Cc -> M Cc +ccSupportsTarget archOs target cc = + checking "whether Cc supports --target" $ + supportsTarget archOs _ccProgram checkCcWorks target cc -checkC99Support :: Cc -> M () +checkC99Support :: Cc -> M Cc checkC99Support cc = checking "for C99 support" $ withTempDir $ \dir -> do let test_o = dir "test.o" compileC cc test_o $ unlines @@ -84,6 +97,7 @@ checkC99Support cc = checking "for C99 support" $ withTempDir $ \dir -> do , "# error \"Compiler does not advertise C99 conformance\"" , "#endif" ] + return cc checkCcSupportsExtraViaCFlags :: Cc -> M () checkCcSupportsExtraViaCFlags cc = checking "whether cc supports extra via-c flags" $ withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs ===================================== @@ -10,7 +10,7 @@ import GHC.Toolchain.Prelude import GHC.Toolchain.Program import GHC.Toolchain.Tools.Cc -import GHC.Toolchain.Utils (withTempDir) +import GHC.Toolchain.Utils (withTempDir, oneOf) newtype Cpp = Cpp { cppProgram :: Program } @@ -83,7 +83,12 @@ findCpp :: ProgOpt -> Cc -> M Cpp findCpp progOpt cc = checking "for C preprocessor" $ do -- Use the specified CPP or try to use the c compiler foundCppProg <- findProgram "C preprocessor" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) []) + -- Check whether the C preprocessor needs -std=gnu99 (only very old toolchains need this) + Cc cpp2 <- oneOf "cc doesn't support C99" $ map checkC99Support + [ Cc foundCppProg + , Cc (foundCppProg & _prgFlags %++ "-std=gnu99") + ] -- Always add the -E flag to the CPP, regardless of the user options - let cppProgram = addFlagIfNew "-E" foundCppProg + let cppProgram = addFlagIfNew "-E" cpp2 return Cpp{cppProgram} ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cxx.hs ===================================== @@ -8,6 +8,8 @@ module GHC.Toolchain.Tools.Cxx ) where import System.FilePath + +import GHC.Platform.ArchOS import GHC.Toolchain.Prelude import GHC.Toolchain.Program import GHC.Toolchain.Utils @@ -19,18 +21,20 @@ newtype Cxx = Cxx { cxxProgram :: Program _cxxProgram :: Lens Cxx Program _cxxProgram = Lens cxxProgram (\x o -> o{cxxProgram=x}) -findCxx :: String -- ^ The llvm target to use if Cc supports --target +findCxx :: ArchOS + -> String -- ^ The llvm target to use if Cc supports --target -> ProgOpt -> M Cxx -findCxx target progOpt = checking "for C++ compiler" $ do +findCxx archOs target progOpt = checking "for C++ compiler" $ do -- TODO: We use the search order in configure, but there could be a more optimal one cxxProgram <- findProgram "C++ compiler" progOpt ["g++", "clang++", "c++"] - cxx <- cxxSupportsTarget target Cxx{cxxProgram} + cxx <- cxxSupportsTarget archOs target Cxx{cxxProgram} checkCxxWorks cxx return cxx -cxxSupportsTarget :: String -> Cxx -> M Cxx -cxxSupportsTarget target cxx = checking "whether C++ supports --target" $ - supportsTarget _cxxProgram checkCxxWorks target cxx +cxxSupportsTarget :: ArchOS -> String -> Cxx -> M Cxx +cxxSupportsTarget archOs target cxx = + checking "whether C++ supports --target" $ + supportsTarget archOs _cxxProgram checkCxxWorks target cxx checkCxxWorks :: Cxx -> M () checkCxxWorks cxx = withTempDir $ \dir -> do ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs ===================================== @@ -42,21 +42,28 @@ _ccLinkProgram :: Lens CcLink Program _ccLinkProgram = Lens ccLinkProgram (\x o -> o{ccLinkProgram=x}) findCcLink :: String -- ^ The llvm target to use if CcLink supports --target + -> ProgOpt -> ProgOpt -> Bool -- ^ Whether we should search for a more efficient linker -> ArchOS -> Cc -> Maybe Readelf -> M CcLink -findCcLink target progOpt ldOverride archOs cc readelf = checking "for C compiler for linking command" $ do +findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C compiler for linking command" $ do -- Use the specified linker or try using the C compiler rawCcLink <- findProgram "C compiler for linking" progOpt [] <|> pure (programFromOpt progOpt (prgPath $ ccProgram cc) []) - ccLinkProgram <- case poFlags progOpt of - Just _ -> + -- See #23857 for why we check to see if LD is set here + -- TLDR: If the user explicitly sets LD then in ./configure + -- we don't perform a linker search (and set -fuse-ld), so + -- we do the same here for consistency. + ccLinkProgram <- case (poPath ld, poFlags progOpt) of + (_, Just _) -> -- If the user specified linker flags don't second-guess them pure rawCcLink - Nothing -> do + (Just {}, _) -> + pure rawCcLink + _ -> do -- If not then try to find decent linker flags findLinkFlags ldOverride cc rawCcLink <|> pure rawCcLink ccLinkProgram <- linkSupportsTarget archOs cc target ccLinkProgram - ccLinkSupportsNoPie <- checkSupportsNoPie ccLinkProgram + ccLinkSupportsNoPie <- checkSupportsNoPie cc ccLinkProgram ccLinkSupportsCompactUnwind <- checkSupportsCompactUnwind archOs cc ccLinkProgram ccLinkSupportsFilelist <- checkSupportsFilelist cc ccLinkProgram ccLinkIsGnu <- checkLinkIsGnu archOs ccLinkProgram @@ -90,12 +97,9 @@ findLinkFlags enableOverride cc ccLink linkSupportsTarget :: ArchOS -> Cc -> String -> Program -> M Program -- Javascript toolchain provided by emsdk just ignores --target flag so -- we have this special case to match with ./configure (#23744) -linkSupportsTarget archOS _ _ c - | ArchJavaScript <- archOS_arch archOS - = return c -linkSupportsTarget _ cc target link - = checking "whether cc linker supports --target" $ - supportsTarget (Lens id const) (checkLinkWorks cc) target link +linkSupportsTarget archOs cc target link = + checking "whether cc linker supports --target" $ + supportsTarget archOs (Lens id const) (checkLinkWorks cc) target link -- | Should we attempt to find a more efficient linker on this platform? -- @@ -112,16 +116,15 @@ doLinkerSearch = False #endif -- | See Note [No PIE when linking] in GHC.Driver.Session -checkSupportsNoPie :: Program -> M Bool -checkSupportsNoPie ccLink = checking "whether the cc linker supports -no-pie" $ +checkSupportsNoPie :: Cc -> Program -> M Bool +checkSupportsNoPie cc ccLink = checking "whether the cc linker supports -no-pie" $ withTempDir $ \dir -> do - let test_c = dir "test.c" - writeFile test_c "int main() { return 0; }" - + let test_o = dir "test.o" let test = dir "test" + compileC cc test_o "int main() { return 0; }" -- Check output as some GCC versions only warn and don't respect -Werror -- when passed an unrecognized flag. - (code, out, err) <- readProgram ccLink ["-no-pie", "-Werror", "-x", "c", test_c, "-o", test] + (code, out, err) <- readProgram ccLink ["-no-pie", "-Werror", test_o, "-o", test] return (isSuccess code && not ("unrecognized" `isInfixOf` out) && not ("unrecognized" `isInfixOf` err)) -- ROMES:TODO: This check is wrong here and in configure because with ld.gold parses "-n" "o_compact_unwind" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e96c51cbd137113ec953d8b7b0817d2d268f3c96...c00a4bd640a154661b8b32ed998b8c44371a70a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e96c51cbd137113ec953d8b7b0817d2d268f3c96...c00a4bd640a154661b8b32ed998b8c44371a70a5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 23:03:20 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 19:03:20 -0400 Subject: [Git][ghc/ghc][master] Stricter Binary.get in GHC.Types.Unit (#23964) Message-ID: <6525d838685e9_1b931c699061546327cb@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - 1 changed file: - compiler/GHC/Unit/Types.hs Changes: ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -149,7 +149,8 @@ instance Uniquable Module where instance Binary a => Binary (GenModule a) where put_ bh (Module p n) = put_ bh p >> put_ bh n - get bh = do p <- get bh; n <- get bh; return (Module p n) + -- Module has strict fields, so use $! in order not to allocate a thunk + get bh = do p <- get bh; n <- get bh; return $! Module p n instance NFData (GenModule a) where rnf (Module unit name) = unit `seq` name `seq` () @@ -317,13 +318,14 @@ instance Binary InstantiatedUnit where cid <- get bh insts <- get bh let fs = mkInstantiatedUnitHash cid insts - return InstantiatedUnit { - instUnitInstanceOf = cid, - instUnitInsts = insts, - instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), - instUnitFS = fs, - instUnitKey = getUnique fs - } + -- InstantiatedUnit has strict fields, so use $! in order not to allocate a thunk + return $! InstantiatedUnit { + instUnitInstanceOf = cid, + instUnitInsts = insts, + instUnitHoles = unionManyUniqDSets (map (moduleFreeHoles.snd) insts), + instUnitFS = fs, + instUnitKey = getUnique fs + } instance IsUnitId u => Eq (GenUnit u) where uid1 == uid2 = unitUnique uid1 == unitUnique uid2 @@ -369,10 +371,12 @@ instance Binary Unit where put_ bh HoleUnit = putByte bh 2 get bh = do b <- getByte bh - case b of + u <- case b of 0 -> fmap RealUnit (get bh) 1 -> fmap VirtUnit (get bh) _ -> pure HoleUnit + -- Unit has strict fields that need forcing; otherwise we allocate a thunk. + pure $! u -- | Retrieve the set of free module holes of a 'Unit'. unitFreeModuleHoles :: GenUnit u -> UniqDSet ModuleName View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f11e7c44e2fa60ce92bd1406e8aea66e3fa29cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f11e7c44e2fa60ce92bd1406e8aea66e3fa29cf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 23:03:51 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 19:03:51 -0400 Subject: [Git][ghc/ghc][master] rel_eng/upload.sh cleanups Message-ID: <6525d857b2b87_1b931c696831fc6371a2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 1 changed file: - .gitlab/rel_eng/upload.sh Changes: ===================================== .gitlab/rel_eng/upload.sh ===================================== @@ -1,6 +1,7 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p moreutils lzip zip lftp gnupg -set -e +set -Eeuo pipefail # This is a script for preparing and uploading a release of GHC. # @@ -30,21 +31,15 @@ set -e # # Prerequisites: moreutils -if [ -z "$SIGNING_KEY" ]; then - SIGNING_KEY="=Benjamin Gamari " -fi +: ${SIGNING_KEY:="=Benjamin Gamari "} # Infer release name from directory name -if [ -z "$rel_name" ]; then - rel_name="$(basename $(pwd))" -fi +: ${rel_name:=$(basename $(pwd))} # Infer version from tarball names -if [ -z "$ver" ]; then - ver="$(ls ghc-*.tar.* | sed -ne 's/ghc-\([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).\+/\1/p' | head -n1)" - if [ -z "$ver" ]; then echo "Failed to infer \$ver"; exit 1; fi -fi +: ${ver:=$(ls ghc-*.tar.* | sed -ne 's/ghc-\([0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).\+/\1/p' | head -n1)} +if [ -z "$ver" ]; then echo "Failed to infer \$ver"; exit 1; fi host="gitlab-storage.haskell.org" @@ -141,6 +136,7 @@ function upload() { } function purge_all() { + dir="$(echo $rel_name | sed s/-release//)" # Purge CDN cache curl -X PURGE http://downloads.haskell.org/ghc/ curl -X PURGE http://downloads.haskell.org/~ghc/ @@ -196,6 +192,7 @@ function prepare_docs() { } function recompress() { + set -Eeuo pipefail combine <(basename -s .xz *.xz) not <(basename -s .lz *.lz) | \ parallel 'echo "Recompressing {}.xz to {}.lz"; unxz -c {}.xz | lzip - -o {}.lz' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4f1a181a20abac1f71e8a1793a2d541dda3394f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4f1a181a20abac1f71e8a1793a2d541dda3394f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 23:04:31 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 19:04:31 -0400 Subject: [Git][ghc/ghc][master] ci: add javascript label rule Message-ID: <6525d87f3a572_1b931c6969c620640383@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - 2 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/generate-ci/gen_ci.hs ===================================== @@ -604,6 +604,7 @@ data Rule = ReleaseOnly -- ^ Only run this job in a release pipeline data ValidateRule = FullCI -- ^ Run this job when the "full-ci" label is present. | LLVMBackend -- ^ Run this job when the "LLVM backend" label is present + | JSBackend -- ^ Run this job when the "javascript" label is present | FreeBSDLabel -- ^ Run this job when the "FreeBSD" label is set. | NonmovingGc -- ^ Run this job when the "non-moving GC" label is set. | IpeData -- ^ Run this job when the "IPE" label is set @@ -648,11 +649,12 @@ validateRuleString FullCI = or_all ([ labelString "full-ci" , branchStringLike "ghc-[0-9]+\\.[0-9]+" ]) -validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString LLVMBackend = labelString "LLVM backend" +validateRuleString JSBackend = labelString "javascript" validateRuleString FreeBSDLabel = labelString "FreeBSD" -validateRuleString NonmovingGc = labelString "non-moving GC" -validateRuleString IpeData = labelString "IPE" -validateRuleString TestPrimops = labelString "test-primops" +validateRuleString NonmovingGc = labelString "non-moving GC" +validateRuleString IpeData = labelString "IPE" +validateRuleString TestPrimops = labelString "test-primops" -- | A 'Job' is the description of a single job in a gitlab pipeline. The -- job contains all the information about how to do the build but can be further @@ -1010,10 +1012,9 @@ job_groups = , disableValidate (standardBuildsWithConfig AArch64 (Linux Alpine318) (splitSectionsBroken vanilla)) , fullyStaticBrokenTests (disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine312) staticNativeInt))) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure") - ) - { bignumBackend = Native - } + + , addValidateRule JSBackend (validateBuilds Amd64 (Linux Debian11) javascriptConfig) + , make_wasm_jobs wasm_build_config , modifyValidateJobs manual $ make_wasm_jobs wasm_build_config {bignumBackend = Native} @@ -1024,6 +1025,8 @@ job_groups = ] where + javascriptConfig = (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure")) + { bignumBackend = Native } -- ghcilink002 broken due to #17869 -- ===================================== .gitlab/jobs.yaml ===================================== @@ -5255,7 +5255,7 @@ ], "rules": [ { - "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", + "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)", "when": "on_success" } ], View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80705335741f0c86e67e30e25a9064f1d73db7f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80705335741f0c86e67e30e25a9064f1d73db7f0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 23:05:13 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 19:05:13 -0400 Subject: [Git][ghc/ghc][master] Make 'wWarningFlagsDeps' include every WarningFlag Message-ID: <6525d8a8f3e9f_1b931c696831fc64365a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - 2 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -696,7 +696,7 @@ data WarningFlag = | Opt_WarnIncompleteRecordSelectors -- Since 9.10 | Opt_WarnBadlyStagedTypes -- Since 9.10 | Opt_WarnInconsistentFlags -- Since 9.8 - deriving (Eq, Ord, Show, Enum) + deriving (Eq, Ord, Show, Enum, Bounded) -- | Return the names of a WarningFlag -- ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2165,127 +2165,125 @@ wWarningFlags :: [FlagSpec WarningFlag] wWarningFlags = map snd (sortBy (comparing fst) wWarningFlagsDeps) wWarningFlagsDeps :: [(Deprecation, FlagSpec WarningFlag)] -wWarningFlagsDeps = mconcat [ +wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of -- See Note [Updating flag description in the User's Guide] -- See Note [Supporting CLI completion] --- Please keep the list of flags below sorted alphabetically - warnSpec Opt_WarnAlternativeLayoutRuleTransitional, - warnSpec Opt_WarnAmbiguousFields, - depWarnSpec Opt_WarnAutoOrphans - "it has no effect", - warnSpec Opt_WarnCPPUndef, - warnSpec Opt_WarnUnbangedStrictPatterns, - warnSpec Opt_WarnDeferredTypeErrors, - warnSpec Opt_WarnDeferredOutOfScopeVariables, - warnSpec Opt_WarnDeprecatedFlags, - warnSpec Opt_WarnDerivingDefaults, - warnSpec Opt_WarnDerivingTypeable, - warnSpec Opt_WarnDodgyExports, - warnSpec Opt_WarnDodgyForeignImports, - warnSpec Opt_WarnDodgyImports, - warnSpec Opt_WarnEmptyEnumerations, - subWarnSpec "duplicate-constraints" - Opt_WarnDuplicateConstraints - "it is subsumed by -Wredundant-constraints", - warnSpec Opt_WarnRedundantConstraints, - warnSpec Opt_WarnDuplicateExports, - depWarnSpec Opt_WarnHiShadows - "it is not used, and was never implemented", - warnSpec Opt_WarnInaccessibleCode, - warnSpec Opt_WarnImplicitPrelude, - depWarnSpec Opt_WarnImplicitKindVars - "it is now an error", - warnSpec Opt_WarnIncompletePatterns, - warnSpec Opt_WarnIncompletePatternsRecUpd, - warnSpec Opt_WarnIncompleteUniPatterns, - warnSpec Opt_WarnInlineRuleShadowing, - warnSpec Opt_WarnIdentities, - warnSpec Opt_WarnMissingFields, - warnSpec Opt_WarnMissingImportList, - warnSpec Opt_WarnMissingExportList, - subWarnSpec "missing-local-sigs" - Opt_WarnMissingLocalSignatures - "it is replaced by -Wmissing-local-signatures", - warnSpec Opt_WarnMissingLocalSignatures, - warnSpec Opt_WarnMissingMethods, - depWarnSpec Opt_WarnMissingMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnSemigroup, - warnSpec Opt_WarnMissingSignatures, - warnSpec Opt_WarnMissingKindSignatures, - warnSpec Opt_WarnMissingPolyKindSignatures, - subWarnSpec "missing-exported-sigs" - Opt_WarnMissingExportedSignatures - "it is replaced by -Wmissing-exported-signatures", - warnSpec Opt_WarnMissingExportedSignatures, - warnSpec Opt_WarnMonomorphism, - warnSpec Opt_WarnNameShadowing, - warnSpec Opt_WarnNonCanonicalMonadInstances, - depWarnSpec Opt_WarnNonCanonicalMonadFailInstances - "fail is no longer a method of Monad", - warnSpec Opt_WarnNonCanonicalMonoidInstances, - warnSpec Opt_WarnOrphans, - warnSpec Opt_WarnOverflowedLiterals, - warnSpec Opt_WarnOverlappingPatterns, - warnSpec Opt_WarnMissedSpecs, - warnSpec Opt_WarnAllMissedSpecs, - warnSpec' Opt_WarnSafe setWarnSafe, - warnSpec Opt_WarnTrustworthySafe, - warnSpec Opt_WarnInferredSafeImports, - warnSpec Opt_WarnMissingSafeHaskellMode, - warnSpec Opt_WarnTabs, - warnSpec Opt_WarnTypeDefaults, - warnSpec Opt_WarnTypedHoles, - warnSpec Opt_WarnPartialTypeSignatures, - warnSpec Opt_WarnUnrecognisedPragmas, - warnSpec Opt_WarnMisplacedPragmas, - warnSpec' Opt_WarnUnsafe setWarnUnsafe, - warnSpec Opt_WarnUnsupportedCallingConventions, - warnSpec Opt_WarnUnsupportedLlvmVersion, - warnSpec Opt_WarnMissedExtraSharedLib, - warnSpec Opt_WarnUntickedPromotedConstructors, - warnSpec Opt_WarnUnusedDoBind, - warnSpec Opt_WarnUnusedForalls, - warnSpec Opt_WarnUnusedImports, - warnSpec Opt_WarnUnusedLocalBinds, - warnSpec Opt_WarnUnusedMatches, - warnSpec Opt_WarnUnusedPatternBinds, - warnSpec Opt_WarnUnusedTopBinds, - warnSpec Opt_WarnUnusedTypePatterns, - warnSpec Opt_WarnUnusedRecordWildcards, - warnSpec Opt_WarnRedundantBangPatterns, - warnSpec Opt_WarnRedundantRecordWildcards, - warnSpec Opt_WarnRedundantStrictnessFlags, - warnSpec Opt_WarnWrongDoBind, - warnSpec Opt_WarnMissingPatternSynonymSignatures, - warnSpec Opt_WarnMissingDerivingStrategies, - warnSpec Opt_WarnSimplifiableClassConstraints, - warnSpec Opt_WarnMissingHomeModules, - warnSpec Opt_WarnUnrecognisedWarningFlags, - warnSpec Opt_WarnStarBinder, - warnSpec Opt_WarnStarIsType, - depWarnSpec Opt_WarnSpaceAfterBang - "bang patterns can no longer be written with a space", - warnSpec Opt_WarnPartialFields, - warnSpec Opt_WarnPrepositiveQualifiedModule, - warnSpec Opt_WarnUnusedPackages, - warnSpec Opt_WarnCompatUnqualifiedImports, - warnSpec Opt_WarnInvalidHaddock, - warnSpec Opt_WarnOperatorWhitespaceExtConflict, - warnSpec Opt_WarnOperatorWhitespace, - warnSpec Opt_WarnImplicitLift, - warnSpec Opt_WarnMissingExportedPatternSynonymSignatures, - warnSpec Opt_WarnForallIdentifier, - warnSpec Opt_WarnUnicodeBidirectionalFormatCharacters, - warnSpec Opt_WarnGADTMonoLocalBinds, - warnSpec Opt_WarnTypeEqualityOutOfScope, - warnSpec Opt_WarnTypeEqualityRequiresOperators, - warnSpec Opt_WarnTermVariableCapture, - warnSpec Opt_WarnMissingRoleAnnotations, - warnSpec Opt_WarnImplicitRhsQuantification, - warnSpec Opt_WarnIncompleteExportWarnings, - warnSpec Opt_WarnIncompleteRecordSelectors - ] + Opt_WarnAlternativeLayoutRuleTransitional -> warnSpec x + Opt_WarnAmbiguousFields -> warnSpec x + Opt_WarnAutoOrphans -> depWarnSpec x "it has no effect" + Opt_WarnCPPUndef -> warnSpec x + Opt_WarnBadlyStagedTypes -> warnSpec x + Opt_WarnUnbangedStrictPatterns -> warnSpec x + Opt_WarnDeferredTypeErrors -> warnSpec x + Opt_WarnDeferredOutOfScopeVariables -> warnSpec x + Opt_WarnDeprecatedFlags -> warnSpec x + Opt_WarnDerivingDefaults -> warnSpec x + Opt_WarnDerivingTypeable -> warnSpec x + Opt_WarnDodgyExports -> warnSpec x + Opt_WarnDodgyForeignImports -> warnSpec x + Opt_WarnDodgyImports -> warnSpec x + Opt_WarnEmptyEnumerations -> warnSpec x + Opt_WarnDuplicateConstraints + -> subWarnSpec "duplicate-constraints" x "it is subsumed by -Wredundant-constraints" + Opt_WarnRedundantConstraints -> warnSpec x + Opt_WarnDuplicateExports -> warnSpec x + Opt_WarnHiShadows + -> depWarnSpec x "it is not used, and was never implemented" + Opt_WarnInaccessibleCode -> warnSpec x + Opt_WarnImplicitPrelude -> warnSpec x + Opt_WarnImplicitKindVars -> depWarnSpec x "it is now an error" + Opt_WarnIncompletePatterns -> warnSpec x + Opt_WarnIncompletePatternsRecUpd -> warnSpec x + Opt_WarnIncompleteUniPatterns -> warnSpec x + Opt_WarnInconsistentFlags -> warnSpec x + Opt_WarnInlineRuleShadowing -> warnSpec x + Opt_WarnIdentities -> warnSpec x + Opt_WarnLoopySuperclassSolve -> warnSpec x + Opt_WarnMissingFields -> warnSpec x + Opt_WarnMissingImportList -> warnSpec x + Opt_WarnMissingExportList -> warnSpec x + Opt_WarnMissingLocalSignatures + -> subWarnSpec "missing-local-sigs" x + "it is replaced by -Wmissing-local-signatures" + ++ warnSpec x + Opt_WarnMissingMethods -> warnSpec x + Opt_WarnMissingMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnSemigroup -> warnSpec x + Opt_WarnMissingSignatures -> warnSpec x + Opt_WarnMissingKindSignatures -> warnSpec x + Opt_WarnMissingPolyKindSignatures -> warnSpec x + Opt_WarnMissingExportedSignatures + -> subWarnSpec "missing-exported-sigs" x + "it is replaced by -Wmissing-exported-signatures" + ++ warnSpec x + Opt_WarnMonomorphism -> warnSpec x + Opt_WarnNameShadowing -> warnSpec x + Opt_WarnNonCanonicalMonadInstances -> warnSpec x + Opt_WarnNonCanonicalMonadFailInstances + -> depWarnSpec x "fail is no longer a method of Monad" + Opt_WarnNonCanonicalMonoidInstances -> warnSpec x + Opt_WarnOrphans -> warnSpec x + Opt_WarnOverflowedLiterals -> warnSpec x + Opt_WarnOverlappingPatterns -> warnSpec x + Opt_WarnMissedSpecs -> warnSpec x + Opt_WarnAllMissedSpecs -> warnSpec x + Opt_WarnSafe -> warnSpec' x setWarnSafe + Opt_WarnTrustworthySafe -> warnSpec x + Opt_WarnInferredSafeImports -> warnSpec x + Opt_WarnMissingSafeHaskellMode -> warnSpec x + Opt_WarnTabs -> warnSpec x + Opt_WarnTypeDefaults -> warnSpec x + Opt_WarnTypedHoles -> warnSpec x + Opt_WarnPartialTypeSignatures -> warnSpec x + Opt_WarnUnrecognisedPragmas -> warnSpec x + Opt_WarnMisplacedPragmas -> warnSpec x + Opt_WarnUnsafe -> warnSpec' x setWarnUnsafe + Opt_WarnUnsupportedCallingConventions -> warnSpec x + Opt_WarnUnsupportedLlvmVersion -> warnSpec x + Opt_WarnMissedExtraSharedLib -> warnSpec x + Opt_WarnUntickedPromotedConstructors -> warnSpec x + Opt_WarnUnusedDoBind -> warnSpec x + Opt_WarnUnusedForalls -> warnSpec x + Opt_WarnUnusedImports -> warnSpec x + Opt_WarnUnusedLocalBinds -> warnSpec x + Opt_WarnUnusedMatches -> warnSpec x + Opt_WarnUnusedPatternBinds -> warnSpec x + Opt_WarnUnusedTopBinds -> warnSpec x + Opt_WarnUnusedTypePatterns -> warnSpec x + Opt_WarnUnusedRecordWildcards -> warnSpec x + Opt_WarnRedundantBangPatterns -> warnSpec x + Opt_WarnRedundantRecordWildcards -> warnSpec x + Opt_WarnRedundantStrictnessFlags -> warnSpec x + Opt_WarnWrongDoBind -> warnSpec x + Opt_WarnMissingPatternSynonymSignatures -> warnSpec x + Opt_WarnMissingDerivingStrategies -> warnSpec x + Opt_WarnSimplifiableClassConstraints -> warnSpec x + Opt_WarnMissingHomeModules -> warnSpec x + Opt_WarnUnrecognisedWarningFlags -> warnSpec x + Opt_WarnStarBinder -> warnSpec x + Opt_WarnStarIsType -> warnSpec x + Opt_WarnSpaceAfterBang + -> depWarnSpec x "bang patterns can no longer be written with a space" + Opt_WarnPartialFields -> warnSpec x + Opt_WarnPrepositiveQualifiedModule -> warnSpec x + Opt_WarnUnusedPackages -> warnSpec x + Opt_WarnCompatUnqualifiedImports -> warnSpec x + Opt_WarnInvalidHaddock -> warnSpec x + Opt_WarnOperatorWhitespaceExtConflict -> warnSpec x + Opt_WarnOperatorWhitespace -> warnSpec x + Opt_WarnImplicitLift -> warnSpec x + Opt_WarnMissingExportedPatternSynonymSignatures -> warnSpec x + Opt_WarnForallIdentifier -> warnSpec x + Opt_WarnUnicodeBidirectionalFormatCharacters -> warnSpec x + Opt_WarnGADTMonoLocalBinds -> warnSpec x + Opt_WarnTypeEqualityOutOfScope -> warnSpec x + Opt_WarnTypeEqualityRequiresOperators -> warnSpec x + Opt_WarnTermVariableCapture -> warnSpec x + Opt_WarnMissingRoleAnnotations -> warnSpec x + Opt_WarnImplicitRhsQuantification -> warnSpec x + Opt_WarnIncompleteExportWarnings -> warnSpec x + Opt_WarnIncompleteRecordSelectors -> warnSpec x warningGroupsDeps :: [(Deprecation, FlagSpec WarningGroup)] warningGroupsDeps = map mk warningGroups View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a2c0fff61afdb14b5f2624374aa5767e7b238ff4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a2c0fff61afdb14b5f2624374aa5767e7b238ff4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 23:06:19 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 19:06:19 -0400 Subject: [Git][ghc/ghc][master] Fix pretty printing of overlap pragmas in TH splices (fixes #24074) Message-ID: <6525d8eb903f5_1b931c6969c62064827a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 5 changed files: - compiler/GHC/ThToHs.hs - hadrian/doc/testsuite.md - + testsuite/tests/th/T24074.hs - + testsuite/tests/th/T24074.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -328,10 +328,10 @@ cvtDec (InstanceD o ctxt ty decs) where overlap pragma = case pragma of - TH.Overlaps -> Hs.Overlaps (SourceText $ fsLit "OVERLAPS") - TH.Overlappable -> Hs.Overlappable (SourceText $ fsLit "OVERLAPPABLE") - TH.Overlapping -> Hs.Overlapping (SourceText $ fsLit "OVERLAPPING") - TH.Incoherent -> Hs.Incoherent (SourceText $ fsLit "INCOHERENT") + TH.Overlaps -> Hs.Overlaps (SourceText $ fsLit "{-# OVERLAPS") + TH.Overlappable -> Hs.Overlappable (SourceText $ fsLit "{-# OVERLAPPABLE") + TH.Overlapping -> Hs.Overlapping (SourceText $ fsLit "{-# OVERLAPPING") + TH.Incoherent -> Hs.Incoherent (SourceText $ fsLit "{-# INCOHERENT") ===================================== hadrian/doc/testsuite.md ===================================== @@ -68,7 +68,7 @@ more directories, under which the testsuite driver will be looking for By default, the `test` rule tries to run all the tests available (the ones under `testsuite/tests/` as well as all the tests of the boot libraries -or programs (`base`, `haddock`, etc). +or programs (`base`, `haddock`, etc)). To restrict the testsuite driver to only run a specific directory of tests, e.g `testsuite/tests/th`, you can simply do: ===================================== testsuite/tests/th/T24074.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module T24074 where + +class A a + +$( [d| instance {-# OVERLAPS #-} A Int |] ) +$( [d| instance {-# OVERLAPPABLE #-} A Bool |] ) +$( [d| instance {-# OVERLAPPING #-} A () |] ) +$( [d| instance {-# INCOHERENT #-} A Char |] ) ===================================== testsuite/tests/th/T24074.stderr ===================================== @@ -0,0 +1,16 @@ +T24074.hs:6:2-43: Splicing declarations + [d| instance {-# OVERLAPS #-} A Int |] + ======> + instance {-# OVERLAPS #-} A Int +T24074.hs:7:2-48: Splicing declarations + [d| instance {-# OVERLAPPABLE #-} A Bool |] + ======> + instance {-# OVERLAPPABLE #-} A Bool +T24074.hs:8:2-45: Splicing declarations + [d| instance {-# OVERLAPPING #-} A () |] + ======> + instance {-# OVERLAPPING #-} A () +T24074.hs:9:2-46: Splicing declarations + [d| instance {-# INCOHERENT #-} A Char |] + ======> + instance {-# INCOHERENT #-} A Char ===================================== testsuite/tests/th/all.T ===================================== @@ -158,6 +158,7 @@ test('TH_tf1', normal, compile, ['-v0']) test('TH_tf3', normal, compile, ['-v0']) test('TH_pragma', normal, compile, ['-v0 -dsuppress-uniques']) +test('T24074', normal, compile, ['-v0 -dsuppress-uniques -ddump-splices']) test('T3177', normal, compile, ['-v0']) test('T3177a', normal, compile_fail, ['-v0']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d055f09970c863bce940dc554f7631f58080fe7a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d055f09970c863bce940dc554f7631f58080fe7a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 10 23:06:48 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 10 Oct 2023 19:06:48 -0400 Subject: [Git][ghc/ghc][master] 3 commits: Aarch64 NCG: Use encoded immediates for literals. Message-ID: <6525d90897364_1b931c699770846501c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 4 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -380,6 +380,114 @@ getSomeReg expr = do Fixed rep reg code -> return (reg, rep, code) +{- Note [Aarch64 immediates] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Aarch64 with it's fixed width instruction encoding uses leftover space for +immediates. +If you want the full rundown consult the arch reference document: +"Arm® Architecture Reference Manual" - "C3.4 Data processing - immediate" + +The gist of it is that different instructions allow for different immediate encodings. +The ones we care about for better code generation are: + +* Simple but potentially repeated bit-patterns for logic instructions. +* 16bit numbers shifted by multiples of 16. +* 12 bit numbers optionally shifted by 12 bits. + +It might seem like the ISA allows for 64bit immediates but this isn't the case. +Rather there are some instruction aliases which allow for large unencoded immediates +which will then be transalted to one of the immediate encodings implicitly. + +For example mov x1, #0x10000 is allowed but will be assembled to movz x1, #0x1, lsl #16 +-} + +-- | Move (wide immediate) +-- Allows for 16bit immediate which can be shifted by 0/16/32/48 bits. +-- Used with MOVZ,MOVN, MOVK +-- See Note [Aarch64 immediates] +getMovWideImm :: Integer -> Width -> Maybe Operand +getMovWideImm n w + -- TODO: Handle sign extension/negatives + | n <= 0 + = Nothing + -- Fits in 16 bits + | sized_n < 2^(16 :: Int) + = Just $ OpImm (ImmInteger truncated) + + -- 0x0000 0000 xxxx 0000 + | trailing_zeros >= 16 && sized_n < 2^(32 :: Int) + = Just $ OpImmShift (ImmInteger $ truncated `shiftR` 16) SLSL 16 + + -- 0x 0000 xxxx 0000 0000 + | trailing_zeros >= 32 && sized_n < 2^(48 :: Int) + = Just $ OpImmShift (ImmInteger $ truncated `shiftR` 32) SLSL 32 + + -- 0x xxxx 0000 0000 0000 + | trailing_zeros >= 48 + = Just $ OpImmShift (ImmInteger $ truncated `shiftR` 48) SLSL 48 + + | otherwise + = Nothing + where + truncated = narrowU w n + sized_n = fromIntegral truncated :: Word64 + trailing_zeros = countTrailingZeros sized_n + +-- | Arithmetic(immediate) +-- Allows for 12bit immediates which can be shifted by 0 or 12 bits. +-- Used with ADD, ADDS, SUB, SUBS, CMP, CMN +-- See Note [Aarch64 immediates] +getArithImm :: Integer -> Width -> Maybe Operand +getArithImm n w + -- TODO: Handle sign extension + | n <= 0 + = Nothing + -- Fits in 16 bits + -- Fits in 12 bits + | sized_n < 2^(12::Int) + = Just $ OpImm (ImmInteger truncated) + + -- 12 bits shifted by 12 places. + | trailing_zeros >= 12 && sized_n < 2^(24::Int) + = Just $ OpImmShift (ImmInteger $ truncated `shiftR` 12) SLSL 12 + + | otherwise + = Nothing + where + sized_n = fromIntegral truncated :: Word64 + truncated = narrowU w n + trailing_zeros = countTrailingZeros sized_n + +-- | Logical (immediate) +-- Allows encoding of some repeated bitpatterns +-- Used with AND, ANDS, EOR, ORR, TST +-- and their aliases which includes at least MOV (bitmask immediate) +-- See Note [Aarch64 immediates] +getBitmaskImm :: Integer -> Width -> Maybe Operand +getBitmaskImm n w + | isAArch64Bitmask (opRegWidth w) truncated = Just $ OpImm (ImmInteger truncated) + | otherwise = Nothing + where + truncated = narrowU w n + +-- | Load/store immediate. +-- Depends on the width of the store to some extent. +isOffsetImm :: Int -> Width -> Bool +isOffsetImm off w + -- 8 bits + sign for unscaled offsets + | -256 <= off, off <= 255 = True + -- Offset using 12-bit positive immediate, scaled by width + -- LDR/STR: imm12: if reg is 32bit: 0 -- 16380 in multiples of 4 + -- LDR/STR: imm12: if reg is 64bit: 0 -- 32760 in multiples of 8 + -- 16-bit: 0 .. 8188, 8-bit: 0 -- 4095 + | 0 <= off, off < 4096 * byte_width, off `mod` byte_width == 0 = True + | otherwise = False + where + byte_width = widthInBytes w + + + + -- TODO OPT: we might be able give getRegister -- a hint, what kind of register we want. getFloatReg :: HasCallStack => CmmExpr -> NatM (Reg, Format, InstrBlock) @@ -502,8 +610,14 @@ getRegister' config plat expr CmmLit lit -> case lit of - -- TODO handle CmmInt 0 specially, use wzr or xzr. - + -- Use wzr xzr for CmmInt 0 if the width matches up, otherwise do a move. + -- TODO: Reenable after https://gitlab.haskell.org/ghc/ghc/-/issues/23632 is fixed. + -- CmmInt 0 W32 -> do + -- let format = intFormat W32 + -- return (Fixed format reg_zero (unitOL $ (COMMENT ((text . show $ expr))) )) + -- CmmInt 0 W64 -> do + -- let format = intFormat W64 + -- return (Fixed format reg_zero (unitOL $ (COMMENT ((text . show $ expr))) )) CmmInt i W8 | i >= 0 -> do return (Any (intFormat W8) (\dst -> unitOL $ annExpr expr (MOV (OpReg W8 dst) (OpImm (ImmInteger (narrowU W8 i)))))) CmmInt i W16 | i >= 0 -> do @@ -518,8 +632,13 @@ getRegister' config plat expr -- Those need the upper bits set. We'd either have to explicitly sign -- or figure out something smarter. Lowered to -- `MOV dst XZR` + CmmInt i w | i >= 0 + , Just imm_op <- getMovWideImm i w -> do + return (Any (intFormat w) (\dst -> unitOL $ annExpr expr (MOVZ (OpReg w dst) imm_op))) + CmmInt i w | isNbitEncodeable 16 i, i >= 0 -> do return (Any (intFormat w) (\dst -> unitOL $ annExpr expr (MOV (OpReg W16 dst) (OpImm (ImmInteger i))))) + CmmInt i w | isNbitEncodeable 32 i, i >= 0 -> do let half0 = fromIntegral (fromIntegral i :: Word16) half1 = fromIntegral (fromIntegral (i `shiftR` 16) :: Word16) @@ -594,7 +713,6 @@ getRegister' config plat expr (op, imm_code) <- litToImm' lit let rep = cmmLitType plat lit format = cmmTypeFormat rep - -- width = typeWidth rep return (Any format (\dst -> imm_code `snocOL` LDR format (OpReg (formatToWidth format) dst) op)) CmmLabelOff lbl off -> do @@ -618,18 +736,11 @@ getRegister' config plat expr -> return (Fixed (cmmTypeFormat (cmmRegType reg)) (getRegisterReg plat reg) nilOL) - CmmRegOff reg off | isNbitEncodeable 12 (fromIntegral off) -> do - getRegister' config plat $ - CmmMachOp (MO_Add width) [CmmReg reg, CmmLit (CmmInt (fromIntegral off) width)] - where width = typeWidth (cmmRegType reg) - - CmmRegOff reg off -> do - (off_r, _off_format, off_code) <- getSomeReg $ CmmLit (CmmInt (fromIntegral off) width) - (reg, _format, code) <- getSomeReg $ CmmReg reg - return $ Any (intFormat width) (\dst -> off_code `appOL` code `snocOL` ADD (OpReg width dst) (OpReg width reg) (OpReg width off_r)) - where width = typeWidth (cmmRegType reg) - - + CmmRegOff reg off -> + -- If we got here we will load the address into a register either way. So we might as well just expand + -- and re-use the existing code path to handle "reg + off". + let !width = cmmRegWidth reg + in getRegister' config plat (CmmMachOp (MO_Add width) [CmmReg reg, CmmLit (CmmInt (fromIntegral off) width)]) -- for MachOps, see GHC.Cmm.MachOp -- For CmmMachOp, see GHC.Cmm.Expr @@ -701,33 +812,25 @@ getRegister' config plat expr -- 0. TODO This should not exist! Rewrite: Reg +- 0 -> Reg CmmMachOp (MO_Add _) [expr'@(CmmReg (CmmGlobal _r)), CmmLit (CmmInt 0 _)] -> getRegister' config plat expr' CmmMachOp (MO_Sub _) [expr'@(CmmReg (CmmGlobal _r)), CmmLit (CmmInt 0 _)] -> getRegister' config plat expr' - -- 1. Compute Reg +/- n directly. - -- For Add/Sub we can directly encode 12bits, or 12bits lsl #12. - CmmMachOp (MO_Add w) [(CmmReg reg), CmmLit (CmmInt n _)] - | n > 0 && n < 4096 -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (ADD (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) - -- TODO: 12bits lsl #12; e.g. lower 12 bits of n are 0; shift n >> 12, and set lsl to #12. - where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) - r' = getRegisterReg plat reg - CmmMachOp (MO_Sub w) [(CmmReg reg), CmmLit (CmmInt n _)] - | n > 0 && n < 4096 -> return $ Any (intFormat w) (\d -> unitOL $ annExpr expr (SUB (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) - -- TODO: 12bits lsl #12; e.g. lower 12 bits of n are 0; shift n >> 12, and set lsl to #12. - where w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) - r' = getRegisterReg plat reg + -- Immediates are handled via `getArithImm` in the generic code path. CmmMachOp (MO_U_Quot w) [x, y] | w == W8 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (UXTB (OpReg w reg_y) (OpReg w reg_y)) `snocOL` (UDIV (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (UXTB (OpReg w reg_y) (OpReg w reg_y)) `snocOL` + (UDIV (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) CmmMachOp (MO_U_Quot w) [x, y] | w == W16 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (UXTH (OpReg w reg_y) (OpReg w reg_y)) `snocOL` (UDIV (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (UXTH (OpReg w reg_y) (OpReg w reg_y)) `snocOL` + (UDIV (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) -- 2. Shifts. x << n, x >> n. - CmmMachOp (MO_Shl w) [x, (CmmLit (CmmInt n _))] | w == W32, 0 <= n, n < 32 -> do - (reg_x, _format_x, code_x) <- getSomeReg x - return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) - CmmMachOp (MO_Shl w) [x, (CmmLit (CmmInt n _))] | w == W64, 0 <= n, n < 64 -> do + CmmMachOp (MO_Shl w) [x, (CmmLit (CmmInt n _))] + | w == W32 || w == W64 + , 0 <= n, n < fromIntegral (widthInBits w) -> do (reg_x, _format_x, code_x) <- getSomeReg x return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) @@ -737,7 +840,8 @@ getRegister' config plat expr CmmMachOp (MO_S_Shr w) [x, y] | w == W8 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (SXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (SXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) CmmMachOp (MO_S_Shr w) [x, (CmmLit (CmmInt n _))] | w == W16, 0 <= n, n < 16 -> do (reg_x, _format_x, code_x) <- getSomeReg x @@ -745,24 +849,23 @@ getRegister' config plat expr CmmMachOp (MO_S_Shr w) [x, y] | w == W16 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (SXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) - - CmmMachOp (MO_S_Shr w) [x, (CmmLit (CmmInt n _))] | w == W32, 0 <= n, n < 32 -> do - (reg_x, _format_x, code_x) <- getSomeReg x - return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (ASR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (SXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) - CmmMachOp (MO_S_Shr w) [x, (CmmLit (CmmInt n _))] | w == W64, 0 <= n, n < 64 -> do + CmmMachOp (MO_S_Shr w) [x, (CmmLit (CmmInt n _))] + | w == W32 || w == W64 + , 0 <= n, n < fromIntegral (widthInBits w) -> do (reg_x, _format_x, code_x) <- getSomeReg x return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (ASR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) - CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] | w == W8, 0 <= n, n < 8 -> do (reg_x, _format_x, code_x) <- getSomeReg x return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (UBFX (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)) (OpImm (ImmInteger (8-n))))) CmmMachOp (MO_U_Shr w) [x, y] | w == W8 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTB (OpReg w reg_x) (OpReg w reg_x)) `snocOL` + (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] | w == W16, 0 <= n, n < 16 -> do (reg_x, _format_x, code_x) <- getSomeReg x @@ -770,13 +873,12 @@ getRegister' config plat expr CmmMachOp (MO_U_Shr w) [x, y] | w == W16 -> do (reg_x, _format_x, code_x) <- getSomeReg x (reg_y, _format_y, code_y) <- getSomeReg y - return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTH (OpReg w reg_x) (OpReg w reg_x)) `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) + return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `snocOL` annExpr expr (UXTH (OpReg w reg_x) (OpReg w reg_x)) + `snocOL` (ASR (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))) - CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] | w == W32, 0 <= n, n < 32 -> do - (reg_x, _format_x, code_x) <- getSomeReg x - return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) - - CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] | w == W64, 0 <= n, n < 64 -> do + CmmMachOp (MO_U_Shr w) [x, (CmmLit (CmmInt n _))] + | w == W32 || w == W64 + , 0 <= n, n < fromIntegral (widthInBits w) -> do (reg_x, _format_x, code_x) <- getSomeReg x return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) @@ -799,17 +901,51 @@ getRegister' config plat expr -- withTempFloatReg w op = OpReg w <$> getNewRegNat (floatFormat w) >>= op -- A "plain" operation. - bitOp w op = do + bitOpImm w op encode_imm = do -- compute x <- x -- compute x <- y -- x, x, x (reg_x, format_x, code_x) <- getSomeReg x - (reg_y, format_y, code_y) <- getSomeReg y - massertPpr (isIntFormat format_x == isIntFormat format_y) $ text "bitOp: incompatible" + (op_y, format_y, code_y) <- case y of + CmmLit (CmmInt n w) + | Just imm_operand_y <- encode_imm n w + -> return (imm_operand_y, intFormat w, nilOL) + _ -> do + (reg_y, format_y, code_y) <- getSomeReg y + return (OpReg w reg_y, format_y, code_y) + massertPpr (isIntFormat format_x == isIntFormat format_y) $ text "bitOpImm: incompatible" return $ Any (intFormat w) (\dst -> code_x `appOL` code_y `appOL` - op (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y)) + op (OpReg w dst) (OpReg w reg_x) op_y) + + -- A (potentially signed) integer operation. + -- In the case of 8- and 16-bit signed arithmetic we must first + -- sign-extend both arguments to 32-bits. + -- See Note [Signed arithmetic on AArch64]. + intOpImm :: Bool -> Width -> (Operand -> Operand -> Operand -> OrdList Instr) -> (Integer -> Width -> Maybe Operand) -> NatM (Register) + intOpImm {- is signed -} True w op _encode_imm = intOp True w op + intOpImm False w op encode_imm = do + -- compute x <- x + -- compute x <- y + -- x, x, x + (reg_x, format_x, code_x) <- getSomeReg x + (op_y, format_y, code_y) <- case y of + CmmLit (CmmInt n w) + | Just imm_operand_y <- encode_imm n w + -> return (imm_operand_y, intFormat w, nilOL) + _ -> do + (reg_y, format_y, code_y) <- getSomeReg y + return (OpReg w reg_y, format_y, code_y) + massertPpr (isIntFormat format_x && isIntFormat format_y) $ text "intOp: non-int" + -- This is the width of the registers on which the operation + -- should be performed. + let w' = opRegWidth w + return $ Any (intFormat w) $ \dst -> + code_x `appOL` + code_y `appOL` + op (OpReg w' dst) (OpReg w' reg_x) (op_y) `appOL` + truncateReg w' w dst -- truncate back to the operand's original width -- A (potentially signed) integer operation. -- In the case of 8- and 16-bit signed arithmetic we must first @@ -855,9 +991,9 @@ getRegister' config plat expr case op of -- Integer operations -- Add/Sub should only be Integer Options. - MO_Add w -> intOp False w (\d x y -> unitOL $ annExpr expr (ADD d x y)) + MO_Add w -> intOpImm False w (\d x y -> unitOL $ annExpr expr (ADD d x y)) getArithImm -- TODO: Handle sub-word case - MO_Sub w -> intOp False w (\d x y -> unitOL $ annExpr expr (SUB d x y)) + MO_Sub w -> intOpImm False w (\d x y -> unitOL $ annExpr expr (SUB d x y)) getArithImm -- Note [CSET] -- ~~~~~~~~~~~ @@ -899,8 +1035,8 @@ getRegister' config plat expr -- N.B. We needn't sign-extend sub-word size (in)equality comparisons -- since we don't care about ordering. - MO_Eq w -> bitOp w (\d x y -> toOL [ CMP x y, CSET d EQ ]) - MO_Ne w -> bitOp w (\d x y -> toOL [ CMP x y, CSET d NE ]) + MO_Eq w -> bitOpImm w (\d x y -> toOL [ CMP x y, CSET d EQ ]) getArithImm + MO_Ne w -> bitOpImm w (\d x y -> toOL [ CMP x y, CSET d NE ]) getArithImm -- Signed multiply/divide MO_Mul w -> intOp True w (\d x y -> unitOL $ MUL d x y) @@ -929,10 +1065,10 @@ getRegister' config plat expr MO_S_Lt w -> intOp True w (\d x y -> toOL [ CMP x y, CSET d SLT ]) -- Unsigned comparisons - MO_U_Ge w -> intOp False w (\d x y -> toOL [ CMP x y, CSET d UGE ]) - MO_U_Le w -> intOp False w (\d x y -> toOL [ CMP x y, CSET d ULE ]) - MO_U_Gt w -> intOp False w (\d x y -> toOL [ CMP x y, CSET d UGT ]) - MO_U_Lt w -> intOp False w (\d x y -> toOL [ CMP x y, CSET d ULT ]) + MO_U_Ge w -> intOpImm False w (\d x y -> toOL [ CMP x y, CSET d UGE ]) getArithImm + MO_U_Le w -> intOpImm False w (\d x y -> toOL [ CMP x y, CSET d ULE ]) getArithImm + MO_U_Gt w -> intOpImm False w (\d x y -> toOL [ CMP x y, CSET d UGT ]) getArithImm + MO_U_Lt w -> intOpImm False w (\d x y -> toOL [ CMP x y, CSET d ULT ]) getArithImm -- Floating point arithmetic MO_F_Add w -> floatOp w (\d x y -> unitOL $ ADD d x y) @@ -955,9 +1091,9 @@ getRegister' config plat expr MO_F_Lt w -> floatCond w (\d x y -> toOL [ CMP x y, CSET d OLT ]) -- x < y <=> y >= x -- Bitwise operations - MO_And w -> bitOp w (\d x y -> unitOL $ AND d x y) - MO_Or w -> bitOp w (\d x y -> unitOL $ ORR d x y) - MO_Xor w -> bitOp w (\d x y -> unitOL $ EOR d x y) + MO_And w -> bitOpImm w (\d x y -> unitOL $ AND d x y) getBitmaskImm + MO_Or w -> bitOpImm w (\d x y -> unitOL $ ORR d x y) getBitmaskImm + MO_Xor w -> bitOpImm w (\d x y -> unitOL $ EOR d x y) getBitmaskImm MO_Shl w -> intOp False w (\d x y -> unitOL $ LSL d x y) MO_U_Shr w -> intOp False w (\d x y -> unitOL $ LSR d x y) MO_S_Shr w -> intOp True w (\d x y -> unitOL $ ASR d x y) @@ -1007,7 +1143,7 @@ getRegister' config plat expr where isNbitEncodeable :: Int -> Integer -> Bool - isNbitEncodeable n i = let shift = n - 1 in (-1 `shiftL` shift) <= i && i < (1 `shiftL` shift) + isNbitEncodeable n_bits i = let shift = n_bits - 1 in (-1 `shiftL` shift) <= i && i < (1 `shiftL` shift) -- N.B. MUL does not set the overflow flag. -- These implementations are based on output from GCC 11. @@ -1146,20 +1282,8 @@ getAmode :: Platform -- OPTIMIZATION WARNING: Addressing modes. -- Addressing options: --- LDUR/STUR: imm9: -256 - 255 -getAmode platform _ (CmmRegOff reg off) | -256 <= off, off <= 255 - = return $ Amode (AddrRegImm reg' off') nilOL - where reg' = getRegisterReg platform reg - off' = ImmInt off --- LDR/STR: imm12: if reg is 32bit: 0 -- 16380 in multiples of 4 -getAmode platform W32 (CmmRegOff reg off) - | 0 <= off, off <= 16380, off `mod` 4 == 0 - = return $ Amode (AddrRegImm reg' off') nilOL - where reg' = getRegisterReg platform reg - off' = ImmInt off --- LDR/STR: imm12: if reg is 64bit: 0 -- 32760 in multiples of 8 -getAmode platform W64 (CmmRegOff reg off) - | 0 <= off, off <= 32760, off `mod` 8 == 0 +getAmode platform w (CmmRegOff reg off) + | isOffsetImm off w = return $ Amode (AddrRegImm reg' off') nilOL where reg' = getRegisterReg platform reg off' = ImmInt off @@ -1168,15 +1292,15 @@ getAmode platform W64 (CmmRegOff reg off) -- CmmStore (CmmMachOp (MO_Add w) [CmmLoad expr, CmmLit (CmmInt n w')]) (expr2) -- E.g. a CmmStoreOff really. This can be translated to `str $expr2, [$expr, #n ] -- for `n` in range. -getAmode _platform _ (CmmMachOp (MO_Add _w) [expr, CmmLit (CmmInt off _w')]) - | -256 <= off, off <= 255 +getAmode _platform w (CmmMachOp (MO_Add _w) [expr, CmmLit (CmmInt off _w')]) + | isOffsetImm (fromIntegral off) w = do (reg, _format, code) <- getSomeReg expr return $ Amode (AddrRegImm reg (ImmInteger off)) code -getAmode _platform _ (CmmMachOp (MO_Sub _w) [expr, CmmLit (CmmInt off _w')]) - | -256 <= -off, -off <= 255 +getAmode _platform w (CmmMachOp (MO_Sub _w) [expr, CmmLit (CmmInt off _w')]) + | isOffsetImm (fromIntegral $ -off) w = do (reg, _format, code) <- getSomeReg expr - return $ Amode (AddrRegImm reg (ImmInteger (-off))) code + return $ Amode (AddrRegImm reg (ImmInteger $ -off)) code -- Generic case getAmode _platform _ expr ===================================== compiler/GHC/CmmToAsm/AArch64/Instr.hs ===================================== @@ -110,6 +110,7 @@ regUsageOfInstr platform instr = case instr of LSR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) MOV dst src -> usage (regOp src, regOp dst) MOVK dst src -> usage (regOp src, regOp dst) + MOVZ dst src -> usage (regOp src, regOp dst) MVN dst src -> usage (regOp src, regOp dst) ORR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) ROR dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst) @@ -251,6 +252,7 @@ patchRegsOfInstr instr env = case instr of LSR o1 o2 o3 -> LSR (patchOp o1) (patchOp o2) (patchOp o3) MOV o1 o2 -> MOV (patchOp o1) (patchOp o2) MOVK o1 o2 -> MOVK (patchOp o1) (patchOp o2) + MOVZ o1 o2 -> MOVZ (patchOp o1) (patchOp o2) MVN o1 o2 -> MVN (patchOp o1) (patchOp o2) ORR o1 o2 o3 -> ORR (patchOp o1) (patchOp o2) (patchOp o3) ROR o1 o2 o3 -> ROR (patchOp o1) (patchOp o2) (patchOp o3) @@ -381,9 +383,8 @@ mkSpillInstr config reg delta slot = where a .&~. b = a .&. (complement b) - fmt = case reg of - RegReal (RealRegSingle n) | n < 32 -> II64 - _ -> FF64 + fmt = fmtOfRealReg (case reg of { RegReal r -> r; _ -> panic "Expected real reg"}) + mkIp0SpillAddr imm = ANN (text "Spill: IP0 <- SP + " <> int imm) $ ADD ip0 sp (OpImm (ImmInt imm)) mkStrSp imm = ANN (text "Spill@" <> int (off - delta)) $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt imm))) mkStrIp0 imm = ANN (text "Spill@" <> int (off - delta)) $ STR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 16) (ImmInt imm))) @@ -408,9 +409,7 @@ mkLoadInstr config reg delta slot = where a .&~. b = a .&. (complement b) - fmt = case reg of - RegReal (RealRegSingle n) | n < 32 -> II64 - _ -> FF64 + fmt = fmtOfRealReg (case reg of { RegReal r -> r; _ -> panic "Expected real reg"}) mkIp0SpillAddr imm = ANN (text "Reload: IP0 <- SP + " <> int imm) $ ADD ip0 sp (OpImm (ImmInt imm)) mkLdrSp imm = ANN (text "Reload@" <> int (off - delta)) $ LDR fmt (OpReg W64 reg) (OpAddr (AddrRegImm (regSingle 31) (ImmInt imm))) @@ -619,7 +618,7 @@ data Instr | MOV Operand Operand -- rd = rn or rd = #i | MOVK Operand Operand -- | MOVN Operand Operand - -- | MOVZ Operand Operand + | MOVZ Operand Operand | MVN Operand Operand -- rd = ~rn | ORN Operand Operand Operand -- rd = rn | ~op2 | ORR Operand Operand Operand -- rd = rn | op2 @@ -708,6 +707,7 @@ instrCon i = LSR{} -> "LSR" MOV{} -> "MOV" MOVK{} -> "MOVK" + MOVZ{} -> "MOVZ" MVN{} -> "MVN" ORN{} -> "ORN" ORR{} -> "ORR" @@ -783,6 +783,9 @@ wzr = OpReg W32 (RegReal (RealRegSingle (-1))) sp = OpReg W64 (RegReal (RealRegSingle 31)) ip0 = OpReg W64 (RegReal (RealRegSingle 16)) +reg_zero :: Reg +reg_zero = RegReal (RealRegSingle (-1)) + _x :: Int -> Operand _x i = OpReg W64 (RegReal (RealRegSingle i)) x0, x1, x2, x3, x4, x5, x6, x7 :: Operand ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -418,6 +418,7 @@ pprInstr platform instr = case instr of | isFloatOp o1 || isFloatOp o2 -> op2 (text "\tfmov") o1 o2 | otherwise -> op2 (text "\tmov") o1 o2 MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 + MOVZ o1 o2 -> op2 (text "\tmovz") o1 o2 MVN o1 o2 -> op2 (text "\tmvn") o1 o2 ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 ===================================== compiler/GHC/CmmToAsm/AArch64/Regs.hs ===================================== @@ -77,6 +77,8 @@ litToImm (CmmInt i w) = ImmInteger (narrowS w i) -- narrow to the width: a CmmInt might be out of -- range, but we assume that ImmInteger only contains -- in-range values. A signed value should be fine here. + -- AK: We do call this with out of range values, however + -- it just truncates as we would expect. litToImm (CmmFloat f W32) = ImmFloat f litToImm (CmmFloat f W64) = ImmDouble f litToImm (CmmLabel l) = ImmCLbl l @@ -147,6 +149,13 @@ classOfRealReg (RealRegSingle i) | i < 32 = RcInteger | otherwise = RcDouble +fmtOfRealReg :: RealReg -> Format +fmtOfRealReg real_reg = + case classOfRealReg real_reg of + RcInteger -> II64 + RcDouble -> FF64 + RcFloat -> panic "No float regs on arm" + regDotColor :: RealReg -> SDoc regDotColor reg = case classOfRealReg reg of View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d055f09970c863bce940dc554f7631f58080fe7a...1b213d336bcb0e66c5773b6015924b57a3a59de5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d055f09970c863bce940dc554f7631f58080fe7a...1b213d336bcb0e66c5773b6015924b57a3a59de5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 08:00:49 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 11 Oct 2023 04:00:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/23944 Message-ID: <6526563170480_1b931c76b3ea186861e8@gitlab.mail> Zubin pushed new branch wip/23944 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/23944 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 11:35:57 2023 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 11 Oct 2023 07:35:57 -0400 Subject: [Git][ghc/ghc][wip/23944] 2 commits: testsuite: add test for #23944 Message-ID: <6526889dd8dc9_1b931c7c12aea47229bd@gitlab.mail> Zubin pushed to branch wip/23944 at Glasgow Haskell Compiler / GHC Commits: 6e77b703 by Zubin Duggal at 2023-10-11T17:05:47+05:30 testsuite: add test for #23944 - - - - - 42d5eda9 by Zubin Duggal at 2023-10-11T17:05:47+05:30 driver: Only run a dynamic-too pipeline if object files are going to be generated Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state when writing simple interface" when dynamic-too is enabled We could remove the panic and just write the interface even if the state is `DT_Dyn`, but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled. Fixes #23944. - - - - - 5 changed files: - compiler/GHC/Driver/Pipeline.hs - + testsuite/tests/driver/T23944.hs - + testsuite/tests/driver/T23944.stderr - + testsuite/tests/driver/T23944A.hs - testsuite/tests/driver/all.T Changes: ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -788,7 +788,9 @@ hscBackendPipeline pipe_env hsc_env mod_sum result = if backendGeneratesCode (backend (hsc_dflags hsc_env)) then do res <- hscGenBackendPipeline pipe_env hsc_env mod_sum result - when (gopt Opt_BuildDynamicToo (hsc_dflags hsc_env)) $ do + -- Only run dynamic-too if the backend generates object files, otherwise there is no point + -- This is the same check as in runHscBackendPhase + when (gopt Opt_BuildDynamicToo (hsc_dflags hsc_env) && backendWritesFiles (backend (hsc_dflags hsc_env)) ) $ do let dflags' = setDynamicNow (hsc_dflags hsc_env) -- set "dynamicNow" () <$ hscGenBackendPipeline pipe_env (hscSetFlags dflags' hsc_env) mod_sum result return res ===================================== testsuite/tests/driver/T23944.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23944 where +import T23944A + +$(foo) ===================================== testsuite/tests/driver/T23944.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling T23944A ( T23944A.hs, interpreted ) +[2 of 2] Compiling T23944 ( T23944.hs, nothing ) ===================================== testsuite/tests/driver/T23944A.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23944A where + +import Language.Haskell.TH + +foo :: DecsQ +foo = pure [] ===================================== testsuite/tests/driver/all.T ===================================== @@ -318,3 +318,4 @@ test('T22669', req_interp, makefile_test, []) test('T23339', req_c, makefile_test, []) test('T23339B', [extra_files(['T23339.hs']), req_c], makefile_test, []) test('T23613', normal, compile_and_run, ['-this-unit-id=foo']) +test('T23944', [unless(have_dynamic(), skip), extra_files(['T23944A.hs'])], multimod_compile, ['T23944 T23944A', '-fprefer-byte-code -fbyte-code -fno-code -dynamic-too -fwrite-interface']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c5212e2f1126eab2f610d827d26d474db16436fa...42d5eda96609e0c2fcda5ca834bd965cf801092a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c5212e2f1126eab2f610d827d26d474db16436fa...42d5eda96609e0c2fcda5ca834bd965cf801092a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 12:58:58 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Wed, 11 Oct 2023 08:58:58 -0400 Subject: [Git][ghc/ghc][wip/angerman/no-section-attr-for-text] 27 commits: Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. Message-ID: <65269c1214351_1b931c7df0cdb47443e8@gitlab.mail> Moritz Angermann pushed to branch wip/angerman/no-section-attr-for-text at Glasgow Haskell Compiler / GHC Commits: e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 7c254f73 by Moritz Angermann at 2023-10-11T12:58:54+00:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Types.hs - configure.ac - docs/users_guide/using-optimisation.rst - hadrian/doc/testsuite.md - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Builders/Cabal.hs - m4/find_merge_objects.m4 - m4/fp_cc_supports_target.m4 - m4/fp_gcc_supports_no_pie.m4 - + m4/fp_prog_cc_linker_target.m4 - m4/ghc_toolchain.m4 - + testsuite/tests/simplCore/should_compile/T21917.hs - + testsuite/tests/simplCore/should_compile/T21917.stderr - testsuite/tests/simplCore/should_compile/all.T - + testsuite/tests/th/T24074.hs - + testsuite/tests/th/T24074.stderr - testsuite/tests/th/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1ddaf1cfd62c67f1c06a5990fcb7b6943e45edcb...7c254f73ef03bfb7a6cb4d0f40c07f37386dcc0e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1ddaf1cfd62c67f1c06a5990fcb7b6943e45edcb...7c254f73ef03bfb7a6cb4d0f40c07f37386dcc0e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 14:17:02 2023 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Wed, 11 Oct 2023 10:17:02 -0400 Subject: [Git][ghc/ghc][wip/or-pats] refactor Message-ID: <6526ae5e26e71_1b931c7fc4b1287567c@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 57b67319 by David Knothe at 2023-10-11T16:16:52+02:00 refactor - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -3113,11 +3113,9 @@ texp :: { ECP } mkHsViewPatPV (comb2 $1 $>) $1 $3 [mu AnnRarrow $2] } orpats :: { [LPat GhcPs] } --- : texp {% do : exp %shift {% do { pat1 <- (checkPattern <=< runPV) (unECP $1) ; return [pat1] }} --- | texp '|' orpats {% do | exp ';' orpats {% do { pat1 <- (checkPattern <=< runPV) (unECP $1) ; pat2 <- addTrailingSemiA pat1 (getLoc $2) @@ -3388,14 +3386,15 @@ pat_syn_pat :: { LPat GhcPs } pat_syn_pat : exp {% (checkPattern <=< runPV) (unECP $1) } pat :: { LPat GhcPs } -pat : pat_syn_pat { $1 } - | pat ';' orpats {% - do { let srcSpan = comb2 (getLocA $1) (getLocA $ last $3) - ; cs <- getCommentsFor srcSpan - ; pat1 <- addTrailingSemiA $1 (getLoc $2) - ; let orpat = sL (noAnnSrcSpan srcSpan) $ OrPat (EpAnn (spanAsAnchor srcSpan) [] cs) (pat1:$3) - ; _ <- hintOrPats orpat - ; return $ orpat }} +pat : orpats {% case $1 of + [pat] -> return pat + _ -> do + let srcSpan = getLocA $1 + ; cs <- getCommentsFor srcSpan + ; let orpat = sL (noAnnSrcSpan srcSpan) $ OrPat (EpAnn (spanAsAnchor srcSpan) [] cs) $1 + ; _ <- hintOrPats orpat + ; return orpat }} + -- 'pats1' does the same thing as 'pat', but returns it as a singleton -- list so that it can be used with a parameterized production rule View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/57b67319bc750d2b8fd31ad95ae90a20ba88947d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/57b67319bc750d2b8fd31ad95ae90a20ba88947d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 14:42:05 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 11 Oct 2023 10:42:05 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 31 commits: hadrian: Add ghcToolchain to tool args list Message-ID: <6526b43dea7fe_1b931c8054a8f07732d5@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 26b7e1eb by John Ericson at 2023-10-11T10:41:26-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 8d717a5d by John Ericson at 2023-10-11T10:41:26-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 46dc5aae by John Ericson at 2023-10-11T10:41:26-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - f151ac96 by John Ericson at 2023-10-11T10:41:26-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 1974f6af by John Ericson at 2023-10-11T10:41:27-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - 96f85149 by Sylvain Henry at 2023-10-11T10:41:38-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 30 changed files: - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/SysTools/Process.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Types.hs - configure.ac - hadrian/doc/testsuite.md - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Builders/Cabal.hs - m4/find_merge_objects.m4 - m4/fp_cc_supports_target.m4 - m4/fp_check_pthreads.m4 - m4/fp_gcc_supports_no_pie.m4 - + m4/fp_prog_cc_linker_target.m4 - m4/ghc_toolchain.m4 - rts/configure.ac - + testsuite/tests/th/T24074.hs - + testsuite/tests/th/T24074.stderr - testsuite/tests/th/all.T - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/ghc-toolchain.cabal - + utils/ghc-toolchain/src/GHC/Toolchain/NormaliseTriple.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36a260492ffea091ee3ace7c78b0c824ab54e9ec...96f85149d5e596dee9d188a2c0e34f825b1ce60d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36a260492ffea091ee3ace7c78b0c824ab54e9ec...96f85149d5e596dee9d188a2c0e34f825b1ce60d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 14:56:13 2023 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Wed, 11 Oct 2023 10:56:13 -0400 Subject: [Git][ghc/ghc][wip/or-pats] refactor Message-ID: <6526b78d7a4d5_1b931c80bf46387777c9@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 5924af3d by David Knothe at 2023-10-11T16:56:04+02:00 refactor - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -3113,11 +3113,9 @@ texp :: { ECP } mkHsViewPatPV (comb2 $1 $>) $1 $3 [mu AnnRarrow $2] } orpats :: { [LPat GhcPs] } --- : texp {% do : exp %shift {% do { pat1 <- (checkPattern <=< runPV) (unECP $1) ; return [pat1] }} --- | texp '|' orpats {% do | exp ';' orpats {% do { pat1 <- (checkPattern <=< runPV) (unECP $1) ; pat2 <- addTrailingSemiA pat1 (getLoc $2) @@ -3388,14 +3386,15 @@ pat_syn_pat :: { LPat GhcPs } pat_syn_pat : exp {% (checkPattern <=< runPV) (unECP $1) } pat :: { LPat GhcPs } -pat : pat_syn_pat { $1 } - | pat ';' orpats {% - do { let srcSpan = comb2 (getLocA $1) (getLocA $ last $3) - ; cs <- getCommentsFor srcSpan - ; pat1 <- addTrailingSemiA $1 (getLoc $2) - ; let orpat = sL (noAnnSrcSpan srcSpan) $ OrPat (EpAnn (spanAsAnchor srcSpan) [] cs) (pat1:$3) - ; _ <- hintOrPats orpat - ; return $ orpat }} +pat : orpats {% case $1 of + [pat] -> return pat + _ -> do { + let srcSpan = getLocA $1 + ; cs <- getCommentsFor srcSpan + ; let orpat = sL (noAnnSrcSpan srcSpan) $ OrPat (EpAnn (spanAsAnchor srcSpan) [] cs) $1 + ; _ <- hintOrPats orpat + ; return orpat }} + -- 'pats1' does the same thing as 'pat', but returns it as a singleton -- list so that it can be used with a parameterized production rule View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5924af3de63d8991b9128e94ae6535bfb20dcaca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5924af3de63d8991b9128e94ae6535bfb20dcaca You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 15:37:14 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Wed, 11 Oct 2023 11:37:14 -0400 Subject: [Git][ghc/ghc][wip/test-mingwex-regression] 51 commits: Simplify and correct nasty case in coercion opt Message-ID: <6526c12a1e349_1b931c81ccd9f07822ce@gitlab.mail> John Ericson pushed to branch wip/test-mingwex-regression at Glasgow Haskell Compiler / GHC Commits: bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 7868012a by John Ericson at 2023-10-11T11:36:55-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - 30 changed files: - .gitignore - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Debug.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Name/Reader.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a1fbbabe69afa65fad6c2369450986fd6710cb3...7868012a509a06e066195e02db0cc8fd2a28b62f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a1fbbabe69afa65fad6c2369450986fd6710cb3...7868012a509a06e066195e02db0cc8fd2a28b62f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 15:38:41 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Wed, 11 Oct 2023 11:38:41 -0400 Subject: [Git][ghc/ghc][wip/no-mingwex-in-configure] 119 commits: Use correct FunTyFlag in adjustJoinPointType Message-ID: <6526c1812109_1b931c81c711787832ae@gitlab.mail> John Ericson pushed to branch wip/no-mingwex-in-configure at Glasgow Haskell Compiler / GHC Commits: 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 7868012a by John Ericson at 2023-10-11T11:36:55-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - 2a5e2273 by John Ericson at 2023-10-11T11:37:38-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Class.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Env.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0d5f48ddb4aa12b88181ed0350f3a853ff5ecd28...2a5e2273a52037b152310dee4f673af8c70cd919 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0d5f48ddb4aa12b88181ed0350f3a853ff5ecd28...2a5e2273a52037b152310dee4f673af8c70cd919 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 17:32:52 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 11 Oct 2023 13:32:52 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: RTS configure: Move over mem management checks Message-ID: <6526dc44cc36f_1b931c84bf73fc81134f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 96862350 by John Ericson at 2023-10-11T13:32:01-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 6f66c263 by John Ericson at 2023-10-11T13:32:01-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 93abd966 by John Ericson at 2023-10-11T13:32:02-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 876555ef by John Ericson at 2023-10-11T13:32:02-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - f8ddb0b4 by John Ericson at 2023-10-11T13:32:02-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - 334f3275 by Moritz Angermann at 2023-10-11T13:32:03-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - bc874842 by Sylvain Henry at 2023-10-11T13:32:05-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 6 changed files: - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/SysTools/Process.hs - compiler/GHC/SysTools/Tasks.hs - configure.ac - m4/fp_check_pthreads.m4 - rts/configure.ac Changes: ===================================== compiler/GHC/CmmToAsm/Ppr.hs ===================================== @@ -246,9 +246,10 @@ pprGNUSectionHeader config t suffix = panic "PprBase.pprGNUSectionHeader: unknown section type" flags = case t of Text - | OSMinGW32 <- platformOS platform + | OSMinGW32 <- platformOS platform, splitSections -> text ",\"xr\"" - | otherwise -> text ",\"ax\"," <> sectionType platform "progbits" + | splitSections + -> text ",\"ax\"," <> sectionType platform "progbits" CString | OSMinGW32 <- platformOS platform -> empty ===================================== compiler/GHC/SysTools/Process.hs ===================================== @@ -10,14 +10,14 @@ module GHC.SysTools.Process where import GHC.Prelude -import GHC.Driver.DynFlags - import GHC.Utils.Exception import GHC.Utils.Error import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Misc import GHC.Utils.Logger +import GHC.Utils.TmpFs +import GHC.Utils.CliOption import GHC.Types.SrcLoc ( SrcLoc, mkSrcLoc, mkSrcSpan ) import GHC.Data.FastString @@ -32,7 +32,6 @@ import System.IO import System.IO.Error as IO import System.Process -import GHC.Utils.TmpFs -- | Enable process jobs support on Windows if it can be expected to work (e.g. -- @process >= 1.6.9.0@). @@ -153,14 +152,14 @@ runSomething logger phase_name pgm args = runSomethingResponseFile :: Logger -> TmpFs - -> DynFlags + -> TempDir -> (String->String) -> String -> String -> [Option] -> Maybe [(String,String)] -> IO () -runSomethingResponseFile logger tmpfs dflags filter_fn phase_name pgm args mb_env = +runSomethingResponseFile logger tmpfs tmp_dir filter_fn phase_name pgm args mb_env = runSomethingWith logger phase_name pgm args $ \real_args -> do fp <- getResponseFile real_args let args = ['@':fp] @@ -168,7 +167,7 @@ runSomethingResponseFile logger tmpfs dflags filter_fn phase_name pgm args mb_en return (r,()) where getResponseFile args = do - fp <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "rsp" + fp <- newTempName logger tmpfs tmp_dir TFL_CurrentModule "rsp" withFile fp WriteMode $ \h -> do hSetEncoding h utf8 hPutStr h $ unlines $ map escape args ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -117,7 +117,7 @@ runCpp logger tmpfs dflags args = traceSystoolCommand logger "cpp" $ do userOpts_c = map Option $ getOpts dflags opt_c args2 = args0 ++ args ++ userOpts_c mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags cc_filter "C pre-processor" p + runSomethingResponseFile logger tmpfs (tmpDir dflags) cc_filter "C pre-processor" p args2 mb_env -- | Run the Haskell C preprocessor. @@ -148,7 +148,7 @@ runCc mLanguage logger tmpfs dflags args = traceSystoolCommand logger "cc" $ do -- We take care to pass -optc flags in args1 last to ensure that the -- user can override flags passed by GHC. See #14452. mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags cc_filter dbgstring prog args2 + runSomethingResponseFile logger tmpfs (tmpDir dflags) cc_filter dbgstring prog args2 mb_env where -- force the C compiler to interpret this file as C when @@ -275,7 +275,7 @@ runLink logger tmpfs dflags args = traceSystoolCommand logger "linker" $ do optl_args = map Option (getOpts dflags opt_l) args2 = args0 ++ args ++ optl_args mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags ld_filter "Linker" p args2 mb_env + runSomethingResponseFile logger tmpfs (tmpDir dflags) ld_filter "Linker" p args2 mb_env where ld_filter = case (platformOS (targetPlatform dflags)) of OSSolaris2 -> sunos_ld_filter @@ -339,7 +339,7 @@ runMergeObjects logger tmpfs dflags args = if toolSettings_mergeObjsSupportsResponseFiles (toolSettings dflags) then do mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags id "Merge objects" p args2 mb_env + runSomethingResponseFile logger tmpfs (tmpDir dflags) id "Merge objects" p args2 mb_env else do runSomething logger "Merge objects" p args2 ===================================== configure.ac ===================================== @@ -1038,81 +1038,8 @@ AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])], [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) ]) -FP_CHECK_PTHREADS - -dnl ** check for eventfd which is needed by the I/O manager -AC_CHECK_HEADERS([sys/eventfd.h]) -AC_CHECK_FUNCS([eventfd]) - -AC_CHECK_FUNCS([getpid getuid raise]) - -dnl ** Check for __thread support in the compiler -AC_MSG_CHECKING(for __thread support) -AC_COMPILE_IFELSE( - [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ], - [ - AC_MSG_RESULT(yes) - AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported]) - ], - [ - AC_MSG_RESULT(no) - AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported]) - ]) - -dnl large address space support (see rts/include/rts/storage/MBlock.h) -dnl -dnl Darwin has vm_allocate/vm_protect -dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED) -dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE -dnl (They also have MADV_DONTNEED, but it means something else!) -dnl -dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however -dnl it counts page-table space as committed memory, and so quickly -dnl runs out of paging file when we have multiple processes reserving -dnl 1TB of address space, we get the following error: -dnl VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete. -dnl - -AC_ARG_ENABLE(large-address-space, - [AS_HELP_STRING([--enable-large-address-space], - [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])], - EnableLargeAddressSpace=$enableval, - EnableLargeAddressSpace=yes -) - -use_large_address_space=no -if test "$ac_cv_sizeof_void_p" -eq 8 ; then - if test "x$EnableLargeAddressSpace" = "xyes" ; then - if test "$ghc_host_os" = "darwin" ; then - use_large_address_space=yes - elif test "$ghc_host_os" = "openbsd" ; then - # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE. - # The flag MAP_NORESERVE is supported for source compatibility reasons, - # but is completely ignored by OS mmap - use_large_address_space=no - elif test "$ghc_host_os" = "mingw32" ; then - # as of Windows 8.1/Server 2012 windows does no longer allocate the page - # tabe for reserved memory eagerly. So we are now free to use LAS there too. - use_large_address_space=yes - else - AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[], - [ - #include - #include - #include - #include - ]) - if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" && - test "$ac_cv_have_decl_MADV_FREE" = "yes" || - test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then - use_large_address_space=yes - fi - fi - fi -fi -if test "$use_large_address_space" = "yes" ; then - AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support]) -fi +FP_CHECK_PTHREAD_LIB +AC_SUBST([UseLibpthread]) GHC_ADJUSTORS_METHOD([Target]) AC_SUBST([UseLibffiForAdjustors]) ===================================== m4/fp_check_pthreads.m4 ===================================== @@ -1,7 +1,10 @@ -dnl FP_CHECK_PTHREADS -dnl ---------------------------------- -dnl Check various aspects of the platform's pthreads support -AC_DEFUN([FP_CHECK_PTHREADS], +# FP_CHECK_PTHREAD_LIB +# ---------------------------------- +# Check whether -lpthread is needed for pthread. +# +# Sets variables: +# - UseLibpthread: [YES|NO] +AC_DEFUN([FP_CHECK_PTHREAD_LIB], [ dnl Some platforms (e.g. Android's Bionic) have pthreads support available dnl without linking against libpthread. Check whether -lpthread is necessary @@ -12,25 +15,28 @@ AC_DEFUN([FP_CHECK_PTHREADS], AC_CHECK_FUNC(pthread_create, [ AC_MSG_RESULT(no) - AC_SUBST([UseLibpthread],[NO]) - need_lpthread=0 + UseLibpthread=NO ], [ AC_CHECK_LIB(pthread, pthread_create, [ AC_MSG_RESULT(yes) - AC_SUBST([UseLibpthread],[YES]) - need_lpthread=1 + UseLibpthread=YES ], [ - AC_SUBST([UseLibpthread],[NO]) AC_MSG_RESULT([no pthreads support found.]) - need_lpthread=0 + UseLibpthread=NO ]) ]) - AC_DEFINE_UNQUOTED([NEED_PTHREAD_LIB], [$need_lpthread], - [Define 1 if we need to link code using pthreads with -lpthread]) +]) +# FP_CHECK_PTHREAD_FUNCS +# ---------------------------------- +# Check various aspects of the platform's pthreads support +# +# `AC_DEFINE`s various C `HAVE_*` macros. +AC_DEFUN([FP_CHECK_PTHREAD_FUNCS], +[ dnl Setting thread names dnl ~~~~~~~~~~~~~~~~~~~~ dnl The portability situation here is complicated: ===================================== rts/configure.ac ===================================== @@ -33,6 +33,83 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host]) FPTOOLS_SET_PLATFORM_VARS([host], [Host]) FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) +FP_CHECK_PTHREAD_FUNCS + +dnl ** check for eventfd which is needed by the I/O manager +AC_CHECK_HEADERS([sys/eventfd.h]) +AC_CHECK_FUNCS([eventfd]) + +AC_CHECK_FUNCS([getpid getuid raise]) + +dnl ** Check for __thread support in the compiler +AC_MSG_CHECKING(for __thread support) +AC_COMPILE_IFELSE( + [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported]) + ], + [ + AC_MSG_RESULT(no) + AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported]) + ]) + +dnl large address space support (see rts/include/rts/storage/MBlock.h) +dnl +dnl Darwin has vm_allocate/vm_protect +dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED) +dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE +dnl (They also have MADV_DONTNEED, but it means something else!) +dnl +dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however +dnl it counts page-table space as committed memory, and so quickly +dnl runs out of paging file when we have multiple processes reserving +dnl 1TB of address space, we get the following error: +dnl VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete. +dnl + +AC_ARG_ENABLE(large-address-space, + [AS_HELP_STRING([--enable-large-address-space], + [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])], + EnableLargeAddressSpace=$enableval, + EnableLargeAddressSpace=yes +) + +use_large_address_space=no +AC_CHECK_SIZEOF([void *]) +if test "$ac_cv_sizeof_void_p" -eq 8 ; then + if test "x$EnableLargeAddressSpace" = "xyes" ; then + if test "$ghc_host_os" = "darwin" ; then + use_large_address_space=yes + elif test "$ghc_host_os" = "openbsd" ; then + # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE. + # The flag MAP_NORESERVE is supported for source compatibility reasons, + # but is completely ignored by OS mmap + use_large_address_space=no + elif test "$ghc_host_os" = "mingw32" ; then + # as of Windows 8.1/Server 2012 windows does no longer allocate the page + # tabe for reserved memory eagerly. So we are now free to use LAS there too. + use_large_address_space=yes + else + AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[], + [ + #include + #include + #include + #include + ]) + if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" && + test "$ac_cv_have_decl_MADV_FREE" = "yes" || + test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then + use_large_address_space=yes + fi + fi + fi +fi +if test "$use_large_address_space" = "yes" ; then + AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support]) +fi + dnl ** Use MMAP in the runtime linker? dnl -------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96f85149d5e596dee9d188a2c0e34f825b1ce60d...bc87484224c08772bc78a0ba774c95a9665f1c3f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96f85149d5e596dee9d188a2c0e34f825b1ce60d...bc87484224c08772bc78a0ba774c95a9665f1c3f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 20:02:41 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 11 Oct 2023 16:02:41 -0400 Subject: [Git][ghc/ghc][master] 4 commits: RTS configure: Move over mem management checks Message-ID: <6526ff61c5581_1b931c885b82f881985d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 2 changed files: - configure.ac - rts/configure.ac Changes: ===================================== configure.ac ===================================== @@ -1040,80 +1040,6 @@ AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])], FP_CHECK_PTHREADS -dnl ** check for eventfd which is needed by the I/O manager -AC_CHECK_HEADERS([sys/eventfd.h]) -AC_CHECK_FUNCS([eventfd]) - -AC_CHECK_FUNCS([getpid getuid raise]) - -dnl ** Check for __thread support in the compiler -AC_MSG_CHECKING(for __thread support) -AC_COMPILE_IFELSE( - [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ], - [ - AC_MSG_RESULT(yes) - AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported]) - ], - [ - AC_MSG_RESULT(no) - AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported]) - ]) - -dnl large address space support (see rts/include/rts/storage/MBlock.h) -dnl -dnl Darwin has vm_allocate/vm_protect -dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED) -dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE -dnl (They also have MADV_DONTNEED, but it means something else!) -dnl -dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however -dnl it counts page-table space as committed memory, and so quickly -dnl runs out of paging file when we have multiple processes reserving -dnl 1TB of address space, we get the following error: -dnl VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete. -dnl - -AC_ARG_ENABLE(large-address-space, - [AS_HELP_STRING([--enable-large-address-space], - [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])], - EnableLargeAddressSpace=$enableval, - EnableLargeAddressSpace=yes -) - -use_large_address_space=no -if test "$ac_cv_sizeof_void_p" -eq 8 ; then - if test "x$EnableLargeAddressSpace" = "xyes" ; then - if test "$ghc_host_os" = "darwin" ; then - use_large_address_space=yes - elif test "$ghc_host_os" = "openbsd" ; then - # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE. - # The flag MAP_NORESERVE is supported for source compatibility reasons, - # but is completely ignored by OS mmap - use_large_address_space=no - elif test "$ghc_host_os" = "mingw32" ; then - # as of Windows 8.1/Server 2012 windows does no longer allocate the page - # tabe for reserved memory eagerly. So we are now free to use LAS there too. - use_large_address_space=yes - else - AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[], - [ - #include - #include - #include - #include - ]) - if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" && - test "$ac_cv_have_decl_MADV_FREE" = "yes" || - test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then - use_large_address_space=yes - fi - fi - fi -fi -if test "$use_large_address_space" = "yes" ; then - AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support]) -fi - GHC_ADJUSTORS_METHOD([Target]) AC_SUBST([UseLibffiForAdjustors]) ===================================== rts/configure.ac ===================================== @@ -33,6 +33,81 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host]) FPTOOLS_SET_PLATFORM_VARS([host], [Host]) FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) +dnl ** check for eventfd which is needed by the I/O manager +AC_CHECK_HEADERS([sys/eventfd.h]) +AC_CHECK_FUNCS([eventfd]) + +AC_CHECK_FUNCS([getpid getuid raise]) + +dnl ** Check for __thread support in the compiler +AC_MSG_CHECKING(for __thread support) +AC_COMPILE_IFELSE( + [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported]) + ], + [ + AC_MSG_RESULT(no) + AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported]) + ]) + +dnl large address space support (see rts/include/rts/storage/MBlock.h) +dnl +dnl Darwin has vm_allocate/vm_protect +dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED) +dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE +dnl (They also have MADV_DONTNEED, but it means something else!) +dnl +dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however +dnl it counts page-table space as committed memory, and so quickly +dnl runs out of paging file when we have multiple processes reserving +dnl 1TB of address space, we get the following error: +dnl VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete. +dnl + +AC_ARG_ENABLE(large-address-space, + [AS_HELP_STRING([--enable-large-address-space], + [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])], + EnableLargeAddressSpace=$enableval, + EnableLargeAddressSpace=yes +) + +use_large_address_space=no +AC_CHECK_SIZEOF([void *]) +if test "$ac_cv_sizeof_void_p" -eq 8 ; then + if test "x$EnableLargeAddressSpace" = "xyes" ; then + if test "$ghc_host_os" = "darwin" ; then + use_large_address_space=yes + elif test "$ghc_host_os" = "openbsd" ; then + # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE. + # The flag MAP_NORESERVE is supported for source compatibility reasons, + # but is completely ignored by OS mmap + use_large_address_space=no + elif test "$ghc_host_os" = "mingw32" ; then + # as of Windows 8.1/Server 2012 windows does no longer allocate the page + # tabe for reserved memory eagerly. So we are now free to use LAS there too. + use_large_address_space=yes + else + AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[], + [ + #include + #include + #include + #include + ]) + if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" && + test "$ac_cv_have_decl_MADV_FREE" = "yes" || + test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then + use_large_address_space=yes + fi + fi + fi +fi +if test "$use_large_address_space" = "yes" ; then + AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support]) +fi + dnl ** Use MMAP in the runtime linker? dnl -------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1b213d336bcb0e66c5773b6015924b57a3a59de5...809e7c2dfb4c7aba7d8ed5297b0e9472a591beea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1b213d336bcb0e66c5773b6015924b57a3a59de5...809e7c2dfb4c7aba7d8ed5297b0e9472a591beea You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 20:03:19 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 11 Oct 2023 16:03:19 -0400 Subject: [Git][ghc/ghc][master] Split `FP_CHECK_PTHREADS` and move part to RTS configure Message-ID: <6526ff876fc93_1b931c88713120823319@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - 3 changed files: - configure.ac - m4/fp_check_pthreads.m4 - rts/configure.ac Changes: ===================================== configure.ac ===================================== @@ -1038,7 +1038,8 @@ AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])], [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) ]) -FP_CHECK_PTHREADS +FP_CHECK_PTHREAD_LIB +AC_SUBST([UseLibpthread]) GHC_ADJUSTORS_METHOD([Target]) AC_SUBST([UseLibffiForAdjustors]) ===================================== m4/fp_check_pthreads.m4 ===================================== @@ -1,7 +1,10 @@ -dnl FP_CHECK_PTHREADS -dnl ---------------------------------- -dnl Check various aspects of the platform's pthreads support -AC_DEFUN([FP_CHECK_PTHREADS], +# FP_CHECK_PTHREAD_LIB +# ---------------------------------- +# Check whether -lpthread is needed for pthread. +# +# Sets variables: +# - UseLibpthread: [YES|NO] +AC_DEFUN([FP_CHECK_PTHREAD_LIB], [ dnl Some platforms (e.g. Android's Bionic) have pthreads support available dnl without linking against libpthread. Check whether -lpthread is necessary @@ -12,25 +15,28 @@ AC_DEFUN([FP_CHECK_PTHREADS], AC_CHECK_FUNC(pthread_create, [ AC_MSG_RESULT(no) - AC_SUBST([UseLibpthread],[NO]) - need_lpthread=0 + UseLibpthread=NO ], [ AC_CHECK_LIB(pthread, pthread_create, [ AC_MSG_RESULT(yes) - AC_SUBST([UseLibpthread],[YES]) - need_lpthread=1 + UseLibpthread=YES ], [ - AC_SUBST([UseLibpthread],[NO]) AC_MSG_RESULT([no pthreads support found.]) - need_lpthread=0 + UseLibpthread=NO ]) ]) - AC_DEFINE_UNQUOTED([NEED_PTHREAD_LIB], [$need_lpthread], - [Define 1 if we need to link code using pthreads with -lpthread]) +]) +# FP_CHECK_PTHREAD_FUNCS +# ---------------------------------- +# Check various aspects of the platform's pthreads support +# +# `AC_DEFINE`s various C `HAVE_*` macros. +AC_DEFUN([FP_CHECK_PTHREAD_FUNCS], +[ dnl Setting thread names dnl ~~~~~~~~~~~~~~~~~~~~ dnl The portability situation here is complicated: ===================================== rts/configure.ac ===================================== @@ -33,6 +33,8 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host]) FPTOOLS_SET_PLATFORM_VARS([host], [Host]) FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) +FP_CHECK_PTHREAD_FUNCS + dnl ** check for eventfd which is needed by the I/O manager AC_CHECK_HEADERS([sys/eventfd.h]) AC_CHECK_FUNCS([eventfd]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58f3babff6a71649554928d269e8c9e21200305f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58f3babff6a71649554928d269e8c9e21200305f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 20:03:59 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 11 Oct 2023 16:03:59 -0400 Subject: [Git][ghc/ghc][master] nativeGen: section flags for .text$foo only Message-ID: <6526ffaf9ecf0_1b931c88713120826822@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - 1 changed file: - compiler/GHC/CmmToAsm/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/Ppr.hs ===================================== @@ -246,9 +246,10 @@ pprGNUSectionHeader config t suffix = panic "PprBase.pprGNUSectionHeader: unknown section type" flags = case t of Text - | OSMinGW32 <- platformOS platform + | OSMinGW32 <- platformOS platform, splitSections -> text ",\"xr\"" - | otherwise -> text ",\"ax\"," <> sectionType platform "progbits" + | splitSections + -> text ",\"ax\"," <> sectionType platform "progbits" CString | OSMinGW32 <- platformOS platform -> empty View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e99cf237f84db34be0468a893b10394d6b364bce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e99cf237f84db34be0468a893b10394d6b364bce You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 20:04:37 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 11 Oct 2023 16:04:37 -0400 Subject: [Git][ghc/ghc][master] Modularity: pass TempDir instead of DynFlags (#17957) Message-ID: <6526ffd57fa11_1b931c885bb7dc829749@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 2 changed files: - compiler/GHC/SysTools/Process.hs - compiler/GHC/SysTools/Tasks.hs Changes: ===================================== compiler/GHC/SysTools/Process.hs ===================================== @@ -10,14 +10,14 @@ module GHC.SysTools.Process where import GHC.Prelude -import GHC.Driver.DynFlags - import GHC.Utils.Exception import GHC.Utils.Error import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Misc import GHC.Utils.Logger +import GHC.Utils.TmpFs +import GHC.Utils.CliOption import GHC.Types.SrcLoc ( SrcLoc, mkSrcLoc, mkSrcSpan ) import GHC.Data.FastString @@ -32,7 +32,6 @@ import System.IO import System.IO.Error as IO import System.Process -import GHC.Utils.TmpFs -- | Enable process jobs support on Windows if it can be expected to work (e.g. -- @process >= 1.6.9.0@). @@ -153,14 +152,14 @@ runSomething logger phase_name pgm args = runSomethingResponseFile :: Logger -> TmpFs - -> DynFlags + -> TempDir -> (String->String) -> String -> String -> [Option] -> Maybe [(String,String)] -> IO () -runSomethingResponseFile logger tmpfs dflags filter_fn phase_name pgm args mb_env = +runSomethingResponseFile logger tmpfs tmp_dir filter_fn phase_name pgm args mb_env = runSomethingWith logger phase_name pgm args $ \real_args -> do fp <- getResponseFile real_args let args = ['@':fp] @@ -168,7 +167,7 @@ runSomethingResponseFile logger tmpfs dflags filter_fn phase_name pgm args mb_en return (r,()) where getResponseFile args = do - fp <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "rsp" + fp <- newTempName logger tmpfs tmp_dir TFL_CurrentModule "rsp" withFile fp WriteMode $ \h -> do hSetEncoding h utf8 hPutStr h $ unlines $ map escape args ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -117,7 +117,7 @@ runCpp logger tmpfs dflags args = traceSystoolCommand logger "cpp" $ do userOpts_c = map Option $ getOpts dflags opt_c args2 = args0 ++ args ++ userOpts_c mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags cc_filter "C pre-processor" p + runSomethingResponseFile logger tmpfs (tmpDir dflags) cc_filter "C pre-processor" p args2 mb_env -- | Run the Haskell C preprocessor. @@ -148,7 +148,7 @@ runCc mLanguage logger tmpfs dflags args = traceSystoolCommand logger "cc" $ do -- We take care to pass -optc flags in args1 last to ensure that the -- user can override flags passed by GHC. See #14452. mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags cc_filter dbgstring prog args2 + runSomethingResponseFile logger tmpfs (tmpDir dflags) cc_filter dbgstring prog args2 mb_env where -- force the C compiler to interpret this file as C when @@ -275,7 +275,7 @@ runLink logger tmpfs dflags args = traceSystoolCommand logger "linker" $ do optl_args = map Option (getOpts dflags opt_l) args2 = args0 ++ args ++ optl_args mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags ld_filter "Linker" p args2 mb_env + runSomethingResponseFile logger tmpfs (tmpDir dflags) ld_filter "Linker" p args2 mb_env where ld_filter = case (platformOS (targetPlatform dflags)) of OSSolaris2 -> sunos_ld_filter @@ -339,7 +339,7 @@ runMergeObjects logger tmpfs dflags args = if toolSettings_mergeObjsSupportsResponseFiles (toolSettings dflags) then do mb_env <- getGccEnv args2 - runSomethingResponseFile logger tmpfs dflags id "Merge objects" p args2 mb_env + runSomethingResponseFile logger tmpfs (tmpDir dflags) id "Merge objects" p args2 mb_env else do runSomething logger "Merge objects" p args2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f383a242c76f90bcca8a4d7ee001dcb49c172a9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f383a242c76f90bcca8a4d7ee001dcb49c172a9a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 22:07:48 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Wed, 11 Oct 2023 18:07:48 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/rts-configure-misc-ac-define Message-ID: <65271cb48b4fc_1b931c8b7267188335a9@gitlab.mail> John Ericson deleted branch wip/rts-configure-misc-ac-define at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 11 22:07:53 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Wed, 11 Oct 2023 18:07:53 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/rts-configure-pthread Message-ID: <65271cb9a9042_1b931c8be40aa883371a@gitlab.mail> John Ericson deleted branch wip/rts-configure-pthread at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 00:26:00 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Wed, 11 Oct 2023 20:26:00 -0400 Subject: [Git][ghc/ghc][wip/expand-do] 58 commits: Simplify and correct nasty case in coercion opt Message-ID: <65273d1721a48_1b931c8ed4dabc8345db@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - a6bfdbc2 by Apoorv Ingle at 2023-10-11T19:25:18-05:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatypes to make this expansion work: `GHC.Hs.Expr.XXExprGhcRn`: It contains 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 30 changed files: - .gitignore - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Config/Tidy.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e010a03c1f2ba0d565f9751af5ab83f1fc388d4e...a6bfdbc2296fcba35cd7811e0159a7f488200874 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e010a03c1f2ba0d565f9751af5ab83f1fc388d4e...a6bfdbc2296fcba35cd7811e0159a7f488200874 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 02:00:19 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Wed, 11 Oct 2023 22:00:19 -0400 Subject: [Git][ghc/ghc][wip/angerman/no-null-deref] Update PEi386.c Message-ID: <65275333dd1f4_1b931c9102f4e083739a@gitlab.mail> Moritz Angermann pushed to branch wip/angerman/no-null-deref at Glasgow Haskell Compiler / GHC Commits: 5ee4a8c8 by Moritz Angermann at 2023-10-12T02:00:06+00:00 Update PEi386.c - - - - - 1 changed file: - rts/linker/PEi386.c Changes: ===================================== rts/linker/PEi386.c ===================================== @@ -1775,6 +1775,9 @@ ocGetNames_PEi386 ( ObjectCode* oc ) targetSection = NULL; break; default: + // targetSecNumber is a uint32_t, and the 0 case should be caught by PE_SECTION_UNDEFINED. + // The compiler should be smart enough to eliminate the guard, we'll keep it in as fail + // safe nontheless. targetSection = targetSecNumber > 0 ? &oc->sections[targetSecNumber-1] : NULL; } if(NULL != targetSection) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ee4a8c88720e98a58a80eca5b34a22ca5db4c0f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ee4a8c88720e98a58a80eca5b34a22ca5db4c0f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 02:06:34 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Wed, 11 Oct 2023 22:06:34 -0400 Subject: [Git][ghc/ghc][wip/angerman/no-null-deref] [PEi386 linker] Bounds check and null-deref guard Message-ID: <652754aad8486_1b931c912a649483899b@gitlab.mail> Moritz Angermann pushed to branch wip/angerman/no-null-deref at Glasgow Haskell Compiler / GHC Commits: 7bbf59e3 by Moritz Angermann at 2023-10-12T10:06:16+08:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - 1 changed file: - rts/linker/PEi386.c Changes: ===================================== rts/linker/PEi386.c ===================================== @@ -1775,9 +1775,13 @@ ocGetNames_PEi386 ( ObjectCode* oc ) targetSection = NULL; break; default: - targetSection = &oc->sections[targetSecNumber-1]; + // targetSecNumber is a uint32_t, and the 0 case should be caught by PE_SECTION_UNDEFINED. + // The compiler should be smart enough to eliminate the guard, we'll keep it in as fail + // safe nontheless. + targetSection = targetSecNumber > 0 ? &oc->sections[targetSecNumber-1] : NULL; } - addr = (SymbolAddr*) ((size_t) targetSection->start + getSymValue(info, targetSym)); + if(NULL != targetSection) + addr = (SymbolAddr*) ((size_t) targetSection->start + getSymValue(info, targetSym)); } else if ( secNumber == IMAGE_SYM_UNDEFINED && symValue > 0) { /* This symbol isn't in any section at all, ie, global bss. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7bbf59e36e2b5b1e8882963016dbfc28f6fc9490 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7bbf59e36e2b5b1e8882963016dbfc28f6fc9490 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 05:08:12 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 12 Oct 2023 01:08:12 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 14 commits: RTS configure: Move over mem management checks Message-ID: <65277f3cb8b30_1b931c956e9e1c8661a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 65720412 by Ben Gamari at 2023-10-12T01:08:00-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - 19032e6e by Moritz Angermann at 2023-10-12T01:08:01-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 233fab61 by Sylvain Henry at 2023-10-12T01:08:01-04:00 Apply 1 suggestion(s) to 1 file(s) - - - - - b0f33b6c by Moritz Angermann at 2023-10-12T01:08:01-04:00 Update CgUtils.hs - - - - - c84b806c by Moritz Angermann at 2023-10-12T01:08:01-04:00 Update CgUtils.hs - - - - - ce9c5115 by Moritz Angermann at 2023-10-12T01:08:01-04:00 Update CgUtils.hs - - - - - c5280857 by Moritz Angermann at 2023-10-12T01:08:01-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - 30 changed files: - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/SysTools/Process.hs - compiler/GHC/SysTools/Tasks.hs - configure.ac - libraries/base/base.cabal - libraries/base/Control/Applicative.hs → libraries/base/src/Control/Applicative.hs - libraries/base/Control/Arrow.hs → libraries/base/src/Control/Arrow.hs - libraries/base/Control/Category.hs → libraries/base/src/Control/Category.hs - libraries/base/Control/Concurrent.hs → libraries/base/src/Control/Concurrent.hs - libraries/base/Control/Concurrent.hs-boot → libraries/base/src/Control/Concurrent.hs-boot - libraries/base/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs - libraries/base/Control/Concurrent/MVar.hs → libraries/base/src/Control/Concurrent/MVar.hs - libraries/base/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs - libraries/base/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs - libraries/base/Control/Exception.hs → libraries/base/src/Control/Exception.hs - libraries/base/Control/Exception/Base.hs → libraries/base/src/Control/Exception/Base.hs - libraries/base/Control/Monad.hs → libraries/base/src/Control/Monad.hs - libraries/base/Control/Monad/Fail.hs → libraries/base/src/Control/Monad/Fail.hs - libraries/base/Control/Monad/Fix.hs → libraries/base/src/Control/Monad/Fix.hs - libraries/base/Control/Monad/IO/Class.hs → libraries/base/src/Control/Monad/IO/Class.hs - libraries/base/Control/Monad/Instances.hs → libraries/base/src/Control/Monad/Instances.hs - libraries/base/Control/Monad/ST.hs → libraries/base/src/Control/Monad/ST.hs - libraries/base/Control/Monad/ST/Imp.hs → libraries/base/src/Control/Monad/ST/Imp.hs - libraries/base/Control/Monad/ST/Lazy.hs → libraries/base/src/Control/Monad/ST/Lazy.hs - libraries/base/Control/Monad/ST/Lazy/Imp.hs → libraries/base/src/Control/Monad/ST/Lazy/Imp.hs - libraries/base/Control/Monad/ST/Lazy/Safe.hs → libraries/base/src/Control/Monad/ST/Lazy/Safe.hs - libraries/base/Control/Monad/ST/Lazy/Unsafe.hs → libraries/base/src/Control/Monad/ST/Lazy/Unsafe.hs - libraries/base/Control/Monad/ST/Safe.hs → libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/Control/Monad/ST/Strict.hs → libraries/base/src/Control/Monad/ST/Strict.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc87484224c08772bc78a0ba774c95a9665f1c3f...c5280857da2c4a8a7a9d8056569648ce7ae60bb1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc87484224c08772bc78a0ba774c95a9665f1c3f...c5280857da2c4a8a7a9d8056569648ce7ae60bb1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 05:21:10 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 01:21:10 -0400 Subject: [Git][ghc/ghc][wip/rts-configure-1] 93 commits: gitlab-ci: Mark T22012 as broken on CentOS 7 Message-ID: <6527824652f8d_1b931c960feec0872630@gitlab.mail> John Ericson pushed to branch wip/rts-configure-1 at Glasgow Haskell Compiler / GHC Commits: de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - a4b4f806 by John Ericson at 2023-10-12T01:20:54-04:00 Move apple compat check to RTS configure - - - - - 56076c26 by John Ericson at 2023-10-12T01:20:54-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 0ff31b86 by John Ericson at 2023-10-12T01:20:55-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - b351f706 by John Ericson at 2023-10-12T01:20:55-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 330d9600 by John Ericson at 2023-10-12T01:20:55-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - fd33055f by John Ericson at 2023-10-12T01:20:55-04:00 Move libdl check to RTS configure - - - - - b9d13ed5 by John Ericson at 2023-10-12T01:20:55-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - 56974161 by John Ericson at 2023-10-12T01:20:55-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - efcbae93 by John Ericson at 2023-10-12T01:20:55-04:00 Split libm check between top level and RTS - - - - - 30 changed files: - .gitignore - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Data/FastString.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df1c19214fb7fd6e451353029b649b42d12de001...efcbae93498348a6e17954d880bd4b80fe2d97dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df1c19214fb7fd6e451353029b649b42d12de001...efcbae93498348a6e17954d880bd4b80fe2d97dc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 05:25:25 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 01:25:25 -0400 Subject: [Git][ghc/ghc][wip/rts-configure] 101 commits: gitlab-ci: Mark T22012 as broken on CentOS 7 Message-ID: <652783455db34_1b931c95d841a087629a@gitlab.mail> John Ericson pushed to branch wip/rts-configure at Glasgow Haskell Compiler / GHC Commits: de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - a4b4f806 by John Ericson at 2023-10-12T01:20:54-04:00 Move apple compat check to RTS configure - - - - - 56076c26 by John Ericson at 2023-10-12T01:20:54-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 0ff31b86 by John Ericson at 2023-10-12T01:20:55-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - b351f706 by John Ericson at 2023-10-12T01:20:55-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 330d9600 by John Ericson at 2023-10-12T01:20:55-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - fd33055f by John Ericson at 2023-10-12T01:20:55-04:00 Move libdl check to RTS configure - - - - - b9d13ed5 by John Ericson at 2023-10-12T01:20:55-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - 56974161 by John Ericson at 2023-10-12T01:20:55-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - efcbae93 by John Ericson at 2023-10-12T01:20:55-04:00 Split libm check between top level and RTS - - - - - 349809ed by John Ericson at 2023-10-12T01:24:17-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 91add9e0 by John Ericson at 2023-10-12T01:24:55-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 4d9a3b61 by John Ericson at 2023-10-12T01:24:56-04:00 Move over a number of C-style checks to RTS configure - - - - - 3e00fed5 by John Ericson at 2023-10-12T01:24:57-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - 127ffc28 by John Ericson at 2023-10-12T01:24:57-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - a9f5c4ca by John Ericson at 2023-10-12T01:24:57-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - a3491cb3 by John Ericson at 2023-10-12T01:24:57-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 7d3f7d92 by John Ericson at 2023-10-12T01:24:57-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - 30 changed files: - .gitignore - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Data/FastString.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/38a9d8ac3f76d8bae4f947970459a93baaca07e9...7d3f7d92b54a450151a474a9f4af8bed8b54fe0c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/38a9d8ac3f76d8bae4f947970459a93baaca07e9...7d3f7d92b54a450151a474a9f4af8bed8b54fe0c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 07:35:16 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Thu, 12 Oct 2023 03:35:16 -0400 Subject: [Git][ghc/ghc][wip/angerman/32bit-cmm] CgUtils.fixStgRegStmt respect register width Message-ID: <6527a1b4e0abf_1b931c9928b2548858de@gitlab.mail> Moritz Angermann pushed to branch wip/angerman/32bit-cmm at Glasgow Haskell Compiler / GHC Commits: b13c48d3 by Moritz Angermann at 2023-10-12T15:34:46+08:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 1 changed file: - compiler/GHC/StgToCmm/CgUtils.hs Changes: ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -177,16 +177,18 @@ fixStgRegStmt platform stmt = fixAssign $ mapExpDeep fixExpr stmt (globalRegSpillType platform reg) NaturallyAligned - CmmRegOff (CmmGlobal reg_use) offset -> + CmmRegOff greg@(CmmGlobal reg) offset -> -- RegOf leaves are just a shorthand form. If the reg maps -- to a real reg, we keep the shorthand, otherwise, we just -- expand it and defer to the above code. - let reg = globalRegUseGlobalReg reg_use in - case reg `elem` activeStgRegs platform of + -- NB: to ensure type correctness we need to ensure the Add + -- as well as the Int need to be of the same size as the + -- register. + case globalRegUseGlobalReg reg `elem` activeStgRegs platform of True -> expr - False -> CmmMachOp (MO_Add (wordWidth platform)) [ - fixExpr (CmmReg (CmmGlobal reg_use)), + False -> CmmMachOp (MO_Add (cmmRegWidth greg)) [ + fixExpr (CmmReg greg), CmmLit (CmmInt (fromIntegral offset) - (wordWidth platform))] + (cmmRegWidth greg))] other_expr -> other_expr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b13c48d3b6e44c24ea7a1ffdd636977c1ce47d88 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b13c48d3b6e44c24ea7a1ffdd636977c1ce47d88 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 08:08:29 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 12 Oct 2023 04:08:29 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Test that functions from `mingwex` are available Message-ID: <6527a97d70213_1b931c99c302788955e1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 88f31aad by John Ericson at 2023-10-12T04:08:20-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - e1bc5aea by John Ericson at 2023-10-12T04:08:20-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 4e7f5521 by Ben Gamari at 2023-10-12T04:08:21-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - 16a8cedf by Moritz Angermann at 2023-10-12T04:08:22-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - 30 changed files: - configure.ac - libraries/base/base.cabal - libraries/base/Control/Applicative.hs → libraries/base/src/Control/Applicative.hs - libraries/base/Control/Arrow.hs → libraries/base/src/Control/Arrow.hs - libraries/base/Control/Category.hs → libraries/base/src/Control/Category.hs - libraries/base/Control/Concurrent.hs → libraries/base/src/Control/Concurrent.hs - libraries/base/Control/Concurrent.hs-boot → libraries/base/src/Control/Concurrent.hs-boot - libraries/base/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs - libraries/base/Control/Concurrent/MVar.hs → libraries/base/src/Control/Concurrent/MVar.hs - libraries/base/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs - libraries/base/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs - libraries/base/Control/Exception.hs → libraries/base/src/Control/Exception.hs - libraries/base/Control/Exception/Base.hs → libraries/base/src/Control/Exception/Base.hs - libraries/base/Control/Monad.hs → libraries/base/src/Control/Monad.hs - libraries/base/Control/Monad/Fail.hs → libraries/base/src/Control/Monad/Fail.hs - libraries/base/Control/Monad/Fix.hs → libraries/base/src/Control/Monad/Fix.hs - libraries/base/Control/Monad/IO/Class.hs → libraries/base/src/Control/Monad/IO/Class.hs - libraries/base/Control/Monad/Instances.hs → libraries/base/src/Control/Monad/Instances.hs - libraries/base/Control/Monad/ST.hs → libraries/base/src/Control/Monad/ST.hs - libraries/base/Control/Monad/ST/Imp.hs → libraries/base/src/Control/Monad/ST/Imp.hs - libraries/base/Control/Monad/ST/Lazy.hs → libraries/base/src/Control/Monad/ST/Lazy.hs - libraries/base/Control/Monad/ST/Lazy/Imp.hs → libraries/base/src/Control/Monad/ST/Lazy/Imp.hs - libraries/base/Control/Monad/ST/Lazy/Safe.hs → libraries/base/src/Control/Monad/ST/Lazy/Safe.hs - libraries/base/Control/Monad/ST/Lazy/Unsafe.hs → libraries/base/src/Control/Monad/ST/Lazy/Unsafe.hs - libraries/base/Control/Monad/ST/Safe.hs → libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/Control/Monad/ST/Strict.hs → libraries/base/src/Control/Monad/ST/Strict.hs - libraries/base/Control/Monad/ST/Unsafe.hs → libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/Control/Monad/Zip.hs → libraries/base/src/Control/Monad/Zip.hs - libraries/base/Data/Array/Byte.hs → libraries/base/src/Data/Array/Byte.hs - libraries/base/Data/Bifoldable.hs → libraries/base/src/Data/Bifoldable.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c5280857da2c4a8a7a9d8056569648ce7ae60bb1...16a8cedf027e51035c090b0733fda4f1ab6ec365 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c5280857da2c4a8a7a9d8056569648ce7ae60bb1...16a8cedf027e51035c090b0733fda4f1ab6ec365 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 10:48:51 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 12 Oct 2023 06:48:51 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Test that functions from `mingwex` are available Message-ID: <6527cf13649bb_24a445ca7f4c566c7@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 9 changed files: - configure.ac - + testsuite/tests/th/T23309.c - + testsuite/tests/th/T23309.hs - + testsuite/tests/th/T23309.stderr - + testsuite/tests/th/T23309A.hs - + testsuite/tests/th/T23378.hs - + testsuite/tests/th/T23378.stderr - + testsuite/tests/th/T23378A.hs - testsuite/tests/th/all.T Changes: ===================================== configure.ac ===================================== @@ -946,9 +946,6 @@ AC_CHECK_DECLS([program_invocation_short_name], , , [#define _GNU_SOURCE 1 #include ]) -dnl ** check for mingwex library -AC_CHECK_LIB([mingwex],[closedir]) - dnl ** check for math library dnl Keep that check as early as possible. dnl as we need to know whether we need libm ===================================== testsuite/tests/th/T23309.c ===================================== @@ -0,0 +1,8 @@ +#define _GNU_SOURCE 1 +#include + +const char* foo(int e) { + static char s[256]; + sprintf(s, "The value of e is: %u", e); + return s; +} ===================================== testsuite/tests/th/T23309.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23309 where + +import Foreign.C.String +import Language.Haskell.TH +import System.IO + +import T23309A + +$(do runIO $ do + cstr <- c_foo 42 + str <- peekCString cstr + hPutStrLn stderr str + hFlush stderr + return []) ===================================== testsuite/tests/th/T23309.stderr ===================================== @@ -0,0 +1 @@ +The value of e is: 42 ===================================== testsuite/tests/th/T23309A.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE CPP #-} +module T23309A (c_foo) where + +import Foreign.C.String +import Foreign.C.Types + +#if defined(mingw32_HOST_OS) +# if defined(i386_HOST_ARCH) +# define CALLCONV stdcall +# elif defined(x86_64_HOST_ARCH) +# define CALLCONV ccall +# else +# error Unknown mingw32 arch +# endif +#else +# define CALLCONV ccall +#endif + +foreign import CALLCONV unsafe "foo" c_foo :: CInt -> IO CString ===================================== testsuite/tests/th/T23378.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE TemplateHaskell #-} +module T23378 where + +import Foreign.C.String +import Language.Haskell.TH +import System.IO + +import T23378A + +$(do runIO $ do + hPrint stderr isatty + hFlush stderr + return []) ===================================== testsuite/tests/th/T23378.stderr ===================================== @@ -0,0 +1 @@ +False ===================================== testsuite/tests/th/T23378A.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE CPP #-} +module T23378A where + +import Foreign.C.Types +import System.IO.Unsafe + +isatty :: Bool +isatty = + unsafePerformIO (c_isatty 1) == 1 +{-# NOINLINE isatty #-} + +#if defined(mingw32_HOST_OS) +# define SYM "_isatty" +#else +# define SYM "isatty" +#endif + +foreign import ccall unsafe SYM + c_isatty :: CInt -> IO CInt ===================================== testsuite/tests/th/all.T ===================================== @@ -591,6 +591,8 @@ test('T23829_hasty', normal, compile_fail, ['']) test('T23829_hasty_b', normal, compile_fail, ['']) test('T23927', normal, compile_and_run, ['']) test('T23954', normal, compile_and_run, ['']) +test('T23309', [extra_files(['T23309A.hs']), req_c], multimod_compile, ['T23309', '-v0 T23309.c -optc-fPIC']) +test('T23378', [extra_files(['T23378A.hs']), js_skip], multimod_compile, ['T23378', '-v0']) test('T23962', normal, compile_and_run, ['']) test('T23968', normal, compile_and_run, ['']) test('T23971', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f383a242c76f90bcca8a4d7ee001dcb49c172a9a...bdb54a0e9437ecd151693d9c6df76747d6b385ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f383a242c76f90bcca8a4d7ee001dcb49c172a9a...bdb54a0e9437ecd151693d9c6df76747d6b385ea You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 10:50:03 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 12 Oct 2023 06:50:03 -0400 Subject: [Git][ghc/ghc][master] base: Introduce move modules into src Message-ID: <6527cf5ba637d_24a44513ee94631e1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - 30 changed files: - libraries/base/base.cabal - libraries/base/Control/Applicative.hs → libraries/base/src/Control/Applicative.hs - libraries/base/Control/Arrow.hs → libraries/base/src/Control/Arrow.hs - libraries/base/Control/Category.hs → libraries/base/src/Control/Category.hs - libraries/base/Control/Concurrent.hs → libraries/base/src/Control/Concurrent.hs - libraries/base/Control/Concurrent.hs-boot → libraries/base/src/Control/Concurrent.hs-boot - libraries/base/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs - libraries/base/Control/Concurrent/MVar.hs → libraries/base/src/Control/Concurrent/MVar.hs - libraries/base/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs - libraries/base/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs - libraries/base/Control/Exception.hs → libraries/base/src/Control/Exception.hs - libraries/base/Control/Exception/Base.hs → libraries/base/src/Control/Exception/Base.hs - libraries/base/Control/Monad.hs → libraries/base/src/Control/Monad.hs - libraries/base/Control/Monad/Fail.hs → libraries/base/src/Control/Monad/Fail.hs - libraries/base/Control/Monad/Fix.hs → libraries/base/src/Control/Monad/Fix.hs - libraries/base/Control/Monad/IO/Class.hs → libraries/base/src/Control/Monad/IO/Class.hs - libraries/base/Control/Monad/Instances.hs → libraries/base/src/Control/Monad/Instances.hs - libraries/base/Control/Monad/ST.hs → libraries/base/src/Control/Monad/ST.hs - libraries/base/Control/Monad/ST/Imp.hs → libraries/base/src/Control/Monad/ST/Imp.hs - libraries/base/Control/Monad/ST/Lazy.hs → libraries/base/src/Control/Monad/ST/Lazy.hs - libraries/base/Control/Monad/ST/Lazy/Imp.hs → libraries/base/src/Control/Monad/ST/Lazy/Imp.hs - libraries/base/Control/Monad/ST/Lazy/Safe.hs → libraries/base/src/Control/Monad/ST/Lazy/Safe.hs - libraries/base/Control/Monad/ST/Lazy/Unsafe.hs → libraries/base/src/Control/Monad/ST/Lazy/Unsafe.hs - libraries/base/Control/Monad/ST/Safe.hs → libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/Control/Monad/ST/Strict.hs → libraries/base/src/Control/Monad/ST/Strict.hs - libraries/base/Control/Monad/ST/Unsafe.hs → libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/Control/Monad/Zip.hs → libraries/base/src/Control/Monad/Zip.hs - libraries/base/Data/Array/Byte.hs → libraries/base/src/Data/Array/Byte.hs - libraries/base/Data/Bifoldable.hs → libraries/base/src/Data/Bifoldable.hs - libraries/base/Data/Bifoldable1.hs → libraries/base/src/Data/Bifoldable1.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43e814e127f52b73173f8f09d4de777f15dd9ec7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43e814e127f52b73173f8f09d4de777f15dd9ec7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 10:50:59 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 12 Oct 2023 06:50:59 -0400 Subject: [Git][ghc/ghc][master] [PEi386 linker] Bounds check and null-deref guard Message-ID: <6527cf9396ece_24a445c86c8466457@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - 1 changed file: - rts/linker/PEi386.c Changes: ===================================== rts/linker/PEi386.c ===================================== @@ -1775,9 +1775,13 @@ ocGetNames_PEi386 ( ObjectCode* oc ) targetSection = NULL; break; default: - targetSection = &oc->sections[targetSecNumber-1]; + // targetSecNumber is a uint32_t, and the 0 case should be caught by PE_SECTION_UNDEFINED. + // The compiler should be smart enough to eliminate the guard, we'll keep it in as fail + // safe nontheless. + targetSection = targetSecNumber > 0 ? &oc->sections[targetSecNumber-1] : NULL; } - addr = (SymbolAddr*) ((size_t) targetSection->start + getSymValue(info, targetSym)); + if(NULL != targetSection) + addr = (SymbolAddr*) ((size_t) targetSection->start + getSymValue(info, targetSym)); } else if ( secNumber == IMAGE_SYM_UNDEFINED && symValue > 0) { /* This symbol isn't in any section at all, ie, global bss. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df81536f2e53abf521a05eb1e482a076f5849c21 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df81536f2e53abf521a05eb1e482a076f5849c21 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 11:09:20 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 12 Oct 2023 07:09:20 -0400 Subject: [Git][ghc/ghc][wip/T17910] Inline data structures more aggressively again Message-ID: <6527d3e0a6359_24a4451db7b7066821@gitlab.mail> Simon Peyton Jones pushed to branch wip/T17910 at Glasgow Haskell Compiler / GHC Commits: d2a6c708 by Simon Peyton Jones at 2023-10-12T12:08:50+01:00 Inline data structures more aggressively again - - - - - 4 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -54,7 +54,7 @@ import GHC.Core.Utils import GHC.Core.DataCon import GHC.Core.TyCon ( tyConArity ) import GHC.Core.TyCon.RecWalk ( initRecTc, checkRecTc ) -import GHC.Core.Predicate ( isDictTy, isEvVar, isCallStackPredTy ) +import GHC.Core.Predicate ( isDictTy, isEvVar, isCallStackPredTy, isCallStackTy ) import GHC.Core.Multiplicity -- We have two sorts of substitution: @@ -1461,7 +1461,7 @@ myExprIsCheap (AE { am_opts = opts, am_sigs = sigs }) e mb_ty cheap_dict = case mb_ty of Nothing -> False Just ty -> (ao_dicts_cheap opts && isDictTy ty) - || isCallStackPredTy ty + || isCallStackPredTy ty || isCallStackTy ty -- See Note [Eta expanding through dictionaries] -- See Note [Eta expanding through CallStacks] ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -1095,14 +1095,13 @@ occAnalNonRecRhs !env lvl imp_rule_edges mb_join bndr rhs mkNonRecRhsCtxt :: TopLevelFlag -> Id -> Unfolding -> OccEncl -- Precondition: Id is not a join point -mkNonRecRhsCtxt lvl bndr unf +mkNonRecRhsCtxt _lvl bndr unf | certainly_inline = OccVanilla -- See Note [Cascading inlines] | otherwise = OccRhs where certainly_inline -- See Note [Cascading inlines] = -- mkNonRecRhsCtxt is only used for non-join points, so occAnalBind -- has set the OccInfo for this binder before calling occAnalNonRecRhs - not (isTopLevel lvl) && case idOccInfo bndr of OneOcc { occ_in_lam = NotInsideLam, occ_n_br = 1 } -> active && not_stable ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -279,7 +279,7 @@ getCoreToDo dflags hpt_rule_base extra_vars runWhen full_laziness $ CoreDoFloatOutwards FloatOutSwitches { floatOutLambdas = floatLamArgs dflags, - floatOutConstants = True, + floatOutConstants = True, -- For SpecConstr and CSE floatOutOverSatApps = True, floatToTopLevelOnly = False }, -- nofib/spectral/hartel/wang doubles in speed if you ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -46,7 +46,7 @@ import GHC.Prelude hiding (head, init, last, tail) import qualified GHC.Prelude as Partial (head) import GHC.Core -import GHC.Types.Literal ( isLitRubbish ) +import GHC.Core.Predicate( isDictId ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Inline import GHC.Core.Opt.Stats ( Tick(..) ) @@ -66,6 +66,7 @@ import GHC.Core.DataCon ( dataConWorkId, isNullaryRepDataCon ) import GHC.Core.Multiplicity import GHC.Core.Opt.ConstantFold +import GHC.Types.Literal ( isLitRubbish ) import GHC.Types.Name import GHC.Types.Id import GHC.Types.Id.Info @@ -1424,7 +1425,8 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env | is_value_lam rhs, IsInteresting <- int_cxt = True | NotInsideLam <- in_lam - , not (isTopLevel top_lvl) || not (exprIsExpandable rhs) + , not (isDictId bndr) -- Solely for SpecConstr +-- , not (isTopLevel top_lvl) || not (exprIsExpandable rhs) -- Inline used-once things; except expandable things at top level -- These may arise from user code e.g. -- x = [1,2,3] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2a6c708ed5b1118a8bd6906680b667b57f78ba4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2a6c708ed5b1118a8bd6906680b667b57f78ba4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 11:21:21 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 12 Oct 2023 07:21:21 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 14 commits: Test that functions from `mingwex` are available Message-ID: <6527d6b1b8338_24a4452237100702f7@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - 2252b49a by John Ericson at 2023-10-12T07:21:05-04:00 Move apple compat check to RTS configure - - - - - a1498c5d by John Ericson at 2023-10-12T07:21:05-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 886657d5 by John Ericson at 2023-10-12T07:21:05-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 7937e257 by John Ericson at 2023-10-12T07:21:05-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 53371b94 by John Ericson at 2023-10-12T07:21:05-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - c3ccc32d by John Ericson at 2023-10-12T07:21:06-04:00 Move libdl check to RTS configure - - - - - c51e11e4 by John Ericson at 2023-10-12T07:21:06-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - b33dd538 by John Ericson at 2023-10-12T07:21:06-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - 4e7600af by John Ericson at 2023-10-12T07:21:06-04:00 Split libm check between top level and RTS - - - - - 81c16967 by Moritz Angermann at 2023-10-12T07:21:06-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 30 changed files: - compiler/GHC/StgToCmm/CgUtils.hs - configure.ac - libraries/base/base.cabal - libraries/base/Control/Applicative.hs → libraries/base/src/Control/Applicative.hs - libraries/base/Control/Arrow.hs → libraries/base/src/Control/Arrow.hs - libraries/base/Control/Category.hs → libraries/base/src/Control/Category.hs - libraries/base/Control/Concurrent.hs → libraries/base/src/Control/Concurrent.hs - libraries/base/Control/Concurrent.hs-boot → libraries/base/src/Control/Concurrent.hs-boot - libraries/base/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs - libraries/base/Control/Concurrent/MVar.hs → libraries/base/src/Control/Concurrent/MVar.hs - libraries/base/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs - libraries/base/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs - libraries/base/Control/Exception.hs → libraries/base/src/Control/Exception.hs - libraries/base/Control/Exception/Base.hs → libraries/base/src/Control/Exception/Base.hs - libraries/base/Control/Monad.hs → libraries/base/src/Control/Monad.hs - libraries/base/Control/Monad/Fail.hs → libraries/base/src/Control/Monad/Fail.hs - libraries/base/Control/Monad/Fix.hs → libraries/base/src/Control/Monad/Fix.hs - libraries/base/Control/Monad/IO/Class.hs → libraries/base/src/Control/Monad/IO/Class.hs - libraries/base/Control/Monad/Instances.hs → libraries/base/src/Control/Monad/Instances.hs - libraries/base/Control/Monad/ST.hs → libraries/base/src/Control/Monad/ST.hs - libraries/base/Control/Monad/ST/Imp.hs → libraries/base/src/Control/Monad/ST/Imp.hs - libraries/base/Control/Monad/ST/Lazy.hs → libraries/base/src/Control/Monad/ST/Lazy.hs - libraries/base/Control/Monad/ST/Lazy/Imp.hs → libraries/base/src/Control/Monad/ST/Lazy/Imp.hs - libraries/base/Control/Monad/ST/Lazy/Safe.hs → libraries/base/src/Control/Monad/ST/Lazy/Safe.hs - libraries/base/Control/Monad/ST/Lazy/Unsafe.hs → libraries/base/src/Control/Monad/ST/Lazy/Unsafe.hs - libraries/base/Control/Monad/ST/Safe.hs → libraries/base/src/Control/Monad/ST/Safe.hs - libraries/base/Control/Monad/ST/Strict.hs → libraries/base/src/Control/Monad/ST/Strict.hs - libraries/base/Control/Monad/ST/Unsafe.hs → libraries/base/src/Control/Monad/ST/Unsafe.hs - libraries/base/Control/Monad/Zip.hs → libraries/base/src/Control/Monad/Zip.hs - libraries/base/Data/Array/Byte.hs → libraries/base/src/Data/Array/Byte.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16a8cedf027e51035c090b0733fda4f1ab6ec365...81c169678de4004246212a1c5b2914ac171895ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16a8cedf027e51035c090b0733fda4f1ab6ec365...81c169678de4004246212a1c5b2914ac171895ed You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 12:57:02 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 12 Oct 2023 08:57:02 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Fix cabal flags for rts Message-ID: <6527ed1ed9a3f_24a44548202e0875b7@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: dbe81e39 by GHC GitLab CI at 2023-10-12T12:56:54+00:00 Fix cabal flags for rts - - - - - 1 changed file: - hadrian/src/Settings/Packages.hs Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -282,8 +282,8 @@ rtsPackageArgs = package rts ? do targetArch <- queryTarget stage queryArch targetOs <- queryTarget stage queryOS targetVendor <- queryTarget stage queryVendor - ghcUnreg <- yesNo <$> queryTarget stage tgtUnregisterised - ghcEnableTNC <- yesNo <$> queryTarget stage tgtTablesNextToCode + ghcUnreg <- queryTarget stage tgtUnregisterised + ghcEnableTNC <- queryTarget stage tgtTablesNextToCode rtsWays <- getRtsWays way <- getWay path <- getBuildPath @@ -352,8 +352,8 @@ rtsPackageArgs = package rts ? do , "-DTargetArch=" ++ show targetArch , "-DTargetOS=" ++ show targetOs , "-DTargetVendor=" ++ show targetVendor - , "-DGhcUnregisterised=" ++ show ghcUnreg - , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DGhcUnregisterised=" ++ show (yesNo ghcUnreg) + , "-DTablesNextToCode=" ++ show (yesNo ghcEnableTNC) ] -- We're after pur performance here. So make sure fast math and @@ -400,6 +400,8 @@ rtsPackageArgs = package rts ? do , useSystemFfi `cabalFlag` "use-system-libffi" , targetUseLibffiForAdjustors stage `cabalFlag` "libffi-adjustors" , Debug `wayUnit` way `cabalFlag` "find-ptr" + , ghcEnableTNC `cabalFlag` "tables-next-to-code" + , ghcUnreg `cabalFlag` "unregisterised" ] , builder (Cabal Setup) ? mconcat [ cabalExtraDirs libdwIncludeDir libdwLibraryDir View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dbe81e392f1671fc50b0b03b6903cd1f711428b1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dbe81e392f1671fc50b0b03b6903cd1f711428b1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 13:16:30 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 12 Oct 2023 09:16:30 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 2 commits: Fix cabal flags for rts Message-ID: <6527f1adf423b_24a445535e800978d3@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: cb6a7c1c by GHC GitLab CI at 2023-10-12T14:14:06+01:00 Fix cabal flags for rts - - - - - a17827a4 by Matthew Pickering at 2023-10-12T14:16:13+01:00 Run full testsuite on wasm - - - - - 2 changed files: - .gitlab/ci.sh - hadrian/src/Settings/Packages.hs Changes: ===================================== .gitlab/ci.sh ===================================== @@ -592,7 +592,7 @@ function test_hadrian() { info "Cannot test cross-compiled build without CROSS_EMULATOR being set." return # If we have set CROSS_EMULATOR, then can't test using normal testsuite. - elif [ -n "${CROSS_EMULATOR:-}" ]; then + elif [ -n "${CROSS_EMULATOR:-}" ] && [[ "${CROSS_TARGET:-}" != *"wasm"* ]]; then local instdir="$TOP/_build/install" local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" install_bindist _build/bindist/ghc-*/ "$instdir" ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -282,8 +282,8 @@ rtsPackageArgs = package rts ? do targetArch <- queryTarget stage queryArch targetOs <- queryTarget stage queryOS targetVendor <- queryTarget stage queryVendor - ghcUnreg <- yesNo <$> queryTarget stage tgtUnregisterised - ghcEnableTNC <- yesNo <$> queryTarget stage tgtTablesNextToCode + ghcUnreg <- queryTarget stage tgtUnregisterised + ghcEnableTNC <- queryTarget stage tgtTablesNextToCode rtsWays <- getRtsWays way <- getWay path <- getBuildPath @@ -352,8 +352,8 @@ rtsPackageArgs = package rts ? do , "-DTargetArch=" ++ show targetArch , "-DTargetOS=" ++ show targetOs , "-DTargetVendor=" ++ show targetVendor - , "-DGhcUnregisterised=" ++ show ghcUnreg - , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DGhcUnregisterised=" ++ show (yesNo ghcUnreg) + , "-DTablesNextToCode=" ++ show (yesNo ghcEnableTNC) ] -- We're after pur performance here. So make sure fast math and @@ -400,6 +400,8 @@ rtsPackageArgs = package rts ? do , useSystemFfi `cabalFlag` "use-system-libffi" , targetUseLibffiForAdjustors stage `cabalFlag` "libffi-adjustors" , Debug `wayUnit` way `cabalFlag` "find-ptr" + , ghcEnableTNC `cabalFlag` "tables-next-to-code" + , ghcUnreg `cabalFlag` "unregisterised" ] , builder (Cabal Setup) ? mconcat [ cabalExtraDirs libdwIncludeDir libdwLibraryDir View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbe81e392f1671fc50b0b03b6903cd1f711428b1...a17827a405c5731a469b8e6adde25dd85ad474d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbe81e392f1671fc50b0b03b6903cd1f711428b1...a17827a405c5731a469b8e6adde25dd85ad474d2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 14:05:40 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 12 Oct 2023 10:05:40 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/cabal-verbosity Message-ID: <6527fd34de58c_24a44561f90e01096b0@gitlab.mail> Matthew Pickering pushed new branch wip/cabal-verbosity at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/cabal-verbosity You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 14:14:50 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 12 Oct 2023 10:14:50 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] Fix T18730 Message-ID: <6527ff5a62b79_24a4456a1cb3c1162cd@gitlab.mail> Sebastian Graf pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: c9bcb2f7 by Sebastian Graf at 2023-10-12T16:14:46+02:00 Fix T18730 - - - - - 1 changed file: - testsuite/tests/perf/compiler/all.T Changes: ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -206,7 +206,7 @@ test('CoOpt_Singletons', test('T18730', [ only_ways(['optasm']) , collect_compiler_stats('bytes allocated',1) - , extra_files(['T8730_aux.hs']) + , extra_files(['T18730_aux.hs']) ], multimod_compile, ['T18730_A', '-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9bcb2f7a195805443c1a5493b2e5698c1acfe44 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9bcb2f7a195805443c1a5493b2e5698c1acfe44 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 14:17:09 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 12 Oct 2023 10:17:09 -0400 Subject: [Git][ghc/ghc][wip/cabal-verbosity] hadrian: Decrease verbosity of cabal commands Message-ID: <6527ffe5c8690_24a44564c93ec1172a9@gitlab.mail> Matthew Pickering pushed to branch wip/cabal-verbosity at Glasgow Haskell Compiler / GHC Commits: d81decca by Matthew Pickering at 2023-10-12T15:17:00+01:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 1 changed file: - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs Changes: ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -198,9 +198,10 @@ copyPackage context at Context {..} = do shakeVerbosityToCabalFlag :: Verbosity -> String shakeVerbosityToCabalFlag = \case Diagnostic -> "-v3" - Verbose -> "-v3" + Verbose -> "-v2" + -- Normal levels should not produce output to stdout Silent -> "-v0" - _ -> "-v2" + _ -> "-v1" -- | What type of file is Main data MainSourceType = HsMain | CppMain | CMain View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d81decca032c415c3b444c35f14e407d4edef66c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d81decca032c415c3b444c35f14e407d4edef66c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 14:18:12 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Thu, 12 Oct 2023 10:18:12 -0400 Subject: [Git][ghc/ghc][wip/expand-do] 2 commits: fixing annoying whitespaces Message-ID: <65280024b802b_24a44566770cc117957@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 310372ea by Apoorv Ingle at 2023-10-11T21:33:15-05:00 fixing annoying whitespaces - - - - - ce8b71de by Apoorv Ingle at 2023-10-12T09:17:53-05:00 changes to call stack info and stats - - - - - 14 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/Language/Haskell/Syntax/Expr.hs - testsuite/tests/profiling/should_run/caller-cc/CallerCc1.prof.sample - testsuite/tests/profiling/should_run/caller-cc/CallerCc2.prof.sample - testsuite/tests/profiling/should_run/caller-cc/CallerCc3.prof.sample - testsuite/tests/profiling/should_run/callstack001.stdout Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -443,7 +443,6 @@ type instance XXExpr GhcTc = XXExprGhcTc -- HsExpansion: see Note [Rebindable syntax and HsExpansion] below - {- ********************************************************************* * * Generating code for HsExpanded @@ -509,7 +508,6 @@ mkExpandedStmt -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' mkExpandedStmt oStmt eExpr = XExpr (ExpandedThingRn (HsExpanded (OrigStmt oStmt) eExpr)) - mkExpandedPatRn :: LPat GhcRn -- ^ source pattern -> HsExpr GhcRn -- ^ expanded expression @@ -562,8 +560,6 @@ data XXExprGhcTc Int -- module-local tick number for False (LHsExpr GhcTc) -- sub-expression - - -- | Build a 'HsExpansion' out of an extension constructor, -- and the two components of the expansion: original and -- expanded typechecked expressions. @@ -582,8 +578,6 @@ mkExpandedStmtTc -> HsExpr GhcTc -- ^ suitably wrapped 'HsExpansion' mkExpandedStmtTc oStmt eExpr = XExpr (ExpandedThingTc (HsExpanded (OrigStmt oStmt) eExpr)) - - {- ********************************************************************* * * Pretty-printing expressions @@ -847,7 +841,7 @@ instance Outputable XXExprGhcTc where ppr (HsTick tickish exp) = pprTicks (ppr exp) $ - ppr tickish <+> ppr_lexpr exp + ppr tickish <+> ppr_lexpr exp ppr (HsBinTick tickIdTrue tickIdFalse exp) = pprTicks (ppr exp) $ ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -543,7 +543,6 @@ type LPatIrrefutableCheck m p -> LPat p -- The LPat thing -> m Bool -- Is it irrefutable? - -- | (isIrrefutableHsPat p) is true if matching against p cannot fail -- in the sense of falling through to the next pattern. -- (NB: this is not quite the same as the (silly) defn @@ -556,6 +555,7 @@ type LPatIrrefutableCheck m p -- tuple patterns are considered irrefutable at the renamer stage. -- -- But if it returns True, the pattern is definitely irrefutable +-- Instantiates `isIrrefutableHsPatHelperM` with a trivial identity monad isIrrefutableHsPatHelper :: forall p. (OutputableBndrId p) => Bool -- ^ Are we in a @-XStrict@ context? -- See Note [-XStrict and irrefutability] @@ -578,8 +578,8 @@ isIrrefutableHsPatHelper is_strict pat = runIdentity $ doWork is_strict pat return $ b && and bs --- This function is abstracts 2 things --- 1. How to compare for irrefutability for a `ConLike` thing +-- This function abstracts 2 things +-- 1. How to compute irrefutability for a `ConLikeP` thing -- 2. The wrapper monad isIrrefutableHsPatHelperM :: forall m p. (Monad m, OutputableBndrId p) => LPatIrrefutableCheck m (GhcPass p) ===================================== compiler/GHC/HsToCore/Ticks.hs ===================================== @@ -606,7 +606,6 @@ addTickHsExpr (XExpr (HsTick t e)) = addTickHsExpr (XExpr (HsBinTick t0 t1 e)) = liftM (XExpr . HsBinTick t0 t1) (addTickLHsExprNever e) - addTickHsExpr (HsDo srcloc cxt (L l stmts)) = do { (stmts', _) <- addTickLStmts' forQual stmts (return ()) ; return (HsDo srcloc cxt (L l stmts')) } ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -252,7 +252,7 @@ and the reasons for doing so. - During the renaming phase, we may not have all the constructor details `HsConDetails` populated in the data structure. This would result in an inaccurate irrefutability analysis causing the continuation lambda body to be wrapped with `fail` alternatives when not needed. - See Part 1. of Note [Expanding HsDo with HsExpansion] + See Part 1. of Note [Expanding HsDo with HsExpansion] (test pattern-fails.hs) - If the expansion is done on the fly during renaming, expressions that have explicit type applications using (-XTypeApplciations) will not work as the name freshening @@ -2744,7 +2744,6 @@ getMonadFailOp ctxt * * ********************************************************************* -} - -- | Expand `HsIf` if rebindable syntax is turned on -- See Note [Handling overloaded and rebindable constructs] rnHsIf :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> RnM (HsExpr GhcRn, FreeVars) ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -316,8 +316,6 @@ The latter is much better. That is why we call unifyExpectedType before tcValArgs. -} - - tcApp :: HsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) -- See Note [tcApp: typechecking applications] tcApp rn_expr exp_res_ty @@ -350,8 +348,8 @@ tcApp rn_expr exp_res_ty | insideExpansion fun_ctxt = addHeadCtxt fun_ctxt thing_inside | otherwise - = do addFunResCtxt rn_fun rn_args app_res_rho exp_res_ty $ - thing_inside + = addFunResCtxt rn_fun rn_args app_res_rho exp_res_ty $ + thing_inside -- Match up app_res_rho: the result type of rn_expr -- with exp_res_ty: the expected result type @@ -813,7 +811,6 @@ addArgCtxt ctxt (L arg_loc arg) thing_inside addExprCtxt arg $ -- Auto-suppressed if arg_loc is generated thing_inside } - {- ********************************************************************* * * Visible type application ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -392,12 +392,12 @@ It stores the original statement (with location) and the expanded expression See Note [Rebindable syntax and HsExpansion] in `GHC.Hs.Expr`. * Recall, that when a source function arugment fails to typecheck, - we print an error message "In the second argument of the function f..". + we print an error message like "In the second argument of the function f..". However, `(>>)` is generated thus we don't want to display that to the user, it would be confusing. But also, we do not want to completely ignore it as we do want to keep the error blame carets as precise as possible and not just blame the complete `do` block. - Thus when we typecheck the application `(>>) e1`, we push the "In the stmt of do block e1" with - the source location of `e1` in the error context stack as we walk inside an `ExpandedStmt` first. + Thus, when we typecheck the application `(>>) e1`, we push the "In the stmt of do block e1" with + the source location of `e1` in the error context stack as we walk inside an `ExpandedStmt`. See also Note [splitHsApps] * After the expanded expression of a `do` statement is typechecked ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -684,8 +684,6 @@ tcXExpr xe@(ExpandedThingRn thing) res_ty tcXExpr xe res_ty = tcApp (XExpr xe) res_ty -- See Wrinkle 2. of Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - - {- ************************************************************************ * * ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -1656,7 +1656,7 @@ checkGADT conlike ex_tvs arg_tys = \case -- | Very similar to GHC.Tc.Pat.isIrrefutableHsPat, but doesn't typecheck the pattern -- It does depend on the type checker monad (`TcM`) however as we need to check ConPat case in more detail. -- Specifically, we call `tcLookupGlobal` to obtain constructor details from global packages --- for a comprehensive irrefutability check and avoid false negatives. +-- for a comprehensive irrefutability check and avoid false negatives. (testcase pattern-fails.hs) isIrrefutableHsPatRnTcM :: Bool -> LPat GhcRn -> TcM Bool isIrrefutableHsPatRnTcM is_strict = isIrrefutableHsPatHelperM is_strict isConLikeIrr where ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -1301,8 +1301,6 @@ setCtLocM (CtLoc { ctl_env = lcl }) thing_inside $ setLclEnvBinderStack (ctl_bndrs lcl) $ env) thing_inside - - {- ********************************************************************* * * Error recovery and exceptions ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -45,7 +45,6 @@ import Data.Maybe import Data.List.NonEmpty ( NonEmpty ) import GHC.Types.Name.Reader - {- Note [RecordDotSyntax field updates] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The extensions @OverloadedRecordDot@ @OverloadedRecordUpdate@ together ===================================== testsuite/tests/profiling/should_run/caller-cc/CallerCc1.prof.sample ===================================== @@ -1,79 +1,79 @@ - Fri Nov 13 01:06 2020 Time and Allocation Profiling Report (Final) + Thu Oct 12 08:47 2023 Time and Allocation Profiling Report (Final) CallerCc1 +RTS -hc -p -RTS 7 - total time = 0.09 secs (87 ticks @ 1000 us, 1 processor) - total alloc = 105,486,200 bytes (excludes profiling overheads) + total time = 0.14 secs (138 ticks @ 1000 us, 1 processor) + total alloc = 104,890,152 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc -disin Main Main.hs:(74,1)-(83,11) 35.6 49.5 -insert Main Main.hs:(108,1)-(112,8) 21.8 1.7 -clause.clause' Main Main.hs:(63,12)-(65,57) 17.2 37.5 -unicl.unicl' Main Main.hs:(178,11)-(180,36) 6.9 2.6 -conjunct Main Main.hs:(70,1)-(71,18) 5.7 0.0 -split.split' Main Main.hs:(165,11)-(166,28) 3.4 2.3 -disin.dp Main Main.hs:80:3-14 3.4 0.0 -unicl Main Main.hs:(176,1)-(180,36) 2.3 1.1 -tautclause Main Main.hs:173:1-49 2.3 3.7 -disin.dq Main Main.hs:81:3-14 1.1 0.0 +disin Main Main.hs:(74,1)-(83,11) 36.2 49.8 +insert Main Main.hs:(108,1)-(112,8) 26.8 1.7 +clause.clause' Main Main.hs:(63,12)-(65,57) 18.8 37.7 +conjunct Main Main.hs:(70,1)-(71,18) 6.5 0.0 +tautclause Main Main.hs:173:1-49 3.6 3.7 +split.split' Main Main.hs:(165,11)-(166,28) 3.6 2.3 +unicl.unicl' Main Main.hs:(178,11)-(180,36) 2.2 2.0 +disin.dp Main Main.hs:80:3-14 1.4 0.0 +unicl Main Main.hs:(176,1)-(180,36) 0.0 1.1 clause Main Main.hs:(61,1)-(65,57) 0.0 1.4 individual inherited COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc -MAIN MAIN 128 0 0.0 0.0 100.0 100.0 - CAF Main 255 0 0.0 0.0 0.0 0.0 - clauses Main Main.hs:68:1-74 261 1 0.0 0.0 0.0 0.0 - Main.clauses(calling:Data.Foldable.concat) Main Main.hs:68:1-7 263 1 0.0 0.0 0.0 0.0 - main Main Main.hs:(42,1)-(44,23) 256 1 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 279 1 0.0 0.0 0.0 0.0 - spaces Main Main.hs:160:1-19 303 1 0.0 0.0 0.0 0.0 - CAF GHC.Conc.Signal 246 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Encoding 235 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Encoding.Iconv 233 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Handle.FD 225 0 0.0 0.0 0.0 0.0 - main Main Main.hs:(42,1)-(44,23) 257 0 0.0 0.0 100.0 100.0 - res Main Main.hs:(46,1)-(48,26) 258 1 0.0 0.0 100.0 99.9 - Main.main(calling:Data.Foldable.concat) Main Main.hs:42:1-4 259 1 0.0 0.0 0.0 0.0 - res.xs Main Main.hs:47:8-69 260 1 0.0 0.0 0.0 0.0 - clauses Main Main.hs:68:1-74 262 0 0.0 0.0 100.0 99.9 - disin Main Main.hs:(74,1)-(83,11) 267 857598 35.6 49.5 46.0 49.5 - conjunct Main Main.hs:(70,1)-(71,18) 291 759353 5.7 0.0 5.7 0.0 - disin.dp Main Main.hs:80:3-14 292 380009 3.4 0.0 3.4 0.0 - disin.dq Main Main.hs:81:3-14 293 380009 1.1 0.0 1.1 0.0 - negin Main Main.hs:(119,1)-(124,11) 268 1617 0.0 0.1 0.0 0.1 - elim Main Main.hs:(89,1)-(94,57) 269 1393 0.0 0.1 0.0 0.1 - disp Main Main.hs:86:1-71 301 7 0.0 0.0 0.0 0.0 - interleave Main Main.hs:(115,1)-(116,25) 302 35 0.0 0.0 0.0 0.0 - parse Main Main.hs:135:1-39 270 7 0.0 0.0 0.0 0.0 - parse.(...) Main Main.hs:135:19-39 272 7 0.0 0.0 0.0 0.0 - parse' Main Main.hs:(137,1)-(145,42) 273 280 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 276 56 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 274 56 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 275 49 0.0 0.0 0.0 0.0 - parse'.(...) Main Main.hs:142:20-49 278 21 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 280 0 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 282 63 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 283 63 0.0 0.0 0.0 0.0 - while Main Main.hs:182:1-48 281 63 0.0 0.0 0.0 0.0 - red Main Main.hs:(148,1)-(152,43) 284 42 0.0 0.0 0.0 0.0 - parse'.s' Main Main.hs:142:20-49 285 21 0.0 0.0 0.0 0.0 - parse'.x Main Main.hs:142:20-49 277 21 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 286 0 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 288 21 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 289 14 0.0 0.0 0.0 0.0 - while Main Main.hs:182:1-48 287 21 0.0 0.0 0.0 0.0 - red Main Main.hs:(148,1)-(152,43) 290 14 0.0 0.0 0.0 0.0 - parse.f Main Main.hs:135:19-39 271 7 0.0 0.0 0.0 0.0 - split Main Main.hs:(163,1)-(166,28) 265 7 0.0 0.0 3.4 2.3 - split.split' Main Main.hs:(165,11)-(166,28) 266 74837 3.4 2.3 3.4 2.3 - unicl Main Main.hs:(176,1)-(180,36) 264 7 2.3 1.1 50.6 48.0 - unicl.unicl' Main Main.hs:(178,11)-(180,36) 294 37422 6.9 2.6 48.3 46.9 - tautclause Main Main.hs:173:1-49 295 37422 2.3 3.7 2.3 3.7 - unicl.unicl'.cp Main Main.hs:180:24-36 296 37422 0.0 0.0 39.1 40.6 - clause Main Main.hs:(61,1)-(65,57) 297 37422 0.0 1.4 39.1 40.6 - clause.clause' Main Main.hs:(63,12)-(65,57) 298 696150 17.2 37.5 39.1 39.2 - insert Main Main.hs:(108,1)-(112,8) 299 366786 21.8 1.7 21.8 1.7 - insert Main Main.hs:(108,1)-(112,8) 300 7 0.0 0.0 0.0 0.0 +MAIN MAIN 137 0 0.0 0.0 100.0 100.0 + CAF Main 273 0 0.0 0.0 0.0 0.0 + clauses Main Main.hs:68:1-74 280 1 0.0 0.0 0.0 0.0 + Main.clauses(calling:Data.Foldable.concat) Main Main.hs:68:1-7 282 1 0.0 0.0 0.0 0.0 + main Main Main.hs:(42,1)-(44,23) 274 1 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 298 1 0.0 0.0 0.0 0.0 + spaces Main Main.hs:160:1-19 322 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 251 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Encoding 232 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Encoding.Iconv 230 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Handle.FD 221 0 0.0 0.0 0.0 0.0 + main Main Main.hs:(42,1)-(44,23) 275 0 0.0 0.0 100.0 100.0 + main.\ Main Main.hs:44:3-23 276 1 0.0 0.0 100.0 100.0 + res Main Main.hs:(46,1)-(48,26) 277 1 0.0 0.0 100.0 99.9 + Main.main(calling:Data.Foldable.concat) Main Main.hs:42:1-4 278 1 0.0 0.0 0.0 0.0 + res.xs Main Main.hs:47:8-69 279 1 0.0 0.0 0.0 0.0 + clauses Main Main.hs:68:1-74 281 0 0.0 0.0 100.0 99.9 + disin Main Main.hs:(74,1)-(83,11) 286 857598 36.2 49.8 44.2 49.8 + conjunct Main Main.hs:(70,1)-(71,18) 310 759353 6.5 0.0 6.5 0.0 + disin.dp Main Main.hs:80:3-14 311 380009 1.4 0.0 1.4 0.0 + disin.dq Main Main.hs:81:3-14 312 380009 0.0 0.0 0.0 0.0 + negin Main Main.hs:(119,1)-(124,11) 287 1617 0.7 0.1 0.7 0.1 + elim Main Main.hs:(89,1)-(94,57) 288 1393 0.0 0.1 0.0 0.1 + disp Main Main.hs:86:1-71 320 7 0.0 0.0 0.0 0.0 + interleave Main Main.hs:(115,1)-(116,25) 321 35 0.0 0.0 0.0 0.0 + parse Main Main.hs:135:1-39 289 7 0.0 0.0 0.0 0.0 + parse.(...) Main Main.hs:135:19-39 291 7 0.0 0.0 0.0 0.0 + parse' Main Main.hs:(137,1)-(145,42) 292 280 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 295 56 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 293 56 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 294 49 0.0 0.0 0.0 0.0 + parse'.(...) Main Main.hs:142:20-49 297 21 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 299 0 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 301 63 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 302 63 0.0 0.0 0.0 0.0 + while Main Main.hs:182:1-48 300 63 0.0 0.0 0.0 0.0 + red Main Main.hs:(148,1)-(152,43) 303 42 0.0 0.0 0.0 0.0 + parse'.s' Main Main.hs:142:20-49 304 21 0.0 0.0 0.0 0.0 + parse'.x Main Main.hs:142:20-49 296 21 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 305 0 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 307 21 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 308 14 0.0 0.0 0.0 0.0 + while Main Main.hs:182:1-48 306 21 0.0 0.0 0.0 0.0 + red Main Main.hs:(148,1)-(152,43) 309 14 0.0 0.0 0.0 0.0 + parse.f Main Main.hs:135:19-39 290 7 0.0 0.0 0.0 0.0 + split Main Main.hs:(163,1)-(166,28) 284 7 0.0 0.0 3.6 2.3 + split.split' Main Main.hs:(165,11)-(166,28) 285 74837 3.6 2.3 3.6 2.3 + unicl Main Main.hs:(176,1)-(180,36) 283 7 0.0 1.1 51.4 47.7 + unicl.unicl' Main Main.hs:(178,11)-(180,36) 313 37422 2.2 2.0 51.4 46.6 + tautclause Main Main.hs:173:1-49 314 37422 3.6 3.7 3.6 3.7 + unicl.unicl'.cp Main Main.hs:180:24-36 315 37422 0.0 0.0 45.7 40.9 + clause Main Main.hs:(61,1)-(65,57) 316 37422 0.0 1.4 45.7 40.9 + clause.clause' Main Main.hs:(63,12)-(65,57) 317 696150 18.8 37.7 45.7 39.5 + insert Main Main.hs:(108,1)-(112,8) 318 366786 26.8 1.7 26.8 1.7 + insert Main Main.hs:(108,1)-(112,8) 319 7 0.0 0.0 0.0 0.0 ===================================== testsuite/tests/profiling/should_run/caller-cc/CallerCc2.prof.sample ===================================== @@ -1,78 +1,81 @@ - Fri Nov 13 01:06 2020 Time and Allocation Profiling Report (Final) + Thu Oct 12 08:47 2023 Time and Allocation Profiling Report (Final) CallerCc2 +RTS -hc -p -RTS 7 - total time = 0.09 secs (91 ticks @ 1000 us, 1 processor) - total alloc = 105,486,200 bytes (excludes profiling overheads) + total time = 0.13 secs (127 ticks @ 1000 us, 1 processor) + total alloc = 104,890,152 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc -disin Main Main.hs:(74,1)-(83,11) 26.4 49.5 -clause.clause' Main Main.hs:(63,12)-(65,57) 23.1 37.5 -insert Main Main.hs:(108,1)-(112,8) 18.7 1.7 -conjunct Main Main.hs:(70,1)-(71,18) 8.8 0.0 -unicl.unicl' Main Main.hs:(178,11)-(180,36) 5.5 2.6 -tautclause Main Main.hs:173:1-49 5.5 3.7 -unicl Main Main.hs:(176,1)-(180,36) 3.3 1.1 -split.split' Main Main.hs:(165,11)-(166,28) 3.3 2.3 -disin.dp Main Main.hs:80:3-14 3.3 0.0 -clause Main Main.hs:(61,1)-(65,57) 2.2 1.4 +disin Main Main.hs:(74,1)-(83,11) 32.3 49.8 +insert Main Main.hs:(108,1)-(112,8) 21.3 1.7 +clause.clause' Main Main.hs:(63,12)-(65,57) 20.5 37.7 +conjunct Main Main.hs:(70,1)-(71,18) 8.7 0.0 +tautclause Main Main.hs:173:1-49 6.3 3.7 +disin.dp Main Main.hs:80:3-14 3.9 0.0 +disin.dq Main Main.hs:81:3-14 2.4 0.0 +split.split' Main Main.hs:(165,11)-(166,28) 1.6 2.3 +parse' Main Main.hs:(137,1)-(145,42) 1.6 0.0 +unicl.unicl' Main Main.hs:(178,11)-(180,36) 0.8 2.0 +unicl Main Main.hs:(176,1)-(180,36) 0.8 1.1 +clause Main Main.hs:(61,1)-(65,57) 0.0 1.4 individual inherited COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc -MAIN MAIN 128 0 0.0 0.0 100.0 100.0 - CAF Main 255 0 0.0 0.0 0.0 0.0 - clauses Main Main.hs:68:1-74 261 1 0.0 0.0 0.0 0.0 - Main.clauses(calling:Data.Foldable.concat) Main Main.hs:68:1-7 263 1 0.0 0.0 0.0 0.0 - main Main Main.hs:(42,1)-(44,23) 256 1 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 279 1 0.0 0.0 0.0 0.0 - spaces Main Main.hs:160:1-19 303 1 0.0 0.0 0.0 0.0 - CAF GHC.Conc.Signal 246 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Encoding 235 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Encoding.Iconv 233 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Handle.FD 225 0 0.0 0.0 0.0 0.0 - main Main Main.hs:(42,1)-(44,23) 257 0 0.0 0.0 100.0 100.0 - res Main Main.hs:(46,1)-(48,26) 258 1 0.0 0.0 100.0 99.9 - Main.main(calling:Data.Foldable.concat) Main Main.hs:42:1-4 259 1 0.0 0.0 0.0 0.0 - res.xs Main Main.hs:47:8-69 260 1 0.0 0.0 0.0 0.0 - clauses Main Main.hs:68:1-74 262 0 0.0 0.0 100.0 99.9 - disin Main Main.hs:(74,1)-(83,11) 267 857598 26.4 49.5 38.5 49.5 - conjunct Main Main.hs:(70,1)-(71,18) 291 759353 8.8 0.0 8.8 0.0 - disin.dp Main Main.hs:80:3-14 292 380009 3.3 0.0 3.3 0.0 - disin.dq Main Main.hs:81:3-14 293 380009 0.0 0.0 0.0 0.0 - negin Main Main.hs:(119,1)-(124,11) 268 1617 0.0 0.1 0.0 0.1 - elim Main Main.hs:(89,1)-(94,57) 269 1393 0.0 0.1 0.0 0.1 - disp Main Main.hs:86:1-71 301 7 0.0 0.0 0.0 0.0 - interleave Main Main.hs:(115,1)-(116,25) 302 35 0.0 0.0 0.0 0.0 - parse Main Main.hs:135:1-39 270 7 0.0 0.0 0.0 0.0 - parse.(...) Main Main.hs:135:19-39 272 7 0.0 0.0 0.0 0.0 - parse' Main Main.hs:(137,1)-(145,42) 273 280 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 276 56 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 274 56 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 275 49 0.0 0.0 0.0 0.0 - parse'.(...) Main Main.hs:142:20-49 278 21 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 280 0 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 282 63 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 283 63 0.0 0.0 0.0 0.0 - while Main Main.hs:182:1-48 281 63 0.0 0.0 0.0 0.0 - red Main Main.hs:(148,1)-(152,43) 284 42 0.0 0.0 0.0 0.0 - parse'.s' Main Main.hs:142:20-49 285 21 0.0 0.0 0.0 0.0 - parse'.x Main Main.hs:142:20-49 277 21 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 286 0 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 288 21 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 289 14 0.0 0.0 0.0 0.0 - while Main Main.hs:182:1-48 287 21 0.0 0.0 0.0 0.0 - red Main Main.hs:(148,1)-(152,43) 290 14 0.0 0.0 0.0 0.0 - parse.f Main Main.hs:135:19-39 271 7 0.0 0.0 0.0 0.0 - split Main Main.hs:(163,1)-(166,28) 265 7 0.0 0.0 3.3 2.3 - split.split' Main Main.hs:(165,11)-(166,28) 266 74837 3.3 2.3 3.3 2.3 - unicl Main Main.hs:(176,1)-(180,36) 264 7 3.3 1.1 58.2 48.0 - unicl.unicl' Main Main.hs:(178,11)-(180,36) 294 37422 5.5 2.6 54.9 46.9 - tautclause Main Main.hs:173:1-49 295 37422 5.5 3.7 5.5 3.7 - unicl.unicl'.cp Main Main.hs:180:24-36 296 37422 0.0 0.0 44.0 40.6 - clause Main Main.hs:(61,1)-(65,57) 297 37422 2.2 1.4 44.0 40.6 - clause.clause' Main Main.hs:(63,12)-(65,57) 298 696150 23.1 37.5 41.8 39.2 - insert Main Main.hs:(108,1)-(112,8) 299 366786 18.7 1.7 18.7 1.7 - insert Main Main.hs:(108,1)-(112,8) 300 7 0.0 0.0 0.0 0.0 +MAIN MAIN 137 0 0.0 0.0 100.0 100.0 + CAF Main 273 0 0.0 0.0 0.0 0.0 + clauses Main Main.hs:68:1-74 280 1 0.0 0.0 0.0 0.0 + Main.clauses(calling:Data.Foldable.concat) Main Main.hs:68:1-7 282 1 0.0 0.0 0.0 0.0 + main Main Main.hs:(42,1)-(44,23) 274 1 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 298 1 0.0 0.0 0.0 0.0 + spaces Main Main.hs:160:1-19 322 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 251 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Encoding 232 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Encoding.Iconv 230 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Handle.FD 221 0 0.0 0.0 0.0 0.0 + main Main Main.hs:(42,1)-(44,23) 275 0 0.0 0.0 100.0 100.0 + main.\ Main Main.hs:44:3-23 276 1 0.0 0.0 100.0 100.0 + res Main Main.hs:(46,1)-(48,26) 277 1 0.0 0.0 100.0 99.9 + Main.main(calling:Data.Foldable.concat) Main Main.hs:42:1-4 278 1 0.0 0.0 0.0 0.0 + res.xs Main Main.hs:47:8-69 279 1 0.0 0.0 0.0 0.0 + clauses Main Main.hs:68:1-74 281 0 0.0 0.0 100.0 99.9 + disin Main Main.hs:(74,1)-(83,11) 286 857598 32.3 49.8 47.2 49.8 + conjunct Main Main.hs:(70,1)-(71,18) 310 759353 8.7 0.0 8.7 0.0 + disin.dp Main Main.hs:80:3-14 311 380009 3.9 0.0 3.9 0.0 + disin.dq Main Main.hs:81:3-14 312 380009 2.4 0.0 2.4 0.0 + negin Main Main.hs:(119,1)-(124,11) 287 1617 0.0 0.1 0.0 0.1 + elim Main Main.hs:(89,1)-(94,57) 288 1393 0.0 0.1 0.0 0.1 + disp Main Main.hs:86:1-71 320 7 0.0 0.0 0.0 0.0 + interleave Main Main.hs:(115,1)-(116,25) 321 35 0.0 0.0 0.0 0.0 + parse Main Main.hs:135:1-39 289 7 0.0 0.0 1.6 0.0 + parse.(...) Main Main.hs:135:19-39 291 7 0.0 0.0 1.6 0.0 + parse' Main Main.hs:(137,1)-(145,42) 292 280 1.6 0.0 1.6 0.0 + opri Main Main.hs:(127,1)-(132,12) 295 56 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 293 56 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 294 49 0.0 0.0 0.0 0.0 + parse'.(...) Main Main.hs:142:20-49 297 21 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 299 0 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 301 63 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 302 63 0.0 0.0 0.0 0.0 + while Main Main.hs:182:1-48 300 63 0.0 0.0 0.0 0.0 + red Main Main.hs:(148,1)-(152,43) 303 42 0.0 0.0 0.0 0.0 + parse'.s' Main Main.hs:142:20-49 304 21 0.0 0.0 0.0 0.0 + parse'.x Main Main.hs:142:20-49 296 21 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 305 0 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 307 21 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 308 14 0.0 0.0 0.0 0.0 + while Main Main.hs:182:1-48 306 21 0.0 0.0 0.0 0.0 + red Main Main.hs:(148,1)-(152,43) 309 14 0.0 0.0 0.0 0.0 + parse.f Main Main.hs:135:19-39 290 7 0.0 0.0 0.0 0.0 + split Main Main.hs:(163,1)-(166,28) 284 7 0.0 0.0 1.6 2.3 + split.split' Main Main.hs:(165,11)-(166,28) 285 74837 1.6 2.3 1.6 2.3 + unicl Main Main.hs:(176,1)-(180,36) 283 7 0.8 1.1 49.6 47.7 + unicl.unicl' Main Main.hs:(178,11)-(180,36) 313 37422 0.8 2.0 48.8 46.6 + tautclause Main Main.hs:173:1-49 314 37422 6.3 3.7 6.3 3.7 + unicl.unicl'.cp Main Main.hs:180:24-36 315 37422 0.0 0.0 41.7 40.9 + clause Main Main.hs:(61,1)-(65,57) 316 37422 0.0 1.4 41.7 40.9 + clause.clause' Main Main.hs:(63,12)-(65,57) 317 696150 20.5 37.7 41.7 39.5 + insert Main Main.hs:(108,1)-(112,8) 318 366786 21.3 1.7 21.3 1.7 + insert Main Main.hs:(108,1)-(112,8) 319 7 0.0 0.0 0.0 0.0 ===================================== testsuite/tests/profiling/should_run/caller-cc/CallerCc3.prof.sample ===================================== @@ -1,78 +1,78 @@ - Fri Nov 13 01:06 2020 Time and Allocation Profiling Report (Final) + Thu Oct 12 08:47 2023 Time and Allocation Profiling Report (Final) CallerCc3 +RTS -hc -p -RTS 7 - total time = 0.09 secs (85 ticks @ 1000 us, 1 processor) - total alloc = 105,486,200 bytes (excludes profiling overheads) + total time = 0.21 secs (208 ticks @ 1000 us, 1 processor) + total alloc = 104,890,152 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc -disin Main Main.hs:(74,1)-(83,11) 29.4 49.5 -insert Main Main.hs:(108,1)-(112,8) 24.7 1.7 -clause.clause' Main Main.hs:(63,12)-(65,57) 23.5 37.5 -conjunct Main Main.hs:(70,1)-(71,18) 10.6 0.0 -tautclause Main Main.hs:173:1-49 4.7 3.7 -unicl.unicl' Main Main.hs:(178,11)-(180,36) 3.5 2.6 -split.split' Main Main.hs:(165,11)-(166,28) 2.4 2.3 -disin.dp Main Main.hs:80:3-14 1.2 0.0 -unicl Main Main.hs:(176,1)-(180,36) 0.0 1.1 +disin Main Main.hs:(74,1)-(83,11) 29.8 49.8 +insert Main Main.hs:(108,1)-(112,8) 28.8 1.7 +clause.clause' Main Main.hs:(63,12)-(65,57) 22.6 37.7 +conjunct Main Main.hs:(70,1)-(71,18) 8.2 0.0 +tautclause Main Main.hs:173:1-49 5.8 3.7 +unicl.unicl' Main Main.hs:(178,11)-(180,36) 1.4 2.0 +split.split' Main Main.hs:(165,11)-(166,28) 1.4 2.3 +unicl Main Main.hs:(176,1)-(180,36) 0.5 1.1 clause Main Main.hs:(61,1)-(65,57) 0.0 1.4 individual inherited COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc -MAIN MAIN 128 0 0.0 0.0 100.0 100.0 - CAF Main 255 0 0.0 0.0 0.0 0.0 - clauses Main Main.hs:68:1-74 261 1 0.0 0.0 0.0 0.0 - Main.clauses(calling:Data.Foldable.concat) Main Main.hs:68:1-7 263 1 0.0 0.0 0.0 0.0 - main Main Main.hs:(42,1)-(44,23) 256 1 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 279 1 0.0 0.0 0.0 0.0 - spaces Main Main.hs:160:1-19 303 1 0.0 0.0 0.0 0.0 - CAF GHC.Conc.Signal 246 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Encoding 235 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Encoding.Iconv 233 0 0.0 0.0 0.0 0.0 - CAF GHC.IO.Handle.FD 225 0 0.0 0.0 0.0 0.0 - main Main Main.hs:(42,1)-(44,23) 257 0 0.0 0.0 100.0 100.0 - res Main Main.hs:(46,1)-(48,26) 258 1 0.0 0.0 100.0 99.9 - Main.main(calling:Data.Foldable.concat) Main Main.hs:42:1-4 259 1 0.0 0.0 0.0 0.0 - res.xs Main Main.hs:47:8-69 260 1 0.0 0.0 0.0 0.0 - clauses Main Main.hs:68:1-74 262 0 0.0 0.0 100.0 99.9 - disin Main Main.hs:(74,1)-(83,11) 267 857598 29.4 49.5 41.2 49.5 - conjunct Main Main.hs:(70,1)-(71,18) 291 759353 10.6 0.0 10.6 0.0 - disin.dp Main Main.hs:80:3-14 292 380009 1.2 0.0 1.2 0.0 - disin.dq Main Main.hs:81:3-14 293 380009 0.0 0.0 0.0 0.0 - negin Main Main.hs:(119,1)-(124,11) 268 1617 0.0 0.1 0.0 0.1 - elim Main Main.hs:(89,1)-(94,57) 269 1393 0.0 0.1 0.0 0.1 - disp Main Main.hs:86:1-71 301 7 0.0 0.0 0.0 0.0 - interleave Main Main.hs:(115,1)-(116,25) 302 35 0.0 0.0 0.0 0.0 - parse Main Main.hs:135:1-39 270 7 0.0 0.0 0.0 0.0 - parse.(...) Main Main.hs:135:19-39 272 7 0.0 0.0 0.0 0.0 - parse' Main Main.hs:(137,1)-(145,42) 273 280 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 276 56 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 274 56 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 275 49 0.0 0.0 0.0 0.0 - parse'.(...) Main Main.hs:142:20-49 278 21 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 280 0 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 282 63 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 283 63 0.0 0.0 0.0 0.0 - while Main Main.hs:182:1-48 281 63 0.0 0.0 0.0 0.0 - red Main Main.hs:(148,1)-(152,43) 284 42 0.0 0.0 0.0 0.0 - parse'.s' Main Main.hs:142:20-49 285 21 0.0 0.0 0.0 0.0 - parse'.x Main Main.hs:142:20-49 277 21 0.0 0.0 0.0 0.0 - redstar Main Main.hs:155:1-35 286 0 0.0 0.0 0.0 0.0 - spri Main Main.hs:(169,1)-(170,10) 288 21 0.0 0.0 0.0 0.0 - opri Main Main.hs:(127,1)-(132,12) 289 14 0.0 0.0 0.0 0.0 - while Main Main.hs:182:1-48 287 21 0.0 0.0 0.0 0.0 - red Main Main.hs:(148,1)-(152,43) 290 14 0.0 0.0 0.0 0.0 - parse.f Main Main.hs:135:19-39 271 7 0.0 0.0 0.0 0.0 - split Main Main.hs:(163,1)-(166,28) 265 7 0.0 0.0 2.4 2.3 - split.split' Main Main.hs:(165,11)-(166,28) 266 74837 2.4 2.3 2.4 2.3 - unicl Main Main.hs:(176,1)-(180,36) 264 7 0.0 1.1 56.5 48.0 - unicl.unicl' Main Main.hs:(178,11)-(180,36) 294 37422 3.5 2.6 56.5 46.9 - tautclause Main Main.hs:173:1-49 295 37422 4.7 3.7 4.7 3.7 - unicl.unicl'.cp Main Main.hs:180:24-36 296 37422 0.0 0.0 48.2 40.6 - clause Main Main.hs:(61,1)-(65,57) 297 37422 0.0 1.4 48.2 40.6 - clause.clause' Main Main.hs:(63,12)-(65,57) 298 696150 23.5 37.5 48.2 39.2 - insert Main Main.hs:(108,1)-(112,8) 299 366786 24.7 1.7 24.7 1.7 - insert Main Main.hs:(108,1)-(112,8) 300 7 0.0 0.0 0.0 0.0 +MAIN MAIN 137 0 0.0 0.0 100.0 100.0 + CAF Main 273 0 0.0 0.0 0.0 0.0 + clauses Main Main.hs:68:1-74 280 1 0.0 0.0 0.0 0.0 + Main.clauses(calling:Data.Foldable.concat) Main Main.hs:68:1-7 282 1 0.0 0.0 0.0 0.0 + main Main Main.hs:(42,1)-(44,23) 274 1 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 298 1 0.0 0.0 0.0 0.0 + spaces Main Main.hs:160:1-19 322 1 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 251 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Encoding 232 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Encoding.Iconv 230 0 0.0 0.0 0.0 0.0 + CAF GHC.IO.Handle.FD 221 0 0.0 0.0 0.0 0.0 + main Main Main.hs:(42,1)-(44,23) 275 0 0.0 0.0 100.0 100.0 + main.\ Main Main.hs:44:3-23 276 1 0.0 0.0 100.0 100.0 + res Main Main.hs:(46,1)-(48,26) 277 1 0.0 0.0 100.0 99.9 + Main.main(calling:Data.Foldable.concat) Main Main.hs:42:1-4 278 1 0.0 0.0 0.0 0.0 + res.xs Main Main.hs:47:8-69 279 1 0.0 0.0 0.0 0.0 + clauses Main Main.hs:68:1-74 281 0 0.0 0.0 100.0 99.9 + disin Main Main.hs:(74,1)-(83,11) 286 857598 29.8 49.8 39.4 49.8 + conjunct Main Main.hs:(70,1)-(71,18) 310 759353 8.2 0.0 8.2 0.0 + disin.dp Main Main.hs:80:3-14 311 380009 1.0 0.0 1.0 0.0 + disin.dq Main Main.hs:81:3-14 312 380009 0.5 0.0 0.5 0.0 + negin Main Main.hs:(119,1)-(124,11) 287 1617 0.0 0.1 0.0 0.1 + elim Main Main.hs:(89,1)-(94,57) 288 1393 0.0 0.1 0.0 0.1 + disp Main Main.hs:86:1-71 320 7 0.0 0.0 0.0 0.0 + interleave Main Main.hs:(115,1)-(116,25) 321 35 0.0 0.0 0.0 0.0 + parse Main Main.hs:135:1-39 289 7 0.0 0.0 0.0 0.0 + parse.(...) Main Main.hs:135:19-39 291 7 0.0 0.0 0.0 0.0 + parse' Main Main.hs:(137,1)-(145,42) 292 280 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 295 56 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 293 56 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 294 49 0.0 0.0 0.0 0.0 + parse'.(...) Main Main.hs:142:20-49 297 21 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 299 0 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 301 63 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 302 63 0.0 0.0 0.0 0.0 + while Main Main.hs:182:1-48 300 63 0.0 0.0 0.0 0.0 + red Main Main.hs:(148,1)-(152,43) 303 42 0.0 0.0 0.0 0.0 + parse'.s' Main Main.hs:142:20-49 304 21 0.0 0.0 0.0 0.0 + parse'.x Main Main.hs:142:20-49 296 21 0.0 0.0 0.0 0.0 + redstar Main Main.hs:155:1-35 305 0 0.0 0.0 0.0 0.0 + spri Main Main.hs:(169,1)-(170,10) 307 21 0.0 0.0 0.0 0.0 + opri Main Main.hs:(127,1)-(132,12) 308 14 0.0 0.0 0.0 0.0 + while Main Main.hs:182:1-48 306 21 0.0 0.0 0.0 0.0 + red Main Main.hs:(148,1)-(152,43) 309 14 0.0 0.0 0.0 0.0 + parse.f Main Main.hs:135:19-39 290 7 0.0 0.0 0.0 0.0 + split Main Main.hs:(163,1)-(166,28) 284 7 0.0 0.0 1.4 2.3 + split.split' Main Main.hs:(165,11)-(166,28) 285 74837 1.4 2.3 1.4 2.3 + unicl Main Main.hs:(176,1)-(180,36) 283 7 0.5 1.1 59.1 47.7 + unicl.unicl' Main Main.hs:(178,11)-(180,36) 313 37422 1.4 2.0 58.7 46.6 + tautclause Main Main.hs:173:1-49 314 37422 5.8 3.7 5.8 3.7 + unicl.unicl'.cp Main Main.hs:180:24-36 315 37422 0.0 0.0 51.4 40.9 + clause Main Main.hs:(61,1)-(65,57) 316 37422 0.0 1.4 51.4 40.9 + clause.clause' Main Main.hs:(63,12)-(65,57) 317 696150 22.6 37.7 51.4 39.5 + insert Main Main.hs:(108,1)-(112,8) 318 366786 28.8 1.7 28.8 1.7 + insert Main Main.hs:(108,1)-(112,8) 319 7 0.0 0.0 0.0 0.0 ===================================== testsuite/tests/profiling/should_run/callstack001.stdout ===================================== @@ -1,2 +1,2 @@ -["Main.main (callstack001.hs:17:8-21)","Main.mapM (callstack001.hs:10:13-17)","Main.mapM.go (callstack001.hs:13:17-19)","Main.f (callstack001.hs:7:10-35)"] -["Main.main (callstack001.hs:17:8-21)","Main.mapM (callstack001.hs:10:13-17)","Main.mapM.go (callstack001.hs:13:17-19)","Main.f (callstack001.hs:7:10-35)"] +["Main.main (callstack001.hs:17:8-21)","Main.mapM (callstack001.hs:10:13-17)","Main.mapM.go (callstack001.hs:(12,21)-(15,25))","Main.mapM.go (callstack001.hs:13:17-19)","Main.f (callstack001.hs:7:10-35)"] +["Main.main (callstack001.hs:17:8-21)","Main.mapM (callstack001.hs:10:13-17)","Main.mapM.go (callstack001.hs:(12,21)-(15,25))","Main.mapM.go (callstack001.hs:14:11-26)","Main.mapM.go (callstack001.hs:13:17-19)","Main.f (callstack001.hs:7:10-35)"] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6bfdbc2296fcba35cd7811e0159a7f488200874...ce8b71de1a9ffb49952972d0f2b537b30dcabe4c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6bfdbc2296fcba35cd7811e0159a7f488200874...ce8b71de1a9ffb49952972d0f2b537b30dcabe4c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 14:20:39 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 10:20:39 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/no-mingwex-in-configure Message-ID: <652800b719ca2_24a4456ec790c1210f@gitlab.mail> John Ericson deleted branch wip/no-mingwex-in-configure at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 14:20:40 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 10:20:40 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/test-mingwex-regression Message-ID: <652800b8e931e_24a4456cf43dc1212af@gitlab.mail> John Ericson deleted branch wip/test-mingwex-regression at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 14:31:42 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 12 Oct 2023 10:31:42 -0400 Subject: [Git][ghc/ghc][master] 9 commits: Move apple compat check to RTS configure Message-ID: <6528034ebf883_24a4456ee4b74133726@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - 4 changed files: - configure.ac - m4/fp_bfd_support.m4 - m4/fp_find_libffi.m4 - rts/configure.ac Changes: ===================================== configure.ac ===================================== @@ -951,18 +951,13 @@ dnl Keep that check as early as possible. dnl as we need to know whether we need libm dnl for math functions or not dnl (see https://gitlab.haskell.org/ghc/ghc/issues/3730) -AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO) -if test $HaveLibM = YES -then - AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm]) - AC_SUBST([UseLibm],[YES]) -else - AC_SUBST([UseLibm],[NO]) -fi -TargetHasLibm=$HaveLibM +AC_CHECK_LIB(m, atan, UseLibm=YES, UseLibm=NO) +AC_SUBST([UseLibm]) +TargetHasLibm=$UseLibm AC_SUBST(TargetHasLibm) -FP_BFD_SUPPORT +FP_BFD_FLAG +AC_SUBST([UseLibbfd]) dnl ################################################################ dnl Check for libraries @@ -970,70 +965,20 @@ dnl ################################################################ FP_FIND_LIBFFI AC_SUBST(UseSystemLibFFI) +AC_SUBST(FFILibDir) +AC_SUBST(FFIIncludeDir) dnl ** check whether we need -ldl to get dlopen() -AC_CHECK_LIB([dl], [dlopen]) -AC_CHECK_LIB([dl], [dlopen], HaveLibdl=YES, HaveLibdl=NO) -AC_SUBST([UseLibdl],[$HaveLibdl]) -dnl ** check whether we have dlinfo -AC_CHECK_FUNCS([dlinfo]) - -dnl -------------------------------------------------- -dnl * Miscellaneous feature tests -dnl -------------------------------------------------- - -dnl ** can we get alloca? -AC_FUNC_ALLOCA - -dnl ** working vfork? -AC_FUNC_FORK - -dnl ** determine whether or not const works -AC_C_CONST - -dnl ** are we big endian? -AC_C_BIGENDIAN -FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN +AC_CHECK_LIB([dl], [dlopen], UseLibdl=YES, UseLibdl=NO) +AC_SUBST([UseLibdl]) dnl ** check for leading underscores in symbol names FP_LEADING_UNDERSCORE AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`]) -if test x"$fptools_cv_leading_underscore" = xyes; then - AC_SUBST([CabalLeadingUnderscore],[True]) - AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.]) -else - AC_SUBST([CabalLeadingUnderscore],[False]) -fi - -FP_VISIBILITY_HIDDEN - -FP_MUSTTAIL dnl ** check for librt -AC_CHECK_LIB([rt], [clock_gettime]) -AC_CHECK_LIB([rt], [clock_gettime], HaveLibrt=YES, HaveLibrt=NO) -if test $HaveLibrt = YES -then - AC_SUBST([UseLibrt],[YES]) -else - AC_SUBST([UseLibrt],[NO]) -fi -AC_CHECK_FUNCS(clock_gettime timer_settime) -FP_CHECK_TIMER_CREATE - -dnl ** check for Apple's "interesting" long double compatibility scheme -AC_MSG_CHECKING(for printf\$LDBLStub) -AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])], - [ - AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1], - [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) - ], - [ - AC_MSG_RESULT(no) - AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0], - [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) - ]) +AC_CHECK_LIB([rt], [clock_gettime], UseLibrt=YES, UseLibrt=NO) +AC_SUBST([UseLibrt]) FP_CHECK_PTHREAD_LIB AC_SUBST([UseLibpthread]) ===================================== m4/fp_bfd_support.m4 ===================================== @@ -1,49 +1,59 @@ # FP_BFD_SUPPORT() # ---------------------- -# whether to use libbfd for debugging RTS -AC_DEFUN([FP_BFD_SUPPORT], [ - HaveLibbfd=NO - AC_ARG_ENABLE(bfd-debug, - [AS_HELP_STRING([--enable-bfd-debug], - [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])], - [ - # don't pollute general LIBS environment - save_LIBS="$LIBS" - AC_CHECK_HEADERS([bfd.h]) - dnl ** check whether this machine has BFD and libiberty installed (used for debugging) - dnl the order of these tests matters: bfd needs libiberty - AC_CHECK_LIB(iberty, xmalloc) - dnl 'bfd_init' is a rare non-macro in libbfd - AC_CHECK_LIB(bfd, bfd_init) +# Whether to use libbfd for debugging RTS +# +# Sets: +# UseLibbfd: [YES|NO] +AC_DEFUN([FP_BFD_FLAG], [ + UseLibbfd=NO + AC_ARG_ENABLE(bfd-debug, + [AS_HELP_STRING([--enable-bfd-debug], + [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])], + [UseLibbfd=YES], + [UseLibbfd=NO]) +]) + +# FP_WHEN_ENABLED_BFD +# ---------------------- +# Checks for libraries in the default way, which will define various +# `HAVE_*` macros. +AC_DEFUN([FP_WHEN_ENABLED_BFD], [ + # don't pollute general LIBS environment + save_LIBS="$LIBS" + AC_CHECK_HEADERS([bfd.h]) + dnl ** check whether this machine has BFD and libiberty installed (used for debugging) + dnl the order of these tests matters: bfd needs libiberty + AC_CHECK_LIB(iberty, xmalloc) + dnl 'bfd_init' is a rare non-macro in libbfd + AC_CHECK_LIB(bfd, bfd_init) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[ - /* mimic our rts/Printer.c */ - bfd* abfd; - const char * name; - char **matching; + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[ + /* mimic our rts/Printer.c */ + bfd* abfd; + const char * name; + char **matching; - name = "some.executable"; - bfd_init(); - abfd = bfd_openr(name, "default"); - bfd_check_format_matches (abfd, bfd_object, &matching); - { - long storage_needed; - storage_needed = bfd_get_symtab_upper_bound (abfd); - } - { - asymbol **symbol_table; - long number_of_symbols; - symbol_info info; + name = "some.executable"; + bfd_init(); + abfd = bfd_openr(name, "default"); + bfd_check_format_matches (abfd, bfd_object, &matching); + { + long storage_needed; + storage_needed = bfd_get_symtab_upper_bound (abfd); + } + { + asymbol **symbol_table; + long number_of_symbols; + symbol_info info; - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - bfd_get_symbol_info(abfd,symbol_table[0],&info); - } - ]])], - HaveLibbfd=YES,dnl bfd seems to work - [AC_MSG_ERROR([can't use 'bfd' library])]) - LIBS="$save_LIBS" - ] - ) - AC_SUBST([UseLibbfd],[$HaveLibbfd]) + number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); + bfd_get_symbol_info(abfd,symbol_table[0],&info); + } + ]])], + [], dnl bfd seems to work + [AC_MSG_ERROR([can't use 'bfd' library])]) + LIBS="$save_LIBS" ]) ===================================== m4/fp_find_libffi.m4 ===================================== @@ -1,6 +1,11 @@ -dnl ** Have libffi? -dnl -------------------------------------------------------------- -dnl Sets UseSystemLibFFI. +# FP_FIND_LIBFFI +# -------------------------------------------------------------- +# Should we used libffi? (yes or no) +# +# Sets variables: +# - UseSystemLibFFI: [YES|NO] +# - FFILibDir: optional path +# - FFIIncludeDir: optional path AC_DEFUN([FP_FIND_LIBFFI], [ # system libffi @@ -28,8 +33,6 @@ AC_DEFUN([FP_FIND_LIBFFI], fi ]) - AC_SUBST(FFIIncludeDir) - AC_ARG_WITH([ffi-libraries], [AS_HELP_STRING([--with-ffi-libraries=ARG], [Find libffi in ARG [default=system default]]) @@ -42,8 +45,6 @@ AC_DEFUN([FP_FIND_LIBFFI], fi ]) - AC_SUBST(FFILibDir) - AS_IF([test "$UseSystemLibFFI" = "YES"], [ CFLAGS2="$CFLAGS" CFLAGS="$LIBFFI_CFLAGS $CFLAGS" @@ -63,7 +64,7 @@ AC_DEFUN([FP_FIND_LIBFFI], AC_CHECK_LIB(ffi, ffi_call, [AC_CHECK_HEADERS( [ffi.h], - [AC_DEFINE([HAVE_SYSTEM_LIBFFI], [1], [Define to 1 if you have libffi.])], + [], [AC_MSG_ERROR([Cannot find ffi.h for system libffi])] )], [AC_MSG_ERROR([Cannot find system libffi])] ===================================== rts/configure.ac ===================================== @@ -33,6 +33,70 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host]) FPTOOLS_SET_PLATFORM_VARS([host], [Host]) FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) +dnl ** check for math library +dnl Keep that check as early as possible. +dnl as we need to know whether we need libm +dnl for math functions or not +dnl (see https://gitlab.haskell.org/ghc/ghc/issues/3730) +AS_IF( + [test "$CABAL_FLAG_libm" = 1], + [AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])]) + +AS_IF([test "$CABAL_FLAG_libbfd" = 1], [FP_WHEN_ENABLED_BFD]) + +dnl ################################################################ +dnl Check for libraries +dnl ################################################################ + +dnl ** check whether we need -ldl to get dlopen() +AC_CHECK_LIB([dl], [dlopen]) +dnl ** check whether we have dlinfo +AC_CHECK_FUNCS([dlinfo]) + +dnl -------------------------------------------------- +dnl * Miscellaneous feature tests +dnl -------------------------------------------------- + +dnl ** can we get alloca? +AC_FUNC_ALLOCA + +dnl ** working vfork? +AC_FUNC_FORK + +dnl ** determine whether or not const works +AC_C_CONST + +dnl ** are we big endian? +AC_C_BIGENDIAN +FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN + +dnl ** check for leading underscores in symbol names +if test "$CABAL_FLAG_leading_underscore" = 1; then + AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.]) +fi + +FP_VISIBILITY_HIDDEN + +FP_MUSTTAIL + +dnl ** check for librt +AC_CHECK_FUNCS(clock_gettime timer_settime) +FP_CHECK_TIMER_CREATE + +dnl ** check for Apple's "interesting" long double compatibility scheme +AC_MSG_CHECKING(for printf\$LDBLStub) +AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])], + [ + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1], + [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) + ], + [ + AC_MSG_RESULT(no) + AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0], + [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).]) + ]) + FP_CHECK_PTHREAD_FUNCS dnl ** check for eventfd which is needed by the I/O manager View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df81536f2e53abf521a05eb1e482a076f5849c21...f64f44e9ebbe4ed59265d91bd3b483c1fbcd5b0e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df81536f2e53abf521a05eb1e482a076f5849c21...f64f44e9ebbe4ed59265d91bd3b483c1fbcd5b0e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 14:32:16 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 12 Oct 2023 10:32:16 -0400 Subject: [Git][ghc/ghc][master] CgUtils.fixStgRegStmt respect register width Message-ID: <6528037043695_24a4456f35ac41368c9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 1 changed file: - compiler/GHC/StgToCmm/CgUtils.hs Changes: ===================================== compiler/GHC/StgToCmm/CgUtils.hs ===================================== @@ -177,16 +177,18 @@ fixStgRegStmt platform stmt = fixAssign $ mapExpDeep fixExpr stmt (globalRegSpillType platform reg) NaturallyAligned - CmmRegOff (CmmGlobal reg_use) offset -> + CmmRegOff greg@(CmmGlobal reg) offset -> -- RegOf leaves are just a shorthand form. If the reg maps -- to a real reg, we keep the shorthand, otherwise, we just -- expand it and defer to the above code. - let reg = globalRegUseGlobalReg reg_use in - case reg `elem` activeStgRegs platform of + -- NB: to ensure type correctness we need to ensure the Add + -- as well as the Int need to be of the same size as the + -- register. + case globalRegUseGlobalReg reg `elem` activeStgRegs platform of True -> expr - False -> CmmMachOp (MO_Add (wordWidth platform)) [ - fixExpr (CmmReg (CmmGlobal reg_use)), + False -> CmmMachOp (MO_Add (cmmRegWidth greg)) [ + fixExpr (CmmReg greg), CmmLit (CmmInt (fromIntegral offset) - (wordWidth platform))] + (cmmRegWidth greg))] other_expr -> other_expr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dafc47091c9107dcf81e1e80a105f59211927c89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dafc47091c9107dcf81e1e80a105f59211927c89 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 15:19:54 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 11:19:54 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/rts-configure-1 Message-ID: <65280e9a4b4e1_24a4458e2fdf8137434@gitlab.mail> John Ericson deleted branch wip/rts-configure-1 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 15:24:30 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 11:24:30 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/rts-cabal-file-no-stage-specific-subst Message-ID: <65280fae95a12_24a4458ea492813784@gitlab.mail> John Ericson pushed new branch wip/rts-cabal-file-no-stage-specific-subst at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/rts-cabal-file-no-stage-specific-subst You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 15:38:14 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 11:38:14 -0400 Subject: [Git][ghc/ghc][wip/rts-cabal-file-no-stage-specific-subst] Do not substitute `@...@` for stage-specific values in cabal files Message-ID: <652812e65945b_24a4458f91fd414127f@gitlab.mail> John Ericson pushed to branch wip/rts-cabal-file-no-stage-specific-subst at Glasgow Haskell Compiler / GHC Commits: 1f209951 by John Ericson at 2023-10-12T11:36:54-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 6 changed files: - .gitignore - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal - rts/.gitignore - rts/rts.cabal.in → rts/rts.cabal Changes: ===================================== .gitignore ===================================== @@ -167,7 +167,6 @@ _darcs/ /libraries/ghc-boot-th/ghc-boot-th.cabal /libraries/ghc-boot-th/ghc.mk /libraries/ghc-heap/ghc-heap.cabal -/libraries/ghc-prim/ghc-prim.cabal /libraries/ghci/GNUmakefile /libraries/ghci/ghci.cabal /libraries/ghci/ghc.mk ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -268,17 +268,6 @@ runInterpolations (Interpolations mk_substs) input = do subst = foldr (.) id [replace ("@"++k++"@") v | (k,v) <- substs] return (subst input) -toCabalBool :: Bool -> String -toCabalBool True = "True" -toCabalBool False = "False" - --- | Interpolate the given variable with the value of the given 'Flag', using --- Cabal's boolean syntax. -interpolateCabalFlag :: String -> Flag -> Interpolations -interpolateCabalFlag name flg = interpolateVar name $ do - val <- flag flg - return (toCabalBool val) - -- | Interpolate the given variable with the value of the given 'Setting'. interpolateSetting :: String -> Setting -> Interpolations interpolateSetting name settng = interpolateVar name $ setting settng @@ -290,31 +279,6 @@ projectVersion = mconcat , interpolateSetting "ProjectVersionMunged" ProjectVersionMunged ] -rtsCabalFlags :: Interpolations -rtsCabalFlags = mconcat - [ flag "CabalHaveLibdw" UseLibdw - , flag "CabalHaveLibm" UseLibm - , flag "CabalHaveLibrt" UseLibrt - , flag "CabalHaveLibdl" UseLibdl - , flag "CabalNeedLibpthread" UseLibpthread - , flag "CabalHaveLibbfd" UseLibbfd - , flag "CabalHaveLibNuma" UseLibnuma - , flag "CabalHaveLibZstd" UseLibzstd - , flag "CabalStaticLibZstd" StaticLibzstd - , flag "CabalNeedLibatomic" NeedLibatomic - , flag "CabalUseSystemLibFFI" UseSystemFfi - , targetFlag "CabalLibffiAdjustors" tgtUseLibffiForAdjustors - , targetFlag "CabalLeadingUnderscore" tgtSymbolsHaveLeadingUnderscore - ] - where - flag = interpolateCabalFlag - targetFlag name q = interpolateVar name $ do - val <- queryTargetTarget q - return (toCabalBool val) - -ghcPrimCabalFlags :: Interpolations -ghcPrimCabalFlags = interpolateCabalFlag "CabalNeedLibatomic" NeedLibatomic - packageVersions :: Interpolations packageVersions = foldMap f [ base, ghcPrim, compiler, ghc, cabal, templateHaskell, ghcCompact, array ] where @@ -347,8 +311,6 @@ templateRule outPath interps = do templateRules :: Rules () templateRules = do templateRule "compiler/ghc.cabal" $ projectVersion - templateRule "rts/rts.cabal" $ rtsCabalFlags - templateRule "libraries/ghc-prim/ghc-prim.cabal" $ ghcPrimCabalFlags templateRule "driver/ghci/ghci-wrapper.cabal" $ projectVersion templateRule "ghc/ghc-bin.cabal" $ projectVersion templateRule "utils/iserv/iserv.cabal" $ projectVersion ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -114,7 +114,7 @@ packageArgs = do -------------------------------- ghcPrim ------------------------------- , package ghcPrim ? mconcat - [ builder (Cabal Flags) ? arg "include-ghc-prim" + [ builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic" , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ? input "**/cbits/atomic.c" ? arg "-Wno-sync-nand" ] @@ -281,8 +281,8 @@ rtsPackageArgs = package rts ? do targetArch <- queryTarget queryArch targetOs <- queryTarget queryOS targetVendor <- queryTarget queryVendor - ghcUnreg <- yesNo <$> queryTarget tgtUnregisterised - ghcEnableTNC <- yesNo <$> queryTarget tgtTablesNextToCode + ghcUnreg <- queryTarget tgtUnregisterised + ghcEnableTNC <- queryTarget tgtTablesNextToCode rtsWays <- getRtsWays way <- getWay path <- getBuildPath @@ -355,8 +355,8 @@ rtsPackageArgs = package rts ? do , "-DTargetArch=" ++ show targetArch , "-DTargetOS=" ++ show targetOs , "-DTargetVendor=" ++ show targetVendor - , "-DGhcUnregisterised=" ++ show ghcUnreg - , "-DTablesNextToCode=" ++ show ghcEnableTNC + , "-DGhcUnregisterised=" ++ show (yesNo ghcUnreg) + , "-DTablesNextToCode=" ++ show (yesNo ghcEnableTNC) , "-DRtsWay=\"rts_" ++ show way ++ "\"" ] @@ -401,8 +401,21 @@ rtsPackageArgs = package rts ? do , any (wayUnit Debug) rtsWays `cabalFlag` "debug" , any (wayUnit Dynamic) rtsWays `cabalFlag` "dynamic" , any (wayUnit Threaded) rtsWays `cabalFlag` "threaded" + , ghcEnableTNC `cabalFlag` "tables-next-to-code" + , ghcUnreg `cabalFlag` "unregisterised" + , flag UseLibm `cabalFlag` "libm" + , flag UseLibrt `cabalFlag` "librt" + , flag UseLibdl `cabalFlag` "libdl" , useSystemFfi `cabalFlag` "use-system-libffi" , useLibffiForAdjustors `cabalFlag` "libffi-adjustors" + , flag UseLibpthread `cabalFlag` "need-pthread" + , flag UseLibbfd `cabalFlag` "libbfd" + , flag NeedLibatomic `cabalFlag` "need-atomic" + , flag UseLibdw `cabalFlag` "libdw" + , flag UseLibnuma `cabalFlag` "libnuma" + , flag UseLibzstd `cabalFlag` "libzstd" + , flag StaticLibzstd `cabalFlag` "static-libzstd" + , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore" , Debug `wayUnit` way `cabalFlag` "find-ptr" ] , builder (Cabal Setup) ? mconcat ===================================== libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -28,7 +28,7 @@ custom-setup setup-depends: base >= 4 && < 5, process, filepath, directory, Cabal >= 1.23 && < 3.9 flag need-atomic - default: @CabalNeedLibatomic@ + default: False Library default-language: Haskell2010 ===================================== rts/.gitignore ===================================== @@ -2,8 +2,6 @@ /dist/ /dist-*/ -/rts.cabal - /include/ghcversion.h /package.conf.inplace ===================================== rts/rts.cabal.in → rts/rts.cabal ===================================== @@ -29,31 +29,31 @@ source-repository head subdir: rts flag libm - default: @CabalHaveLibm@ + default: False flag librt - default: @CabalHaveLibrt@ + default: False flag libdl - default: @CabalHaveLibdl@ + default: False flag use-system-libffi - default: @CabalUseSystemLibFFI@ + default: False flag libffi-adjustors - default: @CabalLibffiAdjustors@ + default: False flag need-pthread - default: @CabalNeedLibpthread@ + default: False flag libbfd - default: @CabalHaveLibbfd@ + default: False flag need-atomic - default: @CabalNeedLibatomic@ + default: False flag libdw - default: @CabalHaveLibdw@ + default: False flag libnuma - default: @CabalHaveLibNuma@ + default: False flag libzstd - default: @CabalHaveLibZstd@ + default: False flag static-libzstd - default: @CabalStaticLibZstd@ + default: False flag leading-underscore - default: @CabalLeadingUnderscore@ + default: False flag smp default: True flag find-ptr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f209951f5683e72b4d83a9739c2ab4d37cc99f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f209951f5683e72b4d83a9739c2ab4d37cc99f8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 15:44:17 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 11:44:17 -0400 Subject: [Git][ghc/ghc][wip/rts-configure] 22 commits: Test that functions from `mingwex` are available Message-ID: <6528145116ada_24a4458f79ad8143894@gitlab.mail> John Ericson pushed to branch wip/rts-configure at Glasgow Haskell Compiler / GHC Commits: 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 1f209951 by John Ericson at 2023-10-12T11:36:54-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 041d3cfb by John Ericson at 2023-10-12T11:38:51-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - b67f3795 by John Ericson at 2023-10-12T11:38:51-04:00 Move over a number of C-style checks to RTS configure - - - - - b5a2feec by John Ericson at 2023-10-12T11:38:51-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - 80ce7a8f by John Ericson at 2023-10-12T11:39:22-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - b9c24368 by John Ericson at 2023-10-12T11:39:23-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 830a78d3 by John Ericson at 2023-10-12T11:39:48-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - eaef63d4 by John Ericson at 2023-10-12T11:42:07-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - 30 changed files: - .gitignore - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/CgUtils.hs - configure.ac - distrib/cross-port - docs/coding-style.html - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Settings/Packages.hs - libraries/base/base.cabal - libraries/base/Control/Applicative.hs → libraries/base/src/Control/Applicative.hs - libraries/base/Control/Arrow.hs → libraries/base/src/Control/Arrow.hs - libraries/base/Control/Category.hs → libraries/base/src/Control/Category.hs - libraries/base/Control/Concurrent.hs → libraries/base/src/Control/Concurrent.hs - libraries/base/Control/Concurrent.hs-boot → libraries/base/src/Control/Concurrent.hs-boot - libraries/base/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs - libraries/base/Control/Concurrent/MVar.hs → libraries/base/src/Control/Concurrent/MVar.hs - libraries/base/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs - libraries/base/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs - libraries/base/Control/Exception.hs → libraries/base/src/Control/Exception.hs - libraries/base/Control/Exception/Base.hs → libraries/base/src/Control/Exception/Base.hs - libraries/base/Control/Monad.hs → libraries/base/src/Control/Monad.hs - libraries/base/Control/Monad/Fail.hs → libraries/base/src/Control/Monad/Fail.hs - libraries/base/Control/Monad/Fix.hs → libraries/base/src/Control/Monad/Fix.hs - libraries/base/Control/Monad/IO/Class.hs → libraries/base/src/Control/Monad/IO/Class.hs - libraries/base/Control/Monad/Instances.hs → libraries/base/src/Control/Monad/Instances.hs - libraries/base/Control/Monad/ST.hs → libraries/base/src/Control/Monad/ST.hs - libraries/base/Control/Monad/ST/Imp.hs → libraries/base/src/Control/Monad/ST/Imp.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d3f7d92b54a450151a474a9f4af8bed8b54fe0c...eaef63d4aa345fd0ea8400392084c69104da68ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d3f7d92b54a450151a474a9f4af8bed8b54fe0c...eaef63d4aa345fd0ea8400392084c69104da68ab You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 12 16:40:57 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 12 Oct 2023 12:40:57 -0400 Subject: [Git][ghc/ghc][wip/rts-configure] Get rid of all mention of `mk/config.h` Message-ID: <65282199c9c0c_24a445a8c00a01648ad@gitlab.mail> John Ericson pushed to branch wip/rts-configure at Glasgow Haskell Compiler / GHC Commits: ac288d14 by John Ericson at 2023-10-12T12:40:42-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - 7 changed files: - .gitignore - compiler/GHC/Builtin/primops.txt.pp - configure.ac - distrib/cross-port - docs/coding-style.html - hadrian/src/Rules/SourceDist.hs - rts/configure.ac Changes: ===================================== .gitignore ===================================== @@ -184,8 +184,8 @@ _darcs/ /linter.log /mk/are-validating.mk /mk/build.mk -/mk/config.h -/mk/config.h.in +/mk/unused.h +/mk/unused.h.in /mk/config.mk /mk/config.mk.old /mk/system-cxx-std-lib-1.0.conf ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -229,7 +229,7 @@ section "The word size story." must contain at least 30 bits. GHC always implements 'Int' using the primitive type 'Int#', whose size equals the @MachDeps.h@ constant @WORD\_SIZE\_IN\_BITS at . - This is normally set based on the @config.h@ parameter + This is normally set based on the RTS @ghcautoconf.h@ parameter @SIZEOF\_HSWORD@, i.e., 32 bits on 32-bit machines, 64 bits on 64-bit machines. ===================================== configure.ac ===================================== @@ -32,8 +32,8 @@ AC_CONFIG_MACRO_DIRS([m4]) # checkout), then we ship a file 'VERSION' containing the full version # when the source distribution was created. -if test ! -f mk/config.h.in; then - echo "mk/config.h.in doesn't exist: perhaps you haven't run 'python3 boot'?" +if test ! -f rts/ghcautoconf.h.autoconf.in; then + echo "rts/ghcautoconf.h.autoconf.in doesn't exist: perhaps you haven't run 'python3 boot'?" exit 1 fi @@ -101,8 +101,11 @@ AC_PREREQ([2.69]) # Prepare to generate the following header files # -# This one is autogenerated by autoheader. -AC_CONFIG_HEADER(mk/config.h) +dnl so the next header, which is manually maintained, doesn't get +dnl overwritten by an autogenerated header. Once we have no more +dnl `AC_CONFIG_HEADER` calls (issue #23966) we can delete all mention +dnl of `mk/unused.h`. +AC_CONFIG_HEADER(mk/unused.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) dnl manually outputted above, for reasons described there. ===================================== distrib/cross-port ===================================== @@ -28,7 +28,7 @@ if [ ! -f b1-stamp ]; then # For cross-compilation, at this stage you may want to set up a source # tree on the target machine, run the configure script there, and bring - # the resulting mk/config.h file back into this tree before building + # the resulting rts/ghcautoconf.h.autoconf file back into this tree before building # the libraries. touch mk/build.mk @@ -38,7 +38,7 @@ if [ ! -f b1-stamp ]; then # We could optimise slightly by not building hslibs here. Also, building # the RTS is not necessary (and might not be desirable if we're using - # a config.h from the target system). + # a ghcautoconf.h from the target system). make stage1 cd .. ===================================== docs/coding-style.html ===================================== @@ -108,7 +108,7 @@ POSIX-compliant to explicitly say so by having #include

  • Some architectures have memory alignment constraints. Others don't have any constraints but go faster if you align things. These -macros (from config.h) tell you which alignment to use +macros (from ghcautoconf.h) tell you which alignment to use
       /* minimum alignment of unsigned int */
    
    
    =====================================
    hadrian/src/Rules/SourceDist.hs
    =====================================
    @@ -156,7 +156,8 @@ prepareTree dest = do
           , pkgPath terminfo -/- "configure"
           , "configure"
           , "aclocal.m4"
    -      , "mk" -/- "config.h.in" ]
    +      , "mk" -/- "unused.h.in"
    +      ]
     
         copyAlexHappyFiles =
           forM_ alexHappyFiles $ \(stg, pkg, inp, out) -> do
    
    
    =====================================
    rts/configure.ac
    =====================================
    @@ -390,9 +390,9 @@ touch include/ghcautoconf.h
     
     echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h
     echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h
    -# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO
    +# Copy the contents of ghcautoconf.h.autoconf, turning '#define PACKAGE_FOO
     # "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
    -cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \
    +cat ghcautoconf.h.autoconf | sed \
        -e 's,^\([	 ]*\)#[	 ]*define[	 ][	 ]*\(PACKAGE_[A-Z]*\)[	 ][ 	]*".*".*$,\1/* #undef \2 */,' \
        -e '/__GLASGOW_HASKELL/d' \
        -e '/REMOVE ME/d' \
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac288d14bb99657393ff69a607c568702d3c65c7
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac288d14bb99657393ff69a607c568702d3c65c7
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 12 17:30:33 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Thu, 12 Oct 2023 13:30:33 -0400
    Subject: [Git][ghc/ghc][wip/no-narrow-n] 3705 commits: Document that
     `InScopeSet` is a superset of currently in-scope variables
    Message-ID: <65282d39820cd_24a445bd1c3f0173964@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/no-narrow-n at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    56b2b04f by Ziyang Liu at 2021-10-22T10:57:28-04:00
    Document that `InScopeSet` is a superset of currently in-scope variables
    
    - - - - -
    7f4e0e91 by Moritz Angermann at 2021-10-22T10:58:04-04:00
    Do not sign extend CmmInt's unless negative.
    
    Might fix #20526.
    - - - - -
    77c6f3e6 by sheaf at 2021-10-22T10:58:44-04:00
    Use tcEqType in GHC.Core.Unify.uVar
    
      Because uVar used eqType instead of tcEqType, it was possible
      to accumulate a substitution that unified Type and Constraint.
    
      For example, a call to `tc_unify_tys` with arguments
    
        tys1 = [ k, k ]
        tys2 = [ Type, Constraint ]
    
      would first add `k = Type` to the substitution. That's fine, but then
      the second call to `uVar` would claim that the substitution also
      unifies `k` with `Constraint`. This could then be used to cause
      trouble, as per #20521.
    
      Fixes #20521
    
    - - - - -
    fa5870d3 by Sylvain Henry at 2021-10-22T19:20:05-04:00
    Add test for #19641
    
    Now that Bignum predicates are inlined (!6696), we only need to add a
    test.
    
    Fix #19641
    
    - - - - -
    6fd7da74 by Sylvain Henry at 2021-10-22T19:20:44-04:00
    Remove Indefinite
    
    We no longer need it after previous IndefUnitId refactoring.
    
    - - - - -
    806e49ae by Sylvain Henry at 2021-10-22T19:20:44-04:00
    Refactor package imports
    
    Use an (Raw)PkgQual datatype instead of `Maybe FastString` to represent
    package imports. Factorize the code that renames RawPkgQual into PkgQual
    in function `rnPkgQual`. Renaming consists in checking if the FastString
    is the magic "this" keyword, the home-unit unit-id or something else.
    
    Bump haddock submodule
    
    - - - - -
    47ba842b by Haochen Tong at 2021-10-22T19:21:21-04:00
    Fix compilerConfig stages
    
    Fix the call to compilerConfig because it accepts 1-indexed stage
    numbers. Also fixes `make stage=3`.
    
    - - - - -
    621608c9 by Matthew Pickering at 2021-10-22T19:21:56-04:00
    driver: Don't use the log queue abstraction when j = 1
    
    This simplifies the code path for -j1 by not using the log queue queue
    abstraction. The result is that trace output isn't interleaved with
    other dump output like it can be with -j<N>.
    
    - - - - -
    dd2dba80 by Sebastian Graf at 2021-10-22T19:22:31-04:00
    WorkWrap: `isRecDataCon` should not eta-reduce NewTyCon field tys (#20539)
    
    In #20539 we had a type
    ```hs
    newtype Measured a = Measured { unmeasure :: () -> a }
    ```
    and `isRecDataCon Measured` recursed into `go_arg_ty` for `(->) ()`, because
    `unwrapNewTyConEtad_maybe` eta-reduced it. That triggered an assertion error a
    bit later. Eta reducing the field type is completely wrong to do here! Just call
    `unwrapNewTyCon_maybe` instead.
    
    Fixes #20539 and adds a regression test T20539.
    
    - - - - -
    8300ca2e by Ben Gamari at 2021-10-24T01:26:11-04:00
    driver: Export wWarningFlagMap
    
    A new feature requires Ghcide to be able to convert warnings to CLI
    flags (WarningFlag -> String). This is most easily implemented in terms
    of the internal function flagSpecOf, which uses an inefficient
    implementation based on linear search through a linked list. This PR
    derives Ord for WarningFlag, and replaces that list with a Map.
    
    Closes #19087.
    
    - - - - -
    3bab222c by Sebastian Graf at 2021-10-24T01:26:46-04:00
    DmdAnal: Implement Boxity Analysis (#19871)
    
    This patch fixes some abundant reboxing of `DynFlags` in
    `GHC.HsToCore.Match.Literal.warnAboutOverflowedLit` (which was the topic
    of #19407) by introducing a Boxity analysis to GHC, done as part of demand
    analysis. This allows to accurately capture ad-hoc unboxing decisions previously
    made in worker/wrapper in demand analysis now, where the boxity info can
    propagate through demand signatures.
    
    See the new `Note [Boxity analysis]`. The actual fix for #19407 is described in
    `Note [No lazy, Unboxed demand in demand signature]`, but
    `Note [Finalising boxity for demand signature]` is probably a better entry-point.
    
    To support the fix for #19407, I had to change (what was)
    `Note [Add demands for strict constructors]` a bit
    (now `Note [Unboxing evaluated arguments]`). In particular, we now take care of
    it in `finaliseBoxity` (which is only called from demand analaysis) instead of
    `wantToUnboxArg`.
    
    I also had to resurrect `Note [Product demands for function body]` and rename
    it to `Note [Unboxed demand on function bodies returning small products]` to
    avoid huge regressions in `join004` and `join007`, thereby fixing #4267 again.
    See the updated Note for details.
    
    A nice side-effect is that the worker/wrapper transformation no longer needs to
    look at strictness info and other bits such as `InsideInlineableFun` flags
    (needed for `Note [Do not unbox class dictionaries]`) at all. It simply collects
    boxity info from argument demands and interprets them with a severely simplified
    `wantToUnboxArg`. All the smartness is in `finaliseBoxity`, which could be moved
    to DmdAnal completely, if it wasn't for the call to `dubiousDataConInstArgTys`
    which would be awkward to export.
    
    I spent some time figuring out the reason for why `T16197` failed prior to my
    amendments to `Note [Unboxing evaluated arguments]`. After having it figured
    out, I minimised it a bit and added `T16197b`, which simply compares computed
    strictness signatures and thus should be far simpler to eyeball.
    
    The 12% ghc/alloc regression in T11545 is because of the additional `Boxity`
    field in `Poly` and `Prod` that results in more allocation during `lubSubDmd`
    and `plusSubDmd`. I made sure in the ticky profiles that the number of calls
    to those functions stayed the same. We can bear such an increase here, as we
    recently improved it by -68% (in b760c1f).
    T18698* regress slightly because there is more unboxing of dictionaries
    happening and that causes Lint (mostly) to allocate more.
    
    Fixes #19871, #19407, #4267, #16859, #18907 and #13331.
    
    Metric Increase:
        T11545
        T18698a
        T18698b
    
    Metric Decrease:
        T12425
        T16577
        T18223
        T18282
        T4267
        T9961
    
    - - - - -
    691c450f by Alan Zimmerman at 2021-10-24T01:27:21-04:00
    EPA: Use LocatedA for ModuleName
    
    This allows us to use an Anchor with a DeltaPos in it when exact
    printing.
    
    - - - - -
    3417a81a by Joachim Breitner at 2021-10-24T01:27:57-04:00
    undefined: Neater CallStack in error message
    
    Users of `undefined` don’t want to see
    ```
    files.hs: Prelude.undefined:
    CallStack (from HasCallStack):
      error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
      undefined, called at file.hs:151:19 in main:Main
    ```
    but want to see
    ```
    files.hs: Prelude.undefined:
    CallStack (from HasCallStack):
      undefined, called at file.hs:151:19 in main:Main
    ```
    so let’s make that so.
    
    The function for that is `withFrozenCallStack`, but that is not usable
    here (module dependencies, and also not representation-polymorphic). And
    even if it were, it could confuse GHC’s strictness analyzer, leading to
    big regressions in some perf tests (T10421 in particular).
    
    So after shuffling modules and definitions around, I eventually noticed
    that the easiest way is to just not call `error` here.
    
    Fixes #19886
    
    - - - - -
    98aa29d3 by John Ericson at 2021-10-24T01:28:33-04:00
    Fix dangling reference to RtsConfig.h
    
    It hasn't existed since a2a67cd520b9841114d69a87a423dabcb3b4368e -- in
    2009!
    
    - - - - -
    9cde38a0 by John Ericson at 2021-10-25T17:45:15-04:00
    Remove stray reference to `dist-ghcconstants`
    
    I think this hasn't been a thing since
    86054b4ab5125a8b71887b06786d0a428539fb9c, almost 10 years ago!
    
    - - - - -
    0f7541dc by Viktor Dukhovni at 2021-10-25T17:45:51-04:00
    Tweak descriptions of lines and unlines
    
    It seems more clear to think of lines as LF-terminated rather than
    LF-separated.
    
    - - - - -
    0255ef38 by Zubin Duggal at 2021-10-26T12:36:24-04:00
    Warn if unicode bidirectional formatting characters are found in the source (#20263)
    
    - - - - -
    9cc6c193 by sheaf at 2021-10-26T12:37:02-04:00
    Don't default type variables in type families
    
      This patch removes the following defaulting of type variables
      in type and data families:
    
        - type variables of kind RuntimeRep defaulting to LiftedRep
        - type variables of kind Levity defaulting to Lifted
        - type variables of kind Multiplicity defaulting to Many
    
      It does this by passing "defaulting options" to the `defaultTyVars`
      function; when calling from `tcTyFamInstEqnGuts` or
      `tcDataFamInstHeader` we pass options that avoid defaulting.
    
      This avoids wildcards being defaulted, which caused type families
      to unexpectedly fail to reduce.
    
      Note that kind defaulting, applicable only with -XNoPolyKinds,
      is not changed by this patch.
    
      Fixes #17536
    
    -------------------------
    Metric Increase:
        T12227
    -------------------------
    
    - - - - -
    cc113616 by Artyom Kuznetsov at 2021-10-26T20:27:33+00:00
    Change CaseAlt and LambdaExpr to FunRhs in deriving Foldable and Traversable (#20496)
    
    - - - - -
    9bd6daa4 by John Ericson at 2021-10-27T13:29:39-04:00
    Make build system: Generalize and/or document distdirs
    
    `manual-package-config` should not hard-code the distdir, and no
    longer does
    
    Elsewhere, we must continue to hard-code due to inconsitent distdir
    names across stages, so we document this referring to the existing note
    "inconsistent distdirs".
    
    - - - - -
    9d577ea1 by John Ericson at 2021-10-27T13:30:15-04:00
    Compiler dosen't need to know about certain settings from file
    
     - RTS and libdw
     - SMP
     - RTS ways
    
    I am leaving them in the settings file because `--info` currently prints
    all the fields in there, but in the future I do believe we should
    separate the info GHC actually needs from "extra metadata". The latter
    could go in `+RTS --info` and/or a separate file that ships with the RTS
    for compile-time inspection instead.
    
    - - - - -
    ed9ec655 by Ben Gamari at 2021-10-27T13:30:55-04:00
    base: Note export of Data.Tuple.Solo in changelog
    
    - - - - -
    638f6548 by Ben Gamari at 2021-10-27T13:30:55-04:00
    hadrian: Turn the `static` flavour into a transformer
    
    This turns the `static` flavour into the `+fully_static` flavour
    transformer.
    
    - - - - -
    522eab3f by Ziyang Liu at 2021-10-29T05:01:50-04:00
    Show family TyCons in mk_dict_error in the case of a single match
    
    - - - - -
    71700526 by Sebastian Graf at 2021-10-29T05:02:25-04:00
    Add more INLINABLE and INLINE pragmas to `Enum Int*` instances
    
    Otherwise the instances aren't good list producers.
    See Note [Stable Unfolding for list producers].
    
    - - - - -
    925c47b4 by Sebastian Graf at 2021-10-29T05:02:25-04:00
    WorkWrap: Update Unfolding with WW'd body prior to `tryWW` (#20510)
    
    We have a function in #20510 that is small enough to get a stable unfolding in WW:
    ```hs
    small :: Int -> Int
    small x = go 0 x
      where
        go z 0 = z * x
        go z y = go (z+y) (y-1)
    ```
    But it appears we failed to use the WW'd RHS as the stable unfolding. As a result,
    inlining `small` would expose the non-WW'd version of `go`. That appears to regress
    badly in #19727 which is a bit too large to extract a reproducer from that is
    guaranteed to reproduce across GHC versions.
    
    The solution is to simply update the unfolding in `certainlyWillInline` with the
    WW'd RHS.
    
    Fixes #20510.
    
    - - - - -
    7b67724b by John Ericson at 2021-10-29T16:57:48-04:00
    make build system: RTS should use dist-install not dist
    
    This is the following find and replace:
    
     - `rts/dist` -> `rts/dist-install` # for paths
     - `rts_dist` -> `rts_dist-install` # for make rules and vars
     - `,dist` -> `,dist-install` # for make, just in rts/ghc.mk`
    
    Why do this? Does it matter when the RTS is just built once? The answer
    is, yes, I think it does, because I want the distdir--stage
    correspondence to be consistent.
    
    In particular, for #17191 and continuing from
    d5de970dafd5876ef30601697576167f56b9c132 I am going to make the headers
    (`rts/includes`) increasingly the responsibility of the RTS (hence their
    new location). However, those headers are current made for multiple
    stages. This will probably become unnecessary as work on #17191
    progresses and the compiler proper becomes more of a freestanding cabal
    package (e.g. a library that can be downloaded from Hackage and built
    without any autoconf). However, until that is finished, we have will
    transitional period where the RTS and headers need to agree on dirs for
    multiple stages.
    
    I know the make build system is going away, but it's not going yet, so I
    need to change it to unblock things :).
    
    - - - - -
    b0a1ed55 by Sylvain Henry at 2021-10-29T16:58:35-04:00
    Add test for T15547 (#15547)
    
    Fix #15547
    
    - - - - -
    c8d89f62 by Sylvain Henry at 2021-10-29T16:58:35-04:00
    Bignum: add missing rule
    
    Add missing "Natural -> Integer -> Word#" rule.
    
    - - - - -
    2a4581ff by sheaf at 2021-10-29T16:59:13-04:00
    User's guide: data family kind-inference changes
    
      Explain that the kind of a data family instance must now be
      fully determined by the header of the instance, and how one
      might migrate code to account for this change.
    
      Fixes #20527
    
    - - - - -
    ea862ef5 by Ben Gamari at 2021-10-30T15:43:28-04:00
    ghci: Make getModBreaks robust against DotO Unlinked
    
    Previously getModBreaks assumed that an interpreted linkable will have
    only a single `BCOs` `Unlinked` entry. However, in general an object may
    also contain `DotO`s; ignore these.
    
    Fixes #20570.
    
    - - - - -
    e4095c0c by John Ericson at 2021-10-31T09:04:41-04:00
    Make build system: Put make generated include's in RTS distdirs
    
    These are best thought of as being part of the RTS.
    
     - After !6791, `ghcautoconf.h` won't be used by the compiler
       inappropriately.
    
     - `ghcversion.h` is only used once outside the RTS, which is
       `compiler/cbits/genSym.c`. Except we *do* mean the RTS GHC is built
       against there, so it's better if we always get get the installed
       version.
    
     - `ghcplatform.h` alone is used extensively outside the RTS, but
       since we no longer have a target platform it is perfectly
       safe/correct to get the info from the previous RTS.
    
    All 3 are exported from the RTS currently and in the bootstrap window.
    
    This commit just swaps directories around, such that the new headers may
    continue to be used in stage 0 despite the reasoning above, but the idea
    is that we can subsequently make more interesting changes doubling down
    on the reasoning above.
    
    In particular, in !6803 we'll start "morally" moving `ghcautonconf.h`
    over, introducing an RTS configure script and temporary header of its
    `AC_DEFINE`s until the top-level configure script doesn't define any
    more.
    
    Progress towards #17191
    
    - - - - -
    f5471c0b by John Ericson at 2021-10-31T09:05:16-04:00
    Modularize autoconf platform detection
    
    This will allow better reuse of it, such as in the upcoming RTS
    configure script.
    
    Progress towards #17191
    
    - - - - -
    6b38c8a6 by Ben Gamari at 2021-10-31T09:05:52-04:00
    ghc: Bump Cabal-Version to 1.22
    
    This is necessary to use reexported-modules
    
    - - - - -
    6544446d by Ben Gamari at 2021-10-31T09:05:52-04:00
    configure: Hide error output from --target check
    
    - - - - -
    7445bd71 by Andreas Klebinger at 2021-11-01T12:13:45+00:00
    Update comment in Lint.hs
    
    mkWwArgs has been renamed to mkWorkerArgs.
    - - - - -
    f1a782dd by Vladislav Zavialov at 2021-11-02T01:36:32-04:00
    HsToken for let/in (#19623)
    
    One more step towards the new design of EPA.
    
    - - - - -
    37a37139 by John Ericson at 2021-11-02T01:37:08-04:00
    Separate some AC_SUBST / AC_DEFINE
    
    Eventually, the RTS configure alone will need the vast majority of
    AC_DEFINE, and the top-level configure will need the most AC_SUBST. By
    removing the "side effects" of the macros like this we make them more
    reusable so they can be shared between the two configures without doing
    too much.
    
    - - - - -
    2f69d102 by John Ericson at 2021-11-02T01:37:43-04:00
    Remove `includes_GHCCONSTANTS` from make build system
    
    It is dead code.
    
    - - - - -
    da1a8e29 by John Ericson at 2021-11-02T01:37:43-04:00
    Treat generated RTS headers in a more consistent manner
    
    We can depend on all of them at once the same way.
    
    - - - - -
    a7e1be3d by Ryan Scott at 2021-11-02T01:38:53-04:00
    Fix #20590 with another application of mkHsContextMaybe
    
    We were always converting empty GADT contexts to `Just []` in `GHC.ThToHs`,
    which caused the pretty-printer to always print them as `() => ...`. This is
    easily fixed by using the `mkHsContextMaybe` function when converting GADT
    contexts so that empty contexts are turned to `Nothing`. This is in the same
    tradition established in commit 4c87a3d1d14f9e28c8aa0f6062e9c4201f469ad7.
    
    In the process of fixing this, I discovered that the `Cxt` argument to
    `mkHsContextMaybe` is completely unnecessary, as we can just as well check if
    the `LHsContext GhcPs` argument is empty.
    
    Fixes #20590.
    
    - - - - -
    39eed84c by Alan Zimmerman at 2021-11-02T21:39:32+00:00
    EPA: Get rid of bare SrcSpan's in the ParsedSource
    
    The ghc-exactPrint library has had to re-introduce the relatavise
    phase.
    
    This is needed if you change the length of an identifier and want the
    layout to be preserved afterwards.
    
    It is not possible to relatavise a bare SrcSpan, so introduce `SrcAnn
    NoEpAnns` for them instead.
    
    Updates haddock submodule.
    
    - - - - -
    9f42a6dc by ARATA Mizuki at 2021-11-03T09:19:17-04:00
    hadrian: Use $bindir instead of `dirname $0` in ghci wrapper
    
    `dirname $0` doesn't work when the wrapper is called via a symbolic link.
    
    Fix #20589
    
    - - - - -
    bf6f96a6 by Vladislav Zavialov at 2021-11-03T16:35:50+03:00
    Generalize the type of wrapLocSndMA
    
    - - - - -
    1419fb16 by Matthew Pickering at 2021-11-04T00:36:09-04:00
    ci: Don't run alpine job in fast-ci
    
    - - - - -
    6020905a by Takenobu Tani at 2021-11-04T09:40:42+00:00
    Correct load_load_barrier for risc-v
    
    This patch corrects the instruction for load_load_barrier().
    Current load_load_barrier() incorrectly uses `fence w,r`.
    It means a store-load barrier.
    
    See also linux-kernel's smp_rmb() implementation:
      https://github.com/torvalds/linux/blob/v5.14/arch/riscv/include/asm/barrier.h#L27
    
    - - - - -
    086e288c by Richard Eisenberg at 2021-11-04T13:04:44-04:00
    Tiny renamings and doc updates
    
    Close #20433
    
    - - - - -
    f0b920d1 by CarrieMY at 2021-11-05T05:30:13-04:00
    Fix deferOutOfScopeVariables for qualified #20472
    
    - - - - -
    59dfb005 by Simon Peyton Jones at 2021-11-05T05:30:48-04:00
    Remove record field from Solo
    
    Ticket #20562 revealed that Solo, which is a wired-in TyCon, had
    a record field that wasn't being added to the type env. Why not?
    Because wired-in TyCons don't have record fields.
    
    It's not hard to change that, but it's tiresome for this one use-case,
    and it seems easier simply to make `getSolo` into a standalone
    function.
    
    On the way I refactored the handling of Solo slightly, to put it
    into wiredInTyCons (where it belongs) rather than only in
    knownKeyNames
    
    - - - - -
    be3750a5 by Matthew Pickering at 2021-11-05T10:12:16-04:00
    Allow CApi FFI calls in GHCi
    
    At some point in the past this started working. I noticed this when
    working on multiple home units and couldn't load GHC's dependencies into
    the interpreter.
    
    Fixes #7388
    
    - - - - -
    d96ce59d by John Ericson at 2021-11-05T10:12:52-04:00
    make: Futher systematize handling of generated headers
    
    This will make it easier to add and remove generated headers, as we will
    do when we add a configure script for the RTS.
    
    - - - - -
    3645abac by John Ericson at 2021-11-05T20:25:32-04:00
    Avoid GHC_STAGE and other include bits
    
    We should strive to make our includes in terms of the RTS as much as
    possible. One place there that is not possible, the llvm version, we
    make a new tiny header
    
    Stage numbers are somewhat arbitrary, if we simple need a newer RTS, we
    should say so.
    
    - - - - -
    4896a6a6 by Matthew Pickering at 2021-11-05T20:26:07-04:00
    Fix boolean confusion with Opt_NoLlvmMangler flag
    
    I accidently got the two branches of the if expression the wrong way
    around when refactoring.
    
    Fixes #20567
    
    - - - - -
    d74cc01e by Ziyang Liu at 2021-11-06T07:53:06-04:00
    Export `withTcPlugins` and `withHoleFitPlugins`
    
    - - - - -
    ecd6d142 by Sylvain Henry at 2021-11-06T07:53:42-04:00
    i386: fix codegen of 64-bit comparisons
    
    - - - - -
    e279ea64 by Sylvain Henry at 2021-11-06T07:53:42-04:00
    Add missing Int64/Word64 constant-folding rules
    
    - - - - -
    4c86df25 by Sylvain Henry at 2021-11-06T07:53:42-04:00
    Fix Int64ToInt/Word64ToWord rules on 32-bit architectures
    
    When the input literal was larger than 32-bit it would crash in a
    compiler with assertion enabled because it was creating an out-of-bound
    word-sized literal (32-bit).
    
    - - - - -
    646c3e21 by Sylvain Henry at 2021-11-06T07:53:42-04:00
    CI: allow perf-nofib to fail
    
    - - - - -
    20956e57 by Sylvain Henry at 2021-11-06T07:53:42-04:00
    Remove target dependent CPP for Word64/Int64 (#11470)
    
    Primops types were dependent on the target word-size at *compiler*
    compilation time. It's an issue for multi-target as GHC may not have the
    correct primops types for the target.
    
    This patch fixes some primops types: if they take or return fixed 64-bit
    values they now always use `Int64#/Word64#`, even on 64-bit
    architectures (where they used `Int#/Word#` before). Users of these
    primops may now need to convert from Int64#/Word64# to Int#/Word# (a
    no-op at runtime).
    
    This is a stripped down version of !3658 which goes the all way of
    changing the underlying primitive types of Word64/Int64. This is left
    for future work.
    
    T12545 allocations increase ~4% on some CI platforms and decrease ~3% on
    AArch64.
    
    Metric Increase:
        T12545
    
    Metric Decrease:
        T12545
    
    - - - - -
    2800eee2 by Sylvain Henry at 2021-11-06T07:53:42-04:00
    Make Word64 use Word64# on every architecture
    
    - - - - -
    be9d7862 by Sylvain Henry at 2021-11-06T07:53:42-04:00
    Fix Int64/Word64's Enum instance fusion
    
    Performance improvement:
      T15185(normal) run/alloc        51112.0        41032.0 -19.7% GOOD
    
    Metric Decrease:
        T15185
    
    - - - - -
    6f2d6a5d by Nikolay Yakimov at 2021-11-06T11:24:50-04:00
    Add regression test for #20568
    
    GHC produced broken executables with rebindable if and -fhpc if `ifThenElse` expected non-Bool condition until GHC 9.0. This adds a simple regression test.
    
    - - - - -
    7045b783 by Vladislav Zavialov at 2021-11-06T11:25:25-04:00
    Refactor HdkM using deriving via
    
    * No more need for InlineHdkM, mkHdkM
    * unHdkM is now just a record selector
    * Update comments
    
    - - - - -
    0d8a883e by Andreas Klebinger at 2021-11-07T12:54:30-05:00
    Don't undersaturate join points through eta-reduction.
    
    In #20599 I ran into an issue where the unfolding for a join point was
    eta-reduced removing the required lambdas.
    
    This patch adds guards that should prevent this from happening going
    forward.
    
    - - - - -
    3d7e3d91 by Vladislav Zavialov at 2021-11-07T12:55:05-05:00
    Print the Type kind qualified when ambiguous (#20627)
    
    The Type kind is printed unqualified:
    	ghci> :set -XNoStarIsType
    	ghci> :k (->)
    	(->) :: Type -> Type -> Type
    
    This is the desired behavior unless the user has defined
    their own Type:
    	ghci> data Type
    
    Then we want to resolve the ambiguity by qualification:
    	ghci> :k (->)
    	(->) :: GHC.Types.Type -> GHC.Types.Type -> GHC.Types.Type
    
    - - - - -
    184f6bc6 by John Ericson at 2021-11-07T16:26:10-05:00
    Factor out unregisterised and tables next to code m4 macros
    
    These will be useful for upcoming RTS configure script.
    
    - - - - -
    56705da8 by Sebastian Graf at 2021-11-07T16:26:46-05:00
    Pmc: Do inhabitation test for unlifted vars (#20631)
    
    Although I thought we were already set to handle unlifted datatypes correctly,
    it appears we weren't. #20631 showed that it's wrong to assume
    `vi_bot=IsNotBot` for `VarInfo`s of unlifted types from their inception if we
    don't follow up with an inhabitation test to see if there are any habitable
    constructors left. We can't trigger the test from `emptyVarInfo`, so now we
    instead fail early in `addBotCt` for variables of unlifted types.
    
    Fixed #20631.
    
    - - - - -
    28334b47 by sheaf at 2021-11-08T13:40:05+01:00
    Default kind vars in tyfams with -XNoPolyKinds
    
      We should still default kind variables in type families
      in the presence of -XNoPolyKinds, to avoid suggesting enabling
      -XPolyKinds just because the function arrow introduced kind variables,
      e.g.
    
        type family F (t :: Type) :: Type where
          F (a -> b) = b
    
      With -XNoPolyKinds, we should still default `r :: RuntimeRep`
      in `a :: TYPE r`.
    
      Fixes #20584
    
    - - - - -
    3f103b1a by John Ericson at 2021-11-08T19:35:12-05:00
    Factor out GHC_ADJUSTORS_METHOD m4 macro
    
    - - - - -
    ba9fdc51 by John Ericson at 2021-11-08T19:35:12-05:00
    Factor out FP_FIND_LIBFFI and use in RTS configure too
    
    - - - - -
    2929850f by Sylvain Henry at 2021-11-09T10:02:06-05:00
    RTS: open timerfd synchronously (#20618)
    
    - - - - -
    bc498fdf by Sylvain Henry at 2021-11-09T10:02:46-05:00
    Bignum: expose backendName (#20495)
    
    - - - - -
    79a26df1 by Sylvain Henry at 2021-11-09T10:02:46-05:00
    Don't expose bignum backend in ghc --info (#20495)
    
    GHC is bignum backend agnostic and shouldn't report this information as
    in the future ghc-bignum will be reinstallable potentially with a
    different backend that GHC is unaware of. Moreover as #20495 shows the
    returned information may be wrong currently.
    
    - - - - -
    e485f4f2 by Andreas Klebinger at 2021-11-09T19:54:31-05:00
    SpecConstr - Attach evaldUnfolding to known evaluated arguments.
    
    - - - - -
    983a99f0 by Ryan Scott at 2021-11-09T19:55:07-05:00
    deriving: infer DatatypeContexts from data constructors, not type constructor
    
    Previously, derived instances that use `deriving` clauses would infer
    `DatatypeContexts` by using `tyConStupidTheta`. But this sometimes causes
    redundant constraints to be included in the derived instance contexts, as the
    constraints that appear in the `tyConStupidTheta` may not actually appear in
    the types of the data constructors (i.e., the `dataConStupidTheta`s). For
    instance, in `data Show a => T a = MkT deriving Eq`, the type of `MkT` does
    not require `Show`, so the derived `Eq` instance should not require `Show`
    either. This patch makes it so with some small tweaks to
    `inferConstraintsStock`.
    
    Fixes #20501.
    
    - - - - -
    bdd7b2be by Ryan Scott at 2021-11-09T19:55:07-05:00
    Flesh out Note [The stupid context] and reference it
    
    `Note [The stupid context]` in `GHC.Core.DataCon` talks about stupid contexts
    from `DatatypeContexts`, but prior to this commit, it was rather outdated.
    This commit spruces it up and references it from places where it is relevant.
    
    - - - - -
    95563259 by Li-yao Xia at 2021-11-10T09:16:21-05:00
    Fix rendering of Applicative law
    
    - - - - -
    0f852244 by Viktor Dukhovni at 2021-11-10T09:16:58-05:00
    Improve ZipList section of Traversable overview
    
    - Fix cut/paste error by adding missing `c` pattern in `Vec3`
      traversable instance.
    
    - Add a bit of contextual prose above the Vec2/Vec3 instance
      sample code.
    
    - - - - -
    c4cd13b8 by Richard Eisenberg at 2021-11-10T18:18:19-05:00
    Fix Note [Function types]
    
    Close #19938.
    
    - - - - -
    dfb9913c by sheaf at 2021-11-10T18:18:59-05:00
    Improvements to rank_polymorphism.rst
    
      - rename the function f4 to h1 for consistency with
        the naming convention
      - be more explicit about the difference between
          `Int -> (forall a. a -> a)`
        and
          `forall a. Int -> (a -> a)`
      - reorder the section to make it flow better
    
    Fixes #20585
    
    - - - - -
    1540f556 by sheaf at 2021-11-10T18:19:37-05:00
    Clarify hs-boot file default method restrictions
    
      The user guide wrongly stated that default methods should not
      be included in hs-boot files. In fact, if the class is not left
      abstract (no methods, no superclass constraints, ...) then the
      defaults must be provided and match with those given in the .hs
      file.
    
      We add some tests for this, as there were no tests in the testsuite
      that gave rise to the "missing default methods" error.
    
      Fixes #20588
    
    - - - - -
    8c0aec38 by Sylvain Henry at 2021-11-10T18:20:17-05:00
    Hadrian: fix building/registering of .dll libraries
    
    - - - - -
    11c9a469 by Matthew Pickering at 2021-11-11T07:21:28-05:00
    testsuite: Convert hole fit performance tests into proper perf tests
    
    Fixes #20621
    
    - - - - -
    c2ed85cb by Matthew Pickering at 2021-11-11T07:22:03-05:00
    driver: Cache the transitive dependency calculation in ModuleGraph
    
    Two reasons for this change:
    
    1. Avoid computing the transitive dependencies when compiling each
       module, this can save a lot of repeated work.
    2. More robust to forthcoming changes to support multiple home units.
    
    - - - - -
    4230e4fb by Matthew Pickering at 2021-11-11T07:22:03-05:00
    driver: Use shared transitive dependency calculation in hptModulesBelow
    
    This saves a lot of repeated work on big dependency graphs.
    
    -------------------------
    Metric Decrease:
        MultiLayerModules
        T13719
    -------------------------
    
    - - - - -
    af653b5f by Matthew Bauer at 2021-11-11T07:22:39-05:00
    Only pass -pie, -no-pie when linking
    
    Previously, these flags were passed when both compiling and linking
    code. However, `-pie` and `-no-pie` are link-time-only options. Usually,
    this does not cause issues, but when using Clang with `-Werror` set
    results in errors:
    
        clang: error: argument unused during compilation: '-nopie' [-Werror,-Wunused-command-line-argument]
    
    This is unused by Clang because this flag has no effect at compile time
    (it’s called `-nopie` internally by Clang but called `-no-pie` in GHC
    for compatibility with GCC). Just passing these flags at linking time
    resolves this.
    
    Additionally, update #15319 hack to look for `-pgml` instead.
    
    Because of the main change, the value of `-pgmc` does not matter when
    checking for the workaround of #15319. However, `-pgml` *does* still
    matter as not all `-pgml` values support `-no-pie`.
    
    To cover all potential values, we assume that no custom `-pgml` values
    support `-no-pie`. This means that we run the risk of not using
    `-no-pie` when it is otherwise necessary for in auto-hardened
    toolchains! This could be a problem at some point, but this workaround
    was already introduced in 8d008b71 and we might as well continue
    supporting it.
    
    Likewise, mark `-pgmc-supports-no-pie` as deprecated and create a new
    `-pgml-supports-no-pie`.
    
    - - - - -
    7cc6ebdf by Sebastian Graf at 2021-11-11T07:23:14-05:00
    Add regression test for #20598
    
    Fixes #20598, which is mostly a duplicate of #18824 but for GHC 9.2.
    
    - - - - -
    7b44c816 by Simon Jakobi at 2021-11-12T21:20:17-05:00
    Turn GHC.Data.Graph.Base.Graph into a newtype
    
    - - - - -
    a57cc754 by John Ericson at 2021-11-12T21:20:52-05:00
    Make: Do not generate ghc.* headers in stage0
    
    GHC should get everything it needs from the RTS, which for stage0 is the
    "old" RTS that comes from the bootstrap compiler.
    
    - - - - -
    265ead8a by Richard Eisenberg at 2021-11-12T21:21:27-05:00
    Improve redundant-constraints warning
    
    Previously, we reported things wrong with
    
      f :: (Eq a, Ord a) => a -> Bool
      f x = x == x
    
    saying that Eq a was redundant. This is fixed now, along with
    some simplification in Note [Replacement vs keeping]. There's
    a tiny bit of extra complexity in setImplicationStatus, but
    it's explained in Note [Tracking redundant constraints].
    
    Close #20602
    
    - - - - -
    ca90ffa3 by Richard Eisenberg at 2021-11-12T21:21:27-05:00
    Use local instances with least superclass depth
    
    See new Note [Use only the best local instance] in
    GHC.Tc.Solver.Interact.
    
    This commit also refactors the InstSC/OtherSC mechanism
    slightly.
    
    Close #20582.
    
    - - - - -
    dfc4093c by Vladislav Zavialov at 2021-11-12T21:22:03-05:00
    Implement -Wforall-identifier (#20609)
    
    In accordance with GHC Proposal #281 "Visible forall in types of terms":
    
    	For three releases before this change takes place, include a new
    	warning -Wforall-identifier in -Wdefault. This warning will be triggered
    	at definition sites (but not use sites) of forall as an identifier.
    
    Updates the haddock submodule.
    
    - - - - -
    4143bd21 by Cheng Shao at 2021-11-12T21:22:39-05:00
    hadrian: use /bin/sh in timeout wrapper
    
    /usr/bin/env doesn't work within a nix build.
    
    - - - - -
    43cab5f7 by Simon Peyton Jones at 2021-11-12T21:23:15-05:00
    Get the in-scope set right in simplArg
    
    This was a simple (but long standing) error in simplArg,
    revealed by #20639
    
    - - - - -
    578b8b48 by Ben Gamari at 2021-11-12T21:23:51-05:00
    gitlab-ci: Allow draft MRs to fail linting jobs
    
    Addresses #20623 by allowing draft MRs to fail linting jobs.
    - - - - -
    908e49fa by Ben Gamari at 2021-11-12T21:23:51-05:00
    Fix it
    - - - - -
    05166660 by Ben Gamari at 2021-11-12T21:23:51-05:00
    Fix it
    - - - - -
    e41cffb0 by Ben Gamari at 2021-11-12T21:23:51-05:00
    Fix it
    - - - - -
    cce3a025 by Ben Gamari at 2021-11-12T21:23:51-05:00
    Fix it
    - - - - -
    4499db7d by Ben Gamari at 2021-11-12T21:23:51-05:00
    Fix it
    - - - - -
    dd1be88b by Travis Whitaker at 2021-11-12T21:24:29-05:00
    mmapForLinkerMarkExecutable: do nothing when len = 0
    
    - - - - -
    4c6ace75 by John Ericson at 2021-11-12T21:25:04-05:00
    Delete compiler/MachDeps.h
    
    This was accidentally added back in
    28334b475a109bdeb8d53d58c48adb1690e2c9b4 after it is was no longer
    needed by the compiler proper in
    20956e5784fe43781d156dd7ab02f0bff4ab41fb.
    
    - - - - -
    490e8c75 by John Ericson at 2021-11-12T21:25:40-05:00
    Generate ghcversion.h with the top-level configure
    
    This is, rather unintuitively, part of the goal of making the packages
    that make of the GHC distribution more freestanding. `ghcversion.h` is
    very simple, so we easily can move it out of the main build systems
    (make and Hadrian). By doing so, the RTS becomes less of a special case
    to those build systems as the header, already existing in the source
    tree, appears like any other.
    
    We could do this with the upcomming RTS configure, but it hardly matters
    because there is nothing platform-specific here, it is just versioning
    information like the other files the top-level configure can be
    responsible for.
    
    - - - - -
    bba156f3 by John Ericson at 2021-11-12T21:26:15-05:00
    Remove bit about size_t in ghc-llvm-version.h
    
    This shouldn't be here. It wasn't causing a problem because this header
    was only used from Haskell, but still.
    
    - - - - -
    0b1da2f1 by John Ericson at 2021-11-12T21:26:50-05:00
    Make: Install RTS headers in `$libdir/rts/include` not `$libdir/include`
    
    Before we were violating the convention of every other package. This
    fixes that. It matches the changes made in
    d5de970dafd5876ef30601697576167f56b9c132 to the location of the files in
    the repo.
    
    - - - - -
    b040d0d4 by Sebastian Graf at 2021-11-12T21:27:26-05:00
    Add regression test for #20663
    
    - - - - -
    c6065292 by John Ericson at 2021-11-12T21:28:02-05:00
    Make: Move remaining built RTS headers to ...build/include
    
    This allows us to clean up the rts include dirs in the package conf.
    
    - - - - -
    aa372972 by Ryan Scott at 2021-11-15T10:17:57-05:00
    Refactoring: Consolidate some arguments with DerivInstTys
    
    Various functions in GHC.Tc.Deriv.* were passing around `TyCon`s and
    `[Type]`s that ultimately come from the same `DerivInstTys`. This patch
    moves the definition of `DerivInstTys` to `GHC.Tc.Deriv.Generate` so that
    all of these `TyCon` and `[Type]` arguments can be consolidated into a
    single `DerivInstTys`. Not only does this make the code easier to read
    (in my opinion), this will also be important in a subsequent commit where we
    need to add another field to `DerivInstTys` that will also be used from
    `GHC.Tc.Deriv.Generate` and friends.
    
    - - - - -
    564a19af by Ryan Scott at 2021-11-15T10:17:57-05:00
    Refactoring: Move DataConEnv to GHC.Core.DataCon
    
    `DataConEnv` will prove to be useful in another place besides
    `GHC.Core.Opt.SpecConstr` in a follow-up commit.
    
    - - - - -
    3e5f0595 by Ryan Scott at 2021-11-15T10:17:57-05:00
    Instantiate field types properly in stock-derived instances
    
    Previously, the `deriving` machinery was very loosey-goosey about how it used
    the types of data constructor fields when generating code. It would usually
    just consult `dataConOrigArgTys`, which returns the _uninstantiated_ field
    types of each data constructor. Usually, you can get away with this, but
    issues #20375 and #20387 revealed circumstances where this approach fails.
    
    Instead, when generated code for a stock-derived instance
    `C (T arg_1 ... arg_n)`, one must take care to instantiate the field types of
    each data constructor with `arg_1 ... arg_n`. The particulars of how this is
    accomplished is described in the new
    `Note [Instantiating field types in stock deriving]` in
    `GHC.Tc.Deriv.Generate`. Some highlights:
    
    * `DerivInstTys` now has a new `dit_dc_inst_arg_env :: DataConEnv [Type]`
      field that caches the instantiated field types of each data constructor.
      Whenever we need to consult the field types somewhere in `GHC.Tc.Deriv.*`
      we avoid using `dataConOrigArgTys` and instead look it up in
      `dit_dc_inst_arg_env`.
    * Because `DerivInstTys` now stores the instantiated field types of each
      constructor, some of the details of the `GHC.Tc.Deriv.Generics.mkBindsRep`
      function were able to be simplified. In particular, we no longer need to
      apply a substitution to instantiate the field types in a `Rep(1)` instance,
      as that is already done for us by `DerivInstTys`. We still need a
      substitution to implement the "wrinkle" section of
      `Note [Generating a correctly typed Rep instance]`, but the code is
      nevertheless much simpler than before.
    * The `tyConInstArgTys` function has been removed in favor of the new
      `GHC.Core.DataCon.dataConInstUnivs` function, which is really the proper tool
      for the job. `dataConInstUnivs` is much like `tyConInstArgTys` except that it
      takes a data constructor, not a type constructor, as an argument, and it adds
      extra universal type variables from that data constructor at the end of the
      returned list if need be. `dataConInstUnivs` takes care to instantiate the
      kinds of the universal type variables at the end, thereby avoiding a bug in
      `tyConInstArgTys` discovered in
      https://gitlab.haskell.org/ghc/ghc/-/issues/20387#note_377037.
    
    Fixes #20375. Fixes #20387.
    
    - - - - -
    25d36c31 by John Ericson at 2021-11-15T10:18:32-05:00
    Make: Get rid of GHC_INCLUDE_DIRS
    
    These dirs should not be included in all stages. Instead make the
    per-stage `BUILD_*_INCLUDE_DIR` "plural" to insert `rts/include` in the
    right place.
    
    - - - - -
    b679721a by John Ericson at 2021-11-15T10:18:32-05:00
    Delete dead code knobs for building GHC itself
    
    As GHC has become target agnostic, we've left behind some now-useless
    logic in both build systems.
    
    - - - - -
    3302f42a by Sylvain Henry at 2021-11-15T13:19:42-05:00
    Fix windres invocation
    
    I've already fixed this 7 months ago in the comments of #16780 but it
    never got merged. Now we need this for #20657 too.
    
    - - - - -
    d9f54905 by Sylvain Henry at 2021-11-15T13:19:42-05:00
    Hadrian: fix windows cross-build (#20657)
    
    Many small things to fix:
    
    * Hadrian: platform triple is "x86_64-w64-mingw32" and this wasn't recognized by
      Hadrian (note "w64" instead of "unknown")
    
    * Hadrian was using the build platform ("isWindowsHost") to detect
      the use of the Windows toolchain, which was wrong. We now use the
      "targetOs" setting.
    
    * Hadrian was doing the same thing for Darwin so we fixed both at once,
      even if cross-compilation to Darwin is unlikely to happen afaik (cf
      "osxHost" vs "osxTarget" changes)
    
    * Hadrian: libffi name was computed in two different places and one of
      them wasn't taking the different naming on Windows into account.
    
    * Hadrian was passing "-Irts/include" when building the stage1 compiler
      leading to the same error as in #18143 (which is using make).
      stage1's RTS is stage0's one so mustn't do this.
    
    * Hadrian: Windows linker doesn't seem to support "-zorigin" so we
      don't pass it (similarly to Darwin)
    
    * Hadrian: hsc2hs in cross-compilation mode uses a trick (taken from
      autoconf): it defines "static int test_array[SOME_EXPR]" where
      SOME_EXPR is a constant expression. However GCC reports an error
      because SOME_EXPR is supposedly not constant. This is fixed by using
      another method enabled with the `--via-asm` flag of hsc2hs. It has been
      fixed in `make` build system (5f6fcf7808b16d066ad0fb2068225b3f2e8363f7)
      but not in Hadrian.
    
    * Hadrian: some packages are specifically built only on Windows but they
      shouldn't be when building a cross-compiler (`touchy` and
      `ghci-wrapper`). We now correctly detect this case and disable these
      packages.
    
    * Base: we use `iNVALID_HANDLE_VALUE` in a few places. It fixed some
      hsc2hs issues before we switched to `--via-asm` (see above). I've kept
      these changes are they make the code nicer.
    
    * Base: `base`'s configure tries to detect if it is building for Windows
      but for some reason the `$host_alias` value is `x86_64-windows` in my
      case and it wasn't properly detected.
    
    * Base: libraries/base/include/winio_structs.h imported "Windows.h" with
      a leading uppercase. It doesn't work on case-sensitive systems when
      cross-compiling so we have to use "windows.h".
    
    * RTS: rts/win32/ThrIOManager.c was importin "rts\OSThreads.h" but this
      path isn't valid when cross-compiling. We replaced "\" with "/".
    
    * DeriveConstants: this tool derives the constants from the target
      RTS header files. However these header files define `StgAsyncIOResult`
      only when `mingw32_HOST_OS` is set hence it seems we have to set it
      explicitly.
      Note that deriveConstants is called more than once (why? there is
      only one target for now so it shouldn't) and in the second case this
      value is correctly defined (probably coming indirectly from the import
      of "rts/PosixSource.h"). A better fix would probably be to disable the
      unneeded first run of deriveconstants.
    
    - - - - -
    cc635da1 by Richard Eisenberg at 2021-11-15T13:20:18-05:00
    Link to ghc-proposals repo from README
    
    A potential contributor said that they weren't aware of
    ghc-proposals. This might increase visibility.
    
    - - - - -
    a8e1a756 by Ben Gamari at 2021-11-16T03:12:34-05:00
    gitlab-ci: Refactor toolchain provision
    
    This makes it easier to invoke ci.sh on Darwin by teaching it to manage
    the nix business.
    
    - - - - -
    1f0014a8 by Ben Gamari at 2021-11-16T03:12:34-05:00
    gitlab-ci: Fail if dynamic references are found in a static bindist
    
    Previously we called error, which just prints an error, rather than
    fail, which actually fails.
    
    - - - - -
    85f2c0ba by Ben Gamari at 2021-11-16T03:12:34-05:00
    gitlab-ci/darwin: Move SDK path discovery into toolchain.nix
    
    Reduce a bit of duplication and a manual step when running builds
    manually.
    
    - - - - -
    3e94b5a7 by John Ericson at 2021-11-16T03:13:10-05:00
    Make: Get rid of `BUILD_.*_INCLUDE_DIRS`
    
    First, we improve some of the rules around -I include dirs, and CPP
    opts.
    
    Then, we just specify the RTS's include dirs normally (locally per the
    package and in the package conf), and then everything should work
    normally.
    
    The primops.txt.pp rule needs no extra include dirs at all, as it no
    longer bakes in a target platfom.
    
    Reverts some of the extra stage arguments I added in
    05419e55cab272ed39790695f448b311f22669f7, as they are no longer needed.
    
    - - - - -
    083a7583 by Ben Gamari at 2021-11-17T05:10:27-05:00
    Increase type sharing
    
    Fixes #20541 by making mkTyConApp do more sharing of types.
    In particular, replace
    
    * BoxedRep Lifted    ==>  LiftedRep
    * BoxedRep Unlifted  ==>  UnliftedRep
    * TupleRep '[]       ==>  ZeroBitRep
    * TYPE ZeroBitRep    ==>  ZeroBitType
    
    In each case, the thing on the right is a type synonym
    for the thing on the left, declared in ghc-prim:GHC.Types.
    See Note [Using synonyms to compress types] in GHC.Core.Type.
    
    The synonyms for ZeroBitRep and ZeroBitType are new, but absolutely
    in the same spirit as the other ones.   (These synonyms are mainly
    for internal use, though the programmer can use them too.)
    
    I also renamed GHC.Core.Ty.Rep.isVoidTy to isZeroBitTy, to be
    compatible with the "zero-bit" nomenclature above.  See discussion
    on !6806.
    
    There is a tricky wrinkle: see GHC.Core.Types
      Note [Care using synonyms to compress types]
    
    Compiler allocation decreases by up to 0.8%.
    
    - - - - -
    20a4f251 by Ben Gamari at 2021-11-17T05:11:03-05:00
    hadrian: Factor out --extra-*-dirs=... pattern
    
    We repeated this idiom quite a few times. Give it a name.
    
    - - - - -
    4cec6cf2 by Ben Gamari at 2021-11-17T05:11:03-05:00
    hadrian: Ensure that term.h is in include search path
    
    terminfo now requires term.h but previously neither build system offered
    any way to add the containing directory to the include search path. Fix
    this in Hadrian.
    
    Also adds libnuma includes to global include search path as it was
    inexplicably missing earlier.
    
    - - - - -
    29086749 by Sebastian Graf at 2021-11-17T05:11:38-05:00
    Pmc: Don't case split on wildcard matches (#20642)
    
    Since 8.10, when formatting a pattern match warning, we'd case split on a
    wildcard match such as
    ```hs
    foo :: [a] -> [a]
    foo [] = []
    foo xs = ys
      where
      (_, ys@(_:_)) = splitAt 0 xs
    -- Pattern match(es) are non-exhaustive
    -- In a pattern binding:
    --     Patterns not matched:
    --         ([], [])
    --         ((_:_), [])
    ```
    But that's quite verbose and distracts from which part of the pattern was
    actually the inexhaustive one. We'd prefer a wildcard for the first pair
    component here, like it used to be in GHC 8.8.
    
    On the other hand, case splitting is pretty handy for `-XEmptyCase` to know the
    different constructors we could've matched on:
    ```hs
    f :: Bool -> ()
    f x = case x of {}
    -- Pattern match(es) are non-exhaustive
    -- In a pattern binding:
    --     Patterns not matched:
    --         False
    --         True
    ```
    The solution is to communicate that we want a top-level case split to
    `generateInhabitingPatterns` for `-XEmptyCase`, which is exactly what
    this patch arranges. Details in `Note [Case split inhabiting patterns]`.
    
    Fixes #20642.
    
    - - - - -
    c591ab1f by Sebastian Graf at 2021-11-17T05:11:38-05:00
    testsuite: Refactor pmcheck all.T
    
    - - - - -
    33c0c83d by Andrew Pritchard at 2021-11-17T05:12:17-05:00
    Fix Haddock markup on Data.Type.Ord.OrdCond.
    
    - - - - -
    7bcd91f4 by Andrew Pritchard at 2021-11-17T05:12:17-05:00
    Provide in-line kind signatures for Data.Type.Ord.Compare.
    
    Haddock doesn't know how to render SAKS, so the only current way to make
    the documentation show the kind is to write what it should say into the
    type family declaration.
    
    - - - - -
    16d86b97 by ARATA Mizuki at 2021-11-17T05:12:56-05:00
    bitReverse functions in GHC.Word are since base-4.14.0.0, not 4.12.0.0
    
    They were added in 33173a51c77d9960d5009576ad9b67b646dfda3c, which constitutes GHC 8.10.1 / base-4.14.0.0
    
    - - - - -
    7850142c by Morrow at 2021-11-17T11:14:37+00:00
    Improve handling of import statements in GHCi (#20473)
    
    Currently in GHCi, when given a line of user input we:
    
    1. Attempt to parse and handle it as a statement
    2. Otherwise, attempt to parse and handle a single import
    3. Otherwise, check if there are imports present (and if so display an error message)
    4. Otherwise, attempt to parse a module and only handle the declarations
    
    This patch simplifies the process to:
    
    Attempt to parse and handle it as a statement
    Otherwise, attempt to parse a module and handle the imports and declarations
    
    This means that multiple imports in a multiline are now accepted, and a multiline containing both imports and declarations is now accepted (as well as when separated by semicolons).
    
    - - - - -
    09d44b4c by Zubin Duggal at 2021-11-18T01:37:36-05:00
    hadrian: add threadedDebug RTS way to devel compilers
    
    - - - - -
    5fa45db7 by Zubin Duggal at 2021-11-18T01:37:36-05:00
    testsuite: disable some tests when we don't have dynamic libraries
    
    - - - - -
    f8c1c549 by Matthew Pickering at 2021-11-18T01:38:11-05:00
    Revert "base: Use one-shot kqueue on macOS"
    
    This reverts commit 41117d71bb58e001f6a2b6a11c9314d5b70b9182
    - - - - -
    f55ae180 by Simon Peyton Jones at 2021-11-18T14:44:45-05:00
    Add one line of comments (c.f. !5706)
    
    Ticket #19815 suggested changing coToMCo to use
    isReflexiveCo rather than isReflCo.  But perf results
    weren't encouraging. This patch just adds a comment to
    point to the data, such as it is.
    
    - - - - -
    12d023d1 by Vladislav Zavialov at 2021-11-18T14:45:20-05:00
    testsuite: check for FlexibleContexts in T17563
    
    The purpose of testsuite/tests/typecheck/should_fail/T17563.hs is to
    make sure we do validity checking on quantified constraints.
    
    In particular, see the following functions in GHC.Tc.Validity:
      * check_quant_pred
      * check_pred_help
      * check_class_pred
    
    The original bug report used a~b constraints as an example of a
    constraint that requires validity checking. But with GHC Proposal #371,
    equality constraints no longer require GADTs or TypeFamilies; instead,
    they require TypeOperators, which are checked earlier in the pipeline,
    in the renamer.
    
    Rather than simply remove this test, we change the example to use
    another extension: FlexibleContexts. Since we decide whether a
    constraint requires this extension in check_class_pred, the regression
    test continues to exercise the relevant code path.
    
    - - - - -
    78d4bca0 by Ben Gamari at 2021-11-18T22:27:20-05:00
    ghc-cabal, make: Add support for building C++ object code
    
    Co-Authored By: Matthew Pickering <matthew at well-typed.com>
    
    - - - - -
    a8b4961b by Ben Gamari at 2021-11-18T22:27:20-05:00
    Bump Cabal submodule
    
    - - - - -
    59e8a900 by Ben Gamari at 2021-11-18T22:27:20-05:00
    Bump text and parsec submodules
    
    Accommodates text-2.0.
    
    Metric Decrease:
        T15578
    
    - - - - -
    7f7d7888 by Ben Gamari at 2021-11-18T22:27:20-05:00
    ghc-cabal: Use bootstrap compiler's text package
    
    This avoids the need to build `text` without Cabal, in turn avoiding the
    need to reproduce the workaround for #20010 contained therein.
    
    - - - - -
    048f8d96 by Ben Gamari at 2021-11-18T22:27:20-05:00
    gitlab-ci: Bump MACOSX_DEPLOYMENT_TARGET
    
    It appears that Darwin's toolchain includes system headers in the
    dependency makefiles it generates with `-M` with older
    `MACOSX_DEPLOYMENT_TARGETS`. To avoid this we have bumped the deployment
    target for x86-64/Darwin to 10.10.
    
    - - - - -
    0acbbd20 by Ben Gamari at 2021-11-18T22:27:20-05:00
    testsuite: Use libc++ rather than libstdc++ in objcpp-hi
    
    It appears that libstdc++ is no longer available in recent XCode
    distributions.
    
    Closes #16083.
    
    - - - - -
    aed98dda by John Ericson at 2021-11-18T22:27:55-05:00
    Hadrian: bring up to date with latest make improvements
    
    Headers should be associated with the RTS, and subject to less hacks.
    
    The most subtle issue was that the package-grained dependencies on
    generated files were being `need`ed before calculating Haskell deps, but
    not before calculating C/C++ deps.
    
    - - - - -
    aabff109 by Ben Gamari at 2021-11-20T05:34:27-05:00
    Bump deepseq submodule to 1.4.7.0-pre
    
    Addresses #20653.
    
    - - - - -
    3d6b78db by Matthew Pickering at 2021-11-20T05:35:02-05:00
    Remove unused module import syntax from .bkp mode
    
    .bkp mode had this unused feature where you could write
    
      module A
    
    and it would go looking for A.hs on the file system and use that rather
    than provide the definition inline.
    
    This isn't use anywhere in the testsuite and the code to find the module
    A looks dubious. Therefore to reduce .bkp complexity I propose to remove
    it.
    
    Fixes #20701
    
    - - - - -
    bdeea37e by Sylvain Henry at 2021-11-20T05:35:42-05:00
    More support for optional home-unit
    
    This is a preliminary refactoring for #14335 (supporting plugins in
    cross-compilers). In many places the home-unit must be optional because
    there won't be one available in the plugin environment (we won't be
    compiling anything in this environment). Hence we replace "HomeUnit"
    with "Maybe HomeUnit" in a few places and we avoid the use of
    "hsc_home_unit" (which is partial) in some few others.
    
    - - - - -
    29e03071 by Ben Gamari at 2021-11-20T05:36:18-05:00
    rts: Ensure that markCAFs marks object code
    
    Previously `markCAFs` would only evacuate CAFs' indirectees. This would
    allow reachable object code to be unloaded by the linker as `evacuate`
    may never be called on the CAF itself, despite it being reachable via
    the `{dyn,revertible}_caf_list`s.
    
    To fix this we teach `markCAFs` to explicit call `markObjectCode`,
    ensuring that the linker is aware of objects reachable via the CAF
    lists.
    
    Fixes #20649.
    
    - - - - -
    b2933ea9 by Ben Gamari at 2021-11-20T05:36:54-05:00
    gitlab-ci: Set HOME to plausible but still non-existent location
    
    We have been seeing numerous CI failures on aarch64/Darwin of the form:
    
        CI_COMMIT_BRANCH:
        CI_PROJECT_PATH: ghc/ghc
        error: creating directory '/nonexistent': Read-only file system
    
    Clearly *something* is attempting to create `$HOME`. A bit of sleuthing
    by @int-e found that the culprit is likely `nix`, although it's not
    clear why. For now we avoid the issue by setting `HOME` to a fresh
    directory in the working tree.
    
    - - - - -
    bc7e9f03 by Zubin Duggal at 2021-11-20T17:39:25+00:00
    Use 'NonEmpty' for the fields in an 'HsProjection' (#20389)
    
    T12545 is very inconsistently affected by this change for some reason.
    There is a decrease in allocations on most configurations, but
    an increase on validate-x86_64-linux-deb9-unreg-hadrian. Accepting it
    as it seems unrelated to this patch.
    
    Metric Decrease:
        T12545
    Metric Increase:
        T12545
    
    - - - - -
    742d8b60 by sheaf at 2021-11-20T18:13:23-05:00
    Include "not more specific" info in overlap msg
    
      When instances overlap, we now include additional information
      about why we weren't able to select an instance: perhaps
      one instance overlapped another but was not strictly more specific,
      so we aren't able to directly choose it.
    
    Fixes #20542
    
    - - - - -
    f748988b by Simon Peyton Jones at 2021-11-22T11:53:02-05:00
    Better wrapper activation calculation
    
    As #20709 showed, GHC could prioritise a wrapper over a SPEC
    rule, which is potentially very bad.  This patch fixes that
    problem.
    
    The fix is is described in Note [Wrapper activation], especially
    item 4, 4a, and Conclusion.
    
    For now, it has a temporary hack (replicating what was there before
    to make sure that wrappers inline no earlier than phase 2.  But
    it should be temporary; see #19001.
    
    - - - - -
    f0bac29b by Simon Peyton Jones at 2021-11-22T11:53:02-05:00
    Make INLINE/NOINLINE pragmas a bgi less constraining
    
    We can inline a bit earlier than the previous pragmas said.  I think
    they dated from an era in which the InitialPhase did no inlining.
    
    I don't think this patch will have much effect, but it's
    a bit cleaner.
    
    - - - - -
    68a3665a by Sylvain Henry at 2021-11-22T11:53:47-05:00
    Hadrian: bump stackage LTS to 18.18 (GHC 8.10.7)
    
    - - - - -
    680ef2c8 by Andreas Klebinger at 2021-11-23T01:07:29-05:00
    CmmSink: Be more aggressive in removing no-op assignments.
    
    No-op assignments like R1 = R1 are not only wasteful. They can also
    inhibit other optimizations like inlining assignments that read from
    R1.
    
    We now check for assignments being a no-op before and after we
    simplify the RHS in Cmm sink which should eliminate most of these
    no-ops.
    
    - - - - -
    1ed2aa90 by Andreas Klebinger at 2021-11-23T01:07:29-05:00
    Don't include types in test output
    
    - - - - -
    3ab3631f by Krzysztof Gogolewski at 2021-11-23T01:08:05-05:00
    Add a warning for GADT match + NoMonoLocalBinds (#20485)
    
    Previously, it was an error to pattern match on a GADT
    without GADTs or TypeFamilies.
    This is now allowed. Instead, we check the flag MonoLocalBinds;
    if it is not enabled, we issue a warning, controlled by -Wgadt-mono-local-binds.
    
    Also fixes #20485: pattern synonyms are now checked too.
    
    - - - - -
    9dcb2ad1 by Ben Gamari at 2021-11-23T16:09:39+00:00
    gitlab-ci: Bump DOCKER_REV
    - - - - -
    16690374 by nineonine at 2021-11-23T22:32:51-08:00
    Combine STG free variable traversals (#17978)
    
    Previously we would traverse the STG AST twice looking for free variables.
     * Once in `annTopBindingsDeps` which considers top level and imported ids free.
       Its output is used to put bindings in dependency order. The pass happens
       in STG pipeline.
     * Once in `annTopBindingsFreeVars` which only considers non-top level ids free.
       Its output is used by the code generator to compute offsets into closures.
       This happens in Cmm (CodeGen) pipeline.
    
    Now these two traversal operations are merged into one - `FVs.depSortWithAnnotStgPgm`.
    The pass happens right at the end of STG pipeline. Some type signatures had to be
    updated due to slight shifts of StgPass boundaries (for example, top-level CodeGen
    handler now directly works with CodeGen flavoured Stg AST instead of Vanilla).
    
    Due to changed order of bindings, a few debugger type reconstruction bugs
    have resurfaced again (see tests break018, break021) - work item #18004 tracks this
    investigation.
    
    authors: simonpj, nineonine
    
    - - - - -
    91c0a657 by Matthew Pickering at 2021-11-25T01:03:17-05:00
    Correct retypechecking in --make mode
    
    Note [Hydrating Modules]
    ~~~~~~~~~~~~~~~~~~~~~~~~
    
    What is hydrating a module?
    
    * There are two versions of a module, the ModIface is the on-disk version and the ModDetails is a fleshed-out in-memory version.
    * We can **hydrate** a ModIface in order to obtain a ModDetails.
    
    Hydration happens in three different places
    
    * When an interface file is initially loaded from disk, it has to be hydrated.
    * When a module is finished compiling, we hydrate the ModIface in order to generate
      the version of ModDetails which exists in memory (see Note)
    * When dealing with boot files and module loops (see Note [Rehydrating Modules])
    
    Note [Rehydrating Modules]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    If a module has a boot file then it is critical to rehydrate the modules on
    the path between the two.
    
    Suppose we have ("R" for "recursive"):
    ```
    R.hs-boot:   module R where
                   data T
                   g :: T -> T
    
    A.hs:        module A( f, T, g ) where
                    import {-# SOURCE #-} R
                    data S = MkS T
                    f :: T -> S = ...g...
    
    R.hs:        module R where
                    data T = T1 | T2 S
                    g = ...f...
    ```
    
    After compiling A.hs we'll have a TypeEnv in which the Id for `f` has a type
    type uses the AbstractTyCon T; and a TyCon for `S` that also mentions that same
    AbstractTyCon. (Abstract because it came from R.hs-boot; we know nothing about
    it.)
    
    When compiling R.hs, we build a TyCon for `T`.  But that TyCon mentions `S`, and
    it currently has an AbstractTyCon for `T` inside it.  But we want to build a
    fully cyclic structure, in which `S` refers to `T` and `T` refers to `S`.
    
    Solution: **rehydration**.  *Before compiling `R.hs`*, rehydrate all the
    ModIfaces below it that depend on R.hs-boot.  To rehydrate a ModIface, call
    `typecheckIface` to convert it to a ModDetails.  It's just a de-serialisation
    step, no type inference, just lookups.
    
    Now `S` will be bound to a thunk that, when forced, will "see" the final binding
    for `T`; see [Tying the knot](https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/tying-the-knot).
    But note that this must be done *before* compiling R.hs.
    
    When compiling R.hs, the knot-tying stuff above will ensure that `f`'s unfolding
    mentions the `LocalId` for `g`.  But when we finish R, we carefully ensure that
    all those `LocalIds` are turned into completed `GlobalIds`, replete with
    unfoldings etc.   Alas, that will not apply to the occurrences of `g` in `f`'s
    unfolding. And if we leave matters like that, they will stay that way, and *all*
    subsequent modules that import A will see a crippled unfolding for `f`.
    
    Solution: rehydrate both R and A's ModIface together, right after completing R.hs.
    
    We only need rehydrate modules that are
    * Below R.hs
    * Above R.hs-boot
    
    There might be many unrelated modules (in the home package) that don't need to be
    rehydrated.
    
    This dark corner is the subject of #14092.
    
    Suppose we add to our example
    ```
    X.hs     module X where
               import A
               data XT = MkX T
               fx = ...g...
    ```
    If in `--make` we compile R.hs-boot, then A.hs, then X.hs, we'll get a `ModDetails` for `X` that has an AbstractTyCon for `T` in the the argument type of `MkX`.  So:
    
    * Either we should delay compiling X until after R has beeen compiled.
    * Or we should rehydrate X after compiling R -- because it transitively depends on R.hs-boot.
    
    Ticket #20200 has exposed some issues to do with the knot-tying logic in GHC.Make, in `--make` mode.
    this particular issue starts [here](https://gitlab.haskell.org/ghc/ghc/-/issues/20200#note_385758).
    
    The wiki page [Tying the knot](https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/tying-the-knot) is helpful.
    Also closely related are
        * #14092
        * #14103
    
    Fixes tickets #20200 #20561
    
    - - - - -
    f0c5d8d3 by Matthew Pickering at 2021-11-25T01:03:17-05:00
    Make T14075 more robust
    
    - - - - -
    6907e9fa by Matthew Pickering at 2021-11-25T01:03:17-05:00
    Revert "Convert lookupIdSubst panic back to a warning (#20200)"
    
    This reverts commit df1d808f26544cbb77d85773d672137c65fd3cc7.
    
    - - - - -
    baa8ffee by Greg Steuck at 2021-11-25T01:03:54-05:00
    Use getExecutablePath in getBaseDir on OpenBSD
    
    While OpenBSD doesn't have a general mechanism for determining the
    path of the executing program image, it is reasonable to rely on
    argv[0] which happens as a fallback in getExecutablePath.
    
    With this change on top of T18173 we can get a bit close to fixing #18173.
    
    - - - - -
    e3c59191 by Christiaan Baaij at 2021-11-25T01:04:32-05:00
    Ensure new Ct/evidence invariant
    
    The `ctev_pred` field of a `CtEvidence` is a just a cache for the type
    of the evidence.  More precisely:
    * For Givens, `ctev_pred` = `varType ctev_evar`
    * For Wanteds, `ctev_pred` = `evDestType ctev_dest`
    
    This new invariant is needed because evidence can become part of a
    type, via `Castty ty kco`.
    
    - - - - -
    3639ad8f by Christiaan Baaij at 2021-11-25T01:04:32-05:00
    Compare types of recursive let-bindings in alpha-equivalence
    
    This commit fixes #20641 by checking the types of recursive
    let-bindings when performing alpha-equality.
    
    The `Eq (DeBruijn CoreExpr)` instance now also compares
    `BreakPoint`s similarly to `GHC.Core.Utils.eqTickish`, taking
    bound variables into account.
    
    In addition, the `Eq (DeBruijn Type)` instance now correctly
    compares the kinds of the types when one of them contains a
    Cast: the instance is modeled after `nonDetCmpTypeX`.
    
    - - - - -
    7c65687e by CarrieMY at 2021-11-25T01:05:11-05:00
    Enable UnboxedTuples in `genInst`, Fixes #20524
    
    - - - - -
    e33412d0 by Krzysztof Gogolewski at 2021-11-25T01:05:46-05:00
    Misc cleanup
    
    * Remove `getTag_RDR` (unused), `tidyKind` and `tidyOpenKind`
      (already available as `tidyType` and `tidyOpenType`)
    
    * Remove Note [Explicit Case Statement for Specificity].
      Since 0a709dd9876e40 we require GHC 8.10 for bootstrapping.
    
    * Change the warning to `cmpAltCon` to a panic.
      This shouldn't happen.  If it ever does, the code was wrong anyway:
      it shouldn't always return `LT`, but rather `LT` in one case
      and `GT` in the other case.
    
    * Rename `verifyLinearConstructors` to `verifyLinearFields`
    
    * Fix `Note [Local record selectors]` which was not referenced
    
    * Remove vestiges of `type +v`
    
    * Minor fixes to StaticPointers documentation, part of #15603
    
    - - - - -
    bb71f7f1 by Greg Steuck at 2021-11-25T01:06:25-05:00
    Reorder `sed` arguments to work with BSD sed
    
    The order was swapped in 490e8c750ea23ce8e2b7309e0d514b7d27f231bb
    causing the build on OpenBSD to fail with:
    `sed: 1: "mk/config.h": invalid command code m`
    
    - - - - -
    c18a51f0 by John Ericson at 2021-11-25T01:06:25-05:00
    Apply 1 suggestion(s) to 1 file(s)
    - - - - -
    d530c46c by sheaf at 2021-11-25T01:07:04-05:00
    Add Data.Bits changes to base 4.16 changelog
    
      Several additions since 4.15 had not been recorded in the changelog:
    
        - newtypes And, Ior, Xor and Iff,
        - oneBits
        - symbolic synonyms `.^.`, `.>>.`, `!>>.`, `.<<.` and `!<<.`.
    
      Fixes #20608.
    
    - - - - -
    4d34bf15 by Matthew Pickering at 2021-11-25T01:07:40-05:00
    Don't use implicit lifting when deriving Lift
    
    It isn't much more complicated to be more precise when deriving Lift so
    we now generate
    
    ```
    data Foo = Foo Int Bool
    
    instance Lift Foo where
      lift (Foo a b) = [| Foo $(lift a) $(lift b) |]
      liftTyped (Foo a b) = [|| Foo $$(lift a) $$(lift b) |]
    ```
    
    This fixes #20688 which complained about using implicit lifting in the
    derived code.
    
    - - - - -
    8961d632 by Greg Steuck at 2021-11-25T01:08:18-05:00
    Disable warnings for unused goto labels
    
    Clang on OpenBSD aborts compilation with this diagnostics:
    ```
    % "inplace/bin/ghc-stage1" -optc-Wno-error=unused-label -optc-Wall -optc-Werror -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist-install/build/./autogen -optc-Irts/include/../dist-install/build/include -optc-Irts/include/. -optc-Irts/. -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -static  -O0 -H64m -Wall -fllvm-fill-undef-with-garbage    -Werror -this-unit-id rts -dcmm-lint     -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts        -O2 -Wcpp-undef   -Wnoncanonical-monad-instances  -c rts/linker/Elf.c -o rts/dist-install/build/linker/Elf.o
    
    rts/linker/Elf.c:2169:1: error:
         error: unused label 'dl_iterate_phdr_fail' [-Werror,-Wunused-label]
         |
    2169 | dl_iterate_phdr_fail:
         | ^
    dl_iterate_phdr_fail:
    ^~~~~~~~~~~~~~~~~~~~~
    
    rts/linker/Elf.c:2172:1: error:
         error: unused label 'dlinfo_fail' [-Werror,-Wunused-label]
         |
    2172 | dlinfo_fail:
         | ^
    dlinfo_fail:
    ^~~~~~~~~~~~
    2 errors generated.
    ```
    
    - - - - -
    5428b8c6 by Zubin Duggal at 2021-11-25T01:08:54-05:00
    testsuite: debounce title updates
    
    - - - - -
    96b3899e by Ben Gamari at 2021-11-25T01:09:29-05:00
    gitlab-ci: Add release jobs for Darwin targets
    
    As noted in #20707, the validate jobs which we previously used lacked
    profiling support.
    
    Also clean up some variable definitions.
    
    Fixes #20707.
    
    - - - - -
    52cdc2fe by Pepe Iborra at 2021-11-25T05:00:43-05:00
    Monoid instance for InstalledModuleEnv
    
    - - - - -
    47f36440 by Pepe Iborra at 2021-11-25T05:00:43-05:00
    Drop  instance Semigroup ModuleEnv
    
    There is more than one possible Semigroup and it is not needed since plusModuleEnv can be used directly
    
    - - - - -
    b742475a by Pepe Iborra at 2021-11-25T05:00:43-05:00
    drop instance Semigroup InstalledModuleEnv
    
    Instead, introduce plusInstalledModuleEnv
    
    - - - - -
    b24e8d91 by Roland Senn at 2021-11-25T05:01:21-05:00
    GHCi Debugger - Improve RTTI
    
    When processing the heap, use also `APClosures` to create additional type
    constraints. This adds more equations and therefore improves the unification
    process to infer the correct type of values at breakpoints.
    (Fix the `incr` part of #19559)
    
    - - - - -
    cf5279ed by Gergő Érdi at 2021-11-25T05:01:59-05:00
    Use `simplify` in non-optimizing build pipeline (#20500)
    
    - - - - -
    c9cead1f by Gergő Érdi at 2021-11-25T05:01:59-05:00
    Add specific optimization flag for fast PAP calls (#6084, #20500)
    
    - - - - -
    be0a9470 by Gergő Érdi at 2021-11-25T05:01:59-05:00
    Add specific optimization flag for Cmm control flow analysis (#20500)
    
    - - - - -
    b52a9a3f by Gergő Érdi at 2021-11-25T05:01:59-05:00
    Add `llvmOptLevel` to `DynFlags` (#20500)
    
    - - - - -
    f27a63fe by sheaf at 2021-11-25T05:02:39-05:00
    Allow boring class declarations in hs-boot files
    
      There are two different ways of declaring a class in an hs-boot file:
    
        - a full declaration, where everything is written as it is
          in the .hs file,
        - an abstract declaration, where class methods and superclasses
          are left out.
    
      However, a declaration with no methods and a trivial superclass,
      such as:
    
        class () => C a
    
      was erroneously considered to be an abstract declaration, because
      the superclass is trivial.
      This is remedied by a one line fix in GHC.Tc.TyCl.tcClassDecl1.
    
      This patch also further clarifies the documentation around
      class declarations in hs-boot files.
    
      Fixes #20661, #20588.
    
    - - - - -
    cafb1f99 by Ben Gamari at 2021-11-25T05:03:15-05:00
    compiler: Mark GHC.Prelude as Haddock no-home
    
    This significantly improves Haddock documentation generated by nix.
    
    - - - - -
    bd92c9b2 by Sebastian Graf at 2021-11-25T05:03:51-05:00
    hadrian: Add `collect_stats` flavour transformer
    
    This is useful for later consumption with
    https://gitlab.haskell.org/bgamari/ghc-utils/-/blob/master/ghc_timings.py
    
    - - - - -
    774fc4d6 by Ilias Tsitsimpis at 2021-11-25T08:34:54-05:00
    Link against libatomic for 64-bit atomic operations
    
    Some platforms (e.g., armel) require linking against libatomic for
    64-bit atomic operations.
    
    Fixes #20549
    
    - - - - -
    20101d9c by Greg Steuck at 2021-11-25T08:35:31-05:00
    Permit multiple values in config_args for validate
    
    The whitespace expansion should be permitted to pass multiple
    arguments to configure.
    
    - - - - -
    e2c48b98 by Greg Steuck at 2021-11-25T08:36:09-05:00
    Kill a use of %n format specifier
    
    This format has been used as a security exploit vector for decades
    now.  Some operating systems (OpenBSD, Android, MSVC). It is targeted
    for removal in C2X standard:
    http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2834.htm
    
    This requires extending the debug message function to return the
    number of bytes written (like printf(3)), to permit %n format
    specifier in one in one invocation of statsPrintf() in
    report_summary().
    
    Implemented by Matthias Kilian (kili<AT>outback.escape.de)
    
    - - - - -
    ff0c45f3 by Andrew Lelechenko at 2021-11-26T16:01:09-05:00
    Rename Data.ByteArray to Data.Array.ByteArray + add Trustworthy
    
    - - - - -
    9907d540 by Andrew Lelechenko at 2021-11-26T16:01:09-05:00
    Rename Data.Array.ByteArray -> Data.Array.Byte
    
    - - - - -
    0c8e1b4d by Kai Prott at 2021-11-26T16:01:47-05:00
    Improve error message for mis-typed plugins #20671
    
    Previously, when a plugin could not be loaded because it was incorrectly typed, the error message only printed the expected but not the actual type. 
    This commit augments the error message such that both types are printed and the corresponding module is printed as well.
    - - - - -
    51bcb986 by Kai Prott at 2021-11-26T16:01:47-05:00
    Remove duplicate import
    
    - - - - -
    1830eea7 by Kai Prott at 2021-11-26T16:01:47-05:00
    Simplify printQualification
    
    
    - - - - -
    69e62032 by Kai Prott at 2021-11-26T16:01:47-05:00
    Fix plugin type to GHC.Plugins.Plugin
    
    
    - - - - -
    0a6776a3 by Kai Prott at 2021-11-26T16:01:47-05:00
    Adapt plugin test case
    
    
    - - - - -
    7e18b304 by Kai Prott at 2021-11-26T16:01:47-05:00
    Reflect type change in the haddock comment
    
    - - - - -
    02372be1 by Matthew Pickering at 2021-11-26T16:02:23-05:00
    Allow keywords which can be used as variables to be used with OverloadedDotSyntax
    
    There are quite a few keywords which are allowed to be used as
    variables. Such as "as", "dependency" etc. These weren't accepted by
    OverloadedDotSyntax.
    
    The fix is pretty simple, use the varid production rather than raw
    VARID.
    
    Fixes #20723
    
    - - - - -
    13ef345c by John Ericson at 2021-11-27T19:41:11+00:00
    Factor our `FP_CAPITALIZE_YES_NO`
    
    This deduplicates converting from yes/no to YES/NO in the configure
    scripts while also making it safer.
    
    - - - - -
    88481c94 by John Ericson at 2021-11-27T19:46:16+00:00
    Fix top-level configure script so --disable-foo works
    
    - - - - -
    f67060c6 by John Ericson at 2021-11-27T19:47:09+00:00
    Make ambient MinGW support a proper settings
    
    Get rid of `USE_INPLACE_MINGW_TOOLCHAIN` and use a settings file entry
    instead.
    
    The CPP setting was originally introduced in f065b6b012.
    
    - - - - -
    1dc0d7af by Ben Gamari at 2021-11-29T11:02:43-05:00
    linker: Introduce linker_verbose debug output
    
    This splits the -Dl RTS debug output into two distinct flags:
    
     * `+RTS -Dl` shows errors and debug output which scales with at most
       O(# objects)
     * `+RTS -DL` shows debug output which scales with O(# symbols)t
    
    - - - - -
    7ea665bf by Krzysztof Gogolewski at 2021-11-29T11:03:19-05:00
    TTG: replace Void/NoExtCon with DataConCantHappen
    
    There were two ways to indicate that a TTG constructor is unused in a phase:
    `NoExtCon` and `Void`. This unifies the code, and uses the name
    'DataConCantHappen', following the discussion at MR 7041.
    
    Updates haddock submodule
    
    - - - - -
    14e9cab6 by Sylvain Henry at 2021-11-29T11:04:03-05:00
    Use Monoid in hptSomeThingsBelowUs
    
    It seems to have a moderate but good impact on perf tests in CI.
    
    In particular:
    
      MultiLayerModules(normal) ghc/alloc  3125771138.7  3065532240.0  -1.9%
    
    So it's likely that huge projects will benefit from this.
    
    - - - - -
    22bbf449 by Anton-Latukha at 2021-11-29T20:03:52+00:00
    docs/users_guide/bugs.rst: Rewording
    
    It is either "slightly" || "significantly".
    
    If it is "bogus" - then no quotes around "optimization" & overall using
    word "bogus" or use quotes in that way in documentation is... Instead,
    something like "hack" or "heuristic" can be used there.
    
    - - - - -
    9345bfed by Mitchell Rosen at 2021-11-30T01:32:22-05:00
    Fix caluclation of nonmoving GC elapsed time
    
    Fixes #20751
    
    - - - - -
    c7613493 by PHO at 2021-12-01T03:07:32-05:00
    rts/ProfHeap.c: Use setlocale() on platforms where uselocale() is not available
    
    Not all platforms have per-thread locales. NetBSD doesn't have uselocale() in particular. Using setlocale() is of course not a safe thing to do, but it would be better than no GHC at all.
    
    - - - - -
    4acfa0db by Ben Gamari at 2021-12-01T03:08:07-05:00
    rts: Refactor SRT representation selection
    
    The goal here is to make the SRT selection logic a bit clearer and allow
    configurations which we currently don't support (e.g. using a full word
    in the info table even when TNTC is used).
    
    - - - - -
    87bd9a67 by Ben Gamari at 2021-12-01T03:08:07-05:00
    gitlab-ci: Introduce no_tntc job
    
    A manual job for testing the non-tables-next-to-code configuration.
    
    - - - - -
    7acb945d by Carrie Xu at 2021-12-01T03:08:46-05:00
    Dump non-module specific info to file #20316
    
    - Change the dumpPrefix to FilePath, and default to non-module
    - Add dot to seperate dump-file-prefix and suffix
    - Modify user guide to introduce how dump files are named
    - This commit does not affect Ghci dump file naming.
    
    See also #17500
    
    - - - - -
    7bdca2ba by Ben Gamari at 2021-12-01T03:09:21-05:00
    rts/RtsSymbols: Provide a proper prototype for environ
    
    Previously we relied on Sym_NeedsProto, but this gave the symbol a type
    which conflicts with the definition that may be provided by unistd.h.
    
    Fixes #20577.
    
    - - - - -
    91d1a773 by Ben Gamari at 2021-12-01T03:09:21-05:00
    hadrian: Don't pass empty paths via -I
    
    Previously we could in some cases add empty paths to `cc`'s include file
    search path. See #20578.
    
    - - - - -
    d8d57729 by Ben Gamari at 2021-12-01T03:09:21-05:00
    ghc-cabal: Manually specify -XHaskell2010
    
    Otherwise we end up with issues like #19631 when bootstrapping using GHC
    9.2 and above.
    
    Fixes #19631.
    
    - - - - -
    1c0c140a by Ben Gamari at 2021-12-01T03:09:21-05:00
    ghc-compact: Update cabal file
    
    Improve documentation, bump bounds and cabal-version.
    
    - - - - -
    322b6b45 by Ben Gamari at 2021-12-01T03:09:21-05:00
    hadrian: Document fully_static flavour transformer
    
    - - - - -
    4c434c9e by Ben Gamari at 2021-12-01T03:09:21-05:00
    user-guide: Fix :since: of -XCApiFFI
    
    Closes #20504.
    
    - - - - -
    0833ad55 by Matthew Pickering at 2021-12-01T03:09:58-05:00
    Add failing test for #20674
    
    - - - - -
    c2cb5e9a by Ben Gamari at 2021-12-01T03:10:34-05:00
    testsuite: Print geometric mean of stat metrics
    
    As suggested in #20733.
    
    - - - - -
    59b27945 by Ben Gamari at 2021-12-01T03:11:09-05:00
    users-guide: Describe requirements of DWARF unwinding
    
    As requested in #20702
    
    - - - - -
    c2f6cbef by Matthew Pickering at 2021-12-01T03:11:45-05:00
    Fix several quoting issues in testsuite
    
    This fixes the ./validate script on my machine.
    
    I also took the step to add some linters which would catch problems like
    these in future.
    
    Fixes #20506
    
    - - - - -
    bffd4074 by John Ericson at 2021-12-01T03:12:21-05:00
    rts.cabal.in: Move `extra-source-files` so it is valid
    
    - - - - -
    86c14db5 by John Ericson at 2021-12-01T03:12:21-05:00
    Switch RTS cabal file / package conf to use Rts.h not Stg.h
    
    When we give cabal a configure script, it seems to begin checking
    whether or not Stg.h is valid, and then gets tripped up on all the
    register stuff which evidentally requires obscure command line flags to
    go.
    
    We can side-step this by making the test header Rts.h instead, which is
    more normal.
    
    I was a bit sketched out making this change, as I don't know why the
    Cabal library would suddenly beging checking the header. But I did
    confirm even without my RTS configure script the header doesn't compile
    stand-alone, and also the Stg.h is a probably-arbitrary choice since it
    dates all the way back to 2002 in
    2cc5b907318f97e19b28b2ad8ed9ff8c1f401dcc.
    
    - - - - -
    defd8d54 by John Ericson at 2021-12-01T03:12:21-05:00
    Avoid raw `echo` in `FPTOOLS_SET_PLATFORM_VARS`
    
    This ensures quiet configuring works.
    
    - - - - -
    b53f1227 by John Ericson at 2021-12-01T03:12:21-05:00
    Factor our `$dir_$distdir_PKGDATA` make variable
    
    This makes a few things cleaner.
    
    - - - - -
    f124f2a0 by Ben Gamari at 2021-12-01T03:12:56-05:00
    rts: Annotate benign race in pthread ticker's exit test
    
    Previously TSAN would report spurious data races due to
    the unsynchronized access of `exited`. I would have thought
    that using a relaxed load on `exited` would be enough to convince
    TSAN that the race was intentional, but apparently not.
    
    Closes #20690.
    - - - - -
    d3c7f9be by Viktor Dukhovni at 2021-12-01T03:13:34-05:00
    Use POSIX shell syntax to redirect stdout/err
    
    FreeBSD (and likely NetBSD) /bin/sh does not support '>& word' to
    redirect stdout + stderr.  (Also the preferred syntax in bash would
    be '&> word' to avoid surprises when `word` is "-" or a number).
    
    Resolves: #20760
    
    - - - - -
    1724ac37 by Ben Gamari at 2021-12-02T18:13:30-05:00
    nativeGen/x86: Don't encode large shift offsets
    
    Handle the case of a shift larger than the width of the shifted value.
    This is necessary since x86 applies a mask of 0x1f to the shift amount,
    meaning that, e.g., `shr 47, $eax` will actually shift by
    47 & 0x1f == 15.
    
    See #20626.
    
    (cherry picked from commit 31370f1afe1e2f071b3569fb5ed4a115096127ca)
    
    - - - - -
    5b950a7f by Ben Gamari at 2021-12-02T18:13:30-05:00
    cmm: narrow when folding signed quotients
    
    Previously the constant-folding behavior for MO_S_Quot and MO_S_Rem
    failed to narrow its arguments, meaning that a program like:
    
        %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8))
    
    would be miscompiled. Specifically, this program should reduce as
    
                    %lobits8(0x00e1::bits16)                 == -31
              %quot(%lobits8(0x00e1::bits16), 3::bits8)      == -10
        %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8))     == 246
    
    However, with this bug the `%lobits8(0x00e1::bits16)` would instead
    be treated as `+31`, resulting in the incorrect result of `75`.
    
    (cherry picked from commit 94e197e3dbb9a48991eb90a03b51ea13d39ba4cc)
    
    - - - - -
    78b78ac4 by Ben Gamari at 2021-12-02T18:13:30-05:00
    ncg/aarch64: Don't sign extend loads
    
    Previously we would emit the sign-extending LDS[HB] instructions for
    sub-word loads. However, this is wrong, as noted in #20638.
    
    - - - - -
    35bbc251 by Ben Gamari at 2021-12-02T18:13:30-05:00
    cmm: Disallow shifts larger than shiftee
    
    Previously primops.txt.pp stipulated that the word-size shift primops
    were only defined for shift offsets in [0, word_size). However, there
    was no further guidance for the definition of Cmm's sub-word size shift
    MachOps.
    
    Here we fix this by explicitly disallowing (checked in many cases by
    CmmLint) shift operations where the shift offset is larger than the
    shiftee. This is consistent with LLVM's shift operations, avoiding the
    miscompilation noted in #20637.
    
    - - - - -
    2f6565cf by Ben Gamari at 2021-12-02T18:13:30-05:00
    testsuite: Add testcases for various machop issues
    
    There were found by the test-primops testsuite.
    
    - - - - -
    7094f4fa by Ben Gamari at 2021-12-02T18:13:30-05:00
    nativeGen/aarch64: Don't rely on register width to determine amode
    
    We might be loading, e.g., a 16- or 8-bit value, in which case the
    register width is not reflective of the loaded element size.
    
    - - - - -
    9c65197e by Ben Gamari at 2021-12-02T18:13:30-05:00
    cmm/opt: Fold away shifts larger than shiftee width
    
    This is necessary for lint-correctness since we no longer allow such
    shifts in Cmm.
    
    - - - - -
    adc7f108 by Ben Gamari at 2021-12-02T18:13:30-05:00
    nativeGen/aarch64: Fix handling of subword values
    
    Here we rework the handling of sub-word operations in the AArch64
    backend, fixing a number of bugs and inconsistencies. In short,
    we now impose the invariant that all subword values are represented in
    registers in zero-extended form. Signed arithmetic operations are then
    responsible for sign-extending as necessary.
    
    Possible future work:
    
     * Use `CMP`s extended register form to avoid burning an instruction
       in sign-extending the second operand.
    
     * Track sign-extension state of registers to elide redundant sign
       extensions in blocks with frequent sub-word signed arithmetic.
    
    - - - - -
    e19e9e71 by Ben Gamari at 2021-12-02T18:13:31-05:00
    CmmToC: Fix width of shift operations
    
    Under C's implicit widening rules, the result of an operation like (a >>
    b) where a::Word8 and b::Word will have type Word, yet we want Word.
    
    - - - - -
    ebaf7333 by Ben Gamari at 2021-12-02T18:13:31-05:00
    CmmToC: Zero-extend sub-word size results
    
    As noted in Note [Zero-extending sub-word signed results] we must
    explicitly zero-extend the results of sub-word-sized signed operations.
    
    - - - - -
    0aeaa8f3 by Ben Gamari at 2021-12-02T18:13:31-05:00
    CmmToC: Always cast arguments as unsigned
    
    As noted in Note [When in doubt, cast arguments as unsigned], we
    must ensure that arguments have the correct signedness since some
    operations (e.g. `%`) have different semantics depending upon
    signedness.
    
    - - - - -
    e98dad1b by Ben Gamari at 2021-12-02T18:13:31-05:00
    CmmToC: Cast possibly-signed results as unsigned
    
    C11 rule 6.3.1.1 dictates that all small integers used in expressions be
    implicitly converted to `signed int`.  However, Cmm semantics require that the
    width of the operands be preserved with zero-extension semantics. For
    this reason we must recast sub-word arithmetic results as unsigned.
    
    - - - - -
    44c08863 by Ben Gamari at 2021-12-02T18:13:31-05:00
    testsuite: Specify expected word-size of machop tests
    
    These generally expect a particular word size.
    
    - - - - -
    fab2579e by Ben Gamari at 2021-12-02T18:14:06-05:00
    hadrian: Don't rely on realpath in bindist Makefile
    
    As noted in #19963, `realpath` is not specified by POSIX and therefore
    cannot be assumed to be available. Here we provide a POSIX shell
    implementation of `realpath`, due to Julian Ospald and others.
    
    Closes #19963.
    
    - - - - -
    99eb54bd by Kamil Dworakowski at 2021-12-02T21:45:10-05:00
    Make openFile more tolerant of async excs (#18832)
    
    - - - - -
    0e274c39 by nineonine at 2021-12-02T21:45:49-05:00
    Require all dirty_MUT_VAR callers to do explicit stg_MUT_VAR_CLEAN_info comparison (#20088)
    
    - - - - -
    81082cf4 by Matthew Pickering at 2021-12-03T10:12:04-05:00
    Revert "Data.List specialization to []"
    
    This reverts commit bddecda1a4c96da21e3f5211743ce5e4c78793a2.
    
    This implements the first step in the plan formulated in #20025 to
    improve the communication and migration strategy for the proposed
    changes to Data.List.
    
    Requires changing the haddock submodule to update the test output.
    
    - - - - -
    a9e035a4 by sheaf at 2021-12-03T10:12:42-05:00
    Test-suite: fix geometric mean of empty list
    
      The geometric mean computation panicked when it was given
      an empty list, which happens when there are no baselines.
    
      Instead, we should simply return 1.
    
    - - - - -
    d72720f9 by Matthew Pickering at 2021-12-06T16:27:35+00:00
    Add section to the user guide about OS memory usage
    
    - - - - -
    0fe45d43 by Viktor Dukhovni at 2021-12-07T06:27:12-05:00
    List-monomorphic `foldr'`
    
    While a *strict* (i.e. constant space) right-fold on lists is not
    possible, the default `foldr'` is optimised for structures like
    `Seq`, that support efficient access to the right-most elements.
    The original default implementation seems to have a better
    constant factor for lists, so we add a monomorphic implementation
    in GHC.List.
    
    Should this be re-exported from `Data.List`?  That would be a
    user-visible change if both `Data.Foldable` and `Data.List` are
    imported unqualified...
    
    - - - - -
    7d2283b9 by Ben Gamari at 2021-12-07T06:27:47-05:00
    compiler: Eliminate accidental loop in GHC.SysTools.BaseDir
    
    As noted in #20757, `GHC.SysTools.BaseDir.findToolDir` previously
    contained an loop, which would be triggered in the case that the search
    failed.
    
    Closes #20757.
    
    - - - - -
    8044e232 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00
    More specific documentation of foldr' caveats
    
    - - - - -
    d932e2d6 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00
    Use italic big-O notation in Data.Foldable
    
    - - - - -
    57c9c0a2 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00
    Fix user-guide typo
    
    - - - - -
    324772bb by Ben Gamari at 2021-12-07T06:28:59-05:00
    rts/Linker: Ensure that mmap_32bit_base is updated after mapping
    
    The amount of duplicated code in `mmapForLinker` hid the fact that some
    codepaths would fail to update `mmap_32bit_base` (specifically, on
    platforms like OpenBSD where `MAP_32BIT` is not supported).
    
    Refactor the function to make the implementation more obviously correct.
    
    Closes #20734.
    
    - - - - -
    5dbdf878 by Ben Gamari at 2021-12-07T06:28:59-05:00
    rts: +RTS -DL should imply +RTS -Dl
    
    Otherwise the user may be surprised by the missing context provided by
    the latter.
    
    - - - - -
    7eb56064 by sheaf at 2021-12-07T06:29:38-05:00
    More permissive parsing of higher-rank type IPs
    
      The parser now accepts implicit parameters with higher-rank
      types, such as
    
      `foo :: (?ip :: forall a. a -> a) => ...`
    
      Before this patch, we instead insisted on parentheses like so:
    
      `foo :: (?ip :: (forall a. a -> a)) => ...`
    
      The rest of the logic surrounding implicit parameters is unchanged;
      in particular, even with ImpredicativeTypes, this idiom is not
      likely to be very useful.
    
      Fixes #20654
    
    - - - - -
    427f9c12 by sheaf at 2021-12-07T13:32:55-05:00
    Re-export GHC.Types from GHC.Exts
    
      Several times in the past, it has happened that things from GHC.Types
      were not re-exported from GHC.Exts, forcing users to import either
      GHC.Types or GHC.Prim, which are subject to internal change without
      notice.
    
      We now re-export GHC.Types from GHC.Exts, which should avoid this
      happening again in the future.
      In particular, we now re-export `Multiplicity` and `MultMul`,
      which we didn't before.
    
      Fixes #20695
    
    - - - - -
    483bd04d by Sebastian Graf at 2021-12-07T13:33:31-05:00
    Explicit Data.List import list in check-ppr (#20789)
    
    `check-ppr` features an import of Data.List without an import list.
    After 81082cf4, this breaks the local validate flavour because of the compat
    warning and `-Werror`. So fix that.
    
    Fixes #20789.
    
    - - - - -
    cc2bf8e9 by Norman Ramsey at 2021-12-07T17:34:51-05:00
    generalize GHC.Cmm.Dataflow to work over any node type
    
    See #20725.
    
    The commit includes source-code changes and a test case.
    
    - - - - -
    4c6985cc by Sylvain Henry at 2021-12-07T17:35:30-05:00
    Perf: remove an indirection when fetching the unique mask
    
    Slight decrease but still noticeable on CI:
    
                                                   Baseline
                               Test    Metric         value     New value Change
    -----------------------------------------------------------------------------
           ManyAlternatives(normal) ghc/alloc   747607676.0   747458936.0  -0.0%
           ManyConstructors(normal) ghc/alloc  4003722296.0  4003530032.0  -0.0%
          MultiLayerModules(normal) ghc/alloc  3064539560.0  3063984552.0  -0.0%
    MultiLayerModulesRecomp(normal) ghc/alloc   894700016.0   894700624.0  +0.0%
                  PmSeriesG(normal) ghc/alloc    48410952.0    48262496.0  -0.3%
                  PmSeriesS(normal) ghc/alloc    61561848.0    61415768.0  -0.2%
                  PmSeriesT(normal) ghc/alloc    90975784.0    90829360.0  -0.2%
                  PmSeriesV(normal) ghc/alloc    60405424.0    60259008.0  -0.2%
                     T10421(normal) ghc/alloc   113275928.0   113137168.0  -0.1%
                    T10421a(normal) ghc/alloc    79195676.0    79050112.0  -0.2%
                     T10547(normal) ghc/alloc    28720176.0    28710008.0  -0.0%
                     T10858(normal) ghc/alloc   180992412.0   180857400.0  -0.1%
                     T11195(normal) ghc/alloc   283452220.0   283293832.0  -0.1%
                     T11276(normal) ghc/alloc   137882128.0   137745840.0  -0.1%
                    T11303b(normal) ghc/alloc    44453956.0    44309184.0  -0.3%
                     T11374(normal) ghc/alloc   248118668.0   247979880.0  -0.1%
                     T11545(normal) ghc/alloc   971994728.0   971852696.0  -0.0%
                     T11822(normal) ghc/alloc   131544864.0   131399024.0  -0.1%
                     T12150(optasm) ghc/alloc    79336468.0    79191888.0  -0.2%
                     T12227(normal) ghc/alloc   495064180.0   494943040.0  -0.0%
                     T12234(optasm) ghc/alloc    57198468.0    57053568.0  -0.3%
                     T12425(optasm) ghc/alloc    90928696.0    90793440.0  -0.1%
                     T12545(normal) ghc/alloc  1695417772.0  1695275744.0  -0.0%
                     T12707(normal) ghc/alloc   956258984.0   956138864.0  -0.0%
                     T13035(normal) ghc/alloc   102279484.0   102132616.0  -0.1%
                     T13056(optasm) ghc/alloc   367196556.0   367066408.0  -0.0%
                     T13253(normal) ghc/alloc   334365844.0   334255264.0  -0.0%
                 T13253-spj(normal) ghc/alloc   125474884.0   125328672.0  -0.1%
                     T13379(normal) ghc/alloc   359185604.0   359036960.0  -0.0%
                     T13701(normal) ghc/alloc  2403026480.0  2402677464.0  -0.0%
                     T13719(normal) ghc/alloc  4192234752.0  4192039448.0  -0.0%
                       T14052(ghci) ghc/alloc  2745868552.0  2747706176.0  +0.1%
                   T14052Type(ghci) ghc/alloc  7335937964.0  7336283280.0  +0.0%
                     T14683(normal) ghc/alloc  2992557736.0  2992436872.0  -0.0%
                     T14697(normal) ghc/alloc   363391248.0   363222920.0  -0.0%
                     T15164(normal) ghc/alloc  1292578008.0  1292434240.0  -0.0%
                     T15304(normal) ghc/alloc  1279603472.0  1279465944.0  -0.0%
                     T15630(normal) ghc/alloc   161707776.0   161602632.0  -0.1%
                     T16190(normal) ghc/alloc   276904644.0   276555264.0  -0.1%
                     T16577(normal) ghc/alloc  7573033016.0  7572982752.0  -0.0%
                     T16875(normal) ghc/alloc    34937980.0    34796592.0  -0.4%
                     T17096(normal) ghc/alloc   287436348.0   287299368.0  -0.0%
                     T17516(normal) ghc/alloc  1714727484.0  1714617664.0  -0.0%
                     T17836(normal) ghc/alloc  1091095748.0  1090958168.0  -0.0%
                    T17836b(normal) ghc/alloc    52467912.0    52321296.0  -0.3%
                     T17977(normal) ghc/alloc    44971660.0    44826480.0  -0.3%
                    T17977b(normal) ghc/alloc    40941128.0    40793160.0  -0.4%
                     T18140(normal) ghc/alloc    82363124.0    82213056.0  -0.2%
                     T18223(normal) ghc/alloc  1168448128.0  1168333624.0  -0.0%
                     T18282(normal) ghc/alloc   131577844.0   131440400.0  -0.1%
                     T18304(normal) ghc/alloc    86988664.0    86844432.0  -0.2%
                     T18478(normal) ghc/alloc   742992400.0   742871136.0  -0.0%
                    T18698a(normal) ghc/alloc   337654412.0   337526792.0  -0.0%
                    T18698b(normal) ghc/alloc   398840772.0   398716472.0  -0.0%
                     T18923(normal) ghc/alloc    68964992.0    68818768.0  -0.2%
                      T1969(normal) ghc/alloc   764285884.0   764156168.0  -0.0%
                     T19695(normal) ghc/alloc  1395577984.0  1395552552.0  -0.0%
                     T20049(normal) ghc/alloc    89159032.0    89012952.0  -0.2%
                      T3064(normal) ghc/alloc   191194856.0   191051816.0  -0.1%
                      T3294(normal) ghc/alloc  1604762016.0  1604656488.0  -0.0%
                      T4801(normal) ghc/alloc   296829368.0   296687824.0  -0.0%
                      T5030(normal) ghc/alloc   364720540.0   364580152.0  -0.0%
                    T5321FD(normal) ghc/alloc   271090004.0   270950824.0  -0.1%
                   T5321Fun(normal) ghc/alloc   301244320.0   301102960.0  -0.0%
                      T5631(normal) ghc/alloc   576154548.0   576022904.0  -0.0%
                      T5642(normal) ghc/alloc   471105876.0   470967552.0  -0.0%
                      T5837(normal) ghc/alloc    36328620.0    36186720.0  -0.4%
                      T6048(optasm) ghc/alloc   103125988.0   102981024.0  -0.1%
                       T783(normal) ghc/alloc   386945556.0   386795984.0  -0.0%
                      T9020(optasm) ghc/alloc   247835012.0   247696704.0  -0.1%
                      T9198(normal) ghc/alloc    47556208.0    47413784.0  -0.3%
                      T9233(normal) ghc/alloc   682210596.0   682069960.0  -0.0%
                      T9630(normal) ghc/alloc  1429689648.0  1429581168.0  -0.0%
                      T9675(optasm) ghc/alloc   431092812.0   430943192.0  -0.0%
                     T9872a(normal) ghc/alloc  1705052592.0  1705042064.0  -0.0%
                     T9872b(normal) ghc/alloc  2180406760.0  2180395784.0  -0.0%
                     T9872c(normal) ghc/alloc  1760508464.0  1760497936.0  -0.0%
                     T9872d(normal) ghc/alloc   501517968.0   501309464.0  -0.0%
                      T9961(normal) ghc/alloc   354037204.0   353891576.0  -0.0%
       TcPlugin_RewritePerf(normal) ghc/alloc  2381708520.0  2381550824.0  -0.0%
                      WWRec(normal) ghc/alloc   589553520.0   589407216.0  -0.0%
             hard_hole_fits(normal) ghc/alloc   492122188.0   492470648.0  +0.1%
                     hie002(normal) ghc/alloc  9336434800.0  9336443496.0  +0.0%
                 parsing001(normal) ghc/alloc   537680944.0   537659824.0  -0.0%
    
                          geo. mean                                        -0.1%
    
    - - - - -
    aafa5079 by Andrew Lelechenko at 2021-12-09T04:26:35-05:00
    Bump bytestring submodule to 0.11.2.0
    
    Both tests import `Data.ByteString`, so the change in allocations is more or less expected.
    
    Metric Increase:
        T19695
        T9630
    
    - - - - -
    803eefb1 by Matthew Pickering at 2021-12-09T04:27:11-05:00
    package imports: Take into account package visibility when renaming
    
    In 806e49ae the package imports refactoring code was modified to rename
    package imports. There was a small oversight which meant the code didn't
    account for module visibility. This patch fixes that oversight.
    
    In general the "lookupPackageName" function is unsafe to use as it
    doesn't account for package visiblity/thinning/renaming etc, there is
    just one use in the compiler which would be good to audit.
    
    Fixes #20779
    
    - - - - -
    52bbea0f by Viktor Dukhovni at 2021-12-09T04:27:48-05:00
    Fix typo and outdated link in Data.Foldable
    
    Amazing nobody had reported the "Foldabla" typo. :-(
    
    The Traversable docs got overhauled, leaving a stale
    link in Foldable to a section that got replaced.  Gave
    the new section an anchor and updated the link.
    
    - - - - -
    a722859f by Viktor Dukhovni at 2021-12-09T04:27:48-05:00
    A few more typos
    
    - - - - -
    d6177cb5 by Viktor Dukhovni at 2021-12-09T04:27:48-05:00
    Drop O(n^2) warning on concat
    
    - - - - -
    9f988525 by David Feuer at 2021-12-09T13:49:47+00:00
    Improve mtimesDefault
    
    * Make 'mtimesDefault' use 'stimes' for the underlying monoid
      rather than the default 'stimes'.
    
    * Explain in the documentation why one might use `mtimesDefault`.
    
    - - - - -
    2fca50d4 by Gergő Érdi at 2021-12-09T22:14:24-05:00
    Use same optimization pipeline regardless of `optLevel` (#20500)
    
    - - - - -
    6d031922 by Gergő Érdi at 2021-12-09T22:14:24-05:00
    Add `Opt_CoreConstantFolding` to turn on constant folding (#20500)
    
    Previously, `-O1` and `-O2`, by way of their effect on the compilation
    pipeline, they implicitly turned on constant folding
    
    - - - - -
    b6f7d145 by Gergő Érdi at 2021-12-09T22:14:24-05:00
    Remove `optLevel` from `DynFlags` (closes #20500)
    
    - - - - -
    724df9c3 by Ryan Scott at 2021-12-09T22:15:00-05:00
    Hadrian: Allow building with GHC 9.2
    
    A separate issue is the fact that many of `hadrian`'s modules produce
    `-Wincomplete-uni-patterns` warnings under 9.2, but that is probably best left
    to a separate patch.
    
    - - - - -
    80a25502 by Matthew Pickering at 2021-12-09T22:15:35-05:00
    Use file hash cache when hashing object file dependencies
    
    This fixes the immediate problem that we hash the same file multiple
    different times which causes quite a noticeably performance regression.
    
    In the future we can probably do better than this by storing the
    implementation hash in the interface file rather than dependending on
    hashing the object file.
    
    Related to #20604 which notes some inefficiencies with the current
    recompilation logic.
    
    Closes #20790
    
    -------------------------
    Metric Decrease:
        T14052Type
    -------------------------
    
    - - - - -
    f573cb16 by nineonine at 2021-12-10T06:16:41-05:00
    rts: use allocation helpers from RtsUtils
    
    Just a tiny cleanup inspired by the following comment:
    https://gitlab.haskell.org/ghc/ghc/-/issues/19437#note_334271
    I was just getting familiar with rts code base so I
    thought might as well do this.
    
    - - - - -
    16eab39b by Matthew Pickering at 2021-12-10T06:17:16-05:00
    Remove confusing haddock quotes in 'readInt' documentation
    
    As pointed out in #20776, placing quotes in this way linked to the
    'Integral' type class which is nothing to do with 'readInt', the text
    should rather just be "integral", to suggest that the argument must be
    an integer.
    
    Closes #20776
    
    - - - - -
    b4a55419 by Ben Gamari at 2021-12-10T06:17:52-05:00
    docs: Drop old release notes
    
    Closes #20786
    
    - - - - -
    8d1f30e7 by Jakob Brünker at 2021-12-11T00:55:48-05:00
    Add PromotedInfixT/PromotedUInfixT to TH
    
    Previously, it was not possible to refer to a data constructor using
    InfixT with a dynamically bound name (i.e. a name with NameFlavour
    `NameS` or `NameQ`) if a type constructor of the same
    name exists.
    
    This commit adds promoted counterparts to InfixT and UInfixT,
    analogously to how PromotedT is the promoted counterpart to ConT.
    
    Closes #20773
    
    - - - - -
    785859fa by Andrew Lelechenko at 2021-12-11T00:56:26-05:00
    Bump text submodule to 2.0-rc2
    
    - - - - -
    352284de by Sylvain Henry at 2021-12-11T00:57:05-05:00
    Perf: remove allocation in writeBlocks and fix comment (#14309)
    
    - - - - -
    40a44f68 by Douglas Wilson at 2021-12-12T09:09:30-05:00
    rts: correct stats when running with +RTS -qn1
    
    Despite the documented care having been taken, several bugs are fixed here.
    
    When run with -qn1, when a SYNC_GC_PAR is requested we will have
    
    n_gc_threads == n_capabilities && n_gc_idle_threads == (n_gc_threads - 1)
    
    In this case we now:
    * Don't increment par_collections
    * Don't increment par_balanced_copied
    * Don't emit debug traces for idle threads
    * Take the fast path in scavenge_until_all_done, wakeup_gc_threads, and
        shutdown_gc_threads.
    
    Some ASSERTs have also been tightened.
    
    Fixes #19685
    
    - - - - -
    6b2947d2 by Matthew Pickering at 2021-12-12T09:10:06-05:00
    iserv: Remove network dependent parts of libiserv
    
    As noted in #20794 the parts of libiserv and iserv-proxy depend on
    network, therefore are never built nor tested during CI.
    
    Due to this iserv-proxy had bitrotted due to the bound on bytestring
    being out of date.
    
    Given we don't test this code it seems undesirable to distribute it.
    Therefore, it's removed and an external maintainer can be responsible
    for testing it (via head.hackage if desired).
    
    Fixes #20794
    
    - - - - -
    f04d1a49 by Ben Gamari at 2021-12-12T09:10:41-05:00
    gitlab-ci: Bump fedora jobs to use Fedora 33
    
    Annoyingly, this will require downstream changes in head.hackage, which
    depends upon the artifact produced by this job.
    
    Prompted by !6462.
    
    - - - - -
    93783e6a by Andrey Mokhov at 2021-12-12T09:11:20-05:00
    Drop --configure from Hadrian docs
    
    - - - - -
    31bf380f by Oleg Grenrus at 2021-12-12T12:52:18-05:00
    Use HasCallStack and error in GHC.List and .NonEmpty
    
    In addition to providing stack traces, the scary HasCallStack will
    hopefully make people think whether they want to use these functions,
    i.e. act as a documentation hint that something weird might happen.
    
    A single metric increased, which doesn't visibly
    use any method with `HasCallStack`.
    
    -------------------------
    Metric Decrease:
        T9630
    Metric Decrease:
        T19695
        T9630
    -------------------------
    
    - - - - -
    401ddd53 by Greg Steuck at 2021-12-12T12:52:56-05:00
    Respect W^X in Linker.c:preloadObjectFile on OpenBSD
    
    This fixes -fexternal-interpreter for ghci. Fixes #20814.
    
    - - - - -
    c43ee6b8 by Andreas Klebinger at 2021-12-14T19:24:20+01:00
    GHC.Utils.Misc.only: Add doc string.
    
    This function expects a singleton list as argument but only checks this
    in debug builds. I've added a docstring saying so.
    
    Fixes #20797
    
    - - - - -
    9ff54ea8 by Vaibhav Sagar at 2021-12-14T20:50:08-05:00
    Data.Functor.Classes: fix Ord1 instance for Down
    
    - - - - -
    8a2de3c2 by Tamar Christina at 2021-12-14T20:50:47-05:00
    rts: update xxhash used by the linker's hashmap
    
    - - - - -
    1c8d609a by alirezaghey at 2021-12-14T20:51:25-05:00
    fix ambiguity in `const` documentation
    
    fixes #20412
    
    - - - - -
    a5d8d47f by Joachim Breitner at 2021-12-14T20:52:00-05:00
    Ghci environment: Do not remove shadowed ids
    
    Names defined earier but shadowed need to be kept around, e.g. for type
    signatures:
    ```
    ghci> data T = T
    ghci> let t = T
    ghci> data T = T
    ghci> :t t
    t :: Ghci1.T
    ```
    and indeed they can be used:
    ```
    ghci> let t2 = Ghci1.T :: Ghci1.T
    ghci> :t t2
    t2 :: Ghci1.T
    ```
    
    However, previously this did not happen for ids (non-types), although they
    are still around under the qualified name internally:
    ```
    ghci> let t = "other t"
    ghci> t'
    
    <interactive>:8:1: error:
        • Variable not in scope: t'
        • Perhaps you meant one of these:
            ‘Ghci2.t’ (imported from Ghci2), ‘t’ (line 7), ‘t2’ (line 5)
    ghci> Ghci2.t
    
    <interactive>:9:1: error:
        • GHC internal error: ‘Ghci2.t’ is not in scope during type checking, but it passed the renamer
          tcl_env of environment: []
        • In the expression: Ghci2.t
          In an equation for ‘it’: it = Ghci2.t
    ```
    
    This fixes the problem by simply removing the code that tries to remove
    shadowed ids from the environment. Now you can refer to shadowed ids using
    `Ghci2.t`, just like you can do for data and type constructors. This
    simplifies the code, makes terms and types more similar, and also
    fixes #20455.
    
    Now all names ever defined in GHCi are in `ic_tythings`, which is printed by
    `:show bindings`. But for that commands, it seems to be more ergonomic
    to only list those bindings that are not shadowed. Or, even if it is not
    more ergonomic, it’s the current behavour. So let's restore that by filtering
    in `icInScopeTTs`.
    
    Of course a single `TyThing` can be associated with many names. We keep
    it it in the bindings if _any_ of its names are still visible
    unqualifiedly. It's a judgement call.
    
    This commit also turns a rather old comment into a test files.
    The comment is is rather stale and things are better explained
    elsewhere. Fixes #925.
    
    Two test cases are regressing:
    
                       T14052(ghci) ghc/alloc  2749444288.0 12192109912.0 +343.4% BAD
                   T14052Type(ghci) ghc/alloc  7365784616.0 10767078344.0  +46.2% BAD
    
    This is not unexpected; the `ic_tythings list grows` a lot more if we
    don’t remove shadowed Ids. I tried to alleviate it a bit with earlier
    MRs, but couldn’t make up for it completely.
    
    Metric Increase:
        T14052
        T14052Type
    
    - - - - -
    7c2609d8 by Cheng Shao at 2021-12-14T20:52:37-05:00
    base: fix clockid_t usage when it's a pointer type in C
    
    Closes #20607.
    
    - - - - -
    55cb2aa7 by MichaWiedenmann1 at 2021-12-14T20:53:16-05:00
    Fixes typo in documentation of the Semigroup instance of Equivalence
    - - - - -
    82c39f4d by Ben Gamari at 2021-12-14T20:53:51-05:00
    users-guide: Fix documentation for -shared flag
    
    This flag was previously called `--mk-dll`. It was renamed to `-shared`
    in b562cbe381d54e08dcafa11339e9a82e781ad557 but the documentation wasn't
    updated to match.
    
    - - - - -
    4f654071 by Ben Gamari at 2021-12-14T20:53:51-05:00
    compiler: Drop `Maybe ModLocation` from T_MergeForeign
    
    This field was entirely unused.
    
    - - - - -
    71ecb55b by Ben Gamari at 2021-12-14T20:53:51-05:00
    compiler: Use withFile instead of bracket
    
    A minor refactoring noticed by hlint.
    
    - - - - -
    5686f47b by Ben Gamari at 2021-12-14T20:53:51-05:00
    ghc-bin: Add --merge-objs mode
    
    This adds a new mode, `--merge-objs`, which can be used to produce
    merged GHCi library objects.
    
    As future work we will rip out the object-merging logic in Hadrian and
    Cabal and instead use this mode.
    
    Closes #20712.
    
    - - - - -
    0198bb11 by Ben Gamari at 2021-12-14T20:54:27-05:00
    libiserv: Rename Lib module to IServ
    
    As proposed in #20546.
    
    - - - - -
    ecaec722 by doyougnu at 2021-12-14T20:55:06-05:00
    CmmToLlvm: Remove DynFlags, add LlvmCgConfig
    
    CodeOutput: LCGConfig, add handshake initLCGConfig
    
    Add two modules:
    GHC.CmmToLlvm.Config                -- to hold the Llvm code gen config
    GHC.Driver.Config.CmmToLlvm         -- for initialization, other utils
    
    CmmToLlvm: remove HasDynFlags, add LlvmConfig
    
    CmmToLlvm: add lcgContext to LCGConfig
    
    CmmToLlvm.Base: DynFlags --> LCGConfig
    
    Llvm: absorb LlvmOpts into LCGConfig
    
    CmmToLlvm.Ppr: swap DynFlags --> LCGConfig
    
    CmmToLlvm.CodeGen: swap DynFlags --> LCGConfig
    
    CmmToLlvm.CodeGen: swap DynFlags --> LCGConfig
    
    CmmToLlvm.Data: swap LlvmOpts --> LCGConfig
    
    CmmToLlvm: swap DynFlags --> LCGConfig
    
    CmmToLlvm: move LlvmVersion to CmmToLlvm.Config
    
    Additionally:
    - refactor Config and initConfig to hold LlvmVersion
    - push IO needed to get LlvmVersion to boundary between Cmm and LLvm
    code generation
    - remove redundant imports, this is much cleaner!
    
    CmmToLlvm.Config: store platformMisc_llvmTarget
    
    instead of all of platformMisc
    
    - - - - -
    6b0fb9a0 by doyougnu at 2021-12-14T20:55:06-05:00
    SysTools.Tasks Llvm.Types: remove redundant import
    
    Llvm.Types: remove redundant import
    
    SysTools.Tasks: remove redundant import
    
    - namely CmmToLlvm.Base
    
    - - - - -
    80016022 by doyougnu at 2021-12-14T20:55:06-05:00
    LLVM.CodeGen: use fast-string literals
    
    That is remove factorization of common strings and string building
    code for the LLVM code gen ops. Replace these with string literals
    to obey the FastString rewrite rule in GHC.Data.FastString and compute
    the string length at compile time
    
    - - - - -
    bc663f87 by doyougnu at 2021-12-14T20:55:06-05:00
    CmmToLlvm.Config: strictify LlvmConfig field
    
    - - - - -
    70f0aafe by doyougnu at 2021-12-14T20:55:06-05:00
    CmmToLlvm: rename LCGConfig -> LlvmCgConfig
    
    CmmToLlvm: renamce lcgPlatform -> llvmCgPlatform
    
    CmmToLlvm: rename lcgContext -> llvmCgContext
    
    CmmToLlvm: rename lcgFillUndefWithGarbage
    
    CmmToLlvm: rename lcgSplitSections
    
    CmmToLlvm: lcgBmiVersion -> llvmCgBmiVersion
    
    CmmToLlvm: lcgLlvmVersion -> llvmCgLlvmVersion
    
    CmmToLlvm: lcgDoWarn -> llvmCgDoWarn
    
    CmmToLlvm: lcgLlvmConfig -> llvmCgLlvmConfig
    
    CmmToLlvm: llvmCgPlatformMisc --> llvmCgLlvmTarget
    
    - - - - -
    34abbd81 by Greg Steuck at 2021-12-14T20:55:43-05:00
    Add OpenBSD to llvm-targets
    
    This improves some tests that previously failed with:
    
    ghc: panic! (the 'impossible' happened)
      GHC version 9.3.20211211:
            Failed to lookup LLVM data layout
      Target: x86_64-unknown-openbsd
    
    Added the new generated lines to `llvm-targets` on an openbsd
    7.0-current with clang 11.1.0.
    
    - - - - -
    45bd6308 by Joachim Breitner at 2021-12-14T20:56:18-05:00
    Test case from #19313
    
    - - - - -
    f5a0b408 by Andrei Barbu at 2021-12-15T16:33:17-05:00
    Plugin load order should follow the commandline order (fixes #17884)
    
    In the past the order was reversed because flags are consed onto a list.
    No particular behavior was documented.
    
    We now reverse the flags and document the behavior.
    
    - - - - -
    d13b9f20 by Cheng Shao at 2021-12-15T16:33:54-05:00
    base: use `CUIntPtr` instead of `Ptr ()` as the autoconf detected Haskell type for C pointers
    
    When autoconf detects a C pointer type, we used to specify `Ptr ()` as
    the Haskell type. This doesn't work in some cases, e.g. in `wasi-libc`,
    `clockid_t` is a pointer type, but we expected `CClockId` to be an
    integral type, and `Ptr ()` lacks various integral type instances.
    
    - - - - -
    89c1ffd6 by Cheng Shao at 2021-12-15T16:33:54-05:00
    base: fix autoconf detection of C pointer types
    
    We used to attempt compiling `foo_t val; *val;` to determine if `foo_t`
    is a pointer type in C. This doesn't work if `foo_t` points to an
    incomplete type, and autoconf will detect `foo_t` as a floating point
    type in that case. Now we use `memset(val, 0, 0)` instead, and it works
    for incomplete types as well.
    
    - - - - -
    6cea7311 by Cheng Shao at 2021-12-15T16:33:54-05:00
    Add a note to base changelog
    
    - - - - -
    3c3e5c03 by Ben Gamari at 2021-12-17T21:20:57-05:00
    Regression test for renamer/typechecker performance (#20261)
    
    We use the parser generated by stack to ensure reproducibility
    
    - - - - -
    5d5620bc by Krzysztof Gogolewski at 2021-12-17T21:21:32-05:00
    Change isUnliftedTyCon to marshalablePrimTyCon (#20401)
    
    isUnliftedTyCon was used in three places: Ticky, Template Haskell
    and FFI checks.
    
    It was straightforward to remove it from Ticky and Template Haskell.
    
    It is now used in FFI only and renamed to marshalablePrimTyCon.
    
    Previously, it was fetching information from a field
    in PrimTyCon called is_unlifted. Instead, I've changed the code
    to compute liftedness based on the kind.
    
    isFFITy and legalFFITyCon are removed. They were only referred from
    an old comment that I removed.
    
    There were three functions to define a PrimTyCon, but the only difference
    was that they were setting is_unlifted to True or False.
    Everything is now done in mkPrimTyCon.
    
    I also added missing integer types in Ticky.hs, I think it was an oversight.
    
    Fixes #20401
    
    - - - - -
    9d77976d by Matthew Pickering at 2021-12-17T21:22:08-05:00
    testsuite: Format metric results with comma separator
    
    As noted in #20763 the way the stats were printed was quite hard for a
    human to compare. Therefore we now insert the comma separator so that
    they are easier to compare at a glance.
    
    Before:
    
    ```
                                                  Baseline
                             Test    Metric          value      New value Change
    -----------------------------------------------------------------------------
              Conversions(normal) run/alloc       107088.0       107088.0  +0.0%
               DeriveNull(normal) run/alloc    112050656.0    112050656.0  +0.0%
         InlineArrayAlloc(normal) run/alloc   1600040712.0   1600040712.0  +0.0%
     InlineByteArrayAlloc(normal) run/alloc   1440040712.0   1440040712.0  +0.0%
    InlineCloneArrayAlloc(normal) run/alloc   1600040872.0   1600040872.0  +0.0%
              MethSharing(normal) run/alloc    480097864.0    480097864.0  +0.0%
                   T10359(normal) run/alloc       354344.0       354344.0  +0.0%
    ```
    
    After
    
    ```
                                                     Baseline
                             Test    Metric             value         New value Change
    ----------------------------------------------------------------------------------
              Conversions(normal) run/alloc         107,088         107,088     +0.0%
               DeriveNull(normal) run/alloc     112,050,656     112,050,656     +0.0%
         InlineArrayAlloc(normal) run/alloc   1,600,040,712   1,600,040,712     +0.0%
     InlineByteArrayAlloc(normal) run/alloc   1,440,040,712   1,440,040,712     +0.0%
    InlineCloneArrayAlloc(normal) run/alloc   1,600,040,872   1,600,040,872     +0.0%
              MethSharing(normal) run/alloc     480,097,864     480,097,864     +0.0%
                   T10359(normal) run/alloc         354,344         354,344     +0.0%
    ```
    
    Closes #20763
    
    - - - - -
    3f31bfe8 by Sylvain Henry at 2021-12-17T21:22:48-05:00
    Perf: inline exprIsCheapX
    
    Allow specialization for the ok_app predicate.
    
    Perf improvements:
    
                                                   Baseline
                               Test    Metric         value     New value Change
    -----------------------------------------------------------------------------
           ManyAlternatives(normal) ghc/alloc   747317244.0   746444024.0  -0.1%
           ManyConstructors(normal) ghc/alloc  4005046448.0  4001548792.0  -0.1%
          MultiLayerModules(normal) ghc/alloc  3063361000.0  3063178472.0  -0.0%
    MultiLayerModulesRecomp(normal) ghc/alloc   894208428.0   894252496.0  +0.0%
                  PmSeriesG(normal) ghc/alloc    48021692.0    47901592.0  -0.3%
                  PmSeriesS(normal) ghc/alloc    61322504.0    61149008.0  -0.3%
                  PmSeriesT(normal) ghc/alloc    90879364.0    90609048.0  -0.3%
                  PmSeriesV(normal) ghc/alloc    60155376.0    59983632.0  -0.3%
                     T10421(normal) ghc/alloc   112820720.0   112517208.0  -0.3%
                    T10421a(normal) ghc/alloc    78783696.0    78557896.0  -0.3%
                     T10547(normal) ghc/alloc    28331984.0    28354160.0  +0.1%
                     T10858(normal) ghc/alloc   180715296.0   180226720.0  -0.3%
                     T11195(normal) ghc/alloc   284139184.0   283981048.0  -0.1%
                     T11276(normal) ghc/alloc   137830804.0   137688912.0  -0.1%
                    T11303b(normal) ghc/alloc    44080856.0    43956152.0  -0.3%
                     T11374(normal) ghc/alloc   249319644.0   249059288.0  -0.1%
                     T11545(normal) ghc/alloc   971507488.0   971146136.0  -0.0%
                     T11822(normal) ghc/alloc   131410208.0   131269664.0  -0.1%
                     T12150(optasm) ghc/alloc    78866860.0    78762296.0  -0.1%
                     T12227(normal) ghc/alloc   494467900.0   494138112.0  -0.1%
                     T12234(optasm) ghc/alloc    56781044.0    56588256.0  -0.3%
                     T12425(optasm) ghc/alloc    90462264.0    90240272.0  -0.2%
                     T12545(normal) ghc/alloc  1694316588.0  1694128448.0  -0.0%
                     T12707(normal) ghc/alloc   955665168.0   955005336.0  -0.1%
                     T13035(normal) ghc/alloc   101875160.0   101713312.0  -0.2%
                     T13056(optasm) ghc/alloc   366370168.0   365347632.0  -0.3%
                     T13253(normal) ghc/alloc   333741472.0   332612920.0  -0.3%
                 T13253-spj(normal) ghc/alloc   124947560.0   124427552.0  -0.4%
                     T13379(normal) ghc/alloc   358997996.0   358879840.0  -0.0%
                     T13701(normal) ghc/alloc  2400391456.0  2399956840.0  -0.0%
                     T13719(normal) ghc/alloc  4193179228.0  4192476392.0  -0.0%
                       T14052(ghci) ghc/alloc  2734741552.0  2735731808.0  +0.0%
                   T14052Type(ghci) ghc/alloc  7323235724.0  7323042264.0  -0.0%
                     T14683(normal) ghc/alloc  2990457260.0  2988899144.0  -0.1%
                     T14697(normal) ghc/alloc   363606476.0   363452952.0  -0.0%
                     T15164(normal) ghc/alloc  1291321780.0  1289491968.0  -0.1%
                     T15304(normal) ghc/alloc  1277838020.0  1276208304.0  -0.1%
                     T15630(normal) ghc/alloc   161074632.0   160388136.0  -0.4%
                     T16190(normal) ghc/alloc   276567192.0   276235216.0  -0.1%
                     T16577(normal) ghc/alloc  7564318656.0  7535598656.0  -0.4%
                     T16875(normal) ghc/alloc    34867720.0    34752440.0  -0.3%
                     T17096(normal) ghc/alloc   288477360.0   288156960.0  -0.1%
                     T17516(normal) ghc/alloc  1712777224.0  1704655496.0  -0.5%
                     T17836(normal) ghc/alloc  1092127336.0  1091709880.0  -0.0%
                    T17836b(normal) ghc/alloc    52083516.0    51954056.0  -0.2%
                     T17977(normal) ghc/alloc    44552228.0    44425448.0  -0.3%
                    T17977b(normal) ghc/alloc    40540252.0    40416856.0  -0.3%
                     T18140(normal) ghc/alloc    81908200.0    81678928.0  -0.3%
                     T18223(normal) ghc/alloc  1166459176.0  1164418104.0  -0.2%
                     T18282(normal) ghc/alloc   131123648.0   130740432.0  -0.3%
                     T18304(normal) ghc/alloc    86486796.0    86223088.0  -0.3%
                     T18478(normal) ghc/alloc   746029440.0   745619968.0  -0.1%
                    T18698a(normal) ghc/alloc   337037580.0   336533824.0  -0.1%
                    T18698b(normal) ghc/alloc   398324600.0   397696400.0  -0.2%
                     T18923(normal) ghc/alloc    68496432.0    68286264.0  -0.3%
                      T1969(normal) ghc/alloc   760424696.0   759641664.0  -0.1%
                     T19695(normal) ghc/alloc  1421672472.0  1413682104.0  -0.6%
                     T20049(normal) ghc/alloc    88601524.0    88336560.0  -0.3%
                      T3064(normal) ghc/alloc   190808832.0   190659328.0  -0.1%
                      T3294(normal) ghc/alloc  1604483120.0  1604339080.0  -0.0%
                      T4801(normal) ghc/alloc   296501624.0   296388448.0  -0.0%
                      T5030(normal) ghc/alloc   364336308.0   364206240.0  -0.0%
                    T5321FD(normal) ghc/alloc   270688492.0   270386832.0  -0.1%
                   T5321Fun(normal) ghc/alloc   300860396.0   300559200.0  -0.1%
                      T5631(normal) ghc/alloc   575822760.0   575579160.0  -0.0%
                      T5642(normal) ghc/alloc   470243356.0   468988784.0  -0.3%
                      T5837(normal) ghc/alloc    35936468.0    35821360.0  -0.3%
                      T6048(optasm) ghc/alloc   102587024.0   102222000.0  -0.4%
                       T783(normal) ghc/alloc   386539204.0   386003344.0  -0.1%
                      T9020(optasm) ghc/alloc   247435312.0   247324184.0  -0.0%
                      T9198(normal) ghc/alloc    47170036.0    47054840.0  -0.2%
                      T9233(normal) ghc/alloc   677186820.0   676550032.0  -0.1%
                      T9630(normal) ghc/alloc  1456411516.0  1451045736.0  -0.4%
                      T9675(optasm) ghc/alloc   427190224.0   426812568.0  -0.1%
                     T9872a(normal) ghc/alloc  1704660040.0  1704681856.0  +0.0%
                     T9872b(normal) ghc/alloc  2180109488.0  2180130856.0  +0.0%
                     T9872c(normal) ghc/alloc  1760209640.0  1760231456.0  +0.0%
                     T9872d(normal) ghc/alloc   501126052.0   500973488.0  -0.0%
                      T9961(normal) ghc/alloc   353244688.0   353063104.0  -0.1%
       TcPlugin_RewritePerf(normal) ghc/alloc  2387276808.0  2387254168.0  -0.0%
                      WWRec(normal) ghc/alloc   588651140.0   587684704.0  -0.2%
             hard_hole_fits(normal) ghc/alloc   492063812.0   491798360.0  -0.1%
                     hie002(normal) ghc/alloc  9334355960.0  9334396872.0  +0.0%
                 parsing001(normal) ghc/alloc   537410584.0   537421736.0  +0.0%
    
                          geo. mean                                        -0.2%
    
    - - - - -
    e04878b0 by Matthew Pickering at 2021-12-17T21:23:23-05:00
    ci: Use correct metrics baseline
    
    It turns out there was already a function in the CI script to correctly
    set the baseline for performance tests but it was just never called. I
    now call it during the initialisation to set the correct baseline.
    
    I also made the make testsuite driver take into account the
    PERF_BASELINE_COMMIT environment variable
    
    Fixes #20811
    
    - - - - -
    1327c176 by Matthew Pickering at 2021-12-17T21:23:58-05:00
    Add regression test for T20189
    
    Closes #20189
    
    - - - - -
    fc9b1755 by Matthew Pickering at 2021-12-17T21:24:33-05:00
    Fix documentation formatting in Language.Haskell.TH.CodeDo
    
    Fixes #20543
    
    - - - - -
    abef93f3 by Matthew Pickering at 2021-12-17T21:24:33-05:00
    Expand documentation for MulArrowT constructor
    
    Fixes #20812
    
    - - - - -
    94c3ff66 by Cheng Shao at 2021-12-17T21:25:09-05:00
    Binary: make withBinBuffer safe
    
    With this patch, withBinBuffer will construct a ByteString that
    properly captures the reference to the BinHandle internal
    MutableByteArray#, making it safe to convert a BinHandle to ByteString
    and use that ByteString outside the continuation.
    
    - - - - -
    a3552934 by Sebastian Graf at 2021-12-17T21:25:45-05:00
    Demand: `Eq DmdType` modulo `defaultFvDmd` (#20827)
    
    Fixes #20827 by filtering out any default free variable demands (as per
    `defaultFvDmd`) prior to comparing the assocs of the `DmdEnv`.
    The details are in `Note [Demand type Equality]`.
    
    - - - - -
    9529d859 by Sylvain Henry at 2021-12-17T21:26:24-05:00
    Perf: avoid using (replicateM . length) when possible
    
    Extracted from !6622
    
    - - - - -
    887d8b4c by Matthew Pickering at 2021-12-17T21:26:59-05:00
    testsuite: Ensure that -dcore-lint is not set for compiler performance tests
    
    This place ensures that the default -dcore-lint option is disabled by
    default when collect_compiler_stats is used but you can still pass
    -dcore-lint as an additional option (see T1969 which tests core lint
    performance).
    
    Fixes #20830
    
    -------------------------
    Metric Decrease:
        PmSeriesS
        PmSeriesT
        PmSeriesV
        T10858
        T11195
        T11276
        T11374
        T11822
        T14052
        T14052Type
        T17096
        T17836
        T17836b
        T18478
        T18698a
        T18698b
    -------------------------
    
    - - - - -
    5ff47ff5 by Ben Gamari at 2021-12-21T01:46:00-05:00
    codeGen: Introduce flag to bounds-check array accesses
    
    Here we introduce code generator support for instrument array primops
    with bounds checking, enabled with the `-fcheck-prim-bounds` flag.
    
    Introduced to debug #20769.
    
    - - - - -
    d47bb109 by Ben Gamari at 2021-12-21T01:46:00-05:00
    rts: Add optional bounds checking in out-of-line primops
    
    - - - - -
    8ea79a16 by Ben Gamari at 2021-12-21T01:46:00-05:00
    Rename -fcatch-bottoms to -fcatch-nonexhaustive-cases
    
    As noted in #20601, the previous name was rather misleading.
    
    - - - - -
    00b55bfc by Ben Gamari at 2021-12-21T01:46:00-05:00
    Introduce -dlint flag
    
    As suggested in #20601, this is a short-hand for enabling the usual
    GHC-internal sanity checks one typically leans on when debugging runtime
    crashes.
    
    - - - - -
    9728d6c2 by Sylvain Henry at 2021-12-21T01:46:39-05:00
    Give plugins a better interface (#17957)
    
    Plugins were directly fetched from HscEnv (hsc_static_plugins and
    hsc_plugins). The tight coupling of plugins and of HscEnv is undesirable
    and it's better to store them in a new Plugins datatype and to use it in
    the plugins' API (e.g. withPlugins, mapPlugins...).
    
    In the process, the interactive context (used by GHCi) got proper
    support for different static plugins than those used for loaded modules.
    
    Bump haddock submodule
    
    - - - - -
    9bc5ab64 by Greg Steuck at 2021-12-21T01:47:17-05:00
    Use libc++ instead of libstdc++ on openbsd in addition to freebsd
    
    This is not entirely accurate because some openbsd architectures use
    gcc. Yet we don't have ghc ported to them and thus the approximation
    is good enough.
    
    Fixes ghcilink006 test
    
    - - - - -
    f92c9c0d by Greg Steuck at 2021-12-21T01:47:55-05:00
    Only use -ldl conditionally to fix T3807
    
    OpenBSD doesn't have this library and so the linker complains:
    ld.lld: error: unable to find library -ldl
    
    - - - - -
    ff657a81 by Greg Steuck at 2021-12-21T01:48:32-05:00
    Mark `linkwhole` test as expected broken on OpenBSD per #20841
    
    - - - - -
    1a596d06 by doyougnu at 2021-12-22T00:12:27-05:00
    Cmm: DynFlags to CmmConfig refactor
    
    add files GHC.Cmm.Config, GHC.Driver.Config.Cmm
    
    Cmm: DynFlag references --> CmmConfig
    
    Cmm.Pipeline: reorder imports, add handshake
    
    Cmm: DynFlag references --> CmmConfig
    
    Cmm.Pipeline: DynFlag references --> CmmConfig
    
    Cmm.LayoutStack: DynFlag references -> CmmConfig
    
    Cmm.Info.Build: DynFlag references -> CmmConfig
    
    Cmm.Config: use profile to retrieve platform
    
    Cmm.CLabel: unpack NCGConfig in labelDynamic
    
    Cmm.Config: reduce CmmConfig surface area
    
    Cmm.Config: add cmmDoCmmSwitchPlans field
    
    Cmm.Config: correct cmmDoCmmSwitchPlans flag
    
    The original implementation dispatches work in cmmImplementSwitchPlans
    in an `otherwise` branch, hence we must add a not to correctly dispatch
    
    Cmm.Config: add cmmSplitProcPoints simplify Config
    
    remove cmmBackend, and cmmPosInd
    
    Cmm.CmmToAsm: move ncgLabelDynamic to CmmToAsm
    
    Cmm.CLabel: remove cmmLabelDynamic function
    
    Cmm.Config: rename cmmOptDoLinting -> cmmDoLinting
    
    testsuite: update CountDepsAst CountDepsParser
    
    - - - - -
    d7cc8f19 by Matthew Pickering at 2021-12-22T00:13:02-05:00
    ci: Fix master CI
    
    I made a mistake in the bash script so there were errors about
    "$CI_MERGE_REQUEST_DIFF_BASE_SHA" not existing.
    
    - - - - -
    09b6cb45 by Alan Zimmerman at 2021-12-22T00:13:38-05:00
    Fix panic trying to -ddump-parsed-ast for implicit fixity
    
    A declaration such as
    
        infixr ++++
    
    is supplied with an implicit fixity of 9 in the parser, but uses
    an invalid SrcSpan to capture this. Use of this span triggers a panic.
    
    Fix the problem by not recording an exact print annotation for the
    non-existent fixity source.
    
    Closes #20846
    
    - - - - -
    3ed90911 by Matthew Pickering at 2021-12-22T14:47:40-05:00
    testsuite: Remove reqlib modifier
    
    The reqlib modifer was supposed to indicate that a test needed a certain
    library in order to work. If the library happened to be installed then
    the test would run as normal.
    
    However, CI has never run these tests as the packages have not been
    installed and we don't want out tests to depend on things which might
    get externally broken by updating the compiler.
    
    The new strategy is to run these tests in head.hackage, where the tests
    have been cabalised as well as possible. Some tests couldn't be
    transferred into the normal style testsuite but it's better than never
    running any of the reqlib tests. https://gitlab.haskell.org/ghc/head.hackage/-/merge_requests/169
    
    A few submodules also had reqlib tests and have been updated to remove
    it.
    
    Closes #16264 #20032 #17764 #16561
    
    - - - - -
    ac3e8c52 by Matthew Pickering at 2021-12-22T14:48:16-05:00
    perf ci: Start searching form the performance baseline
    
    If you specify PERF_BASELINE_COMMIT then this can fail if the specific
    commit you selected didn't have perf test metrics. (This can happen in
    CI for example if a build fails on master).
    
    Therefore instead of just reporting all tests as new, we start searching
    downwards from this point to try and find a good commit to report
    numbers from.
    
    - - - - -
    9552781a by Matthew Pickering at 2021-12-22T14:48:51-05:00
    Mark T16525b as fragile on windows
    
    See ticket #20852
    
    - - - - -
    13a6d85a by Andreas Klebinger at 2021-12-23T10:55:36-05:00
    Make callerCC profiling mode represent entry counter flag.
    
    Fixes #20854
    
    - - - - -
    80daefce by Matthew Pickering at 2021-12-23T10:56:11-05:00
    Properly filter for module visibility in resolvePackageImport
    
    This completes the fix for #20779 / !7123.
    
    Beforehand, the program worked by accident because the two versions of
    the library happened to be ordered properly (due to how the hashes were
    computed). In the real world I observed them being the other way around
    which meant the final lookup failed because we weren't filtering for
    visibility.
    
    I modified the test so that it failed (and it's fixed by this patch).
    
    - - - - -
    e6191d39 by Krzysztof Gogolewski at 2021-12-25T18:26:44+01:00
    Fix typos
    
    - - - - -
    3219610e by Greg Steuck at 2021-12-26T22:12:43-05:00
    Use POSIX-compliant egrep expression to fix T8832 on OpenBSD
    
    - - - - -
    fd42ab5f by Matthew Pickering at 2021-12-28T09:47:53+00:00
    Multiple Home Units
    
    Multiple home units allows you to load different packages which may depend on
    each other into one GHC session. This will allow both GHCi and HLS to support
    multi component projects more naturally.
    
    Public Interface
    ~~~~~~~~~~~~~~~~
    
    In order to specify multiple units, the -unit @⟨filename⟩ flag
    is given multiple times with a response file containing the arguments for each unit.
    The response file contains a newline separated list of arguments.
    
    ```
    ghc -unit @unitLibCore -unit @unitLib
    ```
    
    where the `unitLibCore` response file contains the normal arguments that cabal would pass to `--make` mode.
    
    ```
    -this-unit-id lib-core-0.1.0.0
    -i
    -isrc
    LibCore.Utils
    LibCore.Types
    ```
    
    The response file for lib, can specify a dependency on lib-core, so then modules in lib can use modules from lib-core.
    
    ```
    -this-unit-id lib-0.1.0.0
    -package-id lib-core-0.1.0.0
    -i
    -isrc
    Lib.Parse
    Lib.Render
    ```
    
    Then when the compiler starts in --make mode it will compile both units lib and lib-core.
    
    There is also very basic support for multiple home units in GHCi, at the
    moment you can start a GHCi session with multiple units but only the
    :reload is supported. Most commands in GHCi assume a single home unit,
    and so it is additional work to work out how to modify the interface to
    support multiple loaded home units.
    
    Options used when working with Multiple Home Units
    
    There are a few extra flags which have been introduced specifically for
    working with multiple home units. The flags allow a home unit to pretend
    it’s more like an installed package, for example, specifying the package
    name, module visibility and reexported modules.
    
    -working-dir ⟨dir⟩
    
        It is common to assume that a package is compiled in the directory
        where its cabal file resides. Thus, all paths used in the compiler
        are assumed to be relative to this directory. When there are
        multiple home units the compiler is often not operating in the
        standard directory and instead where the cabal.project file is
        located. In this case the -working-dir option can be passed which
        specifies the path from the current directory to the directory the
        unit assumes to be it’s root, normally the directory which contains
        the cabal file.
    
        When the flag is passed, any relative paths used by the compiler are
        offset by the working directory. Notably this includes -i and
        -I⟨dir⟩ flags.
    
    -this-package-name ⟨name⟩
    
        This flag papers over the awkward interaction of the PackageImports
        and multiple home units. When using PackageImports you can specify
        the name of the package in an import to disambiguate between modules
        which appear in multiple packages with the same name.
    
        This flag allows a home unit to be given a package name so that you
        can also disambiguate between multiple home units which provide
        modules with the same name.
    
    -hidden-module ⟨module name⟩
    
        This flag can be supplied multiple times in order to specify which
        modules in a home unit should not be visible outside of the unit it
        belongs to.
    
        The main use of this flag is to be able to recreate the difference
        between an exposed and hidden module for installed packages.
    
    -reexported-module ⟨module name⟩
    
        This flag can be supplied multiple times in order to specify which
        modules are not defined in a unit but should be reexported. The
        effect is that other units will see this module as if it was defined
        in this unit.
    
        The use of this flag is to be able to replicate the reexported
        modules feature of packages with multiple home units.
    
    Offsetting Paths in Template Haskell splices
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    When using Template Haskell to embed files into your program,
    traditionally the paths have been interpreted relative to the directory
    where the .cabal file resides. This causes problems for multiple home
    units as we are compiling many different libraries at once which have
    .cabal files in different directories.
    
    For this purpose we have introduced a way to query the value of the
    -working-dir flag to the Template Haskell API. By using this function we
    can implement a makeRelativeToProject function which offsets a path
    which is relative to the original project root by the value of
    -working-dir.
    
    ```
    import Language.Haskell.TH.Syntax ( makeRelativeToProject )
    
    foo = $(makeRelativeToProject "./relative/path" >>= embedFile)
    ```
    
    > If you write a relative path in a Template Haskell splice you should use the makeRelativeToProject function so that your library works correctly with multiple home units.
    
    A similar function already exists in the file-embed library. The
    function in template-haskell implements this function in a more robust
    manner by honouring the -working-dir flag rather than searching the file
    system.
    
    Closure Property for Home Units
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    For tools or libraries using the API there is one very important closure
    property which must be adhered to:
    
    > Any dependency which is not a home unit must not (transitively) depend
      on a home unit.
    
    For example, if you have three packages p, q and r, then if p depends on
    q which depends on r then it is illegal to load both p and r as home
    units but not q, because q is a dependency of the home unit p which
    depends on another home unit r.
    
    If you are using GHC by the command line then this property is checked,
    but if you are using the API then you need to check this property
    yourself. If you get it wrong you will probably get some very confusing
    errors about overlapping instances.
    
    Limitations of Multiple Home Units
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    There are a few limitations of the initial implementation which will be smoothed out on user demand.
    
        * Package thinning/renaming syntax is not supported
        * More complicated reexports/renaming are not yet supported.
        * It’s more common to run into existing linker bugs when loading a
          large number of packages in a session (for example #20674, #20689)
        * Backpack is not yet supported when using multiple home units.
        * Dependency chasing can be quite slow with a large number of
          modules and packages.
        * Loading wired-in packages as home units is currently not supported
          (this only really affects GHC developers attempting to load
          template-haskell).
        * Barely any normal GHCi features are supported, it would be good to
          support enough for ghcid to work correctly.
    
    Despite these limitations, the implementation works already for nearly
    all packages. It has been testing on large dependency closures,
    including the whole of head.hackage which is a total of 4784 modules
    from 452 packages.
    
    Internal Changes
    ~~~~~~~~~~~~~~~~
    
    * The biggest change is that the HomePackageTable is replaced with the
      HomeUnitGraph. The HomeUnitGraph is a map from UnitId to HomeUnitEnv,
      which contains information specific to each home unit.
    * The HomeUnitEnv contains:
        - A unit state, each home unit can have different package db flags
        - A set of dynflags, each home unit can have different flags
        - A HomePackageTable
    * LinkNode: A new node type is added to the ModuleGraph, this is used to
      place the linking step into the build plan so linking can proceed in
      parralel with other packages being built.
    * New invariant: Dependencies of a ModuleGraphNode can be completely
      determined by looking at the value of the node. In order to achieve
      this, downsweep now performs a more complete job of downsweeping and
      then the dependenices are recorded forever in the node rather than
      being computed again from the ModSummary.
    * Some transitive module calculations are rewritten to use the
      ModuleGraph which is more efficient.
    * There is always an active home unit, which simplifies modifying a lot
      of the existing API code which is unit agnostic (for example, in the
      driver).
    
    The road may be bumpy for a little while after this change but the
    basics are well-tested.
    
    One small metric increase, which we accept and also submodule update to
    haddock which removes ExtendedModSummary.
    
    Closes #10827
    
    -------------------------
    Metric Increase:
        MultiLayerModules
    -------------------------
    
    Co-authored-by: Fendor <power.walross at gmail.com>
    
    - - - - -
    72824c63 by Richard Eisenberg at 2021-12-28T10:09:28-05:00
    Skip computing superclass origins for equalities
    
    This yields a small, but measurable, performance improvement.
    
    - - - - -
    8b6aafb2 by Matthew Pickering at 2021-12-29T14:09:47-05:00
    Cabal: Update submodule
    
    Closes #20874
    
    - - - - -
    44a5507f by Peter Trommler at 2021-12-29T14:10:22-05:00
    RTS: Fix CloneStack.c when no table next to code
    
    Function `lookupIPE` does not modify its argument. Reflect this in the
    type. Module `CloneStack.c` relies on this for RTS without tables
    next to code.
    
    Fixes #20879
    
    - - - - -
    246d2782 by sheaf at 2022-01-02T04:20:09-05:00
    User's guide: newtype decls can use GADTSyntax
    
    The user's guide failed to explicitly mention that GADTSyntax
    can be used to declare newtypes, so we add an example and a couple
    of explanations.
    
    Also explains that `-XGADTs` generalises `-XExistentialQuantification`.
    
    Fixes #20848 and #20865.
    
    - - - - -
    f212cece by Hécate Moonlight at 2022-01-02T04:20:47-05:00
    Add a source-repository stanza to rts/rts.cabal
    - - - - -
    d9e49195 by Greg Steuck at 2022-01-03T05:18:24+00:00
    Replace `seq` with POSIX-standard printf(1) in ManyAlternatives test
    
    The test now passes on OpenBSD instead of generating broken source
    which was rejected by GHC with
    
      ManyAlternatives.hs:5:1: error:
          The type signature for ‘f’ lacks an accompanying binding
    
    - - - - -
    80e416ae by Greg Steuck at 2022-01-03T05:18:24+00:00
    Replace `seq` with POSIX-standard in PmSeriesG test
    
    - - - - -
    8fa52f5c by Eric Lindblad at 2022-01-03T16:48:51-05:00
    fix typo
    - - - - -
    a49f5889 by Roland Senn at 2022-01-03T16:49:29-05:00
    Add regressiontest for #18045
    
    Issue #18045 got fixed by !6971.
    
    - - - - -
    7f10686e by sheaf at 2022-01-03T16:50:07-05:00
    Add test for #20894
    
    - - - - -
    5111028e by sheaf at 2022-01-04T19:56:13-05:00
    Check quoted TH names are in the correct namespace
    
    When quoting (using a TH single or double quote) a built-in
    name such as the list constructor (:), we didn't always check
    that the resulting 'Name' was in the correct namespace.
    
    This patch adds a check in GHC.Rename.Splice to ensure
    we get a Name that is in the term-level/type-level namespace,
    when using a single/double tick, respectively.
    
    Fixes #20884.
    
    - - - - -
    1de94daa by George Thomas at 2022-01-04T19:56:51-05:00
    Fix Haddock parse error in GHC.Exts.Heap.FFIClosures.hs
    - - - - -
    e59bd46a by nineonine at 2022-01-05T18:07:18+00:00
    Add regression test (#13997)
    
    - - - - -
    c080b443 by Sylvain Henry at 2022-01-06T02:24:54-05:00
    Perf: use SmallArray for primops' Ids cache (#20857)
    
    SmallArray doesn't perform bounds check (faster).
    
    Make primop tags start at 0 to avoid index arithmetic.
    
    - - - - -
    ec26c38b by Sylvain Henry at 2022-01-06T02:24:54-05:00
    Use primOpIds cache more often (#20857)
    
    Use primOpId instead of mkPrimOpId in a few places to benefit from
    Id caching.
    
    I had to mess a little bit with the module hierarchy to fix cycles and
    to avoid adding too many new dependencies to count-deps tests.
    
    - - - - -
    f7fc62e2 by Greg Steuck at 2022-01-06T07:56:22-05:00
    Disable T2615 on OpenBSD, close #20869
    
    - - - - -
    978ea35e by Greg Steuck at 2022-01-06T07:57:00-05:00
    Change ulimit -n in openFile008 back to 1024
    
    The test only wants 1000 descriptors, so changing the limit to double
    that *in the context of just this test* makes no sense.
    
    This is a manual revert of 8f7194fae23bdc6db72fc5784933f50310ce51f9.
    The justification given in the description doesn't instill confidence.
    
    As of HEAD, the test fails on OpenBSD where ulimit -n is hard-limited
    to 1024. The test suite attempts to change it to 2048, which
    fails. The test proceeds with the unchanged default of 512 and
    naturally the test program fails due to the low ulimit. The fixed test
    now passes.
    
    - - - - -
    7b783c9d by Matthew Pickering at 2022-01-07T18:25:06-05:00
    Thoughtful forcing in CoreUnfolding
    
    We noticed that the structure of CoreUnfolding could leave double the
    amount of CoreExprs which were retained in the situation where the
    template but not all the predicates were forced. This observation was
    then confirmed using ghc-debug:
    
    ```
    (["ghc:GHC.Core:App","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 237)
    (["ghc:GHC.Core:App","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 1)
    (["ghc:GHC.Core:Case","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 12)
    (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","BLACKHOLE"],Count 1)
    (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 78)
    (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","ghc-prim:GHC.Types:False","THUNK_1_0"],Count 1)
    (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","THUNK_1_0","THUNK_1_0"],Count 3)
    (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0"],Count 1)
    (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","BLACKHOLE"],Count 31)
    (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 4307)
    (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 6)
    (["ghc:GHC.Core:Let","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 29)
    (["ghc:GHC.Core:Lit","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 1)
    (["ghc:GHC.Core:Tick","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 36)
    (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 1)
    (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","THUNK_1_0","THUNK_1_0"],Count 6)
    (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","ghc-prim:GHC.Types:True","THUNK_1_0"],Count 2)
    ```
    
    Where we can see that the first argument is forced but there are still
    thunks remaining which retain the old expr.
    
    For my test case (a very big module, peak of 3 000 000 core terms) this
    reduced peak memory usage by 1G (12G -> 11G).
    
    Fixes #20905
    
    - - - - -
    f583eb8e by Joachim Breitner at 2022-01-07T18:25:41-05:00
    Remove dangling references to Note [Type-checking overloaded labels]
    
    that note was removed in 4196969c53c55191e644d9eb258c14c2bc8467da
    
    - - - - -
    2b6c2179 by Matthew Pickering at 2022-01-11T19:37:45-05:00
    hadrian: Add bootstrap scripts for building without cabal-install
    
    These scripts are originally from the cabal-install repo with a few
    small tweaks.
    
    This utility allows you to build hadrian without cabal-install, which can be useful
    for packagers. If you are a developer then build hadrian using cabal-install.
    
    If you want to bootstrap with ghc-8.10.5 then run the ./bootstrap script with the
    `plan-bootstrap-8.10.5.json` file.
    
        bootstrap.py -d plan-bootstrap-8.10.5.json -w /path/to-ghc
    
    The result of the bootstrap script will be a hadrian binary in
    `_build/bin/hadrian`.
    
    There is a script (using nix) which can be used to generate the bootstrap plans for the range
    of supported GHC versions using nix.
    
        generate_bootstrap_plans
    
    Otherwise you can run the commands in ./generate_bootstrap_plans directly.
    
    Fixes #17103
    
    - - - - -
    a8fb4251 by Zubin Duggal at 2022-01-11T19:37:45-05:00
    hadrian: allow offline bootstrapping
    
    This patch adds the ability to fetch and store dependencies needed for
    boostrapping hadrian. By default the script will download the
    dependencies from the network but some package managers disallow network
    access so there are also options to build given a supplied tarball.
    
    The -s option allos you to provide the tarball
    
        bootstrap.py -d plan-bootstrap-8.10.5.json -w /path/to-ghc -s sources-tarball.tar.gz
    
    Which dependencies you need can be queried using the `list-sources` option.
    
        bootstrap.py list-sources -d plan-bootstrap-8.10.5.json
    
    This produces `fetch_plan.json` which tells you where to get each source from.
    
    You can instruct the script to create the tarball using the `fetch` option.
    
        bootstrap.py fetch -d plan-bootstrap-8.10.5.json -o sources-tarball.tar.gz
    
    Together these commands mean you can build GHC without needing
    cabal-install.
    
    Fixes #17103
    
    - - - - -
    02cf4bc6 by Zubin Duggal at 2022-01-11T19:37:45-05:00
    hadrian: Fully implement source distributions (#19317)
    
    We use `git ls-files` to get the list of files to include in the source distribution.
    
    Also implements the `-testsuite` and `-extra-tarballs` distributions.
    
    - - - - -
    85473a09 by Zubin Duggal at 2022-01-11T19:37:45-05:00
    ci: test bootstrapping and use hadrian for source dists
    
    - - - - -
    759f3421 by Matthew Pickering at 2022-01-11T19:38:21-05:00
    ci: Nightly, run one head.hackage job with core-lint and one without
    
    This fixes serious skew in the performance numbers because the packages
    were build with core-lint.
    
    Fixes #20826
    
    - - - - -
    6737c8e1 by Ben Gamari at 2022-01-11T19:38:56-05:00
    rts: Depend explicitly on libc
    
    As noted in #19029, currently `ghc-prim` explicitly lists `libc` in
    `extra-libraries`, resulting in incorrect link ordering with the
    `extra-libraries: pthread` in `libHSrts`. Fix this by adding an explicit
    dependency on `libc` to `libHSrts`.
    
    Closes #19029.
    
    - - - - -
    247cd336 by Ben Gamari at 2022-01-11T19:39:32-05:00
    rts: Only declare environ when necessary
    
    Previously we would unconditionally provide a declaration for `environ`,
    even if `<unistd.h>` already provided one. This would result in
    `-Werror` builds failing on some platforms.
    
    Also `#include <unistd.h>` to ensure that the declaration is visible.
    
    Fixes #20861.
    
    - - - - -
    b65e7274 by Greg Steuck at 2022-01-11T19:40:10-05:00
    Skip T18623 on OpenBSD
    
    The bug it regresses didn't happen on this OS (no RLIMIT_AS) and the
    regression doesn't work (ulimit: -v: unknown option)
    
    - - - - -
    c6300cb3 by Greg Steuck at 2022-01-11T19:40:50-05:00
    Skip T16180 on OpenBSD due to bug #14012
    
    - - - - -
    addf8e54 by sheaf at 2022-01-11T19:41:28-05:00
    Kind TyCons: require KindSignatures, not DataKinds
    
      Uses of a TyCon in a kind signature required users to enable
      DataKinds, which didn't make much sense, e.g. in
    
        type U = Type
        type MyMaybe (a :: U) = MyNothing | MyJust a
    
      Now the DataKinds error is restricted to data constructors;
      the use of kind-level type constructors is instead gated behind
      -XKindSignatures.
    
      This patch also adds a convenience pattern synonym for patching
      on both a TyCon or a TcTyCon stored in a TcTyThing, used in
      tcTyVar and tc_infer_id.
    
      fixes #20873
    
    - - - - -
    34d8bc24 by sheaf at 2022-01-11T19:42:07-05:00
    Fix parsing & printing of unboxed sums
    
    The pretty-printing of partially applied unboxed sums was incorrect,
    as we incorrectly dropped the first half of the arguments, even
    for a partial application such as
    
      (# | #) @IntRep @DoubleRep Int#
    
    which lead to the nonsensical (# DoubleRep | Int# #).
    
    This patch also allows users to write unboxed sum type constructors
    such as
    
      (# | #) :: TYPE r1 -> TYPE r2 -> TYPE (SumRep '[r1,r2]).
    
    Fixes #20858 and #20859.
    
    - - - - -
    49731fed by sheaf at 2022-01-11T19:42:46-05:00
    TcPlugins: `newWanted` uses the provided `CtLoc`
    
    The `GHC.Tc.Plugin.newWanted` function takes a `CtLoc` as an argument,
    but it used to discard the location information, keeping only
    the `CtOrigin`. It would then retrieve the source location from the
    `TcM` environment using `getCtLocM`.
    
    This patch changes this so that `GHC.Tc.Plugin.newWanted` passes on
    the full `CtLoc`. This means that authors of type-checking plugins
    no longer need to manually set the `CtLoc` environment in the `TcM`
    monad if they want to create a new Wanted constraint with the given
    `CtLoc` (in particular, for setting the `SrcSpan` of an emitted
    constraint). This makes the `newWanted` function consistent with
    `newGiven`, which always used the full `CtLoc` instead of using
    the environment.
    
    Fixes #20895
    
    - - - - -
    23d215fc by Krzysztof Gogolewski at 2022-01-11T19:43:22-05:00
    warnPprTrace: pass separately the reason
    
    This makes it more similar to pprTrace, pprPanic etc.
    
    - - - - -
    833216a3 by Matthew Pickering at 2022-01-11T19:43:57-05:00
    Use interactive flags when printing expressions in GHCi
    
    The documentation states that the interactive flags should be use for
    any interactive expressions. The interactive flags are used when
    typechecking these expressions but not when printing. The session flags
    (modified by :set) are only used when loading a module.
    
    Fixes #20909
    
    - - - - -
    19b13698 by Matthew Pickering at 2022-01-11T19:43:57-05:00
    Enable :seti in a multi component repl
    
    Part of #20889
    
    - - - - -
    7ca43a3f by Matthew Pickering at 2022-01-11T19:44:33-05:00
    Change assertions in Stats.c to warnings (and introduce WARN macro)
    
    ASSERT should be used in situations where something very bad will happen
    later on if a certain invariant doesn't hold. The idea is that IF we
    catch the assertion earlier then it will be easier to work out what's
    going on at that point rather than at some indeterminate point in the
    future of the program.
    
    The assertions in Stats.c do not obey this philsophy and it is quite
    annoying if you are running a debug build (or a ticky compiler) and one
    of these assertions fails right at the end of your program, before the
    ticky report is printed out so you don't get any profiling information.
    
    Given that nothing terrible happens if these assertions are not true, or
    at least the terrible thing will happen in very close proximity to the
    assertion failure, these assertions use the new WARN macro which prints
    the assertion failure to stdout but does not exit the program.
    
    Of course, it would be better to fix these metrics to not trigger the
    assertion in the first place but if they did fail again in the future it
    is frustrating to be bamboozled in this manner.
    
    Fixes #20899
    
    - - - - -
    e505dbd3 by Greg Steuck at 2022-01-11T19:45:11-05:00
    Remove from error the parenthesized amount of memory requested
    
    Diagnostics for outofmem test on OpenBSD includes the amount of memory
    that it failed to allocate. This seems like an irrelevant detail that
    could change over time and isn't required for determining if test
    passed.
    
    Typical elided text is '(requested 2148532224 bytes)'
    
    - - - - -
    7911aaa9 by Greg Steuck at 2022-01-11T19:45:50-05:00
    Feed /dev/null into cgrun025
    
    The test currently times out waiting for end of stdin in getContents.
    The expected output indicates that nothing should come for the test to
    pass as written. It is unclear how the test was supposed to pass, but
    this looks like a sufficient hack to make it work.
    
    - - - - -
    ed39d15c by Greg Steuck at 2022-01-11T19:46:28-05:00
    Disable keep-cafs{,-fail} tests on OpenBSD
    
    They are likely broken for the same reason as FreeBSD where the tests
    are already disabled.
    
    - - - - -
    35bea01b by Peter Trommler at 2022-01-11T19:47:04-05:00
    RTS: Remove unused file xxhash.c
    
    - - - - -
    c2099059 by Matthew Pickering at 2022-01-11T19:47:39-05:00
    RTTI: Substitute the [rk] skolems into kinds
    
    (Fixes #10616 and #10617)
    
    Co-authored-by: Roland Senn <rsx at bluewin.ch>
    
    - - - - -
    92f3e6e4 by Matthew Pickering at 2022-01-11T19:48:15-05:00
    docs: MonadComprehension desugar using Alternative rather than MonadPlus
    
    Fixes #20928
    
    - - - - -
    7b0c9384 by Sylvain Henry at 2022-01-12T23:25:49-05:00
    Abstract BangOpts
    
    Avoid requiring to pass DynFlags to mkDataConRep/buildDataCon. When we
    load an interface file, these functions don't use the flags.
    
    This is preliminary work to decouple the loader from the type-checker
    for #14335.
    
    - - - - -
    a31ace56 by Sylvain Henry at 2022-01-12T23:25:49-05:00
    Untangled GHC.Types.Id.Make from the driver
    
    - - - - -
    81a8f7a7 by Zubin Duggal at 2022-01-12T23:26:24-05:00
    testsuite: Fix import on python 3.10
    
    - - - - -
    66831b94 by Ben Gamari at 2022-01-13T14:50:13-05:00
    hadrian: Include bash completion script in bindist
    
    See #20802.
    
    - - - - -
    be33d61a by Sebastian Graf at 2022-01-13T14:50:49-05:00
    release notes: Changes to CPR analysis
    
    - - - - -
    c2a6c3eb by Sebastian Graf at 2022-01-13T14:50:49-05:00
    release notes: Changes to Demand analysis
    
    - - - - -
    9ccc445a by Eric Lindblad at 2022-01-14T10:35:46-05:00
    add NUMJOBS
    - - - - -
    564b89ae by Eric Lindblad at 2022-01-14T10:35:46-05:00
    Revert "add NUMJOBS"
    
    This reverts commit c0b854e929f82c680530e944e12fad24f9e14f8e
    - - - - -
    2dfc268c by Eric Lindblad at 2022-01-14T10:35:46-05:00
    update URLs
    - - - - -
    1aace894 by Eric Lindblad at 2022-01-14T10:35:46-05:00
    reinsert target
    - - - - -
    52a4f5ab by Andreas Klebinger at 2022-01-14T10:36:21-05:00
    Add test for #20938.
    
    - - - - -
    e2b60be8 by Ben Gamari at 2022-01-15T03:41:16-05:00
    rts: Consolidate RtsSymbols from libc
    
    Previously (9ebda74ec5331911881d734b21fbb31c00a0a22f) `environ` was
    added to `RtsSymbols` to ensure that environment was correctly
    propagated when statically linking. However, this introduced #20577
    since platforms are inconsistent in whether they provide a prototype for
    `environ`. I fixed this by providing a prototype but while doing so
    dropped symbol-table entry, presumably thinking that it was redundant
    due to the entry in the mingw-specific table.
    
    Here I reintroduce the symbol table entry for `environ` and move libc
    symbols shared by Windows and Linux into a new macro,
    `RTS_LIBC_SYMBOLS`, avoiding this potential confusion.
    
    - - - - -
    0dc72395 by Tamar Christina at 2022-01-15T03:41:55-05:00
    winio: fix heap corruption and various leaks.
    
    - - - - -
    4031ef62 by Eric Lindblad at 2022-01-15T20:11:55+00:00
    wikipedia link
    - - - - -
    a13aff98 by Eric Lindblad at 2022-01-17T08:25:51-05:00
    ms link
    - - - - -
    f161e890 by sheaf at 2022-01-17T14:52:50+00:00
    Use diagnostic infrastructure in GHC.Tc.Errors
    
    - - - - -
    18c797b8 by Jens Petersen at 2022-01-18T16:12:14-05:00
    hadrian BinaryDist: version ghc in ghciScriptWrapper
    
    like we do for the non-Hadrian wrapper script.
    Otherwise if $bindir/ghc is a different ghc version then versioned ghci will incorrectly run the other ghc version instead.
    (Normally this would only happen if there are parallel ghc versions installed in bindir.)
    All the other wrapper scripts already have versioned executablename
    - - - - -
    310424d0 by Matthew Pickering at 2022-01-18T16:12:50-05:00
    Correct type of static forms in hsExprType
    
    The simplest way to do this seemed to be to persist the whole type in
    the extension field from the typechecker so that the few relevant places
    
     * Desugaring can work out the return type by splitting this type rather
       than calling `dsExpr` (slightly more efficient).
     * hsExprType can just return the correct type.
     * Zonking has to now zonk the type as well
    
    The other option we considered was wiring in StaticPtr but that is
    actually quite tricky because StaticPtr refers to StaticPtrInfo which
    has field selectors (which we can't easily wire in).
    
    Fixes #20150
    
    - - - - -
    7ec783de by Matthew Pickering at 2022-01-18T16:12:50-05:00
    Add test for using type families with static pointers
    
    Issue was reported on #13306
    
    - - - - -
    2d205154 by Sebastian Graf at 2022-01-18T16:13:25-05:00
    Stricten the Strict State monad
    
    I found it weird that most of the combinators weren't actually strict. Making
    `pure` strict in the state should hopefully give Nested CPR an easier time to
    unbox the nested state.
    
    - - - - -
    5a6efd21 by Ben Gamari at 2022-01-18T16:14:01-05:00
    rts/winio: Fix #18382
    
    Here we refactor WinIO's IO completion scheme, squashing a memory leak
    and fixing #18382.
    To fix #18382 we drop the special thread status introduced for IoPort
    blocking, BlockedOnIoCompletion, as well as drop the non-threaded RTS's
    special dead-lock detection logic (which is redundant to the GC's
    deadlock detection logic), as proposed in #20947.
    
    Previously WinIO relied on foreign import ccall "wrapper" to create an
    adjustor thunk which can be attached to the OVERLAPPED structure passed
    to the operating system. It would then use foreign import ccall
    "dynamic" to back out the original continuation from the adjustor. This
    roundtrip is significantly more expensive than the alternative, using a
    StablePtr. Furthermore, the implementation let the adjustor leak,
    meaning that every IO request would leak a page of memory.
    
    Fixes T18382.
    
    - - - - -
    01254ceb by Matthew Pickering at 2022-01-18T16:14:37-05:00
    Add note about heap invariant
    
    Closed #20904
    
    - - - - -
    21510698 by Sergey Vinokurov at 2022-01-18T16:15:12-05:00
    Improve detection of lld linker
    
    Newer lld versions may include vendor info in --version output and
    thus the version string may not start with ‘LLD’.
    
    Fixes #20907
    
    - - - - -
    95e7964b by Peter Trommler at 2022-01-18T20:46:08-05:00
    Fix T20638 on big-endian architectures
    
    The test reads a 16 bit value from an array of 8 bit values. Naturally,
    that leads to different values read on big-endian architectures than
    on little-endian. In this case the value read is 0x8081 on big-endian
    and 0x8180 on little endian. This patch changes the argument of the `and`
    machop to mask bit 7 which is the only bit different. The test still checks
    that bit 15 is zero, which was the original issue in #20638.
    
    Fixes #20906.
    
    - - - - -
    fd0019a0 by Eric Lindblad at 2022-01-18T20:46:48-05:00
    ms and gh links
    - - - - -
    85dc61ee by Zubin Duggal at 2022-01-18T20:47:23-05:00
    ci: Fix subtlety with  not taking effect because of time_it (#20898)
    
    - - - - -
    592e4113 by Anselm Schüler at 2022-01-19T13:31:49-05:00
    Note that ImpredicativeTypes doesn’t allow polymorphic instances
    
    See #20939
    
    - - - - -
    3b009e1a by Ben Gamari at 2022-01-19T13:32:25-05:00
    base: Add CTYPE pragmas to all foreign types
    
    Fixes #15531 by ensuring that we know the corresponding C type for all
    marshalling wrappers.
    
    Closes #15531.
    
    - - - - -
    516eeb9e by Robert Hensing at 2022-01-24T21:28:24-05:00
    Add -fcompact-unwind
    
    This gives users the choice to enable __compact_unwind sections
    when linking. These were previously hardcoded to be removed.
    
    This can be used to solved the problem "C++ does not catch
    exceptions when used with Haskell-main and linked by ghc",
    https://gitlab.haskell.org/ghc/ghc/-/issues/11829
    
    It does not change the default behavior, because I can not
    estimate the impact this would have.
    
    When Apple first introduced the compact unwind ABI, a number of
    open source projects have taken the easy route of disabling it,
    avoiding errors or even just warnings shortly after its
    introduction.
    
    Since then, about a decade has passed, so it seems quite possible
    that Apple itself, and presumably many programs with it, have
    successfully switched to the new format, to the point where the
    old __eh_frame section support is in disrepair. Perhaps we should
    get along with the program, but for now we can test the waters
    with this flag, and use it to fix packages that need it.
    
    - - - - -
    5262b1e5 by Robert Hensing at 2022-01-24T21:28:24-05:00
    Add test case for C++ exception handling
    
    - - - - -
    a5c94092 by Sebastian Graf at 2022-01-24T21:29:00-05:00
    Write Note [Strict State monad] to explain what G.U.M.State.Strict does
    
    As requested by Simon after review of !7342.
    
    I also took liberty to define the `Functor` instance by hand, as the derived one
    subverts the invariants maintained by the pattern synonym (as already stated in
    `Note [The one-shot state monad trick]`).
    
    - - - - -
    9b0d56d3 by Eric Lindblad at 2022-01-24T21:29:38-05:00
    links
    - - - - -
    4eac8e72 by Ben Gamari at 2022-01-24T21:30:13-05:00
    ghc-heap: Drop mention of BlockedOnIOCompletion
    
    Fixes bootstrap with GHC 9.0 after 5a6efd218734dbb5c1350531680cd3f4177690f1
    
    - - - - -
    7d7b9a01 by Ryan Scott at 2022-01-24T21:30:49-05:00
    Hadrian: update the index-state to allow building with GHC 9.0.2
    
    Fixes #20984.
    
    - - - - -
    aa50e118 by Peter Trommler at 2022-01-24T21:31:25-05:00
    testsuite: Mark test that require RTS linker
    
    - - - - -
    871ce2a3 by Matthew Pickering at 2022-01-25T17:27:30-05:00
    ci: Move (most) deb9 jobs to deb10
    
    deb9 is now end-of-life so we are dropping support for producing
    bindists.
    
    - - - - -
    9d478d51 by Ryan Scott at 2022-01-25T17:28:06-05:00
    DeriveGeneric: look up datacon fixities using getDataConFixityFun
    
    Previously, `DeriveGeneric` would look up the fixity of a data constructor
    using `getFixityEnv`, but this is subtly incorrect for data constructors
    defined in external modules. This sort of situation can happen with
    `StandaloneDeriving`, as noticed in #20994. In fact, the same bug has occurred
    in the past in #9830, and while that bug was fixed for `deriving Read` and
    `deriving Show`, the fix was never extended to `DeriveGeneric` due to an
    oversight. This patch corrects that oversight.
    
    Fixes #20994.
    
    - - - - -
    112e9e9e by Zubin Duggal at 2022-01-25T17:28:41-05:00
    Fix Werror on alpine
    
    - - - - -
    781323a3 by Matthew Pickering at 2022-01-25T17:29:17-05:00
    Widen T12545 acceptance window
    
    This test has been the scourge of contributors for a long time.
    
    It has caused many failed CI runs and wasted hours debugging a test
    which barely does anything. The fact is does nothing is the reason for
    the flakiness and it's very sensitive to small changes in initialisation costs,
    in particular adding wired-in things can cause this test to fluctuate
    quite a bit.
    
    Therefore we admit defeat and just bump the threshold up to 10% to catch
    very large regressions but otherwise don't care what this test does.
    
    Fixes #19414
    
    - - - - -
    e471a680 by sheaf at 2022-01-26T12:01:45-05:00
    Levity-polymorphic arrays and mutable variables
    
    This patch makes the following types levity-polymorphic in their
    last argument:
    
      - Array# a, SmallArray# a, Weak# b, StablePtr# a, StableName# a
    
      - MutableArray# s a, SmallMutableArray# s a,
        MutVar# s a, TVar# s a, MVar# s a, IOPort# s a
    
    The corresponding primops are also made levity-polymorphic, e.g.
    `newArray#`, `readArray#`, `writeMutVar#`, `writeIOPort#`, etc.
    
    Additionally, exception handling functions such as `catch#`, `raise#`,
    `maskAsyncExceptions#`,... are made levity/representation-polymorphic.
    
    Now that Array# and MutableArray# also work with unlifted types,
    we can simply re-define ArrayArray# and MutableArrayArray# in terms
    of them. This means that ArrayArray# and MutableArrayArray# are no
    longer primitive types, but simply unlifted newtypes around Array# and
    MutableArrayArray#.
    
    This completes the implementation of the Pointer Rep proposal
      https://github.com/ghc-proposals/ghc-proposals/pull/203
    
    Fixes #20911
    
    -------------------------
    Metric Increase:
        T12545
    -------------------------
    
    -------------------------
    Metric Decrease:
        T12545
    -------------------------
    
    - - - - -
    6e94ba54 by Andreas Klebinger at 2022-01-26T12:02:21-05:00
    CorePrep: Don't try to wrap partial applications of primops in profiling ticks.
    
    This fixes #20938.
    
    - - - - -
    b55d7db3 by sheaf at 2022-01-26T12:03:01-05:00
    Ensure that order of instances doesn't matter
    
    The insert_overlapping used in lookupInstEnv used to return different
    results depending on the order in which instances were processed.
    The problem was that we could end up discarding an overlapping instance
    in favour of a more specific non-overlapping instance. This is a
    problem because, even though we won't choose the less-specific instance
    for matching, it is still useful for pruning away other instances,
    because it has the overlapping flag set while the new instance doesn't.
    
    In insert_overlapping, we now keep a list of "guard" instances, which
    are instances which are less-specific that one that matches (and hence
    which we will discard in the end), but want to keep around solely for
    the purpose of eliminating other instances.
    
    Fixes #20946
    
    - - - - -
    61f62062 by sheaf at 2022-01-26T12:03:40-05:00
    Remove redundant SOURCE import in FitTypes
    
    Fixes #20995
    
    - - - - -
    e8405829 by sheaf at 2022-01-26T12:04:15-05:00
    Fix haddock markup in GHC.Tc.Errors.Types
    - - - - -
    590a2918 by Simon Peyton Jones at 2022-01-26T19:45:22-05:00
    Make RULE matching insensitive to eta-expansion
    
    This patch fixes #19790 by making the rule matcher do on-the-fly
    eta reduction.  See Note [Eta reduction the target] in GHC.Core.Rules
    
    I found I also had to careful about casts when matching; see
    Note [Casts in the target] and Note [Casts in the template]
    
    Lots more comments and Notes in the rule matcher
    
    - - - - -
    c61ac4d8 by Matthew Pickering at 2022-01-26T19:45:58-05:00
    alwaysRerun generation of ghcconfig
    
    This file needs to match exactly what is passed as the testCompiler.
    Before this change the settings for the first compiler to be tested
    woudl be stored and not regenerated if --test-compiler changed.
    
    - - - - -
    b5132f86 by Matthew Pickering at 2022-01-26T19:45:58-05:00
    Pass config.stage argument to testsuite
    
    - - - - -
    83d3ad31 by Zubin Duggal at 2022-01-26T19:45:58-05:00
    hadrian: Allow testing of the stage1 compiler (#20755)
    
    - - - - -
    a5924b38 by Joachim Breitner at 2022-01-26T19:46:34-05:00
    Simplifier: Do the right thing if doFloatFromRhs = False
    
    If `doFloatFromRhs` is `False` then the result from `prepareBinding`
    should not be used. Previously it was in ways that are silly (but not
    completly wrong, as the simplifier would clean that up again, so no
    test case).
    
    This was spotted by Simon during a phone call.
    
    Fixes #20976
    
    - - - - -
    ce488c2b by Simon Peyton Jones at 2022-01-26T19:47:09-05:00
    Better occurrence analysis with casts
    
    This patch addresses #20988 by refactoring the way the
    occurrence analyser deals with lambdas.
    
    Previously it used collectBinders to split off a group of binders,
    and deal with them together.  Now I deal with them one at a time
    in occAnalLam, which allows me to skip casts easily.  See
        Note [Occurrence analysis for lambda binders]
    about "lambda-groups"
    
    This avoidance of splitting out a list of binders has some good
    consequences.  Less code, more efficient, and I think, more clear.
    
    The Simplifier needed a similar change, now that lambda-groups
    can inlude casts.  It turned out that I could simplify the code
    here too, in particular elminating the sm_bndrs field of StrictBind.
    Simpler, more efficient.
    
    Compile-time metrics improve slightly; here are the ones that are
    +/- 0.5% or greater:
    
                                      Baseline
                  Test    Metric         value     New value Change
    --------------------------------------------------------------------
       T11303b(normal) ghc/alloc    40,736,702    40,543,992  -0.5%
        T12425(optasm) ghc/alloc    90,443,459    90,034,104  -0.5%
        T14683(normal) ghc/alloc 2,991,496,696 2,956,277,288  -1.2%
        T16875(normal) ghc/alloc    34,937,866    34,739,328  -0.6%
       T17977b(normal) ghc/alloc    37,908,550    37,709,096  -0.5%
        T20261(normal) ghc/alloc   621,154,237   618,312,480  -0.5%
         T3064(normal) ghc/alloc   190,832,320   189,952,312  -0.5%
         T3294(normal) ghc/alloc 1,604,674,178 1,604,608,264  -0.0%
       T5321FD(normal) ghc/alloc   270,540,489   251,888,480  -6.9% GOOD
      T5321Fun(normal) ghc/alloc   300,707,814   281,856,200  -6.3% GOOD
         WWRec(normal) ghc/alloc   588,460,916   585,536,400  -0.5%
    
             geo. mean                                        -0.3%
    
    Metric Decrease:
        T5321FD
        T5321Fun
    
    - - - - -
    4007905d by Roland Senn at 2022-01-26T19:47:47-05:00
    Cleanup tests in directory ghci.debugger. Fixes #21009
    
    * Remove wrong comment about panic in `break003.script`.
    * Improve test `break008`.
    * Add test `break028` to `all.T`
    * Fix wrong comments in `print019.script`, `print026.script` and `result001.script`.
    * Remove wrong comments from `print024.script` and `print031.script`.
    * Replace old module name with current name in `print035.script`.
    
    - - - - -
    3577defb by Matthew Pickering at 2022-01-26T19:48:22-05:00
    ci: Move source-tarball and test-bootstrap into full-build
    
    - - - - -
    6e09b3cf by Matthew Pickering at 2022-01-27T02:39:35-05:00
    ci: Add ENABLE_NUMA flag to explicitly turn on libnuma dependency
    
    In recent releases a libnuma dependency has snuck into our bindists
    because the images have started to contain libnuma. We now explicitly
    pass `--disable-numa` to configure unless explicitly told not to by
    using the `ENABLE_NUMA` environment variable.
    
    So this is tested, there is one random validate job which builds with
    --enable-numa so that the code in the RTS is still built.
    
    Fixes #20957 and #15444
    
    - - - - -
    f4ce4186 by Simon Peyton Jones at 2022-01-27T02:40:11-05:00
    Improve partial signatures
    
    As #20921 showed, with partial signatures, it is helpful to use the
    same algorithm (namely findInferredDiff) for
    * picking the constraints to retain for the /group/
      in Solver.decideQuantification
    * picking the contraints to retain for the /individual function/
      in Bind.chooseInferredQuantifiers
    
    This is still regrettably declicate, but it's a step forward.
    
    - - - - -
    0573aeab by Simon Peyton Jones at 2022-01-27T02:40:11-05:00
    Add an Outputable instance for RecTcChecker
    
    - - - - -
    f0adea14 by Ryan Scott at 2022-01-27T02:40:47-05:00
    Expand type synonyms in markNominal
    
    `markNominal` is repsonsible for setting the roles of type variables
    that appear underneath an `AppTy` to be nominal. However, `markNominal`
    previously did not expand type synonyms, so in a data type like this:
    
    ```hs
    data M f a = MkM (f (T a))
    
    type T a = Int
    ```
    
    The `a` in `M f a` would be marked nominal, even though `T a` would simply
    expand to `Int`. The fix is simple: call `coreView` as appropriate in
    `markNominal`. This is much like the fix for #14101, but in a different spot.
    
    Fixes #20999.
    
    - - - - -
    18df4013 by Simon Peyton Jones at 2022-01-27T08:22:30-05:00
    Define and use restoreLclEnv
    
    This fixes #20981.  See Note [restoreLclEnv vs setLclEnv]
    in GHC.Tc.Utils.Monad.
    
    I also use updLclEnv rather than get/set when I can, because it's
    then much clearer that it's an update rather than an entirely new
    TcLclEnv coming from who-knows-where.
    
    - - - - -
    31088dd3 by David Feuer at 2022-01-27T08:23:05-05:00
    Add test supplied in T20996 which uses data family result kind polymorphism
    
    David (@treeowl) writes:
    
    > Following @kcsongor, I've used ridiculous data family result kind
    > polymorphism in `linear-generics`, and am currently working on getting
    > it into `staged-gg`. If it should be removed, I'd appreciate a heads up,
    > and I imagine Csongor would too.
    >
    > What do I need by ridiculous polymorphic result kinds? Currently, data
    > families are allowed to have result kinds that end in `Type` (or maybe
    > `TYPE r`? I'm not sure), but not in concrete data kinds. However, they
    > *are* allowed to have polymorphic result kinds. This leads to things I
    > think most of us find at least quite *weird*. For example, I can write
    >
    > ```haskell
    > data family Silly :: k
    > data SBool :: Bool -> Type where
    >   SFalse :: SBool False
    >   STrue :: SBool True
    >   SSSilly :: SBool Silly
    > type KnownBool b where
    >   kb :: SBool b
    > instance KnownBool False where kb = SFalse
    > instance KnownBool True where kb = STrue
    > instance KnownBool Silly where kb = Silly
    > ```
    >
    > Basically, every kind now has potentially infinitely many "legit" inhabitants.
    >
    > As horrible as that is, it's rather useful for GHC's current native
    > generics system. It's possible to use these absurdly polymorphic result
    > kinds to probe the structure of generic representations in a relatively
    > pleasant manner. It's a sort of "formal type application" reminiscent of
    > the notion of a formal power series (see the test case below). I suspect
    > a system more like `kind-generics` wouldn't need this extra probing
    > power, but nothing like that is natively available as yet.
    >
    > If the ridiculous result kind polymorphism is banished, we'll still be
    > able to do what we need as long as we have stuck type families. It's
    > just rather less ergonomical: a stuck type family has to be used with a
    > concrete marker type argument.
    
    Closes #20996
    
    Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    8fd2ac25 by Andreas Abel at 2022-01-27T18:34:54-05:00
    Whitespace only
    
    - - - - -
    7a854743 by Andreas Abel at 2022-01-27T18:34:54-05:00
    Ctd. #18087: complete :since: info for all warnings in users guide
    
    Some warnings have been there "forever" and I could not trace back the
    exact genesis, so I wrote "since at least 5.04".
    
    The flag `helpful-errors` could have been added in 7.2 already.  I
    wrote 7.4 since I have no 7.2 available and it is not recognized by 7.0.
    
    - - - - -
    f75411e8 by Andreas Abel at 2022-01-27T18:34:54-05:00
    Re #18087 user's guide: add a note that -Wxxx used to be -fwarn-xxx
    
    The warning option syntax -W was introduced in GHC 8.
    
    The note should clarify what e.g. "since 7.6" means in connection with
    "-Wxxx": That "-fwarn-xxx" was introduced in 7.6.1.
    
    [ci skip]
    
    - - - - -
    3cae7fde by Peter Trommler at 2022-01-27T18:35:30-05:00
    testsuite: Fix AtomicPrimops test on big endian
    
    - - - - -
    6cc6080c by Ben Gamari at 2022-01-27T18:36:05-05:00
    users-guide: Document GHC_CHARENC environment variable
    
    As noted in #20963, this was introduced in
    1b56c40578374a15b4a2593895710c68b0e2a717 but was no documentation
    was added at that point.
    
    Closes #20963.
    - - - - -
    ee21e2de by Ben Gamari at 2022-01-27T18:36:41-05:00
    rts: Clean up RTS flags usage message
    
    Align flag descriptions and acknowledge that some flags may not be
    available unless the user linked with `-rtsopts` (as noted in #20961).
    
    Fixes #20961.
    
    - - - - -
    7f8ce19e by Simon Peyton Jones at 2022-01-27T18:37:17-05:00
    Fix getHasGivenEqs
    
    The second component is supposed to be "insoluble equalities arising
    from givens".  But we were getting wanteds too; and that led to an
    outright duplication of constraints.  It's not harmful, but it's not
    right either.
    
    I came across this when debugging something else.  Easily fixed.
    
    - - - - -
    f9ef2d26 by Simon Peyton Jones at 2022-01-27T18:37:17-05:00
    Set the TcLclEnv when solving a ForAll constraint
    
    Fix a simple omission in GHC.Tc.Solver.Canonical.solveForAll,
    where we ended up with the wrong TcLclEnv captured in an implication.
    
    Result: unhelpful error message (#21006)
    
    - - - - -
    bc6ba8ef by Sylvain Henry at 2022-01-28T12:14:41-05:00
    Make most shifts branchless
    
    - - - - -
    62a6d037 by Simon Peyton Jones at 2022-01-28T12:15:17-05:00
    Improve boxity in deferAfterPreciseException
    
    As #20746 showed, the demand analyser behaved badly in a key I/O
    library (`GHC.IO.Handle.Text`), by unnessarily boxing and reboxing.
    
    This patch adjusts the subtle function deferAfterPreciseException;
    it's quite easy, just a bit subtle.
    
    See the new Note [deferAfterPreciseException]
    
    And this MR deals only with Problem 2 in #20746.
    Problem 1 is still open.
    
    - - - - -
    42c47cd6 by Ben Gamari at 2022-01-29T02:40:45-05:00
    rts/trace: Shrink tracing flags
    
    - - - - -
    cee66e71 by Ben Gamari at 2022-01-29T02:40:45-05:00
    rts/EventLog: Mark various internal globals as static
    
    - - - - -
    6b0cea29 by Ben Gamari at 2022-01-29T02:40:45-05:00
    Propagate PythonCmd to make build system
    
    - - - - -
    2e29edb7 by Ben Gamari at 2022-01-29T02:40:45-05:00
    rts: Refactor event types
    
    Previously we would build the eventTypes array at runtime during RTS
    initialization. However, this is completely unnecessary; it is
    completely static data.
    
    - - - - -
    bb15c347 by Ben Gamari at 2022-01-29T02:40:45-05:00
    rts/eventlog: Ensure that flushCount is initialized
    
    - - - - -
    268efcc9 by Matthew Pickering at 2022-01-29T02:41:21-05:00
    Rework the handling of SkolemInfo
    
    The main purpose of this patch is to attach a SkolemInfo directly to
    each SkolemTv. This fixes the large number of bugs which have
    accumulated over the years where we failed to report errors due to
    having "no skolem info" for particular type variables. Now the origin of
    each type varible is stored on the type variable we can always report
    accurately where it cames from.
    
    Fixes #20969 #20732 #20680 #19482 #20232 #19752 #10946
      #19760 #20063 #13499 #14040
    
    The main changes of this patch are:
    
    * SkolemTv now contains a SkolemInfo field which tells us how the
      SkolemTv was created. Used when reporting errors.
    
    * Enforce invariants relating the SkolemInfoAnon and level of an implication (ic_info, ic_tclvl)
      to the SkolemInfo and level of the type variables in ic_skols.
        * All ic_skols are TcTyVars -- Check is currently disabled
        * All ic_skols are SkolemTv
        * The tv_lvl of the ic_skols agrees with the ic_tclvl
        * The ic_info agrees with the SkolInfo of the implication.
    
      These invariants are checked by a debug compiler by
      checkImplicationInvariants.
    
    * Completely refactor kcCheckDeclHeader_sig which kept
      doing my head in. Plus, it wasn't right because it wasn't skolemising
      the binders as it decomposed the kind signature.
    
      The new story is described in Note [kcCheckDeclHeader_sig].  The code
      is considerably shorter than before (roughly 240 lines turns into 150
      lines).
    
      It still has the same awkward complexity around computing arity as
      before, but that is a language design issue.
      See Note [Arity inference in kcCheckDeclHeader_sig]
    
    * I added new type synonyms MonoTcTyCon and PolyTcTyCon, and used
      them to be clear which TcTyCons have "finished" kinds etc, and
      which are monomorphic. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon]
    
    * I renamed etaExpandAlgTyCon to splitTyConKind, becuase that's a
      better name, and it is very useful in kcCheckDeclHeader_sig, where
      eta-expansion isn't an issue.
    
    * Kill off the nasty `ClassScopedTvEnv` entirely.
    
    Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    0a1d0944 by Ben Gamari at 2022-01-29T14:52:55-05:00
    Drop SPARC NCG
    
    - - - - -
    313afb3d by Ben Gamari at 2022-01-29T14:52:56-05:00
    A few comment cleanups
    
    - - - - -
    d85a527f by Ben Gamari at 2022-01-29T14:52:56-05:00
    Rip out SPARC register support
    
    - - - - -
    c6bede69 by Ben Gamari at 2022-01-29T14:52:56-05:00
    rts: Rip out SPARC support
    
    - - - - -
    a67c2471 by Ben Gamari at 2022-01-29T14:52:56-05:00
    Rip out remaining SPARC support
    
    - - - - -
    5771b690 by Ben Gamari at 2022-01-29T14:52:56-05:00
    CmmToAsm: Drop RegPair
    
    SPARC was its last and only user.
    
    - - - - -
    512ed3f1 by Ben Gamari at 2022-01-29T14:52:56-05:00
    CmmToAsm: Make RealReg a newtype
    
    Now that RegPair is gone we no longer need to pay for the additional
    box.
    
    - - - - -
    88fea6aa by Ben Gamari at 2022-01-29T14:52:56-05:00
    rts: Drop redundant #include <Arena.h>
    
    - - - - -
    ea2a4034 by Ben Gamari at 2022-01-29T14:52:56-05:00
    CmmToAsm: Drop ncgExpandTop
    
    This was only needed for SPARC's synthetic instructions.
    
    - - - - -
    88fce740 by Ben Gamari at 2022-01-29T14:54:04-05:00
    rel-notes: Note dropping of SPARC support
    
    - - - - -
    eb956cf1 by Ben Gamari at 2022-01-30T06:27:19-05:00
    testsuite: Force-enable caret diagnostics in T17786
    
    Otherwise GHC realizes that it's not attached to a proper tty and will
    disable caret diagnostics.
    
    - - - - -
    d07799ab by Ben Gamari at 2022-01-30T06:27:19-05:00
    testsuite: Make T7275 more robust against CCid changes
    
    The cost-center numbers are somewhat unstable; normalise them out.
    
    - - - - -
    c76c8050 by Ben Gamari at 2022-01-30T06:27:19-05:00
    rts: Don't allocate closurePtrs# pointers on C stack
    
    Previously `closurePtrs#` would allocate an aray of the size of the
    closure being decoded on the C stack. This was ripe for overflowing the
    C stack overflow. This resulted in `T12492` failing on Windows.
    
    - - - - -
    3af95f7a by Ben Gamari at 2022-01-30T06:27:19-05:00
    testsuite/T4029: Don't depend on echo
    
    On Windows the `cmd.exe` shell may be used to execute the command, which
    will print `ECHO is on.` instead of a newline if you give it no
    argument. Avoid this by rather using `printf`.
    
    - - - - -
    3531c478 by Ben Gamari at 2022-01-30T06:27:19-05:00
    Use PATH_FMT instead of %s to format `pathchar *`
    
    A few %s occurrences have snuck in over the past months.
    
    - - - - -
    ee5c4f9d by Zubin Duggal at 2022-01-31T16:51:55+05:30
    Improve migration strategy for the XDG compliance change to the GHC application
    directory.
    
    We want to always use the old path (~/.ghc/..) if it exists.
    But we never want to create the old path.
    This ensures that the migration can eventually be completed once older GHC
    versions are no longer in circulation.
    
    Fixes #20684, #20669, #20660
    
    - - - - -
    60a54a8f by doyougnu at 2022-01-31T18:46:11-05:00
    StgToCmm: decouple DynFlags, add StgToCmmConfig
    
    StgToCmm: add Config, remove CgInfoDownwards
    
    StgToCmm: runC api change to take StgToCmmConfig
    
    StgToCmm: CgInfoDownad -> StgToCmmConfig
    
    StgToCmm.Monad: update getters/setters/withers
    
    StgToCmm: remove CallOpts in StgToCmm.Closure
    
    StgToCmm: remove dynflag references
    
    StgToCmm: PtrOpts removed
    
    StgToCmm: add TMap to config, Prof - dynflags
    
    StgToCmm: add omit yields to config
    
    StgToCmm.ExtCode: remove redundant import
    
    StgToCmm.Heap: remove references to dynflags
    
    StgToCmm: codeGen api change, DynFlags -> Config
    
    StgToCmm: remove dynflags in Env and StgToCmm
    
    StgToCmm.DataCon: remove dynflags references
    
    StgToCmm: remove dynflag references in DataCon
    
    StgToCmm: add backend avx flags to config
    
    StgToCmm.Prim: remove dynflag references
    
    StgToCmm.Expr: remove dynflag references
    
    StgToCmm.Bind: remove references to dynflags
    
    StgToCmm: move DoAlignSanitisation to Cmm.Type
    
    StgToCmm: remove PtrOpts in Cmm.Parser.y
    
    DynFlags: update ipInitCode api
    
    StgToCmm: Config Module is single source of truth
    
    StgToCmm: Lazy config breaks IORef deadlock
    
    testsuite: bump countdeps threshold
    
    StgToCmm.Config: strictify fields except UpdFrame
    
    Strictifying UpdFrameOffset causes the RTS build with stage1 to
    deadlock. Additionally, before the deadlock performance of the RTS
    is noticeably slower.
    
    StgToCmm.Config: add field descriptions
    
    StgToCmm: revert strictify on Module in config
    
    testsuite: update CountDeps tests
    
    StgToCmm: update comment, fix exports
    
    Specifically update comment about loopification passed into dynflags
    then stored into stgToCmmConfig. And remove getDynFlags from
    Monad.hs exports
    
    Types.Name: add pprFullName function
    
    StgToCmm.Ticky: use pprFullname, fixup ExtCode imports
    
    Cmm.Info: revert cmmGetClosureType removal
    
    StgToCmm.Bind: use pprFullName, Config update comments
    
    StgToCmm: update closureDescription api
    
    StgToCmm: SAT altHeapCheck
    
    StgToCmm: default render for Info table, ticky
    
    Use default rendering contexts for info table and ticky ticky, which should be independent of command line input.
    
    testsuite: bump count deps
    
    pprFullName: flag for ticky vs normal style output
    
    convertInfoProvMap: remove unused parameter
    
    StgToCmm.Config: add backend flags to config
    
    StgToCmm.Config: remove Backend from Config
    
    StgToCmm.Prim: refactor Backend call sites
    
    StgToCmm.Prim: remove redundant imports
    
    StgToCmm.Config: refactor vec compatibility check
    
    StgToCmm.Config: add allowQuotRem2 flag
    
    StgToCmm.Ticky: print internal names with parens
    
    StgToCmm.Bind: dispatch ppr based on externality
    
    StgToCmm: Add pprTickyname, Fix ticky naming
    
    Accidently removed the ctx for ticky SDoc output. The only relevant flag
    is sdocPprDebug which was accidental set to False due to using
    defaultSDocContext without altering the flag.
    
    StgToCmm: remove stateful fields in config
    
    fixup: config: remove redundant imports
    
    StgToCmm: move Sequel type to its own module
    
    StgToCmm: proliferate getCallMethod updated api
    
    StgToCmm.Monad: add FCodeState to Monad Api
    
    StgToCmm: add second reader monad to FCode
    
    fixup: Prim.hs: missed a merge conflict
    
    fixup: Match countDeps tests to HEAD
    
    StgToCmm.Monad: withState -> withCgState
    
    To disambiguate it from mtl withState. This withState shouldn't be
    returning the new state as a value. However, fixing this means tackling
    the knot tying in CgState and so is very difficult since it changes when
    the thunk of the knot is forced which either leads to deadlock or to
    compiler panic.
    
    - - - - -
    58eccdbc by Ben Gamari at 2022-01-31T18:46:47-05:00
    codeGen: Fix two buglets in -fbounds-check logic
    
    @Bodigrim noticed that the `compareByteArray#` bounds-checking logic had
    flipped arguments and an off-by-one. For the sake of clarity I also
    refactored occurrences of `cmmOffset` to rather use `cmmOffsetB`. I
    suspect the former should be retired.
    
    - - - - -
    584f03fa by Simon Peyton Jones at 2022-01-31T18:47:23-05:00
    Make typechecker trace less strict
    
    Fixes #21011
    
    - - - - -
    60ac7300 by Elton at 2022-02-01T12:28:49-05:00
    Use braces in TH case pprint (fixes #20893)
    
    This patch ensures that the pretty printer formats `case` statements
    using braces (instead of layout) to remain consistent with the
    formatting of other statements (like `do`)
    
    - - - - -
    fdda93b0 by Elton at 2022-02-01T12:28:49-05:00
    Use braces in TH LambdaCase and where clauses
    
    This patch ensures that the pretty printer formats LambdaCase and where
    clauses using braces (instead of layout) to remain consistent with the
    formatting of other statements (like `do` and `case`)
    
    - - - - -
    06185102 by Ben Gamari at 2022-02-01T12:29:26-05:00
    Consistently upper-case "Note ["
    
    This was achieved with
    
        git ls-tree --name-only HEAD -r | xargs sed -i -e 's/note \[/Note \[/g'
    
    - - - - -
    88fba8a4 by Ben Gamari at 2022-02-01T12:29:26-05:00
    Fix a few Note inconsistencies
    
    - - - - -
    05548a22 by Douglas Wilson at 2022-02-02T19:26:06-05:00
    rts: Address failures to inline
    
    - - - - -
    074945de by Simon Peyton Jones at 2022-02-02T19:26:41-05:00
    Two small improvements in the Simplifier
    
    As #20941 describes, this patch implements a couple of small
    fixes to the Simplifier.  They make a difference principally
    with -O0, so few people will notice.  But with -O0 they can
    reduce the number of Simplifer iterations.
    
    * In occurrence analysis we avoid making x = (a,b) into a loop breaker
      because we want to be able to inline x, or (more likely) do
      case-elimination. But HEAD does not treat
          x = let y = blah in (a,b)
      in the same way.  We should though, because we are going to float
      that y=blah out of the x-binding.  A one-line fix in OccurAnal.
    
    * The crucial function exprIsConApp_maybe uses getUnfoldingInRuleMatch
      (rightly) but the latter was deeply strange.  In HEAD, if
      rule-rewriting was off (-O0) we only looked inside stable
      unfoldings. Very stupid.  The patch simplifies.
    
    * I also noticed that in simplStableUnfolding we were failing to
      delete the DFun binders from the usage.  So I added that.
    
    Practically zero perf change across the board, except that we get more
    compiler allocation in T3064 (which is compiled with -O0). There's a
    good reason: we get better code.  But there are lots of other small
    compiler allocation decreases:
    
    Metrics: compile_time/bytes allocated
    ---------------------
                                       Baseline
                   Test    Metric         value     New value Change
    -----------------------------------------------------------------
      PmSeriesG(normal) ghc/alloc    44,260,817    44,184,920  -0.2%
      PmSeriesS(normal) ghc/alloc    52,967,392    52,891,632  -0.1%
      PmSeriesT(normal) ghc/alloc    75,498,220    75,421,968  -0.1%
      PmSeriesV(normal) ghc/alloc    52,341,849    52,265,768  -0.1%
         T10421(normal) ghc/alloc   109,702,291   109,626,024  -0.1%
        T10421a(normal) ghc/alloc    76,888,308    76,809,896  -0.1%
         T10858(normal) ghc/alloc   125,149,038   125,073,648  -0.1%
         T11276(normal) ghc/alloc    94,159,364    94,081,640  -0.1%
        T11303b(normal) ghc/alloc    40,230,059    40,154,368  -0.2%
         T11822(normal) ghc/alloc   107,424,540   107,346,088  -0.1%
         T12150(optasm) ghc/alloc    76,486,339    76,426,152  -0.1%
         T12234(optasm) ghc/alloc    55,585,046    55,507,352  -0.1%
         T12425(optasm) ghc/alloc    88,343,288    88,265,312  -0.1%
         T13035(normal) ghc/alloc    98,919,768    98,845,600  -0.1%
     T13253-spj(normal) ghc/alloc   121,002,153   120,851,040  -0.1%
         T16190(normal) ghc/alloc   290,313,131   290,074,152  -0.1%
         T16875(normal) ghc/alloc    34,756,121    34,681,440  -0.2%
        T17836b(normal) ghc/alloc    45,198,100    45,120,288  -0.2%
         T17977(normal) ghc/alloc    39,479,952    39,404,112  -0.2%
        T17977b(normal) ghc/alloc    37,213,035    37,137,728  -0.2%
         T18140(normal) ghc/alloc    79,430,588    79,350,680  -0.1%
         T18282(normal) ghc/alloc   128,303,182   128,225,384  -0.1%
         T18304(normal) ghc/alloc    84,904,713    84,831,952  -0.1%
         T18923(normal) ghc/alloc    66,817,241    66,731,984  -0.1%
         T20049(normal) ghc/alloc    86,188,024    86,107,920  -0.1%
          T5837(normal) ghc/alloc    35,540,598    35,464,568  -0.2%
          T6048(optasm) ghc/alloc    99,812,171    99,736,032  -0.1%
          T9198(normal) ghc/alloc    46,380,270    46,304,984  -0.2%
    
              geo. mean                                        -0.0%
    
    Metric Increase:
        T3064
    
    - - - - -
    d2cce453 by Morrow at 2022-02-02T19:27:21-05:00
    Fix @since annotation on Nat
    
    - - - - -
    6438fed9 by Simon Peyton Jones at 2022-02-02T19:27:56-05:00
    Refactor the escaping kind check for data constructors
    
    As #20929 pointed out, we were in-elegantly checking for escaping
    kinds in `checkValidType`, even though that check was guaranteed
    to succeed for type signatures -- it's part of kind-checking a type.
    
    But for /data constructors/ we kind-check the pieces separately,
    so we still need the check.
    
    This MR is a pure refactor, moving the test from `checkValidType` to
    `checkValidDataCon`.
    
    No new tests; external behaviour doesn't change.
    
    - - - - -
    fb05e5ac by Andreas Klebinger at 2022-02-02T19:28:31-05:00
    Replace sndOfTriple with sndOf3
    
    I also cleaned up the imports slightly while I was at it.
    
    - - - - -
    fbc77d3a by Matthew Pickering at 2022-02-02T19:29:07-05:00
    testsuite: Honour PERF_BASELINE_COMMIT when computing allowed metric changes
    
    We now get all the commits between the PERF_BASELINE_COMMIT and HEAD and
    check any of them for metric changes.
    
    Fixes #20882
    
    - - - - -
    0a82ae0d by Simon Peyton Jones at 2022-02-02T23:49:58-05:00
    More accurate unboxing
    
    This patch implements a fix for #20817.  It ensures that
    
    * The final strictness signature for a function accurately
      reflects the unboxing done by the wrapper
      See Note [Finalising boxity for demand signatures]
      and Note [Finalising boxity for let-bound Ids]
    
    * A much better "layer-at-a-time" implementation of the
      budget for how many worker arguments we can have
      See Note [Worker argument budget]
    
      Generally this leads to a bit more worker/wrapper generation,
      because instead of aborting entirely if the budget is exceeded
      (and then lying about boxity), we unbox a bit.
    
    Binary sizes in increase slightly (around 1.8%) because of the increase
    in worker/wrapper generation.  The big effects are to GHC.Ix,
    GHC.Show, GHC.IO.Handle.Internals. If we did a better job of dropping
    dead code, this effect might go away.
    
    Some nofib perf improvements:
    
            Program           Size    Allocs   Runtime   Elapsed  TotalMem
    --------------------------------------------------------------------------------
                VSD          +1.8%     -0.5%     0.017     0.017      0.0%
             awards          +1.8%     -0.1%     +2.3%     +2.3%      0.0%
             banner          +1.7%     -0.2%     +0.3%     +0.3%      0.0%
               bspt          +1.8%     -0.1%     +3.1%     +3.1%      0.0%
              eliza          +1.8%     -0.1%     +1.2%     +1.2%      0.0%
             expert          +1.7%     -0.1%     +9.6%     +9.6%      0.0%
     fannkuch-redux          +1.8%     -0.4%     -9.3%     -9.3%      0.0%
              kahan          +1.8%     -0.1%    +22.7%    +22.7%      0.0%
           maillist          +1.8%     -0.9%    +21.2%    +21.6%      0.0%
           nucleic2          +1.7%     -5.1%     +7.5%     +7.6%      0.0%
             pretty          +1.8%     -0.2%     0.000     0.000      0.0%
    reverse-complem          +1.8%     -2.5%    +12.2%    +12.2%      0.0%
               rfib          +1.8%     -0.2%     +2.5%     +2.5%      0.0%
                scc          +1.8%     -0.4%     0.000     0.000      0.0%
             simple          +1.7%     -1.3%    +17.0%    +17.0%     +7.4%
      spectral-norm          +1.8%     -0.1%     +6.8%     +6.7%      0.0%
             sphere          +1.7%     -2.0%    +13.3%    +13.3%      0.0%
                tak          +1.8%     -0.2%     +3.3%     +3.3%      0.0%
               x2n1          +1.8%     -0.4%     +8.1%     +8.1%      0.0%
    --------------------------------------------------------------------------------
                Min          +1.1%     -5.1%    -23.6%    -23.6%      0.0%
                Max          +1.8%     +0.0%    +36.2%    +36.2%     +7.4%
     Geometric Mean          +1.7%     -0.1%     +6.8%     +6.8%     +0.1%
    
    Compiler allocations in CI have a geometric mean of +0.1%; many small
    decreases but there are three bigger increases (7%), all because we do
    more worker/wrapper than before, so there is simply more code to
    compile.  That's OK.
    
    Perf benchmarks in perf/should_run improve in allocation by a geo mean
    of -0.2%, which is good.  None get worse. T12996 improves by -5.8%
    
    Metric Decrease:
        T12996
    Metric Increase:
        T18282
        T18923
        T9630
    
    - - - - -
    d1ef6288 by Peter Trommler at 2022-02-02T23:50:34-05:00
    Cmm: fix equality of expressions
    
    Compare expressions and types when comparing `CmmLoad`s.
    Fixes #21016
    
    - - - - -
    e59446c6 by Peter Trommler at 2022-02-02T23:50:34-05:00
    Check type first then expression
    
    - - - - -
    b0e1ef4a by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Add failing test for #20791
    
    The test produces different output on static vs dynamic GHC builds.
    
    - - - - -
    cae1fb17 by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Frontend01 passes with static GHC
    
    - - - - -
    e343526b by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Don't initialise plugins when there are no pipelines to run
    
    - - - - -
    abac45fc by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Mark prog003 as expected_broken on static way #20704
    
    - - - - -
    13300dfd by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Filter out -rtsopts in T16219 to make static/dynamic ways agree
    
    - - - - -
    d89439f2 by Matthew Pickering at 2022-02-03T14:44:17-05:00
    T13168: Filter out rtsopts for consistency between dynamic and static ways
    
    - - - - -
    00180cdf by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Accept new output for T14335 test
    
    This test was previously not run due to #20960
    
    - - - - -
    1accdcff by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Add flushes to plugin tests which print to stdout
    
    Due to #20791 you need to explicitly flush as otherwise the output from
    these tests doesn't make it to stdout.
    
    - - - - -
    d820f2e8 by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Remove ghc_plugin_way
    
    Using ghc_plugin_way had the unintended effect of meaning certain tests
    weren't run at all when ghc_dynamic=true, if you delete this modifier
    then the tests work in both the static and dynamic cases.
    
    - - - - -
    aa5ef340 by Matthew Pickering at 2022-02-03T14:44:17-05:00
    Unbreak T13168 on windows
    
    Fixes #14276
    
    - - - - -
    84ab0153 by Matthew Pickering at 2022-02-03T14:44:53-05:00
    Rewrite CallerCC parser using ReadP
    
    This allows us to remove the dependency on parsec and hence transitively
    on text.
    
    Also added some simple unit tests for the parser and fixed two small
    issues in the documentation.
    
    Fixes #21033
    
    - - - - -
    4e6780bb by Matthew Pickering at 2022-02-03T14:45:28-05:00
    ci: Add debian 11 jobs (validate/release/nightly)
    
    Fixes #21002
    
    - - - - -
    eddaa591 by Ben Gamari at 2022-02-04T10:01:59-05:00
    compiler: Introduce and use RoughMap for instance environments
    
    Here we introduce a new data structure, RoughMap, inspired by the
    previous `RoughTc` matching mechanism for checking instance matches.
    This allows [Fam]InstEnv to be implemented as a trie indexed by these
    RoughTc signatures, reducing the complexity of instance lookup and
    FamInstEnv merging (done during the family instance conflict test)
    from O(n) to O(log n).
    
    The critical performance improvement currently realised by this patch is
    in instance matching. In particular the RoughMap mechanism allows us to
    discount many potential instances which will never match for constraints
    involving type variables (see Note [Matching a RoughMap]). In realistic
    code bases matchInstEnv was accounting for 50% of typechecker time due
    to redundant work checking instances when simplifying instance contexts
    when deriving instances. With this patch the cost is significantly
    reduced.
    
    The larger constants in InstEnv creation do mean that a few small
    tests regress in allocations slightly. However, the runtime of T19703 is
    reduced by a factor of 4. Moreover, the compilation time of the Cabal
    library is slightly improved.
    
    A couple of test cases are included which demonstrate significant
    improvements in compile time with this patch.
    
    This unfortunately does not fix the testcase provided in #19703 but does
    fix #20933
    
    -------------------------
    Metric Decrease:
        T12425
    Metric Increase:
        T13719
        T9872a
        T9872d
        hard_hole_fits
    -------------------------
    
    Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    62d670eb by Matthew Pickering at 2022-02-04T10:02:35-05:00
    testsuite: Run testsuite dependency calculation before GHC is built
    
    The main motivation for this patch is to allow tests to be added to the
    testsuite which test things about the source tree without needing to
    build GHC. In particular the notes linter can easily start failing and
    by integrating it into the testsuite the  process of observing these
    changes is caught by normal validation procedures rather than having to
    run the linter specially.
    
    With this patch I can run
    
    ```
    ./hadrian/build test --flavour=devel2  --only="uniques"
    ```
    
    In a clean tree to run the checkUniques linter without having to build
    GHC.
    
    Fixes #21029
    
    - - - - -
    4bd52410 by Hécate Moonlight at 2022-02-04T16:14:10-05:00
    Add the Ix class to Foreign C integral types
    
    Related CLC proposal is here: https://github.com/haskell/core-libraries-committee/issues/30
    
    - - - - -
    de6d7692 by Ben Gamari at 2022-02-04T16:14:47-05:00
    Drop dead code
    
    - - - - -
    b79206f1 by Ben Gamari at 2022-02-04T16:14:47-05:00
    Add comments
    
    - - - - -
    58d7faac by Ben Gamari at 2022-02-04T16:14:47-05:00
    cmm: Introduce cmmLoadBWord and cmmLoadGCWord
    
    - - - - -
    7217156c by Ben Gamari at 2022-02-04T16:14:47-05:00
    Introduce alignment in CmmLoad
    
    - - - - -
    99ea5f2c by Ben Gamari at 2022-02-04T16:14:47-05:00
    Introduce alignment to CmmStore
    
    - - - - -
    606b59a5 by Ben Gamari at 2022-02-04T16:14:47-05:00
    Fix array primop alignment
    
    - - - - -
    1cf9616a by Ben Gamari at 2022-02-04T16:14:47-05:00
    llvmGen: Handle unaligned loads/stores
    
    This allows us to produce valid code for indexWord8ArrayAs*# on
    platforms that lack unaligned memory access.
    
    - - - - -
    8c18feba by Ben Gamari at 2022-02-04T16:14:47-05:00
    primops: Fix documentation of setByteArray#
    
    Previously the documentation was subtly incorrect regarding the bounds
    of the operation. Fix this and add a test asserting that a zero-length
    operation is in fact a no-op.
    
    - - - - -
    88480e55 by nineonine at 2022-02-04T20:35:45-05:00
    Fix unsound behavior of unlifted datatypes in ghci (#20194)
    
    Previously, directly calling a function that pattern matches on an
    unlifted data type which has at least two constructors in GHCi resulted
     in a segfault.
    
    This happened due to unaccounted return frame info table pointer. The fix is
    to pop the above mentioned frame info table pointer when unlifted things are
    returned. See Note [Popping return frame for unlifted things]
    
    authors: bgamari, nineonine
    
    - - - - -
    a5c7068c by Simon Peyton Jones at 2022-02-04T20:36:20-05:00
    Add Outputable instance for Messages
    
    c.f. #20980
    
    - - - - -
    bf495f72 by Simon Peyton Jones at 2022-02-04T20:36:20-05:00
    Add a missing restoreLclEnv
    
    The commit
    
      commit 18df4013f6eaee0e1de8ebd533f7e96c4ee0ff04
      Date:   Sat Jan 22 01:12:30 2022 +0000
    
        Define and use restoreLclEnv
    
    omitted to change one setLclEnv to restoreLclEnv, namely
    the one in GHC.Tc.Errors.warnRedundantConstraints.
    
    This new commit fixes the omission.
    
    - - - - -
    6af8e71e by Simon Peyton Jones at 2022-02-04T20:36:20-05:00
    Improve errors for non-existent labels
    
    This patch fixes #17469, by improving matters when you use
    non-existent field names in a record construction:
       data T = MkT { x :: Int }
       f v = MkT { y = 3 }
    
    The check is now made in the renamer, in GHC.Rename.Env.lookupRecFieldOcc.
    
    That in turn led to a spurious error in T9975a, which is fixed by
    making GHC.Rename.Names.extendGlobalRdrEnvRn fail fast if it finds
    duplicate bindings.  See Note [Fail fast on duplicate definitions]
    in that module for more details.
    
    This patch was originated and worked on by Alex D (@nineonine)
    
    - - - - -
    299acff0 by nineonine at 2022-02-05T19:21:49-05:00
    Exit with failure when -e fails (fixes #18411 #9916 #17560)
    
    - - - - -
    549292eb by Matthew Pickering at 2022-02-05T19:22:25-05:00
    Make implication tidying agree with Note [Tidying multiple names at once]
    
    Note [Tidying multiple names at once] indicates that if multiple
    variables have the same name then we shouldn't prioritise one of them
    and instead rename them all to a1, a2, a3... etc
    
    This patch implements that change, some error message changes as
    expected.
    
    Closes #20932
    
    - - - - -
    2e9248b7 by Ben Gamari at 2022-02-06T01:43:56-05:00
    rts/m32: Accept any address within 4GB of program text
    
    Previously m32 would assume that the program image was located near the
    start of the address space and therefore assume that it wanted pages
    in the bottom 4GB of address space. Instead we now check whether they
    are within 4GB of whereever the program is loaded.
    
    This is necessary on Windows, which now tends to place the image in high
    memory. The eventual goal is to use m32 to allocate memory for linker
    sections on Windows.
    
    - - - - -
    86589b89 by GHC GitLab CI at 2022-02-06T01:43:56-05:00
    rts: Generalize mmapForLinkerMarkExecutable
    
    Renamed to mprotectForLinker and allowed setting of arbitrary protection
    modes.
    
    - - - - -
    88ef270a by GHC GitLab CI at 2022-02-06T01:43:56-05:00
    rts/m32: Add consistency-checking infrastructure
    
    This adds logic, enabled in the `-debug` RTS for checking the internal
    consistency of the m32 allocator. This area has always made me a bit
    nervous so this should help me sleep better at night in exchange for
    very little overhead.
    
    - - - - -
    2d6f0b17 by Ben Gamari at 2022-02-06T01:43:56-05:00
    rts/m32: Free large objects back to the free page pool
    
    Not entirely convinced that this is worth doing.
    
    - - - - -
    e96f50be by GHC GitLab CI at 2022-02-06T01:43:56-05:00
    rts/m32: Increase size of free page pool to 256 pages
    
    - - - - -
    fc083b48 by Ben Gamari at 2022-02-06T01:43:56-05:00
    rts: Dump memory map on memory mapping failures
    
    Fixes #20992.
    
    - - - - -
    633296bc by Ben Gamari at 2022-02-06T01:43:56-05:00
    Fix macro redefinition warnings for PRINTF
    
    * Move `PRINTF` macro from `Stats.h` to `Stats.c` as it's only needed in
      the latter.
    * Undefine `PRINTF` at the end of `Messages.h` to avoid leaking it.
    
    - - - - -
    37d435d2 by John Ericson at 2022-02-06T01:44:32-05:00
    Purge DynFlags from GHC.Stg
    
    Also derive some more instances. GHC doesn't need them, but downstream
    consumers may need to e.g. put stuff in maps.
    
    - - - - -
    886baa34 by Peter Trommler at 2022-02-06T10:58:18+01:00
    RTS: Fix cabal specification
    
    In 35bea01b xxhash.c was removed. Remove the extra-source-files
    stanza referring to it.
    
    - - - - -
    27581d77 by nineonine at 2022-02-06T20:50:44-05:00
    hadrian: remove redundant import
    - - - - -
    4ff19981 by John Ericson at 2022-02-07T11:04:43-05:00
    GHC.HsToCore.Coverage: No more HscEnv, less DynFlags
    
    Progress towards #20730
    
    - - - - -
    b09389a6 by John Ericson at 2022-02-07T11:04:43-05:00
    Create `CoverageConfig`
    
    As requested by @mpickering to collect the information we project from
    `HscEnv`
    
    - - - - -
    ff867c46 by Greg Steuck at 2022-02-07T11:05:24-05:00
    Avoid using removed utils/checkUniques in validate
    
    Asked the question:
    https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7460/diffs#4061f4d17546e239dd10d78c6b48668c2a288e02_1_0
    
    - - - - -
    a9355e84 by sheaf at 2022-02-08T05:27:25-05:00
    Allow HasField in quantified constraints
    
    We perform validity checking on user-written HasField instances,
    for example to disallow:
    
      data Foo a = Foo { fld :: Int }
      instance HasField "fld" (Foo a) Bool
    
    However, these checks were also being made on quantified constraints,
    e.g.
    
      data Bar where
        Bar :: (forall a. HasField s (Foo a) Int) => Proxy s -> Bar
    
    This patch simply skips validity checking for quantified constraints,
    in line with what we already do for equality constraints such as
    Coercible.
    
    Fixes #20989
    
    - - - - -
    6d77d3d8 by sheaf at 2022-02-08T05:28:05-05:00
    Relax TyEq:N: allow out-of-scope newtype DataCon
    
    The 'bad_newtype' assertion in GHC.Tc.Solver.Canonical.canEqCanLHSFinish
    failed to account for the possibility that the newtype constructor
    might not be in scope, in which case we don't provide any guarantees
    about canonicalising away a newtype on the RHS of a representational
    equality.
    
    Fixes #21010
    
    - - - - -
    a893d2f3 by Matthew Pickering at 2022-02-08T05:28:42-05:00
    Remove linter dependency on lint-submods
    
    - - - - -
    457a5b9c by Ben Gamari at 2022-02-08T05:28:42-05:00
    notes-util: initial commit
    
    - - - - -
    1a943859 by Ben Gamari at 2022-02-08T05:28:42-05:00
    gitlab-ci: Add lint-notes job
    
    - - - - -
    bc5cbce6 by Matthew Pickering at 2022-02-08T05:28:42-05:00
    Add notes linter to testsuite
    
    - - - - -
    38c6e301 by Matthew Pickering at 2022-02-08T05:28:42-05:00
    Fix some notes
    
    - - - - -
    c3aac0f8 by Matthew Pickering at 2022-02-08T05:28:42-05:00
    Add suggestion mode to notes-util
    
    - - - - -
    5dd29aea by Cale Gibbard at 2022-02-08T05:29:18-05:00
    `hscSimpleIface` drop fingerprint param and ret
    
    `hscSimpleIface` does not depend on or modify the `Maybe Fingerprint` it
    is given, only passes it through, so get rid of the extraneous passing.
    
    Perhaps the intent was that there would be an iface fingerprint check of
    some sort?  but this was never done. If/when we we want to do that, we
    can add it back then.
    
    - - - - -
    4bcbd731 by Cale Gibbard at 2022-02-08T05:29:54-05:00
    Document `hscIncrementalFrontend` and flip bool
    
    - - - - -
    b713db1e by John Ericson at 2022-02-08T05:30:29-05:00
    StgToCmm: Get rid of GHC.Driver.Session imports
    
    `DynFlags` is gone, but let's move a few trivial things around to get
    rid of its module too.
    
    - - - - -
    f115c382 by Gleb Popov at 2022-02-08T05:31:05-05:00
    Fix build on recent FreeBSD.
    
    Recent FreeBSD versions gained the sched_getaffinity function, which made two
    mutually exclusive #ifdef blocks to be enabled.
    
    - - - - -
    3320ab40 by Ben Gamari at 2022-02-08T10:42:04-05:00
    rts/MemoryMap: Use mach_-prefixed type names
    
    There appears to be some inconsistency in system-call type naming across
    Darwin toolchains. Specifically:
    
     * the `address` argument to `mach_vm_region` apparently wants to be a
       `mach_vm_address_t *`, not a `vm_address_t *`
    
     * the `vmsize` argument to `mach_vm_region` wants to be a
       `mach_vm_size_t`, not a `vm_size_t`
    
    - - - - -
    b33f0cfa by Richard Eisenberg at 2022-02-08T10:42:41-05:00
    Document that reifyRoles includes kind parameters
    
    Close #21056
    
    - - - - -
    bd493ed6 by PHO at 2022-02-08T10:43:19-05:00
    Don't try to build stage1 with -eventlog if stage0 doesn't provide it
    
    Like -threaded, stage0 isn't guaranteed to have an event-logging RTS.
    
    - - - - -
    03c2de0f by Matthew Pickering at 2022-02-09T03:56:22-05:00
    testsuite: Use absolute paths for config.libdir
    
    Fixes #21052
    
    - - - - -
    ef294525 by Matthew Pickering at 2022-02-09T03:56:22-05:00
    testsuite: Clean up old/redundant predicates
    
    - - - - -
    a39ed908 by Matthew Pickering at 2022-02-09T03:56:22-05:00
    testsuite: Add missing dependency on ghcconfig
    
    - - - - -
    a172be07 by PHO at 2022-02-09T03:56:59-05:00
    Implement System.Environment.getExecutablePath for NetBSD
    
    and also use it from GHC.BaseDir.getBaseDir
    
    - - - - -
    62fa126d by PHO at 2022-02-09T03:57:37-05:00
    Fix a portability issue in m4/find_llvm_prog.m4
    
    `test A == B' is a Bash extension, which doesn't work on platforms where
    /bin/sh is not Bash.
    
    - - - - -
    fd9981e3 by Ryan Scott at 2022-02-09T03:58:13-05:00
    Look through untyped TH splices in tcInferAppHead_maybe
    
    Previously, surrounding a head expression with a TH splice would defeat
    `tcInferAppHead_maybe`, preventing some expressions from typechecking that
    used to typecheck in previous GHC versions (see #21038 for examples). This is
    simple enough to fix: just look through `HsSpliceE`s in `tcInferAppHead_maybe`.
    I've added some additional prose to `Note [Application chains and heads]` in
    `GHC.Tc.Gen.App` to accompany this change.
    
    Fixes #21038.
    
    - - - - -
    00975981 by sheaf at 2022-02-09T03:58:53-05:00
    Add test for #21037
    
      This program was rejected by GHC 9.2, but is accepted
      on newer versions of GHC. This patch adds a regression test.
    
      Closes #21037
    
    - - - - -
    fad0b2b0 by Ben Gamari at 2022-02-09T08:29:46-05:00
    Rename -merge-objs flag to --merge-objs
    
    For consistency with --make and friends.
    
    - - - - -
    1dbe5b2a by Matthew Pickering at 2022-02-09T08:30:22-05:00
    driver: Filter out our own boot module in hptSomeThingsBelow
    
    hptSomeThingsBelow would return a list of modules which contain the
    .hs-boot file for a particular module. This caused some problems because
    we would try and find the module in the HPT (but it's not there when
    we're compiling the module itself).
    
    Fixes #21058
    
    - - - - -
    2b1cced1 by Sylvain Henry at 2022-02-09T20:42:23-05:00
    NCG: minor code factorization
    
    - - - - -
    e01ffec2 by Sylvain Henry at 2022-02-09T20:42:23-05:00
    ByteCode: avoid out-of-bound read
    
    Cf https://gitlab.haskell.org/ghc/ghc/-/issues/18431#note_287139
    
    - - - - -
    53c26e79 by Ziyang Liu at 2022-02-09T20:43:02-05:00
    Include ru_name in toHsRule message
    
    See #18147
    
    - - - - -
    3df06922 by Ben Gamari at 2022-02-09T20:43:39-05:00
    rts: Rename MemoryMap.[ch] -> ReportMemoryMap.[ch]
    
    - - - - -
    e219ac82 by Ben Gamari at 2022-02-09T20:43:39-05:00
    rts: Move mmapForLinker and friends to linker/MMap.c
    
    They are not particularly related to linking.
    
    - - - - -
    30e205ca by Ben Gamari at 2022-02-09T20:43:39-05:00
    rts/linker: Drop dead IA64 code
    
    - - - - -
    4d3a306d by Ben Gamari at 2022-02-09T20:43:39-05:00
    rts/linker/MMap: Use MemoryAccess in mmapForLinker
    
    - - - - -
    1db4f1fe by Ben Gamari at 2022-02-09T20:43:39-05:00
    linker: Don't use MAP_FIXED
    
    As noted in #21057, we really shouldn't be using MAP_FIXED. I would much
    rather have the process crash with a "failed to map" error than randomly
    overwrite existing mappings.
    
    Closes #21057.
    
    - - - - -
    1eeae25c by Ben Gamari at 2022-02-09T20:43:39-05:00
    rts/mmap: Refactor mmapForLinker
    
    Here we try to separate the policy decisions of where to place mappings
    from the mechanism of creating the mappings. This makes things
    significantly easier to follow.
    
    - - - - -
    ac2d18a7 by sheaf at 2022-02-09T20:44:18-05:00
    Add some perf tests for coercions
    
      This patch adds some performance tests for programs that create
      large coercions. This is useful because the existing test coverage
      is not very representative of real-world situations. In particular,
      this adds a test involving an extensible records library, a common
      pain-point for users.
    
    - - - - -
    48f25715 by Andreas Klebinger at 2022-02-10T04:35:35-05:00
    Add late cost centre support
    
    This allows cost centres to be inserted after the core optimization
    pipeline has run.
    
    - - - - -
    0ff70427 by Andreas Klebinger at 2022-02-10T04:36:11-05:00
    Docs:Mention that safe calls don't keep their arguments alive.
    
    - - - - -
    1d3ed168 by Ben Gamari at 2022-02-10T04:36:46-05:00
    PEi386: Drop Windows Vista fallback in addLibrarySearchPath
    
    We no longer support Windows Vista.
    
    - - - - -
    2a6f2681 by Ben Gamari at 2022-02-10T04:36:46-05:00
    linker/PEi386: Make addLibrarySearchPath long-path aware
    
    Previously `addLibrarySearchPath` failed to normalise the added path to
    UNC form before passing it to `AddDllDirectory`. Consequently, the call
    was subject to the MAX_PATH restriction, leading to the failure of
    `test-defaulting-plugin-fail`, among others. Happily, this also nicely
    simplifies the implementation.
    
    Closes #21059.
    
    - - - - -
    2a47ee9c by Daniel Gröber at 2022-02-10T19:18:58-05:00
    ghc-boot: Simplify writePackageDb permissions handling
    
    Commit ef8a3fbf1 ("ghc-boot: Fix metadata handling of writeFileAtomic")
    introduced a somewhat over-engineered fix for #14017 by trying to preserve
    the current permissions if the target file already exists.
    
    The problem in the issue is simply that the package db cache file should be
    world readable but isn't if umask is too restrictive. In fact the previous
    fix only handles part of this problem. If the file isn't already there in a
    readable configuration it wont make it so which isn't really ideal either.
    
    Rather than all that we now simply always force all the read access bits to
    allow access while leaving the owner at the system default as it's just not
    our business to mess with it.
    
    - - - - -
    a1d97968 by Ben Gamari at 2022-02-10T19:19:34-05:00
    Bump Cabal submodule
    
    Adapts GHC to the factoring-out of `Cabal-syntax`.
    
    Fixes #20991.
    
    Metric Decrease:
        haddock.Cabal
    
    - - - - -
    89cf8caa by Morrow at 2022-02-10T19:20:13-05:00
    Add metadata to integer-gmp.cabal
    
    - - - - -
    c995b7e7 by Matthew Pickering at 2022-02-10T19:20:48-05:00
    eventlog: Fix event type of EVENT_IPE
    
    This leads to corrupted eventlogs because the size of EVENT_IPE is
    completely wrong.
    
    Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de
    
    - - - - -
    59ba8fb3 by Matthew Pickering at 2022-02-10T19:20:48-05:00
    eventlog: Fix event type of MEM_RETURN
    
    This leads to corrupted eventlogs because the size of EVENT_MEM_RETURN is
    completely wrong.
    
    Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de
    
    - - - - -
    19413d09 by Matthew Pickering at 2022-02-10T19:20:48-05:00
    eventlog: Delete misleading comment in gen_event_types.py
    
    Not all events start with CapNo and there's not logic I could see which
    adds this to the length.
    
    - - - - -
    e06f49c0 by Matthew Pickering at 2022-02-10T19:20:48-05:00
    eventlog: Fix size of TICKY_COUNTER_BEGIN_SAMPLE
    
    - - - - -
    2f99255b by Matthew Pickering at 2022-02-10T19:21:24-05:00
    Fix copy-pasto in prof-late-ccs docs
    
    - - - - -
    19deb002 by Matthew Pickering at 2022-02-10T19:21:59-05:00
    Refine tcSemigroupWarnings to work in ghc-prim
    
    ghc-prim doesn't depend on base so can't have any Monoid or Semigroup
    instances. However, attempting to load these definitions ran into issues
    when the interface for `GHC.Base` did exist as that would try and load
    the interface for `GHC.Types` (which is the module we are trying to
    compile and has no interface).
    
    The fix is to just not do this check when we are compiling a module in
    ghc-prim.
    
    Fixes #21069
    
    - - - - -
    34dec6b7 by sheaf at 2022-02-11T17:55:34-05:00
    Decrease the size of the LargeRecord test
    
      This test was taking too long to run, so this patch makes it smaller.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    9cab90d9 by Matthew Pickering at 2022-02-11T22:27:19-05:00
    Make sure all platforms have a release job
    
    The release bindists are currently a mixture of validate and release
    builds. This is bad because the validate builds don't have profiling
    libraries. The fix is to make sure there is a release job for each
    platform we want to produce a release for.t
    
    Fixes #21066
    
    - - - - -
    4bce3575 by Matthew Pickering at 2022-02-11T22:27:54-05:00
    testsuite: Make sure all tests trigger ghc rebuild
    
    I made a mistake when implementing #21029 which meant that certain tests
    didn't trigger a GHC recompilation. By adding the `test:ghc` target to
    the default settings all tests will now depend on this target unless
    explicitly opting out via the no_deps modifier.
    
    - - - - -
    90a26f8b by Sylvain Henry at 2022-02-11T22:28:34-05:00
    Fix documentation about Word64Rep/Int64Rep (#16964)
    
    - - - - -
    0e93023e by Andreas Klebinger at 2022-02-12T13:59:41+00:00
    Tag inference work.
    
    This does three major things:
    * Enforce the invariant that all strict fields must contain tagged
    pointers.
    * Try to predict the tag on bindings in order to omit tag checks.
    * Allows functions to pass arguments unlifted (call-by-value).
    
    The former is "simply" achieved by wrapping any constructor allocations with
    a case which will evaluate the respective strict bindings.
    
    The prediction is done by a new data flow analysis based on the STG
    representation of a program. This also helps us to avoid generating
    redudant cases for the above invariant.
    
    StrictWorkers are created by W/W directly and SpecConstr indirectly.
    See the Note [Strict Worker Ids]
    
    Other minor changes:
    
    * Add StgUtil module containing a few functions needed by, but
      not specific to the tag analysis.
    
    -------------------------
    Metric Decrease:
    	T12545
    	T18698b
    	T18140
    	T18923
            LargeRecord
    Metric Increase:
            LargeRecord
    	ManyAlternatives
    	ManyConstructors
    	T10421
    	T12425
    	T12707
    	T13035
    	T13056
    	T13253
    	T13253-spj
    	T13379
    	T15164
    	T18282
    	T18304
    	T18698a
    	T1969
    	T20049
    	T3294
    	T4801
    	T5321FD
    	T5321Fun
    	T783
    	T9233
    	T9675
    	T9961
    	T19695
    	WWRec
    -------------------------
    
    - - - - -
    744f8a11 by Greg Steuck at 2022-02-12T17:13:55-05:00
    Only check the exit code in derefnull & divbyzero tests on OpenBSD
    
    - - - - -
    eeead9fc by Ben Gamari at 2022-02-13T03:26:14-05:00
    rts/Adjustor: Ensure that allocateExecPage succeeded
    
    Previously we failed to handle the case that `allocateExecPage` failed.
    
    - - - - -
    afdfaff0 by Ben Gamari at 2022-02-13T03:26:14-05:00
    rts: Drop DEC Alpha adjustor implementation
    
    The last Alpha chip was produced in 2004.
    
    - - - - -
    191dfd2d by Ben Gamari at 2022-02-13T03:26:14-05:00
    rts/adjustor: Split Windows path out of NativeAmd64
    
    - - - - -
    be591e27 by Ben Gamari at 2022-02-13T03:26:14-05:00
    rts: Initial commit of AdjustorPool
    
    - - - - -
    d6d48b16 by Ben Gamari at 2022-02-13T03:26:14-05:00
    Introduce initAdjustors
    
    - - - - -
    eab37902 by Ben Gamari at 2022-02-13T03:26:14-05:00
    adjustors/NativeAmd64: Use AdjustorPool
    
    - - - - -
    974e73af by Ben Gamari at 2022-02-13T03:26:14-05:00
    adjustors/NativeAmd64Mingw: Use AdjustorPool
    
    - - - - -
    95fab83f by Ben Gamari at 2022-02-13T03:26:14-05:00
    configure: Fix result reporting of adjustors method check
    
    - - - - -
    ef5cf55d by nikshalark at 2022-02-13T03:26:16-05:00
    (#21044) Documented arithmetic functions in base.
    
    Didn't get it right the ninth time. Now everything's formatted correctly.
    
    - - - - -
    acb482cc by Takenobu Tani at 2022-02-16T05:27:17-05:00
    Relax load_load_barrier for aarch64
    
    This patch relaxes the instruction for load_load_barrier().
    Current load_load_barrier() implements full-barrier with `dmb sy`.
    It's too strong to order load-load instructions.
    We can relax it by using `dmb ld`.
    
    If current load_load_barrier() is used for full-barriers
    (load/store - load/store barrier), this patch is not suitable.
    
    See also linux-kernel's smp_rmb() implementation:
      https://github.com/torvalds/linux/blob/v5.14/arch/arm64/include/asm/barrier.h#L90
    
    Hopefully, it's better to use `dmb ishld` rather than `dmb ld`
    to improve performance. However, I can't validate effects on
    a real many-core Arm machine.
    
    - - - - -
    84eaa26f by Oleg Grenrus at 2022-02-16T05:27:56-05:00
    Add test for #20562
    
    - - - - -
    2c28620d by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00
    rts: remove struct StgRetry, it is never used
    
    - - - - -
    74bf9bb5 by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00
    rts: document some closure types
    
    - - - - -
    316312ec by nineonine at 2022-02-16T05:29:08-05:00
    ghci: fix -ddump-stg-cg (#21052)
    
    The pre-codegen Stg AST dump was not available in ghci because it
    was performed in 'doCodeGen'. This was now moved to 'coreToStg' area.
    
    - - - - -
    a6411d74 by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00
    docs: mention -fprof-late-ccs in the release notes
    
    And note which compiler version it was added in.
    
    - - - - -
    4127e86d by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00
    docs: fix release notes formatting
    
    - - - - -
    4e6c8019 by Matthew Pickering at 2022-02-17T05:25:28-05:00
    Always define __GLASGOW_HASKELL_PATCHLEVEL1/2__ macros
    
    As #21076 reports if you are using `-Wcpp-undef` then you get warnings
    when using the `MIN_VERSION_GLASGOW_HASKELL` macro because
    __GLASGOW_HASKELL_PATCHLEVEL2__ is very rarely explicitliy set (as
    version numbers are not 4 components long).
    
    This macro was introduced in 3549c952b535803270872adaf87262f2df0295a4
    and it seems the bug has existed ever since.
    
    Fixes #21076
    
    - - - - -
    67dd5724 by Ben Gamari at 2022-02-17T05:26:03-05:00
    rts/AdjustorPool: Silence unused function warning
    
    bitmap_get is only used in the DEBUG RTS configuration.
    
    Fixes #21079.
    
    - - - - -
    4b04f7e1 by Zubin Duggal at 2022-02-20T13:56:15-05:00
    Track object file dependencies for TH accurately (#20604)
    
    `hscCompileCoreExprHook` is changed to return a list of `Module`s required
    by a splice. These modules are accumulated in the TcGblEnv (tcg_th_needed_mods).
    Dependencies on the object files of these modules are recording in the
    interface.
    
    The data structures in `LoaderState` are replaced with more efficient versions
    to keep track of all the information required. The
    MultiLayerModulesTH_Make allocations increase slightly but runtime is
    faster.
    
    Fixes #20604
    
    -------------------------
    Metric Increase:
        MultiLayerModulesTH_Make
    -------------------------
    
    - - - - -
    92ab3ff2 by sheaf at 2022-02-20T13:56:55-05:00
    Use diagnostics for "missing signature" errors
    
      This patch makes the "missing signature" errors from
      "GHC.Rename.Names" use the diagnostic infrastructure.
      This encompasses missing type signatures for top-level bindings
      and pattern synonyms, as well as missing kind signatures for
      type constructors.
    
      This patch also renames TcReportMsg to TcSolverReportMsg,
      and adds a few convenience functions to compute whether such a
      TcSolverReportMsg is an expected/actual message.
    
    - - - - -
    845284a5 by sheaf at 2022-02-20T13:57:34-05:00
    Generically: remove redundant Semigroup constraint
    
      This patch removes a redundant Semigroup constraint on the Monoid
      instance for Generically. This constraint can cause trouble when
      one wants to derive a Monoid instance via Generically through a type
      that doesn't itself have a Semigroup instance, for example:
    
        data Point2D a = Point2D !a !a
    
        newtype Vector2D a = Vector2D { tip :: Point2D a }
          deriving ( Semigroup, Monoid )
            via Generically ( Point2D ( Sum a ) )
    
      In this case, we should not require there to be an instance
    
        Semigroup ( Point2D ( Sum a ) )
    
      as all we need is an instance for the generic representation of
      Point2D ( Sum a ), i.e. Semigroup ( Rep ( Point2D ( Sum a) ) () ).
    
    - - - - -
    6b468f7f by Ben Gamari at 2022-02-20T13:58:10-05:00
    Bump time submodule to 1.12.1
    
    - - - - -
    2f0ceecc by Zubin Duggal at 2022-02-20T19:06:19+00:00
    hadrian: detect if 'main' is not a haskell file and add it to appropriate list of sources
    
    - - - - -
    7ce1b694 by Zubin Duggal at 2022-02-21T11:18:58+00:00
    Reinstallable GHC
    
    This patch allows ghc and its dependencies to be built using a normal
    invocation of cabal-install. Each componenent which relied on generated
    files or additional configuration now has a Setup.hs file.
    
    There are also various fixes to the cabal files to satisfy
    cabal-install.
    
    There is a new hadrian command which will build a stage2 compiler and
    then a stage3 compiler by using cabal.
    
    ```
    ./hadrian/build build-cabal
    ```
    
    There is also a new CI job which tests running this command.
    
    For the 9.4 release we will upload all the dependent executables to
    hackage and then end users will be free to build GHC and GHC executables
    via cabal.
    
    There are still some unresolved questions about how to ensure soundness
    when loading plugins into a reinstalled GHC (#20742) which will be
    tighted up in due course.
    
    Fixes #19896
    
    - - - - -
    78fbc3a3 by Matthew Pickering at 2022-02-21T15:14:28-05:00
    hadrian: Enable late-ccs when building profiled_ghc
    
    - - - - -
    2b890c89 by Matthew Pickering at 2022-02-22T15:59:33-05:00
    testsuite: Don't print names of all fragile tests on all runs
    
    This information about fragile tests is pretty useless but annoying on
    CI where you have to scroll up a long way to see the actual issues.
    
    - - - - -
    0b36801f by sheaf at 2022-02-22T16:00:14-05:00
    Forbid standalone instances for built-in classes
    
      `check_special_inst_head` includes logic that disallows hand-written
      instances for built-in classes such as Typeable, KnownNat
      and KnownSymbol.
      However, it also allowed standalone deriving declarations. This was
      because we do want to allow standalone deriving instances with
      Typeable as they are harmless, but we certainly don't want to allow
      instances for e.g. KnownNat.
    
      This patch ensures that we don't allow derived instances for
      KnownNat, KnownSymbol (and also KnownChar, which was previously
      omitted entirely).
    
      Fixes #21087
    
    - - - - -
    ace66dec by Krzysztof Gogolewski at 2022-02-22T16:30:59-05:00
    Remove -Wunticked-promoted-constructors from -Wall
    
    Update manual; explain ticks as optional disambiguation
    rather than the preferred default.
    
    This is a part of #20531.
    
    - - - - -
    558c7d55 by Hugo at 2022-02-22T16:31:01-05:00
    docs: fix error in annotation guide code snippet
    
    - - - - -
    a599abba by Richard Eisenberg at 2022-02-23T08:16:07-05:00
    Kill derived constraints
    
    Co-authored by: Sam Derbyshire
    
    Previously, GHC had three flavours of constraint:
    Wanted, Given, and Derived. This removes Derived constraints.
    
    Though serving a number of purposes, the most important role
    of Derived constraints was to enable better error messages.
    This job has been taken over by the new RewriterSets, as explained
    in Note [Wanteds rewrite wanteds] in GHC.Tc.Types.Constraint.
    
    Other knock-on effects:
     - Various new Notes as I learned about under-described bits of GHC
    
     - A reshuffling around the AST for implicit-parameter bindings,
       with better integration with TTG.
    
     - Various improvements around fundeps. These were caused by the
       fact that, previously, fundep constraints were all Derived,
       and Derived constraints would get dropped. Thus, an unsolved
       Derived didn't stop compilation. Without Derived, this is no
       longer possible, and so we have to be considerably more careful
       around fundeps.
    
     - A nice little refactoring in GHC.Tc.Errors to center the work
       on a new datatype called ErrorItem. Constraints are converted
       into ErrorItems at the start of processing, and this allows for
       a little preprocessing before the main classification.
    
     - This commit also cleans up the behavior in generalisation around
       functional dependencies. Now, if a variable is determined by
       functional dependencies, it will not be quantified. This change
       is user facing, but it should trim down GHC's strange behavior
       around fundeps.
    
     - Previously, reportWanteds did quite a bit of work, even on an empty
       WantedConstraints. This commit adds a fast path.
    
     - Now, GHC will unconditionally re-simplify constraints during
       quantification. See Note [Unconditionally resimplify constraints when
       quantifying], in GHC.Tc.Solver.
    
    Close #18398.
    Close #18406.
    Solve the fundep-related non-confluence in #18851.
    Close #19131.
    Close #19137.
    Close #20922.
    Close #20668.
    Close #19665.
    
    -------------------------
    Metric Decrease:
        LargeRecord
        T9872b
        T9872b_defer
        T9872d
        TcPlugin_RewritePerf
    -------------------------
    
    - - - - -
    2ed22ba1 by Matthew Pickering at 2022-02-23T08:16:43-05:00
    Introduce predicate for when to enable source notes (needSourceNotes)
    
    There were situations where we were using debugLevel == 0 as a proxy for
    whether to retain source notes but -finfo-table-map also enables and
    needs source notes so we should act consistently in both cases.
    
    Ticket #20847
    
    - - - - -
    37deb893 by Matthew Pickering at 2022-02-23T08:16:43-05:00
    Use SrcSpan from the binder as initial source estimate
    
    There are some situations where we end up with no source notes in useful
    positions in an expression. In this case we currently fail to provide
    any source information about where an expression came from.
    
    This patch improves the initial estimate by using the position from the
    top-binder as the guess for the location of the whole inner expression.
    It provides quite a course estimate but it's better than nothing.
    
    Ticket #20847
    
    - - - - -
    59b7f764 by Cheng Shao at 2022-02-23T08:17:24-05:00
    Don't emit foreign exports initialiser code for empty CAF list
    
    - - - - -
    c7f32f76 by John Ericson at 2022-02-23T13:58:36-05:00
    Prepare rechecking logic for new type in a few ways
    
    Combine `MustCompile and `NeedsCompile` into a single case.
    `CompileReason` is put inside to destinguish the two. This makes a
    number of things easier.
    
    `Semigroup RecompileRequired` is no longer used, to make sure we skip
    doing work where possible. `recompThen` is very similar, but helps
    remember.
    
    `checkList` is rewritten with `recompThen`.
    
    - - - - -
    e60d8df8 by John Ericson at 2022-02-23T13:58:36-05:00
    Introduce `MaybeValidated` type to remove invalid states
    
    The old return type `(RecompRequired, Maybe _)`, was confusing
    because it was inhabited by values like `(UpToDate, Nothing)` that made
    no sense.
    
    The new type ensures:
    
     - you must provide a value if it is up to date.
    
     - you must provide a reason if you don't provide a value.
    
    it is used as the return value of:
    
     - `checkOldIface`
     - `checkByteCode`
     - `checkObjects`
    
    - - - - -
    f07b13e3 by Sylvain Henry at 2022-02-23T13:59:23-05:00
    NCG: refactor X86 codegen
    
    Preliminary work done to make working on #5444 easier.
    
    Mostly make make control-flow easier to follow:
    
    * renamed genCCall into genForeignCall
    
    * split genForeignCall into the part dispatching on PrimTarget (genPrim) and
      the one really generating code for a C call (cf ForeignTarget and genCCall)
    
    * made genPrim/genSimplePrim only dispatch on MachOp: each MachOp now
      has its own code generation function.
    
    * out-of-line primops are not handled in a partial `outOfLineCmmOp`
      anymore but in the code generation functions directly. Helper
      functions have been introduced (e.g. genLibCCall) for code sharing.
    
    * the latter two bullets make code generated for primops that are only
      sometimes out-of-line (e.g. Pdep or Memcpy) and the logic to select
      between inline/out-of-line much more localized
    
    * avoided passing is32bit as an argument as we can easily get it from NatM
      state when we really need it
    
    * changed genCCall type to avoid it being partial (it can't handle
      PrimTarget)
    
    * globally removed 12 calls to `panic` thanks to better control flow and
      types ("parse, don't validate" ftw!).
    
    - - - - -
    6fa7591e by Sylvain Henry at 2022-02-23T13:59:23-05:00
    NCG: refactor the way registers are handled
    
    * add getLocalRegReg to avoid allocating a CmmLocal just to call
      getRegisterReg
    
    * 64-bit registers: in the general case we must always use the virtual
      higher part of the register, so we might as well always return it with
      the lower part. The only exception is to implement 64-bit to 32-bit
      conversions. We now have to explicitly discard the higher part when
      matching on Reg64/RegCode64 datatypes instead of explicitly fetching
      the higher part from the lower part: much safer default.
    
    - - - - -
    bc8de322 by Sylvain Henry at 2022-02-23T13:59:23-05:00
    NCG: inline some 64-bit primops on x86/32-bit (#5444)
    
    Several 64-bit operation were implemented with FFI calls on 32-bit
    architectures but we can easily implement them with inline assembly
    code.
    
    Also remove unused hs_int64ToWord64 and hs_word64ToInt64 C functions.
    
    - - - - -
    7b7c6b95 by Matthew Pickering at 2022-02-23T14:00:00-05:00
    Simplify/correct implementation of getModuleInfo
    
    - - - - -
    6215b04c by Matthew Pickering at 2022-02-23T14:00:00-05:00
    Remove mg_boot field from ModuleGraph
    
    It was unused in the compiler so I have removed it to streamline
    ModuleGraph.
    
    - - - - -
    818ff2ef by Matthew Pickering at 2022-02-23T14:00:01-05:00
    driver: Remove needsTemplateHaskellOrQQ from ModuleGraph
    
    The idea of the needsTemplateHaskellOrQQ query is to check if any of the
    modules in a module graph need Template Haskell then enable -dynamic-too
    if necessary. This is quite imprecise though as it will enable
    -dynamic-too for all modules in the module graph even if only one module
    uses template haskell, with multiple home units, this is obviously even
    worse.
    
    With -fno-code we already have similar logic to enable code generation
    just for the modules which are dependeded on my TemplateHaskell modules
    so we use the same code path to decide whether to enable -dynamic-too
    rather than using this big hammer.
    
    This is part of the larger overall goal of moving as much statically
    known configuration into the downsweep as possible in order to have
    fully decided the build plan and all the options before starting to
    build anything.
    
    I also included a fix to #21095, a long standing bug with with the logic
    which is supposed to enable the external interpreter if we don't have
    the internal interpreter.
    
    Fixes #20696 #21095
    
    - - - - -
    b6670af6 by Matthew Pickering at 2022-02-23T14:00:40-05:00
    testsuite: Normalise output of ghci011 and T7627
    
    The outputs of these tests vary on the order interface files are loaded
    so we normalise the output to correct for these inconsequential
    differences.
    
    Fixes #21121
    
    - - - - -
    9ed3bc6e by Peter Trommler at 2022-02-23T14:01:16-05:00
    testsuite: Fix ipeMap test
    
    Pointers to closures must be untagged before use.
    Produce closures of different types so we get different info tables.
    
    Fixes #21112
    
    - - - - -
    7d426148 by Ziyang Liu at 2022-02-24T04:53:34-05:00
    Allow `return` in more cases in ApplicativeDo
    
    The doc says that the last statement of an ado-block can be one of
    `return E`, `return $ E`, `pure E` and `pure $ E`. But `return`
    is not accepted in a few cases such as:
    
    ```haskell
    -- The ado-block only has one statement
    x :: F ()
    x = do
      return ()
    
    -- The ado-block only has let-statements besides the `return`
    y :: F ()
    y = do
      let a = True
      return ()
    ```
    
    These currently require `Monad` instances. This MR fixes it.
    Normally `return` is accepted as the last statement because it is
    stripped in constructing an `ApplicativeStmt`, but this cannot be
    done in the above cases, so instead we replace `return` by `pure`.
    
    A similar but different issue (when the ado-block contains `BindStmt`
    or `BodyStmt`, the second last statement cannot be `LetStmt`, even if
    the last statement uses `pure`) is fixed in !6786.
    
    - - - - -
    a5ea7867 by John Ericson at 2022-02-24T20:23:49-05:00
    Clarify laws of TestEquality
    
    It is unclear what `TestEquality` is for. There are 3 possible choices.
    
    Assuming
    
    ```haskell
    data Tag a where
        TagInt1 :: Tag Int
        TagInt2 :: Tag Int
    ```
    
    Weakest -- type param equality semi-decidable
    ---------------------------------------------
    
    `Just Refl` merely means the type params are equal, the values being compared might not be.
    `Nothing` means the type params may or may not be not equal.
    
    ```haskell
    instance TestEquality Tag where
        testEquality TagInt1 TagInt1 = Nothing -- oopsie is allowed
        testEquality TagInt1 TagInt2 = Just Refl
        testEquality TagInt2 TagInt1 = Just Refl
        testEquality TagInt2 TagInt2 = Just Refl
    ```
    
    This option is better demonstrated with a different type:
    ```haskell
    data Tag' a where
        TagInt1 :: Tag Int
        TagInt2 :: Tag a
    ```
    ```haskell
    instance TestEquality Tag' where
        testEquality TagInt1 TagInt1 = Just Refl
        testEquality TagInt1 TagInt2 = Nothing -- can't be sure
        testEquality TagInt2 TagInt1 = Nothing -- can't be sure
        testEquality TagInt2 TagInt2 = Nothing -- can't be sure
    ```
    
    Weaker -- type param equality decidable
    ---------------------------------------
    
    `Just Refl` merely means the type params are equal, the values being compared might not be.
    `Nothing` means the type params are not equal.
    
    ```haskell
    instance TestEquality Tag where
        testEquality TagInt1 TagInt1 = Just Refl
        testEquality TagInt1 TagInt2 = Just Refl
        testEquality TagInt2 TagInt1 = Just Refl
        testEquality TagInt2 TagInt2 = Just Refl
    ```
    
    Strong -- Like `Eq`
    -------------------
    
    `Just Refl` means the type params are equal, and the values are equal according to `Eq`.
    
    ```haskell
    instance TestEquality Tag where
        testEquality TagInt1 TagInt1 = Just Refl
        testEquality TagInt2 TagInt2 = Just Refl
        testEquality _ _ = Nothing
    ```
    
    Strongest -- unique value concrete type
    ---------------------------------------
    
    `Just Refl` means the type params are equal, and the values are equal, and the class assume if the type params are equal the values must also be equal. In other words, the type is a singleton type when the type parameter is a closed term.
    
    ```haskell
    -- instance TestEquality -- invalid instance because two variants for `Int`
    ```
    ------
    
    The discussion in
    https://github.com/haskell/core-libraries-committee/issues/21 has
    decided on the "Weaker" option (confusingly formerly called the
    "Weakest" option). So that is what is implemented.
    
    - - - - -
    06c18990 by Zubin Duggal at 2022-02-24T20:24:25-05:00
    TH: fix pretty printing of GADTs with multiple constuctors (#20842)
    
    - - - - -
    6555b68c by Matthew Pickering at 2022-02-24T20:25:06-05:00
    Move linters into the tree
    
    This MR moves the GHC linters into the tree, so that they can be run directly using Hadrian.
    
    * Query all files tracked by Git instead of using changed files, so that we can run the exact same linting step locally and in a merge request.
    * Only check that the changelogs don't contain TBA when RELEASE=YES.
    * Add hadrian/lint script, which runs all the linting steps.
    * Ensure the hlint job exits with a failure if hlint is not installed (otherwise we were ignoring the failure). Given that hlint doesn't seem to be available in CI at the moment, I've temporarily allowed failure in the hlint job.
    * Run all linting tests in CI using hadrian.
    
    - - - - -
    b99646ed by Matthew Pickering at 2022-02-24T20:25:06-05:00
    Add rule for generating HsBaseConfig.h
    
    If you are running the `lint:{base/compiler}` command locally then this
    improves the responsiveness because we don't re-run configure everytime
    if the header file already exists.
    
    - - - - -
    d0deaaf4 by Matthew Pickering at 2022-02-24T20:25:06-05:00
    Suggestions due to hlint
    
    It turns out this job hasn't been running for quite a while (perhaps
    ever) so there are quite a few failures when running the linter locally.
    
    - - - - -
    70bafefb by nineonine at 2022-02-24T20:25:42-05:00
    ghci: show helpful error message when loading module with SIMD vector operations (#20214)
    
    Previously, when trying to load module with SIMD vector operations, ghci would panic
    in 'GHC.StgToByteCode.findPushSeq'. Now, a more helpful message is displayed.
    
    - - - - -
    8ed3d5fd by Matthew Pickering at 2022-02-25T10:24:12+00:00
    Remove test-bootstrap and cabal-reinstall jobs from fast-ci [skip ci]
    
    - - - - -
    8387dfbe by Mario Blažević at 2022-02-25T21:09:41-05:00
    template-haskell: Fix two prettyprinter issues
    
    Fix two issues regarding printing numeric literals.
    
    Fixing #20454.
    
    - - - - -
    4ad8ce0b by sheaf at 2022-02-25T21:10:22-05:00
    GHCi: don't normalise partially instantiated types
    
      This patch skips performing type normalisation when we haven't
      fully instantiated the type. That is, in tcRnExpr
      (used only for :type in GHCi), skip normalisation if
      the result type responds True to isSigmaTy.
    
      Fixes #20974
    
    - - - - -
    f35aca4d by Ben Gamari at 2022-02-25T21:10:57-05:00
    rts/adjustor: Always place adjustor templates in data section
    
    @nrnrnr points out that on his machine ld.lld rejects text relocations.
    Generalize the Darwin text-relocation avoidance logic to account for
    this.
    
    - - - - -
    cddb040a by Andreas Klebinger at 2022-02-25T21:11:33-05:00
    Ticky: Gate tag-inference dummy ticky-counters behind a flag.
    
    Tag inference included a way to collect stats about avoided tag-checks.
    This was dony by emitting "dummy" ticky entries with counts corresponding
    to predicted/unpredicated tag checks.
    
    This behaviour for ticky is now gated behind -fticky-tag-checks.
    
    I also documented ticky-LNE in the process.
    
    - - - - -
    948bf2d0 by Ben Gamari at 2022-02-25T21:12:09-05:00
    Fix comment reference to T4818
    
    - - - - -
    9c3edeb8 by Ben Gamari at 2022-02-25T21:12:09-05:00
    simplCore: Correctly extend in-scope set in rule matching
    
    Note [Matching lets] in GHC.Core.Rules claims the following:
    
    > We use GHC.Core.Subst.substBind to freshen the binding, using an
    > in-scope set that is the original in-scope variables plus the
    > rs_bndrs (currently floated let-bindings).
    
    However, previously the implementation didn't actually do extend the
    in-scope set with rs_bndrs. This appears to be a regression which was
    introduced by 4ff4d434e9a90623afce00b43e2a5a1ccbdb4c05.
    
    Moreover, the originally reasoning was subtly wrong: we must rather use
    the in-scope set from rv_lcl, extended with rs_bndrs, not that of
    `rv_fltR`
    
    Fixes #21122.
    
    - - - - -
    7f9f49c3 by sheaf at 2022-02-25T21:12:47-05:00
    Derive some stock instances for OverridingBool
    
      This patch adds some derived instances to
      `GHC.Data.Bool.OverridingBool`. It also changes the order of the
      constructors, so that the derived `Ord` instance matches the
      behaviour for `Maybe Bool`.
    
      Fixes #20326
    
    - - - - -
    140438a8 by nineonine at 2022-02-25T21:13:23-05:00
    Add test for #19271
    
    - - - - -
    ac9f4606 by sheaf at 2022-02-25T21:14:04-05:00
    Allow qualified names in COMPLETE pragmas
    
      The parser didn't allow qualified constructor names to appear
      in COMPLETE pragmas. This patch fixes that.
    
      Fixes #20551
    
    - - - - -
    677c6c91 by Sylvain Henry at 2022-02-25T21:14:44-05:00
    Testsuite: remove arch conditional in T8832
    
    Taken from !3658
    
    - - - - -
    ad04953b by Sylvain Henry at 2022-02-25T21:15:23-05:00
    Allow hscGenHardCode to not return CgInfos
    
    This is a minor change in preparation for the JS backend: CgInfos aren't
    mandatory and the JS backend won't return them.
    
    - - - - -
    929c280f by Sylvain Henry at 2022-02-25T21:15:24-05:00
    Derive Enum instances for CCallConv and Safety
    
    This is used by the JS backend for serialization.
    
    - - - - -
    75e4e090 by Sebastian Graf at 2022-02-25T21:15:59-05:00
    base: Improve documentation of `throwIO` (#19854)
    
    Now it takes a better account of precise vs. imprecise exception semantics.
    
    Fixes #19854.
    
    - - - - -
    61a203ba by Matthew Pickering at 2022-02-26T02:06:51-05:00
    Make typechecking unfoldings from interfaces lazier
    
    The old logic was unecessarily strict in loading unfoldings because when
    reading the unfolding we would case on the result of attempting to load
    the template before commiting to which type of unfolding we were
    producing. Hence trying to inspect any of the information about an
    unfolding would force the template to be loaded.
    
    This also removes a potentially hard to discover bug where if the
    template failed to be typechecked for some reason then we would just not
    return an unfolding. Instead we now panic so these bad situations which
    should never arise can be identified.
    
    - - - - -
    2be74460 by Matthew Pickering at 2022-02-26T02:06:51-05:00
    Use a more up-to-date snapshot of the current rules in the simplifier
    
    As the prescient (now deleted) note warns in simplifyPgmIO we have to be a bit careful
    about when we gather rules from the EPS so that we get the rules for
    imported bindings.
    
    ```
      -- Get any new rules, and extend the rule base
      -- See Note [Overall plumbing for rules] in GHC.Core.Rules
      -- We need to do this regularly, because simplification can
      -- poke on IdInfo thunks, which in turn brings in new rules
      -- behind the scenes.  Otherwise there's a danger we'll simply
      -- miss the rules for Ids hidden inside imported inlinings
    ```
    
    Given the previous commit, the loading of unfoldings is now even more
    delayed so we need to be more careful to read the EPS rule base closer to the point
    where we decide to try rules.
    
    Without this fix GHC performance regressed by a noticeably amount
    because the `zip` rule was not brought into scope eagerly enough which
    led to a further series of unfortunate events in the simplifer which
    tipped `substTyWithCoVars` over the edge of the size threshold, stopped
    it being inlined and increased allocations by 10% in some cases.
    
    Furthermore, this change is noticeably in the testsuite as it changes
    T19790 so that the `length` rules from GHC.List fires earlier.
    
    -------------------------
    Metric Increase:
        T9961
    -------------------------
    
    - - - - -
    b8046195 by Matthew Pickering at 2022-02-26T02:06:52-05:00
    Improve efficiency of extending a RuleEnv with a new RuleBase
    
    Essentially we apply the identity:
    
    > lookupNameEnv n (plusNameEnv_C (++) rb1 rb2)
    >   = lookupNameEnv n rb1 ++ lookupNameEnv n rb2
    
    The latter being more efficient as we don't construct an intermediate
    map.
    
    This is now quite important as each time we try and apply rules we need
    to combine the current EPS RuleBase with the HPT and ModGuts rule bases.
    
    - - - - -
    033e9f0f by sheaf at 2022-02-26T02:07:30-05:00
    Error on anon wildcards in tcAnonWildCardOcc
    
      The code in tcAnonWildCardOcc assumed that it could never encounter
      anonymous wildcards in illegal positions, because the renamer would
      have ruled them out. However, it's possible to sneak past the checks
      in the renamer by using Template Haskell. It isn't possible to simply
      pass on additional information when renaming Template Haskell
      brackets, because we don't know in advance in what context the bracket
      will be spliced in (see test case T15433b). So we accept that we might
      encounter these bogus wildcards in the typechecker and throw the
      appropriate error.
    
      This patch also migrates the error messages for illegal wildcards in
      types to use the diagnostic infrastructure.
    
      Fixes #15433
    
    - - - - -
    32d8fe3a by sheaf at 2022-02-26T14:15:33+01:00
    Core Lint: ensure primops can be eta-expanded
    
    This patch adds a check to Core Lint, checkCanEtaExpand,
    which ensures that primops and other wired-in functions with
    no binding such as unsafeCoerce#, oneShot, rightSection...
    can always be eta-expanded, by checking that the remaining
    argument types have a fixed RuntimeRep.
    
    Two subtleties came up:
    
      - the notion of arity in Core looks through newtypes, so we may
        need to unwrap newtypes in this check,
      - we want to avoid calling hasNoBinding on something whose unfolding
        we are in the process of linting, as this would cause a loop;
        to avoid this we add some information to the Core Lint environment
        that holds this information.
    
    Fixes #20480
    
    - - - - -
    0a80b436 by Peter Trommler at 2022-02-26T17:21:59-05:00
    testsuite: Require LLVM for T15155l
    
    - - - - -
    38cb920e by Oleg Grenrus at 2022-02-28T07:14:04-05:00
    Add Monoid a => Monoid (STM a) instance
    
    - - - - -
    d734ef8f by Hécate Moonlight at 2022-02-28T07:14:42-05:00
    Make modules in base stable.
    
    fix #18963
    
    - - - - -
    fbf005e9 by Sven Tennie at 2022-02-28T19:16:01-05:00
    Fix some hlint issues in ghc-heap
    
    This does not fix all hlint issues as the criticised index and
    length expressions seem to be fine in context.
    
    - - - - -
    adfddf7d by Matthew Pickering at 2022-02-28T19:16:36-05:00
    hadrian: Suggest to the user to run ./configure if missing a setting
    
    If a setting is missing from the configuration file it's likely the user
    needs to reconfigure.
    
    Fixes #20476
    
    - - - - -
    4f0208e5 by Andreas Klebinger at 2022-02-28T19:17:12-05:00
    CLabel cleanup:
    
    Remove these smart constructors for these reasons:
    * mkLocalClosureTableLabel : Does the same as the non-local variant.
    * mkLocalClosureLabel      : Does the same as the non-local variant.
    * mkLocalInfoTableLabel    : Decide if we make a local label based on the name
                                 and just use mkInfoTableLabel everywhere.
    
    - - - - -
    065419af by Matthew Pickering at 2022-02-28T19:17:47-05:00
    linking: Don't pass --hash-size and --reduce-memory-overhead to ld
    
    These flags were added to help with the high linking cost of the old
    split-objs mode. Now we are using split-sections these flags appear to
    make no difference to memory usage or time taken to link.
    
    I tested various configurations linking together the ghc library with
    -split-sections enabled.
    
    | linker | time (s) |
    | ------ | ------   |
    | gold   | 0.95     |
    | ld     | 1.6      |
    | ld (hash-size = 31, reduce-memory-overheads) | 1.6 |
    | ldd    | 0.47     |
    
    Fixes #20967
    
    - - - - -
    3e65ef05 by Teo Camarasu at 2022-02-28T19:18:27-05:00
    template-haskell: fix typo in docstring for Overlap
    
    - - - - -
    80f9133e by Teo Camarasu at 2022-02-28T19:18:27-05:00
    template-haskell: fix docstring for Bytes
    
    It seems like a commented out section of code was accidentally included
    in the docstring for a field.
    
    - - - - -
    54774268 by Matthew Pickering at 2022-03-01T16:23:10-05:00
    Fix longstanding issue with moduleGraphNodes - no hs-boot files case
    
    In the case when we tell moduleGraphNodes to drop hs-boot files the idea
    is to collapse hs-boot files into their hs file nodes. In the old code
    
    * nodeDependencies changed edges from IsBoot to NonBoot
    * moduleGraphNodes just dropped boot file nodes
    
    The net result is that any dependencies of the hs-boot files themselves
    were dropped. The correct thing to do is
    
    * nodeDependencies changes edges from IsBoot to NonBoot
    * moduleGraphNodes merges dependencies of IsBoot and NonBoot nodes.
    
    The result is a properly quotiented dependency graph which contains no
    hs-boot files nor hs-boot file edges.
    
    Why this didn't cause endless issues when compiling with boot files, we
    will never know.
    
    - - - - -
    c84dc506 by Matthew Pickering at 2022-03-01T16:23:10-05:00
    driver: Properly add an edge between a .hs and its hs-boot file
    
    As noted in #21071 we were missing adding this edge so there were
    situations where the .hs file would get compiled before the .hs-boot
    file which leads to issues with -j.
    
    I fixed this properly by adding the edge in downsweep so the definition
    of nodeDependencies can be simplified to avoid adding this dummy edge
    in.
    
    There are plenty of tests which seem to have these redundant boot files
    anyway so no new test. #21094 tracks the more general issue of
    identifying redundant hs-boot and SOURCE imports.
    
    - - - - -
    7aeb6d29 by sheaf at 2022-03-01T16:23:51-05:00
    Core Lint: collect args through floatable ticks
    
    We were not looking through floatable ticks when collecting arguments in
    Core Lint, which caused `checkCanEtaExpand` to fail on something like:
    
    ```haskell
    reallyUnsafePtrEquality
      = \ @a ->
          (src<loc> reallyUnsafePtrEquality#)
            @Lifted @a @Lifted @a
    ```
    
    We fix this by using `collectArgsTicks tickishFloatable` instead of
    `collectArgs`, to be consistent with the behaviour of eta expansion
    outlined in Note [Eta expansion and source notes] in GHC.Core.Opt.Arity.
    
    Fixes #21152.
    
    - - - - -
    75caafaa by Matthew Pickering at 2022-03-02T01:14:59-05:00
    Ticky profiling improvements.
    
    This adds a number of changes to ticky-ticky profiling.
    
    When an executable is profiled with IPE profiling it's now possible to
    associate id-related ticky counters to their source location.
    This works by emitting the info table address as part of the counter
    which can be looked up in the IPE table.
    
    Add a `-ticky-ap-thunk` flag. This flag prevents the use of some standard thunks
    which are precompiled into the RTS. This means reduced cache locality
    and increased code size. But it allows better attribution of execution
    cost to specific source locations instead of simple attributing it to
    the standard thunk.
    
    ticky-ticky now uses the `arg` field to emit additional information
    about counters in json format. When ticky-ticky is used in combination
    with the eventlog eventlog2html can be used to generate a html table
    from the eventlog similar to the old text output for ticky-ticky.
    
    - - - - -
    aeea6bd5 by doyougnu at 2022-03-02T01:15:39-05:00
    StgToCmm.cgTopBinding: no isNCG, use binBlobThresh
    
    This is a one line change. It is a fixup from MR!7325, was pointed out
    in review of MR!7442, specifically: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7442#note_406581
    
    The change removes isNCG check from cgTopBinding. Instead it changes the
    type of binBlobThresh in DynFlags from Word to Maybe Word, where a Just
    0 or a Nothing indicates an infinite threshold and thus the disable
    CmmFileEmbed case in the original check.
    
    This improves the cohesion of the module because more NCG related
    Backend stuff is moved into, and checked in, StgToCmm.Config. Note, that
    the meaning of a Just 0 or a Nothing in binBlobThresh is indicated in a
    comment next to its field in GHC.StgToCmm.Config.
    
    DynFlags: binBlobThresh: Word -> Maybe Word
    
    StgToCmm.Config: binBlobThesh add not ncg check
    
    DynFlags.binBlob: move Just 0 check to dflags init
    
    StgToCmm.binBlob: only check isNCG, Just 0 check to dflags
    
    StgToCmm.Config: strictify binBlobThresh
    
    - - - - -
    b27b2af3 by sheaf at 2022-03-02T14:08:36-05:00
    Introduce ConcreteTv metavariables
    
      This patch introduces a new kind of metavariable, by adding the
      constructor `ConcreteTv` to `MetaInfo`. A metavariable with
      `ConcreteTv` `MetaInfo`, henceforth a concrete metavariable, can only
      be unified with a type that is concrete (that is, a type that answers
      `True` to `GHC.Core.Type.isConcrete`).
    
      This solves the problem of dangling metavariables in `Concrete#`
      constraints: instead of emitting `Concrete# ty`, which contains a
      secret existential metavariable, we simply emit a primitive equality
      constraint `ty ~# concrete_tv` where `concrete_tv` is a fresh concrete
      metavariable.
    
      This means we can avoid all the complexity of canonicalising
      `Concrete#` constraints, as we can just re-use the existing machinery
      for `~#`.
    
      To finish things up, this patch then removes the `Concrete#` special
      predicate, and instead introduces the special predicate `IsRefl#`
      which enforces that a coercion is reflexive.
      Such a constraint is needed because the canonicaliser is quite happy
      to rewrite an equality constraint such as `ty ~# concrete_tv`, but
      such a rewriting is not handled by the rest of the compiler currently,
      as we need to make use of the resulting coercion, as outlined in the
      FixedRuntimeRep plan.
    
      The big upside of this approach (on top of simplifying the code)
      is that we can now selectively implement PHASE 2 of FixedRuntimeRep,
      by changing individual calls of `hasFixedRuntimeRep_MustBeRefl` to
      `hasFixedRuntimeRep` and making use of the obtained coercion.
    
    - - - - -
    81b7c436 by Matthew Pickering at 2022-03-02T14:09:13-05:00
    Make -dannot-lint not panic on let bound type variables
    
    After certain simplifier passes we end up with let bound type variables
    which are immediately inlined in the next pass. The core diff utility
    implemented by -dannot-lint failed to take these into account and
    paniced.
    
    Progress towards #20965
    
    - - - - -
    f596c91a by sheaf at 2022-03-02T14:09:51-05:00
    Improve out-of-order inferred type variables
    
      Don't instantiate type variables for :type in
      `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting
      `r1` but not `r2` in the type
    
        forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ...
    
      This fixes #21088.
    
      This patch also changes the primop pretty-printer to ensure
      that we put all the inferred type variables first. For example,
      the type of reallyUnsafePtrEquality# is now
    
        forall {l :: Levity} {k :: Levity}
               (a :: TYPE (BoxedRep l))
               (b :: TYPE (BoxedRep k)).
          a -> b -> Int#
    
      This means we avoid running into issue #21088 entirely with
      the types of primops. Users can still write a type signature where
      the inferred type variables don't come first, however.
    
      This change to primops had a knock-on consequence, revealing that
      we were sometimes performing eta reduction on keepAlive#.
      This patch updates tryEtaReduce to avoid eta reducing functions
      with no binding, bringing it in line with tryEtaReducePrep,
      and thus fixing #21090.
    
    - - - - -
    1617fed3 by Richard Eisenberg at 2022-03-02T14:10:28-05:00
    Make inert_cycle_breakers into a stack.
    
    Close #20231.
    
    - - - - -
    c8652a0a by Richard Eisenberg at 2022-03-02T14:11:03-05:00
    Make Constraint not *apart* from Type.
    
    More details in Note [coreView vs tcView]
    
    Close #21092.
    
    - - - - -
    91a10cb0 by doyougnu at 2022-03-02T14:11:43-05:00
    GenStgAlt 3-tuple synonym --> Record type
    
    This commit alters GenStgAlt from a type synonym to a Record with field
    accessors. In pursuit of #21078, this is not a required change but cleans
    up several areas for nicer code in the upcoming js-backend, and in GHC
    itself.
    
    GenStgAlt: 3-tuple -> record
    
    Stg.Utils: GenStgAlt 3-tuple -> record
    
    Stg.Stats: StgAlt 3-tuple --> record
    
    Stg.InferTags.Rewrite: StgAlt 3-tuple -> record
    
    Stg.FVs: GenStgAlt 3-tuple -> record
    
    Stg.CSE: GenStgAlt 3-tuple -> record
    
    Stg.InferTags: GenStgAlt 3-tuple --> record
    
    Stg.Debug: GenStgAlt 3-tuple --> record
    
    Stg.Lift.Analysis: GenStgAlt 3-tuple --> record
    
    Stg.Lift: GenStgAlt 3-tuple --> record
    
    ByteCode.Instr: GenStgAlt 3-tuple --> record
    
    Stg.Syntax: add GenStgAlt helper functions
    
    Stg.Unarise: GenStgAlt 3-tuple --> record
    
    Stg.BcPrep: GenStgAlt 3-tuple --> record
    
    CoreToStg: GenStgAlt 3-tuple --> record
    
    StgToCmm.Expr: GenStgAlt 3-tuple --> record
    
    StgToCmm.Bind: GenStgAlt 3-tuple --> record
    
    StgToByteCode: GenStgAlt 3-tuple --> record
    
    Stg.Lint: GenStgAlt 3-tuple --> record
    
    Stg.Syntax: strictify GenStgAlt
    
    GenStgAlt: add haddock, some cleanup
    
    fixup: remove calls to pure, single ViewPattern
    
    StgToByteCode: use case over viewpatterns
    
    - - - - -
    73864f00 by Matthew Pickering at 2022-03-02T14:12:19-05:00
    base: Remove default method from bitraversable
    
    The default instance leads to an infinite loop.
    bisequenceA is defined in terms of bisquence which is defined in terms
    of bitraverse.
    
    ```
    bitraverse f g
    = (defn of bitraverse)
    bisequenceA . bimap f g
    = (defn of bisequenceA)
    bitraverse id id . bimap f g
    = (defn of bitraverse)
    ...
    ```
    
    Any instances defined without an explicitly implementation are currently
    broken, therefore removing it will alert users to an issue in their
    code.
    
    CLC issue: https://github.com/haskell/core-libraries-committee/issues/47
    
    Fixes #20329 #18901
    
    - - - - -
    9579bf35 by Matthew Pickering at 2022-03-02T14:12:54-05:00
    ci: Add check to CI to ensure compiler uses correct BIGNUM_BACKEND
    
    - - - - -
    c48a7c3a by Sylvain Henry at 2022-03-03T07:37:12-05:00
    Use Word64# primops in Word64 Num instance
    
    Taken froù!3658
    
    - - - - -
    ce65d0cc by Matthew Pickering at 2022-03-03T07:37:48-05:00
    hadrian: Correctly set whether we have a debug compiler when running tests
    
    For example, running the `slow-validate` flavour would incorrectly run
    the T16135 test which would fail with an assertion error, despite the
    fact that is should be skipped when we have a debug compiler.
    
    - - - - -
    e0c3e757 by Matthew Pickering at 2022-03-03T13:48:41-05:00
    docs: Add note to unsafeCoerce function that you might want to use coerce [skip ci]
    
    Fixes #15429
    
    - - - - -
    559d4cf3 by Matthew Pickering at 2022-03-03T13:49:17-05:00
    docs: Add note to RULES documentation about locally bound variables [skip ci]
    
    Fixes #20100
    
    - - - - -
    c534b3dd by Matthew Pickering at 2022-03-03T13:49:53-05:00
    Replace ad-hoc CPP with constant from GHC.Utils.Constant
    
    Fixes #21154
    
    - - - - -
    de56cc7e by Krzysztof Gogolewski at 2022-03-04T12:44:26-05:00
    Update documentation of LiberalTypeSynonyms
    
    We no longer require LiberalTypeSynonyms to use 'forall' or an unboxed
    tuple in a synonym.
    
    I also removed that kind checking before expanding synonyms "could be changed".
    This was true when type synonyms were thought of macros, but with
    the extensions such as SAKS or matchability I don't see it changing.
    
    - - - - -
    c0a39259 by Simon Jakobi at 2022-03-04T12:45:01-05:00
    base: Mark GHC.Bits not-home for haddock
    
    Most (all) of the exports are re-exported from
    the preferable Data.Bits.
    
    - - - - -
    3570eda5 by Sylvain Henry at 2022-03-04T12:45:42-05:00
    Fix comments about Int64/Word64 primops
    
    - - - - -
    6f84ee33 by Artem Pelenitsyn at 2022-03-05T01:06:47-05:00
    remove MonadFail instances of ST
    
    CLC proposal: https://github.com/haskell/core-libraries-committee/issues/33
    
    The instances had `fail` implemented in terms of `error`, whereas the
    idea of the `MonadFail` class is that the `fail` method should be
    implemented in terms of the monad itself.
    
    - - - - -
    584cd5ae by sheaf at 2022-03-05T01:07:25-05:00
    Don't allow Float#/Double# literal patterns
    
      This patch does the following two things:
    
        1. Fix the check in Core Lint to properly throw an error when it
           comes across Float#/Double# literal patterns. The check
           was incorrect before, because it expected the type to be
           Float/Double instead of Float#/Double#.
    
        2. Add an error in the parser when the user writes a floating-point
           literal pattern such as `case x of { 2.0## -> ... }`.
    
      Fixes #21115
    
    - - - - -
    706deee0 by Greg Steuck at 2022-03-05T17:44:10-08:00
    Make T20214 terminate promptly be setting input to /dev/null
    
    It was hanging and timing out on OpenBSD before.
    
    - - - - -
    14e90098 by Simon Peyton Jones at 2022-03-07T14:05:41-05:00
    Always generalise top-level bindings
    
    Fix #21023 by always generalising top-level binding; change
    the documentation of -XMonoLocalBinds to match.
    
    - - - - -
    c9c31c3c by Matthew Pickering at 2022-03-07T14:06:16-05:00
    hadrian: Add little flavour transformer to build stage2 with assertions
    
    This can be useful to build a `perf+assertions` build or even better
    `default+no_profiled_libs+omit_pragmas+assertions`.
    
    - - - - -
    89c14a6c by Matthew Pickering at 2022-03-07T14:06:16-05:00
    ci: Convert all deb10 make jobs into hadrian jobs
    
    This is the first step in converting all the CI configs to use hadrian
    rather than make. (#21129)
    
    The metrics increase due to hadrian using --hyperlinked-source for
    haddock builds. (See #21156)
    
    -------------------------
    Metric Increase:
        haddock.Cabal
        haddock.base
        haddock.compiler
    -------------------------
    
    - - - - -
    7bfae2ee by Matthew Pickering at 2022-03-07T14:06:16-05:00
    Replace use of BIN_DIST_PREP_TAR_COMP with BIN_DIST_NAME
    
    And adds a check to make sure we are not accidently settings
    BIN_DIST_PREP_TAR_COMP when using hadrian.
    
    - - - - -
    5b35ca58 by Matthew Pickering at 2022-03-07T14:06:16-05:00
    Fix gen_contents_index logic for hadrian bindist
    
    - - - - -
    273bc133 by Krzysztof Gogolewski at 2022-03-07T14:06:52-05:00
    Fix reporting constraints in pprTcSolverReportMsg
    
    'no_instance_msg' and 'no_deduce_msg' were omitting the first wanted.
    
    - - - - -
    5874a30a by Simon Jakobi at 2022-03-07T14:07:28-05:00
    Improve setBit for Natural
    
    Previously the default definition was used, which involved allocating
    intermediate Natural values.
    
    Fixes #21173.
    
    - - - - -
    7a02aeb8 by Matthew Pickering at 2022-03-07T14:08:03-05:00
    Remove leftover trace in testsuite
    
    - - - - -
    6ce6c250 by Andreas Klebinger at 2022-03-07T23:48:56-05:00
    Expand and improve the Note [Strict Worker Ids].
    
    I've added an explicit mention of the invariants surrounding those. As well as adding
    more direct cross references to the Strict Field Invariant.
    
    - - - - -
    d0f892fe by Ryan Scott at 2022-03-07T23:49:32-05:00
    Delete GenericKind_ in favor of GenericKind_DC
    
    When deriving a `Generic1` instance, we need to know what the last type
    variable of a data type is. Previously, there were two mechanisms to determine
    this information:
    
    * `GenericKind_`, where `Gen1_` stored the last type variable of a data type
       constructor (i.e., the `tyConTyVars`).
    * `GenericKind_DC`, where `Gen1_DC` stored the last universally quantified
      type variable in a data constructor (i.e., the `dataConUnivTyVars`).
    
    These had different use cases, as `GenericKind_` was used for generating
    `Rep(1)` instances, while `GenericKind_DC` was used for generating `from(1)`
    and `to(1)` implementations. This was already a bit confusing, but things went
    from confusing to outright wrong after !6976. This is because after !6976,
    the `deriving` machinery stopped using `tyConTyVars` in favor of
    `dataConUnivTyVars`. Well, everywhere with the sole exception of
    `GenericKind_`, which still continued to use `tyConTyVars`. This lead to
    disaster when deriving a `Generic1` instance for a GADT family instance, as
    the `tyConTyVars` do not match the `dataConUnivTyVars`. (See #21185.)
    
    The fix is to stop using `GenericKind_` and replace it with `GenericKind_DC`.
    For the most part, this proves relatively straightforward. Some highlights:
    
    * The `forgetArgVar` function was deleted entirely, as it no longer proved
      necessary after `GenericKind_`'s demise.
    * The substitution that maps from the last type variable to `Any` (see
      `Note [Generating a correctly typed Rep instance]`) had to be moved from
      `tc_mkRepTy` to `tc_mkRepFamInsts`, as `tc_mkRepTy` no longer has access to
      the last type variable.
    
    Fixes #21185.
    
    - - - - -
    a60ddffd by Matthew Pickering at 2022-03-08T22:51:37+00:00
    Move bootstrap and cabal-reinstall test jobs to nightly
    
    CI is creaking under the pressure of too many jobs so attempt to reduce
    the strain by removing a couple of jobs.
    
    - - - - -
    7abe3288 by Matthew Pickering at 2022-03-09T10:24:15+00:00
    Add 10 minute timeout to linters job
    
    - - - - -
    3cf75ede by Matthew Pickering at 2022-03-09T10:24:16+00:00
    Revert "hadrian: Correctly set whether we have a debug compiler when running tests"
    
    Needing the arguments for "GHC/Utils/Constant.hs" implies a dependency
    on the previous stage compiler. Whilst we work out how to get around
    this I will just revert this commit (as it only affects running the
    testsuite in debug way).
    
    This reverts commit ce65d0cceda4a028f30deafa3c39d40a250acc6a.
    
    - - - - -
    18b9ba56 by Matthew Pickering at 2022-03-09T11:07:23+00:00
    ci: Fix save_cache function
    
    Each interation of saving the cache would copy the whole `cabal` store
    into a subfolder in the CACHE_DIR rather than copying the contents of
    the cabal store into the cache dir. This resulted in a cache which
    looked like:
    
    ```
    /builds/ghc/ghc/cabal-cache/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/
    ```
    
    So it would get one layer deeper every CI run and take longer and longer
    to compress.
    
    - - - - -
    bc684dfb by Ben Gamari at 2022-03-10T03:20:07-05:00
    mr-template: Mention timeframe for review
    - - - - -
    7f5f4ede by Vladislav Zavialov at 2022-03-10T03:20:43-05:00
    Bump submodules: containers, exceptions
    
    GHC Proposal #371 requires TypeOperators to use type equality a~b.
    This submodule update pulls in the appropriate forward-compatibility
    changes in 'libraries/containers' and 'libraries/exceptions'
    
    - - - - -
    8532b8a9 by Matthew Pickering at 2022-03-10T03:20:43-05:00
    Add an inline pragma to lookupVarEnv
    
    The containers bump reduced the size of the Data.IntMap.Internal.lookup
    function so that it no longer experienced W/W. This means that the size
    of lookupVarEnv increased over the inlining threshold and it wasn't
    inlined into the hot code path in substTyVar.
    
    See containers#821, #21159 and !7638 for some more explanation.
    
    -------------------------
    Metric Decrease:
        LargeRecord
        T12227
        T13386
        T15703
        T18223
        T5030
        T8095
        T9872a
        T9872b
        T9872c
        TcPlugin_RewritePerf
    -------------------------
    
    - - - - -
    844cf1e1 by Matthew Pickering at 2022-03-10T03:20:43-05:00
    Normalise output of T10970 test
    
    The output of this test changes each time the containers submodule
    version updates. It's easier to apply the version normaliser so that
    the test checks that there is a version number, but not which one it is.
    
    - - - - -
    24b6af26 by Ryan Scott at 2022-03-11T19:56:28-05:00
    Refactor tcDeriving to generate tyfam insts before any bindings
    
    Previously, there was an awful hack in `genInst` (now called `genInstBinds`
    after this patch) where we had to return a continutation rather than directly
    returning the bindings for a derived instance. This was done for staging
    purposes, as we had to first infer the instance contexts for derived instances
    and then feed these contexts into the continuations to ensure the generated
    instance bindings had accurate instance contexts.
    `Note [Staging of tcDeriving]` in `GHC.Tc.Deriving` described this confusing
    state of affairs.
    
    The root cause of this confusing design was the fact that `genInst` was trying
    to generate instance bindings and associated type family instances for derived
    instances simultaneously. This really isn't possible, however: as
    `Note [Staging of tcDeriving]` explains, one needs to have access to the
    associated type family instances before one can properly infer the instance
    contexts for derived instances. The use of continuation-returning style was an
    attempt to circumvent this dependency, but it did so in an awkward way.
    
    This patch detangles this awkwardness by splitting up `genInst` into two
    functions: `genFamInsts` (for associated type family instances) and
    `genInstBinds` (for instance bindings). Now, the `tcDeriving` function calls
    `genFamInsts` and brings all the family instances into scope before calling
    `genInstBinds`. This removes the need for the awkward continuation-returning
    style seen in the previous version of `genInst`, making the code easier to
    understand.
    
    There are some knock-on changes as well:
    
    1. `hasStockDeriving` now needs to return two separate functions: one that
       describes how to generate family instances for a stock-derived instance,
       and another that describes how to generate the instance bindings. I factored
       out this pattern into a new `StockGenFns` data type.
    2. While documenting `StockGenFns`, I realized that there was some
       inconsistency regarding which `StockGenFns` functions needed which
       arguments. In particular, the function in `GHC.Tc.Deriv.Generics` which
       generates `Rep(1)` instances did not take a `SrcSpan` like other `gen_*`
       functions did, and it included an extra `[Type]` argument that was entirely
       redundant. As a consequence, I refactored the code in
       `GHC.Tc.Deriv.Generics` to more closely resemble other `gen_*` functions.
       A happy result of all this is that all `StockGenFns` functions now take
       exactly the same arguments, which makes everything more uniform.
    
    This is purely a refactoring that should not have any effect on user-observable
    behavior. The new design paves the way for an eventual fix for #20719.
    
    - - - - -
    62caaa9b by Ben Gamari at 2022-03-11T19:57:03-05:00
    gitlab-ci: Use the linters image in hlint job
    
    As the `hlint` executable is only available in the linters image.
    
    Fixes #21146.
    
    - - - - -
    4abd7eb0 by Matthew Pickering at 2022-03-11T19:57:38-05:00
    Remove partOfGhci check in the loader
    
    This special logic has been part of GHC ever since template haskell was
    introduced in 9af77fa423926fbda946b31e174173d0ec5ebac8.
    
    It's hard to believe in any case that this special logic pays its way at
    all. Given
    
    * The list is out-of-date, which has potential to lead to miscompilation
      when using "editline", which was removed in 2010 (46aed8a4).
    * The performance benefit seems negligable as each load only happens
      once anyway and packages specified by package flags are preloaded into
      the linker state at the start of compilation.
    
    Therefore we just remove this logic.
    
    Fixes #19791
    
    - - - - -
    c40cbaa2 by Andreas Klebinger at 2022-03-11T19:58:14-05:00
    Improve -dtag-inference-checks checks.
    
    FUN closures don't get tagged when evaluated. So no point in checking their
    tags.
    
    - - - - -
    ab00d23b by Simon Jakobi at 2022-03-11T19:58:49-05:00
    Improve clearBit and complementBit for Natural
    
    Also optimize bigNatComplementBit#.
    
    Fixes #21175, #21181, #21194.
    
    - - - - -
    a6d8facb by Sebastian Graf at 2022-03-11T19:59:24-05:00
    gitignore all (build) directories headed by _
    
    - - - - -
    524795fe by Sebastian Graf at 2022-03-11T19:59:24-05:00
    Demand: Document why we need three additional equations of multSubDmd
    
    - - - - -
    6bdcd557 by Cheng Shao at 2022-03-11T20:00:01-05:00
    CmmToC: make 64-bit word splitting for 32-bit targets respect target endianness
    
    This used to been broken for little-endian targets.
    
    - - - - -
    9e67c69e by Cheng Shao at 2022-03-11T20:00:01-05:00
    CmmToC: fix Double# literal payload for 32-bit targets
    
    Contrary to the legacy comment, the splitting didn't happen and we
    ended up with a single StgWord64 literal in the output code! Let's
    just do the splitting here.
    
    - - - - -
    1eee2e28 by Cheng Shao at 2022-03-11T20:00:01-05:00
    CmmToC: use __builtin versions of memcpyish functions to fix type mismatch
    
    Our memcpyish primop's type signatures doesn't match the C type
    signatures. It's not a problem for typical archs, since their C ABI
    permits dropping the result, but it doesn't work for wasm. The
    previous logic would cast the memcpyish function pointer to an
    incorrect type and perform an indirect call, which results in a
    runtime trap on wasm.
    
    The most straightforward fix is: don't emit EFF_ for memcpyish
    functions. Since we don't want to include extra headers in .hc to
    bring in their prototypes, we can just use the __builtin versions.
    
    - - - - -
    9d8d4837 by Cheng Shao at 2022-03-11T20:00:01-05:00
    CmmToC: emit __builtin_unreachable() when CmmSwitch doesn't contain fallback case
    
    Otherwise the C compiler may complain "warning: non-void function does
    not return a value in all control paths [-Wreturn-type]".
    
    - - - - -
    27da5540 by Cheng Shao at 2022-03-11T20:00:01-05:00
    CmmToC: make floatToWord32/doubleToWord64 faster
    
    Use castFloatToWord32/castDoubleToWord64 in base to perform the
    reinterpret cast.
    
    - - - - -
    c98e8332 by Cheng Shao at 2022-03-11T20:00:01-05:00
    CmmToC: fix -Wunused-value warning in ASSIGN_BaseReg
    
    When ASSIGN_BaseReg is a no-op, we shouldn't generate any C code,
    otherwise C compiler complains a bunch of -Wunused-value warnings when
    doing unregisterised codegen.
    
    - - - - -
    5932247c by Ben Gamari at 2022-03-11T20:00:36-05:00
    users guide: Eliminate spurious \spxentry mentions
    
    We were failing to pass the style file to `makeindex`, as is done by
    the mklatex configuration generated by Sphinx.
    
    Fixes #20913.
    
    - - - - -
    e40cf4ef by Simon Jakobi at 2022-03-11T20:01:11-05:00
    ghc-bignum: Tweak integerOr
    
    The result of ORing two BigNats is always greater or equal to the
    larger of the two. Therefore it is safe to skip the magnitude checks of
    integerFromBigNat#.
    
    - - - - -
    cf081476 by Vladislav Zavialov at 2022-03-12T07:02:40-05:00
    checkUnboxedLitPat: use non-fatal addError
    
    This enables GHC to report more parse errors in a single pass.
    
    - - - - -
    7fe07143 by Andreas Klebinger at 2022-03-12T07:03:16-05:00
    Rename -fprof-late-ccs to -fprof-late
    
    - - - - -
    88a94541 by Sylvain Henry at 2022-03-12T07:03:56-05:00
    Hadrian: avoid useless allocations in trackArgument
    
    Cf ticky report before the change:
    
        Entries      Alloc    Alloc'd  Non-void Arguments      STG Name
    --------------------------------------------------------------------------------
         696987   29044128          0   1 L                    main:Target.trackArgument_go5{v r24kY} (fun)
    
    - - - - -
    2509d676 by Sylvain Henry at 2022-03-12T07:04:36-05:00
    Hadrian: avoid allocating in stageString (#19209)
    
    - - - - -
    c062fac0 by Sylvain Henry at 2022-03-12T07:04:36-05:00
    Hadrian: remove useless imports
    
    Added for no reason in 7ce1b694f7be7fbf6e2d7b7eb0639e61fbe358c6
    
    - - - - -
    c82fb934 by Sylvain Henry at 2022-03-12T07:05:16-05:00
    Hadrian: avoid allocations in WayUnit's Read instance (#19209)
    
    - - - - -
    ed04aed2 by Sylvain Henry at 2022-03-12T07:05:16-05:00
    Hadrian: use IntSet Binary instance for Way (#19209)
    
    - - - - -
    ad835531 by Simon Peyton Jones at 2022-03-13T18:12:12-04:00
    Fix bug in weak loop-breakers in OccurAnal
    
    Note [Weak loop breakers] explains why we need to track variables free
    in RHS of rules.  But we need to do this for /inactive/ rules as well
    as active ones, unlike the rhs_fv_env stuff.
    
    So we now have two fields in node Details, one for free vars of
    active rules, and one for free vars of all rules.
    
    This was shown up by #20820, which is now fixed.
    
    - - - - -
    76b94b72 by Sebastian Graf at 2022-03-13T18:12:48-04:00
    Worker/wrapper: Preserve float barriers (#21150)
    
    Issue #21150 shows that worker/wrapper allocated a worker function for a
    function with multiple calls that said "called at most once" when the first
    argument was absent. That's bad!
    
    This patch makes it so that WW preserves at least one non-one-shot value lambda
    (see `Note [Preserving float barriers]`) by passing around `void#` in place of
    absent arguments.
    
    Fixes #21150.
    
    Since the fix is pretty similar to `Note [Protecting the last value argument]`,
    I put the logic in `mkWorkerArgs`. There I realised (#21204) that
    `-ffun-to-thunk` is basically useless with `-ffull-laziness`, so I deprecated
    the flag, simplified and split into `needsVoidWorkerArg`/`addVoidWorkerArg`.
    SpecConstr is another client of that API.
    
    Fixes #21204.
    
    Metric Decrease:
        T14683
    
    - - - - -
    97db789e by romes at 2022-03-14T11:36:39-04:00
    Fix up Note [Bind free vars]
    
    Move GHC-specific comments from Language.Haskell.Syntax.Binds to
    GHC.Hs.Binds
    
    It looks like the Note was deleted but there were actually two copies of
    it. L.H.S.B no longer references it, and GHC.Hs.Binds keeps an updated
    copy. (See #19252)
    
    There are other duplicated notes -- they will be fixed in the next
    commit
    
    - - - - -
    135888dd by romes at 2022-03-14T11:36:39-04:00
    TTG Pull AbsBinds and ABExport out of the main AST
    
    AbsBinds and ABExport both depended on the typechecker, and were thus
    removed from the main AST Expr.
    
    CollectPass now has a new function `collectXXHsBindsLR` used for the new
    HsBinds extension point
    
    Bumped haddock submodule to work with AST changes.
    
    The removed Notes from Language.Haskell.Syntax.Binds were duplicated
    (and not referenced) and the copies in GHC.Hs.Binds are kept (and
    referenced there). (See #19252)
    
    - - - - -
    106413f0 by sheaf at 2022-03-14T11:37:21-04:00
    Add two coercion optimisation perf tests
    
    - - - - -
    8eadea67 by sheaf at 2022-03-14T15:08:24-04:00
    Fix isLiftedType_maybe and handle fallout
    
    As #20837 pointed out, `isLiftedType_maybe` returned `Just False` in
    many situations where it should return `Nothing`, because it didn't
    take into account type families or type variables.
    
    In this patch, we fix this issue. We rename `isLiftedType_maybe` to
    `typeLevity_maybe`, which now returns a `Levity` instead of a boolean.
    We now return `Nothing` for types with kinds of the form
    `TYPE (F a1 ... an)` for a type family `F`, as well as
    `TYPE (BoxedRep l)` where `l` is a type variable.
    
    This fix caused several other problems, as other parts of the compiler
    were relying on `isLiftedType_maybe` returning a `Just` value, and were
    now panicking after the above fix. There were two main situations in
    which panics occurred:
    
      1. Issues involving the let/app invariant. To uphold that invariant,
         we need to know whether something is lifted or not. If we get an
         answer of `Nothing` from `isLiftedType_maybe`, then we don't know
         what to do. As this invariant isn't particularly invariant, we
         can change the affected functions to not panic, e.g. by behaving
         the same in the `Just False` case and in the `Nothing` case
         (meaning: no observable change in behaviour compared to before).
    
      2. Typechecking of data (/newtype) constructor patterns. Some programs
         involving patterns with unknown representations were accepted, such
         as T20363. Now that we are stricter, this caused further issues,
         culminating in Core Lint errors. However, the behaviour was
         incorrect the whole time; the incorrectness only being revealed by
         this change, not triggered by it.
    
         This patch fixes this by overhauling where the representation
         polymorphism involving pattern matching are done. Instead of doing
         it in `tcMatches`, we instead ensure that the `matchExpected`
         functions such as `matchExpectedFunTys`, `matchActualFunTySigma`,
         `matchActualFunTysRho` allow return argument pattern types which
         have a fixed RuntimeRep (as defined in Note [Fixed RuntimeRep]).
         This ensures that the pattern matching code only ever handles types
         with a known runtime representation. One exception was that
         patterns with an unknown representation type could sneak in via
         `tcConPat`, which points to a missing representation-polymorphism
         check, which this patch now adds.
    
         This means that we now reject the program in #20363, at least until
         we implement PHASE 2 of FixedRuntimeRep (allowing type families in
         RuntimeRep positions). The aforementioned refactoring, in which
         checks have been moved to `matchExpected` functions, is a first
         step in implementing PHASE 2 for patterns.
    
    Fixes #20837
    
    - - - - -
    8ff32124 by Sebastian Graf at 2022-03-14T15:09:01-04:00
    DmdAnal: Don't unbox recursive data types (#11545)
    
    As `Note [Demand analysis for recursive data constructors]` describes, we now
    refrain from unboxing recursive data type arguments, for two reasons:
    
     1. Relating to run/alloc perf: Similar to
        `Note [CPR for recursive data constructors]`, it seldomly improves run/alloc
        performance if we just unbox a finite number of layers of a potentially huge
        data structure.
     2. Relating to ghc/alloc perf: Inductive definitions on single-product
        recursive data types like the one in T11545 will (diverge, and) have very
        deep demand signatures before any other abortion mechanism in Demand
        analysis is triggered. That leads to great and unnecessary churn on Demand
        analysis when ultimately we will never make use of any nested strictness
        information anyway.
    
    Conclusion: Discard nested demand and boxity information on such recursive types
    with the help of `Note [Detecting recursive data constructors]`.
    
    I also implemented `GHC.Types.Unique.MemoFun.memoiseUniqueFun` in order to avoid
    the overhead of repeated calls to `GHC.Core.Opt.WorkWrap.Utils.isRecDataCon`.
    It's nice and simple and guards against some smaller regressions in T9233 and
    T16577.
    
    ghc/alloc performance-wise, this patch is a very clear win:
    
                                   Test    Metric          value      New value Change
    ---------------------------------------------------------------------------------------
                    LargeRecord(normal) ghc/alloc  6,141,071,720  6,099,871,216  -0.7%
    MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,740,973,040  2,705,146,640  -1.3%
                         T11545(normal) ghc/alloc    945,475,492     85,768,928 -90.9% GOOD
                         T13056(optasm) ghc/alloc    370,245,880    326,980,632 -11.7% GOOD
                         T18304(normal) ghc/alloc     90,933,944     76,998,064 -15.3% GOOD
                         T9872a(normal) ghc/alloc  1,800,576,840  1,792,348,760  -0.5%
                         T9872b(normal) ghc/alloc  2,086,492,432  2,073,991,848  -0.6%
                         T9872c(normal) ghc/alloc  1,750,491,240  1,737,797,832  -0.7%
           TcPlugin_RewritePerf(normal) ghc/alloc  2,286,813,400  2,270,957,896  -0.7%
    
                              geo. mean                                          -2.9%
    
    No noteworthy change in run/alloc either.
    
    NoFib results show slight wins, too:
    
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
        constraints          -1.9%     -1.4%
              fasta          -3.6%     -2.7%
    reverse-complem          -0.3%     -0.9%
           treejoin          -0.0%     -0.3%
    --------------------------------------------------------------------------------
                Min          -3.6%     -2.7%
                Max          +0.1%     +0.1%
     Geometric Mean          -0.1%     -0.1%
    
    Metric Decrease:
        T11545
        T13056
        T18304
    
    - - - - -
    ab618309 by Vladislav Zavialov at 2022-03-15T18:34:38+03:00
    Export (~) from Data.Type.Equality (#18862)
    
    * Users can define their own (~) type operator
    * Haddock can display documentation for the built-in (~)
    * New transitional warnings implemented:
        -Wtype-equality-out-of-scope
        -Wtype-equality-requires-operators
    
    Updates the haddock submodule.
    
    - - - - -
    577135bf by Aaron Allen at 2022-03-16T02:27:48-04:00
    Convert Diagnostics in GHC.Tc.Gen.Foreign
    
    Converts all uses of 'TcRnUnknownMessage' to proper diagnostics.
    
    - - - - -
    c1fed9da by Aaron Allen at 2022-03-16T02:27:48-04:00
    Suggest FFI extensions as hints (#20116)
    
    - Use extension suggestion hints instead of suggesting extensions in the
    error message body for several FFI errors.
    - Adds a test case for `TcRnForeignImportPrimExtNotSet`
    
    - - - - -
    a33d1045 by Zubin Duggal at 2022-03-16T02:28:24-04:00
    TH: allow negative patterns in quotes (#20711)
    
    We still don't allow negative overloaded patterns. Earler all negative patterns
    were treated as negative overloaded patterns. Now, we expliclty check the
    extension field to see if the pattern is actually a negative overloaded pattern
    
    - - - - -
    1575c4a5 by Sebastian Graf at 2022-03-16T02:29:03-04:00
    Demand: Let `Boxed` win in `lubBoxity` (#21119)
    
    Previously, we let `Unboxed` win in `lubBoxity`, which is unsoundly optimistic
    in terms ob Boxity analysis. "Unsoundly" in the sense that we sometimes unbox
    parameters that we better shouldn't unbox. Examples are #18907 and T19871.absent.
    
    Until now, we thought that this hack pulled its weight becuase it worked around
    some shortcomings of the phase separation between Boxity analysis and CPR
    analysis. But it is a gross hack which caused regressions itself that needed all
    kinds of fixes and workarounds. See for example #20767. It became impossible to
    work with in !7599, so I want to remove it.
    
    For example, at the moment, `lubDmd B dmd` will not unbox `dmd`,
    but `lubDmd A dmd` will. Given that `B` is supposed to be the bottom element of
    the lattice, it's hardly justifiable to get a better demand when `lub`bing with
    `A`.
    
    The consequence of letting `Boxed` win in `lubBoxity` is that we *would* regress
     #2387, #16040 and parts of #5075 and T19871.sumIO, until Boxity and CPR
    are able to communicate better. Fortunately, that is not the case since I could
    tweak the other source of optimism in Boxity analysis that is described in
    `Note [Unboxed demand on function bodies returning small products]` so that
    we *recursively* assume unboxed demands on function bodies returning small
    products. See the updated Note.
    
    `Note [Boxity for bottoming functions]` describes why we need bottoming
    functions to have signatures that say that they deeply unbox their arguments.
    In so doing, I had to tweak `finaliseArgBoxities` so that it will never unbox
    recursive data constructors. This is in line with our handling of them in CPR.
    I updated `Note [Which types are unboxed?]` to reflect that.
    
    In turn we fix #21119, #20767, #18907, T19871.absent and get a much simpler
    implementation (at least to think about). We can also drop the very ad-hoc
    definition of `deferAfterPreciseException` and its Note in favor of the
    simple, intuitive definition we used to have.
    
    Metric Decrease:
        T16875
        T18223
        T18698a
        T18698b
        hard_hole_fits
    Metric Increase:
        LargeRecord
        MultiComponentModulesRecomp
        T15703
        T8095
        T9872d
    
    Out of all the regresions, only the one in T9872d doesn't vanish in a perf
    build, where the compiler is bootstrapped with -O2 and thus SpecConstr.
    Reason for regressions:
    
      * T9872d is due to `ty_co_subst` taking its `LiftingContext` boxed.
        That is because the context is passed to a function argument, for
        example in `liftCoSubstTyVarBndrUsing`.
      * In T15703, LargeRecord and T8095, we get a bit more allocations in
        `expand_syn` and `piResultTys`, because a `TCvSubst` isn't unboxed.
        In both cases that guards against reboxing in some code paths.
      * The same is true for MultiComponentModulesRecomp, where we get less unboxing
        in `GHC.Unit.Finder.$wfindInstalledHomeModule`. In a perf build, allocations
        actually *improve* by over 4%!
    
    Results on NoFib:
    
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             awards          -0.4%     +0.3%
          cacheprof          -0.3%     +2.4%
                fft          -1.5%     -5.1%
           fibheaps          +1.2%     +0.8%
              fluid          -0.3%     -0.1%
                ida          +0.4%     +0.9%
       k-nucleotide          +0.4%     -0.1%
         last-piece         +10.5%    +13.9%
               lift          -4.4%     +3.5%
            mandel2         -99.7%    -99.8%
               mate          -0.4%     +3.6%
             parser          -1.0%     +0.1%
             puzzle         -11.6%     +6.5%
    reverse-complem          -3.0%     +2.0%
                scs          -0.5%     +0.1%
             sphere          -0.4%     -0.2%
          wave4main          -8.2%     -0.3%
    --------------------------------------------------------------------------------
    Summary excludes mandel2 because of excessive bias
                Min         -11.6%     -5.1%
                Max         +10.5%    +13.9%
     Geometric Mean          -0.2%     +0.3%
    --------------------------------------------------------------------------------
    
    Not bad for a bug fix.
    
    The regression in `last-piece` could become a win if SpecConstr would work on
    non-recursive functions. The regression in `fibheaps` is due to
    `Note [Reboxed crud for bottoming calls]`, e.g., #21128.
    
    - - - - -
    bb779b90 by sheaf at 2022-03-16T02:29:42-04:00
    Add a regression test for #21130
    
    This problem was due to a bug in cloneWanted, which was incorrectly
    creating a coercion hole to hold an evidence variable.
    
    This bug was introduced by 8bb52d91 and fixed in 81740ce8.
    
    Fixes #21130
    
    - - - - -
    0f0e2394 by Tamar Christina at 2022-03-17T10:16:37-04:00
    linker: Initial Windows C++ exception unwinding support
    
    - - - - -
    36d20d4d by Tamar Christina at 2022-03-17T10:16:37-04:00
    linker: Fix ADDR32NB relocations on Windows
    
    - - - - -
    8a516527 by Tamar Christina at 2022-03-17T10:16:37-04:00
    testsuite: properly escape string paths
    
    - - - - -
    1a0dd008 by sheaf at 2022-03-17T10:17:13-04:00
    Hadrian: account for change in late-ccs flag
    
    The late cost centre flag was renamed from -fprof-late-ccs
    to -fprof-late in 7fe07143, but this change hadn't been
    propagated to Hadrian.
    
    - - - - -
    8561c1af by romes at 2022-03-18T05:10:58-04:00
    TTG: Refactor HsBracket
    
    - - - - -
    19163397 by romes at 2022-03-18T05:10:58-04:00
    Type-checking untyped brackets
    
    When HsExpr GhcTc, the HsBracket constructor should hold a HsBracket
    GhcRn, rather than an HsBracket GhcTc.
    
    We make use of the HsBracket p extension constructor (XBracket
    (XXBracket p)) to hold an HsBracket GhcRn when the pass is GhcTc
    
    See !4782 https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782
    
    - - - - -
    310890a5 by romes at 2022-03-18T05:10:58-04:00
    Separate constructors for typed and untyped brackets
    
    Split HsBracket into HsTypedBracket and HsUntypedBracket.
    
    Unfortunately, we still cannot get rid of
    
        instance XXTypedBracket GhcTc = HsTypedBracket GhcRn
    
    despite no longer requiring it for typechecking, but rather because the
    TH desugarer works on GhcRn rather than GhcTc (See GHC.HsToCore.Quote)
    
    - - - - -
    4a2567f5 by romes at 2022-03-18T05:10:58-04:00
    TTG: Refactor bracket for desugaring during tc
    
    When desugaring a bracket we want to desugar /renamed/ rather than
    /typechecked/ code; So in (HsExpr GhcTc) tree, we must
    have a (HsExpr GhcRn) for the quotation itself.
    
    This commit reworks the TTG refactor on typed and untyped brackets by
    storing the /renamed/ code in the bracket field extension rather than in
    the constructor extension in `HsQuote` (previously called
    `HsUntypedBracket`)
    
    See Note [The life cycle of a TH quotation] and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782
    
    - - - - -
    b056adc8 by romes at 2022-03-18T05:10:58-04:00
    TTG: Make HsQuote GhcTc isomorphic to NoExtField
    
    An untyped bracket `HsQuote p` can never be constructed with
    `p ~ GhcTc`. This is because we don't typecheck `HsQuote` at all.
    
    That's OK, because we also never use `HsQuote GhcTc`.
    
    To enforce this at the type level we make `HsQuote GhcTc` isomorphic
    to `NoExtField` and impossible to construct otherwise, by using TTG field
    extensions to make all constructors, except for `XQuote` (which takes `NoExtField`),
    unconstructable, with `DataConCantHappen`
    
    This is explained more in detail in Note [The life cycle of a TH quotation]
    
    Related discussion: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782
    
    - - - - -
    ac3b2e7d by romes at 2022-03-18T05:10:58-04:00
    TTG: TH brackets finishing touches
    
    Rewrite the critical notes and fix outdated ones,
    
    use `HsQuote GhcRn` (in `HsBracketTc`) for desugaring regardless of the
    bracket being typed or untyped,
    
    remove unused `EpAnn` from `Hs*Bracket GhcRn`,
    
    zonkExpr factor out common brackets code,
    
    ppr_expr factor out common brackets code,
    
    and fix tests,
    
    to finish MR https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782.
    
    -------------------------
    Metric Decrease:
        hard_hole_fits
    -------------------------
    
    - - - - -
    d147428a by Ben Gamari at 2022-03-18T05:11:35-04:00
    codeGen: Fix signedness of jump table indexing
    
    Previously while constructing the jump table index we would
    zero-extend the discriminant before subtracting the start of the
    jump-table. This goes subtly wrong in the case of a sub-word, signed
    discriminant, as described in the included Note. Fix this in both the
    PPC and X86 NCGs.
    
    Fixes #21186.
    
    - - - - -
    435a3d5d by Ben Gamari at 2022-03-18T05:11:35-04:00
    testsuite: Add test for #21186
    
    - - - - -
    e9d8de93 by Zubin Duggal at 2022-03-19T07:35:49-04:00
    TH: Fix pretty printing of newtypes with operators and GADT syntax (#20868)
    
    The pretty printer for regular data types already accounted for these,
    and had some duplication with the newtype pretty printer.
    
    Factoring the logic out into a common function and using it for both
    newtypes and data declarations is enough to fix the bug.
    
    - - - - -
    244da9eb by sheaf at 2022-03-19T07:36:24-04:00
    List GHC.Event.Internal in base.cabal on Windows
    
    GHC.Event.Internal was not listed in base.cabal on Windows. This caused
    undefined reference errors. This patch adds it back, by moving it out
    of the OS-specific logic in base.cabal.
    
    Fixes #21245.
    - - - - -
    d1c03719 by Andreas Klebinger at 2022-03-19T07:37:00-04:00
    Compact regions: Maintain tags properly
    
    Fixes #21251
    
    - - - - -
    d45bb701 by romes at 2022-03-19T07:37:36-04:00
    Remove dead code HsDoRn
    
    - - - - -
    c842611f by nineonine at 2022-03-20T21:16:06-04:00
    Revamp derived Eq instance code generation (#17240)
    
    This patch improves code generation for derived Eq instances.
    The idea is to use 'dataToTag' to evaluate both arguments.
    This allows to 'short-circuit' when tags do not match.
    Unfortunately, inner evals are still present when we branch
    on tags. This is due to the way 'dataToTag#' primop
    evaluates its argument in the code generator. #21207 was
    created to explore further optimizations.
    
    Metric Decrease:
        LargeRecord
    
    - - - - -
    52ffd38c by Sylvain Henry at 2022-03-20T21:16:46-04:00
    Avoid some SOURCE imports
    
    - - - - -
    b91798be by Zubin Duggal at 2022-03-23T13:39:39-04:00
    hi haddock: Lex and store haddock docs in interface files
    
    Names appearing in Haddock docstrings are lexed and renamed like any other names
    appearing in the AST. We currently rename names irrespective of the namespace,
    so both type and constructor names corresponding to an identifier will appear in
    the docstring. Haddock will select a given name as the link destination based on
    its own heuristics.
    
    This patch also restricts the limitation of `-haddock` being incompatible with
    `Opt_KeepRawTokenStream`.
    
    The export and documenation structure is now computed in GHC and serialised in
    .hi files. This can be used by haddock to directly generate doc pages without
    reparsing or renaming the source. At the moment the operation of haddock
    is not modified, that's left to a future patch.
    
    Updates the haddock submodule with the minimum changes needed.
    
    - - - - -
    78db231f by Cheng Shao at 2022-03-23T13:40:17-04:00
    configure: bump LlvmMaxVersion to 14
    
    LLVM 13.0.0 is released in Oct 2021, and latest head validates against
    LLVM 13 just fine if LlvmMaxVersion is bumped.
    
    - - - - -
    b06e5dd8 by Adam Sandberg Ericsson at 2022-03-23T13:40:54-04:00
    docs: clarify the eventlog format documentation a little bit
    
    - - - - -
    4dc62498 by Matthew Pickering at 2022-03-23T13:41:31-04:00
    Fix behaviour of -Wunused-packages in ghci
    
    Ticket #21110 points out that -Wunused-packages behaves a bit unusually
    in GHCi. Now we define the semantics for -Wunused-packages in
    interactive mode as follows:
    
    * If you use -Wunused-packages on an initial load then the warning is reported.
    * If you explicitly set -Wunused-packages on the command line then the
      warning is displayed (until it is disabled)
    * If you then subsequently modify the set of available targets by using
      :load or :cd (:cd unloads everything) then the warning is (silently)
      turned off.
    
    This means that every :r the warning is printed if it's turned on (but you did ask for it).
    
    Fixes #21110
    
    - - - - -
    fed05347 by Ben Gamari at 2022-03-23T13:42:07-04:00
    rts/adjustor: Place adjustor templates in data section on all OSs
    
    In !7604 we started placing adjustor templates in the data section on
    Linux as some toolchains there reject relocations in the text section.
    However, it turns out that OpenBSD also exhibits this restriction.
    
    Fix this by *always* placing adjustor templates in the data section.
    
    Fixes #21155.
    
    - - - - -
    db32bb8c by Zubin Duggal at 2022-03-23T13:42:44-04:00
    Improve error message when warning about unsupported LLVM version (#20958)
    
    Change the wording to make it clear that the upper bound is non-inclusive.
    
    - - - - -
    f214349a by Ben Gamari at 2022-03-23T13:43:20-04:00
    rts: Untag function field in scavenge_PAP_payload
    
    Previously we failed to untag the function closure when scavenging the
    payload of a PAP, resulting in an invalid closure pointer being passed
    to scavenge_large_bitmap and consequently #21254. Fix this.
    
    Fixes #21254
    
    - - - - -
    e6d0e287 by Ben Gamari at 2022-03-23T13:43:20-04:00
    rts: Don't mark object code in markCAFs unless necessary
    
    Previously `markCAFs` would call `markObjectCode` even in non-major GCs.
    This is problematic since `prepareUnloadCheck` is not called in such
    GCs, meaning that the section index has not been updated.
    
    Fixes #21254
    
    - - - - -
    1a7cf096 by Sylvain Henry at 2022-03-23T13:44:05-04:00
    Avoid redundant imports of GHC.Driver.Session
    
    Remove GHC.Driver.Session imports that weren't considered as redundant
    because of the reexport of PlatformConstants. Also remove this reexport
    as modules using this datatype should import GHC.Platform instead.
    
    - - - - -
    e3f60577 by Sylvain Henry at 2022-03-23T13:44:05-04:00
    Reverse dependency between StgToCmm and Runtime.Heap.Layout
    
    - - - - -
    e6585ca1 by Sylvain Henry at 2022-03-23T13:44:46-04:00
    Define filterOut with filter
    
    filter has fusion rules that filterOut lacks
    
    - - - - -
    c58d008c by Ryan Scott at 2022-03-24T06:10:43-04:00
    Fix and simplify DeriveAnyClass's context inference using SubTypePredSpec
    
    As explained in `Note [Gathering and simplifying constraints for DeriveAnyClass]`
    in `GHC.Tc.Deriv.Infer`, `DeriveAnyClass` infers instance contexts by emitting
    implication constraints. Previously, these implication constraints were
    constructed by hand. This is a terribly trick thing to get right, as it
    involves a delicate interplay of skolemisation, metavariable instantiation, and
    `TcLevel` bumping. Despite much effort, we discovered in #20719 that the
    implementation was subtly incorrect, leading to valid programs being rejected.
    
    While we could scrutinize the code that manually constructs implication
    constraints and repair it, there is a better, less error-prone way to do
    things. After all, the heart of `DeriveAnyClass` is generating code which
    fills in each class method with defaults, e.g., `foo = $gdm_foo`. Typechecking
    this sort of code is tantamount to calling `tcSubTypeSigma`, as we much ensure
    that the type of `$gdm_foo` is a subtype of (i.e., more polymorphic than) the
    type of `foo`. As an added bonus, `tcSubTypeSigma` is a battle-tested function
    that handles skolemisation, metvariable instantiation, `TcLevel` bumping, and
    all other means of tricky bookkeeping correctly.
    
    With this insight, the solution to the problems uncovered in #20719 is simple:
    use `tcSubTypeSigma` to check if `$gdm_foo`'s type is a subtype of `foo`'s
    type. As a side effect, `tcSubTypeSigma` will emit exactly the implication
    constraint that we were attempting to construct by hand previously. Moreover,
    it does so correctly, fixing #20719 as a consequence.
    
    This patch implements the solution thusly:
    
    * The `PredSpec` data type (previously named `PredOrigin`) is now split into
      `SimplePredSpec`, which directly stores a `PredType`, and `SubTypePredSpec`,
      which stores the actual and expected types in a subtype check.
      `SubTypePredSpec` is only used for `DeriveAnyClass`; all other deriving
      strategies use `SimplePredSpec`.
    * Because `tcSubTypeSigma` manages the finer details of type variable
      instantiation and constraint solving under the hood, there is no longer any
      need to delicately split apart the method type signatures in
      `inferConstraintsAnyclass`. This greatly simplifies the implementation of
      `inferConstraintsAnyclass` and obviates the need to store skolems,
      metavariables, or given constraints in a `ThetaSpec` (previously named
      `ThetaOrigin`). As a bonus, this means that `ThetaSpec` now simply becomes a
      synonym for a list of `PredSpec`s, which is conceptually much simpler than it
      was before.
    * In `simplifyDeriv`, each `SubTypePredSpec` results in a call to
      `tcSubTypeSigma`. This is only performed for its side effect of emitting
      an implication constraint, which is fed to the rest of the constraint solving
      machinery in `simplifyDeriv`. I have updated
      `Note [Gathering and simplifying constraints for DeriveAnyClass]` to explain
      this in more detail.
    
    To make the changes in `simplifyDeriv` more manageable, I also performed some
    auxiliary refactoring:
    
    * Previously, every iteration of `simplifyDeriv` was skolemising the type
      variables at the start, simplifying, and then performing a reverse
      substitution at the end to un-skolemise the type variables. This is not
      necessary, however, since we can just as well skolemise once at the
      beginning of the `deriving` pipeline and zonk the `TcTyVar`s after
      `simplifyDeriv` is finished. This patch does just that, having been made
      possible by prior work in !7613. I have updated `Note [Overlap and deriving]`
      in `GHC.Tc.Deriv.Infer` to explain this, and I have also left comments on
      the relevant data structures (e.g., `DerivEnv` and `DerivSpec`) to explain
      when things might be `TcTyVar`s or `TyVar`s.
    * All of the aforementioned cleanup allowed me to remove an ad hoc
      deriving-related in `checkImplicationInvariants`, as all of the skolems in
      a `tcSubTypeSigma`–produced implication constraint should now be `TcTyVar`
      at the time the implication is created.
    * Since `simplifyDeriv` now needs a `SkolemInfo` and `UserTypeCtxt`, I have
      added `ds_skol_info` and `ds_user_ctxt` fields to `DerivSpec` to store these.
      Similarly, I have also added a `denv_skol_info` field to `DerivEnv`, which
      ultimately gets used to initialize the `ds_skol_info` in a `DerivSpec`.
    
    Fixes #20719.
    
    - - - - -
    21680fb0 by Sebastian Graf at 2022-03-24T06:11:19-04:00
    WorkWrap: Handle partial FUN apps in `isRecDataCon` (#21265)
    
    Partial FUN apps like `(->) Bool` aren't detected by `splitFunTy_maybe`.
    A silly oversight that is easily fixed by replacing `splitFunTy_maybe` with a
    guard in the `splitTyConApp_maybe` case.
    
    But fortunately, Simon nudged me into rewriting the whole `isRecDataCon`
    function in a way that makes it much shorter and hence clearer which DataCons
    are actually considered as recursive.
    
    Fixes #21265.
    
    - - - - -
    a2937e2b by Matthew Pickering at 2022-03-24T17:13:22-04:00
    Add test for T21035
    
    This test checks that you are allowed to explicitly supply object files
    for dependencies even if you haven't got the shared object for that
    library yet.
    
    Fixes #21035
    
    - - - - -
    1756d547 by Matthew Pickering at 2022-03-24T17:13:58-04:00
    Add check to ensure we are not building validate jobs for releases
    
    - - - - -
    99623358 by Matthew Pickering at 2022-03-24T17:13:58-04:00
    hadrian: Correct generation of hsc2hs wrapper
    
    If you inspect the inside of a wrapper script for hsc2hs you will see
    that the cflag and lflag values are concatenated incorrectly.
    
    ```
    HSC2HS_EXTRA="--cflag=-U__i686--lflag=-fuse-ld=gold"
    ```
    
    It should instead be
    
    ```
    HSC2HS_EXTRA="--cflag=-U__i686 --lflag=-fuse-ld=gold"
    ```
    
    Fixes #21221
    
    - - - - -
    fefd4e31 by Matthew Pickering at 2022-03-24T17:13:59-04:00
    testsuite: Remove library dependenices from T21119
    
    These dependencies would affect the demand signature depending on
    various rules and so on.
    
    Fixes #21271
    
    - - - - -
    5ff690b8 by Matthew Pickering at 2022-03-24T17:13:59-04:00
    ci: Generate jobs for all normal builds and use hadrian for all builds
    
    This commit introduces a new script (.gitlab/gen_ci.hs) which generates
    a yaml file (.gitlab/jobs.yaml) which contains explicit descriptions for
    all the jobs we want to run. The jobs are separated into three
    categories:
    
    * validate - jobs run on every MR
    * nightly  - jobs run once per day on the master branch
    * release  - jobs for producing release artifacts
    
    The generation script is a Haskell program which includes a DSL for
    specifying the different jobs. The hope is that it's easier to reason
    about the different jobs and how the variables are merged together
    rather than the unclear and opaque yaml syntax. The goal is to fix
    issues like #21190 once and for all..
    
    The `.gitlab/jobs.yaml` can be generated by running the `.gitlab/generate_jobs`
    script. You have to do this manually.
    
    Another consequence of this patch is that we use hadrian for all the
    validate, nightly and release builds on all platforms.
    
    - - - - -
    1d673aa2 by Christiaan Baaij at 2022-03-25T11:35:49-04:00
    Add the OPAQUE pragma
    
    A new pragma, `OPAQUE`, that ensures that every call of a named
    function annotated with an `OPAQUE` pragma remains a call of that
    named function, not some name-mangled variant.
    
    Implements GHC proposal 0415:
    https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst
    
    This commit also updates the haddock submodule to handle the newly
    introduced lexer tokens corresponding to the OPAQUE pragma.
    
    - - - - -
    83f5841b by Andrew Lelechenko at 2022-03-25T11:36:31-04:00
    Add instance Lift ByteArray
    
    - - - - -
    7cc1184a by Matthew Pickering at 2022-03-25T11:37:07-04:00
    Make -ddump-rn-ast and -ddump-tc-ast work in GHCi
    
    Fixes #17830
    
    - - - - -
    940feaf3 by Sylvain Henry at 2022-03-25T11:37:47-04:00
    Modularize Tidy (#17957)
    
    - Factorize Tidy options into TidyOpts datatype. Initialize it in
      GHC.Driver.Config.Tidy
    - Same thing for StaticPtrOpts
    - Perform lookups of unpackCString[Utf8]# once in initStaticPtrOpts
      instead of for every use of mkStringExprWithFS
    
    - - - - -
    25101813 by Takenobu Tani at 2022-03-28T01:16:02-04:00
    users-guide: Correct markdown for profiling
    
    This patch corrects some markdown.
    
    [skip ci]
    
    - - - - -
    c832ae93 by Matthew Pickering at 2022-03-28T01:16:38-04:00
    hadrian: Flag cabal flag handling
    
    This patch basically deletes some ad-hoc handling of Cabal Flags and
    replaces it with a correct query of the LocalBuildInfo. The flags in the
    local build info can be modified by users by passing hadrian options
    
    For example (!4331)
    
    ```
    *.genapply.cabal.configure.opts += --flags=unregisterised
    ```
    
    And all the flags specified by the `Cabal Flags` builder were already
    passed to configure properly using `--flags`.
    
    - - - - -
    a9f3a5c6 by Ben Gamari at 2022-03-28T01:16:38-04:00
    Disable text's dependency on simdutf by default
    
    Unfortunately we are simply not currently in a good position to robustly
    ship binary distributions which link against C++ code like simdutf.
    
    Fixes #20724.
    
    - - - - -
    eff86e8a by Richard Eisenberg at 2022-03-28T01:17:14-04:00
    Add Red Herring to Note [What might equal later?]
    
    Close #21208.
    
    - - - - -
    12653be9 by jberryman at 2022-03-28T01:17:55-04:00
    Document typed splices inhibiting unused bind detection (#16524)
    - - - - -
    4aeade15 by Adam Sandberg Ericsson at 2022-03-28T01:18:31-04:00
    users-guide: group ticky-ticky profiling under one heading
    
    - - - - -
    cc59648a by Sylvain Henry at 2022-03-28T01:19:12-04:00
    Hadrian: allow testsuite to run with cross-compilers (#21292)
    
    - - - - -
    89cb1315 by Matthew Pickering at 2022-03-28T01:19:48-04:00
    hadrian: Add show target to bindist makefile
    
    Some build systems use "make show" to query facts about the bindist, for
    example:
    
    ```
    make show VALUE=ProjectVersion > version
    ```
    
    to determine the ProjectVersion
    
    - - - - -
    8229885c by Alan Zimmerman at 2022-03-28T19:23:28-04:00
    EPA: let stmt with semicolon has wrong anchor
    
    The code
    
       let ;x =1
    
    Captures the semicolon annotation, but did not widen the anchor in the
    ValBinds.
    
    Fix that.
    
    Closes #20247
    
    - - - - -
    2c12627c by Ryan Scott at 2022-03-28T19:24:04-04:00
    Consistently attach SrcSpans to sub-expressions in TH splices
    
    Before, `GHC.ThToHs` was very inconsistent about where various sub-expressions
    would get the same `SrcSpan` from the original TH splice location or just a
    generic `noLoc` `SrcSpan`. I have ripped out all uses of `noLoc` in favor of
    the former instead, and I have added a
    `Note [Source locations within TH splices]` to officially enshrine this
    design choice.
    
    Fixes #21299.
    
    - - - - -
    789add55 by Zubin Duggal at 2022-03-29T13:07:22-04:00
    Fix all invalid haddock comments in the compiler
    
    Fixes #20935 and #20924
    
    - - - - -
    967dad03 by Zubin Duggal at 2022-03-29T13:07:22-04:00
    hadrian: Build lib:GHC with -haddock and -Winvalid-haddock (#21273)
    
    - - - - -
    ad09a5f7 by sheaf at 2022-03-29T13:08:05-04:00
    Hadrian: make DDEBUG separate from debugged RTS
    
    This patchs separates whether -DDEBUG is enabled (i.e. whether debug
    assertions are enabled) from whether we are using the debugged RTS
    (i.e. GhcDebugged = YES).
    
    This means that we properly skip tests which have been marked with
    `when(compiler_debugged(), skip)`.
    
    Fixes #21113, #21153 and #21234
    
    - - - - -
    840a6811 by Matthew Pickering at 2022-03-29T13:08:42-04:00
    RTS: Zero gc_cpu_start and gc_cpu_end after accounting
    
    When passed a combination of `-N` and `-qn` options the cpu time for
    garbage collection was being vastly overcounted because the counters
    were not being zeroed appropiately.
    
    When -qn1 is passed, only 1 of the N avaiable GC threads is chosen to
    perform work, the rest are idle. At the end of the GC period, stat_endGC
    traverses all the GC threads and adds up the elapsed time from each of
    them. For threads which didn't participate in this GC, the value of the
    cpu time should be zero, but before this patch, the counters were not
    zeroed and hence we would count the same elapsed time on many subsequent
    iterations (until the thread participated in a GC again).
    
    The most direct way to zero these fields is to do so immediately after
    the value is added into the global counter, after which point they are
    never used again.
    
    We also tried another approach where we would zero the counter in
    yieldCapability but there are some (undiagnosed) siations where a
    capbility would not pass through yieldCapability before the GC ended and
    the same double counting problem would occur.
    
    Fixes #21082
    
    - - - - -
    dda46e2d by Matthew Pickering at 2022-03-29T13:09:18-04:00
    Add test for T21306
    
    Fixes #21306
    
    - - - - -
    f07c7766 by Jakob Brünker at 2022-03-30T03:10:33-04:00
    Give parsing plugins access to errors
    
    Previously, when the parser produced non-fatal errors (i.e. it produced
    errors but the 'PState' is 'POk'), compilation would be aborted before
    the 'parsedResultAction' of any plugin was invoked. This commit changes
    that, so that such that 'parsedResultAction' gets collections of
    warnings and errors as argument, and must return them after potentially
    modifying them.
    
    Closes #20803
    
    - - - - -
    e5dfde75 by Ben Gamari at 2022-03-30T03:11:10-04:00
    Fix reference to Note [FunBind vs PatBind]
    
    This Note was renamed in 2535a6716202253df74d8190b028f85cc6d21b72 yet
    this occurrence was not updated.
    
    - - - - -
    21894a63 by Krzysztof Gogolewski at 2022-03-30T03:11:45-04:00
    Refactor: make primtypes independent of PrimReps
    
    Previously, 'pcPrimTyCon', the function used to define a primitive type,
    was taking a PrimRep, only to convert it to a RuntimeRep. Now it takes
    a RuntimeRep directly.
    
    Moved primRepToRuntimeRep to GHC.Types.RepType. It is now
    located next to its inverse function runtimeRepPrimRep.
    Now GHC.Builtin.Types.Prim no longer mentions PrimRep, and GHC.Types.RepType
    no longer imports GHC.Builtin.Types.Prim.
    
    Removed unused functions `primRepsToRuntimeRep` and `mkTupleRep`.
    
    Removed Note [PrimRep and kindPrimRep] - it was never referenced,
    didn't belong to Types.Prim, and Note [Getting from RuntimeRep to
    PrimRep] is more comprehensive.
    
    - - - - -
    43da2963 by Matthew Pickering at 2022-03-30T09:55:49+01:00
    Fix mention of non-existent "rehydrateIface" function [skip ci]
    
    Fixes #21303
    
    - - - - -
    6793a20f by gershomb at 2022-04-01T10:33:46+01:00
    Remove wrong claim about naturality law.
    
    This docs change removes a longstanding confusion in the Traversable
    docs. The docs say "(The naturality law is implied by parametricity and
    thus so is the purity law [1, p15].)". However if one reads the
    reference a different "natural" law is implied by parametricity. The
    naturality law given as a law here is imposed. Further, the reference
    gives examples which violate both laws -- so they cannot be implied by
    parametricity. This PR just removes the wrong claim.
    
    - - - - -
    5beeff46 by Ben Gamari at 2022-04-01T10:34:39+01:00
    Refactor handling of global initializers
    
    GHC uses global initializers for a number of things including
    cost-center registration, info-table provenance registration, and setup
    of foreign exports. Previously, the global initializer arrays which
    referenced these initializers would live in the object file of the C
    stub, which would then be merged into the main object file of the
    module.
    
    Unfortunately, this approach is no longer tenable with the move to
    Clang/LLVM on Windows (see #21019). Specifically, lld's PE backend does
    not support object merging (that is, the -r flag). Instead we are now
    rather packaging a module's object files into a static library. However,
    this is problematic in the case of initializers as there are no
    references to the C stub object in the archive, meaning that the linker
    may drop the object from the final link.
    
    This patch refactors our handling of global initializers to instead
    place initializer arrays within the object file of the module to which
    they belong. We do this by introducing a Cmm data declaration containing
    the initializer array in the module's Cmm stream. While the initializer
    functions themselves remain in separate C stub objects, the reference
    from the module's object ensures that they are not dropped from the
    final link.
    
    In service of #21068.
    
    - - - - -
    3e6fe71b by Matthew Pickering at 2022-04-01T10:35:41+01:00
    Fix remaining issues in eventlog types (gen_event_types.py)
    
    *  The size of End concurrent mark phase looks wrong and, it used to be 4 and now it's 0.
    *  The size of Task create is wrong, used to be 18 and now 14.
    *  The event ticky-ticky entry counter begin sample has the wrong name
    *  The event ticky-ticky entry counter being sample has the wrong size, was 0 now 32.
    
    Closes #21070
    
    - - - - -
    7847f47a by Ben Gamari at 2022-04-01T10:35:41+01:00
    users-guide: Fix a few small issues in eventlog format descriptions
    
    The CONC_MARK_END event description didn't mention its payload.
    Clarify the meaning of the CREATE_TASK's payload.
    
    - - - - -
    acfd5a4c by Matthew Pickering at 2022-04-01T10:35:53+01:00
    ci: Regenerate jobs.yaml
    
    It seems I forgot to update this to reflect the current state of
    gen_ci.hs
    
    - - - - -
    a952dd80 by Matthew Pickering at 2022-04-01T10:35:59+01:00
    ci: Attempt to fix windows cache issues
    
    It appears that running the script directly does nothing (no info is
    printed about saving the cache).
    
    - - - - -
    fb65e6e3 by Adrian Ratiu at 2022-04-01T10:49:52+01:00
    fp_prog_ar.m4: take AR var into consideration
    
    In ChromeOS and Gentoo we want the ability to use LLVM ar
    instead of GNU ar even though both are installed, thus we
    pass (for eg) AR=llvm-ar to configure.
    
    Unfortunately GNU ar always gets picked regardless of the
    AR setting because the check does not consider the AR var
    when setting fp_prog_ar, hence this fix.
    
    - - - - -
    1daaefdf by Greg Steuck at 2022-04-01T10:50:16+01:00
    T13366 requires c++ & c++abi libraries on OpenBSD
    
    Fixes this failure:
    
    =====> 1 of 1 [0, 0, 0]
    T13366(normal) 1 of 1 [0, 0, 0] Compile failed (exit code 1) errors were:
    
    <no location info>: error:
        user specified .o/.so/.DLL could not be loaded (File not found)
    Whilst trying to load:  (dynamic) stdc++
    Additional directories searched: (none)
    
    *** unexpected failure for T13366(normal)
    
    - - - - -
    18e6c85b by Jakob Bruenker at 2022-04-01T10:54:28+01:00
    new datatypes for parsedResultAction
    
    Previously, the warnings and errors were given and returned as a tuple
    (Messages PsWarnings, Messages PsErrors). Now, it's just PsMessages.
    
    This, together with the HsParsedModule the parser plugin gets and
    returns, has been wrapped up as ParsedResult.
    
    - - - - -
    9727e592 by Morrow at 2022-04-01T10:55:12+01:00
    Clarify that runghc interprets the input program
    
    - - - - -
    f589dea3 by sheaf at 2022-04-01T10:59:58+01:00
    Unify RuntimeRep arguments in ty_co_match
    
    The `ty_co_match` function ignored the implicit RuntimeRep coercions
    that occur in a `FunCo`. Even though a comment explained that this
    should be fine, #21205 showed that it could result in discarding a
    RuntimeRep coercion, and thus discarding an important cast entirely.
    
    With this patch, we first match the kinds in `ty_co_match`.
    
    Fixes #21205
    
    -------------------------
    Metric Increase:
        T12227
        T18223
    -------------------------
    
    - - - - -
    6f4dc372 by Andreas Klebinger at 2022-04-01T11:01:35+01:00
    Export MutableByteArray from Data.Array.Byte
    
    This implements CLC proposal #49
    
    - - - - -
    5df9f5e7 by ARATA Mizuki at 2022-04-01T11:02:35+01:00
    Add test cases for #20640
    
    Closes #20640
    
    - - - - -
    8334ff9e by Krzysztof Gogolewski at 2022-04-01T11:03:16+01:00
    Minor cleanup
    
    - Remove unused functions exprToCoercion_maybe, applyTypeToArg,
      typeMonoPrimRep_maybe, runtimeRepMonoPrimRep_maybe.
    - Replace orValid with a simpler check
    - Use splitAtList in applyTysX
    - Remove calls to extra_clean in the testsuite; it does not do anything.
    
    Metric Decrease:
        T18223
    
    - - - - -
    b2785cfc by Eric Lindblad at 2022-04-01T11:04:07+01:00
    hadrian typos
    
    - - - - -
    418e6fab by Eric Lindblad at 2022-04-01T11:04:12+01:00
    two typos
    
    - - - - -
    dd7c7c99 by Phil de Joux at 2022-04-01T11:04:56+01:00
    Add tests and docs on plugin args and order.
    
    - - - - -
    3e209a62 by MaxHearnden at 2022-04-01T11:05:19+01:00
    Change may not to might not
    - - - - -
    b84380d3 by Matthew Pickering at 2022-04-01T11:07:27+01:00
    hadrian: Remove linters-common from bindist
    
    Zubin observed that the bindists contains the utility library
    linters-common. There are two options:
    
    1. Make sure only the right files are added into the bindist.. a bit
       tricky due to the non-trivial structure of the lib directory.
    2. Remove the bad files once they get copied in.. a bit easier
    
    So I went for option 2 but we perhaps should go for option 1 in the
    future.
    
    Fixes #21203
    
    - - - - -
    ba9904c1 by Zubin Duggal at 2022-04-01T11:07:31+01:00
    hadrian: allow testing linters with out of tree compilers
    
    - - - - -
    26547759 by Matthew Pickering at 2022-04-01T11:07:35+01:00
    hadrian: Introduce CheckProgram datatype to replace a 7-tuple
    
    - - - - -
    df65d732 by Jakob Bruenker at 2022-04-01T11:08:28+01:00
    Fix panic when pretty printing HsCmdLam
    
    When pretty printing a HsCmdLam with more than one argument, GHC
    panicked because of a missing case. This fixes that.
    
    Closes #21300
    
    - - - - -
    ad6cd165 by John Ericson at 2022-04-01T11:10:06+01:00
    hadrian: Remove vestigial -this-unit-id support check
    
    This has been dead code since 400ead81e80f66ad7b1260b11b2a92f25ccc3e5a.
    
    - - - - -
    8ca7ab81 by Matthew Pickering at 2022-04-01T11:10:23+01:00
    hadrian: Fix race involving empty package databases
    
    There was a small chance of a race occuring between the small window of
    
    1. The first package (.conf) file get written into the database
    2. hadrian calling "ghc-pkg recache" to refresh the package.conf file
    
    In this window the package database would contain rts.conf but not a
    package.cache file, and therefore if ghc was invoked it would error
    because it was missing.
    
    To solve this we call "ghc-pkg recache" at when the database is created
    by shake by writing the stamp file into the database folder. This also
    creates the package.cache file and so avoids the possibility of this
    race.
    
    - - - - -
    cc4ec64b by Matthew Pickering at 2022-04-01T11:11:05+01:00
    hadrian: Add assertion that in/out tree args are the same
    
    There have been a few instances where this calculation was incorrect, so
    we add a non-terminal assertion when now checks they the two
    computations indeed compute the same thing.
    
    Fixes #21285
    
    - - - - -
    691508d8 by Matthew Pickering at 2022-04-01T11:13:10+01:00
    hlint: Ignore suggestions in generated HaddockLex file
    
    With the make build system this file ends up in the compiler/
    subdirectory so is linted. With hadrian, the file ends up in _build so
    it's not linted.
    
    Fixes #21313
    
    - - - - -
    f8f152e7 by Krzysztof Gogolewski at 2022-04-01T11:14:08+01:00
    Change GHC.Prim to GHC.Exts in docs and tests
    
    Users are supposed to import GHC.Exts rather than GHC.Prim.
    Part of #18749.
    
    - - - - -
    f8fc6d2e by Matthew Pickering at 2022-04-01T11:15:24+01:00
    driver: Improve -Wunused-packages error message (and simplify implementation)
    
    In the past I improved the part of -Wunused-packages which found which
    packages were used. Now I improve the part which detects which ones were
    specified. The key innovation is to use the explicitUnits field from
    UnitState which has the result of resolving the package flags, so we
    don't need to mess about with the flag arguments from DynFlags anymore.
    
    The output now always includes the package name and version (and the
    flag which exposed it).
    
    ```
        The following packages were specified via -package or -package-id flags,
        but were not needed for compilation:
          - bytestring-0.11.2.0 (exposed by flag -package bytestring)
          - ghc-9.3 (exposed by flag -package ghc)
          - process-1.6.13.2 (exposed by flag -package process)
    ```
    
    Fixes #21307
    
    - - - - -
    5e5a12d9 by Matthew Pickering at 2022-04-01T11:15:32+01:00
    driver: In oneshot mode, look for interface files in hidir
    
    How things should work:
    
    *  -i is the search path for source files
    *  -hidir explicitly sets the search path for interface files and the output location for interface files.
    *  -odir sets the search path and output location for object files.
    
    Before in one shot mode we would look for the interface file in the
    search locations given by `-i`, but then set the path to be in the
    `hidir`, so in unusual situations the finder could find an interface
    file in the `-i` dir but later fail because it tried to read the
    interface file from the `-hidir`.
    
    A bug identified by #20569
    
    - - - - -
    950f58e7 by Matthew Pickering at 2022-04-01T11:15:36+01:00
    docs: Update documentation interaction of search path, -hidir and -c mode.
    
    As noted in #20569 the documentation for search path was wrong because
    it seemed to indicate that `-i` dirs were important when looking for
    interface files in `-c` mode, but they are not important if `-hidir` is
    set.
    
    Fixes #20569
    
    - - - - -
    d85c7dcb by sheaf at 2022-04-01T11:17:56+01:00
    Keep track of promotion ticks in HsOpTy
    
    This patch adds a PromotionFlag field to HsOpTy, which is used
    in pretty-printing and when determining whether to emit warnings
    with -fwarn-unticked-promoted-constructors.
    
    This allows us to correctly report tick-related warnings for things
    like:
    
      type A = Int : '[]
      type B = [Int, Bool]
    
    Updates haddock submodule
    
    Fixes #19984
    
    - - - - -
    32070e6c by Jakob Bruenker at 2022-04-01T20:31:08+02:00
    Implement \cases (Proposal 302)
    
    This commit implements proposal 302: \cases - Multi-way lambda
    expressions.
    
    This adds a new expression heralded by \cases, which works exactly like
    \case, but can match multiple apats instead of a single pat.
    
    Updates submodule haddock to support the ITlcases token.
    
    Closes #20768
    
    - - - - -
    c6f77f39 by sheaf at 2022-04-01T20:33:05+02:00
    Add a regression test for #21323
    
    This bug was fixed at some point between GHC 9.0 and GHC 9.2;
    this patch simply adds a regression test.
    
    - - - - -
    3596684e by Jakob Bruenker at 2022-04-01T20:33:05+02:00
    Fix error when using empty case in arrow notation
    
    It was previously not possible to use -XEmptyCase in Arrow notation,
    since GHC would print "Exception: foldb of empty list".
    
    This is now fixed.
    
    Closes #21301
    
    - - - - -
    9a325b59 by Ben Gamari at 2022-04-01T20:33:05+02:00
    users-guide: Fix various markup issues
    
    - - - - -
    aefb1e6d by sheaf at 2022-04-01T20:36:01+02:00
    Ensure implicit parameters are lifted
    
    `tcExpr` typechecked implicit parameters by introducing a metavariable
    of kind `TYPE kappa`, without enforcing that `kappa ~ LiftedRep`.
    This patch instead creates a metavariable of kind `Type`.
    
    Fixes #21327
    
    - - - - -
    ed62dc66 by Ben Gamari at 2022-04-05T11:44:51-04:00
    gitlab-ci: Disable cabal-install store caching on Windows
    
    For reasons that remain a mystery, cabal-install seems to consistently
    corrupt its cache on Windows. Disable caching for now.
    
    Works around #21347.
    
    - - - - -
    5ece5c5a by Ryan Scott at 2022-04-06T13:00:51-04:00
    Add /linters/*/dist-install/ to .gitignore
    
    Fixes #21335.
    
    [ci skip]
    
    - - - - -
    410c76ee by Ben Gamari at 2022-04-06T13:01:28-04:00
    Use static archives as an alternative to object merging
    
    Unfortunately, `lld`'s COFF backend does not currently support object
    merging. With ld.bfd having broken support for high image-load base
    addresses, it's necessary to find an alternative. Here I introduce
    support in the driver for generating static archives, which we use on
    Windows instead of object merging.
    
    Closes #21068.
    
    - - - - -
    400666c8 by Ben Gamari at 2022-04-06T13:01:28-04:00
    rts/linker: Catch archives masquerading as object files
    
    Check the file's header to catch static archive bearing the `.o`
    extension, as may happen on Windows after the Clang refactoring.
    
    See #21068
    
    - - - - -
    694d39f0 by Ben Gamari at 2022-04-06T13:01:28-04:00
    driver: Make object merging optional
    
    On Windows we don't have a linker which supports object joining (i.e.
    the `-r` flag). Consequently, `-pgmlm` is now a `Maybe`.
    
    See #21068.
    
    - - - - -
    41fcb5cd by Ben Gamari at 2022-04-06T13:01:28-04:00
    hadrian: Refactor handling of ar flags
    
    Previously the setup was quite fragile as it had to assume which
    arguments were file arguments and which were flags.
    
    - - - - -
    3ac80a86 by Ben Gamari at 2022-04-06T13:01:28-04:00
    hadrian: Produce ar archives with L modifier on Windows
    
    Since object files may in fact be archive files, we must ensure that
    their contents are merged rather than constructing an
    archive-of-an-archive.
    
    See #21068.
    
    - - - - -
    295c35c5 by Ben Gamari at 2022-04-06T13:01:28-04:00
    Add a Note describing lack of object merging on Windows
    
    See #21068.
    
    - - - - -
    d2ae0a3a by Ben Gamari at 2022-04-06T13:01:28-04:00
    Build ar archives with -L when "joining" objects
    
    Since there may be .o files which are in fact archives.
    
    - - - - -
    babb47d2 by Zubin Duggal at 2022-04-06T13:02:04-04:00
    Add warnings for file header pragmas that appear in the body of a module (#20385)
    
    Once we are done parsing the header of a module to obtain the options, we
    look through the rest of the tokens in order to determine if they contain any
    misplaced file header pragmas that would usually be ignored, potentially
    resulting in bad error messages.
    
    The warnings are reported immediately so that later errors don't shadow
    over potentially helpful warnings.
    
    Metric Increase:
      T13719
    
    - - - - -
    3f31825b by Ben Gamari at 2022-04-06T13:02:40-04:00
    rts/AdjustorPool: Generalize to allow arbitrary contexts
    
    Unfortunately the i386 adjustor logic needs this.
    
    - - - - -
    9b645ee1 by Ben Gamari at 2022-04-06T13:02:40-04:00
    adjustors/i386: Use AdjustorPool
    
    In !7511 (closed) I introduced a new allocator for adjustors,
    AdjustorPool, which eliminates the address space fragmentation issues
    which adjustors can introduce. In that work I focused on amd64 since
    that was the platform where I observed issues.
    
    However, in #21132 we noted that the size of adjustors is also a cause
    of CI fragility on i386. In this MR I port i386 to use AdjustorPool.
    Sadly the complexity of the i386 adjustor code does cause require a bit
    of generalization which makes the code a bit more opaque but such is the
    world.
    
    Closes #21132.
    
    - - - - -
    c657a616 by Ben Gamari at 2022-04-06T13:03:16-04:00
    hadrian: Clean up flavour transformer definitions
    
    Previously the `ipe` and `omit_pragmas` transformers were hackily
    defined using the textual key-value syntax. Fix this.
    
    - - - - -
    9ce273b9 by Ben Gamari at 2022-04-06T13:03:16-04:00
    gitlab-ci: Drop dead HACKAGE_INDEX_STATE variable
    
    - - - - -
    01845375 by Ben Gamari at 2022-04-06T13:03:16-04:00
    gitlab/darwin: Factor out bindists
    
    This makes it a bit easier to bump them.
    
    - - - - -
    c41c478e by Ben Gamari at 2022-04-06T13:03:16-04:00
    Fix a few new warnings when booting with GHC 9.2.2
    
    -Wuni-incomplete-patterns and apparent improvements in the pattern match
    checker surfaced these.
    
    - - - - -
    6563cd24 by Ben Gamari at 2022-04-06T13:03:16-04:00
    gitlab-ci: Bump bootstrap compiler to 9.2.2
    
    This is necessary to build recent `text` commits.
    
    Bumps Hackage index state for a hashable which builds with GHC 9.2.
    
    - - - - -
    a62e983e by Ben Gamari at 2022-04-06T13:03:16-04:00
    Bump text submodule to current `master`
    
    Addresses #21295.
    
    - - - - -
    88d61031 by Vladislav Zavialov at 2022-04-06T13:03:53-04:00
    Refactor OutputableBndrFlag instances
    
    The matching on GhcPass introduced by 95275a5f25a is not necessary.
    This patch reverts it to make the code simpler.
    
    - - - - -
    f601f002 by GHC GitLab CI at 2022-04-06T15:18:26-04:00
    rts: Eliminate use of nested functions
    
    This is a gcc-specific extension.
    
    - - - - -
    d4c5f29c by Ben Gamari at 2022-04-06T15:18:26-04:00
    driver: Drop hacks surrounding windres invocation
    
    Drop hack for #1828, among others as they appear to be unnecessary when
    using `llvm-windres`.
    
    - - - - -
    6be2c5a7 by Ben Gamari at 2022-04-06T15:18:26-04:00
    Windows/Clang: Build system adaptation
    
    * Bump win32-tarballs to 0.7
    * Move Windows toolchain autoconf logic into separate file
    * Use clang and LLVM utilities as described in #21019
    * Disable object merging as lld doesn't support -r
    * Drop --oformat=pe-bigobj-x86-64 arguments from ld flags as LLD detects
      that the output is large on its own.
    * Drop gcc wrapper since Clang finds its root fine on its own.
    
    - - - - -
    c6fb7aff by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Test that we can build bigobj PE objects
    
    - - - - -
    79851c07 by Ben Gamari at 2022-04-06T15:18:26-04:00
    Drop -static-libgcc
    
    This flag is not applicable when Clang is used.
    
    - - - - -
    1f8a8264 by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Port T16514 to C
    
    Previously this test was C++ which made it a bit of a portability
    problem.
    
    - - - - -
    d7e650d1 by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Mark Windows as a libc++ platform
    
    - - - - -
    d7886c46 by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Mark T9405 as fixed on Windows
    
    I have not seen it fail since moving to clang.
    
    Closes #12714.
    
    - - - - -
    4c3fbb4e by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Mark FloatFnInverses as fixed
    
    The new toolchain has fixed it.
    
    Closes #15670.
    
    - - - - -
    402c36ba by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Rework T13606 to avoid gcc dependence
    
    Previously we used libgcc_s's import library in T13606. However, now that
    we ship with clang we no longer have this library. Instead we now use gdi32.
    
    - - - - -
    9934ad54 by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Clean up tests depending on C++ std lib
    
    - - - - -
    12fcdef2 by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Split T13366 into two tests
    
    Split up the C and C++ uses since the latter is significantly more
    platform-dependent.
    
    - - - - -
    3c08a198 by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Fix mk-big-obj
    
    I'm a bit unclear on how this previously worked as it attempted
    to build an executable without defining `main`.
    
    - - - - -
    7e97cc23 by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Provide module definitions in T10955dyn
    
    Otherwise the linker will export all symbols, including those provided
    by the RTS, from the produced shared object. Consequently, attempting
    to link against multiple objects simultaneously will cause the linker
    to complain that RTS symbols are multiply defined. Avoid this
    by limiting the DLL exports with a module definition file.
    
    - - - - -
    9a248afa by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite: Mark test-defaulting-plugin as fragile on Windows
    
    Currently llvm-ar does not handle long file paths, resulting in
    occassional failures of these tests and #21293.
    
    - - - - -
    39371aa4 by Ben Gamari at 2022-04-06T15:18:26-04:00
    testsuite/driver: Treat framework failures of fragile tests as non-fatal
    
    Previously we would report framework failures of tests marked as fragile
    as failures. Now we rather treat them as fragile test failures, which
    are not fatal to the testsuite run. Noticed while investigating #21293.
    
    - - - - -
    a1e6661d by Ben Gamari at 2022-04-06T15:18:32-04:00
    Bump Cabal submodule
    
    - Disable support for library-for-ghci on Windows as described
      in #21068.
    - Teach Cabal to use `ar -L` when available
    
    - - - - -
    f7b0f63c by Ben Gamari at 2022-04-06T15:18:37-04:00
    Bump process submodule
    
    Fixes missing TEST_CC_OPTS in testsuite tests.
    
    - - - - -
    109cee19 by Ben Gamari at 2022-04-06T15:18:37-04:00
    hadrian: Disable ghci libraries when object merging is not available
    
    - - - - -
    c22fba5c by Ben Gamari at 2022-04-06T15:18:37-04:00
    Bump bytestring submodule
    
    - - - - -
    6e2744cc by Ben Gamari at 2022-04-06T15:18:37-04:00
    Bump text submodule
    
    - - - - -
    32333747 by Ben Gamari at 2022-04-06T15:18:37-04:00
    hadrian: Build wrappers using ghc rather than cc
    
    - - - - -
    59787ba5 by Ben Gamari at 2022-04-06T15:18:37-04:00
    linker/PEi386: More descriptive error message
    
    - - - - -
    5e3c3c4f by Ben Gamari at 2022-04-06T15:18:37-04:00
    testsuite: Mark TH_spliceE5_prof as unbroken on Windows
    
    It was previously failing due to #18721 and now passes with the new
    toolchain.
    
    Closes #18721.
    
    - - - - -
    9eb0a9d9 by GHC GitLab CI at 2022-04-06T15:23:48-04:00
    rts/PEi386: Move some debugging output to -DL
    
    - - - - -
    ce874595 by Ben Gamari at 2022-04-06T15:24:01-04:00
    nativeGen/x86: Use %rip-relative addressing
    
    On Windows with high-entropy ASLR we must use %rip-relative addressing
    to avoid overflowing the signed 32-bit immediate size of x86-64.
    Since %rip-relative addressing comes essentially for free and can make
    linking significantly easier, we use it on all platforms.
    
    - - - - -
    52deee64 by Ben Gamari at 2022-04-06T15:24:01-04:00
    Generate LEA for label expressions
    
    - - - - -
    105a0056 by Ben Gamari at 2022-04-06T15:24:01-04:00
    Refactor is32BitLit to take Platform rather than Bool
    
    - - - - -
    ec4526b5 by Ben Gamari at 2022-04-06T15:24:01-04:00
    Don't assume that labels are 32-bit on Windows
    
    - - - - -
    ffdbe457 by Ben Gamari at 2022-04-06T15:24:01-04:00
    nativeGen: Note signed-extended nature of MOV
    
    - - - - -
    bfb79697 by Ben Gamari at 2022-04-06T15:30:56-04:00
    rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h
    
    It's easier to ensure that this is included first than Rts.h
    
    - - - - -
    5ad143fd by Ben Gamari at 2022-04-06T15:30:56-04:00
    rts: Fix various #include issues
    
    This fixes various violations of the newly-added RTS includes linter.
    
    - - - - -
    a59a66a8 by Ben Gamari at 2022-04-06T15:30:56-04:00
    testsuite: Lint RTS #includes
    
    Verifies two important properties of #includes in the RTS:
    
     * That system headers don't appear inside of a `<BeginPrivate.h>` block
       as this can hide system library symbols, resulting in very
       hard-to-diagnose linker errors
    
     * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO
       is set correctly before system headers are included.
    
    - - - - -
    42bf7528 by GHC GitLab CI at 2022-04-06T16:25:04-04:00
    rts/PEi386: Fix memory leak
    
    Previously we would leak the section information of the `.bss`
    section.
    
    - - - - -
    d286a55c by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/linker: Preserve information about symbol types
    
    As noted in #20978, the linker would previously handle overflowed
    relocations by creating a jump island. While this is fine in the case of
    code symbols, it's very much not okay in the case of data symbols. To
    fix this we must keep track of whether each symbol is code or data and
    relocate them appropriately. This patch takes the first step in this
    direction, adding a symbol type field to the linker's symbol table. It
    doesn't yet change relocation behavior to take advantage of this
    knowledge.
    
    Fixes #20978.
    
    - - - - -
    e689e9d5 by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/PEi386: Fix relocation overflow behavior
    
    This fixes handling of overflowed relocations on PEi386 targets:
    
     * Refuse to create jump islands for relocations of data symbols
     * Correctly handle the `__imp___acrt_iob_func` symbol, which is an new
       type of symbol: `SYM_TYPE_INDIRECT_DATA`
    
    - - - - -
    655e7d8f by GHC GitLab CI at 2022-04-06T16:25:25-04:00
    rts: Mark anything that might have an info table as data
    
    Tables-next-to-code mandates that we treat symbols with info tables like
    data since we cannot relocate them using a jump island.
    
    See #20983.
    
    - - - - -
    7e8cc293 by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/PEi386: Rework linker
    
    This is a significant rework of the PEi386 linker, making the linker
    compatible with high image base addresses. Specifically, we now use the
    m32 allocator instead of `HeapAllocate`.
    
    In addition I found a number of latent bugs in our handling of import
    libraries and relocations. I've added quite a few comments describing
    what I've learned about Windows import libraries while fixing these.
    
    Thanks to Tamar Christina (@Phyx) for providing the address space search
    logic, countless hours of help while debugging, and his boundless
    Windows knowledge.
    
    Co-Authored-By: Tamar Christina <tamar at zhox.com>
    
    - - - - -
    ff625218 by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/PEi386: Move allocateBytes to MMap.c
    
    - - - - -
    f562b5ca by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/PEi386: Avoid accidentally-quadratic allocation cost
    
    We now preserve the address that we last mapped, allowing us to resume
    our search and avoiding quadratic allocation costs. This fixes the
    runtime of T10296a, which allocates many adjustors.
    
    - - - - -
    3247b7db by Ben Gamari at 2022-04-06T16:25:25-04:00
    Move msvcrt dep out of base
    
    - - - - -
    fa404335 by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/linker: More descriptive debug output
    
    - - - - -
    140f338f by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/PathUtils: Define pathprintf in terms of snwprintf on Windows
    
    swprintf deviates from usual `snprintf` semantics in that it does not
    guarantee reasonable behavior when the buffer is NULL (that is,
    returning the number of bytes that would have been emitted).
    
    - - - - -
    eb60565b by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/linker: Report archive member index
    
    - - - - -
    209fd61b by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/linker: Split up object resolution and initialization
    
    Previously the RTS linker would call initializers during the
    "resolve" phase of linking. However, this is problematic in the
    case of cyclic dependencies between objects. In particular, consider
    the case where we have a situation where a static library
    contains a set of recursive objects:
    
     * object A has depends upon symbols in object B
     * object B has an initializer that depends upon object A
     * we try to load object A
    
    The linker would previously:
    
     1. start resolving object A
     2. encounter the reference to object B, loading it resolve object B
     3. run object B's initializer
     4. the initializer will attempt to call into object A,
        which hasn't been fully resolved (and therefore protected)
    
    Fix this by moving constructor execution to a new linking
    phase, which follows resolution.
    
    Fix #21253.
    
    - - - - -
    8e8a1021 by Ben Gamari at 2022-04-06T16:25:25-04:00
    rts/linker/LoadArchive: Fix leaking file handle
    
    Previously `isArchive` could leak a `FILE` handle if the `fread`
    returned a short read.
    
    - - - - -
    429ea5d9 by sheaf at 2022-04-07T07:55:52-04:00
    Remove Fun pattern from Typeable COMPLETE set
    
    GHC merge request !963 improved warnings in the presence of
    COMPLETE annotations. This allows the removal of the Fun pattern
    from the complete set.
    
    Doing so expectedly causes some redundant pattern match warnings,
    in particular in GHC.Utils.Binary.Typeable and Data.Binary.Class
    from the binary library; this commit addresses that.
    
    Updates binary submodule
    
    Fixes #20230
    
    - - - - -
    54b18824 by Alan Zimmerman at 2022-04-07T07:56:28-04:00
    EPA: handling of con_bndrs in mkGadtDecl
    
    Get rid of unnnecessary case clause that always matched.
    
    Closes #20558
    
    - - - - -
    9c838429 by Ben Gamari at 2022-04-07T09:38:53-04:00
    testsuite: Mark T10420 as broken on Windows
    
    Due to #21322.
    
    - - - - -
    50739d2b by Ben Gamari at 2022-04-07T09:42:42-04:00
    rts: Refactor and fix printf attributes on clang
    
    Clang on Windows does not understand the `gnu_printf` attribute; use
    `printf` instead.
    
    - - - - -
    9eeaeca4 by Ben Gamari at 2022-04-07T09:42:42-04:00
    rts: Add missing newline in error message
    
    - - - - -
    fcef9a17 by Ben Gamari at 2022-04-07T09:42:42-04:00
    configure: Make environ decl check more robust
    
    Some platforms (e.g. Windows/clang64) declare `environ` in `<stdlib.h>`,
    not `<unistd.h>`
    
    - - - - -
    8162b4f3 by Ben Gamari at 2022-04-07T09:42:42-04:00
    rts: Adjust RTS symbol table on Windows for ucrt
    
    - - - - -
    633280d7 by Ben Gamari at 2022-04-07T09:43:21-04:00
    testsuite: Fix exit code of bounds checking tests on Windows
    
    `abort` exits with 255, not 134, on Windows.
    
    - - - - -
    cab4dc01 by Ben Gamari at 2022-04-07T09:43:31-04:00
    testsuite: Update expected output from T5435 tests on Windows
    
    I'll admit, I don't currently see *why* this output is reordered
    but it is a fairly benign difference and I'm out of time to investigate.
    
    - - - - -
    edf5134e by Ben Gamari at 2022-04-07T09:43:35-04:00
    testsuite: Mark T20918 as broken on Windows
    
    Our toolchain on Windows doesn't currently have Windows support.
    
    - - - - -
    d0ddeff3 by Ben Gamari at 2022-04-07T09:43:39-04:00
    testsuite: Mark linker unloading tests as broken on Windows
    
    Due to #20354.
    
    We will need to investigate this prior the release.
    
    - - - - -
    5a86da2b by Ben Gamari at 2022-04-07T09:43:43-04:00
    testsuite: Mark T9405 as broken on Windows
    
    Due to #21361.
    
    - - - - -
    4aa86dcf by Ben Gamari at 2022-04-07T09:44:18-04:00
    Merge branches 'wip/windows-high-codegen', 'wip/windows-high-linker', 'wip/windows-clang-2' and 'wip/lint-rts-includes' into wip/windows-clang-join
    
    - - - - -
    7206f055 by Ben Gamari at 2022-04-07T09:45:07-04:00
    rts/CloneStack: Ensure that Rts.h is #included first
    
    As is necessary on Windows.
    
    - - - - -
    9cfcb27b by Ben Gamari at 2022-04-07T09:45:07-04:00
    rts: Fallback to ucrtbase not msvcrt
    
    Since we have switched to Clang the toolchain now links against
    ucrt rather than msvcrt.
    
    - - - - -
    d6665d85 by Ben Gamari at 2022-04-07T09:46:25-04:00
    Accept spurious perf test shifts on Windows
    
    Metric Decrease:
        T16875
    Metric Increase:
        T12707
        T13379
        T3294
        T4801
        T5321FD
        T5321Fun
        T783
    
    - - - - -
    83363c8b by Simon Peyton Jones at 2022-04-07T12:57:21-04:00
    Use prepareBinding in tryCastWorkerWrapper
    
    As #21144 showed, tryCastWorkerWrapper was calling prepareRhs, and
    then unconditionally floating the bindings, without the checks of
    doFloatFromRhs.   That led to floating an unlifted binding into
    a Rec group.
    
    This patch refactors prepareBinding to make these checks,
    and do them uniformly across all calls.  A nice improvement.
    
    Other changes
    * Instead of passing around a RecFlag and a TopLevelFlag; and sometimes
      a (Maybe SimplCont) for join points, define a new Simplifier-specific
      data type BindContext:
          data BindContext = BC_Let  TopLevelFlag RecFlag
                           | BC_Join SimplCont
      and use it consistently.
    
    * Kill off completeNonRecX by inlining it.  It was only called in
      one place.
    
    * Add a wrapper simplImpRules for simplRules.
    
    Compile time on T9630 drops by 4.7%; little else changes.
    
    Metric Decrease:
        T9630
    
    - - - - -
    02279a9c by Vladislav Zavialov at 2022-04-07T12:57:59-04:00
    Rename [] to List (#21294)
    
    This patch implements a small part of GHC Proposal #475.
    The key change is in GHC.Types:
    
    	- data [] a = [] | a : [a]
    	+ data List a = [] | a : List a
    
    And the rest of the patch makes sure that List is pretty-printed as []
    in various contexts.
    
    Updates the haddock submodule.
    
    - - - - -
    08480d2a by Simon Peyton Jones at 2022-04-07T12:58:36-04:00
    Fix the free-var test in validDerivPred
    
    The free-var test (now documented as (VD3)) was too narrow,
    affecting only class predicates.  #21302 demonstrated that
    this wasn't enough!
    
    Fixes #21302.
    
    Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com>
    
    - - - - -
    b3d6d23d by Andreas Klebinger at 2022-04-07T12:59:12-04:00
    Properly explain where INLINE pragmas can appear.
    
    Fixes #20676
    
    - - - - -
    23ef62b3 by Ben Gamari at 2022-04-07T14:28:28-04:00
    rts: Fix off-by-one in snwprintf usage
    
    - - - - -
    b2dbcc7d by Simon Jakobi at 2022-04-08T03:00:38-04:00
    Improve seq[D]VarSet
    
    Previously, the use of size[D]VarSet would involve a traversal of the
    entire underlying IntMap. Since IntMaps are already spine-strict,
    this is unnecessary.
    
    - - - - -
    64ac20a7 by sheaf at 2022-04-08T03:01:16-04:00
    Add test for #21338
    
    This no-skolem-info bug was fixed by the no-skolem-info patch
    that will be part of GHC 9.4. This patch adds a regression test for
    the issue reported in issue #21338.
    
    Fixes #21338.
    
    - - - - -
    c32c4db6 by Ben Gamari at 2022-04-08T03:01:53-04:00
    rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h
    
    It's easier to ensure that this is included first than Rts.h
    
    - - - - -
    56f85d62 by Ben Gamari at 2022-04-08T03:01:53-04:00
    rts: Fix various #include issues
    
    This fixes various violations of the newly-added RTS includes linter.
    
    - - - - -
    cb1f31f5 by Ben Gamari at 2022-04-08T03:01:53-04:00
    testsuite: Lint RTS #includes
    
    Verifies two important properties of #includes in the RTS:
    
     * That system headers don't appear inside of a `<BeginPrivate.h>` block
       as this can hide system library symbols, resulting in very
       hard-to-diagnose linker errors
    
     * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO
       is set correctly before system headers are included.
    
    - - - - -
    c44432db by Krzysztof Gogolewski at 2022-04-08T03:02:29-04:00
    Fixes to 9.4 release notes
    
    - Mention -Wforall-identifier
    - Improve description of withDict
    - Fix formatting
    
    - - - - -
    777365f1 by sheaf at 2022-04-08T09:43:35-04:00
    Correctly report SrcLoc of redundant constraints
    
    We were accidentally dropping the source location information in
    certain circumstances when reporting redundant constraints. This patch
    makes sure that we set the TcLclEnv correctly before reporting the
    warning.
    
    Fixes #21315
    
    - - - - -
    af300a43 by Vladislav Zavialov at 2022-04-08T09:44:11-04:00
    Reject illegal quote mark in data con declarations (#17865)
    
    * Non-fatal (i.e. recoverable) parse error
    * Checking infix constructors
    * Extended the regression test
    
    - - - - -
    56254e6b by Ben Gamari at 2022-04-08T09:59:46-04:00
    Merge remote-tracking branch 'origin/master'
    
    - - - - -
    6e2c3b7c by Matthew Pickering at 2022-04-08T13:55:15-04:00
    driver: Introduce HomeModInfoCache abstraction
    
    The HomeModInfoCache is a mutable cache which is updated incrementally
    as the driver completes, this makes it robust to exceptions including
    (SIGINT)
    
    The interface for the cache is described by the `HomeMOdInfoCache` data
    type:
    
    ```
    data HomeModInfoCache = HomeModInfoCache { hmi_clearCache :: IO [HomeModInfo]
                                             , hmi_addToCache :: HomeModInfo -> IO () }
    ```
    
    The first operation clears the cache and returns its contents. This is
    designed so it's harder to end up in situations where the cache is
    retained throughout the execution of upsweep.
    
    The second operation allows a module to be added to the cache.
    
    The one slightly nasty part is in `interpretBuildPlan` where we have to
    be careful to ensure that the cache writes happen:
    
    1. In parralel
    2. Before the executation continues after upsweep.
    
    This requires some simple, localised MVar wrangling.
    
    Fixes #20780
    
    - - - - -
    85f4a3c9 by Andreas Klebinger at 2022-04-08T13:55:50-04:00
    Add flag -fprof-manual which controls if GHC should honour manual cost centres.
    
    This allows disabling of manual control centres in code a user doesn't control like
    libraries.
    
    Fixes #18867
    
    - - - - -
    3415981c by Vladislav Zavialov at 2022-04-08T13:56:27-04:00
    HsUniToken for :: in GADT constructors (#19623)
    
    One more step towards the new design of EPA.
    
    Updates the haddock submodule.
    
    - - - - -
    23f95735 by sheaf at 2022-04-08T13:57:07-04:00
    Docs: datacon eta-expansion, rep-poly checks
    
    The existing notes weren't very clear on how the eta-expansion of
    data constructors that occurs in tcInferDataCon/dsConLike interacts
    with the representation polymorphism invariants. So we explain with
    a few more details how we ensure that the representation-polymorphic
    lambdas introduced by tcInferDataCon/dsConLike don't end up causing
    problems, by checking they are properly instantiated and then relying
    on the simple optimiser to perform beta reduction.
    
    A few additional changes:
    
      - ConLikeTc just take type variables instead of binders, as we
        never actually used the binders.
      - Removed the FRRApp constructor of FRROrigin; it was no longer used
        now that we use ExpectedFunTyOrigin.
      - Adds a bit of documentation to the constructors
        of ExpectedFunTyOrigin.
    
    - - - - -
    d4480490 by Matthew Pickering at 2022-04-08T13:57:43-04:00
    ci: Replace "always" with "on_success" to stop build jobs running before hadrian-ghci has finished
    
    See https://docs.gitlab.com/ee/ci/yaml/#when
    
    * always means, always run not matter what
    * on_success means, run if the dependencies have built successfully
    
    - - - - -
    0736e949 by Vladislav Zavialov at 2022-04-08T13:58:19-04:00
    Disallow (->) as a data constructor name (#16999)
    
    The code was misusing isLexCon, which was never meant for validation.
    In fact, its documentation states the following:
    
    	Use these functions to figure what kind of name a 'FastString'
    	represents; these functions do /not/ check that the identifier
    	is valid.
    
    Ha! This sign can't stop me because I can't read.
    
    The fix is to use okConOcc instead. The other checks (isTcOcc or
    isDataOcc) seem superfluous, so I also removed those.
    
    - - - - -
    e58d5eeb by Simon Peyton Jones at 2022-04-08T13:58:55-04:00
    Tiny documentation wibble
    
    This commit
       commit 83363c8b04837ee871a304cf85207cf79b299fb0
       Author: Simon Peyton Jones <simon.peytonjones at gmail.com>
       Date:   Fri Mar 11 16:55:38 2022 +0000
    
           Use prepareBinding in tryCastWorkerWrapper
    
    refactored completeNonRecX away, but left a Note referring to it.
    This MR fixes that Note.
    
    - - - - -
    4bb00839 by Matthew Pickering at 2022-04-09T07:40:28-04:00
    ci: Fix nightly head.hackage pipelines
    
    This also needs a corresponding commit to head.hackage, I also made the
    job explicitly depend on the fedora33 job so that it isn't blocked by a
    failing windows job, which causes docs-tarball to fail.
    
    - - - - -
    3c48e12a by Matthew Pickering at 2022-04-09T07:40:28-04:00
    ci: Remove doc-tarball dependency from perf and perf-nofib jobs
    
    These don't depend on the contents of the tarball so we can run them
    straight after the fedora33 job finishes.
    
    - - - - -
    27362265 by Matthew Pickering at 2022-04-09T07:41:04-04:00
    Bump deepseq to 1.4.7.0
    
    Updates deepseq submodule
    
    Fixes #20653
    
    - - - - -
    dcf30da8 by Joachim Breitner at 2022-04-09T13:02:19-04:00
    Drop the app invariant
    
    previously, GHC had the "let/app-invariant" which said that the RHS of a
    let or the argument of an application must be of lifted type or ok for
    speculation. We want this on let to freely float them around, and we
    wanted that on app to freely convert between the two (e.g. in
    beta-reduction or inlining).
    
    However, the app invariant meant that simple code didn't stay simple and
    this got in the way of rules matching. By removing the app invariant,
    this thus fixes #20554.
    
    The new invariant is now called "let-can-float invariant", which is
    hopefully easier to guess its meaning correctly.
    
    Dropping the app invariant means that everywhere where we effectively do
    beta-reduction (in the two simplifiers, but also in `exprIsConApp_maybe`
    and other innocent looking places) we now have to check if the argument
    must be evaluated (unlifted and side-effecting), and analyses have to be
    adjusted to the new semantics of `App`.
    
    Also, `LetFloats` in the simplifier can now also carry such non-floating
    bindings.
    
    The fix for DmdAnal, refine by Sebastian, makes functions with unlifted
    arguments strict in these arguments, which changes some signatures.
    
    This causes some extra calls to `exprType` and `exprOkForSpeculation`,
    so some perf benchmarks regress a bit (while others improve).
    
    Metric Decrease:
        T9020
    Metric Increase:
        LargeRecord
        T12545
        T15164
        T16577
        T18223
        T5642
        T9961
    
    Co-authored-by: Sebastian Graf <sebastian.graf at kit.edu>
    
    - - - - -
    6c6c5379 by Philip Hazelden at 2022-04-09T13:02:59-04:00
    Add functions traceWith, traceShowWith, traceEventWith.
    
    As discussed at
    https://github.com/haskell/core-libraries-committee/issues/36
    
    - - - - -
    8fafacf7 by Philip Hazelden at 2022-04-09T13:02:59-04:00
    Add tests for several trace functions.
    
    - - - - -
    20bbf3ac by Philip Hazelden at 2022-04-09T13:02:59-04:00
    Update changelog.
    
    - - - - -
    47d18b0b by Andreas Klebinger at 2022-04-09T13:03:35-04:00
    Add regression test for #19569
    
    - - - - -
    5f8d6e65 by sheaf at 2022-04-09T13:04:14-04:00
    Fix missing SymCo in pushCoercionIntoLambda
    
    There was a missing SymCo in pushCoercionIntoLambda. Currently
    this codepath is only used with rewrite rules, so this bug managed
    to slip by, but trying to use pushCoercionIntoLambda in other contexts
    revealed the bug.
    
    - - - - -
    20eca489 by Vladislav Zavialov at 2022-04-09T13:04:50-04:00
    Refactor: simplify lexing of the dot
    
    Before this patch, the lexer did a truly roundabout thing with the dot:
    
    1. look up the varsym in reservedSymsFM and turn it into ITdot
    2. under OverloadedRecordDot, turn it into ITvarsym
    3. in varsym_(prefix|suffix|...) turn it into ITvarsym, ITdot, or
       ITproj, depending on extensions and whitespace
    
    Turns out, the last step is sufficient to handle the dot correctly.
    This patch removes the first two steps.
    
    - - - - -
    5440f63e by Hécate Moonlight at 2022-04-12T11:11:06-04:00
    Document that DuplicateRecordFields doesn't tolerates ambiguous fields
    
    Fix #19891
    
    - - - - -
    0090ad7b by Sebastian Graf at 2022-04-12T11:11:42-04:00
    Eta reduction based on evaluation context (#21261)
    
    I completely rewrote our Notes surrounding eta-reduction. The new entry point is
    `Note [Eta reduction makes sense]`.
    
    Then I went on to extend the Simplifier to maintain an evaluation context in the
    form of a `SubDemand` inside a `SimplCont`. That `SubDemand` is useful for doing
    eta reduction according to `Note [Eta reduction based on evaluation context]`,
    which describes how Demand analysis, Simplifier and `tryEtaReduce` interact to
    facilitate eta reduction in more scenarios.
    
    Thus we fix #21261.
    
    ghc/alloc perf marginally improves (-0.0%). A medium-sized win is when compiling
    T3064 (-3%). It seems that haddock improves by 0.6% to 1.0%, too.
    
    Metric Decrease:
        T3064
    
    - - - - -
    4d2ee313 by Sebastian Graf at 2022-04-12T17:54:57+02:00
    Specialising through specialised method calls (#19644)
    
    In #19644, we discovered that the ClassOp/DFun rules from
    Note [ClassOp/DFun selection] inhibit transitive specialisation in a scenario
    like
    ```
    class C a where m :: Show b => a -> b -> ...; n :: ...
    instance C Int where m = ... -- $cm :: Show b => Int -> b -> ...
    f :: forall a b. (C a, Show b) => ...
    f $dC $dShow = ... m @a $dC @b $dShow ...
    main = ... f @Int @Bool ...
    ```
    After we specialise `f` for `Int`, we'll see `m @a $dC @b $dShow` in the body of
    `$sf`. But before this patch, Specialise doesn't apply the ClassOp/DFun rule to
    rewrite to a call of the instance method for `C Int`, e.g., `$cm @Bool $dShow`.
    As a result, Specialise couldn't further specialise `$cm` for `Bool`.
    
    There's a better example in `Note [Specialisation modulo dictionary selectors]`.
    
    This patch enables proper Specialisation, as follows:
    
    1. In the App case of `specExpr`, try to apply the CalssOp/DictSel rule on the
       head of the application
    2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and
       `$dShow` in `bindAuxiliaryDict`
    
    NB: Without (2), (1) would be pointless, because `lookupRule` wouldn't be able
    to look into the RHS of `$dC` to see the DFun.
    
    (2) triggered #21332, because the Specialiser floats around dictionaries without
    accounting for them in the `SpecEnv`'s `InScopeSet`, triggering a panic when
    rewriting dictionary unfoldings.
    
    Fixes #19644 and #21332.
    
    - - - - -
    b06f4f47 by Sebastian Graf at 2022-04-12T17:54:58+02:00
    Specialise: Check `typeDeterminesValue` before specialising on an interesting dictionary
    
    I extracted the checks from `Note [Type determines value]` into its own
    function, so that we share the logic properly. Then I made sure that we
    actually call `typeDeterminesValue` everywhere we check for `interestingDict`.
    
    - - - - -
    a42dbc55 by Matthew Pickering at 2022-04-13T06:24:52-04:00
    Refine warning about defining rules in SAFE modules
    
    This change makes it clear that it's the definition rather than any
    usage which is a problem, and that rules defined in other modules will
    still be  used to do rewrites.
    
    Fixes #20923
    
    - - - - -
    df893f66 by Andreas Klebinger at 2022-04-14T08:18:37-04:00
    StgLint: Lint constructor applications and strict workers for arity.
    
    This will mean T9208 when run with lint will return a lint error instead
    of resulting in a panic.
    
    Fixes #21117
    
    - - - - -
    426ec446 by sheaf at 2022-04-14T08:19:16-04:00
    Hadrian: use a set to keep track of ways
    
    The order in which ways are provided doesn't matter,
    so we use a data structure with the appropriate semantics to
    represent ways.
    
    Fixes #21378
    
    - - - - -
    7c639b9a by Dylan Yudaken at 2022-04-15T13:55:59-04:00
    Only enable PROF_SPIN in DEBUG
    
    - - - - -
    96b9e5ea by Ben Gamari at 2022-04-15T13:56:34-04:00
    testsuite: Add test for #21390
    
    - - - - -
    d8392f6a by Ben Gamari at 2022-04-15T13:56:34-04:00
    rts: Ensure that the interpreter doesn't disregard tags
    
    Previously the interpreter's handling of `RET_BCO` stack frames would
    throw away the tag of the returned closure. This resulted in #21390.
    
    - - - - -
    83c67f76 by Alan Zimmerman at 2022-04-20T11:49:28-04:00
    Add -dkeep-comments flag to keep comments in the parser
    
    This provides a way to set the Opt_KeepRawTokenStream from the command
    line, allowing exact print annotation users to see exactly what is
    produced for a given parsed file, when used in conjunction with
    -ddump-parsed-ast
    
    Discussed in #19706, but this commit does not close the issue.
    
    - - - - -
    a5ea65c9 by Krzysztof Gogolewski at 2022-04-20T11:50:04-04:00
    Remove LevityInfo
    
    Every Id was storing a boolean whether it could be levity-polymorphic.
    This information is no longer needed since representation-checking
    has been moved to the typechecker.
    
    - - - - -
    49bd7584 by Andreas Klebinger at 2022-04-20T11:50:39-04:00
    Fix a shadowing issue in StgUnarise.
    
    For I assume performance reasons we don't record no-op replacements
    during unarise. This lead to problems with code like this:
    
        f = \(Eta_B0 :: VoidType) x1 x2 ->
           ... let foo = \(Eta_B0 :: LiftedType) -> g x y Eta_B0
               in ...
    
    Here we would record the outer Eta_B0 as void rep, but would not
    shadow Eta_B0 inside `foo` because this arg is single-rep and so
    doesn't need to replaced. But this means when looking at occurence
    sites we would check the env and assume it's void rep based on the
    entry we made for the (no longer in scope) outer `Eta_B0`.
    
    Fixes #21396 and the ticket has a few more details.
    
    - - - - -
    0c02c919 by Simon Peyton Jones at 2022-04-20T11:51:15-04:00
    Fix substitution in bindAuxiliaryDict
    
    In GHC.Core.Opt.Specialise.bindAuxiliaryDict we were unnecessarily
    calling `extendInScope` to bring into scope variables that were
    /already/ in scope.  Worse, GHC.Core.Subst.extendInScope strangely
    deleted the newly-in-scope variables from the substitution -- and that
    was fatal in #21391.
    
    I removed the redundant calls to extendInScope.
    
    More ambitiously, I changed GHC.Core.Subst.extendInScope (and cousins)
    to stop deleting variables from the substitution.  I even changed the
    names of the function to extendSubstInScope (and cousins) and audited
    all the calls to check that deleting from the substitution was wrong.
    In fact there are very few such calls, and they are all about
    introducing a fresh non-in-scope variable.  These are "OutIds"; it is
    utterly wrong to mess with the "InId" substitution.
    
    I have not added a Note, because I'm deleting wrong code, and it'd be
    distracting to document a bug.
    
    - - - - -
    0481a6af by Cheng Shao at 2022-04-21T11:06:06+00:00
    [ci skip] Drop outdated TODO in RtsAPI.c
    
    - - - - -
    1e062a8a by Ben Gamari at 2022-04-22T02:12:59-04:00
    rts: Introduce ip_STACK_FRAME
    
    While debugging it is very useful to be able to determine whether a
    given info table is a stack frame or not. We have spare bits in the
    closure flags array anyways, use one for this information.
    
    - - - - -
    08a6a2ee by Ben Gamari at 2022-04-22T02:12:59-04:00
    rts: Mark closureFlags array as const
    
    - - - - -
    8f9b8282 by Krzysztof Gogolewski at 2022-04-22T02:13:35-04:00
    Check for zero-bit types in sizeExpr
    
    Fixes #20940
    
    Metric Decrease:
        T18698a
    
    - - - - -
    fcf22883 by Andreas Klebinger at 2022-04-22T02:14:10-04:00
    Include the way string in the file name for dump files.
    
    This can be disabled by `-fno-dump-with-ways` if not desired.
    Finally we will be able to look at both profiled and non-profiled dumps
    when compiling with dump flags and we compile in both ways.
    
    - - - - -
    252394ce by Andrew Lelechenko at 2022-04-22T02:14:48-04:00
    Improve error messages from GHC.IO.Encoding.Failure
    
    - - - - -
    250f57c1 by Andrew Lelechenko at 2022-04-22T02:14:48-04:00
    Update test baselines to match new error messages from GHC.IO.Encoding.Failure
    
    - - - - -
    5ac9b321 by Ben Gamari at 2022-04-22T02:15:25-04:00
    get-win32-tarballs: Drop i686 architecture
    
    As of #18487 we no longer support 32-bit Windows.
    
    Fixes #21372.
    
    - - - - -
    dd5fecb0 by Ben Gamari at 2022-04-22T02:16:00-04:00
    hadrian: Don't rely on xxx not being present in installation path
    
    Previously Hadrian's installation makefile would assume that the string
    `xxx` did not appear in the installation path. This would of course
    break for some users.
    
    Fixes #21402.
    
    - - - - -
    09e98859 by Ben Gamari at 2022-04-22T02:16:35-04:00
    testsuite: Ensure that GHC doesn't pick up environment files
    
    Here we set GHC_ENVIRONMENT="-" to ensure that GHC invocations of tests
    don't pick up a user's local package environment.
    
    Fixes #21365.
    
    Metric Decrease:
        T10421
        T12234
        T12425
        T13035
        T16875
        T9198
    
    - - - - -
    76bb8cb3 by Ben Gamari at 2022-04-22T02:17:11-04:00
    hadrian: Enable -dlint in devel2 flavour
    
    Previously only -dcore-lint was enabled.
    
    - - - - -
    f435d55f by Krzysztof Gogolewski at 2022-04-22T08:00:18-04:00
    Fixes to rubbish literals
    
    * In CoreToStg, the application 'RUBBISH[rep] x' was simplified
      to 'RUBBISH[rep]'. But it is possible that the result of the function
      is represented differently than the function.
    * In Unarise, 'LitRubbish (primRepToType prep)'
      is incorrect: LitRubbish takes a RuntimeRep such as IntRep,
      while primRepToType returns a type such as Any @(TYPE IntRep). Use
      primRepToRuntimeRep instead.
      This code is never run in the testsuite.
    * In StgToByteCode, all rubbish literals were assumed to be boxed.
      This code predates representation-polymorphic RubbishLit and I think
      it was not updated.
    
    I don't have a testcase for any of those issues, but the code looks
    wrong.
    
    - - - - -
    93c16b94 by sheaf at 2022-04-22T08:00:57-04:00
    Relax "suppressing errors" assert in reportWanteds
    
    The assertion in reportWanteds that we aren't suppressing all the
    Wanted constraints was too strong: it might be the case that we are
    inside an implication, and have already reported an unsolved Wanted
    from outside the implication. It is possible that all Wanteds inside
    the implication have been rewritten by the outer Wanted, so we shouldn't
    throw an assertion failure in that case.
    
    Fixes #21405
    
    - - - - -
    78ec692d by Andreas Klebinger at 2022-04-22T08:01:33-04:00
    Mention new MutableByteArray# wrapper in base changelog.
    
    - - - - -
    56d7cb53 by Eric Lindblad at 2022-04-22T14:13:32-04:00
    unlist announce
    
    - - - - -
    1e4dcf23 by sheaf at 2022-04-22T14:14:12-04:00
    decideMonoTyVars: account for CoVars in candidates
    
    The "candidates" passed to decideMonoTyVars can contain coercion holes.
    This is because we might well decide to quantify over some unsolved
    equality constraints, as long as they are not definitely insoluble.
    
    In that situation, decideMonoTyVars was passing a set of type variables
    that was not closed over kinds to closeWrtFunDeps, which was tripping
    up an assertion failure.
    
    Fixes #21404
    
    - - - - -
    2c541f99 by Simon Peyton Jones at 2022-04-22T14:14:47-04:00
    Improve floated dicts in Specialise
    
    Second fix to #21391.  It turned out that we missed calling
    bringFloatedDictsIntoScope when specialising imports, which
    led to the same bug as before.
    
    I refactored to move that call to a single place, in specCalls,
    so we can't forget it.
    
    This meant making `FloatedDictBinds` into its own type, pairing
    the dictionary bindings themselves with the set of their binders.
    Nicer this way.
    
    - - - - -
    0950e2c4 by Ben Gamari at 2022-04-25T10:18:17-04:00
    hadrian: Ensure that --extra-lib-dirs are used
    
    Previously we only took `extraLibDirs` and friends from the package
    description, ignoring any contribution from the `LocalBuildInfo`. Fix
    this.
    
    Fixes #20566.
    
    - - - - -
    53cc93ae by Ben Gamari at 2022-04-25T10:18:17-04:00
    hadrian: Drop redundant include directories
    
    The package-specific include directories in
    Settings.Builders.Common.cIncludeDirs are now redundant since they now
    come from Cabal.
    
    Closes #20566.
    
    - - - - -
    b2721819 by Ben Gamari at 2022-04-25T10:18:17-04:00
    hadrian: Clean up handling of libffi dependencies
    
    - - - - -
    18e5103f by Ben Gamari at 2022-04-25T10:18:17-04:00
    testsuite: More robust library way detection
    
    Previously `test.mk` would try to determine whether the dynamic,
    profiling, and vanilla library ways are available by searching for
    `PrimOpWrappers.{,dyn_,p_}hi` in directory reported by `ghc-pkg field
    ghc-prim library-dirs`. However, this is extremely fragile as
    there is no guarantee that there is only one library directory. To
    handle the case of multiple `library-dirs` correct we would
    have to carry out the delicate task of tokenising the directory list (in
    shell, no less).
    
    Since this isn't a task that I am eager to solve, I have rather moved
    the detection logic into the testsuite driver and instead perform a test
    compilation in each of the ways. This should be more robust than the
    previous approach.
    
    I stumbled upon this while fixing #20579.
    
    - - - - -
    6c7a4913 by Ben Gamari at 2022-04-25T10:18:17-04:00
    testsuite: Cabalify ghc-config
    
    To ensure that the build benefits from Hadrian's usual logic for building
    packages, avoiding #21409.
    
    Closes #21409.
    
    - - - - -
    9af091f7 by Ben Gamari at 2022-04-25T10:18:53-04:00
    rts: Factor out built-in GC roots
    
    - - - - -
    e7c4719d by Ben Gamari at 2022-04-25T10:18:54-04:00
    Ensure that wired-in exception closures aren't GC'd
    
    As described in Note [Wired-in exceptions are not CAFfy], a small set of
    built-in exception closures get special treatment in the code generator,
    being declared as non-CAFfy despite potentially containing CAF
    references. The original intent of this treatment for the RTS to then
    add StablePtrs for each of the closures, ensuring that they are not
    GC'd. However, this logic was not applied consistently and eventually
    removed entirely in 951c1fb0. This lead to #21141.
    
    Here we fix this bug by reintroducing the StablePtrs and document the
    status quo.
    
    Closes #21141.
    
    - - - - -
    9587726f by Ben Gamari at 2022-04-25T10:18:54-04:00
    testsuite: Add testcase for #21141
    
    - - - - -
    cb71226f by Ben Gamari at 2022-04-25T10:19:29-04:00
    Drop dead code in GHC.Linker.Static.linkBinary'
    
    Previously we supported building statically-linked executables using
    libtool. However, this was dropped in
    91262e75dd1d80f8f28a3922934ec7e59290e28c in favor of using ar/ranlib
    directly. Consequently we can drop this logic.
    
    Fixes #18826.
    
    - - - - -
    9420d26b by Ben Gamari at 2022-04-25T10:19:29-04:00
    Drop libtool path from settings file
    
    GHC no longers uses libtool for linking and therefore this is no longer
    necessary.
    
    - - - - -
    41cf758b by Ben Gamari at 2022-04-25T10:19:29-04:00
    Drop remaining vestiges of libtool
    
    Drop libtool logic from gen-dll, allowing us to drop the remaining logic
    from the `configure` script.
    
    Strangely, this appears to reliably reduce compiler allocations of
    T16875 on Windows.
    
    Closes #18826.
    
    Metric Decrease:
        T16875
    
    - - - - -
    e09afbf2 by Ben Gamari at 2022-04-25T10:20:05-04:00
    rts: Refactor handling of dead threads' stacks
    
    This fixes a bug that @JunmingZhao42 and I noticed while working on her
    MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a
    sentinel at the tail of a stack after a thread has completed. However,
    stg_enter_info expects to have a two-field payload, which we do not
    push. Consequently, if the GC ends up somehow the stack it will attempt
    to interpret data past the end of the stack as the frame's fields,
    resulting in unsound behavior.
    
    To fix this I eliminate this hacky use of `stg_stop_thread` and instead
    introduce a new stack frame type, `stg_dead_thread_info`. Not only does
    this eliminate the potential for the previously mentioned memory
    unsoundness but it also more clearly captures the intended structure of
    the dead threads' stacks.
    
    - - - - -
    e76705cf by Ben Gamari at 2022-04-25T10:20:05-04:00
    rts: Improve documentation of closure types
    
    Also drops the unused TREC_COMMITTED transaction state.
    
    - - - - -
    f2c08124 by Andrew Lelechenko at 2022-04-25T10:20:44-04:00
    Document behaviour of RULES with KnownNat
    
    - - - - -
    360dc2bc by Li-yao Xia at 2022-04-25T19:13:06+00:00
    Fix rendering of liftA haddock
    
    - - - - -
    16df6058 by Ben Gamari at 2022-04-27T10:02:25-04:00
    testsuite: Report minimum and maximum stat changes
    
    As suggested in #20733.
    
    - - - - -
    e39cab62 by Fabian Thorand at 2022-04-27T10:03:03-04:00
    Defer freeing of mega block groups
    
    Solves the quadratic worst case performance of freeing megablocks that
    was described in issue #19897.
    
    During GC runs, we now keep a secondary free list for megablocks that is
    neither sorted, nor coalesced. That way, free becomes an O(1) operation
    at the expense of not being able to reuse memory for larger allocations.
    At the end of a GC run, the secondary free list is sorted and then
    merged into the actual free list in a single pass.
    
    That way, our worst case performance is O(n log(n)) rather than O(n^2).
    
    We postulate that temporarily losing coalescense during a single GC run
    won't have any adverse effects in practice because:
    
    - We would need to release enough memory during the GC, and then after
      that (but within the same GC run) allocate a megablock group of more
      than one megablock. This seems unlikely, as large objects are not
      copied during GC, and so we shouldn't need such large allocations
      during a GC run.
    - Allocations of megablock groups of more than one megablock are rare.
      They only happen when a single heap object is large enough to require
      that amount of space. Any allocation areas that are supposed to hold
      more than one heap object cannot use megablock groups, because only
      the first megablock of a megablock group has valid `bdescr`s. Thus,
      heap object can only start in the first megablock of a group, not in
      later ones.
    
    - - - - -
    5de6be0c by Fabian Thorand at 2022-04-27T10:03:03-04:00
    Add note about inefficiency in returnMemoryToOS
    
    - - - - -
    8bef471a by sheaf at 2022-04-27T10:03:43-04:00
    Ensure that Any is Boxed in FFI imports/exports
    
    We should only accept the type `Any` in foreign import/export
    declarations when it has type `Type` or `UnliftedType`.
    This patch adds a kind check, and a special error message triggered by
    occurrences of `Any` in foreign import/export declarations at other
    kinds.
    
    Fixes #21305
    
    - - - - -
    ba3d4e1c by Ben Gamari at 2022-04-27T10:04:19-04:00
    Basic response file support
    
    Here we introduce support into our command-line parsing infrastructure
    and driver for handling gnu-style response file arguments,
    typically used to work around platform command-line length limitations.
    
    Fixes #16476.
    
    - - - - -
    3b6061be by Ben Gamari at 2022-04-27T10:04:19-04:00
    testsuite: Add test for #16476
    
    - - - - -
    75bf1337 by Matthew Pickering at 2022-04-27T10:04:55-04:00
    ci: Fix cabal-reinstall job
    
    It's quite nice we can do this by mostly deleting code
    
    Fixes #21373
    
    - - - - -
    2c00d904 by Matthew Pickering at 2022-04-27T10:04:55-04:00
    ci: Add test to check that release jobs have profiled libs
    
    - - - - -
    50d78d3b by Matthew Pickering at 2022-04-27T10:04:55-04:00
    ci: Explicitly handle failures in test_hadrian
    
    We also disable the stage1 testing which is broken.
    
    Related to #21072
    
    - - - - -
    2dcdf091 by Matthew Pickering at 2022-04-27T10:04:55-04:00
    ci: Fix shell command
    
    - - - - -
    55c84123 by Matthew Pickering at 2022-04-27T10:04:55-04:00
    bootstrap: Add bootstrapping files for ghc-9_2_2
    
    Fixes #21373
    
    - - - - -
    c7ee0be6 by Matthew Pickering at 2022-04-27T10:04:55-04:00
    ci: Add linting job which checks authors are not GHC CI
    
    - - - - -
    23aad124 by Adam Sandberg Ericsson at 2022-04-27T10:05:31-04:00
    rts: state explicitly what evacuate and scavange mean in the copying gc
    
    - - - - -
    318e0005 by Ben Gamari at 2022-04-27T10:06:07-04:00
    rts/eventlog: Don't attempt to flush if there is no writer
    
    If the user has not configured a writer then there is nothing to flush.
    
    - - - - -
    ee11d043 by Ben Gamari at 2022-04-27T10:06:07-04:00
    Enable eventlog support in all ways by default
    
    Here we deprecate the eventlogging RTS ways and instead enable eventlog
    support in the remaining ways. This simplifies packaging and reduces GHC
    compilation times (as we can eliminate two whole compilations of the RTS)
    while simplifying the end-user story. The trade-off is a small increase
    in binary sizes in the case that the user does not want eventlogging
    support, but we think that this is a fine trade-off.
    
    This also revealed a latent RTS bug: some files which included `Cmm.h`
    also assumed that it defined various macros which were in fact defined
    by `Config.h`, which `Cmm.h` did not include. Fixing this in turn
    revealed that `StgMiscClosures.cmm` failed to import various spinlock
    statistics counters, as evidenced by the failed unregisterised build.
    
    Closes #18948.
    
    - - - - -
    a2e5ab70 by Andreas Klebinger at 2022-04-27T10:06:43-04:00
    Change `-dsuppress-ticks` to only suppress non-code ticks.
    
    This means cost centres and coverage ticks will still be present in
    output. Makes using -dsuppress-all more convenient when looking at
    profiled builds.
    
    - - - - -
    ec9d7e04 by Ben Gamari at 2022-04-27T10:07:21-04:00
    Bump text submodule.
    
    This should fix #21352
    
    - - - - -
    c3105be4 by Andrew Lelechenko at 2022-04-27T10:08:01-04:00
    Documentation for setLocaleEncoding
    
    - - - - -
    7f618fd3 by sheaf at 2022-04-27T10:08:40-04:00
    Update docs for change to type-checking plugins
    
    There was no mention of the changes to type-checking plugins
    in the 9.4.1 notes, and the extending_ghc documentation contained
    a reference to an outdated type.
    
    - - - - -
    4419dd3a by Adam Sandberg Ericsson at 2022-04-27T10:09:18-04:00
    rts: add some more documentation to StgWeak closure type
    
    - - - - -
    5a7f0dee by Matthew Pickering at 2022-04-27T10:09:54-04:00
    Give Cmm files fake ModuleNames which include full filepath
    
    This fixes the initialisation functions when using -prof or
    -finfo-table-map.
    
    Fixes #21370
    
    - - - - -
    81cf52bb by sheaf at 2022-04-27T10:10:33-04:00
    Mark GHC.Prim.PtrEq as Unsafe
    
    This module exports unsafe pointer equality operations,
    so we accordingly mark it as Unsafe.
    
    Fixes #21433
    
    - - - - -
    f6a8185d by Ben Gamari at 2022-04-28T09:10:31+00:00
    testsuite: Add performance test for #14766
    
    This distills the essence of the Sigs.hs program found in the ticket.
    
    - - - - -
    c7a3dc29 by Douglas Wilson at 2022-04-28T18:54:44-04:00
    hadrian: Add Monoid instance to Way
    
    - - - - -
    654bafea by Douglas Wilson at 2022-04-28T18:54:44-04:00
    hadrian: Enrich flavours to build profiled/debugged/threaded ghcs per stage
    
    - - - - -
    4ad559c8 by Douglas Wilson at 2022-04-28T18:54:44-04:00
    hadrian: add debug_ghc and debug_stage1_ghc flavour transformers
    
    - - - - -
    f9728fdb by Douglas Wilson at 2022-04-28T18:54:44-04:00
    hadrian: Don't pass -rtsopts when building libraries
    
    - - - - -
    769279e6 by Matthew Pickering at 2022-04-28T18:54:44-04:00
    testsuite: Fix calculation about whether to pass -dynamic to compiler
    
    - - - - -
    da8ae7f2 by Ben Gamari at 2022-04-28T18:55:20-04:00
    hadrian: Clean up flavour transformer definitions
    
    Previously the `ipe` and `omit_pragmas` transformers were hackily
    defined using the textual key-value syntax. Fix this.
    
    - - - - -
    61305184 by Ben Gamari at 2022-04-28T18:55:56-04:00
    Bump process submodule
    
    - - - - -
    a8c99391 by sheaf at 2022-04-28T18:56:37-04:00
    Fix unification of ConcreteTvs, removing IsRefl#
    
    This patch fixes the unification of concrete type variables.
    The subtlety was that unifying concrete metavariables is more subtle
    than other metavariables, as decomposition is possible. See the Note
    [Unifying concrete metavariables], which explains how we unify a
    concrete type variable with a type 'ty' by concretising 'ty', using
    the function 'GHC.Tc.Utils.Concrete.concretise'.
    
    This can be used to perform an eager syntactic check for concreteness,
    allowing us to remove the IsRefl# special predicate. Instead of emitting
    two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we
    instead concretise 'rr'. If this succeeds we can fill 'concrete_tv',
    and otherwise we directly emit an error message to the typechecker
    environment instead of deferring. We still need the error message
    to be passed on (instead of directly thrown), as we might benefit from
    further unification in which case we will need to zonk the stored types.
    To achieve this, we change the 'wc_holes' field of 'WantedConstraints'
    to 'wc_errors', which stores general delayed errors. For the moement,
    a delayed error is either a hole, or a syntactic equality error.
    
    hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and
    hasFixedRuntimeRep has been refactored to directly return the most
    useful coercion for PHASE 2 of FixedRuntimeRep.
    
    This patch also adds a field ir_frr to the InferResult datatype,
    holding a value of type Maybe FRROrigin. When this value is not
    Nothing, this means that we must fill the ir_ref field with a type
    which has a fixed RuntimeRep.
    When it comes time to fill such an ExpType, we ensure that the type
    has a fixed RuntimeRep by performing a representation-polymorphism
    check with the given FRROrigin
    This is similar to what we already do to ensure we fill an Infer
    ExpType with a type of the correct TcLevel.
    This allows us to properly perform representation-polymorphism checks
    on 'Infer' 'ExpTypes'.
    
    The fillInferResult function had to be moved to GHC.Tc.Utils.Unify
    to avoid a cyclic import now that it calls hasFixedRuntimeRep.
    
    This patch also changes the code in matchExpectedFunTys to make use
    of the coercions, which is now possible thanks to the previous change.
    This implements PHASE 2 of FixedRuntimeRep in some situations.
    For example, the test cases T13105 and T17536b are now both accepted.
    
    Fixes #21239 and #21325
    
    -------------------------
    Metric Decrease:
        T18223
        T5631
    -------------------------
    
    - - - - -
    43bd897d by Simon Peyton Jones at 2022-04-28T18:57:13-04:00
    Add INLINE pragmas for Enum helper methods
    
    As #21343 showed, we need to be super-certain that the "helper
    methods" for Enum instances are actually inlined or specialised.
    
    I also tripped over this when I discovered that numericEnumFromTo
    and friends had no pragmas at all, so their performance was very
    fragile.  If they weren't inlined, all bets were off.  So I've added
    INLINE pragmas for them too.
    
    See new Note [Inline Enum method helpers] in GHC.Enum.
    
    I also expanded Note [Checking for INLINE loop breakers] in
    GHC.Core.Lint to explain why an INLINE function might temporarily
    be a loop breaker -- this was the initial bug report in #21343.
    
    Strangely we get a 16% runtime allocation decrease in
    perf/should_run/T15185, but only on i386.  Since it moves in the right
    direction I'm disinclined to investigate, so I'll accept it.
    
    Metric Decrease:
        T15185
    
    - - - - -
    ca1434e3 by Ben Gamari at 2022-04-28T18:57:49-04:00
    configure: Bump GHC version to 9.5
    
    Bumps haddock submodule.
    
    - - - - -
    292e3971 by Teo Camarasu at 2022-04-28T18:58:28-04:00
    add since annotation for GHC.Stack.CCS.whereFrom
    
    - - - - -
    905206d6 by Tamar Christina at 2022-04-28T22:19:34-04:00
    winio: add support to iserv.
    
    - - - - -
    d182897e by Tamar Christina at 2022-04-28T22:19:34-04:00
    Remove unused line
    - - - - -
    22cf4698 by Matthew Pickering at 2022-04-28T22:20:10-04:00
    Revert "rts: Refactor handling of dead threads' stacks"
    
    This reverts commit e09afbf2a998beea7783e3de5dce5dd3c6ff23db.
    
    - - - - -
    8ed57135 by Matthew Pickering at 2022-04-29T04:11:29-04:00
    Provide efficient unionMG function for combining two module graphs.
    
    This function is used by API clients (hls).
    
    This supercedes !6922
    
    - - - - -
    0235ff02 by Ben Gamari at 2022-04-29T04:12:05-04:00
    Bump bytestring submodule
    
    Update to current `master`.
    
    - - - - -
    01988418 by Matthew Pickering at 2022-04-29T04:12:05-04:00
    testsuite: Normalise package versions in UnusedPackages test
    
    - - - - -
    724d0dc0 by Matthew Pickering at 2022-04-29T08:59:42+00:00
    testsuite: Deduplicate ways correctly
    
    This was leading to a bug where we would run a profasm test twice which
    led to invalid junit.xml which meant the test results database was not
    being populated for the fedora33-perf job.
    
    - - - - -
    5630dde6 by Ben Gamari at 2022-04-29T13:06:20-04:00
    rts: Refactor handling of dead threads' stacks
    
    This fixes a bug that @JunmingZhao42 and I noticed while working on her
    MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a
    sentinel at the tail of a stack after a thread has completed. However,
    stg_enter_info expects to have a two-field payload, which we do not
    push. Consequently, if the GC ends up somehow the stack it will attempt
    to interpret data past the end of the stack as the frame's fields,
    resulting in unsound behavior.
    
    To fix this I eliminate this hacky use of `stg_stop_thread` and instead
    introduce a new stack frame type, `stg_dead_thread_info`. Not only does
    this eliminate the potential for the previously mentioned memory
    unsoundness but it also more clearly captures the intended structure of
    the dead threads' stacks.
    
    - - - - -
    0cdef807 by parsonsmatt at 2022-04-30T16:51:12-04:00
    Add a note about instance visibility across component boundaries
    
    In principle, the *visible* instances are
    * all instances defined in a prior top-level declaration group
      (see docs on `newDeclarationGroup`), or
    * all instances defined in any module transitively imported by the
      module being compiled
    
    However, actually searching all modules transitively below the one being
    compiled is unreasonably expensive, so `reifyInstances` will report only the
    instance for modules that GHC has had some cause to visit during this
    compilation.  This is a shortcoming: `reifyInstances` might fail to report
    instances for a type that is otherwise unusued, or instances defined in a
    different component.  You can work around this shortcoming by explicitly importing the modules
    whose instances you want to be visible. GHC issue #20529
    has some discussion around this.
    
    Fixes #20529
    
    - - - - -
    e2dd884a by Ryan Scott at 2022-04-30T16:51:47-04:00
    Make mkFunCo take AnonArgFlags into account
    
    Previously, whenever `mkFunCo` would produce reflexive coercions, it would
    use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is
    also used to produce coercions between types of the form `ty1 => ty2` in
    certain places. This has the unfortunate side effect of causing the type of
    the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted
    in #21328.
    
    This patch address this by changing replacing the use of `mkVisFunTy` with
    `mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and
    makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`,
    so this should always produce the correct `AnonArgFlag`. As a result, this
    patch fixes part (2) of #21328.
    
    This is not the only possible way to fix #21328, as the discussion on that
    issue lists some possible alternatives. Ultimately, it was concluded that the
    alternatives would be difficult to maintain, and since we already use
    `mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType`
    in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType`
    does not regress the performance of any test case we have in GHC's test suite.
    
    - - - - -
    170da54f by Ben Gamari at 2022-04-30T16:52:27-04:00
    Convert More Diagnostics (#20116)
    
    Replaces uses of `TcRnUnknownMessage` with proper diagnostics
    constructors.
    
    - - - - -
    39edc7b4 by Marius Ghita at 2022-04-30T16:53:06-04:00
    Update user guide example rewrite rules formatting
    
    Change the rewrite rule examples to include a space between the
    composition of `f` and `g` in the map rewrite rule examples.
    
    Without this change, if the user has locally enabled the extension
    OverloadedRecordDot the copied example will result in a compile time
    error that `g` is not a field of `f`.
    
    ```
        • Could not deduce (GHC.Records.HasField "g" (a -> b) (a1 -> b))
            arising from selecting the field ‘g’
    ```
    
    - - - - -
    2e951e48 by Adam Sandberg Ericsson at 2022-04-30T16:53:42-04:00
    ghc-boot: export typesynonyms from GHC.Utils.Encoding
    
    This makes the Haddocks easier to understand.
    
    - - - - -
    d8cbc77e by Adam Sandberg Ericsson at 2022-04-30T16:54:18-04:00
    users guide: add categories to some flags
    
    - - - - -
    d0f14fad by Chris Martin at 2022-04-30T16:54:57-04:00
    hacking guide: mention the core libraries committee
    
    - - - - -
    34b28200 by Matthew Pickering at 2022-04-30T16:55:32-04:00
    Revert "Make the specialiser handle polymorphic specialisation"
    
    This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8.
    
    See ticket #21229
    
    -------------------------
    Metric Decrease:
        T15164
    Metric Increase:
        T13056
    -------------------------
    
    - - - - -
    ee891c1e by Matthew Pickering at 2022-04-30T16:55:32-04:00
    Add test for T21229
    
    - - - - -
    ab677cc8 by Matthew Pickering at 2022-04-30T16:56:08-04:00
    Hadrian: Update README about the flavour/testsuite contract
    
    There have been a number of tickets about non-tested flavours not
    passing the testsuite.. this is expected and now noted in the
    documentation. You use other flavours to run the testsuite at your own
    risk.
    
    Fixes #21418
    
    - - - - -
    b57b5b92 by Ben Gamari at 2022-04-30T16:56:44-04:00
    rts/m32: Fix assertion failure
    
    This fixes an assertion failure in the m32 allocator due to the
    imprecisely specified preconditions of `m32_allocator_push_filled_list`.
    Specifically, the caller must ensure that the page type is set to filled
    prior to calling `m32_allocator_push_filled_list`.
    
    While this issue did result in an assertion failure in the debug RTS,
    the issue is in fact benign.
    
    - - - - -
    a7053a6c by sheaf at 2022-04-30T16:57:23-04:00
    Testsuite driver: don't crash on empty metrics
    
    The testsuite driver crashed when trying to display minimum/maximum
    performance changes when there are no metrics (i.e. there is
    no baseline available). This patch fixes that.
    
    - - - - -
    636f7c62 by Andreas Klebinger at 2022-05-01T22:21:17-04:00
    StgLint: Check that functions are applied to compatible runtime reps
    
    We use compatibleRep to compare reps, and avoid checking functions with
    levity polymorphic types because of #21399.
    
    - - - - -
    60071076 by Hécate Moonlight at 2022-05-01T22:21:55-04:00
    Add documentation to the ByteArray# primetype.
    
    close #21417
    
    - - - - -
    2b2e3020 by Andreas Klebinger at 2022-05-01T22:22:31-04:00
    exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is bottoming.
    
    We used to check the divergence and that the number of arguments > arity.
    But arity zero represents unknown arity so this was subtly broken for a long time!
    
    We would check if the saturated function diverges, and if we applied >=arity arguments.
    But for unknown arity functions any number of arguments is >=idArity.
    
    This fixes #21440.
    
    - - - - -
    4eaf0f33 by Eric Lindblad at 2022-05-01T22:23:11-04:00
    typos
    - - - - -
    fc58df90 by Niklas Hambüchen at 2022-05-02T08:59:27+00:00
    libraries/base: docs: Explain relationshipt between `finalizeForeignPtr` and `*Conc*` creation
    
    Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/21420
    
    - - - - -
    3e400f20 by Krzysztof Gogolewski at 2022-05-02T18:29:23-04:00
    Remove obsolete code in CoreToStg
    
    Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4.
    This codepath is tested by T15696_3.
    
    - - - - -
    4a780928 by Krzysztof Gogolewski at 2022-05-02T18:29:24-04:00
    Fix several note references
    
    - - - - -
    15ffe2b0 by Sebastian Graf at 2022-05-03T20:11:51+02:00
    Assume at least one evaluation for nested SubDemands (#21081, #21133)
    
    See the new `Note [SubDemand denotes at least one evaluation]`.
    
    A demand `n :* sd` on a let binder `x=e` now means
    
    > "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is
    >  evaluated deeply in sub-demand `sd`."
    
    The "any time it is evaluated" premise is what this patch adds. As a result,
    we get better nested strictness. For example (T21081)
    ```hs
    f :: (Bool, Bool) -> (Bool, Bool)
    f pr = (case pr of (a,b) -> a /= b, True)
    -- before: <MP(L,L)>
    -- after:  <MP(SL,SL)>
    
    g :: Int -> (Bool, Bool)
    g x = let y = let z = odd x in (z,z) in f y
    ```
    The change in demand signature "before" to "after" allows us to case-bind `z`
    here.
    
    Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which
    allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`,
    albeit).
    
    We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand
    expansion.
    
    In an attempt to fix a regression caused by less inlining due to eta-reduction
    in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus
    fixing #21345 on the go.
    
    The main point of this patch is that it fixes #21081 and #21133.
    
    Annoyingly, I discovered that more precise demand signatures for join points can
    transform a program into a lazier program if that join point gets floated to the
    top-level, see #21392. There is no simple fix at the moment, but !5349 might.
    Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392
    bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue.
    
    Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by
    0.4% in the geometric mean and by 2% in T16875.
    
    Metric Increase:
        MultiLayerModulesTH_OneShot
    Metric Decrease:
        T16875
    
    - - - - -
    948c7e40 by Andreas Klebinger at 2022-05-04T09:57:34-04:00
    CoreLint - When checking for levity polymorphism look through more ticks.
    
    For expressions like `(scc<cc_name> primOp#) arg1` we should also look
    at arg1 to determine if we call primOp# at a fixed runtime rep.
    
    This is what corePrep already does but CoreLint didn't yet. This patch
    will bring them in sync in this regard.
    
    It also uses tickishFloatable in CorePrep instead of CorePrep having
    it's own slightly differing definition of when a tick is floatable.
    
    - - - - -
    85bc73bd by Alexis King at 2022-05-04T09:58:14-04:00
    genprimopcode: Support Unicode properly
    
    - - - - -
    063d485e by Alexis King at 2022-05-04T09:58:14-04:00
    genprimopcode: Replace LaTeX documentation syntax with Haddock
    
    The LaTeX documentation generator does not seem to have been used for
    quite some time, so the LaTeX-to-Haddock preprocessing step has become a
    pointless complication that makes documenting the contents of GHC.Prim
    needlessly difficult. This commit replaces the LaTeX syntax with the
    Haddock it would have been converted into, anyway, though with an
    additional distinction: it uses single quotes in places to instruct
    Haddock to generate hyperlinks to bindings. This improves the quality of
    the generated output.
    
    - - - - -
    d61f7428 by Ben Gamari at 2022-05-04T09:58:50-04:00
    rts/ghc.mk: Only build StgCRunAsm.S when it is needed
    
    Previously the make build system unconditionally included StgCRunAsm.S
    in the link, meaning that the RTS would require an execstack
    unnecessarily.
    
    Fixes #21478.
    
    - - - - -
    934a90dd by Simon Peyton Jones at 2022-05-04T16:15:34-04:00
    Improve error reporting in generated code
    
    Our error reporting in generated code (via desugaring before
    typechecking) only worked when the generated code was just a simple
    call. This commit makes it work in nested cases.
    
    - - - - -
    445d3657 by sheaf at 2022-05-04T16:16:12-04:00
    Ensure Any is not levity-polymorphic in FFI
    
    The previous patch forgot to account for a type such as
    
      Any @(TYPE (BoxedRep l))
    
    for a quantified levity variable l.
    
    - - - - -
    ddd2591c by Ben Gamari at 2022-05-04T16:16:48-04:00
    Update supported LLVM versions
    
    Pull forward minimum version to match 9.2.
    
    (cherry picked from commit c26faa54c5fbe902ccb74e79d87e3fa705e270d1)
    
    - - - - -
    f9698d79 by Ben Gamari at 2022-05-04T16:16:48-04:00
    testsuite/T7275: Use sed -r
    
    Darwin requires the `-r` flag to be compatible with GNU sed.
    
    (cherry picked from commit 512338c8feec96c38ef0cf799f3a01b77c967c56)
    
    - - - - -
    8635323b by Ben Gamari at 2022-05-04T16:16:48-04:00
    gitlab-ci: Use ld.lld on ARMv7/Linux
    
    Due to #16177.
    
    Also cleanup some code style issues.
    
    (cherry picked from commit cc1c3861e2372f464bf9e3c9c4d4bd83f275a1a6)
    
    - - - - -
    4f6370c7 by Ben Gamari at 2022-05-04T16:16:48-04:00
    gitlab-ci: Always preserve artifacts, even in failed jobs
    
    (cherry picked from commit fd08b0c91ea3cab39184f1b1b1aafcd63ce6973f)
    
    - - - - -
    6f662754 by Ben Gamari at 2022-05-04T16:16:48-04:00
    configure: Make sphinx version check more robust
    
    It appears that the version of sphinx shipped on CentOS 7
    reports a version string of `Sphinx v1...`. Accept the `v`.
    
    (cherry picked from commit a9197a292fd4b13308dc6664c01351c7239357ed)
    
    - - - - -
    0032dc38 by Ben Gamari at 2022-05-04T16:16:48-04:00
    gitlab-ci: Don't run make job in release pipelines
    
    (cherry picked from commit 16d6a8ff011f2194485387dcca1c00f8ddcdbdeb)
    
    - - - - -
    27f9aab3 by Ben Gamari at 2022-05-04T16:16:48-04:00
    gitlab/ci: Fix name of bootstrap compiler directory
    
    Windows binary distributions built with Hadrian have a target platform
    suffix in the name of their root directory. Teach `ci.sh` about this
    fact.
    
    (cherry picked from commit df5752f39671f6d04d8cd743003469ae5eb67235)
    
    - - - - -
    b528f0f6 by Krzysztof Gogolewski at 2022-05-05T09:05:43-04:00
    Fix several note references, part 2
    
    - - - - -
    691aacf6 by Adam Sandberg Ericsson at 2022-05-05T09:06:19-04:00
    adjustors: align comment about number of integer like arguments with implementation for Amd4+MinGW implementation
    
    - - - - -
    f050557e by Simon Jakobi at 2022-05-05T12:47:32-04:00
    Remove two uses of IntMap.size
    
    IntMap.size is O(n). The new code should be slightly more efficient.
    
    The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be
    described formally as the transformation:
    
        (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n
        ==>
        (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk)
    
    - - - - -
    7da90ae3 by Tom Ellis at 2022-05-05T12:48:09-04:00
    Explain that 'fail s' should run in the monad itself
    
    - - - - -
    610d0283 by Matthew Craven at 2022-05-05T12:48:47-04:00
    Add a test for the bracketing in rules for (^)
    
    - - - - -
    016f9ca6 by Matthew Craven at 2022-05-05T12:48:47-04:00
    Fix broken rules for (^) with known small powers
    
    - - - - -
    9372aaab by Matthew Craven at 2022-05-05T12:48:47-04:00
    Give the two T19569 tests different names
    
    - - - - -
    61901b32 by Andreas Klebinger at 2022-05-05T12:49:23-04:00
    SpecConstr: Properly create rules for call patterns representing partial applications
    
    The main fix is that in addVoidWorkerArg we now add the argument to the front.
    
    This fixes #21448.
    
    -------------------------
    Metric Decrease:
        T16875
    -------------------------
    
    - - - - -
    71278dc7 by Teo Camarasu at 2022-05-05T12:50:03-04:00
    add since annotations for instances of ByteArray
    
    - - - - -
    962ff90b by sheaf at 2022-05-05T12:50:42-04:00
    Start 9.6.1-notes
    
    Updates the documentation notes to start tracking changes for
    the 9.6.1 release (instead of 9.4).
    
    - - - - -
    aacb15a3 by Matthew Pickering at 2022-05-05T20:24:01-04:00
    ci: Add job to check that jobs.yaml is up-to-date
    
    There have been quite a few situations where jobs.yaml has been out of
    date. It's better to add a CI job which checks that it's right.
    
    We don't want to use a staged pipeline because it obfuscates the
    structure of the pipeline.
    
    - - - - -
    be7102e5 by Ben Gamari at 2022-05-05T20:24:37-04:00
    rts: Ensure that XMM registers are preserved on Win64
    
    Previously we only preserved the bottom 64-bits of the callee-saved
    128-bit XMM registers, in violation of the Win64 calling convention.
    Fix this.
    
    Fixes #21465.
    
    - - - - -
    73b22ff1 by Ben Gamari at 2022-05-05T20:24:37-04:00
    testsuite: Add test for #21465
    
    - - - - -
    e2ae9518 by Ziyang Liu at 2022-05-06T19:22:22-04:00
    Allow `let` just before pure/return in ApplicativeDo
    
    The following is currently rejected:
    
    ```haskell
    -- F is an Applicative but not a Monad
    x :: F (Int, Int)
    x = do
      a <- pure 0
      let b = 1
      pure (a, b)
    ```
    
    This has bitten me multiple times. This MR contains a simple fix:
    only allow a "let only" segment to be merged with the next (and not
    the previous) segment. As a result, when the last one or more
    statements before pure/return are `LetStmt`s, there will be one
    more segment containing only those `LetStmt`s.
    
    Note that if the `let` statement mentions a name bound previously, then
    the program is still rejected, for example
    
    ```haskell
    x = do
      a <- pure 0
      let b = a + 1
      pure (a, b)
    ```
    
    or the example in #18559. To support this would require a more
    complex approach, but this is IME much less common than the
    previous case.
    
    - - - - -
    0415449a by Matthew Pickering at 2022-05-06T19:22:58-04:00
    template-haskell: Fix representation of OPAQUE pragmas
    
    There is a mis-match between the TH representation of OPAQUE pragmas and
    GHC's internal representation due to how OPAQUE pragmas disallow phase
    annotations. It seemed most in keeping to just fix the wired in name
    issue by adding a special case to the desugaring of INLINE pragmas
    rather than making TH/GHC agree with how the representation should look.
    
    Fixes #21463
    
    - - - - -
    4de887e2 by Simon Peyton Jones at 2022-05-06T19:23:34-04:00
    Comments only: Note [AppCtxt]
    
    - - - - -
    6e69964d by Matthew Pickering at 2022-05-06T19:24:10-04:00
    Fix name of windows release bindist in doc-tarball job
    
    - - - - -
    ced4689e by Matthew Pickering at 2022-05-06T19:24:46-04:00
    ci: Generate source-tarball in release jobs
    
    We need to distribute the source tarball so we should generate it in the
    CI pipeline.
    
    - - - - -
    3c91de21 by Rob at 2022-05-08T13:40:53+02:00
    Change Specialise to use OrdList.
    
    Fixes #21362
    
    Metric Decrease:
        T16875
    
    - - - - -
    67072c31 by Simon Jakobi at 2022-05-08T12:23:43-04:00
    Tweak GHC.CmmToAsm.CFG.delEdge
    
    mapAdjust is more efficient than mapAlter.
    
    - - - - -
    374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00
    Respect -po when heap profiling (#21446)
    
    - - - - -
    1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00
    add test case for #21446
    
    - - - - -
    c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00
    avoid hadrian/bindist/Makefile install_docs error when --docs=none
    
    When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated.
    Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index
    to avoid the error:
    
    /usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory
    make: *** [Makefile:195: install_docs] Error 1
    
    - - - - -
    158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00
    Correct base's changelog for 4.16.1.0
    
    This commit reaffects the new Ix instances of the foreign integral
    types from base 4.17 to 4.16.1.0
    
    closes #21529
    
    - - - - -
    a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00
    STG: only print cost-center if asked to
    
    - - - - -
    50347ded by Gergő Érdi at 2022-05-10T11:43:33+00:00
    Improve "Glomming" note
    
    Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order
    references, and thus needing to glom, is not a cause for concern when its
    root cause is rewrite rules.
    
    - - - - -
    df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00
    update INSTALL
    - - - - -
    dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00
    driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode
    
    It seems like it was just an oversight to use the incorrect DynFlags
    (global rather than local) when implementing these two options. Using
    the local flags allows users to request these intermediate files get
    cleaned up, which works fine in --make mode because
    
    1. Interface files are stored in memory
    2. Object files are only cleaned at the end of session (after link)
    
    Fixes #21349
    
    - - - - -
    35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00
    configure: Check for ffi.h
    
    As noted in #21485, we checked for ffi.h yet then failed to throw an
    error if it is missing.
    
    Fixes #21485.
    
    - - - - -
    bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00
    Check for uninferrable variables in tcInferPatSynDecl
    
    This fixes #21479
    
    See Note [Unquantified tyvars in a pattern synonym]
    
    While doing this, I found that some error messages pointed at the
    pattern synonym /name/, rather than the /declaration/ so I widened the
    SrcSpan to encompass the declaration.
    
    - - - - -
    142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00
    hadrian: Fix split-sections transformer
    
    The splitSections transformer has been broken since -dynamic-too support
    was implemented in hadrian. This is because we actually build the
    dynamic way when building the dynamic way, so the predicate would always
    fail.
    
    The fix is to just always pass `split-sections` even if it doesn't do
    anything for a particular way.
    
    Fixes #21138
    
    - - - - -
    699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00
    packaging: Build perf builds with -split-sections
    
    In 8f71d958 the make build system was made to use split-sections on
    linux systems but it appears this logic never made it to hadrian.
    There is the split_sections flavour transformer but this doesn't appear
    to be used for perf builds on linux.
    
    Closes #21135
    
    - - - - -
    21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00
    Use the wrapper for an unlifted binding
    
    We assumed the wrapper for an unlifted binding is the identity,
    but as #21516 showed, that is no always true.
    
    Solution is simple: use it.
    
    - - - - -
    68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00
    docs: Fix path to GHC API docs in index.html
    
    In the make bindists we generate documentation in docs/ghc-<VER> but the
    hadrian bindists generate docs/ghc/ so the path to the GHC API docs was
    wrong in the index.html file.
    
    Rather than make the hadrian and make bindists the same it was easier to
    assume that if you're using the mkDocs script that you're using hadrian
    bindists.
    
    Fixes #21509
    
    - - - - -
    9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00
    hadrian: Don't pass -j to haddock
    
    This has high potential for oversubcribing as many haddock jobs can be
    spawned in parralel which will each request the given number of
    capabilities.
    
    Once -jsem is implemented (#19416, !5176) we can expose that haddock via
    haddock and use that to pass a semaphore.
    
    Ticket #21136
    
    - - - - -
    fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00
    hadrian: Only copy and install libffi headers when using in-tree libffi
    
    When passed `--use-system-libffi` then we shouldn't copy and install the
    headers from the system package. Instead the headers are expected to be
    available as a runtime dependency on the users system.
    
    Fixes #21485 #21487
    
    - - - - -
    5b791ed3 by mikael at 2022-05-11T08:22:13-04:00
    FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10.
    
    - - - - -
    8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00
    Make floating-point abs IEEE 754 compliant
    
    The old code used by via-C backend didn't handle the sign bit of NaN.
    
    See #21043.
    
    - - - - -
    4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00
    EPA: do statement with leading semicolon has wrong anchor
    
    The code
    
        do; a <- doAsync; b
    
    Generated an incorrect Anchor for the statement list that starts after
    the first semicolon.
    
    This commit fixes it.
    
    Closes #20256
    
    - - - - -
    e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00
    Specialiser: saturate DFuns correctly
    
    Ticket #21489 showed that the saturation mechanism for
    DFuns (see Note Specialising DFuns) should use both
    UnspecType and UnspecArg.
    
    We weren't doing that; but this MR fixes that problem.
    
    No test case because it's hard to tickle, but it showed up in
    Gergo's work with GHC-as-a-library.
    
    - - - - -
    fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00
    gitlab-ci: Check for dynamic msys2 dependencies
    
    Both #20878 and #21196 were caused by unwanted dynamic dependencies
    being introduced by boot libraries. Ensure that we catch this in CI by
    attempting to run GHC in an environment with a minimal PATH.
    
    - - - - -
    3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00
    Add back Debian9 CI jobs
    
    We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
    not being at EOL until April 2023 and they still need tinfo5.
    
    Fixes #21469
    
    - - - - -
    dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00
    rts: Drop setExecutable
    
    Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been
    dead code. Drop it.
    
    - - - - -
    32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00
    Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat
    
    This missing guard gave rise to #21519.
    
    - - - - -
    2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00
    Add mention of -hi to RTS --help
    
    Fixes #21546
    
    - - - - -
    a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00
    Decouple dynflags in Cmm parser (related to #17957)
    
    - - - - -
    3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00
    Remove Module argument from initCmmParserConfig
    
    - - - - -
    2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00
    Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config
    
    - - - - -
    b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00
    Decouple dynflags in GHC.Core.Opt.Arity (related to #17957)
    
    Metric Decrease:
        T16875
    
    - - - - -
    3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00
    Update extending_ghc for TcPlugin changes
    
    The documentation still mentioned Derived constraints and
    an outdated datatype TcPluginResult.
    
    - - - - -
    668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00
    Fix printing of brackets in multiplicities (#20315)
    
    Change mulArrow to allow for printing of correct application precedence
    where necessary and update callers of mulArrow to reflect this.
    
    As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type.
    
    Fixes #20315
    
    - - - - -
    30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00
    rts: Add debug output on ocResolve failure
    
    This makes it easier to see how resolution failures nest.
    
    - - - - -
    53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00
    rts/PEi386: Fix handling of weak symbols
    
    Previously we would flag the symbol as weak but failed
    to set its address, which must be computed from an "auxiliary"
    symbol entry the follows the weak symbol.
    
    Fixes #21556.
    
    - - - - -
    5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00
    testsuite: Add tests for #21556
    
    - - - - -
    49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00
    Re-export augment and build from GHC.List
    
    Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127
    
    - - - - -
    aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00
    Comments only around HsWrapper
    
    - - - - -
    27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00
    hadrian: Introduce linting flavour transformer (+lint)
    
    The linting flavour enables -dlint uniformly across anything build by
    the stage1 compiler.
    
    -dcmm-lint is not currently enabled because it fails on i386 (see #21563)
    
    - - - - -
    3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00
    hadrian: Uniformly enable -dlint with enableLinting transformer
    
    This fixes some bugs where
    
    * -dcore-lint was being passed when building stage1 libraries with the
      boot compiler
    * -dcore-lint was not being passed when building executables.
    
    Fixes #20135
    
    - - - - -
    3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00
    Make closure macros EXTERN_INLINE to make debugging easier
    
    Implements #21424.
    
    The RTS macros get_itbl and friends are extremely helpful during debugging.
    However only a select few of those were available in the compiled RTS as actual symbols
    as the rest were INLINE macros.
    
    This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites
    but allow us to use their compiled counterparts during debugging.
    
    This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell
    since `get_fun_itbl` will now be available as symbol!
    
    - - - - -
    93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00
    packaging: Introduce CI job for generating hackage documentation
    
    This adds a CI job (hackage-doc-tarball) which generates the necessary
    tarballs for uploading libraries and documentation to hackage. The
    release script knows to download this folder and the upload script will
    also upload the release to hackage as part of the release.
    
    The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs
    
    There are two modes, preparation and upload.
    
    * The `prepare` mode takes a link to a bindist and creates a folder containing the
      source and doc tarballs ready to upload to hackage.
    * The `upload` mode takes the folder created by prepare and performs the upload to
      hackage.
    
    Fixes #21493
    
    Related to #21512
    
    - - - - -
    65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00
    Add arity to the INLINE pragmas for pattern synonyms
    
    The lack of INLNE arity was exposed by #21531.  The fix is
    simple enough, if a bit clumsy.
    
    - - - - -
    43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00
    Misc cleanup
    
    - Remove groupWithName (unused)
    - Use the RuntimeRepType synonym where possible
    - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM
    
    No functional changes.
    
    - - - - -
    8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00
    TcPlugin: access to irreducible givens + fix passed ev_binds_var
    
    - - - - -
    fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00
    driver: Introduce pgmcxx
    
    Here we introduce proper support for compilation of C++ objects. This
    includes:
    
     * logic in `configure` to detect the C++ toolchain and propagating this
       information into the `settings` file
     * logic in the driver to use the C++ toolchain when compiling C++
       sources
    
    - - - - -
    43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00
    testsuite: Build T20918 with HC, not CXX
    
    - - - - -
    0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00
    Introduce package to capture dependency on C++ stdlib
    
    Here we introduce a new "virtual" package into the initial package
    database, `system-cxx-std-lib`. This gives users a convenient, platform
    agnostic way to link against C++ libraries, addressing #20010.
    
    Fixes #20010.
    
    - - - - -
    03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00
    testsuite: Add tests for system-cxx-std-lib package
    
    Test that we can successfully link against C++ code both in GHCi and
    batch compilation.
    
    See #20010
    
    - - - - -
    5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00
    OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420)
    
    - - - - -
    eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00
    Adjust flags for pprTrace
    
    We were using defaultSDocContext for pprTrace, which suppresses
    lots of useful infomation. This small MR adds
    
       GHC.Utils.Outputable.traceSDocContext
    
    and uses it for pprTrace and pprTraceUserWarning.
    
    traceSDocContext is a global, and hence not influenced by flags,
    but that seems unavoidable.  But I made the sdocPprDebug bit
    controlled by unsafeHasPprDebug, since we have the latter for
    exactly this purpose.
    
    Fixes #21569
    
    - - - - -
    d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00
    Fix bad interaction between withDict and the Specialiser
    
    This MR fixes a bad bug, where the withDict was inlined too
    vigorously, which in turn made the type-class Specialiser generate
    a bogus specialisation, because it saw the same overloaded function
    applied to two /different/ dictionaries.
    
    Solution: inline `withDict` later.  See (WD8) of Note [withDict]
    in GHC.HsToCore.Expr
    
    See #21575, which is fixed by this change.
    
    - - - - -
    70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00
    Bump time submodule to 1.12.2
    
    This bumps the time submodule to the 1.12.2 release.
    
    Fixes #21571
    
    - - - - -
    2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00
    Remove unused test files (#21582)
    
    Those files were moved to the perf/ subtree in 11c9a469, and then
    accidentally reintroduced in 680ef2c8.
    
    - - - - -
    cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00
    CafAnal: Improve code clarity
    
    Here we implement a few measures to improve the clarity of the CAF
    analysis implementation. Specifically:
    
    * Use CafInfo instead of Bool since the former is more descriptive
    * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact
      CAFs
    * Add numerous comments
    
    - - - - -
    b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00
    codeGen: Ensure that static datacon apps are included in SRTs
    
    When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT
    filters out recursive references, as described in Note [recursive SRTs].
    However, doing so for static functions would be unsound, for the reason
    described in Note [Invalid optimisation: shortcutting].
    
    However, the same argument applies to static data constructor
    applications, as we discovered in #20959. Fix this by ensuring that
    static data constructor applications are included in recursive SRTs.
    
    The approach here is not entirely satisfactory, but it is a starting
    point.
    
    Fixes #20959.
    
    - - - - -
    0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00
    Add test for #21558
    
    This is now fixed on master and 9.2 branch.
    
    Closes #21558
    
    - - - - -
    ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00
    Don't store LlvmConfig into DynFlags
    
    LlvmConfig contains information read from llvm-passes and llvm-targets
    files in GHC's top directory. Reading these files is done only when
    needed (i.e. when the LLVM backend is used) and cached for the whole
    compiler session. This patch changes the way this is done:
    
    - Split LlvmConfig into LlvmConfig and LlvmConfigCache
    
    - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no
      good reason to store it in DynFlags. As it is fixed per session, we
      store it in the session state instead (HscEnv).
    
    - Initializing LlvmConfigCache required some changes to driver functions
      such as newHscEnv. I've used the opportunity to untangle initHscEnv
      from initGhcMonad (in top-level GHC module) and to move it to
      GHC.Driver.Main, close to newHscEnv.
    
    - I've also made `cmmPipeline` independent of HscEnv in order to remove
      the call to newHscEnv in regalloc_unit_tests.
    
    - - - - -
    828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00
    Give all EXTERN_INLINE closure macros prototypes
    
    - - - - -
    cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00
    base: Introduce [sg]etFinalizerExceptionHandler
    
    This introduces a global hook which is called when an exception is
    thrown during finalization.
    
    - - - - -
    372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00
    base: Throw exceptions raised while closing finalized Handles
    
    Fixes #21336.
    
    - - - - -
    3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00
    testsuite: Add tests for #21336
    
    - - - - -
    297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00
    Add release flavour and use it for the release jobs
    
    The release flavour is essentially the same as the perf flavour
    currently but also enables `-haddock`. I have hopefully updated all the
    relevant places where the `-perf` flavour was hardcoded.
    
    Fixes #21486
    
    - - - - -
    a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00
    ci: Don't build sphinx documentation on centos
    
    The centos docker image lacks the sphinx builder so we disable building
    sphinx docs for these jobs.
    
    Fixes #21580
    
    - - - - -
    209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00
    ci: Use correct syntax when args list is empty
    
    This seems to fail on the ancient version of bash present on CentOS
    
    - - - - -
    02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00
    hadrian: Don't attempt to build dynamic profiling libraries
    
    We only support building static profiling libraries, the transformer was
    requesting things like a dynamic, threaded, debug, profiling RTS, which
    we have never produced nor distributed.
    
    Fixes #21567
    
    - - - - -
    35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00
    configure: Check CC_STAGE0 for --target support
    
    We previously only checked the stage 1/2 compiler
    for --target support. We got away with this for quite a while but it
    eventually caught up with us in #21579, where `bytestring`'s new NEON
    implementation was unbuildable on Darwin due to Rosetta's seemingly
    random logic for determining which executable image to execute. This
    lead to a confusing failure to build `bytestring`'s cbits, when `clang`
    tried to compile NEON builtins while targetting x86-64.
    
    Fix this by checking CC_STAGE0 for --target support.
    
    Fixes #21579.
    
    - - - - -
    0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00
    add dominator analysis of `CmmGraph`
    
    This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper
    around two existing algorithms in GHC: the Lengauer-Tarjan dominator
    analysis from the X86 back end and the reverse postorder ordering from
    the Cmm Dataflow framework.  Issue #20726 proposes that we evaluate
    some alternatives for dominator analysis, but for the time being, the
    best path forward is simply to use the existing analysis on
    `CmmGraph`s.
    
    This commit addresses a bullet in #21200.
    
    - - - - -
    54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00
    add dominator-tree function
    
    - - - - -
    05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00
    add HasDebugCallStack; remove unneeded extensions
    
    - - - - -
    0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00
    document fields of `DominatorSet`
    - - - - -
    8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00
    nonmoving: Fix documentation of GC statistics fields
    
    These were previously incorrect.
    
    Fixes #21553.
    
    - - - - -
    c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00
    Remove pprTrace from pushCoercionIntoLambda (#21555)
    
    This firstly caused spurious output to be emitted (as evidenced by
     #21555) but even worse caused a massive coercion to be attempted to be
     printed (> 200k terms) which would invariably eats up all the memory of
     your computer.
    
    The good news is that removing this trace allows the program to compile
    to completion, the bad news is that the program exhibits a core lint
    error (on 9.0.2) but not any other releases it seems.
    
    Fixes #21577 and #21555
    
    - - - - -
    a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00
    docs: Fix LlvmVersion in manpage (#21280)
    
    - - - - -
    36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00
    validate: Use $make rather than make
    
    In the validate script we are careful to use the $make variable as this
    stores whether we are using gmake, make, quiet mode etc. There was just
    this one place where we failed to use it.
    
    Fixes #21598
    
    - - - - -
    4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00
    Change `Backend` type and remove direct dependencies
    
    With this change, `Backend` becomes an abstract type
    (there are no more exposed value constructors).
    Decisions that were formerly made by asking "is the
    current back end equal to (or different from) this named value
    constructor?" are now made by interrogating the back end about
    its properties, which are functions exported by `GHC.Driver.Backend`.
    
    There is a description of how to migrate code using `Backend` in the
    user guide.
    
    Clients using the GHC API can find a backdoor to access the Backend
    datatype in GHC.Driver.Backend.Internal.
    
    Bumps haddock submodule.
    
    Fixes #20927
    
    - - - - -
    ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00
    Respect DESTDIR in hadrian bindist Makefile, fixes #19646
    
    - - - - -
    7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00
    Test DESTDIR in test_hadrian()
    
    - - - - -
    ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00
    Consider the stage of typeable evidence when checking stage restriction
    
    We were considering all Typeable evidence to be "BuiltinInstance"s which
    meant the stage restriction was going unchecked. In-fact, typeable has
    evidence and so we need to apply the stage restriction.
    
    This is
    complicated by the fact we don't generate typeable evidence and the
    corresponding DFunIds until after typechecking is concluded so we
    introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which
    records whether the evidence is going to be local or not.
    
    Fixes #21547
    
    - - - - -
    ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00
    Modularize GHC.Core.Opt.LiberateCase
    
    Progress towards #17957
    
    - - - - -
    bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00
    Improve FloatOut and SpecConstr
    
    This patch addresses a relatively obscure situation that arose
    when chasing perf regressions in !7847, which itself is fixing
    
    It does two things:
    
    * SpecConstr can specialise on ($df d1 d2) dictionary arguments
    * FloatOut no longer checks argument strictness
    
    See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr.
    
    A test case is difficult to construct, but it makes a big difference
    in nofib/real/eff/VSM, at least when we have the patch for #21286
    installed. (The latter stops worker/wrapper for dictionary arguments).
    
    There is a spectacular, but slightly illusory, improvement in
    runtime perf on T15426.  I have documented the specifics in
    T15426 itself.
    
    Metric Decrease:
        T15426
    
    - - - - -
    1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00
    Make debug a `Bool` not an `Int` in `StgToCmmConfig`
    
    We don't need any more resolution than this.
    
    Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer
    conveying any "level" information.
    
    - - - - -
    e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00
    EPA : Remove duplicate comments in DataFamInstD
    
    The code
    
      data instance Method PGMigration = MigrationQuery Query
                                       -- ^ Run a query against the database
                                       | MigrationCode (Connection -> IO (Either String ()))
                                       -- ^ Run any arbitrary IO code
    
    Resulted in two instances of the "-- ^ Run a query against the database"
    comment appearing in the Exact Print Annotations when it was parsed.
    
    Ensure only one is kept.
    
    Closes #20239
    
    - - - - -
    e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00
    EPA: Comment Order Reversed
    
    Make sure comments captured in the exact print annotations are in
    order of increasing location
    
    Closes #20718
    
    - - - - -
    4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00
    Add test for T21455
    
    - - - - -
    e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00
    Allow passing -po outside profiling way
    
    Resolves #21455
    
    - - - - -
    3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00
    Fix haddock_*_perf tests on non-GNU-grep systems
    
    Using regexp pattern requires `egrep` and straight up `+`.  The
    haddock_parser_perf and haddock_renamer_perf tests now pass on
    OpenBSD. They previously incorrectly parsed the files and awk
    complained about invalid syntax.
    
    - - - - -
    1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00
    hadrian/bindist: Drop redundant include of install.mk
    
    `install.mk` is already included by `config.mk`. Moreover, `install.mk`
    depends upon `config.mk` to set `RelocatableBuild`, making this first
    include incorrect.
    
    - - - - -
    f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00
    Remove -z wxneeded for OpenBSD
    
    With all the recent W^X fixes in the loader this workaround is not
    necessary any longer. I verified that the only tests failing for me on
    OpenBSD 7.1-current are the same (libc++ related) before and after
    this commit (with --fast).
    
    - - - - -
    7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00
    Use UnionListsOrd instead of UnionLists in most places.
    
    This should get rid of most, if not all "Overlong lists" errors and fix #20016
    
    - - - - -
    81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00
    Fix #21563 by using Word64 for 64bit shift code.
    
    We use the 64bit shifts only on 64bit platforms. But we
    compile the code always so compiling it on 32bit caused a
    lint error. So use Word64 instead.
    
    - - - - -
    2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00
    Fix compilation with -haddock on GHC <= 8.10
    
    -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors
    when it encounters invalid haddock syntax.
    
    This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b
    enabled -haddock by default on many flavours.
    
    Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem
    managed to slip throught the cracks.
    
    - - - - -
    cfb9faff by sheaf at 2022-05-24T22:15:12-04:00
    Hadrian: don't add "lib" for relocatable builds
    
    The conditional in hadrian/bindist/Makefile depended on the target OS,
    but it makes more sense to use whether we are using a relocatable build.
    (Currently this only gets set to true on Windows, but this ensures
    that the logic stays correctly coupled.)
    
    - - - - -
    9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00
    Remove HscEnv from GHC.HsToCore.Usage (related to #17957)
    
    Metric Decrease:
        T16875
    
    - - - - -
    2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00
    SimpleOpt: beta-reduce through casts
    
    The simple optimiser would sometimes fail to
    beta-reduce a lambda when there were casts
    in between the lambda and its arguments.
    This can cause problems because we rely on
    representation-polymorphic lambdas getting
    beta-reduced away (for example, those
    that arise from newtype constructors with
    representation-polymorphic arguments, with
    UnliftedNewtypes).
    
    - - - - -
    e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00
    Desugar RecordUpd in `tcExpr`
    
    This patch typechecks record updates by desugaring them inside
    the typechecker using the HsExpansion mechanism, and then typechecking
    this desugared result.
    
    Example:
    
        data T p q = T1 { x :: Int, y :: Bool, z :: Char }
                   | T2 { v :: Char }
                   | T3 { x :: Int }
                   | T4 { p :: Float, y :: Bool, x :: Int }
                   | T5
    
    The record update `e { x=e1, y=e2 }` desugars as follows
    
      e { x=e1, y=e2 }
        ===>
      let { x' = e1; y' = e2 } in
      case e of
         T1 _ _ z -> T1 x' y' z
         T4 p _ _ -> T4 p y' x'
    
    The desugared expression is put into an HsExpansion, and we typecheck
    that.
    
    The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr.
    
    Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289
    
    Updates haddock submodule
    
    - - - - -
    2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00
    update README
    - - - - -
    3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00
    Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602)
    
    - - - - -
    ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00
    Add Haddocks for `WwOpts`
    
    - - - - -
    da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00
    Avoid global compiler state for `GHC.Core.Opt.WorkWrap`
    
    Progress towards #17957
    
    - - - - -
    3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00
    Optimiser: avoid introducing bad rep-poly
    
    The functions `pushCoValArg` and `pushCoercionIntoLambda` could
    introduce bad representation-polymorphism. Example:
    
      type RR :: RuntimeRep
      type family RR where { RR = IntRep }
      type F :: TYPE RR
      type family F where  { F  = Int# }
    
      co = GRefl F (TYPE RR[0])
        :: (F :: TYPE RR)
        ~# (F |> TYPE RR[0] :: TYPE IntRep)
    
      f :: F -> ()
    
    `pushCoValArg` would transform the unproblematic application
    
      (f |> (co -> <()>)) (arg :: F |> TYPE RR[0])
    
    into an application in which the argument does not have a fixed
    `RuntimeRep`:
    
      f ((arg |> sym co) :: (F :: TYPE RR))
    
    - - - - -
    b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00
    executablePath test: fix file extension treatment
    
    The executablePath test strips the file extension (if any) when
    comparing the query result with the expected value.  This is to
    handle platforms where GHC adds a file extension to the output
    program file (e.g. .exe on Windows).
    
    After the initial check, the file gets deleted (if supported).
    However, it tries to delete the *stripped* filename, which is
    incorrect.  The test currently passes only because Windows does not
    allow deleting the program while any process created from it is
    alive.
    
    Make the test program correct in general by deleting the
    *non-stripped* executable filename.
    
    - - - - -
    afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00
    fix executablePath test for NetBSD
    
    executablePath support for NetBSD was added in
    a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not
    updated.
    
    Update the test so that it works for NetBSD.  This requires handling
    some quirks:
    
    - The result of getExecutablePath could include "./" segments.
      Therefore use System.FilePath.equalFilePath to compare paths.
    
    - The sysctl(2) call returns the original executable name even after
      it was deleted.  Add `canQueryAfterDelete :: [FilePath]` and
      adjust expectations for the post-delete query accordingly.
    
    Also add a note to the `executablePath` haddock to advise that
    NetBSD behaves differently from other OSes when the file has been
    deleted.
    
    Also accept a decrease in memory usage for T16875.  On Windows, the
    metric is -2.2% of baseline, just outside the allowed ±2%.  I don't
    see how this commit could have influenced this metric, so I suppose
    it's something in the CI environment.
    
    Metric Decrease:
        T16875
    
    - - - - -
    d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00
    Factor out `initArityOps` to `GHC.Driver.Config.*` module
    
    We want `DynFlags` only mentioned in `GHC.Driver`.
    
    - - - - -
    44bb7111 by romes at 2022-05-26T16:27:57+00:00
    TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs
    
    - - - - -
    88e58600 by sheaf at 2022-05-26T17:38:43-04:00
    Add tests for eta-expansion of data constructors
    
    This patch adds several tests relating to the eta-expansion of
    data constructors, including UnliftedNewtypes and DataTypeContexts.
    
    - - - - -
    d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00
    Generalize breakTyVarCycle to work with TyFamLHS
    
    The function breakTyVarCycle_maybe has been installed
    in a dark corner of GHC to catch some gremlins (a.k.a.
    occurs-check failures) who lurk
    there. But it previously only caught gremlins of the
    form (a ~ ... F a ...), where some of our intrepid users
    have spawned gremlins of the form (G a ~ ... F (G a) ...).
    This commit improves breakTyVarCycle_maybe (and renames
    it to breakTyEqCycle_maybe) to catch the new gremlins.
    
    Happily, the change is remarkably small.
    
    The gory details are in Note [Type equality cycles].
    
    Test cases: typecheck/should_compile/{T21515,T21473}.
    
    - - - - -
    ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00
    [base] Fix the links in the Data.Data module
    
    fix #21658
    fix #21657
    fix #21657
    
    - - - - -
    3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00
    Use a class to check validity of withDict
    
    This moves handling of the magic 'withDict' function from the desugarer
    to the typechecker. Details in Note [withDict].
    
    I've extracted a part of T16646Fail to a separate file T16646Fail2,
    because the new error in 'reify' hides the errors from 'f' and 'g'.
    
    WithDict now works with casts, this fixes #21328.
    
    Part of #19915
    
    - - - - -
    b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00
    Fix FreeVars computation for mdo
    
    Commit acb188e0 introduced a regression in the computation of free
    variables in mdo statements, as the logic in
    GHC.Rename.Expr.segmentRecStmts was slightly different depending on
    whether the recursive do block corresponded to an mdo statement or
    a rec statment.
    
    This patch restores the previous computation for mdo blocks.
    
    Fixes #21654
    
    - - - - -
    0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00
    T16875: Stabilise (temporarily) by increasing acceptance threshold
    
    The theory is that on windows there is some difference in the
    environment between pipelines on master and merge requests which affects
    all tests equally but because T16875 barely allocates anything it is the
    test which is affected the most.
    
    See #21557
    
    - - - - -
    6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00
    make: Fix make maintainer-clean deleting a file tracked by source control
    
    Fixes #21659
    
    - - - - -
    fbf2f254 by Andrew Lelechenko at 2022-05-28T21:01:58-04:00
    Expand documentation of hIsTerminalDevice
    
    - - - - -
    0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00
    export IsList from GHC.IsList
    
    it is still re-exported from GHC.Exts
    
    - - - - -
    91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00
    MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR
    
    ARM64_RELOC_SUBTRACTOR relocations are paired with an
    AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2
    The linker was doing it in two steps, basically:
      *addend <- *addend - sym2
      *addend <- *addend + sym1
    The first operation was likely to overflow. For example when the
    relocation target was 32-bit and both sym1/sym2 were 64-bit addresses.
    With the small memory model, (sym1-sym2) would fit in 32 bits but
    (*addend-sym2) may not.
    
    Now the linker does it in one step:
      *addend <- *addend + sym1 - sym2
    
    - - - - -
    acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00
    Some fixes to SRT documentation
    
    - reordered the 3 SRT implementation cases from the most general to the
      most specific one:
        USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD
    - added requirements for each
    - found and documented a confusion about "SRT inlining" not supported
      with MachO. (It is fixed in the following commit)
    
    - - - - -
    5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00
    Enable USE_INLINE_SRT_FIELD on ARM64
    
    It was previously disabled because of:
    - a confusion about "SRT inlining" (see removed comment in this commit)
    - a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR
      relocation: fixed by a previous commit.
    
    - - - - -
    59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00
    ci: Make sure to exit promptly if `make install` fails.
    
    Due to the vageries of bash, you have to explicitly handle the failure
    and exit when in a function.
    
    This failed to exit promptly when !8247 was failing.
    
    See #21358 for the general issue
    
    - - - - -
    5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00
    Split GHC.HsToCore.Foreign.Decl
    
    This is preliminary work for JavaScript support. It's better to put the
    code handling the desugaring of Prim, C and JavaScript declarations into
    separate modules.
    
    - - - - -
    6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00
    Bump hadrian to LTS-19.8 (GHC 9.0.2)
    
    - - - - -
    f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00
    Hadrian: remove unused code
    
    - - - - -
    2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Eta reduction with casted function
    
    We want to be able to eta-reduce
       \x y. ((f x) |> co) y
    by pushing 'co' inwards.  A very small change accommodates this
    See Note [Eta reduction with casted function]
    
    - - - - -
    f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Do arity trimming at bindings, rather than in exprArity
    
    Sometimes there are very large casts, and coercionRKind
    can be slow.
    
    - - - - -
    610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Make findRhsArity take RecFlag
    
    This avoids a fixpoint iteration for the common case of
    non-recursive bindings.
    
    - - - - -
    80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Comments and white space
    
    - - - - -
    0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Make PrimOpId record levity
    
    This patch concerns #20155, part (1)
    
    The general idea is that since primops have curried bindings
    (currently in PrimOpWrappers.hs) we don't need to eta-expand
    them.  But we /do/ need to eta-expand the levity-polymorphic ones,
    because they /don't/ have bindings.
    
    This patch makes a start in that direction, by identifying the
    levity-polymophic primops in the PrimOpId IdDetails constructor.
    
    For the moment, I'm still eta-expanding all primops (by saying
    that hasNoBinding returns True for all primops), because of the
    bug reported in #20155.  But I hope that before long we can
    tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding.
    
    - - - - -
    6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    A bunch of changes related to eta reduction
    
    This is a large collection of changes all relating to eta
    reduction, originally triggered by #18993, but there followed
    a long saga.
    
    Specifics:
    
    * Move state-hack stuff from GHC.Types.Id (where it never belonged)
      to GHC.Core.Opt.Arity (which seems much more appropriate).
    
    * Add a crucial mkCast in the Cast case of
      GHC.Core.Opt.Arity.eta_expand; helps with T18223
    
    * Add clarifying notes about eta-reducing to PAPs.
      See Note [Do not eta reduce PAPs]
    
    * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity,
      where it properly belongs.  See Note [Eta reduce PAPs]
    
    * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for
      when eta-expansion is wanted, to make wantEtaExpansion, and all that
      same function in GHC.Core.Opt.Simplify.simplStableUnfolding.  It was
      previously inconsistent, but it's doing the same thing.
    
    * I did a substantial refactor of ArityType; see Note [ArityType].
      This allowed me to do away with the somewhat mysterious takeOneShots;
      more generally it allows arityType to describe the function, leaving
      its clients to decide how to use that information.
    
      I made ArityType abstract, so that clients have to use functions
      to access it.
    
    * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called
      mkLam before) aware of the floats that the simplifier builds up, so
      that it can still do eta-reduction even if there are some floats.
      (Previously that would not happen.)  That means passing the floats
      to rebuildLam, and an extra check when eta-reducting (etaFloatOk).
    
    * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info
      in the idDemandInfo of the binder, as well as the CallArity info. The
      occurrence analyser did this but we were failing to take advantage here.
    
      In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity;
      see Note [Combining arityType with demand info], and functions
      idDemandOneShots and combineWithDemandOneShots.
    
      (These changes partly drove my refactoring of ArityType.)
    
    * In GHC.Core.Opt.Arity.findRhsArity
      * I'm now taking account of the demand on the binder to give
        extra one-shot info.  E.g. if the fn is always called with two
        args, we can give better one-shot info on the binders
        than if we just look at the RHS.
    
      * Don't do any fixpointing in the non-recursive
        case -- simple short cut.
    
      * Trim arity inside the loop. See Note [Trim arity inside the loop]
    
    * Make SimpleOpt respect the eta-reduction flag
      (Some associated refactoring here.)
    
    * I made the CallCtxt which the Simplifier uses distinguish between
      recursive and non-recursive right-hand sides.
         data CallCtxt = ... | RhsCtxt RecFlag | ...
      It affects only one thing:
         - We call an RHS context interesting only if it is non-recursive
           see Note [RHS of lets] in GHC.Core.Unfold
    
    * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification.
      See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep.
    
    Other incidental changes
    
    * Fix a fairly long-standing outright bug in the ApplyToVal case of
      GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the
      tail of 'dmds' in the recursive call, which meant the demands were All
      Wrong.  I have no idea why this has not caused problems before now.
    
    * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg
    
    Metrics: compile_time/bytes allocated
                                   Test    Metric       Baseline      New value Change
    ---------------------------------------------------------------------------------------
    MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,743,297,692  2,619,762,992  -4.5% GOOD
                         T18223(normal) ghc/alloc  1,103,161,360    972,415,992 -11.9% GOOD
                          T3064(normal) ghc/alloc    201,222,500    184,085,360  -8.5% GOOD
                          T8095(normal) ghc/alloc  3,216,292,528  3,254,416,960  +1.2%
                          T9630(normal) ghc/alloc  1,514,131,032  1,557,719,312  +2.9%  BAD
                     parsing001(normal) ghc/alloc    530,409,812    525,077,696  -1.0%
    
    geo. mean                                 -0.1%
    
    Nofib:
           Program           Size    Allocs   Runtime   Elapsed  TotalMem
    --------------------------------------------------------------------------------
             banner          +0.0%     +0.4%     -8.9%     -8.7%      0.0%
        exact-reals          +0.0%     -7.4%    -36.3%    -37.4%      0.0%
     fannkuch-redux          +0.0%     -0.1%     -1.0%     -1.0%      0.0%
               fft2          -0.1%     -0.2%    -17.8%    -19.2%      0.0%
              fluid          +0.0%     -1.3%     -2.1%     -2.1%      0.0%
                 gg          -0.0%     +2.2%     -0.2%     -0.1%      0.0%
      spectral-norm          +0.1%     -0.2%      0.0%      0.0%      0.0%
                tak          +0.0%     -0.3%     -9.8%     -9.8%      0.0%
               x2n1          +0.0%     -0.2%     -3.2%     -3.2%      0.0%
    --------------------------------------------------------------------------------
                Min          -3.5%     -7.4%    -58.7%    -59.9%      0.0%
                Max          +0.1%     +2.2%    +32.9%    +32.9%      0.0%
     Geometric Mean          -0.0%     -0.1%    -14.2%    -14.8%     -0.0%
    
    Metric Decrease:
        MultiLayerModulesTH_OneShot
        T18223
        T3064
        T15185
        T14766
    Metric Increase:
        T9630
    
    - - - - -
    cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00
    hadrian: Fix building from source-dist without alex/happy
    
    This fixes two bugs which were adding dependencies on alex/happy when
    building from a source dist.
    
    * When we try to pass `--with-alex` and `--with-happy` to cabal when
      configuring but the builders are not set. This is fixed by making them
      optional.
    * When we configure, cabal requires alex/happy because of the
      build-tool-depends fields. These are now made optional with a cabal
      flag (build-tool-depends) for compiler/hpc-bin/genprimopcode.
    
    Fixes #21627
    
    - - - - -
    a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00
    ci: Test the bootstrap without ALEX/HAPPY on path
    
    - - - - -
    0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00
    ci: Test bootstrapping in release jobs
    
    - - - - -
    d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00
    ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label
    
    - - - - -
    18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00
    rts: Remove explicit timescale for deprecating -h flag
    
    We originally planned to remove the flag in 9.4 but there's actually no
    great rush to do so and it's probably less confusing (forever) to keep
    the message around suggesting an explicit profiling option.
    
    Fixes #21545
    
    - - - - -
    eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00
    Enable -dlint in hadrian lint transformer
    
    Now #21563 is fixed we can properly enable `-dlint` in CI rather than a
    subset of the flags.
    
    - - - - -
    0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00
    upload-ghc-libs: Allow candidate-only upload
    
    - - - - -
    83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00
    Avoid using DynFlags in GHC.Linker.Unit (#17957)
    
    - - - - -
    5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00
    hadrian: Introduce new package database for executables needed to build stage0
    
    These executables (such as hsc2hs) are built using the boot compiler and
    crucially, most libraries from the global package database.
    
    We also move other build-time executables to be built in this stage such
    as linters which also cleans up which libraries end up in the global
    package database. This allows us to remove hacks where linters-common is
    removed from the package database when a bindist is created.
    
    This fixes issues caused by infinite recursion due to bytestring adding
    a dependency on template-haskell.
    
    Fixes #21634
    
    - - - - -
    0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00
    Build stage1 with -V as well
    
    This helps tracing errors which happen when building stage1
    
    - - - - -
    15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00
    Revert "packaging: Build perf builds with -split-sections"
    
    This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f.
    
    Split sections causes segfaults in profiling way with old toolchains
    (deb9) and on windows (#21670)
    
    Fixes #21670
    
    - - - - -
    d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00
    Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard
    
    Progress towards #17957
    
    Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other
    modules as thoroughly as I usually do. This does mean that risk of
    `DynFlags` "creeping back in" is higher than it usually is.
    
    After we do the same process to the other Core passes, and then figure
    out what we want to do about `CoreM`, we can finish the job started
    here.
    
    That is a good deal more work, however, so it certainly makes sense to
    land this now.
    
    - - - - -
    a720322f by romes at 2022-06-01T07:44:44-04:00
    Restore Note [Quasi-quote overview]
    
    - - - - -
    392ce3fc by romes at 2022-06-01T07:44:44-04:00
    Move UntypedSpliceFlavour from L.H.S to GHC.Hs
    
    UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr`
    but was defined in the client-independent L.H.S.Expr.
    
    - - - - -
    7975202b by romes at 2022-06-01T07:44:44-04:00
    TTG: Rework and improve splices
    
    This commit redefines the structure of Splices in the AST.
    
    We get rid of `HsSplice` which used to represent typed and untyped
    splices, quasi quotes, and the result of splicing either an expression,
    a type or a pattern.
    
    Instead we have `HsUntypedSplice` which models an untyped splice or a
    quasi quoter, which works in practice just like untyped splices.
    
    The `HsExpr` constructor `HsSpliceE` which used to be constructed with
    an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The
    former is directly constructed with an `HsExpr` and the latter now takes
    an `HsUntypedSplice`.
    
    Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now
    take an `HsUntypedSplice` instead of a `HsSplice` (remember only
    /untyped splices/ can be spliced as types or patterns).
    
    The result of splicing an expression, type, or pattern is now
    comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`,
    `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType
    GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult
    (HsExpr GhcRn)`
    
    Overall the TTG extension points are now better used to
    make invalid states unrepresentable and model the progression between
    stages better.
    
    See Note [Lifecycle of an untyped splice, and PendingRnSplice]
    and Note [Lifecycle of an typed splice, and PendingTcSplice] for more
    details.
    
    Updates haddock submodule
    
    Fixes #21263
    
    -------------------------
    Metric Decrease:
        hard_hole_fits
    -------------------------
    
    - - - - -
    320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00
    Add test for #21619
    
    Fixes #21619
    
    - - - - -
    ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00
    Pure Haskell implementation of GHC.Unicode
    
    Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/).
    
    Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691.
    
    - Remove current Unicode cbits.
    - Add generator for Unicode property files from Unicode Character Database.
    - Generate internal modules.
    - Update GHC.Unicode.
    - Add unicode003 test for general categories and case mappings.
    - Add Python scripts to check 'base' Unicode tests outputs and characters properties.
    
    Fixes #21375
    
    -------------------------
    Metric Decrease:
        T16875
    Metric Increase:
        T4029
        T18304
        haddock.base
    -------------------------
    
    - - - - -
    514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00
    typos
    
    - - - - -
    9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00
    source-dist: Copy in files created by ./boot
    
    Since we started producing source dists with hadrian we stopped copying
    in the files created by ./boot which adds a dependency on python3 and
    autoreconf. This adds back in the files which were created by running
    configure.
    
    Fixes #21673 #21672 and #21626
    
    - - - - -
    a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00
    ci: Don't try to run ./boot when testing bootstrap of source dist
    
    - - - - -
    e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00
    Language.Haskell.Syntax: Fix docs for PromotedConsT etc.
    
    Fixes ghc/ghc#21675.
    
    - - - - -
    87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00
    Bump bytestring, process, and text submodules
    
    Metric Decrease:
        T5631
    Metric Increase:
        T18223
    
    (cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af)
    
    - - - - -
    24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00
    Bump Cabal submodule
    
    To current `master`.
    
    (cherry picked from commit fbb59c212415188486aafd970eafef170516356a)
    
    - - - - -
    5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00
    hadrian/tool-args: Write output to intermediate file rather than via stdout
    
    This allows us to see the output of hadrian while it is doing the setup.
    
    - - - - -
    468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00
    Make -fcompact-unwind the default
    
    This is a follow-up to !7247 (closed) making the inclusion of compact unwinding
    sections the default.
    
    Also a slight refactoring/simplification of the flag handling to add
    -fno-compact-unwind.
    
    - - - - -
    819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00
    hadrian bootstrap: add plans for 9.0.2 and 9.2.3
    
    - - - - -
    9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00
    ci: Add matrix for bootstrap sources
    
    - - - - -
    ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00
    HsToCore.Coverage: Improve haddocks
    
    - - - - -
    f065804e by John Ericson at 2022-06-02T15:42:59+00:00
    Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller
    
    No need to inline traversing a maybe for `mkModBreaks`. And better to
    make each function do one thing and let the caller deside when than
    scatter the decision making and make the caller seem more imperative.
    
    - - - - -
    d550d907 by John Ericson at 2022-06-02T15:42:59+00:00
    Rename `HsToCore.{Coverage -> Ticks}`
    
    The old name made it confusing why disabling HPC didn't disable the
    entire pass. The name makes it clear --- there are other reasons to add
    ticks in addition.
    
    - - - - -
    6520da95 by John Ericson at 2022-06-02T15:42:59+00:00
    Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq`
    
    As proposed in
    https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and
    https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676,
    `GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and
    backend-specific (only for the bytecode interpreter), and mix entry
    writing is just for HPC.
    
    With this split we separate out those interpreter- and HPC-specific
    its, and keep the main `GHC.HsToCore.Ticks` agnostic.
    
    Also, instead of passing the reversed list and count around, we use
    `SizedSeq` which abstracts over the algorithm. This is much nicer to
    avoid noise and prevents bugs.
    
    (The bugs are not just hypothetical! I missed up the reverses on an
    earlier draft of this commit.)
    
    - - - - -
    1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00
    GHC.HsToCore.Breakpoints: Slightly improve perf
    
    We have the length already, so we might as well use that rather than
    O(n) recomputing it.
    
    - - - - -
    5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00
    HsToCore.Coverage: Purge DynFlags
    
    Finishes what !7467 (closed) started.
    
    Progress towards #17957
    
    - - - - -
    9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00
    Deprecate TypeInType extension
    
    This commit fixes #20312
    It deprecates "TypeInType" extension
    according to the following proposal:
    https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst
    
    It has been already implemented.
    
    The migration strategy:
     1. Disable TypeInType
     2. Enable both DataKinds and PolyKinds extensions
    
    Metric Decrease:
        T16875
    
    - - - - -
    f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00
    Diagnostics conversions, part 6 (#20116)
    
    Replaces uses of `TcRnUnknownMessage` with proper diagnostics
    constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and
    `GHC.Tc.Gen.Sig`.
    
    - - - - -
    04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00
    Ensure floated dictionaries are in scope (again)
    
    In the Specialiser, we missed one more call to
    bringFloatedDictsIntoScope (see #21391).
    
    This omission led to #21689. The problem is that the call
    to `rewriteClassOps` needs to have in scope any dictionaries
    floated out of the arguments we have just specialised.
    
    Easy fix.
    
    - - - - -
    a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00
    Don't print the number of deps in count-deps tests
    
    It is redundant information and a source of needless version control
    conflicts when multiple MRs are changing the deps list.
    
    Just printing the list and not also its length is fine.
    
    - - - - -
    a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00
    Core.Lint: Reduce `DynFlags` and `HscEnv`
    
    Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com>
    
    - - - - -
    56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00
    Fix a CSE shadowing bug.
    
    We used to process the rhs of non-recursive bindings and their body
    using the same env. If we had something like
        let x = ... x ...
    this caused trouble because the two xs refer to different binders
    but we would substitute both for a new binder x2 causing out of scope
    errors.
    
    We now simply use two different envs for the rhs and body in cse_bind.
    It's all explained in the Note [Separate envs for let rhs and body]
    
    Fixes #21685
    
    - - - - -
    28880828 by sheaf at 2022-06-09T09:12:19-04:00
    Typecheck remaining ValArgs in rebuildHsApps
    
    This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it
    to tcRemainingValArgs. The logic is moved to rebuildHsApps, which
    ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg.
    
    This patch also refactors the treatment of stupid theta for data
    constructors, changing the place we drop stupid theta arguments
    from dsConLike to mkDataConRep (now the datacon wrapper drops these
    arguments).
    
    We decided not to implement PHASE 2 of the FixedRuntimeRep plan for
    these remaining ValArgs. Future directions are outlined on the wiki:
      https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs
    
    Fixes #21544 and #21650
    
    - - - - -
    1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00
    Add test for T21682
    
    Fixes #21682
    
    - - - - -
    8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00
    Document dataToTag# primop
    
    - - - - -
    7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00
    Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115
    
    - - - - -
    46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00
    Fix TcRnPragmaWarning meaning
    
    - - - - -
    69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00
    getProcessCPUTime: Fix the getrusage fallback to account for system CPU time
    
    clock_gettime reports the combined total or user AND system time so in
    order to replicate it with getrusage we need to add both system and user
    time together.
    
    See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime
    
    Some sample measurements when building Cabal with this patch
    
    t1: rusage
    t2: clock_gettime
    
    t1: 62347518000; t2: 62347520873
    t1: 62395687000; t2: 62395690171
    t1: 62432435000; t2: 62432437313
    t1: 62478489000; t2: 62478492465
    t1: 62514990000; t2: 62514992534
    t1: 62515479000; t2: 62515480327
    t1: 62515485000; t2: 62515486344
    
    Fixes #21656
    
    - - - - -
    722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00
    Use <br> instead of newline character
    
    - - - - -
    dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00
    Use (fixed_lev = True) in mkDataTyConRhs
    
    - - - - -
    ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00
    hadrian: Fix testing stage1 compiler
    
    There were various issues with testing the stage1 compiler..
    
    1. The wrapper was not being built
    2. The wrapper was picking up the stage0 package database and trying to
       load prelude from that.
    3. The wrappers never worked on windows so just don't support that for
       now.
    
    Fixes #21072
    
    - - - - -
    ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00
    validate: Ensure that $make variable is set
    
    Currently the `$make` variable is used without being set in `validate`'s
    Hadrian path, which uses make to install the binary distribution. Fix
    this.
    
    Fixes #21687.
    
    - - - - -
    59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00
    CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv`
    
    The call sites in `Driver.Main` are duplicative, but this is good,
    because the next step is to remove `InteractiveContext` from `Core.Lint`
    into `Core.Lint.Interactive`.
    
    Also further clean up `Core.Lint` to use a better configuration record
    than the one we initially added.
    
    - - - - -
    aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00
    hadrian: Run xattr -rc . on bindist tarball
    
    Fixes #21506.
    
    - - - - -
    cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00
    configure: Hide spurious warning from ld
    
    Previously the check_for_gold_t22266 configure check could result in
    spurious warnings coming from the linker being blurted to stderr.
    Suppress these by piping stderr to /dev/null.
    
    - - - - -
    e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00
    cmm: Add surface syntax for MO_MulMayOflo
    
    - - - - -
    bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00
    configure: Don't attempt to override linker on Darwin
    
    Configure's --enable-ld-override functionality is intended to ensure
    that we don't rely on ld.bfd, which tends to be slow and buggy, on
    Linux and Windows. However, on Darwin the lack of sensible package
    management makes it extremely easy for users to have awkward mixtures of
    toolchain components from, e.g., XCode, the Apple Command-Line Tools
    package, and homebrew. This leads to extremely confusing problems
    like #21712.
    
    Here we avoid this by simply giving up on linker selection on Darwin
    altogether. This isn't so bad since the Apple ld64 linker has decent
    performance and AFAICT fairly reliable.
    
    Closes #21712.
    
    - - - - -
    25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00
    replace quadratic nub to fight byte code gen perf explosion
    
    Despite this code having been present in the core-to-bytecode
    implementation, I have observed it in the wild starting with 9.2,
    causing enormous slowdown in certain situations.
    
    My test case produces the following profiles:
    
    Before:
    
    ```
    	total time  =      559.77 secs   (559766 ticks @ 1000 us, 1 processor)
    	total alloc = 513,985,665,640 bytes  (excludes profiling overheads)
    
    COST CENTRE MODULE         SRC                                         %time %alloc  ticks     bytes
    
    elem_by     Data.OldList   libraries/base/Data/OldList.hs:429:1-7       67.6   92.9  378282 477447404296
    eqInt       GHC.Classes    libraries/ghc-prim/GHC/Classes.hs:275:8-14   12.4    0.0  69333        32
    $c>>=       GHC.Data.IOEnv <no location info>                            6.9    0.6  38475 3020371232
    ```
    
    After:
    
    ```
    	total time  =       89.83 secs   (89833 ticks @ 1000 us, 1 processor)
    	total alloc = 39,365,306,360 bytes  (excludes profiling overheads)
    
    COST CENTRE           MODULE                SRC                                                                  %time %alloc  ticks     bytes
    
    $c>>=                 GHC.Data.IOEnv        <no location info>                                                    43.6    7.7  39156 3020403424
    doCase                GHC.StgToByteCode     compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53)                        2.5    7.4   2246 2920777088
    
    ```
    
    - - - - -
    aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00
    hadrian: Don't install `include/` directory in bindist.
    
    The install_includes for the RTS package used to be put in the top-level
    ./include folder but this would lead to confusing things happening if
    you installed multiple GHC versions side-by-side.
    
    We don't need this folder anymore because install-includes
    is honoured properly by cabal and the relevant header files already
    copied in by the cabal installation process.
    
    If you want to depend on the header files for the RTS in a Haskell
    project then you just have to depend on the `rts` package and the
    correct include directories will be provided for you.
    
    If you want to depend on the header files in a standard C project then
    you should query ghc-pkg to get the right paths.
    
    ```
    ghc-pkg field rts include-dirs  --simple-output
    ```
    
    Fixes #21609
    
    - - - - -
    03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00
    Enable eventlogs on nightly perf job
    
    - - - - -
    ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00
    Repair dead link in TH haddocks
    
    Closes #21724
    
    - - - - -
    99ff3818 by sheaf at 2022-06-16T16:30:39-04:00
    Hadrian: allow configuring Hsc2Hs
    
    This patch adds the ability to pass options to Hsc2Hs as Hadrian
    key/value settings, in the same way as cabal configure options,
    using the syntax:
    
      *.*.hsc2hs.run.opts += ...
    
    - - - - -
    9c575f24 by sheaf at 2022-06-16T16:30:39-04:00
    Hadrian bootstrap: look up hsc2hs
    
    Hadrian bootstrapping looks up where to find ghc_pkg, but the same
    logic was not in place for hsc2hs which meant we could fail to
    find the appropriate hsc2hs executabe when bootstrapping Hadrian.
    This patch adds that missing logic.
    
    - - - - -
    229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00
    ghc-heap: Add (broken) test for #21622
    
    - - - - -
    cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00
    ghc-heap: Don't Box NULL pointers
    
    Previously we could construct a `Box` of a NULL pointer from the `link`
    field of `StgWeak`. Now we take care to avoid ever introducing such
    pointers in `collect_pointers` and ensure that the `link` field is
    represented as a `Maybe` in the `Closure` type.
    
    Fixes #21622
    
    - - - - -
    31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00
    winio: Add support to console handles to handleToHANDLE
    
    - - - - -
    711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00
    CmmToAsm/AArch64: Add SMUL[LH] instructions
    
    These will be needed to fix #21624.
    
    - - - - -
    d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00
    CmmToAsm/AArch64: Fix syntax of OpRegShift operands
    
    Previously this produced invalid assembly containing a redundant comma.
    
    - - - - -
    a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00
    ncg/aarch64: Fix implementation of IntMulMayOflo
    
    The code generated for IntMulMayOflo was previously wrong as it
    depended upon the overflow flag, which the AArch64 MUL instruction does
    not set. Fix this.
    
    Fixes #21624.
    
    - - - - -
    26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00
    testsuite: Add test for #21624
    
    Ensuring that mulIntMayOflo# behaves as expected.
    
    - - - - -
    94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00
    CprAnal: Set signatures of DFuns to top
    
    The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal
    that is observable in a debug build. The CPR signature of a recursive DFunId
    was never updated and hence the optimistic arity 0 bottom signature triggered a
    mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any
    code because WW doesn't exploit bottom CPR signatures.
    
    - - - - -
    b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00
    CorePrep: Don't speculatively evaluate recursive calls (#20836)
    
    In #20836 we have optimised a terminating program into an endless loop,
    because we speculated the self-recursive call of a recursive DFun.
    Now we track the set of enclosing recursive binders in CorePrep to prevent
    speculation of such self-recursive calls.
    
    See the updates to Note [Speculative evaluation] for details.
    
    Fixes #20836.
    
    - - - - -
    49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00
    Simplify: Take care with eta reduction in recursive RHSs (#21652)
    
    Similar to the fix to #20836 in CorePrep, we now track the set of enclosing
    recursive binders in the SimplEnv and SimpleOptEnv.
    See Note [Eta reduction in recursive RHSs] for details.
    
    I also updated Note [Arity robustness] with the insights Simon and I had in a
    call discussing the issue.
    
    Fixes #21652.
    
    Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to
    additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation
    of a large list literal at the top-level that didn't happen before (presumably
    because it was too interesting to float to the top-level). There's not much we
    can do about that.
    
    Metric Increase:
        T16577
    
    - - - - -
    2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00
    Ignore .hie-bios
    
    - - - - -
    e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00
    Instantiate top level foralls in partial type signatures
    
    The main fix for #21667 is the new call to tcInstTypeBnders
    in tcHsPartialSigType. It was really a simple omission before.
    
    I also moved the decision about whether we need to apply the
    Monomorphism Restriction, from `decideGeneralisationPlan` to
    `tcPolyInfer`.  That removes a flag from the InferGen constructor,
    which is good.
    
    But more importantly, it allows the new function,
       checkMonomorphismRestriction
    called from `tcPolyInfer`, to "see" the `Types` involved rather than
    the `HsTypes`.  And that in turn matters because we invoke the MR for
    partial signatures if none of the partial signatures in the group have
    any overloading context; and we can't answer that question for HsTypes.
    See Note [Partial type signatures and the monomorphism restriction]
    in GHC.Tc.Gen.Bind.
    
    This latter is really a pre-existing bug.
    
    - - - - -
    262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00
    Make Outputable instance for InlineSig print the InlineSpec
    
    Fix ghc/ghc#21739
    
    Squash fix ghc/ghc#21739
    
    - - - - -
    b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00
    Add NO_BOOT to hackage_doc_tarball job
    
    We were attempting to boot a src-tarball which doesn't work as ./boot is
    not included in the source tarball. This slipped through as the job is
    only run on nightly.
    
    - - - - -
    d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00
    HsToken for @-patterns and TypeApplications (#19623)
    
    One more step towards the new design of EPA.
    
    - - - - -
    159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00
    linker: only keep rtl exception tables if they have been relocated
    
    - - - - -
    da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00
    Ticky:Make json info a separate field.
    
    - - - - -
    1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00
    Revert "Ticky:Make json info a separate field."
    
    This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862.
    
    This was pushed directly without review.
    
    - - - - -
    f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00
    Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags
    
    These flags affect the behaviour of local let floating.
    
    If `-flocal-float-out` is disabled (the default) then we disable all
    local floating.
    
    ```
    …(let x = let y = e in (a,b) in body)...
    ===>
    …(let y = e; x = (a,b) in body)...
    
    ```
    
    Further to this, top-level local floating can be disabled on it's own by
    passing -fno-local-float-out-top-level.
    
    ```
    x = let y = e in (a,b)
    ===>
    y = e; x = (a,b)
    ```
    
    Note that this is only about local floating, ie, floating two adjacent
    lets past each other and doesn't say anything about the global floating
    pass which is controlled by `-fno-float`.
    
    Fixes #13663
    
    - - - - -
    4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00
    Check for Int overflows in Data.Array.Byte
    
    - - - - -
    2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00
    Add a basic test for ByteArray's Monoid instance
    
    - - - - -
    fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00
    Rename `copyByteArray` to `unsafeCopyByteArray`
    
    - - - - -
    ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00
    testsuite: Add test for #21719
    
    Happily, this has been fixed since 9.2.
    
    - - - - -
    19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00
    Use lookupNameCache instead of lookupOrigIO
    
    - - - - -
    4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00
    Break out thNameToGhcNameIO (ref. #21730)
    
    - - - - -
    eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00
    Add laws for 'toInteger' and 'toRational'
    
    CLC discussion here:
    https://github.com/haskell/core-libraries-committee/issues/58
    
    - - - - -
    c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00
    Correct documentation of defaults of the `-V` RTS option
    
    - - - - -
    b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00
    Transcribe discussion from #21483 into a Note
    
    In #21483 I had a discussion with Simon Marlow about the memory
    retention behaviour of -Fd. I have just transcribed that conversation
    here as it elucidates the potentially subtle assumptions which led to
    the design of the memory retention behaviours of -Fd.
    
    Fixes #21483
    
    - - - - -
    980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00
    eventlog: Don't leave dangling pointers hanging around
    
    Previously we failed to reset pointers to various eventlog buffers to
    NULL after freeing them. In principle we shouldn't look at them after
    they are freed but nevertheless it is good practice to set them to a
    well-defined value.
    
    - - - - -
    575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00
    runhaskell
    - - - - -
    e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00
    re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural
    
    CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45
    
    - - - - -
    5d45aa97 by Gergő Érdi at 2022-06-22T22:00:46-04:00
    When specialising, look through floatable ticks.
    
    Fixes #21697.
    
    - - - - -
    531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00
    TagCheck.hs: Properly check if arguments are boxed types.
    
    For one by mistake I had been checking against the kind of runtime rep
    instead of the boxity.
    
    This uncovered another bug, namely that we tried to generate the
    checking code before we had associated the function arguments with
    a register, so this could never have worked to begin with.
    
    This fixes #21729 and both of the above issues.
    
    - - - - -
    c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00
    Use correct arch for the FreeBSD triple in gen-data-layout.sh
    
    Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798
    Relevant upstream issue: #15718
    
    - - - - -
    75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00
    Bump nofib submodule.
    
    Allows the shake runner to build with 9.2.3 among other things.
    
    Fixes #21772
    
    - - - - -
    0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00
    Bump ghc-prim and base versions
    
    To 0.9.0 and 4.17.0 respectively.
    
    Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm,
    terminfo, text, unix, haddock, and hsc2hs submodules.
    
    (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095)
    
    - - - - -
    4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00
    testsuite: Use normalise_version more consistently
    
    Previously several tests' output were unnecessarily dependent on version
    numbers, particularly of `base`. Fix this.
    
    - - - - -
    d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00
    linters: Fix lint-submodule-refs when crashing trying to find plausible branches
    
    - - - - -
    38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
    hadrian: Improve haddocks for ghcDebugAssertions
    
    - - - - -
    ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
    Don't mark lambda binders as OtherCon
    
    We used to put OtherCon unfoldings on lambda binders of workers
    and sometimes also join points/specializations with with the
    assumption that since the wrapper would force these arguments
    once we execute the RHS they would indeed be in WHNF.
    
    This was wrong for reasons detailed in #21472. So now we purge
    evaluated unfoldings from *all* lambda binders.
    
    This fixes #21472, but at the cost of sometimes not using as efficient a
    calling convention. It can also change inlining behaviour as some
    occurances will no longer look like value arguments when they did
    before.
    
    As consequence we also change how we compute CBV information for
    arguments slightly. We now *always* determine the CBV convention
    for arguments during tidy. Earlier in the pipeline we merely mark
    functions as candidates for having their arguments treated as CBV.
    
    As before the process is described in the relevant notes:
    Note [CBV Function Ids]
    Note [Attaching CBV Marks to ids]
    Note [Never put `OtherCon` unfoldigns on lambda binders]
    
    -------------------------
    Metric Decrease:
        T12425
        T13035
        T18223
        T18223
        T18923
        MultiLayerModulesTH_OneShot
    Metric Increase:
        WWRec
    -------------------------
    
    - - - - -
    06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00
    Add suggestions for unrecognised pragmas (#21589)
    
    In case of a misspelled pragma, offer possible corrections as to what
    the user could have meant.
    
    Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589
    
    - - - - -
    3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00
    Remove the traces of i386-*-openbsd, long live amd64
    
    OpenBSD will not ship any ghc packages on i386 starting with 7.2
    release.  This means there will not be a bootstrap compiler easily
    available.  The last available binaries are ghc-8.10.6 which is
    already not supported as bootstrap for HEAD.
    
    See here for more information:
    
    https://marc.info/?l=openbsd-ports&m=165060700222580&w=2
    
    - - - - -
    58530271 by Andrew Lelechenko at 2022-06-27T08:03:34-04:00
    Add Foldable1 and Bifoldable1 type classes
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9
    
    Instances roughly follow
    https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1
    but the API of `Foldable1` was expanded in comparison to `semigroupoids`.
    
    Compatibility shim is available from https://github.com/phadej/foldable1 (to be released).
    
    Closes #13573.
    
    - - - - -
    a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00
    add levity polymorphism to addrToAny#
    
    - - - - -
    f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00
    add tests for addrToAny# levity
    
    - - - - -
    07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00
    hadrian: Update main README page
    
    This README had some quite out-of-date content about the build system so
    I did a complete pass deleting old material. I also made the section
    about flavours more prominent and mentioned flavour transformers.
    
    - - - - -
    79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00
    testsuite: Hide output from test compilations with verbosity==2
    
    Previously the output from test compilations used to determine whether,
    e.g., profiling libraries are available was shown with verbosity
    levels >= 2. However, the default level is 2, meaning that most users
    were often spammed with confusing errors. Fix this by bumping the
    verbosity threshold for this output to >=3.
    
    Fixes #21760.
    - - - - -
    995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00
    configure: Only probe for LD in FIND_LD
    
    Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD
    rather early in `configure`. However, it turns out that this breaks
    `configure`'s `ld`-override logic, which assumes that `LD` was set by
    the user and aborts.
    
    Fixes #21778.
    
    - - - - -
    b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00
    `.hs-boot` make rules: add missing order-only dependency on target directory
    
    Noticed missing target directory dependency as a build failure in
    `make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100):
    
        "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot
        cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory
        libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory
        make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254
        make: *** [Makefile:128: all] Error 2 shuffle=1656129254
    
    Note that `cp` complains about inability to create target file.
    
    The change adds order-only dependency on a target directory (similar to
    the rest of rules in that file).
    
    The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build
    system megapatch`.) where upfront directory creation was never added to
    `.hs-boot` files.
    
    - - - - -
    57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00
    Mark AArch64/Darwin as requiring sign-extension
    
    Apple's AArch64 ABI requires that the caller sign-extend small integer
    arguments. Set platformCConvNeedsExtension to reflect this fact.
    
    Fixes #21773.
    
    - - - - -
    df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00
    -ddump-llvm shouldn't imply -fllvm
    
    Previously -ddump-llvm would change the backend used, which contrasts
    with all other dump flags. This is quite surprising and cost me quite
    a bit of time. Dump flags should not change compiler behavior.
    
    Fixes #21776.
    
    - - - - -
    70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00
    CmmToAsm/AArch64: Re-format argument handling logic
    
    Previously there were very long, hard to parse lines. Fix this.
    
    - - - - -
    696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00
    CmmToAsm/AArch64: Sign-extend narrow C arguments
    
    The AArch64/Darwin ABI requires that function arguments narrower
    than 32-bits must be sign-extended by the caller. We neglected to
    do this, resulting in #20735.
    
    Fixes #20735.
    
    - - - - -
    c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00
    testsuite: Add test for #20735
    
    - - - - -
    16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00
    integer-gmp: Fix cabal file
    
    Evidently fields may not come after sections in a cabal file.
    
    - - - - -
    03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00
    ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist)
    
    before the change `make install` was failing as:
    
    ```
    "mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc"
    make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'.  Stop.
    ```
    
    I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf`
    is created (somewhat manually), but not the .install varianlt of it.
    
    The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere.
    
    Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784
    
    - - - - -
    eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00
    Comments only, about join points
    
    This MR just adds some documentation about why casts
    destroy join points, following #21716.
    
    - - - - -
    251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00
    Cleanup BuiltInSyntax vs UserSyntax
    
    There was some confusion about whether FUN/TYPE/One/Many should be
    BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as
    BuiltInSyntax is for things which are directly constructed by the parser
    rather than going through normal renaming channels.
    
    I fixed all the obviously wrong places I could find and added a test for
    the original bug which was caused by this (#21752)
    
    Fixes #21752 #20695 #18302
    
    - - - - -
    0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00
    template-haskell: Bump version to 2.19.0.0
    
    Bumps text and exceptions submodules due to bounds.
    
    - - - - -
    bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00
    Tiny tweak to `IOPort#` documentation
    
    The exclamation mark and bracket don’t seem to make sense here. I’ve
    looked through the history, and I don’t think they’re deliberate – possibly
    a copy-and-paste error.
    - - - - -
    70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00
    Remove `CoreOccurAnal` constructor of the `CoreToDo` type
    
    It was dead code since the last occurence in an expression context got
    removed in 71916e1c018dded2e68d6769a2dbb8777da12664.
    
    - - - - -
    d0722170 by nineonine at 2022-07-01T08:15:56-04:00
    Fix panic with UnliftedFFITypes+CApiFFI (#14624)
    
    When declaring foreign import using CAPI calling convention, using
    unlifted unboxed types would result in compiler panic. There was
    an attempt to fix the situation in #9274, however it only addressed
    some of the ByteArray cases.
    
    This patch fixes other missed cases for all prims that may be used
    as basic foreign types.
    
    - - - - -
    eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00
    rts: gc stats: account properly for copied bytes in sequential collections
    
    We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow]
    counters during sequential collections. As well, we were double counting for
    parallel collections.
    
    To fix this we add an `else` clause to the `if (is_par_gc())`.
    
    The par_* counters do not need to be updated in the sequential case
    because they must be 0.
    
    - - - - -
    f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00
    desugar: Look through ticks when warning about possible literal overflow
    
    Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up
    between the appliation of `neg` to its argument. This defeated the
    special logic which looks for `NegApp ... (HsOverLit` to warn about
    possible overflow if a user writes a negative literal (without out
    NegativeLiterals) in their code.
    
    Fixes #21701
    
    - - - - -
    f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00
    ci: Fix definition of slow-validate flavour (so that -dlint) is passed
    
    In this embarassing sequence of events we were running slow-validate
    without -dlint.
    
    - - - - -
    bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00
    Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411
    - - - - -
    9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00
    Data.Foldable1: Remove references to Foldable-specific note
    
    ...as discussed in
    https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455.
    
    - - - - -
    3a8970ac by romes at 2022-07-03T14:11:31-04:00
    TTG: Move HsModule to L.H.S
    
    Move the definition of HsModule defined in GHC.Hs to
    Language.Haskell.Syntax with an added TTG parameter and corresponding
    extension fields.
    
    This is progress towards having the haskell-syntax package, as described
    in #21592
    
    - - - - -
    f9f80995 by romes at 2022-07-03T14:11:31-04:00
    TTG: Move ImpExp client-independent bits to L.H.S.ImpExp
    
    Move the GHC-independent definitions from GHC.Hs.ImpExp to
    Language.Haskell.Syntax.ImpExp with the required TTG extension fields
    such as to keep the AST independent from GHC.
    
    This is progress towards having the haskell-syntax package, as described
    in #21592
    
    Bumps haddock submodule
    
    - - - - -
    c43dbac0 by romes at 2022-07-03T14:11:31-04:00
    Refactor ModuleName to L.H.S.Module.Name
    
    ModuleName used to live in GHC.Unit.Module.Name. In this commit, the
    definition of ModuleName and its associated functions are moved to
    Language.Haskell.Syntax.Module.Name according to the current plan
    towards making the AST GHC-independent.
    
    The instances for ModuleName for Outputable, Uniquable and Binary were
    moved to the module in which the class is defined because these instances
    depend on GHC.
    
    The instance of Eq for ModuleName is slightly changed to no longer
    depend on unique explicitly and instead uses FastString's instance of
    Eq.
    
    - - - - -
    2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00
    Expand `Ord` instance for `Down`
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610
    
    - - - - -
    36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00
    Add applyWhen to Data.Function per CLC prop
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233
    
    - - - - -
    3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00
    hadrian: Don't read package environments in ghc-stage1 wrapper
    
    The stage1 compiler may be on the brink of existence and not have even a
    working base library. You may have installed packages globally with a
    similar stage2 compiler which will then lead to arguments such as
    --show-iface not even working because you are passing too many package
    flags. The solution is simple, don't read these implicit files.
    
    Fixes #21803
    
    - - - - -
    aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00
    Ticky:Make json info a separate field.
    
    Fixes #21233
    
    - - - - -
    74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00
    Add docs:<pkg> command to hadrian to build docs for just one package
    
    - - - - -
    418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00
    upload-docs: propagate publish correctly in upload_sdist
    
    - - - - -
    ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00
    docs-upload: Fix upload script when no packages are listed
    
    - - - - -
    d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00
    hadrian: Add --haddock-base-url option for specifying base-url when generating docs
    
    The motiviation for this flag is to be able to produce documentation
    which is suitable for uploading for hackage, ie, the cross-package links
    work correctly.
    
    There are basically three values you want to set this to:
    
    * off - default, base_url = ../%pkg% which works for local browsing
    * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload
    * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation.
    
    The `%pkg%` string is a template variable which is replaced with the
    package identifier for the relevant package.
    
    This is one step towards fixing #21749
    
    - - - - -
    41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00
    Add nightly job for generating docs suitable for hackage upload
    
    - - - - -
    620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00
    ghci: Support :set prompt in multi repl
    
    This adds supports for various :set commands apart from `:set <FLAG>` in
    multi repl, this includes `:set prompt` and so-on.
    
    Fixes #21796
    
    - - - - -
    b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00
    Vendor filepath inside template-haskell
    
    Adding filepath as a dependency of template-haskell means that it can't
    be reinstalled if any build-plan depends on template-haskell.
    
    This is a temporary solution for the 9.4 release.
    
    A longer term solution is to split-up the template-haskell package into
    the wired-in part and a non-wired-in part which can be reinstalled. This
    was deemed quite risky on the 9.4 release timescale.
    
    Fixes #21738
    
    - - - - -
    c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00
    Factor fields of `CoreDoSimplify` into separate data type
    
    This avoids some partiality. The work @mmhat is doing cleaning up and
    modularizing `Core.Opt` will build on this nicely.
    
    - - - - -
    d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00
    https urls
    - - - - -
    803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00
    options and typos
    - - - - -
    5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00
    grammar
    - - - - -
    4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00
    sources
    - - - - -
    c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00
    Fix lint warnings in bootstrap.py
    
    - - - - -
    86ced2ad by romes at 2022-07-06T01:36:23-04:00
    Restore Eq instance of ImportDeclQualifiedStyle
    
    Fixes #21819
    
    - - - - -
    3547e264 by romes at 2022-07-06T13:50:27-04:00
    Prune L.H.S modules of GHC dependencies
    
    Move around datatypes, functions and instances that are GHC-specific out
    of the `Language.Haskell.Syntax.*` modules to reduce the GHC
    dependencies in them -- progressing towards #21592
    
    Creates a module `Language.Haskell.Syntax.Basic` to hold basic
    definitions required by the other L.H.S modules (and don't belong in any
    of them)
    
    - - - - -
    e4eea07b by romes at 2022-07-06T13:50:27-04:00
    TTG: Move CoreTickish out of LHS.Binds
    
    Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and
    move them to the extension point instance, according to the plan
    outlined in #21592 to separate the base AST from the GHC specific bits.
    
    - - - - -
    acc1816b by romes at 2022-07-06T13:50:27-04:00
    TTG for ForeignImport/Export
    
    Add a TTG parameter to both `ForeignImport` and `ForeignExport` and,
    according to #21592, move the GHC-specific bits in them and in the other
    AST data types related to foreign imports and exports to the TTG
    extension point.
    
    - - - - -
    371c5ecf by romes at 2022-07-06T13:50:27-04:00
    TTG for HsTyLit
    
    Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText`
    fields to the extension point and out of the base AST.
    
    Progress towards #21592
    
    - - - - -
    fd379d1b by romes at 2022-07-06T13:50:27-04:00
    Remove many GHC dependencies from L.H.S
    
    Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC
    imports according to the plan in the linked issue.
    
    Moves more GHC-specific declarations to `GHC.*` and brings more required
    GHC-independent declarations to `Language.Haskell.Syntax.*` (extending
    e.g. `Language.Haskell.Syntax.Basic`).
    
    Progress towards #21592
    
    Bump haddock submodule for !8308
    
    -------------------------
    Metric Decrease:
        hard_hole_fits
    -------------------------
    
    - - - - -
    c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00
    Fix exact printing of the HsRule name
    
    Prior to this branch, the HsRule name was
    
        XRec pass (SourceText,RuleName)
    
    and there is an ExactPrint instance for (SourceText, RuleName).
    
    The SourceText has moved to a different location, so synthesise the
    original to trigger the correct instance when printing.
    
    We need both the SourceText and RuleName when exact printing, as it is
    possible to have a NoSourceText variant, in which case we fall back to
    the FastString.
    
    - - - - -
    665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00
    driver: Fix issue with module loops and multiple home units
    
    We were attempting to rehydrate all dependencies of a particular module,
    but we actually only needed to rehydrate those of the current package
    (as those are the ones participating in the loop).
    
    This fixes loading GHC into a multi-unit session.
    
    Fixes #21814
    
    - - - - -
    bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00
    Remove a bogus #define from ClosureMacros.h
    
    - - - - -
    fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00
    winio: make consoleReadNonBlocking not wait for any events at all.
    
    - - - - -
    42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00
    rts: allow NULL to be used as an invalid StgStablePtr
    
    - - - - -
    3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00
    RTS: Add stack marker to StgCRunAsm.S
    
    Every object file must be properly marked for non-executable stack, even if it
    contains no code.
    
    - - - - -
    a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00
    Bump unix submodule
    
    Adds `config.sub` to unix's `.gitignore`, fixing #19574.
    
    - - - - -
    3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00
    ghci: Fix most calls to isLoaded to work in multi-mode
    
    The most egrarious thing this fixes is the report about the total number
    of loaded modules after starting a session.
    
    Ticket #20889
    
    - - - - -
    fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00
    Enable :edit command in ghci multi-mode.
    
    This works after the last change to isLoaded.
    
    Ticket #20888
    
    - - - - -
    46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00
    Fix a scoping bug in the Specialiser
    
    In the call to `specLookupRule` in `already_covered`, in `specCalls`,
    we need an in-scope set that includes the free vars of the arguments.
    But we simply were not guaranteeing that: did not include the
    `rule_bndrs`.
    
    Easily fixed.  I'm not sure how how this bug has lain for quite
    so long without biting us.
    
    Fixes #21828.
    
    - - - - -
    6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
    Edit Note [idArity varies independently of dmdTypeDepth]
    
    ...and refer to it in GHC.Core.Lint.lintLetBind.
    
    Fixes #21452
    
    - - - - -
    89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
    Tiny documentation wibbles (comments only)
    
    - - - - -
    61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00
    fix readme
    - - - - -
    61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00
    fix bootstrap
    - - - - -
    8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00
    tarball
    - - - - -
    e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00
    hie-files: Fix scopes for deriving clauses and instance signatures (#18425)
    
    - - - - -
    c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00
    hie-files: Record location of filled in default method bindings
    
    This is useful for hie files to reconstruct the evidence that default methods
    depend on.
    
    - - - - -
    9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00
    testsuite: Factor out common parts from hiefile tests
    
    - - - - -
    6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00
    Hadrian: update documentation of settings
    
    The documentation for key-value settings was a bit out of date.
    This patch updates it to account for `cabal.configure.opts` and
    `hsc2hs.run.opts`.
    
    The user-settings document was also re-arranged, to make the key-value
    settings more prominent (as it doesn't involve changing the Hadrian
    source code, and thus doesn't require any recompilation of Hadrian).
    
    - - - - -
    a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00
    Fix potential space leak that arise from ModuleGraphs retaining references
    to previous ModuleGraphs, in particular the lazy `mg_non_boot` field.
    This manifests in `extendMG`.
    
    Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which
    is only called in two places in the compiler, and should only be called at most
    once for every home unit:
    
    GHC.Driver.Make:
          mainModuleSrcPath :: Maybe String
          mainModuleSrcPath = do
            ms <- mgLookupModule mod_graph (mainModIs hue)
            ml_hs_file (ms_location ms)
    
    GHCI.UI:
    listModuleLine modl line = do
       graph <- GHC.getModuleGraph
       let this = GHC.mgLookupModule graph modl
    
    Instead `mgLookupModule` can be a linear function that looks through the entire
    list of `ModuleGraphNodes`
    
    Fixes #21816
    
    - - - - -
    dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00
    rts: Fix AdjustorPool bitmap manipulation
    
    Previously the implementation of bitmap_first_unset assumed that
    `__builtin_clz` would accept `uint8_t` however it apparently rather
    extends its argument to `unsigned int`.
    
    To fix this we simply revert to a naive implementation since handling
    the various corner cases with `clz` is quite tricky. This should be
    fine given that AdjustorPool isn't particularly hot. Ideally we would
    have a single, optimised bitmap implementation in the RTS but I'll leave
    this for future work.
    
    Fixes #21838.
    
    - - - - -
    ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00
    Change GHCi bytecode return convention for unlifted datatypes.
    
    This changes the bytecode return convention for unlifted
    algebraic datatypes to be the same as for lifted
    types, i.e. ENTER/PUSH_ALTS instead of
    RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED
    
    Fixes #20849
    
    - - - - -
    5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00
    Compute record-dot-syntax types
    Ensures type information for record-dot-syntax
    is included in HieASTs. See #21797
    
    - - - - -
    89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00
    Add record-dot-syntax test
    
    - - - - -
    4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00
    Document RuntimeRep polymorphism limitations of catch#, et al
    
    As noted in #21868, several primops accepting continuations producing
    RuntimeRep-polymorphic results aren't nearly as polymorphic as their
    types suggest. Document this limitation and adapt the `UnliftedWeakPtr`
    test to avoid breaking this limitation in `keepAlive#`.
    
    - - - - -
    4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00
    Make keepAlive# out-of-line
    
    This is a naive approach to fixing the unsoundness noticed in #21708.
    Specifically, we remove the lowering of `keepAlive#` via CorePrep and
    instead turn it into an out-of-line primop.
    This is simple, inefficient (since the continuation must now be heap
    allocated), but good enough for 9.4.1. We will revisit this
    (particiularly via #16098) in a future release.
    
    Metric Increase:
        T4978
        T7257
        T9203
    
    - - - - -
    1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00
    Suppress extra output from configure check for c++ libraries
    
    - - - - -
    3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00
    rel-notes: Drop mention of #21745 fix
    
    Since we have backported the fix to 9.4.1.
    
    - - - - -
    b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00
    Align the behaviour of `dopt` and `log_dopt`
    
    Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying
    function `log_dopt`) were different as the latter did not take the
    verbosity level into account. This led to problems during the
    refactoring as we cannot simply replace calls to `dopt` with calls to
    `logHasDumpFlag`.
    
    In addition to that a subtle bug in the GHC module was fixed:
    `setSessionDynFlags` did not update the logger and as a consequence the
    verbosity value of the logger was not set appropriately.
    
    Fixes #21861
    
    - - - - -
    28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00
    rts: forkOn context switches the target capability
    
    Fixes #21824
    
    - - - - -
    f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00
    cmm: Eliminate orphan Outputable instances
    
    Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and
    `OutputableP` instances for the Cmm AST. This makes it significantly
    easier to use the Cmm pretty-printers in tracing output without
    incurring module import cycles.
    
    - - - - -
    f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00
    cmm: Move toBlockList to GHC.Cmm
    
    - - - - -
    fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00
    compiler: Add haddock sections to GHC.Utils.Panic
    
    - - - - -
    097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00
    configure: Don't override Windows CXXFLAGS
    
    At some point we used the clang distribution from msys2's `MINGW64`
    environment for our Windows toolchain. This defaulted to using libgcc
    and libstdc++ for its runtime library. However, we found for a variety
    of reasons that compiler-rt, libunwind, and libc++ were more reliable,
    consequently we explicitly overrode the CXXFLAGS to use these.
    
    However, since then we have switched to use the `CLANG64` packaging,
    which default to these already. Consequently we can drop these
    arguments, silencing some redundant argument warnings from clang.
    
    Fixes #21669.
    
    - - - - -
    e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/Elf: Check that there are no NULL ctors
    
    - - - - -
    616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/Elf: Introduce support for invoking finalizers on unload
    
    Addresses #20494.
    
    - - - - -
    cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00
    testsuite: Add T20494
    
    - - - - -
    03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Rename finit field to fini
    
    fini is short for "finalizer", which does not contain a "t".
    
    - - - - -
    033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Refactor handling of oc->info
    
    Previously we would free oc->info after running initializers. However,
    we can't do this is we want to also run finalizers.
    
    Moreover, freeing oc->info so early was wrong for another reason:
    we will need it in order to unregister the exception tables (see the
    call to `RtlDeleteFunctionTable`).
    
    In service of #20494.
    
    - - - - -
    f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Add finalization support
    
    This implements #20494 for the PEi386 linker.
    
    Happily, this also appears to fix `T9405`, resolving #21361.
    
    - - - - -
    2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00
    Loader: Implement gnu-style -l:$path syntax
    
    Gnu ld allows `-l` to be passed an absolute file path,
    signalled by a `:` prefix. Implement this in the GHC's
    loader search logic.
    
    - - - - -
    5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00
    Statically-link against libc++ on Windows
    
    Unfortunately on Windows we have no RPATH-like facility, making dynamic
    linking extremely fragile. Since we cannot assume that the user will
    add their GHC installation to `$PATH` (and therefore their DLL
    search path) we cannot assume that the loader will be able to locate our
    `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on
    Windows.
    
    Fixes #21435.
    
    - - - - -
    8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run
    
    It turns out that PE objects may have multiple `.ctors`/`.dtors`
    sections but the RTS linker had assumed that there was only one. Fix
    this.
    
    Fixes #21618.
    
    - - - - -
    fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Respect dtor/ctor priority
    
    Previously we would run constructors and destructors in arbitrary order
    despite explicit priorities.
    
    Fixes #21847.
    
    - - - - -
    1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00
    testsuite: Add test for #21618 and #21847
    
    - - - - -
    6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Fix exception unwind unregistration
    
    RtlDeleteFunctionTable expects a pointer to the .pdata section
    yet we passed it the .xdata section.
    
    Happily, this fixes #21354.
    
    - - - - -
    d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/MachO: Drop dead code
    
    - - - - -
    d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/MachO: Use section flags to identify initializers
    
    - - - - -
    fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/MachO: Introduce finalizer support
    
    - - - - -
    5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00
    testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl
    
    - - - - -
    6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00
    rts/linker/Elf: Work around GCC 6 init/fini behavior
    
    It appears that GCC 6t (at least on i386) fails to give
    init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY
    section types, instead marking them as SHT_PROGBITS. This caused T20494
    to fail on Debian.
    
    - - - - -
    5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00
    testsuite: Mark T13366Cxx as unbroken on Darwin
    
    - - - - -
    1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00
    rts/linker: Fix resolution of __dso_handle on Darwin
    
    Darwin expects a leading underscore.
    
    - - - - -
    a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00
    rts/linker: Clean up section kinds
    
    - - - - -
    aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00
    rts/linker: Ensure that __cxa_finalize is called on code unload
    
    - - - - -
    028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00
    testsuite: Fix T11829 on Centos 7
    
    It appears that Centos 7 has a more strict C++ compiler than most
    distributions since std::runtime_error is defined in <stdexcept> rather
    than <exception>. In T11829 we mistakenly imported the latter.
    
    - - - - -
    a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00
    hadrian: Rename documentation directories for consistency with make
    
    * Rename `docs` to `doc`
    * Place pdf documentation in `doc/` instead of `doc/pdfs/`
    
    Fixes #21164.
    
    - - - - -
    b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00
    Fix incorrect proof of applyWhen’s properties
    
    - - - - -
    eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00
    hadrian: Add multi:<pkg> and multi targets for starting a multi-repl
    
    This patch adds support to hadrian for starting a multi-repl containing
    all the packages which stage0 can build. In particular, there is the new
    user-facing command:
    
    ```
    ./hadrian/ghci-multi
    ```
    
    which when executed will start a multi-repl containing the `ghc` package
    and all it's dependencies.
    
    This is implemented by two new hadrian targets:
    
    ```
    ./hadrian/build multi:<pkg>
    ```
    
    Construct the arguments for a multi-repl session where the top-level
    package is <pkg>. For example, `./hadrian/ghci-multi` is implemented
    using `multi:ghc` target.
    
    There is also the `multi` command which constructs a repl for everything
    in stage0 which we can build.
    
    - - - - -
    19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00
    changelog typo
    - - - - -
    af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00
    typos
    
    - - - - -
    415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00
    Refactor SpecConstr to use treat bindings uniformly
    
    This patch, provoked by #21457, simplifies SpecConstr by treating
    top-level and nested bindings uniformly (see the new scBind).
    
    * Eliminates the mysterious scTopBindEnv
    
    * Refactors scBind to handle top-level and nested definitions
      uniformly.
    
    * But, for now at least, continues the status quo of not doing
      SpecConstr for top-level non-recursive bindings.  (In contrast
      we do specialise nested non-recursive bindings, although the
      original paper did not; see Note [Local let bindings].)
    
      I tried the effect of specialising top-level non-recursive
      bindings (which is now dead easy to switch on, unlike before)
      but found some regressions, so I backed off.  See !8135.
    
    It's a pure refactoring.  I think it'll do a better job in a few
    cases, but there is no regression test.
    
    - - - - -
    d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00
    Rule matching: Don't compute the FVs if we don't look at them.
    
    - - - - -
    5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    White space only in FamInstEnv
    
    - - - - -
    ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    Make transferPolyIdInfo work for CPR
    
    I don't know why this hasn't bitten us before, but it was plain wrong.
    
    - - - - -
    9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    Inline mapAccumLM
    
    This function is called in inner loops in the compiler, and it's
    overloaded and higher order.  Best just to inline it.
    
    This popped up when I was looking at something else.  I think
    perhaps GHC is delicately balanced on the cusp of inlining this
    automatically.
    
    - - - - -
    d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    Make SetLevels honour floatConsts
    
    This fix,  in the definition of profitableFloat,
    is just for consistency. `floatConsts` should
    do what it says!
    
    I don't think it'll affect anything much, though.
    
    - - - - -
    d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    Refactor wantToUnboxArg a bit
    
    * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg
      and similarly wantToUnboxResult to canUnboxResult.
    
    * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for
      the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg,
      avoiding some yukky duplication.
    
      I decided it was clearer to give it a new data type for its
      return type, because I nedeed the FD_RecBox case which was not
      otherwise readiliy expressible.
    
    * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload
    
    * Get rid of the Unlift constructor of UnboxingDecision, eliminate
      two panics, and two arguments to canUnboxArg (new name).  Much
      nicer now.
    
    - - - - -
    6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00
    Allow running memInventory when the concurrent nonmoving gc is enabled
    
    If the nonmoving gc is enabled and we are using a threaded RTS,
    we now try to grab the collector mutex to avoid memInventory and
    the collection racing.
    
    Before memInventory was disabled.
    
    - - - - -
    aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00
    gitignore: don't ignore all aclocal.m4 files
    
    While GHC's own aclocal.m4 is generated by the aclocal tool, other
    packages' aclocal.m4 are committed in the repository. Previously
    `.gitignore` included an entry which covered *any* file named
    `aclocal.m4`, which lead to quite some confusion (e.g. see #21740).
    Fix this by modifying GHC's `.gitignore` to only cover GHC's own
    `aclocal.m4`.
    
    - - - - -
    4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00
    Add mapAccumM, forAccumM to Data.Traversable
    
    Approved by Core Libraries Committee in
    https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433
    
    - - - - -
    bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00
    configure: Use AC_PATH_TOOL to detect tools
    
    Previously we used AC_PATH_PROG which, as noted by #21601, does not
    look for tools with a target prefix,
    breaking cross-compilation.
    
    Fixes #21601.
    
    - - - - -
    e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00
    driver: Fix implementation of -S
    
    We were failing to stop before running the assembler so the object file
    was also created.
    
    Fixes #21869
    
    - - - - -
    e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00
    rts/ProfHeap: Ensure new Censuses are zeroed
    
    When growing the Census array ProfHeap previously neglected to
    zero the new part of the array. Consequently `freeEra` would attempt to
    free random words that often looked suspiciously like pointers.
    
    Fixes #21880.
    
    - - - - -
    81d65f7f by sheaf at 2022-07-21T15:37:22+02:00
    Make withDict opaque to the specialiser
    
    As pointed out in #21575, it is not sufficient to set withDict to inline
    after the typeclass specialiser, because we might inline withDict in one
    module and then import it in another, and we run into the same problem.
    This means we could still end up with incorrect runtime results because
    the typeclass specialiser would assume that distinct typeclass evidence
    terms at the same type are equal, when this is not necessarily the case
    when using withDict.
    
    Instead, this patch introduces a new magicId, 'nospec', which is only
    inlined in CorePrep. We make use of it in the definition of withDict
    to ensure that the typeclass specialiser does not common up distinct
    typeclass evidence terms.
    
    Fixes #21575
    
    - - - - -
    9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00
    Refactored Simplify pass
    
     * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify
       namespace and GHC.Core.Opt.Stats.
       Also removed services from configuration records.
    
     * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration.
    
     * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm`
       and moved the Simplify driver to GHC.Core.Opt.Simplify.
    
     * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env.
    
     * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment
       in GHC.Core.Opt.Simplify.Monad.
    
     * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions
       for those in a new module GHC.Driver.Config.Core.Opt.Simplify.
       Also added initialization functions for `SimplMode` to that module.
    
     * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types
       and the counting types and functions (`SimplCount` and `Tick`) to new
       module GHC.Core.Opt.Stats.
    
     * Added getter functions for the fields of `SimplMode`. The pedantic bottoms
       option and the platform are retrieved from the ArityOpts and RuleOpts and the
       getter functions allow us to retrieve values from `SpecEnv` without the
       knowledge where the data is stored exactly.
    
     * Moved the coercion optimization options from the top environment to
       `SimplMode`. This way the values left in the top environment are those
       dealing with monadic functionality, namely logging, IO related stuff and
       counting. Added a note "The environments of the Simplify pass".
    
     * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of
       `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead.
    
     * Prep work before removing `InteractiveContext` from `HscEnv`.
    
    - - - - -
    2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00
    Make the specialiser deal better with specialised methods
    
    This patch fixes #21848, by being more careful to update unfoldings
    in the type-class specialiser.
    
    See the new Note [Update unfolding after specialisation]
    
    Now that we are being so much more careful about unfoldings,
    it turned out that I could dispense with se_interesting, and
    all its tricky corners. Hooray.  This fixes #21368.
    
    - - - - -
    ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00
    ghc-boot: Clean up UTF-8 codecs
    
    In preparation for moving the UTF-8 codecs into `base`:
    
    * Move them to GHC.Utils.Encoding.UTF8
    * Make names more consistent
    * Add some Haddocks
    
    - - - - -
    e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00
    base: Introduce GHC.Encoding.UTF8
    
    Here we copy a subset of the UTF-8 implementation living in `ghc-boot`
    into `base`, with the intent of dropping the former in the future. For
    this reason, the `ghc-boot` copy is now CPP-guarded on
    `MIN_VERSION_base(4,18,0)`.
    
    Naturally, we can't copy *all* of the functions defined by `ghc-boot` as
    some depend upon `bytestring`; we rather just copy those which only
    depend upon `base` and `ghc-prim`.
    
    Further consolidation?
    ----------------------
    
    Currently GHC ships with at least five UTF-8 implementations:
    
    * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this
      can be used at a number of types including `Addr#`, `ByteArray#`,
      `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this
      can be removed in GHC 9.6+2, when the copies in `base` will become
      available to `ghc-boot`.
    * the copy of the `ghc-boot` definition now exported by
      `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`,
      `ByteArray#`, and `ForeignPtr`
    * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`;
      this is specialised at `Addr#`.
    * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`;
      this is specialised at `Addr#` but, unlike the above, supports
      recovery in the presence of partial codepoints (since in IO contexts
      codepoints may be broken across buffers)
    * the implementation provided by the `text` library
    
    This does seem a tad silly. On the other hand, these implementations
    *do* materially differ from one another (e.g. in the types they support,
    the detail in errors they can report, and the ability to recover from
    partial codepoints). Consequently, it's quite unclear that further
    consolidate would be worthwhile.
    
    - - - - -
    f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00
    Add a Note summarising GHC's UTF-8 implementations
    
    GHC has a somewhat dizzying array of UTF-8 implementations. This note
    describes why this is the case.
    
    - - - - -
    72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00
    upload_ghc_libs: Fix path to documentation
    
    The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35
    but this one occurrence was note updated.
    
    Finally closes #21164.
    
    - - - - -
    a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00
    Add test for #21871
    
    This adds a test for #21871, which was fixed by the No Skolem Info
    rework (MR !7105).
    
    Fixes #21871
    
    - - - - -
    6379f942 by sheaf at 2022-07-22T08:18:46-04:00
    Add test for #21360
    
    The way record updates are typechecked/desugared changed in MR !7981.
    Because we desugar in the typechecker to a simple case expression, the
    pattern match checker becomes able to spot the long-distance information
    and avoid emitting an incorrect pattern match warning.
    
    Fixes #21360
    
    - - - - -
    ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00
    Hadrian: don't try to build "unix" on Windows
    - - - - -
    dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
    Implement DeepSubsumption
    
    This MR adds the language extension -XDeepSubsumption, implementing
    GHC proposal #511.  This change mitigates the impact of GHC proposal
    
    The changes are highly localised, by design.  See Note [Deep subsumption]
    in GHC.Tc.Utils.Unify.
    
    The main changes are:
    
    * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010,
      but off in Haskell2021.
    
      -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change.
      -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds:
      it makes type inference more complicated and less predictable, but it
      may be convenient in practice.
    
    * The main changes are in:
      * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion
      * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation
      * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result
        type. Without deep subsumption, unifyExpectedType would be sufficent.
    
      See Note [Deep subsumption] in GHC.Tc.Utils.Unify.
    
    * There are no changes to Quick Look at all.
    
    * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to
      GHC.Magic.Dict
    
    * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where
      we'd forgotten to take the free vars of the multiplicity of an Id.
    
    * I also had to fix tcSplitNestedSigmaTys
    
      When I did the shallow-subsumption patch
        commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f
        Date:   Sun Feb 2 18:23:11 2020 +0000
        Simple subsumption
    
      I changed tcSplitNestedSigmaTys to not look through function arrows
      any more.  But that was actually an un-forced change.  This function
      is used only in
    
      * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt
      * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass
      * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect
    
      All to do with validity checking and error messages. Acutally its
      fine to look under function arrows here, and quite useful a test
      DeepSubsumption05 (a test motivated by a build failure in the
      `lens` package) shows.
    
      The fix is easy.  I added Note [tcSplitNestedSigmaTys].
    
    - - - - -
    e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00
    Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption
    
    - - - - -
    67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00
    Add DeepSubsumption08
    
    - - - - -
    5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
    Fix the interaction of operator sections and deep subsumption
    
    Fixes DeepSubsumption08
    
    - - - - -
    918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00
    Add DeepSubsumption09
    
    - - - - -
    2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00
    Default implementation for mempty/(<>)
    
    Approved by: https://github.com/haskell/core-libraries-committee/issues/61
    
    This adds a default implementation for `mempty` and `(<>)` along
    with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid`
    instances can be defined in terms of `sconcat` / `mconcat`.
    
    The description for each class has also been updated to include the
    equivalent set of laws for the `sconcat`-only / `mconcat`-only
    instances.
    
    - - - - -
    73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00
    ci: Disable (broken) perf-nofib
    
    See #21859
    
    - - - - -
    c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00
    Docs: clarify ConstraintKinds infelicity
    
    GHC doesn't consistently require the ConstraintKinds extension to
    be enabled, as it allows programs such as type families returning
    a constraint without this extension.
    
    MR !7784 fixes this infelicity, but breaking user programs was deemed
    to not be worth it, so we document it instead.
    
    Fixes #21061.
    
    - - - - -
    5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00
    More improvements to worker/wrapper
    
    This patch fixes #21888, and simplifies finaliseArgBoxities
    by eliminating the (recently introduced) data type FinalDecision.
    
    A delicate interaction meant that this patch
       commit d1c25a48154236861a413e058ea38d1b8320273f
       Date:   Tue Jul 12 16:33:46 2022 +0100
       Refactor wantToUnboxArg a bit
    
    make worker/wrapper go into an infinite loop.  This patch
    fixes it by narrowing the handling of case (B) of
    Note [Boxity for bottoming functions], to deal only the
    arguemnts that are type variables.  Only then do we drop
    the trimBoxity call, which is what caused the bug.
    
    I also
    * Added documentation of case (B), which was previously
      completely un-mentioned.  And a regression test,
      T21888a, to test it.
    
    * Made unboxDeeplyDmd stop at lazy demands.  It's rare anyway
      for a bottoming function to have a lazy argument (mainly when
      the data type is recursive and then we don't want to unbox
      deeply).  Plus there is Note [No lazy, Unboxed demands in
      demand signature]
    
    * Refactored the Case equation for dmdAnal a bit, to do less
      redundant pattern matching.
    
    - - - - -
    b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00
    Fix a small buglet in tryEtaReduce
    
    Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was
    making an ill-formed cast.  It didn't matter, because the subsequent
    guard discarded it; but still worth fixing.  Spurious warnings are
    distracting.
    
    - - - - -
    3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00
    Fix #21889, GHCi misbehaves with Ctrl-C on Windows
    
    On Windows, we create multiple levels of wrappers for GHCi which ultimately
    execute ghc --interactive. In order to handle console events properly, each of
    these wrappers must call FreeConsole() in order to hand off event processing to
    the child process. See #14150.
    
    In addition to this, FreeConsole must only be called from interactive processes (#13411).
    
    This commit makes two changes to fix this situation:
    
    1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole`
       if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi.
    2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather
       than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`:
    
       Before:
       ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe
    
       After:
       ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe
    
    - - - - -
    79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00
    docs: Fix documentation of \cases
    
    Fixes #21902.
    
    - - - - -
    e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00
    ghc-cabal: allow Cabal 3.8 to unbreak make build
    
    When bootstrapping GHC 9.4.*, the build will fail when configuring
    ghc-cabal as part of the make based build system due to this upper
    bound, as Cabal has been updated to a 3.8 release.
    
    Reference #21914, see especially
    https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699
    
    - - - - -
    726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
    Fix isEvaldUnfolding and isValueUnfolding
    
    This fixes (1) in #21831.  Easy, obviously correct.
    
    - - - - -
    5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
    Switch off eta-expansion in rules and unfoldings
    
    I think this change will make little difference except to reduce
    clutter.  But that's it -- if it causes problems we can switch it
    on again.
    
    - - - - -
    d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
    Teach SpecConstr about typeDeterminesValue
    
    This patch addresses #21831, point 2.  See
    Note [generaliseDictPats] in SpecConstr
    
    I took the opportunity to refactor the construction of specialisation
    rules a bit, so that the rule name says what type we are specialising
    at.
    
    Surprisingly, there's a 20% decrease in compile time for test
    perf/compiler/T18223. I took a look at it, and the code size seems the
    same throughout. I did a quick ticky profile which seemed to show a
    bit less substitution going on.  Hmm.  Maybe it's the "don't do
    eta-expansion in stable unfoldings" patch, which is part of the
    same MR as this patch.
    
    Anyway, since it's a move in the right direction, I didn't think it
    was worth looking into further.
    
    Metric Decrease:
        T18223
    
    - - - - -
    65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
    Add a 'notes' file in testsuite/tests/perf/compiler
    
    This file is just a place to accumlate notes about particular
    benchmarks, so that I don't keep re-inventing the wheel.
    
    - - - - -
    61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00
    Get the in-scope set right in FamInstEnv.injectiveBranches
    
    There was an assert error, as Gergo pointed out in #21896.
    
    I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs.
    And also to GHC.Core.Unify.niFixTCvSubst.
    
    I also took the opportunity to get a couple more InScopeSets right,
    and to change some substTyUnchecked into substTy.
    
    This MR touches a lot of other files, but only because I also took the
    opportunity to introduce mkInScopeSetList, and use it.
    
    - - - - -
    4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00
    Add location to cc phase
    
    - - - - -
    96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00
    Avoid as pipeline when compiling c
    
    - - - - -
    2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00
    testsuite: Skip test cases involving -S when testing unregisterised GHC
    
    We no longer generate .s files anyway.
    
    Metric Decrease:
        MultiLayerModules
        T10421
        T13035
        T13701
        T14697
        T16875
        T18140
        T18304
        T18923
        T9198
    
    - - - - -
    82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00
    testsuite: introduce nonmoving_thread_sanity way
    
    (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae)
    
    - - - - -
    4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00
    rts/nonmoving: Track segment state
    
    It can often be useful during debugging to be able to determine the
    state of a nonmoving segment. Introduce some state, enabled by DEBUG, to
    track this.
    
    (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f)
    
    - - - - -
    54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00
    rts/nonmoving: Don't scavenge objects which weren't evacuated
    
    This fixes a rather subtle bug in the logic responsible for scavenging
    objects evacuated to the non-moving generation. In particular, objects
    can be allocated into the non-moving generation by two ways:
    
     a. evacuation out of from-space by the garbage collector
     b. direct allocation by the mutator
    
    Like all evacuation, objects moved by (a) must be scavenged, since they
    may contain references to other objects located in from-space. To
    accomplish this we have the following scheme:
    
     * each nonmoving segment's block descriptor has a scan pointer which
       points to the first object which has yet to be scavenged
    
     * the GC tracks a set of "todo" segments which have pending scavenging
       work
    
     * to scavenge a segment, we scavenge each of the unmarked blocks
       between the scan pointer and segment's `next_free` pointer.
    
       We skip marked blocks since we know the allocator wouldn't have
       allocated into marked blocks (since they contain presumably live
       data).
    
       We can stop at `next_free` since, by
       definition, the GC could not have evacuated any objects to blocks
       above `next_free` (otherwise `next_free wouldn't be the first free
       block).
    
    However, this neglected to consider objects allocated by path (b).
    In short, the problem is that objects directly allocated by the mutator
    may become unreachable (but not swept, since the containing segment is
    not yet full), at which point they may contain references to swept objects.
    Specifically, we observed this in #21885 in the following way:
    
    1. the mutator (specifically in #21885, a `lockCAF`) allocates an object
       (specifically a blackhole, which here we will call `blkh`; see Note
       [Static objects under the nonmoving collector] for the reason why) on
       the non-moving heap. The bitmap of the allocated block remains 0
       (since allocation doesn't affect the bitmap) and the containing
       segment's (which we will call `blkh_seg`) `next_free` is advanced.
    2. We enter the blackhole, evaluating the blackhole to produce a result
       (specificaly a cons cell) in the nursery
    3. The blackhole gets updated into an indirection pointing to the cons
       cell; it is pushed to the generational remembered set
    4. we perform a GC, the cons cell is evacuated into the nonmoving heap
       (into segment `cons_seg`)
    5. the cons cell is marked
    6. the GC concludes
    7. the CAF and blackhole become unreachable
    8. `cons_seg` is filled
    9. we start another GC; the cons cell is swept
    10. we start a new GC
    11. something is evacuated into `blkh_seg`, adding it to the "todo" list
    12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks
        between `scan` and `next_free`, which includes `blkh`). We attempt to
        evacuate `blkh`'s indirectee, which is the previously-swept cons cell.
        This is unsafe, since the indirectee is no longer a valid heap
        object.
    
    The problem here was that the scavenging logic *assumed* that (a) was
    the only source of allocations into the non-moving heap and therefore
    *all* unmarked blocks between `scan` and `next_free` were evacuated.
    However, due to (b) this is not true.
    
    The solution is to ensure that that the scanned region only encompasses
    the region of objects allocated during evacuation. We do this by
    updating `scan` as we push the segment to the todo-segment list to
    point to the block which was evacuated into.
    
    Doing this required changing the nonmoving scavenging implementation's
    update of the `scan` pointer to bump it *once*, instead of after
    scavenging each block as was done previously. This is because we may end
    up evacuating into the segment being scavenged as we scavenge it. This
    was quite tricky to discover but the result is quite simple,
    demonstrating yet again that global mutable state should be used
    exceedingly sparingly.
    
    Fixes #21885
    
    (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060)
    
    - - - - -
    25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00
    testsuite: Skip a few tests as in the nonmoving collector
    
    Residency monitoring under the non-moving collector is quite
    conservative (e.g. the reported value is larger than reality) since
    otherwise we would need to block on concurrent collection. Skip a few
    tests that are sensitive to residency.
    
    (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70)
    
    - - - - -
    42147534 by sternenseemann at 2022-07-26T16:26:53-04:00
    hadrian: add flag disabling selftest rules which require QuickCheck
    
    The hadrian executable depends on QuickCheck for building, meaning this
    library (and its dependencies) will need to be built for bootstrapping
    GHC in the future. Building QuickCheck, however, can require
    TemplateHaskell. When building a statically linking GHC toolchain,
    TemplateHaskell can be tricky to get to work, and cross-compiling
    TemplateHaskell doesn't work at all without -fexternal-interpreter,
    so QuickCheck introduces an element of fragility to GHC's bootstrap.
    
    Since the selftest rules are the only part of hadrian that need
    QuickCheck, we can easily eliminate this bootstrap dependency when
    required by introducing a `selftest` flag guarding the rules' inclusion.
    
    Closes #8699.
    
    - - - - -
    9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00
    Regression test for #21848
    
    - - - - -
    ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00
    driver: Don't create LinkNodes when -no-link is enabled
    
    Fixes #21866
    
    - - - - -
    fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00
    Docs: fix mistaken claim about kind signatures
    
    This patch fixes #21806 by rectifying an incorrect claim about
    the usage of kind variables in the header of a data declaration with
    a standalone kind signature.
    
    It also adds some clarifications about the number of parameters expected
    in GADT declarations and in type family declarations.
    
    - - - - -
    2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00
    testsuite: Correctly set withNativeCodeGen
    
    Fixes #21918
    
    - - - - -
    f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00
    Fix since annotations in GHC.Stack.CloneStack
    
    Fixes #21894
    
    - - - - -
    aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00
    Add -dsuppress-coercion-types to make coercions even smaller.
    
    Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)``
    simply print `` `cast` <Co:11> :: ... ``
    
    - - - - -
    97655ad8 by sheaf at 2022-08-02T19:27:29-04:00
    User's guide: fix typo in hasfield.rst
    
    Fixes #21950
    
    - - - - -
    35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00
    Remove TCvSubst and use Subst for both term and type-level subst
    
    This patch removes the TCvSubst data type and instead uses Subst as
    the environment for both term and type level substitution. This
    change is partially motivated by the existential type proposal,
    which will introduce types that contain expressions and therefore
    forces us to carry around an "IdSubstEnv" even when substituting for
    types. It also reduces the amount of code because "Subst" and
    "TCvSubst" share a lot of common operations. There isn't any
    noticeable impact on performance (geo. mean for ghc/alloc is around
    0.0% but we have -94 loc and one less data type to worry abount).
    
    Currently, the "TCvSubst" data type for substitution on types is
    identical to the "Subst" data type except the former doesn't store
    "IdSubstEnv". Using "Subst" for type-level substitution means there
    will be a redundant field stored in the data type. However, in cases
    where the substitution starts from the expression, using "Subst" for
    type-level substitution saves us from having to project "Subst" into a
    "TCvSubst". This probably explains why the allocation is mostly even
    despite the redundant field.
    
    The patch deletes "TCvSubst" and moves "Subst" and its relevant
    functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst".
    Substitution on expressions is still defined in "GHC.Core.Subst" so we
    don't have to expose the definition of "Expr" in the hs-boot file that
    "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose
    codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed
    into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a
    distinct function from "isEmptySubst"; the former ignores the
    emptiness of "IdSubstEnv"). These exceptions mainly exist for
    performance reasons and will go away when "Expr" and "Type" are
    mutually recursively defined (we won't be able to take those
    shortcuts if we can't make the assumption that expressions don't
    appear in types).
    
    - - - - -
    b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00
    Fix TH + defer-type-errors interaction (#21920)
    
    Previously, we had to disable defer-type-errors in splices because of #7276.
    But this fix is no longer necessary, the test T7276 no longer segfaults
    and is now correctly deferred.
    
    - - - - -
    fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00
    Add a note about about W/W for unlifting strict arguments
    
    This fixes #21236.
    
    - - - - -
    fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00
    Force safeInferred to avoid retaining extra copy of DynFlags
    
    This will only have a (very) modest impact on memory but we don't want
    to retain old copies of DynFlags hanging around so best to force this
    value.
    
    - - - - -
    0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00
    Force name selectors to ensure no reference to Ids enter the NameCache
    
    I observed some unforced thunks in the NameCache which were retaining a
    whole Id, which ends up retaining a Type.. which ends up retaining old
    copies of HscEnv containing stale HomeModInfo.
    
    - - - - -
    0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00
    Fix leaks in --make mode when there are module loops
    
    This patch fixes quite a tricky leak where we would end up retaining
    stale ModDetails due to rehydrating modules against non-finalised
    interfaces.
    
    == Loops with multiple boot files
    
    It is possible for a module graph to have a loop (SCC, when ignoring boot files)
    which requires multiple boot files to break. In this case we must perform the
    necessary hydration steps before and after compiling modules which have boot files
    which are described above for corectness but also perform an additional hydration step
    at the end of the SCC to remove space leaks.
    
    Consider the following example:
    
    ┌───────┐   ┌───────┐
    │       │   │       │
    │   A   │   │   B   │
    │       │   │       │
    └─────┬─┘   └───┬───┘
          │         │
     ┌────▼─────────▼──┐
     │                 │
     │        C        │
     └────┬─────────┬──┘
          │         │
     ┌────▼──┐  ┌───▼───┐
     │       │  │       │
     │ A-boot│  │ B-boot│
     │       │  │       │
     └───────┘  └───────┘
    
     A, B and C live together in a SCC. Say we compile the modules in order
     A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps
     (because A has a boot file). Therefore C will be hydrated relative to A, and the
     ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again,
     and so B will reference C/A,B, its interface will be hydrated relative to both A and B.
     Now there is a space leak because say C is a very big module, there are now two different copies of
     ModDetails kept alive by modules A and B.
    
    The way to avoid this space leak is to rehydrate an entire SCC together at the
    end of compilation so that all the ModDetails point to interfaces for .hs files.
    In this example, when we hydrate A, B and C together then both A and B will refer to
    C/A,B.
    
    See #21900 for some more discussion.
    
    -------------------------------------------------------
    
    In addition to this simple case, there is also the potential for a leak
    during parallel upsweep which is also fixed by this patch. Transcibed is
    Note [ModuleNameSet, efficiency and space leaks]
    
    Note [ModuleNameSet, efficiency and space leaks]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    During unsweep the results of compiling modules are placed into a MVar, to find
    the environment the module needs to compile itself in the MVar is consulted and
    the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking
    module dependencies and recreating the HUG from scratch each time is very expensive.
    
    In serial mode (-j1), this all works out fine because a module can only be compiled after
    its dependencies have finished compiling and not interleaved with compiling module loops.
    Therefore when we create the finalised or no loop interfaces, the HUG only contains
    finalised interfaces.
    
    In parallel mode, we have to be more careful because the HUG variable can contain
    non-finalised interfaces which have been started by another thread. In order to avoid
    a space leak where a finalised interface is compiled against a HPT which contains a
    non-finalised interface we have to restrict the HUG to only the visible modules.
    
    The visible modules is recording in the ModuleNameSet, this is propagated upwards
    whilst compiling and explains which transitive modules are visible from a certain point.
    This set is then used to restrict the HUG before the module is compiled to only
    the visible modules and thus avoiding this tricky space leak.
    
    Efficiency of the ModuleNameSet is of utmost importance because a union occurs for
    each edge in the module graph. Therefore the set is represented directly as an IntSet
    which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is
    too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode.
    
    See test "jspace" for an example which used to trigger this problem.
    
    Fixes #21900
    
    - - - - -
    1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00
    Store interfaces in ModIfaceCache more directly
    
    I realised hydration was completely irrelavant for this cache because
    the ModDetails are pruned from the result. So now it simplifies things a
    lot to just store the ModIface and Linkable, which we can put into the
    cache straight away rather than wait for the final version of a
    HomeModInfo to appear.
    
    - - - - -
    6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00
    cmm: Remove unused ReadOnlyData16
    
    We don't actually emit rodata16 sections anywhere.
    
    - - - - -
    16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00
    findExternalRules: Don't needlessly traverse the list of rules.
    
    - - - - -
    52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00
    Remove backported items from 9.6 release notes
    
    They have been backported to 9.4 in commits 5423d84bd9a28f,
    13c81cb6be95c5, 67ccbd6b2d4b9b.
    
    - - - - -
    78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00
    ci: Fix pages job
    
    The job has been failing because we don't bundle haddock docs anymore in
    the docs dist created by hadrian.
    
    Fixes #21789
    
    - - - - -
    037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00
    codeGen/X86: Don't clobber switch variable in switch generation
    
    Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was
    safe to clobber the switch variable when generating code for a jump
    table since we were at the end of a block. However, this assumption is
    wrong; the register could be live in the jump target.
    
    Fixes #21968.
    
    - - - - -
    50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00
    Fix equality operator in jspace test
    
    - - - - -
    e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    Improve BUILD_PAP comments
    
    - - - - -
    41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    Make dropTail comment a haddock comment
    
    - - - - -
    ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    Add one more sanity check in stg_restore_cccs
    
    - - - - -
    1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    StgToCmm: Fix isSimpleScrut when profiling is enabled.
    
    When profiling is enabled we must enter functions that might represent
    thunks in order for their sccs to show up in the profile.
    
    We might allocate even if the function is already evaluated in this
    case. So we can't consider any potential function thunk to be a simple
    scrut when profiling.
    
    Not doing so caused profiled binaries to segfault.
    
    - - - - -
    fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    Change `-fprof-late` to insert cost centres after unfolding creation.
    
    The former behaviour of adding cost centres after optimization but
    before unfoldings are created is not available via the flag
    `prof-late-inline` instead.
    
    I also reduced the overhead of -fprof-late* by pushing the cost centres
    into lambdas. This means the cost centres will only account for
    execution of functions and not their partial application.
    
    Further I made LATE_CC cost centres it's own CC flavour so they now
    won't clash with user defined ones if a user uses the same string for
    a custom scc.
    
    LateCC: Don't put cost centres inside constructor workers.
    
    With -fprof-late they are rarely useful as the worker is usually
    inlined. Even if the worker is not inlined or we use -fprof-late-linline
    they are generally not helpful but bloat compile and run time
    significantly. So we just don't add sccs inside constructor workers.
    
    -------------------------
    Metric Decrease:
        T13701
    -------------------------
    
    - - - - -
    f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00
    gitlab-ci: Fix hadrian bootstrapping of release pipelines
    
    Previously we would attempt to test hadrian bootstrapping in the
    `validate` build flavour. However, `ci.sh` refuses to run validation
    builds during release pipelines, resulting in job failures. Fix this by
    testing bootstrapping in the `release` flavour during release pipelines.
    
    We also attempted to record perf notes for these builds, which is
    redundant work and undesirable now since we no longer build in a
    consistent flavour.
    
    - - - - -
    c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00
    compiler: Eliminate two uses of foldr in favor of foldl'
    
    These two uses constructed maps, which is a case where foldl' is
    generally more efficient since we avoid constructing an intermediate
    O(n)-depth stack.
    
    - - - - -
    d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00
    rts: Fix code style
    
    - - - - -
    57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00
    genprimopcode: Drop ArrayArray# references
    
    As ArrayArray# no longer exists
    
    - - - - -
    7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00
    base: Organize Haddocks in GHC.Conc.Sync
    
    - - - - -
    aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00
    Add primop to list threads
    
    A user came to #ghc yesterday wondering how best to check whether they
    were leaking threads. We ended up using the eventlog but it seems to me
    like it would be generally useful if Haskell programs could query their
    own threads.
    
    - - - - -
    6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00
    rts: Move thread labels into TSO
    
    This eliminates the thread label HashTable and instead tracks this
    information in the TSO, allowing us to use proper StgArrBytes arrays for
    backing the label and greatly simplifying management of object lifetimes
    when we expose them to the user with the coming `threadLabel#` primop.
    
    - - - - -
    1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00
    Add a primop to query the label of a thread
    
    - - - - -
    43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00
    base: Share finalization thread label
    
    For efficiency's sake we float the thread label assigned to the
    finalization thread to the top-level, ensuring that we only need to
    encode the label once.
    
    - - - - -
    1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00
    users-guide: Add release notes entry for thread introspection support
    
    - - - - -
    09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00
    hadrian: Fix binary distribution install attributes
    
    Previously we would use plain `cp` to install various parts of the
    binary distribution. However, `cp`'s behavior w.r.t. file attributes is
    quite unclear; for this reason it is much better to rather use
    `install`.
    
    Fixes #21965.
    
    - - - - -
    2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00
    hadrian: Fix installation of system-cxx-std-lib package conf
    
    - - - - -
    7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00
    gitlab-ci: Bump Docker images
    
    To give the ARMv7 job access to lld, fixing #21875.
    
    - - - - -
    afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00
    hadrian: Don't use mk/config.mk.in
    
    Ultimately we want to drop mk/config.mk so here I extract the bits
    needed by the Hadrian bindist installation logic into a Hadrian-specific
    file. While doing this I fixed binary distribution installation, #21901.
    
    - - - - -
    b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00
    hadrian: Fix naming of cross-compiler wrappers
    
    - - - - -
    78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00
    hadrian: Extend xattr Darwin hack to cover /lib
    
    As noted in #21506, it is now necessary to remove extended attributes
    from `/lib` as well as `/bin` to avoid SIP issues on Darwin.
    
    Fixes #21506.
    
    - - - - -
    20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00
    NCG(x86): Compile add+shift as lea if possible.
    
    - - - - -
    742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00
    dataToTag#: Skip runtime tag check if argument is infered tagged
    
    This addresses one part of #21710.
    
    - - - - -
    1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00
    rts: remove redundant stg_traceCcszh
    
    This out-of-line primop has no Haskell wrapper and hasn't been used
    anywhere in the tree. Furthermore, the code gets in the way of !7632, so
    it should be garbage collected.
    
    - - - - -
    a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00
    Document a divergence from the report in parsing function lhss.
    
    GHC is happy to parse `(f) x y = x + y` when it should be a parse error
    based on the Haskell report. Seems harmless enough so we won't fix it
    but it's documented now.
    
    Fixes #19788
    
    - - - - -
    5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00
    gitlab-ci: Add release job for aarch64/debian 11
    
    - - - - -
    5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00
    gitlab-ci: Introduce validation job for aarch64 cross-compilation
    
    Begins to address #11958.
    
    - - - - -
    e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00
    Bump process submodule
    
    - - - - -
    ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00
    gitlab-ci: Add basic support for cross-compiler testiing
    
    Here we add a simple qemu-based test for cross-compilers.
    
    - - - - -
    50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00
    rts: Ensure that Array# card arrays are initialized
    
    In #19143 I noticed that newArray# failed to initialize the card table
    of newly-allocated arrays. However, embarrassingly, I then only fixed
    the issue in newArrayArray# and, in so doing, introduced the potential
    for an integer underflow on zero-length arrays (#21962).
    
    Here I fix the issue in newArray#, this time ensuring that we do not
    underflow in pathological cases.
    
    Fixes #19143.
    
    - - - - -
    e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00
    testsuite: Add test for #21962
    
    - - - - -
    c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00
    gitlab-ci: Don't use coreutils on Darwin
    
    In general we want to ensure that the tested environment is as similar
    as possible to the environment the user will use. In the case of Darwin,
    this means we want to use the system's BSD command-line utilities, not
    coreutils.
    
    This would have caught #21974.
    
    - - - - -
    1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00
    hadrian: Fix bindist installation on Darwin
    
    It turns out that `cp -P` on Darwin does not always copy a symlink as
    a symlink. In order to get these semantics one must pass `-RP`. It's not
    entirely clear whether this is valid under POSIX, but it is nevertheless
    what Apple does.
    
    - - - - -
    681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00
    hadrian: Fix access mode of installed package registration files
    
    Previously hadrian's bindist Makefile would modify package
    registrations placed by `install` via a shell pipeline and `mv`.
    However, the use of `mv` means that if umask is set then the user may
    otherwise end up with package registrations which are inaccessible.
    Fix this by ensuring that the mode is 0644.
    
    - - - - -
    e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00
    Cleanups around pretty-printing
    
    * Remove hack when printing OccNames. No longer needed since e3dcc0d5
    * Remove unused `pprCmms` and `instance Outputable Instr`
    * Simplify `pprCLabel` (no need to pass platform)
    * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by
      ImmLit, but that can take just a String instead.
    * Remove instance `Outputable CLabel` - proper output of labels
      needs a platform, and is done by the `OutputableP` instance
    
    - - - - -
    66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00
    rts/linker: Resolve iconv_* on FreeBSD
    
    FreeBSD's libiconv includes an implementation of the
    iconv_* functions in libc. Unfortunately these can
    only be resolved using dlvsym, which is how the RTS linker
    usually resolves such functions. To fix this we include an ad-hoc
    special case for iconv_*.
    
    Fixes #20354.
    
    - - - - -
    5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00
    system-cxx-std-lib: Add support for FreeBSD libcxxrt
    
    - - - - -
    ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00
    gitlab-ci: Bump to use freebsd13 runners
    
    - - - - -
    d71a2051 by sheaf at 2022-08-09T13:47:28-04:00
    Fix size_up_alloc to account for UnliftedDatatypes
    
    The size_up_alloc function mistakenly considered any type that isn't
    lifted to not allocate anything, which is wrong. What we want instead
    is to check the type isn't boxed. This accounts for (BoxedRep Unlifted).
    
    Fixes #21939
    
    - - - - -
    76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00
    testsuite: 21651 add test for closeFdWith + setNumCapabilities
    
    This bug does not affect windows, which does not use the
    base module GHC.Event.Thread.
    
    - - - - -
    7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00
    base: Fix races in IOManager (setNumCapabilities,closeFdWith)
    
    Fix for #21651
    
    Fixes three bugs:
    
    - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith.
    - The race in closeFdWith described in the ticket.
    - A race in getSystemEventManager where it accesses the 'IOArray' in
      'eventManager' before 'ioManagerCapabilitiesChanged' has written to
      'eventManager', causing an Array Index exception. The fix here is to
      'yield' and retry.
    
    - - - - -
    dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00
    Updates language extension documentation
    
    Adding a 'Status' field with a few values:
    - Deprecated
    - Experimental
    - InternalUseOnly
    - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98'
    
    Those values are pulled from the existing descriptions or elsewhere in
    the documentation.
    
    While at it, include the :implied by: where appropriate, to provide
    more detail.
    
    Fixes #21475
    
    - - - - -
    823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00
    hadrian RunRest: add type signature for stageNumber
    
    avoids warning seen on 9.4.1:
    
    src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults]
        • Defaulting the following constraints to type ‘Integer’
            (Show a0)
              arising from a use of ‘show’
              at src/Settings/Builders/RunTest.hs:264:53-84
            (Num a0)
              arising from a use of ‘stageNumber’
              at src/Settings/Builders/RunTest.hs:264:59-83
        • In the second argument of ‘(++)’, namely
            ‘show (stageNumber (C.stage ctx))’
          In the second argument of ‘($)’, namely
            ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’
          In the expression:
            arg $ "config.stage=" ++ show (stageNumber (C.stage ctx))
        |
    264 |             , arg "-e", arg $ "config.stage="    ++ show (stageNumber (C.stage ctx))
        |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    compilation tested locally
    
    - - - - -
    f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00
    Add support for external static plugins (#20964)
    
    This patch adds a new command-line flag:
    
      -fplugin-library=<file-path>;<unit-id>;<module>;<args>
    
    used like this:
    
      -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"]
    
    It allows a plugin to be loaded directly from a shared library. With
    this approach, GHC doesn't compile anything for the plugin and doesn't
    load any .hi file for the plugin and its dependencies. As such GHC
    doesn't need to support two environments (one for plugins, one for
    target code), which was the more ambitious approach tracked in #14335.
    
    Fix #20964
    
    Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com>
    
    - - - - -
    5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00
    gitlab-ci: Fix ARMv7 build
    
    It appears that the CI refactoring carried out in
    5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some
    critical configuration: setting the build/host/target platforms and
    forcing use of a non-broken linker.
    
    - - - - -
    596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00
    gitlab-ci: Run ARMv7 jobs when ~ARM label is used
    
    - - - - -
    7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00
    hadrian: Don't attempt to install documentation if doc/ doesn't exist
    
    Previously we would attempt to install documentation even if the `doc`
    directory doesn't exist (e.g. due to `--docs=none`). This would result
    in the surprising side-effect of the entire contents of the bindist
    being installed in the destination documentation directory. Fix this.
    
    Fixes #21976.
    
    - - - - -
    67575f20 by normalcoder at 2022-08-10T15:38:34-04:00
    ncg/aarch64: Don't use x18 register on AArch64/Darwin
    
    Apple's ABI documentation [1] says: "The platforms reserve register x18.
    Don’t use this register." While this wasn't problematic in previous
    Darwin releases, macOS 13 appears to start zeroing this register
    periodically. See #21964.
    
    [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
    
    - - - - -
    45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00
    Note [Trimming auto-rules]: State that this improves compiler perf.
    
    - - - - -
    5c24b1b3 by Andrew Lelechenko at 2022-08-10T22:41:50-04:00
    Document that threadDelay / timeout are susceptible to overflows on 32-bit machines
    
    - - - - -
    ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00
    EPA: DotFieldOcc does not have exact print annotations
    
    For the code
    
        {-# LANGUAGE OverloadedRecordUpdate #-}
    
        operatorUpdate f = f{(+) = 1}
    
    There are no exact print annotations for the parens around the +
    symbol, nor does normal ppr print them.
    
    This MR fixes that.
    
    Closes #21805
    
    Updates haddock submodule
    
    - - - - -
    dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00
    Revert "gitlab-ci: Add release job for aarch64/debian 11"
    
    This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46.
    
    The job was not tested before being merged and fails CI
    (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392)
    
    Ticket #22005
    
    - - - - -
    ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00
    typo
    - - - - -
    cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00
    CmmToLlvm: Don't aliasify builtin LLVM variables
    
    Our aliasification logic would previously turn builtin LLVM variables
    into aliases, which apparently confuses LLVM. This manifested in
    initializers failing to be emitted, resulting in many profiling failures
    with the LLVM backend.
    
    Fixes #22019.
    
    - - - - -
    dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00
    run_ci: remove monoidal-containers
    
    Fixes #21492
    
    MonoidalMap is inlined and used to implement Variables, as before.
    
    The top-level value "jobs" is reimplemented as a regular Map, since it
    doesn't use the monoidal union anyway.
    
    - - - - -
    64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00
    CmmToAsm/AArch64: correct a typo
    
    - - - - -
    f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00
    Fix #21979 - compact-share failing with -O
    
    I don't have good reason to believe the optimization level should affect
    if sharing works or not here. So limit the test to the normal way.
    
    - - - - -
    68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00
    users-guide: Fix reference to dead llvm-version substitution
    
    Fixes #22052.
    
    - - - - -
    28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00
    users-guide: Fix incorrect reference to `:extension: role
    
    - - - - -
    71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00
    users-guide: Add :ghc-flag: reference
    
    - - - - -
    385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00
    hadrian: Place manpage in docroot
    
    This relocates it from docs/ to doc/
    
    - - - - -
    84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00
    Bump haddock submodule
    
    Includes merge of `main` into `ghc-head` as well as some Haddock users
    guide fixes.
    
    - - - - -
    59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00
    base: Add changelog entries from ghc-9.2
    
    Closes #21922.
    
    - - - - -
    a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00
    relnotes: Add "included libraries" section
    
    As noted in #21988, some users rely on this.
    
    - - - - -
    a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00
    users-guide: Rephrase the rewrite rule documentation
    
    Previously the wording was a tad unclear. Fix this.
    
    Closes #21114.
    
    - - - - -
    3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00
    Implement Response File support for HPC
    
    This is an improvement to HPC authored by Richard Wallace
    (https://github.com/purefn) and myself. I have received permission from
    him to attempt to upstream it. This improvement was originally
    implemented as a patch to HPC via input-output-hk/haskell.nix:
    https://github.com/input-output-hk/haskell.nix/pull/1464
    
    Paraphrasing Richard, HPC currently requires all inputs as command line arguments.
    With large projects this can result in an argument list too long error.
    I have only seen this error in Nix, but I assume it can occur is a plain Unix environment.
    
    This MR adds the standard response file syntax support to HPC. For
    example you can now pass a file to the command line which contains the
    arguments.
    
    ```
    hpc @response_file_1 @response_file_2 ...
    
    The contents of a Response File must have this format:
    COMMAND ...
    
    example:
    report my_library.tix --include=ModuleA --include=ModuleB
    ```
    
    Updates hpc submodule
    
    Co-authored-by:  Richard Wallace <rwallace at thewallacepack.net>
    
    Fixes #22050
    
    - - - - -
    436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00
    ghc-heap: Fix decoding of TSO closures
    
    An extra field was added to the TSO structure in 6d1700b6 but the
    decoding logic in ghc-heap was not updated for this new field.
    
    Fixes #22046
    
    - - - - -
    a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00
    driver: Honour -x option
    
    The -x option is used to manually specify which phase a file should be
    started to be compiled from (even if it lacks the correct extension). I
    just failed to implement this when refactoring the driver.
    
    In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to
    preprocess source files using GHC.
    
    I added a test to exercise this case.
    
    Fixes #22044
    
    - - - - -
    e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00
    Be more careful in chooseInferredQuantifiers
    
    This fixes #22065. We were failing to retain a quantifier that
    was mentioned in the kind of another retained quantifier.
    
    Easy to fix.
    
    - - - - -
    714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00
    testsuite: Add test for #21583
    
    - - - - -
    989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00
    compiler: Drop --build-id=none hack
    
    Since 2011 the object-joining implementation has had a hack to pass
    `--build-id=none` to `ld` when supported, seemingly to work around a
    linker bug. This hack is now unnecessary and may break downstream users
    who expect objects to have valid build-ids. Remove it.
    
    Closes #22060.
    
    - - - - -
    519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00
    Make ru_fn field strict to avoid retaining Ids
    
    It's better to perform this projection from Id to Name strictly so we
    don't retain an old Id (hence IdInfo, hence Unfolding, hence everything
    etc)
    
    - - - - -
    7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00
    Force `getOccFS bndr` to avoid retaining reference to Bndr.
    
    This is another symptom of #19619
    
    - - - - -
    4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00
    Force unfoldings when they are cleaned-up in Tidy and CorePrep
    
    If these thunks are not forced then the entire unfolding for the binding
    is live throughout the whole of CodeGen despite the fact it should have
    been discarded.
    
    Fixes #22071
    
    - - - - -
    2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00
    haddock docs: Fix links from identifiers to dependent packages
    
    When implementing the base_url changes I made the pretty bad mistake of
    zipping together two lists which were in different orders. The simpler
    thing to do is just modify `haddockDependencies` to also return the
    package identifier so that everything stays in sync.
    
    Fixes #22001
    
    - - - - -
    9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00
    Revert "Refactor SpecConstr to use treat bindings uniformly"
    
    This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729.
    
    This refactoring introduced quite a severe residency regression (900MB
    live from 650MB live when compiling mmark), see #21993 for a reproducer
    and more discussion.
    
    Ticket #21993
    
    - - - - -
    9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00
    tc: warn about lazy annotations on unlifted arguments (fixes #21951)
    
    - - - - -
    e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00
    Fix #22048 where we failed to drop rules for -fomit-interface-pragmas.
    
    Now we also filter the local rules (again) which fixes the issue.
    
    - - - - -
    51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00
    Print constraints in quotes (#21167)
    
    This patch improves the uniformity of error message formatting by
    printing constraints in quotes, as we do for types.
    
    Fix #21167
    
    - - - - -
    ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00
    19217 Implicitly quantify type variables in :kind command
    
    - - - - -
    9939e95f by MorrowM at 2022-08-21T16:51:38-04:00
    Recognize file-header pragmas in GHCi (#21507)
    
    - - - - -
    fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00
    hadrian: Fix bootstrapping with ghc-9.4
    
    The error was that we were trying to link together
    
        containers from boot package library (which depends template-haskell in boot package library)
        template-haskell from in-tree package database
    
    So the fix is to build containers in stage0 (and link against template-haskell built in stage0).
    
    Fixes #21981
    
    - - - - -
    b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00
    Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942.
    
    * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization
    * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence
    * `ParensT` constructor is now always printed parenthesized
    * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down
    * using `>=` instead of former `>` to match the Core type printing logic
    * some test outputs have changed, losing extraneous parentheses
    
    - - - - -
    fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00
    Fix and test for issue #21723
    
    - - - - -
    33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00
    Test for issue #21942
    
    - - - - -
    c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00
    Updated the changelog
    
    - - - - -
    80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00
    hadrian: Don't duplicate binaries on installation
    
    Previously we used `install` on symbolic links, which ended up
    copying the target file rather than installing a symbolic link.
    
    Fixes #22062.
    
    - - - - -
    b929063e by Matthew Farkas-Dyck at 2022-08-24T02:37:01-04:00
    Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`.
    
    Closes #22092.
    
    - - - - -
    112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00
    driver: don't actually merge objects when ar -L works
    
    - - - - -
    a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00
    rts: Consistently use MiB in stats output
    
    Previously we would say `MB` even where we
    meant `MiB`.
    - - - - -
    a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00
    Fix arityType: -fpedantic-bottoms, join points, etc
    
    This MR fixes #21694, #21755.  It also makes sure that #21948 and
    fix to #21694.
    
    * For #21694 the underlying problem was that we were calling arityType
      on an expression that had free join points.  This is a Bad Bad Idea.
      See Note [No free join points in arityType].
    
    * To make "no free join points in arityType" work out I had to avoid
      trying to use eta-expansion for runRW#. This entailed a few changes
      in the Simplifier's treatment of runRW#.  See
      GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#]
    
    * I also made andArityType work correctly with -fpedantic-bottoms;
      see Note [Combining case branches: andWithTail].
    
    * Rewrote Note [Combining case branches: optimistic one-shot-ness]
    
    * arityType previously treated join points differently to other
      let-bindings. This patch makes them unform; arityType analyses
      the RHS of all bindings to get its ArityType, and extends am_sigs.
    
      I realised that, now we have am_sigs giving the ArityType for
      let-bound Ids, we don't need the (pre-dating) special code in
      arityType for join points. But instead we need to extend the env for
      Rec bindings, which weren't doing before.  More uniform now.  See
      Note [arityType for let-bindings].
    
      This meant we could get rid of ae_joins, and in fact get rid of
      EtaExpandArity altogether.  Simpler.
    
    * And finally, it was the strange treatment of join-point Ids in
      arityType (involving a fake ABot type) that led to a serious bug:
      #21755.  Fixed by this refactoring, which treats them uniformly;
      but without breaking #18328.
    
      In fact, the arity for recursive join bindings is pretty tricky;
      see the long Note [Arity for recursive join bindings]
      in GHC.Core.Opt.Simplify.Utils.  That led to more refactoring,
      including deciding that an Id could have an Arity that is bigger
      than its JoinArity; see Note [Invariants on join points], item
      2(b) in GHC.Core
    
    * Make sure that the "demand threshold" for join points in DmdAnal
      is no bigger than the join-arity.  In GHC.Core.Opt.DmdAnal see
      Note [Demand signatures are computed for a threshold arity based on idArity]
    
    * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity,
      where it more properly belongs.
    
    * Remove an old, redundant hack in FloatOut.  The old Note was
      Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels.
    
    Compile time improves very slightly on average:
    
    Metrics: compile_time/bytes allocated
    ---------------------------------------------------------------------------------------
      T18223(normal) ghc/alloc    725,808,720    747,839,216  +3.0%  BAD
      T6048(optasm)  ghc/alloc    105,006,104    101,599,472  -3.2% GOOD
      geo. mean                                          -0.2%
      minimum                                            -3.2%
      maximum                                            +3.0%
    
    For some reason Windows was better
    
       T10421(normal) ghc/alloc    125,888,360    124,129,168  -1.4% GOOD
       T18140(normal) ghc/alloc     85,974,520     83,884,224  -2.4% GOOD
      T18698b(normal) ghc/alloc    236,764,568    234,077,288  -1.1% GOOD
       T18923(normal) ghc/alloc     75,660,528     73,994,512  -2.2% GOOD
        T6048(optasm) ghc/alloc    112,232,512    108,182,520  -3.6% GOOD
      geo. mean                                          -0.6%
    
    I had a quick look at T18223 but it is knee deep in coercions and
    the size of everything looks similar before and after.  I decided
    to accept that 3% increase in exchange for goodness elsewhere.
    
    Metric Decrease:
        T10421
        T18140
        T18698b
        T18923
        T6048
    
    Metric Increase:
        T18223
    
    - - - - -
    909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00
    upload_ghc_libs: Add means of passing Hackage credentials
    
    - - - - -
    28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00
    Scrub some partiality in `CommonBlockElim`.
    
    - - - - -
    54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00
    hadrian: Fix whitespace
    
    Previously this region of Settings.Packages was incorrectly indented.
    
    - - - - -
    c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00
    validate: Drop --legacy flag
    
    In preparation for removal of the legacy `make`-based build system.
    
    - - - - -
    822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00
    gitlab-ci: Drop make build validation jobs
    
    In preparation for removal of the `make`-based build system
    
    - - - - -
    6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00
    Drop make build system
    
    Here we at long last remove the `make`-based build system, it having
    been replaced with the Shake-based Hadrian build system. Users are
    encouraged to refer to the documentation in `hadrian/doc` and this [1]
    blog post for details on using Hadrian.
    
    Closes #17527.
    
    [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html
    
    - - - - -
    dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00
    Remove testsuite/tests/perf/haddock/.gitignore
    
    As noted in #16802, this is no longer needed.
    
    Closes #16802.
    
    - - - - -
    fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00
    Drop hc-build script
    
    This has not worked for many, many years and relied on the now-removed
    `make`-based build system.
    
    - - - - -
    659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00
    Drop mkdirhier
    
    This is only used by nofib's dead `dist` target
    
    - - - - -
    4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00
    Drop mk/{build,install,config}.mk.in
    
    - - - - -
    46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00
    compiler: Drop comment references to make
    
    - - - - -
    d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00
    Add inits1 and tails1 to Data.List.NonEmpty
    
    See https://github.com/haskell/core-libraries-committee/issues/67
    
    - - - - -
    8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00
    Add since annotations and changelog entries
    
    - - - - -
    6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00
    Fix redundant import
    
    This fixes a build error on x86_64-linux-alpine3_12-validate.
    See the function 'loadExternalPlugins' defined in this file.
    
    - - - - -
    4786acf7 by sheaf at 2022-08-26T15:05:23-04:00
    Pmc: consider any 2 dicts of the same type equal
    
    This patch massages the keys used in the `TmOracle` `CoreMap` to ensure
    that dictionaries of coherent classes give the same key.
    That is, whenever we have an expression we want to insert or lookup in
    the `TmOracle` `CoreMap`, we first replace any dictionary
    `$dict_abcd :: ct` with a value of the form `error @ct`.
    
    This allows us to common-up view pattern functions with required
    constraints whose arguments differed only in the uniques of the
    dictionaries they were provided, thus fixing #21662.
    
    This is a rather ad-hoc change to the keys used in the
    `TmOracle` `CoreMap`. In the long run, we would probably want to use
    a different representation for the keys instead of simply using
    `CoreExpr` as-is. This more ambitious plan is outlined in #19272.
    
    Fixes #21662
    Updates unix submodule
    
    - - - - -
    f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00
    Remove label style from printing context
    
    Previously, the SDocContext used for code generation contained
    information whether the labels should use Asm or C style.
    However, at every individual call site, this is known statically.
    This removes the parameter to 'PprCode' and replaces every 'pdoc'
    used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'.
    The OutputableP instance is now used only for dumps.
    
    The output of T15155 changes, it now uses the Asm style
    (which is faithful to what actually happens).
    
    - - - - -
    1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00
    boot: cleanup legacy args
    
    Cleanup legacy boot script args, following removal of the legacy make
    build system.
    
    - - - - -
    95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00
    Improve SpecConstr for evals
    
    As #21763 showed, we were over-specialising in some cases, when
    the function involved was doing a simple 'eval', but not taking
    the value apart, or branching on it.
    
    This MR fixes the problem.  See Note [Do not specialise evals].
    
    Nofib barely budges, except that spectral/cichelli allocates about
    3% less.
    
    Compiler bytes-allocated improves a bit
       geo. mean                                          -0.1%
       minimum                                            -0.5%
       maximum                                            +0.0%
    
    The -0.5% is on T11303b, for what it's worth.
    
    - - - - -
    565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00
    Revert "Revert "Refactor SpecConstr to use treat bindings uniformly""
    
    This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8.
    
    This commit was originally reverted due to an increase in space usage.
    This was diagnosed as because the SCE increased in size and that was
    being retained by another leak. See #22102
    
    - - - - -
    82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00
    Avoid retaining bindings via ModGuts held on the stack
    
    It's better to overwrite the bindings fields of the ModGuts before
    starting an iteration as then all the old bindings can be collected as
    soon as the simplifier has processed them. Otherwise we end up with the
    old bindings being alive until right at the end of the simplifier pass
    as the mg_binds field is only modified right at the end.
    
    - - - - -
    64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00
    Force imposs_deflt_cons in filterAlts
    
    This fixes a pretty serious space leak as the forced thunk would retain
    `Alt b` values which would then contain reference to a lot of old
    bindings and other simplifier gunk.
    
    The OtherCon unfolding was not forced on subsequent simplifier runs so
    more and more old stuff would be retained until the end of
    simplification.
    
    Fixing this has a drastic effect on maximum residency for the mmark
    package which goes from
    
    ```
      45,005,401,056 bytes allocated in the heap
      17,227,721,856 bytes copied during GC
         818,281,720 bytes maximum residency (33 sample(s))
           9,659,144 bytes maximum slop
                2245 MiB total memory in use (0 MB lost due to fragmentation)
    ```
    
    to
    
    ```
      45,039,453,304 bytes allocated in the heap
      13,128,181,400 bytes copied during GC
         331,546,608 bytes maximum residency (40 sample(s))
           7,471,120 bytes maximum slop
                 916 MiB total memory in use (0 MB lost due to fragmentation)
    ```
    
    See #21993 for some more discussion.
    
    - - - - -
    a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00
    Use Solo to avoid retaining the SCE but to avoid performing the substitution
    
    The use of Solo here allows us to force the selection into the SCE to obtain
    the Subst but without forcing the substitution to be applied. The resulting thunk
    is placed into a lazy field which is rarely forced, so forcing it regresses
    peformance.
    
    - - - - -
    161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00
    Fix a nasty loop in Tidy
    
    As the remarkably-simple #22112 showed, we were making a black hole
    in the unfolding of a self-recursive binding.  Boo!
    
    It's a bit tricky.  Documented in GHC.Iface.Tidy,
       Note [tidyTopUnfolding: avoiding black holes]
    
    - - - - -
    68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00
    Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117)
    
    The following `TcRnDiagnostic` messages have been introduced:
    
    TcRnIllegalHsigDefaultMethods
    TcRnBadGenericMethod
    TcRnWarningMinimalDefIncomplete
    TcRnDefaultMethodForPragmaLacksBinding
    TcRnIgnoreSpecialisePragmaOnDefMethod
    TcRnBadMethodErr
    TcRnNoExplicitAssocTypeOrDefaultDeclaration
    
    - - - - -
    cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00
    Fix a bug in anyInRnEnvR
    
    This bug was a subtle error in anyInRnEnvR, introduced by
    
        commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06
        Author: Andreas Klebinger <klebinger.andreas at gmx.at>
        Date:   Sat Jul 9 01:19:52 2022 +0200
    
        Rule matching: Don't compute the FVs if we don't look at them.
    
    The net result was #22028, where a rewrite rule would wrongly
    match on a lambda.
    
    The fix to that function is easy.
    
    - - - - -
    0154bc80 by sheaf at 2022-08-30T06:05:41-04:00
    Various Hadrian bootstrapping fixes
    
      - Don't always produce a distribution archive (#21629)
      - Use correct executable names for ghc-pkg and hsc2hs on windows
        (we were missing the .exe file extension)
      - Fix a bug where we weren't using the right archive format on Windows
        when unpacking the bootstrap sources.
    
    Fixes #21629
    
    - - - - -
    451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00
    ci: Attempt using normal submodule cloning strategy
    
    We do not use any recursively cloned submodules, and this protects us
    from flaky upstream remotes.
    
    Fixes #22121
    
    - - - - -
    9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00
    Fix typo in Any docs: stray "--"
    
    - - - - -
    3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00
    Fix typo in Any docs: syntatic -> syntactic
    
    - - - - -
    7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00
    Add a missing trimArityType
    
    This buglet was exposed by #22114, a consequence of my earlier
    refactoring of arity for join points.
    
    - - - - -
    e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00
    Bump binary submodule to 0.8.9.1
    
    - - - - -
    4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00
    Bump stm submodule to 2.5.1.0
    
    - - - - -
    837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00
    users-guide: Document system-cxx-std-lib
    
    - - - - -
    f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00
    Update submodule containers to 0.6.6
    
    - - - - -
    4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00
    Update submodule process to 1.6.15.0
    
    - - - - -
    1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00
    Bump directory submodule to 1.3.7.1
    
    - - - - -
    7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00
    Bump text submodule to 2.0.1
    
    - - - - -
    fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00
    Bump deepseq submodule to 1.4.8.0
    
    - - - - -
    a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00
    Add dates to base, ghc-prim changelogs
    
    - - - - -
    2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00
    Update autoconf scripts
    
    Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983
    
    - - - - -
    e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00
    Bump bytestring submodule to 0.11.3.1
    
    - - - - -
    f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00
    Update submodule Cabal to tag Cabal-v3.8.1.0
    
    closes #21931
    
    - - - - -
    e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00
    Refine in-tree compiler args for --test-compiler=stage1
    
    Some of the logic to calculate in-tree arguments was not correct for the
    stage1 compiler. Namely we were not correctly reporting whether we were
    building static or dynamic executables and whether debug assertions were
    enabled.
    
    Fixes #22096
    
    - - - - -
    6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00
    Make ghcDebugAssertions into a Stage predicate (Stage -> Bool)
    
    We also care whether we have debug assertions enabled for a stage one
    compiler, but the way which we turned on the assertions was quite
    different from the stage2 compiler. This makes the logic for turning on
    consistent across both and has the advantage of being able to correct
    determine in in-tree args whether a flavour enables assertions or not.
    
    Ticket #22096
    
    - - - - -
    15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00
    Add regression test for #21550
    
    This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5
    "Use local instances with least superclass depth"
    
    - - - - -
    7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00
    Minor cleanup
    
    - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused),
      isCoVar_maybe (duplicated by getCoVar_maybe)
    - Replace a few occurrences of voidPrimId with (# #).
      void# is a deprecated synonym for the unboxed tuple.
    - Use showSDoc in :show linker.
      This makes it consistent with the other :show commands
    
    - - - - -
    31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00
    Change Ord defaults per CLC proposal
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267
    
    - - - - -
    7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00
    Fix bootstrap with ghc-9.0
    
    It turns out Solo is a very recent addition to base, so for older GHC
    versions we just defined it inline here the one place we use it in the
    compiler.
    
    - - - - -
    d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00
    DmdAnal: Don't panic in addCaseBndrDmd (#22039)
    
    Rather conservatively return Top.
    See Note [Untyped demand on case-alternative binders].
    
    I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and
    `fieldBndrDmds`.
    
    Fixes #22039.
    
    - - - - -
    25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00
    gitlab-ci: Ensure that ghc derivation is in scope
    
    Previously the lint-ci job attempted to use cabal-install (specifically
    `cabal update`) without a GHC in PATH. However, cabal-install-3.8
    appears to want GHC, even for `cabal update`.
    
    - - - - -
    f37b621f by sheaf at 2022-09-06T11:51:53+00:00
    Update instances.rst, clarifying InstanceSigs
    
    Fixes #22103
    
    - - - - -
    d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00
    Fix :add docs in user guide
    
    - - - - -
    808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00
    ci: remove unused build_make/test_make in ci script
    
    - - - - -
    d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00
    typo
    - - - - -
    fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00
    typos
    
    - - - - -
    a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00
    whitespace
    
    - - - - -
    04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00
    CmmToAsm: remove unused ModLocation from NatM_State
    
    - - - - -
    ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00
    Minor SDoc cleanup
    
    Change calls to renderWithContext with showSDocOneLine; it's more
    efficient and explanatory.
    
    Remove polyPatSig (unused)
    
    - - - - -
    7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00
    Remove Outputable Char instance
    
    Use 'text' instead of 'ppr'.
    Using 'ppr' on the list "hello" rendered as "h,e,l,l,o".
    
    - - - - -
    77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Export liftA2 from Prelude
    
    Changes:
    In order to be warning free and compatible, we hide Applicative(..)
    from Prelude in a few places and instead import it directly from
    Control.Applicative.
    Please see the migration guide at
    https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md
    for more details.
    
    This means that Applicative is now exported in its entirety from
    Prelude.
    
    Motivation:
    
    This change is motivated by a few things:
    * liftA2 is an often used function, even more so than (<*>) for some
      people.
    * When implementing Applicative, the compiler will prompt you for either
      an implementation of (<*>) or of liftA2, but trying to use the latter
      ends with an error, without further imports. This could be confusing
      for newbies.
    * For teaching, it is often times easier to introduce liftA2 first,
      as it is a natural generalisation of fmap.
    * This change seems to have been unanimously and enthusiastically
      accepted by the CLC members, possibly indicating a lot of love for it.
    * This change causes very limited breakage, see the linked issue below
      for an investigation on this.
    
    See https://github.com/haskell/core-libraries-committee/issues/50
    for the surrounding discussion and more details.
    
    - - - - -
    442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Add changelog entry for liftA2 export from Prelude
    
    - - - - -
    fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Bump submodule containers to one with liftA2 warnings fixed
    
    - - - - -
    f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Bump submodule Cabal to one with liftA2 warnings fixed
    
    - - - - -
    a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Isolate some Applicative hidings to GHC.Prelude
    
    By reexporting the entirety of Applicative from GHC.Prelude, we can save
    ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude.
    This also has the benefit of isolating this type of change to
    GHC.Prelude, so that people in the future don't have to think about it.
    
    - - - - -
    9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00
    CmmToC: enable 64-bit CallishMachOp on 32-bit targets
    
    Normally, the unregisterised builds avoid generating 64-bit
    CallishMachOp in StgToCmm, so CmmToC doesn't support these. However,
    there do exist cases where we'd like to invoke cmmToC for other cmm
    inputs which may contain such CallishMachOps, and it's a rather low
    effort to add support for these since they only require calling into
    existing ghc-prim cbits.
    
    - - - - -
    04062510 by Alexis King at 2022-09-11T11:30:32+02:00
    Add native delimited continuations to the RTS
    
    This patch implements GHC proposal 313, "Delimited continuation
    primops", by adding native support for delimited continuations to the
    GHC RTS.
    
    All things considered, the patch is relatively small. It almost
    exclusively consists of changes to the RTS; the compiler itself is
    essentially unaffected. The primops come with fairly extensive Haddock
    documentation, and an overview of the implementation strategy is given
    in the Notes in rts/Continuation.c.
    
    This first stab at the implementation prioritizes simplicity over
    performance. Most notably, every continuation is always stored as a
    single, contiguous chunk of stack. If one of these chunks is
    particularly large, it can result in poor performance, as the current
    implementation does not attempt to cleverly squeeze a subset of the
    stack frames into the existing stack: it must fit all at once. If this
    proves to be a performance issue in practice, a cleverer strategy would
    be a worthwhile target for future improvements.
    
    - - - - -
    ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00
    rts: fix missing dirty_MVAR argument in stg_writeIOPortzh
    
    - - - - -
    a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00
    ci: enable parallel compression for xz
    
    - - - - -
    3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00
    Windows: Always define _UCRT when compiling C code
    
    As seen in #22159, this is required to ensure correct behavior when MinGW-w64
    headers are in the `C_INCLUDE_PATH`.
    
    Fixes #22159.
    
    - - - - -
    65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00
    Add diagnostic codes
    
    This MR adds diagnostic codes, assigning unique numeric codes to
    error and warnings, e.g.
    
      error: [GHC-53633]
      Pattern match is redundant
    
    This is achieved as follows:
    
      - a type family GhcDiagnosticCode that gives the diagnostic code
        for each diagnostic constructor,
      - a type family ConRecursInto that specifies whether to recur into
        an argument of the constructor to obtain a more fine-grained code
        (e.g. different error codes for different 'deriving' errors),
      - generics machinery to generate the value-level function assigning
        each diagnostic its error code; see Note [Diagnostic codes using generics]
        in GHC.Types.Error.Codes.
    
    The upshot is that, to add a new diagnostic code, contributors only need
    to modify the two type families mentioned above. All logic relating to
    diagnostic codes is thus contained to the GHC.Types.Error.Codes module,
    with no code duplication.
    
    This MR also refactors error message datatypes a bit, ensuring we can
    derive Generic for them, and cleans up the logic around constraint
    solver reports by splitting up 'TcSolverReportInfo' into separate
    datatypes (see #20772).
    
    Fixes #21684
    
    - - - - -
    362cca13 by sheaf at 2022-09-13T10:27:53-04:00
    Diagnostic codes: acccept test changes
    
    The testsuite output now contains diagnostic codes, so many tests need
    to be updated at once.
    We decided it was best to keep the diagnostic codes in the testsuite
    output, so that contributors don't inadvertently make changes to the
    diagnostic codes.
    
    - - - - -
    08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00
    Allow imports to reference multiple fields with the same name (#21625)
    
    If a module `M` exports two fields `f` (using DuplicateRecordFields), we can
    still accept
    
        import M (f)
        import M hiding (f)
    
    and treat `f` as referencing both of them.  This was accepted in GHC 9.0, but gave
    rise to an ambiguity error in GHC 9.2.  See #21625.
    
    This patch also documents this behaviour in the user's guide, and updates the
    test for #16745 which is now treated differently.
    
    - - - - -
    c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00
    ci: remove unused appveyor config
    
    - - - - -
    dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00
    compiler: remove unused lazy state monad
    
    - - - - -
    646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00
    Fix typos
    
    This fixes various typos and spelling mistakes
    in the compiler.
    
    Fixes #21891
    
    - - - - -
    7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00
    hadrian: Bump index state
    
    This bumps the index state so a build plan can also be found when
    booting with 9.4.
    
    Fixes #22165
    
    - - - - -
    98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Use a stamp file to record when a package is built in a certain way
    
    Before this patch which library ways we had built wasn't recorded
    directly. So you would run into issues if you build the .conf file with
    some library ways before switching the library ways which you wanted to
    build.
    
    Now there is one stamp file for each way, so in order to build a
    specific way you can need that specific stamp file rather than going
    indirectly via the .conf file.
    
    - - - - -
    b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Inplace/Final package databases
    
    There are now two different package databases per stage. An inplace
    package database contains .conf files which point directly into the
    build directories. The final package database contains .conf files which
    point into the installed locations. The inplace .conf files are created
    before any building happens and have fake ABI hash values. The final
    .conf files are created after a package finished building and contains
    the proper ABI has.
    
    The motivation for this is to make the dependency structure more
    fine-grained when building modules. Now a module depends just depends
    directly on M.o from package p rather than the .conf file depend on the
    .conf file for package p. So when all of a modules direct dependencies
    have finished building we can start building it rather than waiting for
    the whole package to finish.
    
    The secondary motivation is that the multi-repl doesn't need to build
    everything before starting the multi-repl session. We can just configure
    the inplace package-db and use that in order to start the repl.
    
    - - - - -
    6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Add some more packages to multi-cradle
    
    The main improvement here is to pass `-this-unit-id` for executables so
    that they can be added to the multi-cradle if desired as well as normal
    library packages.
    
    - - - - -
    e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Need builders needed by Cabal Configure in parallel
    
    Because of the use of withStaged (which needs the necessary builder)
    when configuring a package, the builds of stage1:exe:ghc-bin and
    stage1:exe:ghc-pkg where being linearised when building a specific
    target like `binary-dist-dir`.
    
    Thankfully the fix is quite local, to supply all the `withStaged`
    arguments together so the needs can be batched together and hence
    performed in parallel.
    
    Fixes #22093
    
    - - - - -
    c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00
    Remove stage1:exe:ghc-bin pre-build from CI script
    
    CI builds stage1:exe:ghc-bin before the binary-dist target which
    introduces some quite bad linearisation (see #22093) because we don't
    build stage1 compiler in parallel with anything. Then when the
    binary-dist target is started we have to build stage1:exe:ghc-pkg before
    doing anything.
    
    Fixes #22094
    
    - - - - -
    71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Add extra implicit dependencies from DeriveLift
    
    ghc -M should know that modules which use DeriveLift (or
    TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have
    to add these extra edges manually or the modules will be compiled before
    TH.Lib.Internal is compiled which leads to a desugarer error.
    
    - - - - -
    43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00
    Repair c++ probing on OpenBSD
    
    Failure without this change:
    ```
    checking C++ standard library flavour... libc++
    checking for linkage against 'c++ c++abi'... failed
    checking for linkage against 'c++ cxxrt'... failed
    configure: error: Failed to find C++ standard library
    ```
    
    - - - - -
    534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00
    libraries: template-haskell: vendor filepath differently
    
    Vendoring with ../ in hs-source-dirs prevents upload to hackage.
    
    (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842)
    
    - - - - -
    bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00
    Unbreak Hadrian with Cabal 3.8.
    
    - - - - -
    df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00
    Fix typos
    
    - - - - -
    d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00
    Tag inference: Fix #21954 by retaining tagsigs of vars in function position.
    
    For an expression like:
    
        case x of y
          Con z -> z
    
    If we also retain the tag sig for z we can generate code to immediately return
    it rather than calling out to stg_ap_0_fast.
    
    - - - - -
    7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00
    Stg.InferTags.Rewrite - Avoid some thunks.
    
    - - - - -
    88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00
    hadrian: enable -fprof-late only for profiling ways
    
    - - - - -
    d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00
    hadrian: add late_ccs flavour transformer
    
    - - - - -
    ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00
    configure: remove unused program checks
    
    - - - - -
    9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00
    Update to Unicode 15.0
    
    - - - - -
    c6e9b89a by Andrew Lelechenko at 2022-09-16T13:59:55-04:00
    Avoid partial head and tail in ghc-heap; replace with total pattern-matching
    
    - - - - -
    616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00
    hadrian: relax Cabal upper bound to allow building with Cabal-3.8
    
    A follow up of !8910.
    
    - - - - -
    df35d994 by Alexis King at 2022-09-16T14:01:11-04:00
    Add links to the continuations haddocks in the docs for each primop
    
    fixes #22176
    
    - - - - -
    383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00
    -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice
    
    See the examples in #22057 which show we have to traverse deeply into a
    pattern to determine whether it contains a splice or not. The original
    implementation pointed this out but deemed this very shallow traversal
    "too expensive".
    
    Fixes #22057
    
    I also fixed an oversight in !7821 which meant we lost a warning which
    was present in 9.2.2.
    
    Fixes #22067
    
    - - - - -
    5031bf49 by sheaf at 2022-09-16T21:42:49-04:00
    Hadrian: Don't try to build terminfo on Windows
    
    Commit b42cedbe introduced a dependency on terminfo on Windows,
    but that package isn't available on Windows.
    
    - - - - -
    c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00
    Clean up some. In particular:
    • Delete some dead code, largely under `GHC.Utils`.
    • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`.
    • Clean up `GHC.Types.SrcLoc`.
    • Derive stock `Functor, Foldable, Traversable` for more types.
    • Derive more instances for newtypes.
    
    Bump haddock submodule.
    
    - - - - -
    85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00
    driver: pass original Cmm filename in ModLocation
    
    When compiling Cmm, the ml_hs_file field is used to indicate Cmm
    filename when later generating DWARF information. We should pass the
    original filename here, otherwise for preprocessed Cmm files, the
    filename will be a temporary filename which is confusing.
    
    - - - - -
    63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00
    rts: remove legacy logging cabal flag
    
    - - - - -
    bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00
    rts: make threaded ways optional
    
    For certain targets (e.g. wasm32-wasi), the threaded rts is known not to
    work. This patch adds a "threaded" cabal flag to rts to make threaded
    rts ways optional. Hadrian enables this flag iff the flavour rtsWays
    contains threaded ways.
    
    - - - - -
    8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00
    DeriveFunctor: Check for last type variables using dataConUnivTyVars
    
    Previously, derived instances of `Functor` (as well as the related classes
    `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to
    infer by checking for fields that contain the last type variable. The problem
    was that this last type variable was taken from `tyConTyVars`. For GADTs, the
    type variables in each data constructor are _not_ the same type variables as
    in `tyConTyVars`, leading to #22167.
    
    This fixes the issue by instead checking for the last type variable using
    `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185,
    which also replaced an errant use of `tyConTyVars` with type variables from
    each data constructor.)
    
    Fixes #22167.
    
    - - - - -
    78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00
    Lexer: pass updated buffer to actions (#22201)
    
    In the lexer, predicates have the following type:
    	{ ... } :: user       -- predicate state
    		-> AlexInput  -- input stream before the token
    		-> Int        -- length of the token
    		-> AlexInput  -- input stream after the token
    		-> Bool       -- True <=> accept the token
    This is documented in the Alex manual.
    
    There is access to the input stream both before and after the token.
    But when the time comes to construct the token, GHC passes only the
    initial string buffer to the lexer action. This patch fixes it:
    
    	- type Action = PsSpan -> StringBuffer -> Int ->                 P (PsLocated Token)
    	+ type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token)
    
    Now lexer actions have access to the string buffer both before and after
    the token, just like the predicates. It's just a matter of passing an
    additional function parameter throughout the lexer.
    
    - - - - -
    75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00
    Lexer: define varsym without predicates (#22201)
    
    Before this patch, the varsym lexing rules were defined as follows:
    
    	<0> {
    	  @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix }
    	  @varsym / { followedByOpeningToken }  { varsym_prefix }
    	  @varsym / { precededByClosingToken }  { varsym_suffix }
    	  @varsym                               { varsym_loose_infix }
    	}
    
    Unfortunately, this meant that the predicates 'precededByClosingToken' and
    'followedByOpeningToken' were recomputed several times before we could figure
    out the whitespace context.
    
    With this patch, we check for whitespace context directly in the lexer
    action:
    
    	<0> {
    	  @varsym { with_op_ws varsym }
    	}
    
    The checking for opening/closing tokens happens in 'with_op_ws' now,
    which is part of the lexer action rather than the lexer predicate.
    
    - - - - -
    c1f81b38 by Matthew Farkas-Dyck at 2022-09-19T09:07:05-04:00
    Scrub partiality about `NewOrData`.
    
    Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor.
    
    Closes #22070.
    
    Bump haddock submodule.
    
    - - - - -
    1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00
    CmmToC: emit __builtin_unreachable() after noreturn ccalls
    
    Emit a __builtin_unreachable() call after a foreign call marked as
    CmmNeverReturns. This is crucial to generate correctly typed code for
    wasm; as for other archs, this is also beneficial for the C compiler
    optimizations.
    
    - - - - -
    19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00
    Document :unadd GHCi command in user guide
    
    - - - - -
    545ff490 by sheaf at 2022-09-20T03:50:06-04:00
    Hadrian: merge archives even in stage 0
    
    We now always merge .a archives when ar supports -L.
    This change is necessary in order to bootstrap GHC using GHC 9.4
    on Windows, as nested archives aren't supported.
    Not doing so triggered bug #21990 when trying to use the Win32
    package, with errors such as:
    
      Not a x86_64 PE+ file.
      Unknown COFF 4 type in getHeaderInfo.
    
      ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info
    
    We have to be careful about which ar is meant: in stage 0, the check
    should be done on the system ar (system-ar in system.config).
    
    - - - - -
    59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00
    Fix -Woperator-whitespace for consym (part of #19372)
    
    Due to an oversight, the initial specification and implementation of
    -Woperator-whitespace focused on varsym exclusively and completely
    ignored consym.
    
    This meant that expressions such as "x+ y" would produce a warning,
    while "x:+ y" would not.
    
    The specification was corrected in ghc-proposals pull request #404,
    and this patch updates the implementation accordingly.
    
    Regression test included.
    
    - - - - -
    c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00
    Add `Eq` and `Ord` instances for `Generically1`
    
    These are needed so the subsequent commit overhauling the `*1` classes
    type-checks.
    
    - - - - -
    7beb356e by John Ericson at 2022-09-20T13:11:50-04:00
    Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking
    
    This change is approved by the Core Libraries commitee in
    https://github.com/haskell/core-libraries-committee/issues/10
    
    The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for
    `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`.
    These have the proper flexible contexts that are exactly what the
    instance needs:
    
    For example, instead of
    ```haskell
    instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where
      (==) = eq1
    ```
    we do
    ```haskell
    deriving instance Eq (f (g a)) => Eq (Compose f g a)
    ```
    
    But, that change alone is rather breaking, because until now `Eq (f a)`
    and `Eq1 f` (and respectively the other classes and their `*1`
    equivalents too) are *incomparable* constraints. This has always been an
    annoyance of working with the `*1` classes, and now it would rear it's
    head one last time as an pesky migration.
    
    Instead, we give the `*1` classes superclasses, like so:
    ```haskell
    (forall a. Eq a => Eq (f a)) => Eq1 f
    ```
    along with some laws that canonicity is preserved, like:
    ```haskell
    liftEq (==) = (==)
    ```
    
    and likewise for `*2` classes:
    ```haskell
    (forall a. Eq a => Eq1 (f a)) => Eq2 f
    ```
    and laws:
    ```haskell
    liftEq2 (==) = liftEq1
    ```
    
    The `*1` classes also have default methods using the `*2` classes where
    possible.
    
    What this means, as explained in the docs, is that `*1` classes really
    are generations of the regular classes, indicating that the methods can
    be split into a canonical lifting combined with a canonical inner, with
    the super class "witnessing" the laws[1] in a fashion.
    
    Circling back to the pragmatics of migrating, note that the superclass
    means evidence for the old `Sum`, `Product`, and `Compose` instances is
    (more than) sufficient, so breakage is less likely --- as long no
    instances are "missing", existing polymorphic code will continue to
    work.
    
    Breakage can occur when a datatype implements the `*1` class but not the
    corresponding regular class, but this is almost certainly an oversight.
    For example, containers made that mistake for `Tree` and `Ord`, which I
    fixed in https://github.com/haskell/containers/pull/761, but fixing the
    issue by adding `Ord1` was extremely *un*controversial.
    
    `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show`
    instances. It is unlikely this would have been caught without
    implementing this change.
    
    -----
    
    [1]: In fact, someday, when the laws are part of the language and not
    only documentation, we might be able to drop the superclass field of the
    dictionary by using the laws to recover the superclass in an
    instance-agnostic manner, e.g. with a *non*-overloaded function with
    type:
    
    ```haskell
    DictEq1 f -> DictEq a -> DictEq (f a)
    ```
    
    But I don't wish to get into optomizations now, just demonstrate the
    close relationship between the law and the superclass.
    
    Bump haddock submodule because of test output changing.
    
    - - - - -
    6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00
    Add notes to ghc-prim Haddocks that users should not import it
    
    - - - - -
    ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00
    docs: clarify that LLVM codegen is not available in unregisterised mode
    
    The current docs are misleading and suggest that it is possible to use
    LLVM codegen from an unregisterised build.  This is not the case;
    attempting to pass `-fllvm` to an unregisterised build warns:
    
    ```
    when making flags consistent: warning:
        Target platform uses unregisterised ABI, so compiling via C
    ```
    
    and uses the C codegen anyway.
    
    - - - - -
    854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00
    rts: remove copy-paste error from `cabal.rts.in`
    
    This was, likely accidentally, introduced in 4bf542bf1c.
    
    See: 4bf542bf1cdf2fa468457fc0af21333478293476
    
    - - - - -
    c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00
    hadrian: Add extra_dependencies edges for all different ways
    
    The hack to add extra dependencies needed by DeriveLift extension missed
    the cases for profiles and dynamic ways. For the profiled way this leads
    to errors like:
    
    ```
    GHC error in desugarer lookup in Data.IntSet.Internal:
      Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’
      Perhaps you haven't installed the profiling libraries for package ‘template-haskell’?
      Use -v (or `:set -v` in ghci) to see a list of the files searched for.
    ghc: panic! (the 'impossible' happened)
      GHC version 9.5.20220916:
            initDs
    ```
    
    Therefore the fix is to add these extra edges in.
    
    Fixes #22197
    
    - - - - -
    a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00
    users-guide: fix incorrect ghcappdata folder for unix and windows
    
    - - - - -
    06ccad0d by sheaf at 2022-09-21T08:28:49-04:00
    Don't use isUnliftedType in isTagged
    
    The function GHC.Stg.InferTags.Rewrite.isTagged can be given
    the Id of a join point, which might be representation polymorphic.
    This would cause the call to isUnliftedType to crash. It's better
    to use typeLevity_maybe instead.
    
    Fixes #22212
    
    - - - - -
    c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00
    Add fragmentation statistic to GHC.Stats
    
    Implements #21537
    
    - - - - -
    2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00
    Rename Solo[constructor] to MkSolo
    
    Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst)
    
    Moves all tuples to GHC.Tuple.Prim
    Updates ghc-prim version (and bumps bounds in dependents)
    
    updates haddock submodule
    updates deepseq submodule
    updates text submodule
    
    - - - - -
    9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00
    Update filepath to filepath-1.4.100.0
    
    Updates submodule
    
    * Always rely on vendored filepath
    * filepath must be built as stage0 dependency because it uses
      template-haskell.
    
    Towards #22098
    
    - - - - -
    615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00
    Minor refactor around Outputable
    
    * Replace 'text . show' and 'ppr' with 'int'.
    * Remove Outputable.hs-boot, no longer needed
    * Use pprWithCommas
    * Factor out instructions in AArch64 codegen
    
    - - - - -
    aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00
    Demand: Clear distinction between Call SubDmd and eval Dmd (#21717)
    
    In #21717 we saw a reportedly unsound strictness signature due to an unsound
    definition of plusSubDmd on Calls. This patch contains a description and the fix
    to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`.
    
    This fix means we also get rid of the special handling of `-fpedantic-bottoms`
    in eta-reduction. Thanks to less strict and actually sound strictness results,
    we will no longer eta-reduce the problematic cases in the first place, even
    without `-fpedantic-bottoms`.
    
    So fixing the unsoundness also makes our eta-reduction code simpler with less
    hacks to explain. But there is another, more unfortunate side-effect:
    We *unfix* #21085, but fortunately we have a new fix ready:
    See `Note [mkCall and plusSubDmd]`.
    
    There's another change:
    I decided to make `Note [SubDemand denotes at least one evaluation]` a lot
    simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument
    demands are lazy. That leads to less precise results, but in turn rids ourselves
    from the need for 4 different `OpMode`s and the complication of
    `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code
    that is in line with the paper draft on Demand Analysis.
    
    I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for
    posterity. The fallout in terms of regressions is negligible, as the testsuite
    and NoFib shows.
    
    ```
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             hidden          +0.2%     -0.2%
             linear          -0.0%     -0.7%
    --------------------------------------------------------------------------------
                Min          -0.0%     -0.7%
                Max          +0.2%     +0.0%
     Geometric Mean          +0.0%     -0.0%
    ```
    
    Fixes #21717.
    
    - - - - -
    9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00
    implement proposal 106 (Define Kinds Without Promotion) (fixes #6024)
    
    includes corresponding changes to haddock submodule
    
    - - - - -
    c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00
    Apply some tricks to speed up core lint.
    
    Below are the noteworthy changes and if given their impact on compiler
    allocations for a type heavy module:
    
    * Use the oneShot trick on LintM
    * Use a unboxed tuple for the result of LintM: ~6% reduction
    * Avoid a thunk for the result of typeKind in lintType: ~5% reduction
    * lint_app: Don't allocate the error msg in the hot code path: ~4%
      reduction
    * lint_app: Eagerly force the in scope set: ~4%
    * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2%
    * lintM: Use a unboxed maybe for the `a` result: ~12%
    * lint_app: make go_app tail recursive to avoid allocating the go function
                as heap closure: ~7%
    * expandSynTyCon_maybe: Use a specialized data type
    
    For a less type heavy module like nofib/spectral/simple compiled with
    -O -dcore-lint allocations went down by ~24% and compile time by ~9%.
    
    -------------------------
    Metric Decrease:
        T1969
    -------------------------
    
    - - - - -
    b74b6191 by sheaf at 2022-09-28T15:08:10-04:00
    matchLocalInst: do domination analysis
    
    When multiple Given quantified constraints match a Wanted, and there is
    a quantified constraint that dominates all others, we now pick it
    to solve the Wanted.
    
    See Note [Use only the best matching quantified constraint].
    
    For example:
    
      [G] d1: forall a b. ( Eq a, Num b, C a b  ) => D a b
      [G] d2: forall a  .                C a Int  => D a Int
      [W] {w}: D a Int
    
    When solving the Wanted, we find that both Givens match, but we pick
    the second, because it has a weaker precondition, C a Int, compared
    to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1;
    see Note [When does a quantified instance dominate another?].
    
    This domination test is done purely in terms of superclass expansion,
    in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt
    to do a full round of constraint solving; this simple check suffices
    for now.
    
    Fixes #22216 and #22223
    
    - - - - -
    2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
    Improve aggressive specialisation
    
    This patch fixes #21286, by not unboxing dictionaries in
    worker/wrapper (ever). The main payload is tiny:
    
    * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox
      dictionaries in `get_dmd`.  See Note [Do not unbox class dictionaries]
      in that module
    
    * I also found that imported wrappers were being fruitlessly
      specialised, so I fixed that too, in canSpecImport.
      See Note [Specialising imported functions] point (2).
    
    In doing due diligence in the testsuite I fixed a number of
    other things:
    
    * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make,
      and Note [Inline specialisations] in GHC.Core.Opt.Specialise,
      and remove duplication between the two. The new Note describes
      how we specialise functions with an INLINABLE pragma.
    
      And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`.
    
    * Improve Note [Worker/wrapper for INLINABLE functions] in
      GHC.Core.Opt.WorkWrap.
    
      And (critially) make an actual change which is to propagate the
      user-written pragma from the original function to the wrapper; see
      `mkStrWrapperInlinePrag`.
    
    * Write new Note [Specialising imported functions] in
      GHC.Core.Opt.Specialise
    
    All this has a big effect on some compile times. This is
    compiler/perf, showing only changes over 1%:
    
    Metrics: compile_time/bytes allocated
    -------------------------------------
                    LargeRecord(normal)  -50.2% GOOD
               ManyConstructors(normal)   +1.0%
    MultiLayerModulesTH_OneShot(normal)   +2.6%
                      PmSeriesG(normal)   -1.1%
                         T10547(normal)   -1.2%
                         T11195(normal)   -1.2%
                         T11276(normal)   -1.0%
                        T11303b(normal)   -1.6%
                         T11545(normal)   -1.4%
                         T11822(normal)   -1.3%
                         T12150(optasm)   -1.0%
                         T12234(optasm)   -1.2%
                         T13056(optasm)   -9.3% GOOD
                         T13253(normal)   -3.8% GOOD
                         T15164(normal)   -3.6% GOOD
                         T16190(normal)   -2.1%
                         T16577(normal)   -2.8% GOOD
                         T16875(normal)   -1.6%
                         T17836(normal)   +2.2%
                        T17977b(normal)   -1.0%
                         T18223(normal)  -33.3% GOOD
                         T18282(normal)   -3.4% GOOD
                         T18304(normal)   -1.4%
                        T18698a(normal)   -1.4% GOOD
                        T18698b(normal)   -1.3% GOOD
                         T19695(normal)   -2.5% GOOD
                          T5837(normal)   -2.3%
                          T9630(normal)  -33.0% GOOD
                          WWRec(normal)   -9.7% GOOD
                 hard_hole_fits(normal)   -2.1% GOOD
                         hie002(normal)   +1.6%
    
                              geo. mean   -2.2%
                              minimum    -50.2%
                              maximum     +2.6%
    
    I diligently investigated some of the big drops.
    
    * Caused by not doing w/w for dictionaries:
        T13056, T15164, WWRec, T18223
    
    * Caused by not fruitlessly specialising wrappers
        LargeRecord, T9630
    
    For runtimes, here is perf/should+_run:
    
    Metrics: runtime/bytes allocated
    --------------------------------
                   T12990(normal)   -3.8%
                    T5205(normal)   -1.3%
                    T9203(normal)  -10.7% GOOD
            haddock.Cabal(normal)   +0.1%
             haddock.base(normal)   -1.1%
         haddock.compiler(normal)   -0.3%
            lazy-bs-alloc(normal)   -0.2%
    ------------------------------------------
                        geo. mean   -0.3%
                        minimum    -10.7%
                        maximum     +0.1%
    
    I did not investigate exactly what happens in T9203.
    
    Nofib is a wash:
    
    +-------------------------------++--+-----------+-----------+
    |                               ||  | tsv (rel) | std. err. |
    +===============================++==+===========+===========+
    |                     real/anna ||  |    -0.13% |      0.0% |
    |                      real/fem ||  |    +0.13% |      0.0% |
    |                   real/fulsom ||  |    -0.16% |      0.0% |
    |                     real/lift ||  |    -1.55% |      0.0% |
    |                  real/reptile ||  |    -0.11% |      0.0% |
    |                  real/smallpt ||  |    +0.51% |      0.0% |
    |          spectral/constraints ||  |    +0.20% |      0.0% |
    |               spectral/dom-lt ||  |    +1.80% |      0.0% |
    |               spectral/expert ||  |    +0.33% |      0.0% |
    +===============================++==+===========+===========+
    |                     geom mean ||  |           |           |
    +-------------------------------++--+-----------+-----------+
    
    I spent quite some time investigating dom-lt, but it's pretty
    complicated.  See my note on !7847.  Conclusion: it's just a delicate
    inlining interaction, and we have plenty of those.
    
    Metric Decrease:
        LargeRecord
        T13056
        T13253
        T15164
        T16577
        T18223
        T18282
        T18698a
        T18698b
        T19695
        T9630
        WWRec
        hard_hole_fits
        T9203
    
    - - - - -
    addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
    Refactor UnfoldingSource and IfaceUnfolding
    
    I finally got tired of the way that IfaceUnfolding reflected
    a previous structure of unfoldings, not the current one. This
    MR refactors UnfoldingSource and IfaceUnfolding to be simpler
    and more consistent.
    
    It's largely just a refactor, but in UnfoldingSource (which moves
    to GHC.Types.Basic, since it is now used in IfaceSyn too), I
    distinguish between /user-specified/ and /system-generated/ stable
    unfoldings.
    
        data UnfoldingSource
          = VanillaSrc
          | StableUserSrc   -- From a user-specified pragma
          | StableSystemSrc -- From a system-generated unfolding
          | CompulsorySrc
    
    This has a minor effect in CSE (see the use of isisStableUserUnfolding
    in GHC.Core.Opt.CSE), which I tripped over when working on
    specialisation, but it seems like a Good Thing to know anyway.
    
    - - - - -
    7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
    INLINE/INLINEABLE pragmas in Foreign.Marshal.Array
    
    Foreign.Marshal.Array contains many small functions, all of which are
    overloaded, and which are critical for performance. Yet none of them
    had pragmas, so it was a fluke whether or not they got inlined.
    
    This patch makes them all either INLINE (small ones) or
    INLINEABLE and hence specialisable (larger ones).
    
    See Note [Specialising array operations] in that module.
    
    - - - - -
    b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00
    Export OnOff from GHC.Driver.Session
    
    I was working on fixing an issue where HLS was trying to pass its
    DynFlags to HLint, but didn't pass any of the disabled language
    extensions, which HLint would then assume are on because of their
    default values.
    
    Currently it's not possible to get any of the "No" flags because the
    `DynFlags.extensions` field can't really be used since it is [OnOff
    Extension] and OnOff is not exported.
    
    So let's export it.
    
    - - - - -
    2f050687 by Andrew Lelechenko at 2022-09-28T17:50:28-04:00
    Avoid Data.List.group; prefer Data.List.NonEmpty.group
    
    This allows to avoid further partiality, e. g., map head . group is
    replaced by map NE.head . NE.group, and there are less panic calls.
    
    - - - - -
    bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00
    Clean up `findWiredInUnit`. In particular, avoid `head`.
    
    - - - - -
    6a2eec98 by Andrew Lelechenko at 2022-09-28T22:52:38-04:00
    Eliminate headFS, use unconsFS instead
    
    A small step towards #22185 to avoid partial functions + safe implementation
    of `startsWithUnderscore`.
    
    - - - - -
    5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00
    Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)
    
    Justification in #22231. Short form: In a demand like `1C1(C1(L))`
    it was too easy to confuse which `1` belongs to which `C`. Now
    that should be more obvious.
    
    Fixes #22231
    
    - - - - -
    ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00
    Revert "ci: enable parallel compression for xz"
    
    Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners.
    
    This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab.
    
    - - - - -
    f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00
    Boxity: Don't update Boxity unless worker/wrapper follows (#21754)
    
    A small refactoring in our Core Opt pipeline and some new functions for
    transfering argument boxities from one signature to another to facilitate
    `Note [Don't change boxity without worker/wrapper]`.
    
    Fixes #21754.
    
    - - - - -
    4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00
    Scrub various partiality involving empty lists.
    
    Avoids some uses of `head` and `tail`, and some panics when an argument is null.
    
    - - - - -
    95ead839 by Alexis King at 2022-10-01T00:37:43-04:00
    Fix a bug in continuation capture across multiple stack chunks
    
    - - - - -
    22096652 by Andrew Lelechenko at 2022-10-01T00:38:22-04:00
    Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc
    
    `viewCons` used to ignore `Many` constructor completely, returning `VNothing`.
    `viewSnoc` violated internal invariant of `Many` being a non-empty list.
    
    - - - - -
    48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00
    chore: extend `.editorconfig` for C files
    
    - - - - -
    b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00
    Fix docs for pattern synonyms
    - - - - -
    463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00
    Use sameByteArray# in sameByteArray
    
    - - - - -
    fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00
    Minor fixes following Unicode 15.0.0 update
    
    - Fix changelog for Unicode 15.0.0
    - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell".
    
    - - - - -
    8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00
    rts: don't enforce aligned((8)) on 32-bit targets
    
    We simply need to align to the word size for pointer tagging to work. On
    32-bit targets, aligned((8)) is wasteful.
    
    - - - - -
    532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00
    Export symbolSing, SSymbol, and friends (CLC#85)
    
    This implements this Core Libraries Proposal:
    https://github.com/haskell/core-libraries-committee/issues/85
    
    In particular, it:
    
    1. Exposes the `symbolSing` method of `KnownSymbol`,
    2. Exports the abstract `SSymbol` type used in `symbolSing`, and
    3. Defines an API for interacting with `SSymbol`.
    
    This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and
    `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2)
    of #21568.
    
    - - - - -
    d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00
    Remove mention of make from README.md
    
    - - - - -
    945e8e49 by Andrew Lelechenko at 2022-10-10T17:13:31-04:00
    Add a newline before since pragma in Data.Array.Byte
    
    - - - - -
    44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00
    Parser/PostProcess: rename failOp* functions
    
    There are three functions named failOp* in the parser:
    	failOpNotEnabledImportQualifiedPost
    	failOpImportQualifiedTwice
    	failOpFewArgs
    Only the last one has anything to do with operators. The other two
    were named this way either by mistake or due to a misunderstanding of
    what "op" stands for. This small patch corrects this.
    
    - - - - -
    96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00
    Make rewrite rules "win" over inlining
    
    If a rewrite rule and a rewrite rule compete in the simplifier, this
    patch makes sure that the rewrite rule "win".  That is, in general
    a bit fragile, but it's a huge help when making specialisation work
    reliably, as #21851 and #22097 showed.
    
    The change is fairly straightforwad, and documented in
       Note [Rewrite rules and inlining]
    in GHC.Core.Opt.Simplify.Iteration.
    
    Compile-times change, up and down a bit -- in some cases because
    we get better specialisation.  But the payoff (more reliable
    specialisation) is large.
    
    Metrics: compile_time/bytes allocated
    -----------------------------------------------
        T10421(normal)   +3.7% BAD
       T10421a(normal)   +5.5%
        T13253(normal)   +1.3%
          T14052(ghci)   +1.8%
        T15304(normal)   -1.4%
        T16577(normal)   +3.1% BAD
        T17516(normal)   +2.3%
        T17836(normal)   -1.9%
        T18223(normal)   -1.8%
         T8095(normal)   -1.3%
         T9961(normal)   +2.5% BAD
    
             geo. mean   +0.0%
             minimum     -1.9%
             maximum     +5.5%
    
    Nofib results are (bytes allocated)
    
    +-------------------------------++----------+
    |                               ||tsv (rel) |
    +===============================++==========+
    |           imaginary/paraffins ||   +0.27% |
    |                imaginary/rfib ||   -0.04% |
    |                     real/anna ||   +0.02% |
    |                      real/fem ||   -0.04% |
    |                    real/fluid ||   +1.68% |
    |                   real/gamteb ||   -0.34% |
    |                       real/gg ||   +1.54% |
    |                   real/hidden ||   -0.01% |
    |                      real/hpg ||   -0.03% |
    |                    real/infer ||   -0.03% |
    |                   real/prolog ||   +0.02% |
    |                  real/veritas ||   -0.47% |
    |       shootout/fannkuch-redux ||   -0.03% |
    |         shootout/k-nucleotide ||   -0.02% |
    |               shootout/n-body ||   -0.06% |
    |        shootout/spectral-norm ||   -0.01% |
    |         spectral/cryptarithm2 ||   +1.25% |
    |             spectral/fibheaps ||  +18.33% |
    |           spectral/last-piece ||   -0.34% |
    +===============================++==========+
    |                     geom mean ||   +0.17% |
    
    There are extensive notes in !8897 about the regressions.
    Briefly
    
    * fibheaps: there was a very delicately balanced inlining that
      tipped over the wrong way after this change.
    
    * cryptarithm2 and paraffins are caused by #22274, which is
      a separate issue really.  (I.e. the right fix is *not* to
      make inlining "win" over rules.)
    
    So I'm accepting these changes
    
    Metric Increase:
        T10421
        T16577
        T9961
    
    - - - - -
    ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00
    Utils.JSON: do not escapeJsonString in ToJson String instance
    
    as `escapeJsonString` is used in `renderJSON`, so the `JSString`
    constructor is meant to carry the unescaped string.
    
    - - - - -
    fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00
    Tidy implicit binds
    
    We want to put implicit binds into fat interface files, so the easiest
    thing to do seems to be to treat them uniformly with other binders.
    
    - - - - -
    e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00
    Interface Files with Core Definitions
    
    This commit adds three new flags
    
    * -fwrite-if-simplified-core: Writes the whole core program into an interface
      file
    * -fbyte-code-and-object-code: Generate both byte code and object code
      when compiling a file
    * -fprefer-byte-code: Prefer to use byte-code if it's available when
      running TH splices.
    
    The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline
    at the point just after simplification and before code generation. Once compilation is
    restarted then code can be created for the byte code backend.
    This can significantly speed up
    start-times for projects in GHCi. HLS already implements its own version of these extended interface
    files for this reason.
    
    Preferring to use byte-code means that we can avoid some potentially
    expensive code generation steps (see #21700)
    
    * Producing object code is much slower than producing bytecode, and normally you
      need to compile with `-dynamic-too` to produce code in the static and dynamic way, the
      dynamic way just for Template Haskell execution when using a dynamically linked compiler.
    
    * Linking many large object files, which happens once per splice, can be quite
      expensive compared to linking bytecode.
    
    And you can get GHC to compile the necessary byte code so
    `-fprefer-byte-code` has access to it by using
    `-fbyte-code-and-object-code`.
    
    Fixes #21067
    
    - - - - -
    9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00
    Teach -fno-code about -fprefer-byte-code
    
    This patch teachs the code generation logic of -fno-code about
    -fprefer-byte-code, so that if we need to generate code for a module
    which prefers byte code, then we generate byte code rather than object
    code.
    
    We keep track separately which modules need object code and which byte
    code and then enable the relevant code generation for each. Typically
    the option will be enabled globally so one of these sets should be empty
    and we will just turn on byte code or object code generation.
    
    We also fix the bug where we would generate code for a module which
    enables Template Haskell despite the fact it was unecessary.
    
    Fixes #22016
    
    - - - - -
    caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00
    Don't keep exit join points so much
    
    We were religiously keeping exit join points throughout, which
    had some bad effects (#21148, #22084).
    
    This MR does two things:
    
    * Arranges that exit join points are inhibited from inlining
      only in /one/ Simplifier pass (right after Exitification).
    
      See Note [Be selective about not-inlining exit join points]
      in GHC.Core.Opt.Exitify
    
      It's not a big deal, but it shaves 0.1% off compile times.
    
    * Inline used-once non-recursive join points very aggressively
      Given join j x = rhs in
            joinrec k y = ....j x....
    
      where this is the only occurrence of `j`, we want to inline `j`.
      (Unless sm_keep_exits is on.)
    
      See Note [Inline used-once non-recursive join points] in
      GHC.Core.Opt.Simplify.Utils
    
      This is just a tidy-up really.  It doesn't change allocation, but
      getting rid of a binding is always good.
    
    Very effect on nofib -- some up and down.
    
    - - - - -
    284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00
    Make SpecConstr bale out less often
    
    When doing performance debugging on #22084 / !8901, I found that the
    algorithm in SpecConstr.decreaseSpecCount was so aggressive that if
    there were /more/ specialisations available for an outer function,
    that could more or less kill off specialisation for an /inner/
    function.  (An example was in nofib/spectral/fibheaps.)
    
    This patch makes it a bit more aggressive, by dividing by 2, rather
    than by the number of outer specialisations.
    
    This makes the program bigger, temporarily:
    
       T19695(normal) ghc/alloc   +11.3% BAD
    
    because we get more specialisation.  But lots of other programs
    compile a bit faster and the geometric mean in perf/compiler
    is 0.0%.
    
    Metric Increase:
        T19695
    
    - - - - -
    66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00
    CmmToC: emit explicit tail calls when the C compiler supports it
    
    Clang 13+ supports annotating a return statement using the musttail
    attribute, which guarantees that it lowers to a tail call if compilation
    succeeds.
    
    This patch takes advantage of that feature for the unregisterised code
    generator. The configure script tests availability of the musttail
    attribute, if it's available, the Cmm tail calls will become C tail
    calls that avoids the mini interpreter trampoline overhead. Nothing is
    affected if the musttail attribute is not supported.
    
    Clang documentation:
    https://clang.llvm.org/docs/AttributeReference.html#musttail
    
    - - - - -
    7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00
    Don't include BufPos in interface files
    
    Ticket #22162 pointed out that the build directory was leaking into the
    ABI hash of a module because the BufPos depended on the location of the
    build tree.
    
    BufPos is only used in GHC.Parser.PostProcess.Haddock, and the
    information doesn't need to be propagated outside the context of a
    module.
    
    Fixes #22162
    
    - - - - -
    dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00
    CLabel: fix isInfoTableLabel
    
    isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work.
    
    - - - - -
    da679f2e by Andrew Lelechenko at 2022-10-11T18:02:59-04:00
    Extend documentation for Data.List, mostly wrt infinite lists
    
    - - - - -
    9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00
    Expand comment for Data.List.permutations
    - - - - -
    d3863cb7 by Andrew Lelechenko at 2022-10-11T18:03:37-04:00
    ByteArray# is unlifted, not unboxed
    
    - - - - -
    f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00
    rts: Add missing declaration of stg_noDuplicate
    
    - - - - -
    69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00
    base: Move CString, CStringLen to GHC.Foreign
    
    - - - - -
    f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00
    base: Move IPE helpers to GHC.InfoProv
    
    - - - - -
    866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00
    rts: Refactor IPE tracing support
    
    - - - - -
    6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00
    Refactor IPE initialization
    
    Here we refactor the representation of info table provenance information
    in object code to significantly reduce its size and link-time impact.
    Specifically, we deduplicate strings and represent them as 32-bit
    offsets into a common string table.
    
    In addition, we rework the registration logic to eliminate allocation
    from the registration path, which is run from a static initializer where
    things like allocation are technically undefined behavior (although it
    did previously seem to work). For similar reasons we eliminate lock
    usage from registration path, instead relying on atomic CAS.
    
    Closes #22077.
    
    - - - - -
    9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00
    Separate IPE source file from span
    
    The source file name can very often be shared across many IPE entries
    whereas the source coordinates are generally unique. Separate the two to
    exploit sharing of the former.
    
    - - - - -
    27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00
    Make Cmm Lint messages use dump style
    
    Lint errors indicate an internal error in GHC, so it makes sense to use
    it instead of the user style. This is consistent with Core Lint and STG Lint:
    
    https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429
    
    https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144
    
    Fixes #22218.
    
    - - - - -
    64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00
    Mark T7919 as fragile
    
    On x86_64-linux, T7919 timed out ~30 times during July 2022.
    
    And again ~30 times in September 2022.
    
    - - - - -
    481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00
    rts: Don't hint inlining of appendToRunQueue
    
    These hints have resulted in compile-time warnings due to failed
    inlinings for quite some time. Moreover, it's quite unlikely that
    inlining them is all that beneficial given that they are rather sizeable
    functions.
    
    Resolves #22280.
    
    - - - - -
    81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00
    remove name shadowing
    
    - - - - -
    626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00
    winio: do not re-translate input when handle is uncooked
    
    - - - - -
    5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00
    Unrestricted OverloadedLabels (#11671)
    
    Implements GHC proposal:
    https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst
    
    - - - - -
    ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00
    Add a perf test for the generics code pattern from #21839.
    
    This code showed a strong shift between compile time (got worse) and
    run time (got a lot better) recently which is perfectly acceptable.
    
    However it wasn't clear why the compile time regression was happening
    initially so I'm adding this test to make it easier to track such changes
    in the future.
    
    - - - - -
    78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00
    rts/linker: Consolidate initializer/finalizer handling
    
    Here we extend our treatment of initializer/finalizer priorities to
    include ELF and in so doing refactor things to share the implementation
    with PEi386. As well, I fix a subtle misconception of the ordering
    behavior for `.ctors`.
    
    Fixes #21847.
    
    - - - - -
    44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00
    rts/linker: Add support for .fini sections
    
    - - - - -
    beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00
    Update phases.rst
    
    (the name of the original source file is $1, not $2)
    - - - - -
    eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00
    Clearer error msg for newtype GADTs with defaulted kind
    
    When a newtype introduces GADT eq_specs due to a defaulted
    RuntimeRep, we detect this and print the error message with
    explicit kinds.
    
    This also refactors newtype type checking to use the new
    diagnostic infra.
    
    Fixes #21447
    
    - - - - -
    43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00
    Add standard Unicode case predicates isUpperCase and isLowerCase.
    
    These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower.
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403.
    
    Fixes #14589
    
    - - - - -
    aec5a443 by Andrew Lelechenko at 2022-10-14T07:46:21-04:00
    Add type signatures in where-clause of Data.List.permutations
    
    The type of interleave' is very much revealing, otherwise it's extremely tough to decipher.
    
    - - - - -
    ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00
    rts: Use pthread_setname_np correctly on Darwin
    
    As noted in #22206, pthread_setname_np on Darwin only supports
    setting the name of the calling thread. Consequently we must introduce
    a trampoline which first sets the thread name before entering the thread
    entrypoint.
    - - - - -
    8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00
    testsuite: Add test for #22282
    
    This will complement mpickering's more general port of foundation's
    numerical testsuite, providing a test for the specific case found
    in #22282.
    
    - - - - -
    62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00
    ncg/aarch64: Fix sub-word sign extension yet again
    
    In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues
    to do with sign extension in the AArch64 NCG found by ghc/test-primops>.
    However, this patch made a critical error, assuming that getSomeReg
    would allocate a fresh register for the result of its evaluation.
    However, this is not the case as `getSomeReg (CmmReg r) == r`.
    Consequently, any mutation of the register returned by `getSomeReg` may
    have unwanted side-effects on other expressions also mentioning `r`. In
    the fix listed above, this manifested as the registers containing the
    operands of binary arithmetic operations being incorrectly
    sign-extended. This resulted in #22282.
    
    Sadly, the rather simple structure of the tests generated
    by `test-primops` meant that this particular case was not exercised.
    Even more surprisingly, none of our testsuite caught this case.
    
    Here we fix this by ensuring that intermediate sign extension is
    performed in a fresh register.
    
    Fixes #22282.
    
    - - - - -
    54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00
    rts: ensure we are below maxHeapSize after returning megablocks
    
    When the heap is heavily block fragmented the live byte size might be
    low while the memory usage is high. We want to ensure that heap overflow
    triggers in these cases.
    
    We do so by checking that we can return enough megablocks to
    under maxHeapSize at the end of GC.
    
    - - - - -
    29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00
    rts: trigger a major collection if megablock usage exceeds maxHeapSize
    
    When the heap is suffering from block fragmentation, live bytes might be
    low while megablock usage is high.
    
    If megablock usage exceeds maxHeapSize, we want to trigger a major GC to
    try to recover some memory otherwise we will die from a heapOverflow at
    the end of the GC.
    
    Fixes #21927
    
    - - - - -
    4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00
    Add realease note for #21927
    
    - - - - -
    c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00
    DmdAnal: Look through unfoldings of DataCon wrappers (#22241)
    
    Previously, the demand signature we computed upfront for a DataCon wrapper
    
    lacked boxity information and was much less precise than the demand transformer
    
    for the DataCon worker.
    
    In this patch we adopt the solution to look through unfoldings of DataCon
    
    wrappers during Demand Analysis, but still attach a demand signature for other
    
    passes such as the Simplifier.
    
    See `Note [DmdAnal for DataCon wrappers]` for more details.
    
    Fixes #22241.
    
    - - - - -
    8c72411d by Gergő Érdi at 2022-10-17T19:20:04-04:00
    Add `Enum (Down a)` instance that swaps `succ` and `pred`
    
    See https://github.com/haskell/core-libraries-committee/issues/51 for
    discussion. The key points driving the implementation are the following
    two ideas:
    
    * For the `Int` type, `comparing (complement @Int)` behaves exactly as
      an order-swapping `compare @Int`.
    * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`,
      if only the corner case of starting at the very end is handled specially
    
    - - - - -
    d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00
    Update the check-exact infrastructure to match ghc-exactprint
    
    GHC tests the exact print annotations using the contents of
    utils/check-exact.
    
    The same functionality is provided via
    https://github.com/alanz/ghc-exactprint
    
    The latter was updated to ensure it works with all of the files on
    hackage when 9.2 was released, as well as updated to ensure users of
    the library could work properly (apply-refact, retrie, etc).
    
    This commit brings the changes from ghc-exactprint into
    GHC/utils/check-exact, adapting for the changes to master.
    
    Once it lands, it will form the basis for the 9.4 version of
    ghc-exactprint.
    
    See also discussion around this process at #21355
    
    - - - - -
    08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00
    Avoid allocating intermediate lists for non recursive bindings.
    
    We do so by having an explicit folding function that doesn't need to
    allocate intermediate lists first.
    
    Fixes #22196
    
    - - - - -
    ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00
    Testsuite: Add a new tables_next_to_code predicate.
    
    And use it to avoid T21710a failing on non-tntc archs.
    
    Fixes #22169
    
    - - - - -
    abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00
    example rewrite
    - - - - -
    39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00
    remove redirect
    - - - - -
    0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00
    use heredoc
    - - - - -
    0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00
    testsuite: Fix typo when setting llvm_ways
    
    Since 2014 llvm_ways has been set to [] so none of the tests which use
    only_ways(llvm_ways) have worked as expected.
    
    Hopefully the tests still pass with this typo fix!
    
    - - - - -
    ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00
    Fix T15155l not getting -fllvm
    
    - - - - -
    0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00
    Fix GHCis interaction with tag inference.
    
    I had assumed that wrappers were not inlined in interactive mode.
    Meaning we would always execute the compiled wrapper which properly
    takes care of upholding the strict field invariant.
    This turned out to be wrong. So instead we now run tag inference even
    when we generate bytecode. In that case only for correctness not
    performance reasons although it will be still beneficial for runtime
    in some cases.
    
    I further fixed a bug where GHCi didn't tag nullary constructors
    properly when used as arguments. Which caused segfaults when calling
    into compiled functions which expect the strict field invariant to
    be upheld.
    
    Fixes #22042 and #21083
    
    -------------------------
    Metric Increase:
        T4801
    
    Metric Decrease:
        T13035
    -------------------------
    
    - - - - -
    9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00
    Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions.
    
    - - - - -
    f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00
    configure: Bump minimum bootstrap GHC version
    
    Fixes #22245
    
    - - - - -
    ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00
    Build System: Remove out-of-date comment about make build system
    
    Both make and hadrian interleave compilation of modules of different
    modules and don't respect the package boundaries. Therefore I just
    remove this comment which points out this "difference".
    
    Fixes #22253
    
    - - - - -
    e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00
    Allow configuration of error message printing
    
    This MR implements the idea of #21731 that the printing of a diagnostic
    method should be configurable at the printing time.
    
    The interface of the `Diagnostic` class is modified from:
    
    ```
    class Diagnostic a where
      diagnosticMessage :: a -> DecoratedSDoc
      diagnosticReason  :: a -> DiagnosticReason
      diagnosticHints   :: a -> [GhcHint]
    ```
    
    to
    
    ```
    class Diagnostic a where
      type DiagnosticOpts a
      defaultDiagnosticOpts :: DiagnosticOpts a
      diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
      diagnosticReason  :: a -> DiagnosticReason
      diagnosticHints   :: a -> [GhcHint]
    ```
    
    and so each `Diagnostic` can implement their own configuration record
    which can then be supplied by a client in order to dictate how to print
    out the error message.
    
    At the moment this only allows us to implement #21722 nicely but in
    future it is more natural to separate the configuration of how much
    information we put into an error message and how much we decide to print
    out of it.
    
    Updates Haddock submodule
    
    - - - - -
    99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00
    Add -fsuppress-error-contexts to disable printing error contexts in errors
    
    In many development environments, the source span is the primary means
    of seeing what an error message relates to, and the In the expression:
    and In an equation for: clauses are not particularly relevant. However,
    they can grow to be quite long, which can make the message itself both
    feel overwhelming and interact badly with limited-space areas.
    
    It's simple to implement this flag so we might as well do it and give
    the user control about how they see their messages.
    
    Fixes #21722
    
    - - - - -
    5b3a992f by Dai at 2022-10-19T10:45:45-04:00
    Add VecSlot for unboxed sums of SIMD vectors
    
    This patch adds the missing `VecRep` case to `primRepSlot` function and
    all the necessary machinery to carry this new `VecSlot` through code
    generation. This allows programs involving unboxed sums of SIMD vectors
    to be written and compiled.
    
    Fixes #22187
    
    - - - - -
    6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00
    Remove SIMD conversions
    
    This patch makes it so that packing/unpacking SIMD
    vectors always uses the right sized types, e.g.
    unpacking a Word16X4# will give a tuple of Word16#s.
    
    As a result, we can get rid of the conversion instructions
    that were previously required.
    
    Fixes #22296
    
    - - - - -
    3be48877 by sheaf at 2022-10-19T10:45:45-04:00
    Cmm Lint: relax SIMD register assignment check
    
    As noted in #22297, SIMD vector registers can be used
    to store different kinds of values, e.g. xmm1 can be used
    both to store integer and floating point values.
    The Cmm type system doesn't properly account for this, so
    we weaken the Cmm register assignment lint check to only
    compare widths when comparing a vector type with its
    allocated vector register.
    
    - - - - -
    f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00
    Disable some SIMD tests on non-X86 architectures
    
    - - - - -
    83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00
    Scrub various partiality involving lists (again).
    
    Lets us avoid some use of `head` and `tail`, and some panics.
    
    - - - - -
    c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00
    Enforce invariant of `ListBag` constructor.
    
    - - - - -
    488d3631 by Andrew Lelechenko at 2022-10-19T10:47:52-04:00
    More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg
    
    It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches`
    and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches`
    contains a single instance, but these invariants are immediately lost afterwards
    and not encoded in types. This patch enforces the invariants by pattern matching
    and makes types more precise, avoiding asserts and partial functions such as `head`.
    
    - - - - -
    607ce263 by sheaf at 2022-10-19T10:47:52-04:00
    Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap
    - - - - -
    1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00
    Add SpliceTypes test for hie files
    
    This test checks that typed splices and quotes get the right type
    information when used in hiefiles.
    
    See #21619
    
    - - - - -
    a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00
    Small language fixes in 'Using GHC'
    
    - - - - -
    1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00
    Fix typo in `Opt_WriteIfSimplifiedCore`'s name
    
    - - - - -
    b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00
    TyEq:N assertion: only for saturated applications
    
    The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly
    triggered in the case of an unsaturated newtype TyCon heading the RHS,
    even though we can't unwrap such an application. Now, we only trigger
    an assertion failure in case of a saturated application of a newtype
    TyCon.
    
    Fixes #22310
    
    - - - - -
    ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00
    CoreToStg: purge `DynFlags`.
    
    - - - - -
    1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00
    ci: Make fat014 test robust
    
    For some reason I implemented this as a makefile test rather than a
    ghci_script test. Hopefully making it a ghci_script test makes it more
    robust.
    
    Fixes #22313
    
    - - - - -
    8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00
    remove a no-warn directive from GHC.Cmm.ContFlowOpt
    
    This patch is motivated by the desire to remove the {-# OPTIONS_GHC
    -fno-warn-incomplete-patterns #-} directive at the top of
    GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I
    understand it's a goal of the project to remove such directives.) I
    chose this task because I'm a new contributor to GHC, and it seemed like
    a good way to get acquainted with the patching process.
    
    In order to address the warning that arose when I removed the no-warn
    directive, I added a case to removeUnreachableBlocksProc to handle the
    CmmData constructor. Clearly, since this partial function has not been
    erroring out in the wild, its inputs are always in practice wrapped by
    the CmmProc constructor. Therefore the CmmData case is handled by a
    precise panic (which is an improvement over the partial pattern match
    from before).
    
    - - - - -
    a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00
    build: get rid of `HAVE_TIME_H`
    
    As advertized by `autoreconf`:
    
    > All current systems provide time.h; it need not be checked for.
    
    Hence, remove the check for it in `configure.ac` and remove conditional
    inclusion of the header in `HAVE_TIME_H` blocks where applicable.
    
    The `time.h` header was being included in various source files without a
    `HAVE_TIME_H` guard already anyway.
    
    - - - - -
    25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00
    rts: remove use of `TIME_WITH_SYS_TIME`
    
    `autoreconf` will insert an `m4_warning` when the obsolescent
    `AC_HEADER_TIME` macro is used:
    
    > Update your code to rely only on HAVE_SYS_TIME_H,
    > then remove this warning and the obsolete code below it.
    > All current systems provide time.h; it need not be checked for.
    > Not all systems provide sys/time.h, but those that do, all allow
    > you to include it and time.h simultaneously.
    
    Presence of `sys/time.h` was already checked in an earlier
    `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and
    guards relying on `TIME_WITH_SYS_TIME` can be reworked to
    (unconditionally) include `time.h` and include `sys/time.h` based on
    `HAVE_SYS_TIME_H`.
    
    Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67
    says
    
    > This macro is obsolescent, as current systems can include both files
    > when they exist. New programs need not use this macro.
    
    - - - - -
    1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00
    runhaskell
    - - - - -
    e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00
    Document how to quote certain names with spaces
    
    Quoting a name for Template Haskell is a bit tricky if the second
    character of that name is a single quote. The User's Guide falsely
    claimed that it was impossible. Document how to do it.
    
    Fixes #22236
    - - - - -
    0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00
    Fix syntax
    - - - - -
    a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00
    Fix manifest filename when writing Windows .rc files
    
    As noted in #12971, we previously used `show` which resulted in
    inappropriate escaping of non-ASCII characters.
    
    - - - - -
    30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00
    Write response files in UTF-8 on Windows
    
    This reverts the workaround introduced in
    f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file
    logic to write response files with the `latin1` encoding to workaround
    `gcc`'s lacking Unicode support. This is now no longer necessary (and in
    fact actively unhelpful) since we rather use Clang.
    
    - - - - -
    b8304648 by Matthew Farkas-Dyck at 2022-10-21T09:11:56-04:00
    Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`.
    
    - - - - -
    09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00
    template-haskell: Improve documentation of strictness annotation types
    
    Before it was undocumentated that DecidedLazy can be returned by
    reifyConStrictness for strict fields. This can happen when a field has
    an unlifted type or its the single field of a newtype constructor.
    
    Fixes #21380
    
    - - - - -
    88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00
    Delete `eqExpr`, since GHC 9.4 has been released.
    
    - - - - -
    86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00
    Introduce a standard thunk for allocating strings
    
    Currently for a top-level closure in the form
    
        hey = unpackCString# x
    
    we generate code like this:
    
        Main.hey_entry() //  [R1]
                 { info_tbls: [(c2T4,
                                label: Main.hey_info
                                rep: HeapRep static { Thunk }
                                srt: Nothing)]
                   stack_info: arg_space: 8 updfr_space: Just 8
                 }
             {offset
               c2T4: // global
                   _rqm::P64 = R1;
                   if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6;
               c2T5: // global
                   R1 = _rqm::P64;
                   call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8;
               c2T6: // global
                   (_c2T1::I64) = call "ccall" arg hints:  [PtrHint,
                                                            PtrHint]  result hints:  [PtrHint] newCAF(BaseReg, _rqm::P64);
                   if (_c2T1::I64 == 0) goto c2T3; else goto c2T2;
               c2T3: // global
                   call (I64[_rqm::P64])() args: 8, res: 0, upd: 8;
               c2T2: // global
                   I64[Sp - 16] = stg_bh_upd_frame_info;
                   I64[Sp - 8] = _c2T1::I64;
                   R2 = hey1_r2Gg_bytes;
                   Sp = Sp - 16;
                   call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24;
             }
         }
    
    This code is generated for every string literal. Only difference between
    top-level closures like this is the argument for the bytes of the string
    (hey1_r2Gg_bytes in the code above).
    
    With this patch we introduce a standard thunk in the RTS, called
    stg_MK_STRING_info, that does what `unpackCString# x` does, except it
    gets the bytes address from the payload. Using this, for the closure
    above, we generate this:
    
        Main.hey_closure" {
            Main.hey_closure:
                const stg_MK_STRING_info;
                const 0; // padding for indirectee
                const 0; // static link
                const 0; // saved info
                const hey1_r1Gg_bytes; // the payload
        }
    
    This is much smaller in code.
    
    Metric Decrease:
        T10421
        T11195
        T12150
        T12425
        T16577
        T18282
        T18698a
        T18698b
    
    Co-Authored By: Ben Gamari <ben at well-typed.com>
    
    - - - - -
    1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00
    hadrian: Improve error for wrong key/value errors.
    
    - - - - -
    11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00
    Class layout info (#19623)
    
    Updates the haddock submodule.
    
    - - - - -
    f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00
    Pin used way for test cloneMyStack (#21977)
    
    cloneMyStack checks the order of closures on the cloned stack. This may
    change for different ways. Thus we limit this test to one way (normal).
    
    - - - - -
    0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00
    Convert Diagnostics in GHC.Tc.Gen.Splice (#20116)
    
    Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with
    structured diagnostics.
    
    closes #20116
    
    - - - - -
    8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00
    Improve stg lint for unboxed sums.
    
    It now properly lints cases where sums end up distributed
    over multiple args after unarise.
    
    Fixes #22026.
    
    - - - - -
    41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00
    Fix binder-swap bug
    
    This patch fixes #21229 properly, by avoiding doing a
    binder-swap on dictionary Ids.  This is pretty subtle, and explained
    in Note [Care with binder-swap on dictionaries].
    
    Test is already in simplCore/should_run/T21229
    
    This allows us to restore a feature to the specialiser that we had
    to revert: see Note [Specialising polymorphic dictionaries].
    (This is done in a separate patch.)
    
    I also modularised things, using a new function scrutBinderSwap_maybe
    in all the places where we are (effectively) doing a binder-swap,
    notably
    
    * Simplify.Iteration.addAltUnfoldings
    * SpecConstr.extendCaseBndrs
    
    In Simplify.Iteration.addAltUnfoldings I also eliminated a guard
        Many <- idMult case_bndr
    because we concluded, in #22123, that it was doing no good.
    
    - - - - -
    5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00
    Make the specialiser handle polymorphic specialisation
    
    Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a
    program run (a lot) slower, because less specialisation took place
    overall. It turned out that the specialiser was missing opportunities
    because of quantified type variables.
    
    It was quite easy to fix. The story is given in
        Note [Specialising polymorphic dictionaries]
    
    Two other minor fixes in the specialiser
    
    * There is no benefit in specialising data constructor /wrappers/.
      (They can appear overloaded because they are given a dictionary
      to store in the constructor.)  Small guard in canSpecImport.
    
    * There was a buglet in the UnspecArg case of specHeader, in the
      case where there is a dead binder. We need a LitRubbish filler
      for the specUnfolding stuff.  I expanded
      Note [Drop dead args from specialisations] to explain.
    
    There is a 4% increase in compile time for T15164, because we generate
    more specialised code.  This seems OK.
    
    Metric Increase:
        T15164
    
    - - - - -
    7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00
    Numeric exceptions: replace FFI calls with primops
    
    ghc-bignum needs a way to raise numerical exceptions defined in base
    package. At the time we used FFI calls into primops defined in the RTS.
    These FFI calls had to be wrapped into hacky bottoming functions because
    "foreign import prim" syntax doesn't support giving a bottoming demand
    to the foreign call (cf #16929).
    
    These hacky wrapper functions trip up the JavaScript backend (#21078)
    because they are polymorphic in their return type. This commit
    replaces them with primops very similar to raise# but raising predefined
    exceptions.
    
    - - - - -
    0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00
    Enable popcount rewrite rule when cross-compiling
    
    The comment applies only when host's word size < target's word size.
    So we can relax the guard.
    
    - - - - -
    a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00
    Add GHC.SysTools.Cpp module
    
    Move doCpp out of the driver to be able to use it in the upcoming JS backend.
    
    - - - - -
    1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00
    llvm-targets: Add datalayouts for big-endian AArch64 targets
    
    Fixes #22311.
    
    Thanks to @zeldin for the patch.
    
    - - - - -
    f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00
    Cleanup String/FastString conversions
    
    Remove unused mkPtrString and isUnderscoreFS.
    We no longer use mkPtrString since 1d03d8bef96.
    
    Remove unnecessary conversions between FastString and String and back.
    
    - - - - -
    f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00
    Broaden the in-scope sets for liftEnvSubst and composeTCvSubst
    
    This patch fixes two distinct (but closely related) buglets that were uncovered
    in #22235:
    
    * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover
      the variables in the range of the substitution. This patch fixes this by
      populating the in-scope set from the free variables in the range of the
      substitution.
    * `composeTCvSubst` applied the first substitution argument to the range of the
      second substitution argument, but the first substitution's in-scope set was
      not wide enough to cover the range of the second substutition. We similarly
      fix this issue in this patch by widening the first substitution's in-scope set
      before applying it.
    
    Fixes #22235.
    
    - - - - -
    0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00
    Introduce TcRnWithHsDocContext (#22346)
    
    Before this patch, GHC used withHsDocContext to attach an HsDocContext
    to an error message:
    
    	addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg)
    
    The problem with this approach is that it only works with
    TcRnUnknownMessage. But could we attach an HsDocContext to a
    structured error message in a generic way? This patch solves
    the problem by introducing a new constructor to TcRnMessage:
    
    	data TcRnMessage where
    	  ...
    	  TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage
    	  ...
    
    - - - - -
    9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00
    Testsuite: more precise test options
    
    Necessary for newer cross-compiling backends (JS, Wasm) that don't
    support TH yet.
    
    - - - - -
    f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00
    Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115)
    
    When faced with VDQ in the type of a term, GHC generates the following
    error message:
    
    	Illegal visible, dependent quantification in the type of a term
    	(GHC does not yet support this)
    
    Prior to this patch, there were two ways this message could have been
    generated and represented:
    
    	1. with the dedicated constructor TcRnVDQInTermType
    	    (see check_type in GHC.Tc.Validity)
    	2. with the transitional constructor TcRnUnknownMessage
    	    (see noNestedForallsContextsErr in GHC.Rename.Utils)
    
    Not only this led to duplication of code generating the final SDoc,
    it also made it tricky to track the origin of the error message.
    
    This patch fixes the problem by using TcRnVDQInTermType exclusively.
    
    - - - - -
    223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00
    Remove source location information from interface files
    
    This change aims to minimize source location information leaking
    into interface files, which makes ABI hashes dependent on the
    build location.
    
    The `Binary (Located a)` instance has been removed completely.
    
    It seems that the HIE interface still needs the ability to
    serialize SrcSpans, but by wrapping the instances, it should
    be a lot more difficult to inadvertently add source location
    information.
    
    - - - - -
    22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00
    Add missing dict binds to specialiser
    
    I had forgotten to add the auxiliary dict bindings to the
    /unfolding/ of a specialised function.  This caused #22358,
    which reports failures when compiling Hackage packages
         fixed-vector
         indexed-traversable
    
    Regression test T22357 is snarfed from indexed-traversable
    
    - - - - -
    a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00
    Fix broken link to `async` package
    
    - - - - -
    750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00
    Pass correct package db when testing stage1.
    
    It used to pick the db for stage-2 which obviously didn't work.
    
    - - - - -
    ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00
    Minor SDoc-related cleanup
    
    * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel
      for a function using CStyle (analogous to pprAsmLabel)
    * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable.
    * Move calls to 'text' right next to literals, to make sure the text/str
      rule is triggered.
    * Remove FastString/String roundtrip in Tc.Deriv.Generate
    * Introduce showSDocForUser', which abstracts over a pattern in
      GHCi.UI
    
    - - - - -
    c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00
    CI: Don't run lint-submods on nightly
    
    Fixes #22325
    
    - - - - -
    270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00
    Start the deprecation process for GHC.Pack
    
    - - - - -
    d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00
    Drop a kludge for binutils<2.17, which is now over 10 years old.
    
    - - - - -
    8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
    rts: `name` argument of `createOSThread` can be `const`
    
    Since we don't intend to ever change the incoming string, declare this
    to be true.
    
    Also, in the POSIX implementation, the argument is no longer `STG_UNUSED`
    (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path.
    
    See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080
    
    - - - - -
    13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
    rts: fix lifetime of `start_thread`s `name` value
    
    Since, unlike the code in ee0deb8054da2^, usage of the `name` value
    passed to `createOSThread` now outlives said function's lifetime, and
    could hence be released by the caller by the time the new thread runs
    `start_thread`, it needs to be copied.
    
    See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080
    See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066
    
    - - - - -
    edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
    rts: fix OS thread naming in ticker
    
    Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed
    when invoking `createOSThread`. However, the 'ticker' has some
    thread-creation code which doesn't rely on `createOSThread`, yet also
    uses `pthread_setname_np`.
    
    This patch enforces all thread creation to go through a single
    function, which uses the (correct) thread-naming code introduced in
    ee0deb805.
    
    See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206
    See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066
    
    - - - - -
    b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00
    Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core
    
    - - - - -
    30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00
    ThToHs: fix overzealous parenthesization
    
    Before this patch, when converting from TH.Exp to LHsExpr GhcPs,
    the compiler inserted more parentheses than required:
    
    	((f a) (b + c)) d
    
    This was happening because the LHS of the function application was
    parenthesized as if it was the RHS.
    
    Now we use funPrec and appPrec appropriately and produce sensibly
    parenthesized expressions:
    
    	f a (b + c) d
    
    I also took the opportunity to remove the special case for LamE,
    which was not special at all and simply duplicated code.
    
    - - - - -
    0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00
    Add accurate skolem info when quantifying
    
    Ticket #22379 revealed that skolemiseQuantifiedTyVar was
    dropping the passed-in skol_info on the floor when it encountered
    a SkolemTv.  Bad!  Several TyCons thereby share a single SkolemInfo
    on their binders, which lead to bogus error reports.
    
    - - - - -
    38d19668 by Fendor at 2022-11-01T12:50:25-04:00
    Expose UnitEnvGraphKey for user-code
    
    - - - - -
    77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00
    Shrink test case for #22357
    
    Ryan Scott offered a cut-down repro case
    (60 lines instead of more than 700 lines)
    
    - - - - -
    4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00
    Add two tests for #17366
    
    - - - - -
    6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: introduce (and use) `STG_NORETURN`
    
    Instead of sprinkling the codebase with
    `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for,
    basically, the same thing) similar to `STG_UNUSED` and others, and
    update the code to use this macro where applicable.
    
    - - - - -
    f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: consistently use `STG_UNUSED`
    
    - - - - -
    81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: introduce (and use) `STG_USED`
    
    Similar to `STG_UNUSED`, have a specific macro for
    `__attribute__(used)`.
    
    - - - - -
    41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: introduce (and use) `STG_MALLOC`
    
    Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC`
    macro definition and use it instead.
    
    - - - - -
    3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: use `STG_UNUSED`
    
    - - - - -
    9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: specify deallocator of allocating functions
    
    This patch adds a new `STG_MALLOC1` macro (and its counterpart
    `STG_MALLOC2` for completeness) which allows to specify the deallocation
    function to be used with allocations of allocating functions, and
    applies it to `stg*allocBytes`.
    
    It also fixes a case where `free` was used to free up an
    `stgMallocBytes` allocation, found by the above change.
    
    See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
    
    - - - - -
    81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: use `alloc_size` attribute
    
    This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which
    allow to set the `alloc_size` attribute on functions, when available.
    
    See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
    
    - - - - -
    99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: add and use `STG_RETURNS_NONNULL`
    
    See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
    
    - - - - -
    c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: tag `stgStrndup` as `STG_MALLOC`
    
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
    
    - - - - -
    ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00
    Move Symbol implementation note out of public haddock
    
    - - - - -
    284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00
    gen-dll: Drop it
    
    Currently it is only used by the make build system, which is soon to be
    retired, and it has not built since 41cf758b. We may need to reintroduce
    it when dynamic-linking support is introduced on Windows, but we will
    cross that bridge once we get there.
    
    Fixes #21753.
    
    - - - - -
    24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00
    Port foundation numeric tests to GHC testsuite
    
    This commit ports the numeric tests which found a regression in GHC-9.4.
    
    https://github.com/haskell-foundation/foundation/issues/571
    
    Included in the commit is a simple random number generator and
    simplified QuickCheck implementation. In future these could be factored
    out of this standalone file and reused as a general purpose library
    which could be used for other QuickCheck style tests in the testsuite.
    
    See #22282
    
    - - - - -
    d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00
    git: ignore HIE files.
    
    Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci.
    
    - - - - -
    a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00
    Clarify status of bindings in WholeCoreBindings
    
    Gergo points out that these bindings are tidied, rather than prepd as
    the variable claims. Therefore we update the name of the variable to
    reflect reality and add a comment to the data type to try to erase any
    future confusion.
    
    Fixes #22307
    
    - - - - -
    634da448 by Andrew Lelechenko at 2022-11-03T21:25:02+00:00
    Fix haddocks for GHC.IORef
    
    - - - - -
    31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00
    Export pprTrace and friends from GHC.Prelude.
    
    Introduces GHC.Prelude.Basic which can be used in modules which are a
    dependency of the ppr code.
    
    - - - - -
    bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00
    CI: Allow hadrian-ghc-in-ghci to run in nightlies
    
    Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs
    to mark it as "optional" so it can run if the job doesn't exist.
    
    Fixes #22396.
    
    - - - - -
    3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00
    Minor refactor around FastStrings
    
    Pass FastStrings to functions directly, to make sure the rule
    for fsLit "literal" fires.
    
    Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph.
    
    - - - - -
    e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00
    Bump unix submodule to 2.8.0.0
    
    Also bumps process and ghc-boot bounds on unix.
    
    For hadrian, when cross-compiling, we add -Wwarn=unused-imports
    -Wwarn=unused-top-binds to validation flavour. Further fixes in unix
    and/or hsc2hs is needed to make it completely free of warnings; for
    the time being, this change is needed to unblock other
    cross-compilation related work.
    
    - - - - -
    42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00
    Bump Win32 submodule to 2.13.4.0
    
    Fixes #22098
    
    - - - - -
    e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00
    Bump ci-images revision
    
    ci-images has recently been updated, including changes needed for wasm32-wasi CI.
    
    - - - - -
    88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00
    Bump gmp-tarballs submodule
    
    Includes a fix for wasm support, doesn't impact other targets.
    
    - - - - -
    69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00
    Bump haskeline submodule
    
    Includes a fix for wasm support, doesn't impact other targets.
    
    - - - - -
    5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00
    bump llvm upper bound
    - - - - -
    68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00
    Define `Infinite` list and use where appropriate.
    
    Also add perf test for infinite list fusion.
    
    In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names.
    
    Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists].
    
    - - - - -
    ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00
    Fix TypeData issues (fixes #22315 and #22332)
    
    There were two bugs here:
    
    1. Treating type-level constructors as PromotedDataCon doesn't always
       work, in particular because constructors promoted via DataKinds are
       called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b)
       Fix: guard these cases with isDataKindsPromotedDataCon.
    
    2. Type-level constructors were sent to the code generator, producing
       things like constructor wrappers. (Tests T22332a, T22332b)
       Fix: test for them in isDataTyCon.
    
    Other changes:
    
    * changed the marking of "type data" DataCon's as suggested by SPJ.
    
    * added a test TDGADT for a type-level GADT.
    
    * comment tweaks
    
    * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo
      is used only for pretty printing, not for typechecking. (SPJ)
    
    - - - - -
    132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00
    Clarify msum/asum documentation
    
    - - - - -
    bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00
    Add example for (<$)
    
    - - - - -
    080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00
    Document what Alternative/MonadPlus instances actually do
    
    - - - - -
    92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00
    Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117)
    
    The following `TcRnDiagnostic` messages have been introduced:
    
    TcRnWarnUnsatisfiedMinimalDefinition
    TcRnMisplacedInstSig
    TcRnBadBootFamInstDeclErr
    TcRnIllegalFamilyInstance
    TcRnAssocInClassErr
    TcRnBadFamInstDecl
    TcRnNotOpenFamily
    
    - - - - -
    90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00
    GHCi tags generation phase 2
    
    see #19884
    
    - - - - -
    f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00
    Fire RULES in the Specialiser
    
    The Specialiser has, for some time, fires class-op RULES in the
    specialiser itself: see
       Note [Specialisation modulo dictionary selectors]
    
    This MR beefs it up a bit, so that it fires /all/ RULES in the
    specialiser, not just class-op rules.  See
       Note [Fire rules in the specialiser]
    The result is a bit more specialisation; see test
       simplCore/should_compile/T21851_2
    
    This pushed me into a bit of refactoring.  I made a new data types
    GHC.Core.Rules.RuleEnv, which combines
      - the several source of rules (local, home-package, external)
      - the orphan-module dependencies
    
    in a single record for `getRules` to consult.  That drove a bunch of
    follow-on refactoring, including allowing me to remove
    cr_visible_orphan_mods from the CoreReader data type.
    
    I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule.
    
    The reorganisation in the Simplifier improve compile times a bit
    (geom mean -0.1%), but T9961 is an outlier
    
    Metric Decrease:
        T9961
    
    - - - - -
    2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00
    Make indexError work better
    
    The problem here is described at some length in
    Note [Boxity for bottoming functions] and
    Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal.
    
    This patch adds a SPECIALISE pragma for indexError, which
    makes it much less vulnerable to the problem described in
    these Notes.
    
    (This came up in another line of work, where a small change made
    indexError do reboxing (in nofib/spectral/simple/table_sort)
    that didn't happen before my change.  I've opened #22404
    to document the fagility.
    
    - - - - -
    399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00
    Fix DsUselessSpecialiseForClassMethodSelector msg
    
    The error message for DsUselessSpecialiseForClassMethodSelector
    was just wrong (a typo in some earlier work); trivial fix
    
    - - - - -
    dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00
    WorkWrap: Unboxing unboxed tuples is not always useful (#22388)
    
    See Note [Unboxing through unboxed tuples].
    
    Fixes #22388.
    
    - - - - -
    1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00
    Boxity: Handle argument budget of unboxed tuples correctly (#21737)
    
    Now Budget roughly tracks the combined width of all arguments after unarisation.
    See the changes to `Note [Worker argument budgets]`.
    
    Fixes #21737.
    
    - - - - -
    2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00
    autoconf: check getpid getuid raise
    
    This patch adds checks for getpid, getuid and raise in autoconf. These
    functions are absent in wasm32-wasi and thus needs to be checked.
    
    - - - - -
    f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00
    hadrian: add -Wwarn only for cross-compiling unix
    
    - - - - -
    2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00
    hadrian: add targetSupportsThreadedRts flag
    
    This patch adds a targetSupportsThreadedRts flag to indicate whether
    the target supports the threaded rts at all, different from existing
    targetSupportsSMP that checks whether -N is supported by the RTS. All
    existing flavours have also been updated accordingly to respect this
    flags.
    
    Some targets (e.g. wasm32-wasi) does not support the threaded rts,
    therefore this flag is needed for the default flavours to work. It
    makes more sense to have proper autoconf logic to check for threading
    support, but for the time being, we just set the flag to False iff the
    target is wasm32.
    
    - - - - -
    8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00
    Fix Cmm symbol kind
    
    - - - - -
    b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00
    add the two key graph modules from Martin Erwig's FGL
    
    Martin Erwig's FGL (Functional Graph Library) provides an "inductive"
    representation of graphs.  A general graph has labeled nodes and
    labeled edges.  The key operation on a graph is to decompose it by
    removing one node, together with the edges that connect the node to
    the rest of the graph.  There is also an inverse composition
    operation.
    
    The decomposition and composition operations make this representation
    of graphs exceptionally well suited to implement graph algorithms in
    which the graph is continually changing, as alluded to in #21259.
    
    This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the
    interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides
    an implementation.  Both modules are taken from `fgl-5.7.0.3` on
    Hackage, with these changes:
    
      - Copyright and license text have been copied into the files
        themselves, not stored separately.
    
      - Some calls to `error` have been replaced with calls to `panic`.
    
      - Conditional-compilation support for older versions of GHC,
        `containers`, and `base` has been removed.
    
    - - - - -
    3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00
    add new modules for reducibility and WebAssembly translation
    
    - - - - -
    df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00
    Add support for the wasm32-wasi target tuple
    
    This patch adds the wasm32-wasi tuple support to various places in the
    tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen
    logic will come in subsequent commits.
    
    - - - - -
    32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00
    deriveConstants: parse .ll output for wasm32 due to broken nm
    
    This patch makes deriveConstants emit and parse an .ll file when
    targeting wasm. It's a necessary workaround for broken llvm-nm on
    wasm, which isn't capable of reporting correct constant values when
    parsing an object.
    
    - - - - -
    07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking
    
    Unlike other targets, wasm requires the function signature of the call
    site and callee to strictly match. So in Cmm, when we call a C
    function that actually returns a value, we need to add an _unused
    local variable to receive it, otherwise type error awaits.
    
    An even bigger problem is calling variadic functions like barf() and
    such. Cmm doesn't support CAPI calling convention yet, so calls to
    variadic functions just happen to work in some cases with some
    target's ABI. But again, it doesn't work with wasm. Fortunately, the
    wasm C ABI lowers varargs to a stack pointer argument, and it can be
    passed NULL when no other arguments are expected to be passed. So we
    also add the additional unused NULL arguments to those functions, so
    to fix wasm, while not affecting behavior on other targets.
    
    - - - - -
    00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00
    testsuite: correct sleep() signature in T5611
    
    In libc, sleep() returns an integer. The ccall type signature should
    match the libc definition, otherwise it causes linker error on wasm.
    
    - - - - -
    d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: prefer ffi_type_void over FFI_TYPE_VOID
    
    This patch uses ffi_type_void instead of FFI_TYPE_VOID in the
    interpreter code, since the FFI_TYPE_* macros are not available in
    libffi-wasm32 yet. The libffi public documentation also only mentions
    the lower-case ffi_type_* symbols, so we should prefer the lower-case
    API here.
    
    - - - - -
    4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: don't define RTS_USER_SIGNALS when signal.h is not present
    
    In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related
    logic is guarded with RTS_USER_SIGNALS. This patch extends the range
    of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff
    signal.h is actually detected by autoconf. This is required for
    wasm32-wasi to work, which lacks signals.
    
    - - - - -
    3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: use HAVE_GETPID to guard subprocess related logic
    
    We've previously added detection of getpid() in autoconf. This patch
    uses HAVE_GETPID to guard some subprocess related logic in the RTS.
    This is required for certain targets like wasm32-wasi, where there
    isn't a process model at all.
    
    - - - - -
    50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined
    
    This patch adds the missing THREADED_RTS CPP guard to mutex logic in
    IPE.c.
    
    - - - - -
    ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: genericRaise: use exit() instead when not HAVE_RAISE
    
    We check existence of raise() in autoconf, and here, if not
    HAVE_RAISE, we should use exit() instead in genericRaise.
    
    - - - - -
    c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: checkSuid: don't do it when not HAVE_GETUID
    
    When getuid() is not present, don't do checkSuid since it doesn't make
    sense anyway on that target.
    
    - - - - -
    d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: wasm32 placeholder linker
    
    This patch adds minimal placeholder linker logic for wasm32, just
    enough to unblock compiling rts on wasm32. RTS linker functionality is
    not properly implemented yet for wasm32.
    
    - - - - -
    65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: RtsStartup: chdir to PWD on wasm32
    
    This patch adds a wasm32-specific behavior to RtsStartup logic. When
    the PWD environment variable is present, we chdir() to it first.
    
    The point is to workaround an issue in wasi-libc: it's currently not
    possible to specify the initial working directory, it always defaults
    to / (in the virtual filesystem mapped from some host directory). For
    some use cases this is sufficient, but there are some other cases
    (e.g. in the testsuite) where the program needs to access files
    outside.
    
    - - - - -
    65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: no timer for wasm32
    
    Due to the lack of threads, on wasm32 there can't be a background
    timer that periodically resets the context switch flag. This patch
    disables timer for wasm32, and also makes the scheduler default to -C0
    on wasm32 to avoid starving threads.
    
    - - - - -
    e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32
    
    The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32.
    
    - - - - -
    0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32
    
    On wasm32 there isn't a process model at all, so no
    FORKPROCESS_PRIMOP_SUPPORTED.
    
    - - - - -
    88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32
    
    libffi-wasm32 only supports non-standard libffi closure api via
    ffi_alloc_prep_closure(). This patch implements
    ffi_alloc_prep_closure() via standard libffi closure api on other
    targets, and uses it to implement adjustor functionality.
    
    - - - - -
    15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: don't return memory to OS on wasm32
    
    This patch makes the storage manager not return any memory on wasm32.
    The detailed reason is described in Note [Megablock allocator on
    wasm].
    
    - - - - -
    631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: make flushExec a no-op on wasm32
    
    This patch makes flushExec a no-op on wasm32, since there's no such
    thing as executable memory on wasm32 in the first place.
    
    - - - - -
    654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32
    
    This patch prevents resetTerminalSettings and freeThreadingResources
    to be called on wasm32, since there is no TTY or threading on wasm32
    at all.
    
    - - - - -
    f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: OSThreads.h: stub types for wasm32
    
    This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey
    types for wasm32, just enough to unblock compiling RTS. Any
    threading-related functionality has been patched to be disabled on
    wasm32.
    
    - - - - -
    a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00
    Add register mapping for wasm32
    
    This patch adds register mapping logic for wasm32. See Note [Register
    mapping on WebAssembly] in wasm32 NCG for more description.
    
    - - - - -
    d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: wasm32 specific logic
    
    This patch adds the rest of wasm32 specific logic in rts.
    
    - - - - -
    7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00
    base: fall back to using monotonic clock to emulate cputime on wasm32
    
    On wasm32, we have to fall back to using monotonic clock to emulate
    cputime, since there's no native support for cputime as a clock id.
    
    - - - - -
    5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00
    base: more autoconf checks for wasm32
    
    This patch adds more autoconf checks to base, since those functions
    and headers may exist on other POSIX systems but don't exist on
    wasm32.
    
    - - - - -
    00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00
    base: avoid using unsupported posix functionality on wasm32
    
    This base patch avoids using unsupported posix functionality on
    wasm32.
    
    - - - - -
    34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00
    autoconf: set CrossCompiling=YES in cross bindist configure
    
    This patch fixes the bindist autoconf logic to properly set
    CrossCompiling=YES when it's a cross GHC bindist.
    
    - - - - -
    5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: add util functions for UniqFM and UniqMap
    
    This patch adds addToUFM_L (backed by insertLookupWithKey),
    addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util
    functions are used by the wasm32 NCG.
    
    - - - - -
    177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00
    driver: avoid -Wl,--no-as-needed for wasm32
    
    The driver used to pass -Wl,--no-as-needed for LLD linking. This is
    actually only supported for ELF targets, and must be avoided when
    linking for wasm32.
    
    - - - - -
    06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: allow big arith for wasm32
    
    This patch enables Cmm big arithmetic on wasm32, since 64-bit
    arithmetic can be efficiently lowered to wasm32 opcodes.
    
    - - - - -
    df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00
    driver: pass -Wa,--no-type-check for wasm32 when runAsPhase
    
    This patch passes -Wa,--no-type-check for wasm32 when compiling
    assembly. See the added note for more detailed explanation.
    
    - - - - -
    c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: enforce cmm switch planning for wasm32
    
    This patch forcibly enable Cmm switch planning for wasm32, since
    otherwise the switch tables we generate may exceed the br_table
    maximum allowed size.
    
    - - - - -
    a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: annotate CmmFileEmbed with blob length
    
    This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG
    needs to know the precise size of each data segment.
    
    - - - - -
    36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: wasm32 NCG
    
    This patch adds the wasm32 NCG.
    
    - - - - -
    435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00
    ci: add wasm32-wasi release bindist job
    
    - - - - -
    d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00
    ci: add a stronger test for cross bindists
    
    This commit adds a simple GHC API program that parses and reprints the
    original hello world program used for basic testing of cross bindists.
    Before there's full cross-compilation support in the test suite
    driver, this provides better coverage than the original test.
    
    - - - - -
    8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00
    CODEOWNERS: add wasm-specific maintainers
    
    - - - - -
    707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00
    Clarify that LLVM upper bound is non-inclusive during configure (#22411)
    
    - - - - -
    430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00
    rts: Check for program_invocation_short_name via autoconf
    
    Instead of assuming support on all Linuxes.
    
    - - - - -
    6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00
    driver: Fix -fdefer-diagnostics flag
    
    The `withDeferredDiagnostics` wrapper wasn't doing anything because the
    session it was modifying wasn't used in hsc_env. Therefore the fix is
    simple, just push the `getSession` call into the scope of
    `withDeferredDiagnostics`.
    
    Fixes #22391
    
    - - - - -
    d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00
    Add a fast path for data constructor workers
    
    See Note [Fast path for data constructors] in
    GHC.Core.Opt.Simplify.Iteration
    
    This bypasses lots of expensive logic, in the special case of
    applications of data constructors.  It is a surprisingly worthwhile
    improvement, as you can see in the figures below.
    
    Metrics: compile_time/bytes allocated
    ------------------------------------------------
              CoOpt_Read(normal)   -2.0%
        CoOpt_Singletons(normal)   -2.0%
        ManyConstructors(normal)   -1.3%
                  T10421(normal)   -1.9% GOOD
                 T10421a(normal)   -1.5%
                  T10858(normal)   -1.6%
                  T11545(normal)   -1.7%
                  T12234(optasm)   -1.3%
                  T12425(optasm)   -1.9% GOOD
                  T13035(normal)   -1.0% GOOD
                  T13056(optasm)   -1.8%
                  T13253(normal)   -3.3% GOOD
                  T15164(normal)   -1.7%
                  T15304(normal)   -3.4%
                  T15630(normal)   -2.8%
                  T16577(normal)   -4.3% GOOD
                  T17096(normal)   -1.1%
                  T17516(normal)   -3.1%
                  T18282(normal)   -1.9%
                  T18304(normal)   -1.2%
                 T18698a(normal)   -1.2% GOOD
                 T18698b(normal)   -1.5% GOOD
                  T18923(normal)   -1.3%
                   T1969(normal)   -1.3% GOOD
                  T19695(normal)   -4.4% GOOD
                 T21839c(normal)   -2.7% GOOD
                 T21839r(normal)   -2.7% GOOD
                   T4801(normal)   -3.8% GOOD
                   T5642(normal)   -3.1% GOOD
                   T6048(optasm)   -2.5% GOOD
                   T9020(optasm)   -2.7% GOOD
                   T9630(normal)   -2.1% GOOD
                   T9961(normal)  -11.7% GOOD
                   WWRec(normal)   -1.0%
    
                       geo. mean   -1.1%
                       minimum    -11.7%
                       maximum     +0.1%
    
    Metric Decrease:
        T10421
        T12425
        T13035
        T13253
        T16577
        T18698a
        T18698b
        T1969
        T19695
        T21839c
        T21839r
        T4801
        T5642
        T6048
        T9020
        T9630
        T9961
    
    - - - - -
    3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00
    Use a more efficient printer for code generation (#21853)
    
    The changes in `GHC.Utils.Outputable` are the bulk of the patch
    and drive the rest.
    The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc`
    and support printing directly to a handle with `bPutHDoc`.
    See Note [SDoc versus HDoc] and Note [HLine versus HDoc].
    
    The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic
    over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF
    and dependencies (printing module names, labels etc.).
    
    Co-authored-by: Alexis King <lexi.lambda at gmail.com>
    
    Metric Decrease:
        CoOpt_Read
        ManyAlternatives
        ManyConstructors
        T10421
        T12425
        T12707
        T13035
        T13056
        T13253
        T13379
        T18140
        T18282
        T18698a
        T18698b
        T1969
        T20049
        T21839c
        T21839r
        T3064
        T3294
        T4801
        T5321FD
        T5321Fun
        T5631
        T6048
        T783
        T9198
        T9233
    
    - - - - -
    6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00
    Weaken wrinkle 1 of Note [Scrutinee Constant Folding]
    
    Fixes #22375.
    
    Co-authored-by:  Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00
    Fix fragile RULE setup in GHC.Float
    
    In testing my type-vs-constraint patch I found that the handling
    of Natural literals was very fragile -- and I somehow tripped that
    fragility in my work.
    
    So this patch fixes the fragility.
    See Note [realToFrac natural-to-float]
    
    This made a big (9%) difference in one existing test in
    perf/should_run/T1-359
    
    Metric Decrease:
        T10359
    
    - - - - -
    778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00
    Type vs Constraint: finally nailed
    
    This big patch addresses the rats-nest of issues that have plagued
    us for years, about the relationship between Type and Constraint.
    See #11715/#21623.
    
    The main payload of the patch is:
    * To introduce CONSTRAINT :: RuntimeRep -> Type
    * To make TYPE and CONSTRAINT distinct throughout the compiler
    
    Two overview Notes in GHC.Builtin.Types.Prim
    
    * Note [TYPE and CONSTRAINT]
    
    * Note [Type and Constraint are not apart]
      This is the main complication.
    
    The specifics
    
    * New primitive types (GHC.Builtin.Types.Prim)
      - CONSTRAINT
      - ctArrowTyCon (=>)
      - tcArrowTyCon (-=>)
      - ccArrowTyCon (==>)
      - funTyCon     FUN     -- Not new
      See Note [Function type constructors and FunTy]
      and Note [TYPE and CONSTRAINT]
    
    * GHC.Builtin.Types:
      - New type Constraint = CONSTRAINT LiftedRep
      - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in
    
    * Exploit the fact that Type and Constraint are distinct throughout GHC
      - Get rid of tcView in favour of coreView.
      - Many tcXX functions become XX functions.
        e.g. tcGetCastedTyVar --> getCastedTyVar
    
    * Kill off Note [ForAllTy and typechecker equality], in (old)
      GHC.Tc.Solver.Canonical.  It said that typechecker-equality should ignore
      the specified/inferred distinction when comparein two ForAllTys.  But
      that wsa only weakly supported and (worse) implies that we need a separate
      typechecker equality, different from core equality. No no no.
    
    * GHC.Core.TyCon: kill off FunTyCon in data TyCon.  There was no need for it,
      and anyway now we have four of them!
    
    * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo
      See Note [FunCo] in that module.
    
    * GHC.Core.Type.  Lots and lots of changes driven by adding CONSTRAINT.
      The key new function is sORTKind_maybe; most other changes are built
      on top of that.
    
      See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`.
    
    * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in
      kinding ForAllTys.  See new tules (FORALL1) and (FORALL2) in GHC.Core.Type.
      (The bug was that before (forall (cv::t1 ~# t2). blah), where
      blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be
      (TYPE LiftedRep).  See Note [Kinding rules for types] in GHC.Core.Type.
    
    * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType.
      Of course, no tcEqType any more.
    
    * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module:
      tyConsOfType, visVarsOfType, and occCheckExpand.  Refactoring only.
    
    * GHC.Builtin.Types.  Compiletely re-engineer boxingDataCon_maybe to
      have one for each /RuntimeRep/, rather than one for each /Type/.
      This dramatically widens the range of types we can auto-box.
      See Note [Boxing constructors] in GHC.Builtin.Types
      The boxing types themselves are declared in library ghc-prim:GHC.Types.
    
      GHC.Core.Make.  Re-engineer the treatment of "big" tuples (mkBigCoreVarTup
      etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially)
      types of kind Constraint. That allows the desugaring for arrows to work;
      it gathers up free variables (including dictionaries) into tuples.
      See  Note [Big tuples] in GHC.Core.Make.
    
      There is still work to do here: #22336. But things are better than
      before.
    
    * GHC.Core.Make.  We need two absent-error Ids, aBSENT_ERROR_ID for types of
      kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint.
      Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make;
      see Note [inlineId magic].
    
    * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion.  It is now called
      SelCo, and its fields are much more descriptive than the single Int we used to
      have.  A great improvement.  See Note [SelCo] in GHC.Core.TyCo.Rep.
    
    * GHC.Core.RoughMap.roughMatchTyConName.  Collapse TYPE and CONSTRAINT to
      a single TyCon, so that the rough-map does not distinguish them.
    
    * GHC.Core.DataCon
      - Mainly just improve documentation
    
    * Some significant renamings:
      GHC.Core.Multiplicity: Many -->  ManyTy (easier to grep for)
                             One  -->  OneTy
      GHC.Core.TyCo.Rep TyCoBinder      -->   GHC.Core.Var.PiTyBinder
      GHC.Core.Var      TyCoVarBinder   -->   ForAllTyBinder
                        AnonArgFlag     -->   FunTyFlag
                        ArgFlag         -->   ForAllTyFlag
      GHC.Core.TyCon    TyConTyCoBinder --> TyConPiTyBinder
      Many functions are renamed in consequence
      e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc
    
    * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type
        data FunTyFlag
          = FTF_T_T           -- (->)  Type -> Type
          | FTF_T_C           -- (-=>) Type -> Constraint
          | FTF_C_T           -- (=>)  Constraint -> Type
          | FTF_C_C           -- (==>) Constraint -> Constraint
    
    * GHC.Tc.Errors.Ppr.  Some significant refactoring in the TypeEqMisMatch case
      of pprMismatchMsg.
    
    * I made the tyConUnique field of TyCon strict, because I
      saw code with lots of silly eval's.  That revealed that
      GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because
      we pack the sum tag into a 6-bit field.  (Lurking bug squashed.)
    
    Fixes
    * #21530
    
    Updates haddock submodule slightly.
    
    Performance changes
    ~~~~~~~~~~~~~~~~~~~
    I was worried that compile times would get worse, but after
    some careful profiling we are down to a geometric mean 0.1%
    increase in allocation (in perf/compiler).  That seems fine.
    
    There is a big runtime improvement in T10359
    
    Metric Decrease:
        LargeRecord
        MultiLayerModulesTH_OneShot
        T13386
        T13719
    Metric Increase:
        T8095
    
    - - - - -
    360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00
    Indent closing "#-}" to silence HLint
    
    - - - - -
    e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00
    Fix merge conflict in T18355.stderr
    
    Fixes #22446
    
    - - - - -
    294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00
    Fix a trivial typo in dataConNonlinearType
    
    Fixes #22416
    
    - - - - -
    268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00
    eventlog: Ensure that IPE output contains actual info table pointers
    
    The refactoring in 866c736e introduced a rather subtle change in the
    semantics of the IPE eventlog output, changing the eventlog field from
    encoding info table pointers to "TNTC pointers" (which point to entry
    code when tables-next-to-code is enabled). Fix this.
    
    Fixes #22452.
    
    - - - - -
    d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00
    testsuite: Add tests for T22347
    
    These are fixed in recent versions but might as well add regression
    tests.
    
    See #22347
    
    - - - - -
    8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00
    testsuite: Improve output from tests which have failing pre_cmd
    
    There are two changes:
    
    * If a pre_cmd fails, then don't attempt to run the test.
    * If a pre_cmd fails, then print the stdout and stderr from running that
      command (which hopefully has a nice error message).
    
    For example:
    
    ```
    =====> 1 of 1 [0, 0, 0]
    *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2
    ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}".
    stdout:
    stderr:
    DefaultLifted.hs:19:13: error: [GHC-76037]
        Not in scope: type constructor or class ‘Typ’
        Suggested fix:
          Perhaps use one of these:
            ‘Type’ (imported from GHC.Tc.Utils.TcType),
            data constructor ‘Type’ (imported from GHC.Plugins)
       |
    19 | instance Eq Typ where
       |             ^^^
    make: *** [Makefile:17: package.test-defaulting-plugin] Error 1
    
    Performance Metrics (test environment: local):
    ```
    
    Fixes #22329
    
    - - - - -
    2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00
    Implement UNPACK support for sum types.
    
    This is based on osa's unpack_sums PR from ages past.
    
    The meat of the patch is implemented in dataConArgUnpackSum
    and described in Note [UNPACK for sum types].
    
    - - - - -
    78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00
    Expand on the need to clone local binders.
    
    Fixes #22402.
    
    - - - - -
    65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00
    Fix :i Constraint printing "type Constraint = Constraint"
    
    Since Constraint became a synonym for CONSTRAINT 'LiftedRep,
    we need the same code for handling printing as for the synonym
    Type = TYPE 'LiftedRep.
    This addresses the same bug as #18594, so I'm reusing the test.
    
    - - - - -
    94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00
    configure: Don't check for an unsupported version of LLVM
    
    The upper bound is not inclusive.
    
    Fixes #22449
    
    - - - - -
    02d3511b by Andrew Lelechenko at 2022-11-15T21:36:41-05:00
    Fix capitalization in haddock for TestEquality
    
    - - - - -
    08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00
    base: make Foreign.Marshal.Pool use RTS internal arena for allocation
    
    `Foreign.Marshal.Pool` used to call `malloc` once for each allocation
    request. Each `Pool` maintained a list of allocated pointers, and
    traverses the list to `free` each one of those pointers. The extra O(n)
    overhead is apparently bad for a `Pool` that serves a lot of small
    allocation requests.
    
    This patch uses the RTS internal arena to implement `Pool`, with these
    benefits:
    
    - Gets rid of the extra O(n) overhead.
    - The RTS arena is simply a bump allocator backed by the block
      allocator, each allocation request is likely faster than a libc
      `malloc` call.
    
    Closes #14762 #18338.
    
    - - - - -
    37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00
    Misc cleanup
    
    * Replace catMaybes . map f with mapMaybe f
    * Use concatFS to concatenate multiple FastStrings
    * Fix documentation of -exclude-module
    * Cleanup getIgnoreCount in GHCi.UI
    
    - - - - -
    b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00
    Give better errors for code corrupted by Unicode smart quotes (#21843)
    
    Previously, we emitted a generic and potentially confusing error during lexical
    analysis on programs containing smart quotes (“/”/‘/’). This commit adds
    smart quote-aware lexer errors.
    
    - - - - -
    cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00
    Make OpaqueNo* tests less noisy to unrelated changes
    
    - - - - -
    b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00
    Simplifier: Consider `seq` as a `BoringCtxt` (#22317)
    
    See `Note [Seq is boring]` for the rationale.
    
    Fixes #22317.
    
    - - - - -
    9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00
    Make T21839c's ghc/max threshold more forgiving
    
    - - - - -
    4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00
    Be more careful when reporting unbound RULE binders
    
    See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds.
    
    Fixes #22471.
    
    - - - - -
    e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00
    PPC NCG: Fix generating assembler code
    
    Fixes #22479
    
    - - - - -
    f2f9ef07 by Andrew Lelechenko at 2022-11-20T18:39:30-05:00
    Extend documentation for Data.IORef
    
    - - - - -
    ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00
    Buglet in GHC.Tc.Module.checkBootTyCon
    
    This lurking bug used the wrong function to compare two
    types in GHC.Tc.Module.checkBootTyCon
    
    It's hard to trigger the bug, which only came up during
    !9343, so there's no regression test in this MR.
    
    - - - - -
    451aeac3 by Andrew Lelechenko at 2022-11-20T18:40:44-05:00
    Add since pragmas for c_interruptible_open and hostIsThreaded
    
    - - - - -
    8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00
    Introduce CapIOManager as the per-cap I/O mangager state
    
    Rather than each I/O manager adding things into the Capability structure
    ad-hoc, we should have a common CapIOManager iomgr member of the
    Capability structure, with a common interface to initialise etc.
    
    The content of the CapIOManager struct will be defined differently for
    each I/O manager implementation. Eventually we should be able to have
    the CapIOManager be opaque to the rest of the RTS, and known just to the
    I/O manager implementation. We plan for that by making the Capability
    contain a pointer to the CapIOManager rather than containing the
    structure directly.
    
    Initially just move the Unix threaded I/O manager's control FD.
    
    - - - - -
    8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Add hook markCapabilityIOManager
    
    To allow I/O managers to have GC roots in the Capability, within the
    CapIOManager structure.
    
    Not yet used in this patch.
    
    - - - - -
    5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Move APPEND_TO_BLOCKED_QUEUE from cmm to C
    
    The I/O and delay blocking primitives for the non-threaded way
    currently access the blocked_queue and sleeping_queue directly.
    
    We want to move where those queues are to make their ownership clearer:
    to have them clearly belong to the I/O manager impls rather than to the
    scheduler. Ultimately we will want to change their representation too.
    
    It's inconvenient to do that if these queues are accessed directly from
    cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a
    C version appendToIOBlockedQueue(), and replace the open-coded
    sleeping_queue insertion with insertIntoSleepingQueue().
    
    - - - - -
    ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager
    
    The blocked_queue_{hd,tl} and the sleeping_queue are currently
    cooperatively managed between the scheduler and (some but not all of)
    the non-threaded I/O manager implementations.
    
    They lived as global vars with the scheduler, but are poked by I/O
    primops and the I/O manager backends.
    
    This patch is a step on the path towards making the management of I/O or
    timer blocking belong to the I/O managers and not the scheduler.
    
    Specifically, this patch moves the {blocked,sleeping}_queue from being
    global vars in the scheduler to being members of the CapIOManager struct
    within each Capability. They are not yet exclusively used by the I/O
    managers: they are still poked from a couple other places, notably in
    the scheduler before calling awaitEvent.
    
    - - - - -
    0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Remove the now-unused markScheduler
    
    The global vars {blocked,sleeping}_queue are now in the Capability and
    so get marked there via markCapabilityIOManager.
    
    - - - - -
    39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Move macros for checking for pending IO or timers
    
    from Schedule.h to Schedule.c and IOManager.h
    
    This is just moving, the next step will be to rejig them slightly.
    
    For the non-threaded RTS the scheduler needs to be able to test for
    there being pending I/O operation or pending timers. The implementation
    of these tests should really be considered to be part of the I/O
    managers and not part of the scheduler.
    
    - - - - -
    664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function
    
    These are the macros originaly from Scheduler.h, previously moved to
    IOManager.h, and now replaced with a single inline function
    anyPendingTimeoutsOrIO(). We can use a single function since the two
    macros were always checked together.
    
    Note that since anyPendingTimeoutsOrIO is defined for all IO manager
    cases, including threaded, we do not need to guard its use by cpp
     #if !defined(THREADED_RTS)
    
    - - - - -
    32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Expand emptyThreadQueues inline for clarity
    
    It was not really adding anything. The name no longer meant anything
    since those I/O and timeout queues do not belong to the scheuler.
    
    In one of the two places it was used, the comments already had to
    explain what it did, whereas now the code matches the comment nicely.
    
    - - - - -
    9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Move the awaitEvent declaration into IOManager.h
    
    And add or adjust comments at the use sites of awaitEvent.
    
    - - - - -
    054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Pass the Capability *cap explicitly to awaitEvent
    
    It is currently only used in the non-threaded RTS so it works to use
    MainCapability, but it's a bit nicer to pass the cap anyway. It's
    certainly shorter.
    
    - - - - -
    667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Pass the Capability *cap explicitly to appendToIOBlockedQueue
    
    And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler
    though not strictly necessary given that these primops are currently
    only used in the non-threaded RTS.
    
    - - - - -
    7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Reveiew feedback: improve one of the TODO comments
    
    The one about the nonsense (const False) test on WinIO for there being any IO
    or timers pending, leading to unnecessary complication later in the
    scheduler.
    
    - - - - -
    e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00
    Optimize getLevity.
    
    Avoid the intermediate data structures allocated by splitTyConApp.
    This avoids ~0.5% of allocations for a build using -O2.
    
    Fixes #22254
    
    - - - - -
    de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00
    hadrian:Set TNTC when running testsuite.
    
    - - - - -
    9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00
    Add unsafePtrEquality# restricted to UnliftedTypes
    
    - - - - -
    e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00
    utils/unlit: adjust parser to match Report spec
    
    The Haskell 2010 Report says that, for Latex-style Literate format,
    "Program code begins on the first line following a line that begins
    \begin{code}". (This is unchanged from the 98 Report)
    
    However the unlit.c implementation only matches a line that contains
    "\begin{code}" and nothing else. One consequence of this is that one
    cannot suffix Latex options to the code environment. I.e., this does
    not work:
    
    \begin{code}[label=foo,caption=Foo Code]
    
    Adjust the matcher to conform to the specification from the Report.
    
    The Haskell Wiki currently recommends suffixing a '%' to \begin{code}
    in order to deliberately hide a code block from Haskell. This is bad
    advice, as it's relying on an implementation quirk rather than specified
    behaviour. None-the-less, some people have tried to use it, c.f.
    <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html>
    
    An alternative solution is to define a separate, equivalent Latex
    environment to "code", that is functionally identical in Latex but
    ignored by unlit. This should not be a burden: users are required to
    manually define the code environment anyway, as it is not provided
    by the Latex verbatim or lstlistings packages usually used for
    presenting code in documents.
    
    Fixes #3549.
    
    - - - - -
    0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00
    Fix eventlog all option
    
    Previously it didn't enable/disable nonmoving_gc and ticky event types
    
    Fixes #21813
    
    - - - - -
    04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00
    Expand Note [Linear types] with the stance on linting linearity
    
    Per the discussion on #22123
    
    - - - - -
    e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00
    Add documentation on custom Prelude modules (#22228)
    
    Specifically, custom Prelude modules that are named `Prelude`.
    
    - - - - -
    b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00
    Don't let configure perform trivial substitutions (#21846)
    
    Hadrian now performs substitutions, especially to generate .cabal files
    from .cabal.in files. Two benefits:
    
    1. We won't have to re-configure when we modify thing.cabal.in. Hadrian
       will take care of this for us.
    
    2. It paves the way to allow the same package to be configured
       differently by Hadrian in the same session. This will be useful to
       fix #19174: we want to build a stage2 cross-compiler for the host
       platform and a stage1 compiler for the cross target platform in the
       same Hadrian session.
    
    - - - - -
    99aca26b by nineonine at 2022-11-23T12:47:11-05:00
    CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)
    
    Previously, when using `capi` calling convention in foreign declarations,
    code generator failed to handle const-cualified pointer return types.
    This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers`
    warning.
    
    `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases -
    special treatment was put in place to generate appropritetly qualified C
    wrapper that no longer triggers the above mentioned warning.
    
    Fixes #22043
    
    - - - - -
    040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00
    Scrub some no-warning pragmas.
    
    - - - - -
    178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00
    Check if the SDoc starts with a single quote (#22488)
    
    This patch fixes pretty-printing of character literals
    inside promoted lists and tuples.
    
    When we pretty-print a promoted list or tuple whose first element
    starts with a single quote, we want to add a space between the opening
    bracket and the element:
    
    	'[True]    -- ok
    	'[ 'True]  -- ok
    	'['True]   -- not ok
    
    If we don't add the space, we accidentally produce a character
    literal '['.
    
    Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST
    and tried to guess if it would be rendered with a single quote. However,
    it missed the case when the inner type was itself a character literal:
    
    	'[ 'x']  -- ok
    	'['x']   -- not ok
    
    Instead of adding this particular case, I opted for a more future-proof
    solution: check the SDoc directly. This way we can detect if the single
    quote is actually there instead of trying to predict it from the AST.
    The new function is called spaceIfSingleQuote.
    
    - - - - -
    11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00
    notes: Fix references to HPT space leak note
    
    Updating this note was missed when updating the HPT to the HUG.
    
    Fixes #22477
    
    - - - - -
    86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00
    Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115)
    
    Problem: avoid usage of TcRnMessageUnknown
    
    Solution:
    The following `TcRnMessage` messages has been introduced:
      TcRnNoRebindableSyntaxRecordDot
      TcRnNoFieldPunsRecordDot
      TcRnIllegalStaticExpression
      TcRnIllegalStaticFormInSplice
      TcRnListComprehensionDuplicateBinding
      TcRnEmptyStmtsGroup
      TcRnLastStmtNotExpr
      TcRnUnexpectedStatementInContext
      TcRnIllegalTupleSection
      TcRnIllegalImplicitParameterBindings
      TcRnSectionWithoutParentheses
    
    Co-authored-by: sheaf <sam.derbyshire at gmail.com>
    
    - - - - -
    d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00
    rts: fix missing Arena.h symbols in RtsSymbols.c
    
    It was an unfortunate oversight in !8961 and broke devel2 builds.
    
    - - - - -
    5943e739 by Andrew Lelechenko at 2022-11-25T04:38:28-05:00
    Assorted fixes to avoid Data.List.{head,tail}
    
    - - - - -
    1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00
    Review suggestions for assorted fixes to avoid Data.List.{head,tail}
    
    - - - - -
    13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00
    Print unticked promoted data constructors (#20531)
    
    Before this patch, GHC unconditionally printed ticks before promoted
    data constructors:
    
    	ghci> type T = True  -- unticked (user-written)
    	ghci> :kind! T
    	T :: Bool
    	= 'True              -- ticked (compiler output)
    
    After this patch, GHC prints ticks only when necessary:
    
    	ghci> type F = False    -- unticked (user-written)
    	ghci> :kind! F
    	F :: Bool
    	= False                 -- unticked (compiler output)
    
    	ghci> data False        -- introduce ambiguity
    	ghci> :kind! F
    	F :: Bool
    	= 'False                -- ticked by necessity (compiler output)
    
    The old behavior can be enabled by -fprint-redundant-promotion-ticks.
    
    Summary of changes:
    * Rename PrintUnqualified to NamePprCtx
    * Add QueryPromotionTick to it
    * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick)
    * Introduce -fprint-redundant-promotion-ticks
    
    Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht>
    
    - - - - -
    d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00
    Fix decomposition of TyConApps
    
    Ticket #22331 showed that we were being too eager to decompose
    a Wanted TyConApp, leading to incompleteness in the solver.
    
    To understand all this I ended up doing a substantial rewrite
    of the old Note [Decomposing equalities], now reborn as
    Note [Decomposing TyConApp equalities]. Plus rewrites of other
    related Notes.
    
    The actual fix is very minor and actually simplifies the code: in
    `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call
    `noMatchableIrreds`.  A closely related refactor: we stop trying to
    use the same "no matchable givens" function here as in
    `matchClassInst`.  Instead split into two much simpler functions.
    
    - - - - -
    2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00
    Redirect output of musttail attribute test
    
    Compilation output from test for support of musttail attribute leaked to
    the console.
    
    - - - - -
    0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00
    Move hs_mulIntMayOflo cbits to ghc-prim
    
    It's only used by wasm NCG at the moment, but ghc-prim is a more
    reasonable place for hosting out-of-line primops. Also, we only need a
    single version of hs_mulIntMayOflo.
    
    - - - - -
    36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00
    compiler: generate ccalls for clz/ctz/popcnt in wasm NCG
    
    We used to generate a single wasm clz/ctz/popcnt opcode, but it's
    wrong when it comes to subwords, so might as well generate ccalls for
    them. See #22470 for details.
    
    - - - - -
    d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00
    compiler: remove unused MO_U_MulMayOflo
    
    We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere.
    
    - - - - -
    8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00
    Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order
    
    Fixes: #217093
    Associated to #19415
    
    This change
    * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero;
    * Removes `cc_fundeps` in CDictCan as the check was incomplete;
    * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities
    * Adds 2 new tests for validating the change
       - testsuites/typecheck/should_compile/T21703.hs and
       - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs)
    * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors
    * Changes in Notes:
      - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances]
      - Added Note [Kind Equality Orientation] to visualize the kind flipping
      - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties]
    
    - - - - -
    646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00
    Change printing of sized literals to match the proposal
    
    Literals in Core were printed as e.g. 0xFF#16 :: Int16#.
    The proposal 451 now specifies syntax 0xFF#Int16.
    This change affects the Core printer only - more to be done later.
    
    Part of #21422.
    
    - - - - -
    02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00
    Be a bit more selective about floating bottoming expressions
    
    This MR arranges to float a bottoming expression to the top
    only if it escapes a value lambda.
    
    See #22494 and Note [Floating to the top] in SetLevels.
    
    This has a generally beneficial effect in nofib
    
    +-------------------------------++----------+
    |                               ||tsv (rel) |
    +===============================++==========+
    |           imaginary/paraffins ||   -0.93% |
    |                imaginary/rfib ||   -0.05% |
    |                      real/fem ||   -0.03% |
    |                    real/fluid ||   -0.01% |
    |                   real/fulsom ||   +0.05% |
    |                   real/gamteb ||   -0.27% |
    |                       real/gg ||   -0.10% |
    |                   real/hidden ||   -0.01% |
    |                      real/hpg ||   -0.03% |
    |                      real/scs ||  -11.13% |
    |         shootout/k-nucleotide ||   -0.01% |
    |               shootout/n-body ||   -0.08% |
    |   shootout/reverse-complement ||   -0.00% |
    |        shootout/spectral-norm ||   -0.02% |
    |             spectral/fibheaps ||   -0.20% |
    |           spectral/hartel/fft ||   -1.04% |
    |         spectral/hartel/solid ||   +0.33% |
    |     spectral/hartel/wave4main ||   -0.35% |
    |                 spectral/mate ||   +0.76% |
    +===============================++==========+
    |                     geom mean ||   -0.12% |
    
    The effect on compile time is generally slightly beneficial
    
    Metrics: compile_time/bytes allocated
    ----------------------------------------------
    MultiLayerModulesTH_OneShot(normal)  +0.3%
                      PmSeriesG(normal)  -0.2%
                      PmSeriesT(normal)  -0.1%
                         T10421(normal)  -0.1%
                        T10421a(normal)  -0.1%
                         T10858(normal)  -0.1%
                         T11276(normal)  -0.1%
                        T11303b(normal)  -0.2%
                         T11545(normal)  -0.1%
                         T11822(normal)  -0.1%
                         T12150(optasm)  -0.1%
                         T12234(optasm)  -0.3%
                         T13035(normal)  -0.2%
                         T16190(normal)  -0.1%
                         T16875(normal)  -0.4%
                        T17836b(normal)  -0.2%
                         T17977(normal)  -0.2%
                        T17977b(normal)  -0.2%
                         T18140(normal)  -0.1%
                         T18282(normal)  -0.1%
                         T18304(normal)  -0.2%
                        T18698a(normal)  -0.1%
                         T18923(normal)  -0.1%
                         T20049(normal)  -0.1%
                        T21839r(normal)  -0.1%
                          T5837(normal)  -0.4%
                          T6048(optasm)  +3.2% BAD
                          T9198(normal)  -0.2%
                          T9630(normal)  -0.1%
           TcPlugin_RewritePerf(normal)  -0.4%
                 hard_hole_fits(normal)  -0.1%
    
                              geo. mean  -0.0%
                              minimum    -0.4%
                              maximum    +3.2%
    
    The T6048 outlier is hard to pin down, but it may be the effect of
    reading in more interface files definitions. It's a small program for
    which compile time is very short, so I'm not bothered about it.
    
    Metric Increase:
        T6048
    
    - - - - -
    ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00
    testsuite: Mark unpack_sums_6 as fragile due to #22504
    
    This test is explicitly dependent upon runtime, which is generally not
    appropriate given that the testsuite is run in parallel and generally
    saturates the CPU.
    
    - - - - -
    def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00
    testsuite: Don't use grep -q in unpack_sums_7
    
    `grep -q` closes stdin as soon as it finds the pattern it is looking
    for, resulting in #22484.
    
    - - - - -
    cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00
    Add Javascript backend
    
    Add JS backend adapted from the GHCJS project by Luite Stegeman.
    
    Some features haven't been ported or implemented yet. Tests for these
    features have been disabled with an associated gitlab ticket.
    
    Bump array submodule
    
    Work funded by IOG.
    
    Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io>
    Co-authored-by: Luite Stegeman <stegeman at gmail.com>
    Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com>
    
    - - - - -
    68c966cd by sheaf at 2022-11-30T09:31:25-05:00
    Fix @since annotations on WithDict and Coercible
    
    Fixes #22453
    
    - - - - -
    a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00
    Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther
    
    We were failing to account for the cc_pend_sc flag in this
    important function, with the result that we expanded superclasses
    forever.
    
    Fixes #22516.
    
    - - - - -
    a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00
    Use mkNakedFunTy in tcPatSynSig
    
    As #22521 showed, in tcPatSynSig we make a "fake type" to
    kind-generalise; and that type has unzonked type variables in it. So
    we must not use `mkFunTy` (which checks FunTy's invariants) via
    `mkPhiTy` when building this type.  Instead we need to use
    `mkNakedFunTy`.
    
    Easy fix.
    
    - - - - -
    31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00
    Properly cast values when writing/reading unboxed sums.
    
    Unboxed sums might store a Int8# value as Int64#. This patch
    makes sure we keep track of the actual value type.
    
    See Note [Casting slot arguments] for the details.
    
    - - - - -
    10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00
    Move Void to GHC.Base...
    
    This change would allow `Void` to be used deeper in module graph.
    For example exported from `Prelude` (though that might be already
    possible).
    
    Also this change includes a change `stimes @Void _ x = x`,
    https://github.com/haskell/core-libraries-committee/issues/95
    
    While the above is not required, maintaining old stimes behavior
    would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`,
    which would require more hs-boot files.
    
    - - - - -
    b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00
    DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475)
    
    See the updated `Note [Data-con worker strictness]`
    and the new `Note [Demand transformer for data constructors]`.
    
    Fixes #22475.
    
    - - - - -
    d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00
    Make Functor a quantified superclass of Bifunctor.
    
    See https://github.com/haskell/core-libraries-committee/issues/91 for
    discussion.
    
    This change relates Bifunctor with Functor by requiring second = fmap.
    Moreover this change is a step towards unblocking the major version bump
    of bifunctors and profunctors to major version 6. This paves the way to
    move the Profunctor class into base. For that Functor first similarly
    becomes a superclass of Profunctor in the new major version 6.
    
    - - - - -
    72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00
    FastString: SAT bucket_match
    
    Metric Decrease:
        MultiLayerModulesTH_OneShot
    
    - - - - -
    afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00
    Add a missing varToCoreExpr in etaBodyForJoinPoint
    
    This subtle bug showed up when compiling a library with 9.4.
    See #22491.  The bug is present in master, but it is hard to
    trigger; the new regression test T22491 fails in 9.4.
    
    The fix was easy: just add a missing varToCoreExpr in
    etaBodyForJoinPoint.
    
    The fix is definitely right though!
    
    I also did some other minor refatoring:
    * Moved the preInlineUnconditionally test in simplExprF1 to
      before the call to joinPointBinding_maybe, to avoid fruitless
      eta-expansion.
    * Added a boolean from_lam flag to simplNonRecE, to avoid two
      fruitless tests, and commented it a bit better.
    
    These refactorings seem to save 0.1% on compile-time allocation in
    perf/compiler; with a max saving of 1.4% in T9961
    
    Metric Decrease:
        T9961
    
    - - - - -
    81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00
    CI: Forbid the fully static build on Alpine to fail.
    
    To do so, we mark some tests broken in this configuration.
    
    - - - - -
    c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00
    CI: Remove ARMv7 jobs
    
    These jobs fail (and are allowed to fail) nearly every time.
    
    Soon they won't even be able to run at all, as we won't currently have
    runners that can run them.
    
    Fixing the latter problem is tracked in #22409.
    
    I went ahead and removed all settings and configurations.
    
    - - - - -
    d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00
    CI: Fix CI lint
    
    Failure was introduced by conflicting changes to gen_ci.hs that did
    *not* trigger git conflicts.
    
    - - - - -
    ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00
    Refactor TyCon to have a top-level product
    
    This patch changes the representation of TyCon so that it has
    a top-level product type, with a field that gives the details
    (newtype, type family etc), #22458.
    
    Not much change in allocation, but execution seems to be a bit
    faster.
    
    Includes a change to the haddock submodule to adjust for API changes.
    
    - - - - -
    74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00
    ApplicativeDo: Set pattern location before running exhaustiveness checker
    
    This improves the error messages of the exhaustiveness checker when
    checking statements which have been moved around with ApplicativeDo.
    
    Before:
    
    Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns]
        Pattern match(es) are non-exhaustive
        In a pattern binding:
            Patterns of type ‘Maybe ()’ not matched: Nothing
      |
    2 |   let x = ()
      |   ^^^^^^^^^^
    
    After:
    
    Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns]
        Pattern match(es) are non-exhaustive
        In a pattern binding:
            Patterns of type ‘Maybe ()’ not matched: Nothing
      |
    4 |   ~(Just res1) <- seq x (pure $ Nothing @())
      |
    
    Fixes #22483
    
    - - - - -
    85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00
    Add special case for :Main module in `GHC.IfaceToCore.mk_top_id`
    
    See Note [Root-main Id]
    
    The `:Main` special binding is actually defined in the current module
    (hence don't go looking for it externally) but the module name is rOOT_MAIN
    rather than the current module so we need this special case.
    
    There was already some similar logic in `GHC.Rename.Env` for
    External Core, but now the "External Core" is in interface files it
    needs to be moved here instead.
    
    Fixes #22405
    
    - - - - -
    108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00
    Fix linearity checking in Lint
    
    Lint was not able to see that x*y <= x*y, because this inequality
    was decomposed to x <= x*y && y <= x*y, but there was no rule
    to see that x <= x*y.
    
    Fixes #22546.
    
    - - - - -
    bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00
    Mark T16916 fragile
    
    See https://gitlab.haskell.org/ghc/ghc/-/issues/16966
    
    - - - - -
    5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00
    Refactor: FreshOrReuse instead of addTyClTyVarBinds
    
    This is a refactoring that should have no effect on observable behavior.
    
    Prior to this change, GHC.HsToCore.Quote contained a few closely related
    functions to process type variable bindings: addSimpleTyVarBinds,
    addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds.
    
    We can classify them by their input type and name generation strategy:
    
                                  Fresh names only    Reuse bound names
                              +---------------------+-------------------+
                       [Name] | addSimpleTyVarBinds |                   |
    [LHsTyVarBndr flag GhcRn] |     addHsTyVarBinds |                   |
            LHsQTyVars GhcRn  |      addQTyVarBinds | addTyClTyVarBinds |
                              +---------------------+-------------------+
    
    Note how two functions are missing. Because of this omission, there were
    two places where a LHsQTyVars value was constructed just to be able to pass it
    to addTyClTyVarBinds:
    
    1. mk_qtvs in addHsOuterFamEqnTyVarBinds    -- bad
    2. mkHsQTvs in repFamilyDecl                -- bad
    
    This prevented me from making other changes to LHsQTyVars, so the main
    goal of this refactoring is to get rid of those workarounds.
    
    The most direct solution would be to define the missing functions.
    But that would lead to a certain amount of code duplication. To avoid
    code duplication, I factored out the name generation strategy into a
    function parameter:
    
    	data FreshOrReuse
    	  = FreshNamesOnly
    	  | ReuseBoundNames
    
    	addSimpleTyVarBinds :: FreshOrReuse -> ...
    	addHsTyVarBinds     :: FreshOrReuse -> ...
    	addQTyVarBinds      :: FreshOrReuse -> ...
    
    - - - - -
    c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00
    addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders
    
    Consider this example:
    
    	[d| instance forall a. C [a] where
    	      type forall b. G [a] b = Proxy b |]
    
    When we process "forall b." in the associated type instance, it is
    unambiguously the binding site for "b" and we want a fresh name for it.
    Therefore, FreshNamesOnly is more fitting than ReuseBoundNames.
    This should not have any observable effect but it avoids pointless
    lookups in the MetaEnv.
    
    - - - - -
    42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00
    Handle type data declarations in Template Haskell quotations and splices (fixes #22500)
    
    This adds a TypeDataD constructor to the Template Haskell Dec type,
    and ensures that the constructors it contains go in the TyCls namespace.
    
    - - - - -
    1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00
    Add BufSpan to EpaLocation (#22319, #22558)
    
    The key part of this patch is the change to mkTokenLocation:
    
    	- mkTokenLocation (RealSrcSpan r _)  = TokenLoc (EpaSpan r)
    	+ mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb)
    
    mkTokenLocation used to discard the BufSpan, but now it is saved and can
    be retrieved from LHsToken or LHsUniToken.
    
    This is made possible by the following change to EpaLocation:
    
    	- data EpaLocation = EpaSpan !RealSrcSpan
    	+ data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan)
    	                   | ...
    
    The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock.
    
    - - - - -
    cd31acad by sheaf at 2022-12-06T15:45:58-05:00
    Hadrian: fix ghcDebugAssertions off-by-one error
    
    Commit 6b2f7ffe changed the logic that decided whether to enable debug
    assertions. However, it had an off-by-one error, as the stage parameter
    to the function inconsistently referred to the stage of the compiler
    being used to build or the stage of the compiler we are building.
    
    This patch makes it consistent. Now the parameter always refers to the
    the compiler which is being built.
    
    In particular, this patch re-enables
    assertions in the stage 2 compiler when building with devel2 flavour,
    and disables assertions in the stage 2 compiler when building with
    validate flavour.
    
    Some extra performance tests are now run in the "validate" jobs because
    the stage2 compiler no longer contains assertions.
    
    -------------------------
    Metric Decrease:
        CoOpt_Singletons
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModulesTH_OneShot
        T11374
        T12227
        T12234
        T13253-spj
        T13701
        T14683
        T14697
        T15703
        T17096
        T17516
        T18304
        T18478
        T18923
        T5030
        T9872b
        TcPlugin_RewritePerf
    Metric Increase:
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModules
        MultiLayerModulesRecomp
        MultiLayerModulesTH_Make
        T13386
        T13719
        T3294
        T9233
        T9675
        parsing001
    -------------------------
    
    - - - - -
    21d66db1 by mrkun at 2022-12-06T15:46:38-05:00
    Push DynFlags out of runInstallNameTool
    
    - - - - -
    aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00
    Push DynFlags out of askOtool
    
    - - - - -
    4e28f49e by mrkun at 2022-12-06T15:46:38-05:00
    Push DynFlags out of runInjectRPaths
    
    - - - - -
    a7422580 by mrkun at 2022-12-06T15:46:38-05:00
    Push DynFlags out of Linker.MacOS
    
    - - - - -
    e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00
    Fix bounds-checking buglet in Data.Array.Byte
    
    ...another manifestation of #20851 which
    I unfortunately missed in my first pass.
    
    - - - - -
    8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00
    Remove copy-pasted definitions of `graphFromEdgedVertices*`
    
    - - - - -
    c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00
    Add version of `reachableGraph` that avoids loop for cyclic inputs
    by building its result connected component by component
    
    Fixes #22512
    
    - - - - -
    90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00
    Mark Type.Reflection.Unsafe as Unsafe
    
    This module can be used to construct ill-formed TypeReps, so it should
    be Unsafe.
    
    - - - - -
    2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00
    Truncate eventlog event for large payload (#20221)
    
    RTS eventlog events for postCapsetVecEvent are truncated if payload
    is larger than EVENT_PAYLOAD_SIZE_MAX
    Previously, postCapsetVecEvent records eventlog event with payload
    of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without
    any validation, resulting in corrupted data.
    For example, this happens when a Haskell binary is invoked with very
    long command line arguments exceeding 2^16 bytes (see #20221).
    Now we check the size of accumulated payload messages incrementally,
    and truncate the message just before the payload size exceeds
    EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing
    how many arguments are truncated.
    
    - - - - -
    9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00
    hadrian: don't add debug info to non-debug ways of rts
    
    Hadrian used to pass -g when building all ways of rts. It makes output
    binaries larger (especially so for wasm backend), and isn't needed by
    most users out there, so this patch removes that flag. In case the
    debug info is desired, we still pass -g3 when building the debug way,
    and there's also the debug_info flavour transformer which ensures -g3
    is passed for all rts ways.
    
    - - - - -
    7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00
    Restore show (typeRep @[]) == "[]"
    
    The Show instance for TypeRep [] has changed in 9.5 to output "List"
    because the name of the type constructor changed.
    This seems to be accidental and is inconsistent with TypeReps of saturated
    lists, which are printed as e.g. "[Int]".
    For now, I'm restoring the old behavior; in the future,
    maybe we should show TypeReps without puns (List, Tuple, Type).
    
    - - - - -
    216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00
    Add test for #22162
    
    - - - - -
    5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00
    ci: Add job to test interface file determinism guarantees
    
    In this job we can run on every commit we add a test which builds the
    Cabal library twice and checks that the ABI hash and interface hash is
    stable across the two builds.
    
    * We run the test 20 times to try to weed out any race conditions due to
      `-j`
    * We run the builds in different temporary directories to try to weed
      out anything related to build directory affecting ABI or interface
      file hash.
    
    Fixes #22180
    
    - - - - -
    0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00
    ci: Add job for testing interface stability across builds
    
    The idea is that both the bindists should product libraries with the
    same ABI and interface hash.
    So the job checks with ghc-pkg to make sure the computed ABI
    is the same.
    
    In future this job can be extended to check for the other facets of
    interface determinism.
    
    Fixes #22180
    
    - - - - -
    74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00
    backpack: Be more careful when adding together ImportAvails
    
    There was some code in the signature merging logic which added together
    the ImportAvails of the signature and the signature which was merged
    into it. This had the side-effect of making the merged signature depend
    on the signature (via a normal module dependency). The intention was to
    propagate orphan instances through the merge but this also messed up
    recompilation logic because we shouldn't be attempting to load B.hi when
    mergeing it.
    
    The fix is to just combine the part of ImportAvails that we intended to
    (transitive info, orphan instances and type family instances) rather
    than the whole thing.
    
    - - - - -
    d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00
    Fix mk_mod_usage_info if the interface file is not already loaded
    
    In #22217 it was observed that the order modules are compiled in affects
    the contents of an interface file. This was because a module dependended
    on another module indirectly, via a re-export but the interface file for
    this module was never loaded because the symbol was never used in the
    file.
    
    If we decide that we depend on a module then we jolly well ought to
    record this fact in the interface file! Otherwise it could lead to very
    subtle recompilation bugs if the dependency is not tracked and the
    module is updated.
    
    Therefore the best thing to do is just to make sure the file is loaded
    by calling the `loadSysInterface` function.  This first checks the
    caches (like we did before) but then actually goes to find the interface
    on disk if it wasn't loaded.
    
    Fixes #22217
    
    - - - - -
    ea25088d by lrzlin at 2022-12-08T22:46:06-05:00
    Add initial support for LoongArch Architecture.
    
    - - - - -
    9eb9d2f4 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
    Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD
    
    - - - - -
    08d8fe2a by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
    Allow mtl-2.3 in hadrian
    
    - - - - -
    3807a46c by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
    Support mtl-2.3 in check-exact
    
    - - - - -
    ef702a18 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
    Fix tests
    
    - - - - -
    3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00
    Make (^) INLINE (#22324)
    
    So that we get to cancel away the allocation for the lazily used base.
    
    We can move `powImpl` (which *is* strict in the base) to the top-level
    so that we don't duplicate too much code and move the SPECIALISATION
    pragmas onto `powImpl`.
    
    The net effect of this change is that `(^)` plays along much better with
    inlining thresholds and loopification (#22227), for example in `x2n1`.
    
    Fixes #22324.
    
    - - - - -
    1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00
    Typeable: Fix module locations of some definitions in GHC.Types
    
    There was some confusion in Data.Typeable about which module certain
    wired-in things were defined in. Just because something is wired-in
    doesn't mean it comes from GHC.Prim, in particular things like LiftedRep
    and RuntimeRep are defined in GHC.Types and that's the end of the story.
    
    Things like Int#, Float# etc are defined in GHC.Prim as they have no
    Haskell definition site at all so we need to generate type
    representations for them (which live in GHC.Types).
    
    Fixes #22510
    
    - - - - -
    0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00
    Make `drop` and `dropWhile` fuse (#18964)
    
    I copied the fusion framework we have in place for `take`.
    T18964 asserts that we regress neither when fusion fires nor when it doesn't.
    
    Fixes #18964.
    
    - - - - -
    26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00
    Do not strictify a DFun's parameter dictionaries (#22549)
    
    ... thus fixing #22549.
    
    The details are in the refurbished and no longer dead
    `Note [Do not strictify a DFun's parameter dictionaries]`.
    
    There's a regression test in T22549.
    
    - - - - -
    36093407 by John Ericson at 2022-12-08T22:49:45-05:00
    Delete `rts/package.conf.in`
    
    It is a relic of the Make build system. The RTS now uses a
    `package.conf` file generated the usual way by Cabal.
    
    - - - - -
    b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00
    Fixes around primitive literals
    
    * The SourceText of primitive characters 'a'# did not include
      the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#.
      We can now remove the function pp_st_suffix, which was a hack
      to add the # back.
    * Negative primitive literals shouldn't use parentheses, as described in
      Note [Printing of literals in Core]. Added a testcase to T14681.
    
    - - - - -
    aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00
    testsuite: Mark conc024 fragile on Windows
    
    - - - - -
    ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00
    Document TH splices' interaction with INCOHERENT instances
    
    Top-level declaration splices can having surprising interactions with
    `INCOHERENT` instances, as observed in #22492. This patch
    resolves #22492 by documenting this strange interaction in the GHC User's
    Guide.
    
    [ci skip]
    
    - - - - -
    1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00
    Fix #22300 Document GHC's extensions to valid whitespace
    
    - - - - -
    79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00
    Add support for environments that don't have setImmediate
    
    - - - - -
    5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00
    Fix bound thread status
    
    - - - - -
    65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00
    Update containers submodule
    
    This contains a fix necessary for the multi-repl to work on GHC's code
    base where we try to load containers and template-haskell into the same
    session.
    
    - - - - -
    4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00
    hadrian-multi: Put interface files in separate directories
    
    Before we were putting all the interface files in the same directory
    which was leading to collisions if the files were called the same thing.
    
    - - - - -
    8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00
    hadrian-toolargs: Add filepath to allowed repl targets
    
    - - - - -
    5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00
    driver: Set correct UnitId when rehydrating modules
    
    We were not setting the UnitId before rehydrating modules which just led
    to us attempting to find things in the wrong HPT. The test for this is
    the hadrian-multi command (which is now added as a CI job).
    
    Fixes #22222
    
    - - - - -
    ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00
    ci: Add job to test hadrian-multi command
    
    I am not sure this job is good because it requires booting HEAD with
    HEAD, but it should be fine.
    
    - - - - -
    fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00
    hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series.
    
    This updates the build plans for the most recent compiler versions, as
    well as fixing the hadrian-bootstrap-gen script to a specific GHC
    version.
    
    - - - - -
    195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00
    ci: Bump boot images to use ghc-9.4.3
    
    Also updates the bootstrap jobs to test booting 9.2 and 9.4.
    
    - - - - -
    c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00
    hlint: Removed redundant UnboxedSums pragmas
    
    UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just
    the way it is.
    
    See #22485
    
    - - - - -
    b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00
    Add heqT, a kind-heterogeneous variant of heq
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/99
    
    - - - - -
    bfd7c1e6 by Andrew Lelechenko at 2022-12-11T12:26:55-05:00
    Document that Bifunctor instances for tuples are lawful only up to laziness
    
    - - - - -
    5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00
    Mark T21336a fragile
    
    - - - - -
    c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00
    Add test for #21476
    
    This issues seems to have been fixed since the ticket was made, so let's
    add a test and move on.
    
    Fixes #21476
    
    - - - - -
    e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00
    Respect -XStrict in the pattern-match checker (#21761)
    
    We were missing a call to `decideBangHood` in the pattern-match checker.
    There is another call in `matchWrapper.mk_eqn_info` which seems redundant
    but really is not; see `Note [Desugaring -XStrict matches in Pmc]`.
    
    Fixes #21761.
    
    - - - - -
    884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00
    Fix loop in the interface representation of some `Unfolding` fields
    
    As discovered in #22272, dehydration of the unfolding info of a
    recursive definition used to involve a traversal of the definition
    itself, which in turn involves traversing the unfolding info. Hence,
    a loop.
    
    Instead, we now store enough data in the interface that we can produce
    the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot]
    for details.
    
    Fixes #22272
    
    Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00
    EPA: When splitting out header comments, keep ones for first decl
    
    Any comments immediately preceding the first declaration are no longer
    kept as header comments, but attach to the first declaration instead.
    
    - - - - -
    8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00
    JS: fix object file name comparison (#22578)
    
    - - - - -
    e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00
    configure: Bump min bootstrap GHC version to 9.2
    
    - - - - -
    75855643 by Ben Gamari at 2022-12-15T03:54:02-05:00
    hadrian: Don't enable TSAN in stage0 build
    
    - - - - -
    da7b51d8 by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm: Introduce blockConcat
    
    - - - - -
    34f6b09c by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm: Introduce MemoryOrderings
    
    - - - - -
    43beaa7b by Ben Gamari at 2022-12-15T03:54:02-05:00
    llvm: Respect memory specified orderings
    
    - - - - -
    8faf74fc by Ben Gamari at 2022-12-15T03:54:02-05:00
    Codegen/x86: Eliminate barrier for relaxed accesses
    
    - - - - -
    6cc3944a by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm/Parser: Reduce some repetition
    
    - - - - -
    6c9862c4 by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm/Parser: Add syntax for ordered loads and stores
    
    - - - - -
    748490d2 by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm/Parser: Atomic load syntax
    
    Originally I had thought I would just use the `prim` call syntax instead
    of introducing new syntax for atomic loads. However, it turns out that
    `prim` call syntax tends to make things quite unreadable. This new
    syntax seems quite natural.
    
    - - - - -
    28c6781a by Ben Gamari at 2022-12-15T03:54:02-05:00
    codeGen: Introduce ThreadSanitizer instrumentation
    
    This introduces a new Cmm pass which instruments the program with
    ThreadSanitizer annotations, allowing full tracking of mutator memory
    accesses via TSAN.
    
    - - - - -
    d97aa311 by Ben Gamari at 2022-12-15T03:54:02-05:00
    Hadrian: Drop TSAN_ENABLED define from flavour
    
    This is redundant since the TSANUtils.h already defines it.
    
    - - - - -
    86974ef1 by Ben Gamari at 2022-12-15T03:54:02-05:00
    hadrian: Enable Cmm instrumentation in TSAN flavour
    
    - - - - -
    93723290 by Ben Gamari at 2022-12-15T03:54:02-05:00
    rts: Ensure that global regs are never passed as fun call args
    
    This is in general unsafe as they may be clobbered if they are mapped to
    caller-saved machine registers. See Note [Register parameter passing].
    
    - - - - -
    2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-05:00
    Package Imports: Get candidate packages also from re-exported modules
    
    Previously we were just looking at the direct imports to try and work
    out what a package qualifier could apply to but #22333 pointed out we
    also needed to look for reexported modules.
    
    Fixes #22333
    
    - - - - -
    552b7908 by Ben Gamari at 2022-12-15T03:55:15-05:00
    compiler: Ensure that MutVar operations have necessary barriers
    
    Here we add acquire and release barriers in readMutVar# and
    writeMutVar#, which are necessary for soundness.
    
    Fixes #22468.
    
    - - - - -
    933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-05:00
    Fix bogus test in Lint
    
    The Lint check for branch compatiblity within an axiom, in
    GHC.Core.Lint.compatible_branches was subtly different to the
    check made when contructing an axiom, in
    GHC.Core.FamInstEnv.compatibleBranches.
    
    The latter is correct, so I killed the former and am now using the
    latter.
    
    On the way I did some improvements to pretty-printing and documentation.
    
    - - - - -
    03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-05:00
    checkValidInst: Don't expand synonyms when splitting sigma types
    
    Previously, the `checkValidInst` function (used when checking that an instance
    declaration is headed by an actual type class, not a type synonym) was using
    `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is
    incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause
    instances headed by quantified constraint type synonyms to be accepted
    erroneously.
    
    This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy`
    specialized for validity checking that does _not_ expand type synonyms, and
    uses it in `checkValidInst`.
    
    Fixes #22570.
    
    - - - - -
    ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts/Messages: Refactor
    
    This doesn't change behavior but makes the code a bit easier to follow.
    
    - - - - -
    7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts/ThreadPaused: Ordering fixes
    
    - - - - -
    914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00
    eventlog: Silence spurious data race
    
    - - - - -
    fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00
    Introduce SET_INFO_RELEASE for Cmm
    
    - - - - -
    821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts: Use fences instead of explicit barriers
    
    - - - - -
    2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts/stm: Fix memory ordering in readTVarIO#
    
    See #22421.
    
    - - - - -
    99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00
    Improve heap memory barrier Note
    
    Also introduce MUT_FIELD marker in Closures.h to document mutable
    fields.
    
    - - - - -
    70999283 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts: Introduce getNumCapabilities
    
    And ensure accesses to n_capabilities are atomic (although with relaxed
    ordering). This is necessary as RTS API callers may concurrently call
    into the RTS without holding a capability.
    
    - - - - -
    98689f77 by Ben Gamari at 2022-12-16T16:12:44-05:00
    ghc: Fix data race in dump file handling
    
    Previously the dump filename cache would use a non-atomic update which
    could potentially result in lost dump contents. Note that this is still
    a bit racy since the first writer may lag behind a later appending
    writer.
    
    - - - - -
    605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Always use atomics for context_switch and interrupt
    
    Since these are modified by the timer handler.
    
    - - - - -
    86f20258 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts/Timer: Always use atomic operations
    
    As noted in #22447, the existence of the pthread-based ITimer
    implementation means that we cannot assume that the program is
    single-threaded.
    
    - - - - -
    f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Encapsulate recent_activity access
    
    This makes it easier to ensure that it is accessed using the necessary
    atomic operations.
    
    - - - - -
    e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Encapsulate access to capabilities array
    
    - - - - -
    7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Encapsulate sched_state
    
    - - - - -
    1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00
    PrimOps: Fix benign MutVar race
    
    Relaxed ordering is fine here since the later CAS implies a release.
    
    - - - - -
    3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Style fix
    
    - - - - -
    82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00
    compiler: Use release store in eager blackholing
    
    - - - - -
    eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Fix ordering of makeStableName
    
    - - - - -
    ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Use ordered accesses instead of explicit barriers
    
    - - - - -
    a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Statically allocate capabilities
    
    This is a rather simplistic way of solving #17289.
    
    - - - - -
    287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Ensure that all accesses to pending_sync are atomic
    
    - - - - -
    351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Note race with wakeBlockingQueue
    
    - - - - -
    5acf33dd by Andrew Lelechenko at 2022-12-16T16:13:22-05:00
    Bump submodule directory to 1.3.8.0 and hpc to HEAD
    
    - - - - -
    0dd95421 by Andrew Lelechenko at 2022-12-16T16:13:22-05:00
    Accept allocations increase on Windows
    
    This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips
    between lists and ByteArray. See #22625 for discussion.
    
    Metric Increase:
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModules
        MultiLayerModulesRecomp
        T10421
        T10547
        T12150
        T12227
        T12234
        T12425
        T13035
        T13253
        T13253-spj
        T13701
        T13719
        T15703
        T16875
        T18140
        T18282
        T18304
        T18698a
        T18698b
        T18923
        T20049
        T21839c
        T21839r
        T5837
        T6048
        T9198
        T9961
        TcPlugin_RewritePerf
        hard_hole_fits
    
    - - - - -
    ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00
    testsuite: Mark T9405 as fragile instead of broken on Windows
    
    It's starting to pass again, and the unexpected pass blocks CI.
    
    - - - - -
    1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00
    compiler: remove obsolete commented code in wasm NCG
    
    It was just a temporary hack to workaround a bug in the relooper, that
    bug has been fixed long before the wasm backend is merged.
    
    - - - - -
    e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00
    compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm
    
    Also removes some unreachable code here.
    
    - - - - -
    1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00
    compiler: change fallback function signature to Cmm function signature in wasm NCG
    
    In the wasm NCG, when handling a `CLabel` of undefined function
    without knowing its function signature, we used to fallback to `() ->
    ()` which is accepted by `wasm-ld`. This patch changes it to the
    signature of Cmm functions, which equally works, but would be required
    when we emit tail call instructions.
    
    - - - - -
    8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00
    compiler: add optional tail-call support in wasm NCG
    
    When the `-mtail-call` clang flag is passed at configure time, wasm
    tail-call extension is enabled, and the wasm NCG will emit
    `return_call`/`return_call_indirect` instructions to take advantage of
    it and avoid the `StgRun` trampoline overhead.
    
    Closes #22461.
    
    - - - - -
    d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00
    base: add missing autoconf checks for waitpid/umask
    
    These are not present in wasi-libc. Required for fixing #22589
    
    - - - - -
    da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00
    compiler: make .wasm the default executable extension on wasm32
    
    Following convention as in other wasm toolchains. Fixes #22594.
    
    - - - - -
    ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00
    ci: support hello.wasm in ci.sh cross testing logic
    
    - - - - -
    6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00
    Correct `exitWith` Haddocks
    
    The `IOError`-specific `catch` in the Prelude is long gone.
    
    - - - - -
    b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-05:00
    rts: Drop racy assertion
    
    0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in
    `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean.
    However, this isn't necessarily the case since another thread may have
    raced us to dirty the object.
    
    - - - - -
    761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00
    rts/libdw: Silence uninitialized usage warnings
    
    As noted in #22538, previously some GCC versions warned that various
    locals in Libdw.c may be used uninitialized. Although this wasn't
    strictly true (since they were initialized in an inline assembler block)
    we fix this by providing explicit empty initializers.
    
    Fixes #22538
    - - - - -
    5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00
    testsuite: Mark T16392 as fragile on windows
    
    See #22649
    
    - - - - -
    703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00
    Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`.
    
    - - - - -
    9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05:00
    packaging: Fix upload_ghc_libs.py script
    
    This change reflects the changes where .cabal files are now generated by
    hadrian rather than ./configure.
    
    Fixes #22518
    
    - - - - -
    7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00
    configure: Drop uses of AC_PROG_CC_C99
    
    As noted in #22566, this macro is deprecated as of autoconf-2.70
    `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself.
    
    Closes #22566.
    
    - - - - -
    36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00
    configure: Use AS_HELP_STRING instead of AC_HELP_STRING
    
    The latter has been deprecated.
    
    See #22566.
    
    - - - - -
    befe6ff8 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
    GHCi.UI: fix various usages of head and tail
    
    - - - - -
    666d0ba7 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
    GHCi.UI: avoid head and tail in parseCallEscape and around
    
    - - - - -
    5d96fd50 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
    Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty
    
    - - - - -
    3ce2ab94 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
    Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian
    
    - - - - -
    954de93a by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
    Update submodule haskeline to HEAD (to allow transformers-0.6)
    
    - - - - -
    cefbeec3 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
    Update submodule transformers to 0.6.0.4
    
    - - - - -
    b4730b62 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
    Fix tests
    
    T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations
    
    Metric Increase:
        T13253
    
    - - - - -
    0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05:00
    Abstract over the right free vars
    
    Fix #22459, in two ways:
    
    (1) Make the Specialiser not create a bogus specialisation if
        it is presented by strangely polymorphic dictionary.
        See Note [Weird special case in SpecDict] in
        GHC.Core.Opt.Specialise
    
    (2) Be more careful in abstractFloats
        See Note [Which type variables to abstract over]
        in GHC.Core.Opt.Simplify.Utils.
    
    So (2) stops creating the excessively polymorphic dictionary in
    abstractFloats, while (1) stops crashing if some other pass should
    nevertheless create a weirdly polymorphic dictionary.
    
    - - - - -
    df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00
    rts: explicitly store return value of ccall checkClosure to prevent type error (#22617)
    
    - - - - -
    e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00
    Fix shadowing lacuna in OccurAnal
    
    Issue #22623 demonstrated another lacuna in the implementation
    of wrinkle (BS3) in Note [The binder-swap substitution] in
    the occurrence analyser.
    
    I was failing to add TyVar lambda binders using
    addInScope/addOneInScope and that led to a totally bogus binder-swap
    transformation.
    
    Very easy to fix.
    
    - - - - -
    3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00
    Fix an assertion check in addToEqualCtList
    
    The old assertion saw that a constraint ct could rewrite itself
    (of course it can) and complained (stupid).
    
    Fixes #22645
    
    - - - - -
    ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00
    configure: Bump version to 9.6
    
    - - - - -
    fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00
    base: Bump version to 4.18
    
    Requires various submodule bumps.
    
    - - - - -
    93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00
    ghc-boot: Fix bootstrapping
    
    - - - - -
    fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00
    Bump GHC version to 9.7
    
    - - - - -
    914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05:00
    Don't consider large byte arrays/compact regions pinned.
    
    Workaround for #22255 which showed how treating large/compact regions
    as pinned could cause segfaults.
    
    - - - - -
    32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00
    hadrian bindist: Install manpages to share/man/man1/ghc.1
    
    When the installation makefile was copied over the manpages were no
    longer installed in the correct place. Now we install it into share/man/man1/ghc.1
    as the make build system did.
    
    Fixes #22371
    
    - - - - -
    b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00
    rts: Drop paths from configure from cabal file
    
    A long time ago we would rely on substitutions from the configure script
    to inject paths of the include and library directories of libffi and
    libdw. However, now these are instead handled inside Hadrian when
    calling Cabal's `configure` (see the uses of `cabalExtraDirs` in
    Hadrian's `Settings.Packages.packageArgs`).
    
    While the occurrences in the cabal file were redundant, they did no
    harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have
    no longer been interpolated. @mpickering noticed the suspicious
    uninterpolated occurrence of `@FFIIncludeDir@` in #22595,
    prompting this commit to finally remove them.
    
    - - - - -
    b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00
    Bump libffi-tarballs submodule
    
    We will now use libffi-3.4.4.
    
    - - - - -
    3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00
    EPA: Make EOF position part of AnnsModule
    
    Closes #20951
    Closes #19697
    
    - - - - -
    99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00
    JS: fix support for -outputdir (#22641)
    
    The `-outputdir` option wasn't correctly handled with the JS backend
    because the same code path was used to handle both objects produced by
    the JS backend and foreign .js files. Now we clearly distinguish the
    two in the pipeline, fixing the bug.
    
    - - - - -
    02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00
    Refactor mkRuntimeError
    
    This patch fixes #22634.  Because we don't have TYPE/CONSTRAINT
    polymorphism, we need two error functions rather than one.
    
    I took the opportunity to rname runtimeError to impossibleError,
    to line up with mkImpossibleExpr, and avoid confusion with the
    genuine runtime-error-constructing functions.
    
    - - - - -
    35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00
    base: Fix event manager shutdown race on non-Linux platforms
    
    During shutdown it's possible that we will attempt to use a closed fd
    to wakeup another capability's event manager. On the Linux eventfd path
    we were careful to handle this. However on the non-Linux path we failed
    to do so. Fix this.
    
    - - - - -
    317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00
    Fix unifier bug: failing to decompose over-saturated type family
    
    This simple patch fixes #22647
    
    - - - - -
    14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00
    rts/m32: Fix sanity checking
    
    Previously we would attempt to clear pages which were marked as
    read-only. Fix this.
    
    - - - - -
    16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00
    ci: Move wasm pipelines into nightly rather than master
    
    See #22664 for the changes which need to be made to bring one of these
    back to the validate pipeline.
    
    - - - - -
    18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix race in marking of blackholes
    
    We must use an acquire-fence when marking to ensure that the indirectee
    is visible.
    
    - - - - -
    11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix segment list races
    
    - - - - -
    602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Use atomic when looking at bd->gen
    
    Since it may have been mutated by a moving GC.
    
    - - - - -
    9d63b160 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Eliminate race in bump_static_flag
    
    To ensure that we don't race with a mutator entering a new CAF we take
    the SM mutex before touching static_flag. The other option here would be
    to instead modify newCAF to use a CAS but the present approach is a bit
    safer.
    
    - - - - -
    26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Ensure that mutable fields have acquire barrier
    
    - - - - -
    8093264a by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix races in collector status tracking
    
    Mark a number of accesses to do with tracking of the status of the
    concurrent collection thread as atomic. No interesting races here,
    merely necessary to satisfy TSAN.
    
    - - - - -
    387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Make segment state updates atomic
    
    - - - - -
    543cae00 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Refactor update remembered set initialization
    
    This avoids a lock inversion between the storage manager mutex and
    the stable pointer table mutex by not dropping the SM_MUTEX in
    nonmovingCollect. This requires quite a bit of rejiggering but it
    does seem like a better strategy.
    
    - - - - -
    c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Ensure that we aren't holding locks when closing them
    
    TSAN complains about this sort of thing.
    
    - - - - -
    0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Make bitmap accesses atomic
    
    This is a benign race on any sensible hard since these are byte
    accesses. Nevertheless, atomic accesses are necessary to satisfy
    TSAN.
    
    - - - - -
    d3fe110a by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix benign race in update remembered set check
    
    Relaxed load is fine here since we will take the lock before looking at
    the list.
    
    - - - - -
    ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix race in shortcutting
    
    We must use an acquire load to read the info table pointer since if we
    find an indirection we must be certain that we see the indirectee.
    
    - - - - -
    36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Make free list counter accesses atomic
    
    Since these may race with the allocator(s).
    
    - - - - -
    aebef31c by doyougnu at 2022-12-23T19:10:09-05:00
    add GHC.Utils.Binary.foldGet' and use for Iface
    
    A minor optimization to remove lazy IO and a lazy accumulator
    
    strictify foldGet'
    
    IFace.Binary: use strict foldGet'
    
    remove superfluous bang
    
    - - - - -
    5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-05:00
    compiler: Ensure that GHC toolchain is first in search path
    
    As noted in #22561, it is important that GHC's toolchain look
    first for its own headers and libraries to ensure that the
    system's are not found instead. If this happens things can
    break in surprising ways (e.g. see #22561).
    
    - - - - -
    cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00
    head.hackage: Use slow-validate bindist for linting jobs
    
    This enables the SLOW_VALIDATE env var for the linting head.hackage
    jobs, namely the jobs enabled manually, by the label or on the nightly
    build now use the deb10-numa-slow-validate bindist which has assertions
    enabled.
    
    See #22623 for a ticket which was found by using this configuration
    already!
    
    The head.hackage jobs triggered by upstream CI are now thusly:
    
    hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build.
                  Runs head.hackage with -dlint and a slow-validate bindist
    
    hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate
                        head.hackage build with -dlint.
    
    nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config.
    
    nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled.
    
    release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist.
    
    - - - - -
    f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00
    ci: Don't run abi-test-nightly on release jobs
    
    The test is not configured to get the correct dependencies for the
    release pipelines (and indeed stops the release pipeline being run at
    all)
    
    - - - - -
    c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00
    ci: Run head.hackage jobs on upstream-testing branch rather than master
    
    This change allows less priviledged users to trigger head.hackage jobs
    because less permissions are needed to trigger jobs on the
    upstream-testing branch, which is not protected.
    
    There is a CI job which updates upstream-testing each hour to the state
    of the master branch so it should always be relatively up-to-date.
    
    - - - - -
    63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00
    llvmGen: Fix relaxed ordering
    
    Previously I used LLVM's `unordered` ordering for the C11 `relaxed`
    ordering. However, this is wrong and should rather use the LLVM
    `monotonic` ordering.
    
    Fixes #22640
    - - - - -
    f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00
    gitlab-ci: Introduce aarch64-linux-llvm job
    
    This nightly job will ensure that we don't break the LLVM backend on
    AArch64/Linux by bootstrapping GHC.
    
    This would have caught #22640.
    
    - - - - -
    6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00
    Store RdrName rather than OccName in Holes
    
    In #20472 it was pointed out that you couldn't defer out of scope but
    the implementation collapsed a RdrName into an OccName to stuff it into
    a Hole. This leads to the error message for a deferred qualified name
    dropping the qualification which affects the quality of the error
    message.
    
    This commit adds a bit more structure to a hole, so a hole can replace a
    RdrName without losing information about what that RdrName was. This is
    important when printing error messages.
    
    I also added a test which checks the Template Haskell deferral of out of
    scope qualified names works properly.
    
    Fixes #22130
    
    - - - - -
    3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00
    Drop support for kind constraints.
    
    This implements proposal 547 and closes ticket #22298.
    See the proposal and ticket for motivation.
    
    Compiler perf improves a bit
    
    Metrics: compile_time/bytes allocated
    -------------------------------------
      CoOpt_Singletons(normal)   -2.4% GOOD
                T12545(normal)   +1.0%
                T13035(normal)  -13.5% GOOD
                T18478(normal)   +0.9%
                T9872d(normal)   -2.2% GOOD
    
                     geo. mean   -0.2%
                     minimum    -13.5%
                     maximum     +1.0%
    
    Metric Decrease:
        CoOpt_Singletons
        T13035
        T9872d
    
    - - - - -
    6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00
    hadrian: Ensure that linker scripts are used when merging objects
    
    In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's
    implementation of the object merging rules: unlike the old `make` build
    system we utterly failed to pass the needed linker scripts. Fix this.
    
    - - - - -
    a5bd0eb8 by Andrew Lelechenko at 2022-12-24T21:10:34-05:00
    Document infelicities of instance Ord Double and workarounds
    
    - - - - -
    62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+00:00
    Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface
    
    Involves adding many new NFData instances.
    
    Without forcing Docs, references to the TcGblEnv for each module are retained
    by the Docs structure. Usually these are forced when the ModIface is serialised
    but not when we aren't writing the interface.
    
    - - - - -
    21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00
    Explain the auxiliary functions of permutations
    
    - - - - -
    32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    compiler: Add -f[no-]split-sections flags
    
    Here we add a `-fsplit-sections` flag which may some day replace
    `-split-sections`. This has the advantage of automatically providing a
    `-fno-split-sections` flag, which is useful for our packaging because we
    enable `-split-sections` by default but want to disable it in certain
    configurations.
    
    - - - - -
    e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00
    hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler
    
    This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b
    
    - - - - -
    15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    hadrian: Add test:all_deps to build just testsuite dependencies
    
    Fixes #22534
    
    - - - - -
    fec6638e by Matthew Pickering at 2023-01-04T11:58:42+00:00
    hadrian: Add no_split_sections tranformer
    
    This transformer reverts the effect of `split_sections`, which we intend
    to use for platforms which don't support split sections.
    
    In order to achieve this we have to modify the implemntation of the
    split_sections transformer to store whether we are enabling
    split_sections directly in the `Flavour` definition. This is because
    otherwise there's no convenient way to turn off split_sections due to
    having to pass additional linker scripts when merging objects.
    
    - - - - -
    3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    check-exact: Fix build with -Werror
    
    - - - - -
    53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+00:00
    ci: Build all test dependencies with in-tree compiler
    
    This means that these executables will honour flavour transformers such
    as "werror".
    
    Fixes #22555
    
    - - - - -
    32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    hadrian: Document using GHC environment variable to select boot compiler
    
    Fixes #22340
    
    - - - - -
    be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    packaging: Build perf builds with -split-sections
    
    In 8f71d958 the make build system was made to use split-sections on
    linux systems but it appears this logic never made it to hadrian.
    There is the split_sections flavour transformer but this doesn't appear
    to be used for perf builds on linux.
    
    This is disbled on deb9 and windows due to #21670
    
    Closes #21135
    
    - - - - -
    00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00
    sphinx: Use modern syntax for extlinks
    
    This fixes the following build error:
    
    ```
      Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273
      ===> Command failed with error code: 2
    
      Exception occurred:
        File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role
          title = caption % part
                  ~~~~~~~~^~~~~~
      TypeError: not all arguments converted during string formatting
    ```
    
    I tested on Sphinx-5.1.1 and Sphinx-6.0.0
    
    Thanks for sterni for providing instructions about how to test using
    sphinx-6.0.0.
    
    Fixes #22690
    
    - - - - -
    541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00
    Misc cleanup
    
    - Remove unused uniques and hs-boot declarations
    - Fix types of seq and unsafeCoerce#
    - Remove FastString/String roundtrip in JS
    - Use TTG to enforce totality
    - Remove enumeration in Heap/Inspect; the 'otherwise' clause
      serves the primitive types well.
    
    - - - - -
    22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00
    EPA: Do not collect comments from end of file
    
    In Parser.y semis1 production triggers for the virtual semi at the end
    of the file. This is detected by it being zero length.
    
    In this case, do not extend the span being used to gather comments, so
    any final comments are allocated at the module level instead.
    
    - - - - -
    9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00
    HsToken in TypeArg (#19623)
    
    Updates the haddock submodule.
    
    - - - - -
    b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00
    Revert "configure: Drop uses of AC_PROG_CC_C99"
    
    This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6.
    
    Centos7 using a very old version of the toolchain (autotools-2.69) where
    the behaviour of these macros has not yet changed. I am reverting this
    without haste as it is blocking the 9.6 branch.
    
    Fixes #22704
    
    - - - - -
    28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00
    Add support for sized literals in the bytecode interpreter.
    
    The bytecode interpreter only has branching instructions for
    word-sized values. These are used for pattern matching.
    Branching instructions for other types (e.g. Int16# or Word8#)
    weren't needed, since unoptimized Core or STG never requires
    branching on types like this.
    
    It's now possible for optimized STG to reach the bytecode
    generator (e.g. fat interface files or certain compiler flag
    combinations), which requires dealing with various sized
    literals in branches.
    
    This patch improves support for generating bytecode from
    optimized STG by adding the following new bytecode
    instructions:
    
        TESTLT_I64
        TESTEQ_I64
        TESTLT_I32
        TESTEQ_I32
        TESTLT_I16
        TESTEQ_I16
        TESTLT_I8
        TESTEQ_I8
        TESTLT_W64
        TESTEQ_W64
        TESTLT_W32
        TESTEQ_W32
        TESTLT_W16
        TESTEQ_W16
        TESTLT_W8
        TESTEQ_W8
    
    Fixes #21945
    
    - - - - -
    ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00
    Only store Name in FunRhs rather than Id with knot-tied fields
    
    All the issues here have been caused by #18758.
    The goal of the ticket is to be able to talk about things like
    `LTyClDecl GhcTc`. In the case of HsMatchContext,
    the correct "context" is whatever we want, and in fact storing just a
    `Name` is sufficient and correct context, even if the rest of the AST is
    storing typechecker Ids.
    
    So this reverts (#20415, !5579) which intended to get closed to #18758 but
    didn't really and introduced a few subtle bugs.
    
    Printing of an error message in #22695 would just hang, because we would
    attempt to print the `Id` in debug mode to assertain whether it was
    empty or not. Printing the Name is fine for the error message.
    
    Another consequence is that when `-dppr-debug` was enabled the compiler would
    hang because the debug printing of the Id would try and print fields
    which were not populated yet.
    
    This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add
    a workaround for the `checkArgs` function which was probably a very
    similar bug to #22695.
    
    Fixes #22695
    
    - - - - -
    c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00
    ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3
    
    Fixes #22599
    
    - - - - -
    0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00
    darwin ci: Explicitly pass desired build triple to configure
    
    On the zw3rk machines for some reason the build machine was inferred to
    be arm64. Setting the build triple appropiately resolve this confusion
    and we produce x86 binaries.
    
    - - - - -
    2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00
    rts: MUT_VAR is not a StgMutArrPtrs
    
    There was previously a comment claiming that the MUT_VAR closure type
    had the layout of StgMutArrPtrs.
    - - - - -
    6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00
    Make FloatIn robust to shadowing
    
    This MR fixes #22622. See the new
      Note [Shadowing and name capture]
    
    I did a bit of refactoring in sepBindsByDropPoint too.
    
    The bug doesn't manifest in HEAD, but it did show up in 9.4,
    so we should backport this patch to 9.4
    
    - - - - -
    a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00
    T10955: Set DYLD_LIBRARY_PATH for darwin
    
    The correct path to direct the dynamic linker on darwin is
    DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX
    using LD_LIBRARY_PATH seems to have stopped working.
    
    For more reading see:
    
    https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s
    
    - - - - -
    73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00
    Skip T18623 on darwin (to add to the long list of OSs)
    
    On recent versions of OSX, running `ulimit -v` results in
    
    ```
    ulimit: setrlimit failed: invalid argument
    ```
    
    Time is too short to work out what random stuff Apple has been doing
    with ulimit, so just skip the test like we do for other platforms.
    
    - - - - -
    8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00
    Pass -Wl,-no_fixup_chains to ld64 when appropiate
    
    Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default.
    This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we
    explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on
    darwin. This results in a warning of the form:
    
    ld: warning: -undefined dynamic_lookup may not work with chained fixups
    
    The manual explains the incompatible nature of these two flags:
    
         -undefined treatment
                 Specifies how undefined symbols are to be treated. Options are: error, warning,
                 suppress, or dynamic_lookup.  The default is error. Note: dynamic_lookup that
                 depends on lazy binding will not work with chained fixups.
    
    A relevant ticket is #22429
    
    Here are also a few other links which are relevant to the issue:
    
    Official comment: https://developer.apple.com/forums/thread/719961
    
    More relevant links:
    
    https://openradar.appspot.com/radar?id=5536824084660224
    
    https://github.com/python/cpython/issues/97524
    
    Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas    e-notes
    
    - - - - -
    365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00
    Disable split sections on aarch64-deb10 build
    
    See #22722
    
    Failure on this job:
    
    https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852
    
    ```
    Unexpected failures:
       /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T10828.run  T10828 [exit code non-0] (ext-interp)
       /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T13123.run  T13123 [exit code non-0] (ext-interp)
       /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T20590.run  T20590 [exit code non-0] (ext-interp)
    Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv
    ```
    
    ```
    Compile failed (exit code 1) errors were:
    data family D_0 a_1 :: * -> *
    data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where
        DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool
    data E_3 where MkE_4 :: a_5 -> E_3
    data Foo_6 a_7 b_8 where
        MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12
    newtype Bar_13 :: * -> GHC.Types.Bool -> * where
        MkBar_14 :: a_15 -> Bar_13 a_15 b_16
    data T10828.T (a_0 :: *) where
        T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1
        T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2
                                                                   GHC.Types.Int => {T10828.foo :: a_2,
                                                                                     T10828.bar :: b_3} -> T10828.T GHC.Types.Int
    T10828.hs:1:1: error: [GHC-87897]
        Exception when trying to run compile-time code:
          ghc-iserv terminated (-4)
        Code: (do TyConI dec <- runQ $ reify (mkName "T")
                  runIO $ putStrLn (pprint dec) >> hFlush stdout
                  d <- runQ
                         $ [d| data T' a :: Type
                                 where
                                   MkT' :: a -> a -> T' a
                                   MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |]
                  runIO $ putStrLn (pprint d) >> hFlush stdout
                  ....)
    *** unexpected failure for T10828(ext-interp)
    =====> 7000 of 9215 [0, 1, 0]
    =====> 7000 of 9215 [0, 1, 0]
    =====> 7000 of 9215 [0, 1, 0]
    =====> 7000 of 9215 [0, 1, 0]
    Compile failed (exit code 1) errors were:
    T13123.hs:1:1: error: [GHC-87897]
        Exception when trying to run compile-time code:
          ghc-iserv terminated (-4)
        Code: ([d| data GADT
                     where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |])
    *** unexpected failure for T13123(ext-interp)
    =====> 7100 of 9215 [0, 2, 0]
    =====> 7100 of 9215 [0, 2, 0]
    =====> 7200 of 9215 [0, 2, 0]
    Compile failed (exit code 1) errors were:
    T20590.hs:1:1: error: [GHC-87897]
        Exception when trying to run compile-time code:
          ghc-iserv terminated (-4)
        Code: ([d| data T where MkT :: forall a. a -> T |])
    *** unexpected failure for T20590(ext-interp)
    ```
    
    Looks fairly worrying to me.
    
    - - - - -
    965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00
    EPA: exact print HsDocTy
    
    To match ghc-exactprint
    https://github.com/alanz/ghc-exactprint/pull/121
    
    - - - - -
    5d65773e by John Ericson at 2023-01-09T20:39:27-05:00
    Remove RTS hack for configuring
    
    See the brand new Note [Undefined symbols in the RTS] for additional
    details.
    
    - - - - -
    e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00
    Handle shadowing in DmdAnal (#22718)
    
    Previously, when we had a shadowing situation like
    ```hs
    f x = ... -- demand signature <1L><1L>
    
    main = ... \f -> f 1 ...
    ```
    we'd happily use the shadowed demand signature at the call site inside the
    lambda. Of course, that's wrong and solution is simply to remove the demand
    signature from the `AnalEnv` when we enter the lambda.
    This patch does so for all binding constructs Core.
    
    In #22718 the issue was caused by LetUp not shadowing away the existing demand
    signature for the let binder in the let body. The resulting absent error is
    fickle to reproduce; hence no reproduction test case. #17478 would help.
    
    Fixes #22718.
    
    It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that
    DmdAnal was exploiting ill-scoped analysis results.
    
    Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate):
        TcPlugin_Rewrite
    
    - - - - -
    d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00
    Add safe list indexing operator: !?
    
    With Joachim's amendments.
    
    Implements https://github.com/haskell/core-libraries-committee/issues/110
    
    - - - - -
    cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00
    rts, tests: limit thread name length to 15 bytes
    
    On Linux, `pthread_setname_np` (or rather, the kernel) only allows for
    thread names up to 16 bytes, including the terminating null byte.
    
    This commit adds a note pointing this out in `createOSThread`, and fixes
    up two instances where a thread name of more than 15 characters long was
    used (in the RTS, and in a test-case).
    
    Fixes: #22366
    Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796
    
    - - - - -
    64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00
    Store bootstrap_llvm_target and use it to set LlvmTarget in bindists
    
    This mirrors some existing logic for the bootstrap_target which
    influences how TargetPlatform is set.
    
    As described on #21970 not storing this led to `LlvmTarget` being set incorrectly
    and hence the wrong `--target` flag being passed to the C compiler.
    
    Towards #21970
    
    - - - - -
    4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00
    Check for FP_LD_NO_FIXUP_CHAINS in installation configure script
    
    Otherwise, when installing from a bindist the C flag isn't passed to the
    C compiler.
    
    This completes the fix for #22429
    
    - - - - -
    2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00
    Fix outdated link to Happy section on sequences
    
    - - - - -
    146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00
    Revert "NCG(x86): Compile add+shift as lea if possible."
    
    This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a.
    
    See #22666 and #21777
    
    - - - - -
    6e6adbe3 by Jade Lovelace at 2023-01-11T00:55:30-05:00
    Fix tcPluginRewrite example
    
    - - - - -
    faa57138 by Jade Lovelace at 2023-01-11T00:55:31-05:00
    fix missing haddock pipe
    
    - - - - -
    0470ea7c by Florian Weimer at 2023-01-11T00:56:10-05:00
    m4/fp_leading_underscore.m4: Avoid implicit exit function declaration
    
    And switch to a new-style function definition.
    
    Fixes build issues with compilers that do not accept implicit function
    declarations.
    
    - - - - -
    b2857df4 by HaskellMouse at 2023-01-11T00:56:52-05:00
    Added a new warning about compatibility with RequiredTypeArguments
    
    This commit introduces a new warning
    that indicates code incompatible with
    future extension: RequiredTypeArguments.
    
    Enabling this extension may break some code and the warning
    will help to make it compatible in advance.
    
    - - - - -
    5f17e21a by Ben Gamari at 2023-01-11T00:57:27-05:00
    testsuite: Drop testheapalloced.c
    
    As noted in #22414, this file (which appears to be a benchmark for
    characterising the one-step allocator's MBlock cache) is currently 
    unreferenced. Remove it.
    
    Closes #22414. 
    - - - - -
    bc125775 by Vladislav Zavialov at 2023-01-11T00:58:03-05:00
    Introduce the TypeAbstractions language flag
    
    GHC Proposals #448 "Modern scoped type variables"
    and #425 "Invisible binders in type declarations"
    introduce a new language extension flag: TypeAbstractions.
    
    Part of the functionality guarded by this flag has already been
    implemented, namely type abstractions in constructor patterns, but it
    was guarded by a combination of TypeApplications and ScopedTypeVariables
    instead of a dedicated language extension flag.
    
    This patch does the following:
    
    * introduces a new language extension flag TypeAbstractions
    * requires TypeAbstractions for @a-syntax in constructor patterns
      instead of TypeApplications and ScopedTypeVariables
    * creates a User's Guide page for TypeAbstractions and
      moves the "Type Applications in Patterns" section there
    
    To avoid a breaking change, the new flag is implied by
    ScopedTypeVariables and is retroactively added to GHC2021.
    
    Metric Decrease:
        MultiLayerModulesTH_OneShot
    
    - - - - -
    083f7015 by Krzysztof Gogolewski at 2023-01-11T00:58:38-05:00
    Misc cleanup
    
    - Remove unused mkWildEvBinder
    - Use typeTypeOrConstraint - more symmetric and asserts that
      that the type is Type or Constraint
    - Fix escape sequences in Python; they raise a deprecation warning
      with -Wdefault
    
    - - - - -
    aed1974e by Richard Eisenberg at 2023-01-11T08:30:42+00:00
    Refactor the treatment of loopy superclass dicts
    
    This patch completely re-engineers how we deal with loopy superclass
    dictionaries in instance declarations. It fixes #20666 and #19690
    
    The highlights are
    
    * Recognise that the loopy-superclass business should use precisely
      the Paterson conditions.  This is much much nicer.  See
      Note [Recursive superclasses] in GHC.Tc.TyCl.Instance
    
    * With that in mind, define "Paterson-smaller" in
      Note [Paterson conditions] in GHC.Tc.Validity, and the new
      data type `PatersonSize` in GHC.Tc.Utils.TcType, along with
      functions to compute and compare PatsonSizes
    
    * Use the new PatersonSize stuff when solving superclass constraints
      See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance
    
    * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to
      prohibitedSuperClassSolve.  This was the original cause of #20666.
    
    * Treat (TypeError "stuff") as having PatersonSize zero. See
      Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType.
    
    * Treat the head of a Wanted quantified constraint in the same way
      as the superclass of an instance decl; this is what fixes #19690.
      See GHC.Tc.Solver.Canonical Note [Solving a Wanted forall-constraint]
      (Thanks to Matthew Craven for this insight.)
    
      This entailed refactoring the GivenSc constructor of CtOrigin a bit,
      to say whether it comes from an instance decl or quantified constraint.
    
    * Some refactoring way in which redundant constraints are reported; we
      don't want to complain about the extra, apparently-redundant
      constraints that we must add to an instance decl because of the
      loopy-superclass thing.  I moved some work from GHC.Tc.Errors to
      GHC.Tc.Solver.
    
    * Add a new section to the user manual to describe the loopy
      superclass issue and what rules it follows.
    
    - - - - -
    300bcc15 by HaskellMouse at 2023-01-11T13:43:36-05:00
    Parse qualified terms in type signatures
    
    This commit allows qualified terms in type
    signatures to pass the parser and to be cathced by renamer
    with more informative error message. Adds a few tests.
    
    Fixes #21605
    
    - - - - -
    964284fc by Simon Peyton Jones at 2023-01-11T13:44:12-05:00
    Fix void-arg-adding mechanism for worker/wrapper
    
    As #22725 shows, in worker/wrapper we must add the void argument
    /last/, not first.  See GHC.Core.Opt.WorkWrap.Utils
    Note [Worker/wrapper needs to add void arg last].
    
    That led me to to study GHC.Core.Opt.SpecConstr
    Note [SpecConstr needs to add void args first] which suggests the
    opposite!  And indeed I think it's the other way round for SpecConstr
    -- or more precisely the void arg must precede the "extra_bndrs".
    
    That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo.
    
    - - - - -
    f7ceafc9 by Krzysztof Gogolewski at 2023-01-11T22:36:59-05:00
    Add 'docWithStyle' to improve codegen
    
    This new combinator
    
    docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc
    
    let us remove the need for code to be polymorphic in HDoc
    when not used in code style.
    
    Metric Decrease:
        ManyConstructors
        T13035
        T1969
    
    - - - - -
    b3be0d18 by Simon Peyton Jones at 2023-01-11T22:37:35-05:00
    Fix finaliseArgBoxities for OPAQUE function
    
    We never do worker wrapper for OPAQUE functions, so we must
    zap the unboxing info during strictness analysis.
    
    This patch fixes #22502
    
    - - - - -
    db11f358 by Ben Gamari at 2023-01-12T07:49:04-05:00
    Revert "rts: Drop racy assertion"
    
    The logic here was inverted. Reverting the commit to avoid confusion
    when examining the commit history.
    
    This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1.
    
    - - - - -
    3242139f by Ben Gamari at 2023-01-12T07:49:04-05:00
    rts: Drop racy assertion
    
    0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in
    `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean.
    However, this isn't necessarily the case since another thread may have
    raced us to dirty the object.
    
    - - - - -
    9ffd5d57 by Ben Gamari at 2023-01-12T07:49:41-05:00
    configure: Fix escaping of `$tooldir`
    
    In !9547 I introduced `$tooldir` directories into GHC's default link and
    compilation flags to ensure that our C toolchain finds its own headers
    and libraries before others on the system. However, the patch was subtly
    wrong in the escaping of `$tooldir`. Fix this.
    
    Fixes #22561.
    
    - - - - -
    905d0b6e by Sebastian Graf at 2023-01-12T15:51:47-05:00
    Fix contification with stable unfoldings (#22428)
    
    Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with
    a `JoinArity` that reflects the number of join point binders around the body
    for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by
    `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`.
    
    I adjusted `Note [Join points and unfoldings/rules]` and
    `Note [Adjusting right-hand sides]` to account for the new machinery.
    I also wrote a new `Note [Join arity prediction based on joinRhsArity]`
    and refer to it when we combine `TailUsageDetails` for a recursive RHS.
    
    I also renamed
    
      * `occAnalLam` to `occAnalLamTail`
      * `adjustRhsUsage` to `adjustTailUsage`
      * a few other less important functions
    
    and properly documented the that each call of `occAnalLamTail` must pair up with
    `adjustTailUsage`.
    
    I removed `Note [Unfoldings and join points]` because it was redundant with
    `Note [Occurrences in stable unfoldings]`.
    
    While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed
    `NodeDetails` called `SimpleNodeDetails`.
    
    Fixes #22428.
    
    The refactoring seems to have quite beneficial effect on ghc/alloc performance:
    
    ```
         CoOpt_Read(normal) ghc/alloc    784,778,420    768,091,176  -2.1% GOOD
             T12150(optasm) ghc/alloc     77,762,270     75,986,720  -2.3% GOOD
             T12425(optasm) ghc/alloc     85,740,186     84,641,712  -1.3% GOOD
             T13056(optasm) ghc/alloc    306,104,656    299,811,632  -2.1% GOOD
             T13253(normal) ghc/alloc    350,233,952    346,004,008  -1.2%
             T14683(normal) ghc/alloc  2,800,514,792  2,754,651,360  -1.6%
             T15304(normal) ghc/alloc  1,230,883,318  1,215,978,336  -1.2%
             T15630(normal) ghc/alloc    153,379,590    151,796,488  -1.0%
             T16577(normal) ghc/alloc  7,356,797,056  7,244,194,416  -1.5%
             T17516(normal) ghc/alloc  1,718,941,448  1,692,157,288  -1.6%
             T19695(normal) ghc/alloc  1,485,794,632  1,458,022,112  -1.9%
            T21839c(normal) ghc/alloc    437,562,314    431,295,896  -1.4% GOOD
            T21839r(normal) ghc/alloc    446,927,580    440,615,776  -1.4% GOOD
    
                  geo. mean                                          -0.6%
                  minimum                                            -2.4%
                  maximum                                            -0.0%
    ```
    
    Metric Decrease:
        CoOpt_Read
        T10421
        T12150
        T12425
        T13056
        T18698a
        T18698b
        T21839c
        T21839r
        T9961
    
    - - - - -
    a1491c87 by Andreas Klebinger at 2023-01-12T15:52:23-05:00
    Only gc sparks locally when we can ensure marking is done.
    
    When performing GC without work stealing there was no guarantee that
    spark pruning was happening after marking of the sparks. This could
    cause us to GC live sparks under certain circumstances.
    
    Fixes #22528.
    
    - - - - -
    8acfe930 by Cheng Shao at 2023-01-12T15:53:00-05:00
    Change MSYSTEM to CLANG64 uniformly
    
    - - - - -
    73bc162b by M Farkas-Dyck at 2023-01-12T15:53:42-05:00
    Make `GHC.Tc.Errors.Reporter` take `NonEmpty ErrorItem` rather than `[ErrorItem]`, which lets us drop some panics.
    
    Also use the `BasicMismatch` constructor rather than `mkBasicMismatchMsg`, which lets us drop the "-Wno-incomplete-record-updates" flag.
    
    - - - - -
    1b812b69 by Oleg Grenrus at 2023-01-12T15:54:21-05:00
    Fix #22728: Not all diagnostics in safe check are fatal
    
    Also add tests for the issue and -Winferred-safe-imports in general
    
    - - - - -
    c79b2b65 by Matthew Pickering at 2023-01-12T15:54:58-05:00
    Don't run hadrian-multi on fast-ci label
    
    Fixes #22667
    
    - - - - -
    9a3d6add by Andrew Lelechenko at 2023-01-13T00:46:36-05:00
    Bump submodule bytestring to 0.11.4.0
    
    Metric Decrease:
        T21839c
        T21839r
    
    - - - - -
    df33c13c by Ben Gamari at 2023-01-13T00:47:12-05:00
    gitlab-ci: Bump Darwin bootstrap toolchain
    
    This updates the bootstrap compiler on Darwin from 8.10.7 to 9.2.5,
    ensuring that we have the fix for #21964.
    
    - - - - -
    756a66ec by Ben Gamari at 2023-01-13T00:47:12-05:00
    gitlab-ci: Pass -w to cabal update
    
    Due to cabal#8447, cabal-install 3.8.1.0 requires a compiler to run
    `cabal update`.
    - - - - -
    1142f858 by Cheng Shao at 2023-01-13T11:04:00+00:00
    Bump hsc2hs submodule
    
    - - - - -
    d4686729 by Cheng Shao at 2023-01-13T11:04:00+00:00
    Bump process submodule
    
    - - - - -
    84ae6573 by Cheng Shao at 2023-01-13T11:06:58+00:00
    ci: Bump DOCKER_REV
    
    - - - - -
    d53598c5 by Cheng Shao at 2023-01-13T11:06:58+00:00
    ci: enable xz parallel compression for x64 jobs
    
    - - - - -
    d31fcbca by Cheng Shao at 2023-01-13T11:06:58+00:00
    ci: use in-image emsdk for js jobs
    
    - - - - -
    93b9bbc1 by Cheng Shao at 2023-01-13T11:47:17+00:00
    ci: improve nix-shell for gen_ci.hs and fix some ghc/hlint warnings
    
    - Add a ghc environment including prebuilt dependencies to the
      nix-shell. Get rid of the ad hoc cabal cache and all dependencies
      are now downloaded from the nixos binary cache.
    - Make gen_ci.hs a cabal package with HLS integration, to make future
      hacking of gen_ci.hs easier.
    - Fix some ghc/hlint warnings after I got HLS to work.
    - For the lint-ci-config job, do a shallow clone to save a few minutes
      of unnecessary git checkout time.
    
    - - - - -
    8acc56c7 by Cheng Shao at 2023-01-13T11:47:17+00:00
    ci: source the toolchain env file in wasm jobs
    
    - - - - -
    87194df0 by Cheng Shao at 2023-01-13T11:47:17+00:00
    ci: add wasm ci jobs via gen_ci.hs
    
    - There is one regular wasm job run in validate pipelines
    - Additionally, int-native/unreg wasm jobs run in nightly/release pipelines
    
    Also, remove the legacy handwritten wasm ci jobs in .gitlab-ci.yml.
    
    - - - - -
    b6eb9bcc by Matthew Pickering at 2023-01-13T11:52:16+00:00
    wasm ci: Remove wasm release jobs
    
    This removes the wasm release jobs, as we do not yet intend to
    distribute these binaries.
    
    - - - - -
    496607fd by Simon Peyton Jones at 2023-01-13T16:52:07-05:00
    Add a missing checkEscapingKind
    
    Ticket #22743 pointed out that there is a missing check,
    for type-inferred bindings, that the inferred type doesn't
    have an escaping kind.
    
    The fix is easy.
    
    - - - - -
    7a9a1042 by Andreas Klebinger at 2023-01-16T20:48:19-05:00
    Separate core inlining logic from `Unfolding` type.
    
    This seems like a good idea either way, but is mostly motivated by a
    patch where this avoids a module loop.
    
    - - - - -
    33b58f77 by sheaf at 2023-01-16T20:48:57-05:00
    Hadrian: generalise &%> to avoid warnings
    
    This patch introduces a more general version of &%> that works
    with general traversable shapes, instead of lists. This allows us
    to pass along the information that the length of the list of filepaths
    passed to the function exactly matches the length of the input list
    of filepath patterns, avoiding pattern match warnings.
    
    Fixes #22430
    
    - - - - -
    8c7a991c by Andreas Klebinger at 2023-01-16T20:49:34-05:00
    Add regression test for #22611.
    
    A case were a function used to fail to specialize, but now does.
    
    - - - - -
    6abea760 by Andreas Klebinger at 2023-01-16T20:50:10-05:00
    Mark maximumBy/minimumBy as INLINE.
    
    The RHS was too large to inline which often prevented the overhead of the Maybe
    from being optimized away. By marking it as INLINE we can eliminate the
    overhead of both the maybe and are able to unpack the accumulator when
    possible.
    
    Fixes #22609
    
    - - - - -
    99d151bb by Matthew Pickering at 2023-01-16T20:50:50-05:00
    ci: Bump CACHE_REV so that ghc-9.6 branch and HEAD have different caches
    
    Having the same CACHE_REV on both branches leads to issues where the
    darwin toolchain is different on ghc-9.6 and HEAD which leads to long
    darwin build times.
    
    In general we should ensure that each branch has a different CACHE_REV.
    
    - - - - -
    6a5845fb by Matthew Pickering at 2023-01-16T20:51:25-05:00
    ci: Change owner of files in source-tarball job
    
    This fixes errors of the form:
    
    ```
    fatal: detected dubious ownership in repository at '/builds/ghc/ghc'
    To add an exception for this directory, call:
    	git config --global --add safe.directory /builds/ghc/ghc
    inferred 9.7.20230113
    checking for GHC Git commit id... fatal: detected dubious ownership in repository at '/builds/ghc/ghc'
    To add an exception for this directory, call:
    	git config --global --add safe.directory /builds/ghc/ghc
    ```
    
    - - - - -
    4afb952c by Matthew Pickering at 2023-01-16T20:51:25-05:00
    ci: Don't build aarch64-deb10-llvm job on release pipelines
    
    Closes #22721
    
    - - - - -
    8039feb9 by Matthew Pickering at 2023-01-16T20:51:25-05:00
    ci: Change owner of files in test-bootstrap job
    
    - - - - -
    0b358d0c by Matthew Pickering at 2023-01-16T20:51:25-05:00
    rel_eng: Add release engineering scripts into ghc tree
    
    It is better to keep these scripts in the tree as they depend on the CI
    configuration and so on. By keeping them in tree we can keep them
    up-to-date as the CI config changes and also makes it easier to backport
    changes to the release script between release branches in future.
    
    The final motivation is that it makes generating GHCUp metadata
    possible.
    
    - - - - -
    28cb2ed0 by Matthew Pickering at 2023-01-16T20:51:25-05:00
    ci: Don't use complicated image or clone in not-interruptible job
    
    This job exists only for the meta-reason of not allowing nightly
    pipelines to be cancelled. It was taking two minutes to run as in order
    to run "true" we would also clone the whole GHC repo.
    
    - - - - -
    eeea59bb by Matthew Pickering at 2023-01-16T20:51:26-05:00
    Add scripts to generate ghcup metadata on nightly and release pipelines
    
    1. A python script in .gitlab/rel_eng/mk-ghcup-metadata which generates
       suitable metadata for consumption by GHCUp for the relevant
       pipelines.
    
      - The script generates the metadata just as the ghcup maintainers
        want, without taking into account platform/library combinations. It
        is updated manually when the mapping changes.
    
      - The script downloads the bindists which ghcup wants to distribute,
        calculates the hash and generates the yaml in the correct structure.
    
      - The script is documented in the .gitlab/rel_eng/mk-ghcup-metadata/README.mk file
    
    1a. The script requires us to understand the mapping from platform ->
        job. To choose the preferred bindist for each platform the
        .gitlab/gen_ci.hs script is modified to allow outputting a metadata
        file which answers the question about which job produces the
        bindist which we want to distribute to users for a specific
        platform.
    
    2. Pipelines to run on nightly and release jobs to generate metadata
    
      - ghcup-metadata-nightly: Generates metadata which points directly to
        artifacts in the nightly job.
    
      - ghcup-metadata-release: Generates metadata suitable for inclusion
        directly in ghcup by pointing to the downloads folder where the
        bindist will be uploaded to.
    
    2a. Trigger jobs which test the generated metadata in the downstream
        `ghccup-ci` repo. See that repo for documentation about what is
        tested and how but essentially we test in a variety of clean images
        that ghcup can download and install the bindists we say exist in our
        metadata.
    
    - - - - -
    97bd4d8c by Andrew Lelechenko at 2023-01-16T20:52:04-05:00
    Bump submodule parsec to 3.1.16.1
    
    - - - - -
    97ac8230 by Alan Zimmerman at 2023-01-16T20:52:39-05:00
    EPA: Add annotation for 'type' in DataDecl
    
    Closes #22765
    
    - - - - -
    dbbab95d by Ben Gamari at 2023-01-17T06:36:06-05:00
    compiler: Small optimisation of assertM
    
    In #22739 @AndreasK noticed that assertM performed the action to compute
    the asserted predicate regardless of whether DEBUG is enabled. This is
    inconsistent with the other assertion operations and general convention.
    Fix this.
    
    Closes #22739.
    
    - - - - -
    fc02f3bb by Viktor Dukhovni at 2023-01-17T06:36:47-05:00
    Avoid unnecessary printf warnings in EventLog.c
    
    Fixes #22778
    
    - - - - -
    003b6d44 by Simon Peyton Jones at 2023-01-17T16:33:05-05:00
    Document the semantics of pattern bindings a bit better
    
    This MR is in response to the discussion on #22719
    
    - - - - -
    f4d50baf by Vladislav Zavialov at 2023-01-17T16:33:41-05:00
    Hadrian: fix warnings (#22783)
    
    This change fixes the following warnings when building Hadrian:
    
    	src/Hadrian/Expression.hs:38:10: warning: [-Wredundant-constraints]
    	src/Hadrian/Expression.hs:84:13: warning: [-Wtype-equality-requires-operators]
    	src/Hadrian/Expression.hs:84:21: warning: [-Wtype-equality-requires-operators]
    	src/Hadrian/Haskell/Cabal/Parse.hs:67:1: warning: [-Wunused-imports]
    
    - - - - -
    06036d93 by Sylvain Henry at 2023-01-18T01:55:10-05:00
    testsuite: req_smp --> req_target_smp, req_ghc_smp
    
    See #22630 and !9552
    
    This commit:
     - splits req_smp into req_target_smp and req_ghc_smp
     - changes the testsuite driver to calculate req_ghc_smp
     - changes a handful of tests to use req_target_smp instead of req_smp
     - changes a handful of tests to use req_host_smp when needed
    
    The problem:
     - the problem this solves is the ambiguity surrounding req_smp
     - on master req_smp was used to express the constraint that the program
     being compiled supports smp _and_ that the host RTS (i.e., the RTS used
     to compile the program) supported smp. Normally that is fine, but in
     cross compilation this is not always the case as was discovered in #22630.
    
    The solution:
     - Differentiate the two constraints:
       - use req_target_smp to say the RTS the compiled program is linked
       with (and the platform) supports smp
       - use req_host_smp to say the RTS the host is linked with supports smp
    
    WIP: fix req_smp (target vs ghc)
    
    add flag to separate bootstrapper
    
    split req_smp -> req_target_smp and req_ghc_smp
    
    update tests smp flags
    
    cleanup and add some docstrings
    
    only set ghc_with_smp to bootstrapper on S1 or CC
    
    Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1
    and cross compiling
    
    test the RTS in config/ghc not hadrian
    
    re-add ghc_with_smp
    
    fix and align req names
    
    fix T11760 to use req_host_smp
    
    test the rts directly, avoid python 3.5 limitation
    
    test the compiler in a try block
    
    align out of tree and in tree withSMP flags
    
    mark failing tests as host req smp
    
    testsuite: req_host_smp --> req_ghc_smp
    
    Fix ghc vs host, fix ghc_with_smp leftover
    
    - - - - -
    ee9b78aa by Krzysztof Gogolewski at 2023-01-18T01:55:45-05:00
    Use -Wdefault when running Python testdriver (#22727)
    
    - - - - -
    e9c0537c by Vladislav Zavialov at 2023-01-18T01:56:22-05:00
    Enable -Wstar-is-type by default (#22759)
    
    Following the plan in GHC Proposal #143 "Remove the * kind syntax",
    which states:
    
    	In the next release (or 3 years in), enable -fwarn-star-is-type by default.
    
    The "next release" happens to be 9.6.1
    
    I also moved the T21583 test case from should_fail to should_compile,
    because the only reason it was failing was -Werror=compat in our test
    suite configuration.
    
    - - - - -
    4efee43d by Ryan Scott at 2023-01-18T01:56:59-05:00
    Add missing parenthesizeHsType in cvtSigTypeKind
    
    We need to ensure that the output of `cvtSigTypeKind` is parenthesized (at
    precedence `sigPrec`) so that any type signatures with an outermost, explicit
    kind signature can parse correctly.
    
    Fixes #22784.
    
    - - - - -
    f891a442 by Ben Gamari at 2023-01-18T07:28:00-05:00
    Bump ghc-tarballs to fix #22497
    
    It turns out that gmp 6.2.1 uses the platform-reserved `x18` register on
    AArch64/Darwin. This was fixed in upstream changeset 18164:5f32dbc41afc,
    which was merged in 2020. Here I backport this patch although I do hope
    that a new release is forthcoming soon.
    
    Bumps gmp-tarballs submodule.
    
    Fixes #22497.
    
    - - - - -
    b13c6ea5 by Ben Gamari at 2023-01-18T07:28:00-05:00
    Bump gmp-tarballs submodule
    
    This backports the upstream fix for CVE-2021-43618, fixing #22789.
    
    - - - - -
    c45a5fff by Cheng Shao at 2023-01-18T07:28:37-05:00
    Fix typo in recent darwin tests fix
    
    Corrects a typo in !9647. Otherwise T18623 will still fail on darwin
    and stall other people's work.
    
    - - - - -
    b4c14c4b by Luite Stegeman at 2023-01-18T14:21:42-05:00
    Add PrimCallConv support to GHCi
    
    This adds support for calling Cmm code from bytecode using the native
    calling convention, allowing modules that use `foreign import prim`
    to be loaded and debugged in GHCi.
    
    This patch introduces a new `PRIMCALL` bytecode instruction and
    a helper stack frame `stg_primcall`. The code is based on the
    existing functionality for dealing with unboxed tuples in bytecode,
    which has been generalised to handle arbitrary calls.
    
    Fixes #22051
    
    - - - - -
    d0a63ef8 by Adam Gundry at 2023-01-18T14:22:26-05:00
    Refactor warning flag parsing to add missing flags
    
    This adds `-Werror=<group>` and `-fwarn-<group>` flags for warning
    groups as well as individual warnings. Previously these were defined
    on an ad hoc basis so for example we had `-Werror=compat` but not
    `-Werror=unused-binds`, whereas we had `-fwarn-unused-binds` but not
    `-fwarn-compat`. Fixes #22182.
    
    - - - - -
    7ed1b8ef by Adam Gundry at 2023-01-18T14:22:26-05:00
    Minor corrections to comments
    
    - - - - -
    5389681e by Adam Gundry at 2023-01-18T14:22:26-05:00
    Revise warnings documentation in user's guide
    
    - - - - -
    ab0d5cda by Adam Gundry at 2023-01-18T14:22:26-05:00
    Move documentation of deferred type error flags out of warnings section
    
    - - - - -
    eb5a6b91 by John Ericson at 2023-01-18T22:24:10-05:00
    Give the RTS it's own configure script
    
    Currently it doesn't do much anything, we are just trying to introduce
    it without breaking the build. Later, we will move functionality from
    the top-level configure script over to it.
    
    We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to
    facilitate and existing hack of skipping some configure checks for the
    RTS we now need to skip just *part* not *all* of the "post configure"
    hook, as running the configure script (which we definitely want to do)
    is also implemented as part of the "post configure" hook. But doing this
    requires exposing functionality that wasn't exposed before.
    
    - - - - -
    32ab07bf by Andrew Lelechenko at 2023-01-18T22:24:51-05:00
    ghc package does not have to depend on terminfo
    
    - - - - -
    981ff7c4 by Andrew Lelechenko at 2023-01-18T22:24:51-05:00
    ghc-pkg does not have to depend on terminfo
    
    - - - - -
    f058e367 by Ben Gamari at 2023-01-18T22:25:27-05:00
    nativeGen/X86: MFENCE is unnecessary for release semantics
    
    In #22764 a user noticed that a program implementing a simple atomic
    counter via an STRef regressed significantly due to the introduction of
    necessary atomic operations in the MutVar# primops (#22468). This
    regression was caused by a bug in the NCG, which emitted an unnecessary
    MFENCE instruction for a release-ordered atomic write. MFENCE is rather
    only needed to achieve sequentially consistent ordering.
    
    Fixes #22764.
    
    - - - - -
    154889db by Ryan Scott at 2023-01-18T22:26:03-05:00
    Add regression test for #22151
    
    Issue #22151 was coincidentally fixed in commit
    aed1974e92366ab8e117734f308505684f70cddf (`Refactor the treatment of loopy
    superclass dicts`). This adds a regression test to ensure that the issue
    remains fixed.
    
    Fixes #22151.
    
    - - - - -
    14b5982a by Andrei Borzenkov at 2023-01-18T22:26:43-05:00
    Fix printing of promoted MkSolo datacon (#22785)
    
    Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo,
    and Solo was turned into a pattern synonym for backwards compatibility.
    Since pattern synonyms can not be promoted, the old code that pretty-printed
    promoted single-element tuples started producing ill-typed code:
       t :: Proxy ('Solo Int)
    This fails with "Pattern synonym ‘Solo’ used as a type"
    
    The solution is to track the distinction between type constructors and data
    constructors more carefully when printing single-element tuples.
    
    - - - - -
    1fe806d3 by Cheng Shao at 2023-01-23T04:48:47-05:00
    hadrian: add hi_core flavour transformer
    
    The hi_core flavour transformer enables -fwrite-if-simplified-core for
    stage1 libraries, which emit core into interface files to make it
    possible to restart code generation. Building boot libs with it makes
    it easier to use GHC API to prototype experimental backends that needs
    core/stg at link time.
    
    - - - - -
    317cad26 by Cheng Shao at 2023-01-23T04:48:47-05:00
    hadrian: add missing docs for recently added flavour transformers
    
    - - - - -
    658f4446 by Ben Gamari at 2023-01-23T04:49:23-05:00
    gitlab-ci: Add Rocky8 jobs
    
    Addresses #22268.
    
    - - - - -
    a83ec778 by Vladislav Zavialov at 2023-01-23T04:49:58-05:00
    Set "since: 9.8" for TypeAbstractions and -Wterm-variable-capture
    
    These flags did not make it into the 9.6 release series,
    so the "since" annotations must be corrected.
    
    - - - - -
    fec7c2ea by Alan Zimmerman at 2023-01-23T04:50:33-05:00
    EPA: Add SourceText to HsOverLabel
    
    To be able to capture string literals with possible escape codes as labels.
    
    Close #22771
    
    - - - - -
    3efd1e99 by Ben Gamari at 2023-01-23T04:51:08-05:00
    template-haskell: Bump version to 2.20.0.0
    
    Updates `text` and `exceptions` submodules for bounds bumps.
    
    Addresses #22767.
    
    - - - - -
    0900b584 by Cheng Shao at 2023-01-23T04:51:45-05:00
    hadrian: disable alloca for in-tree GMP on wasm32
    
    When building in-tree GMP for wasm32, disable its alloca usage, since
    it may potentially cause stack overflow (e.g. #22602).
    
    - - - - -
    db0f1bfd by Cheng Shao at 2023-01-23T04:52:21-05:00
    Bump process submodule
    
    Includes a critical fix for wasm32, see
    https://github.com/haskell/process/pull/272 for details. Also changes
    the existing cross test to include process stuff and avoid future
    regression here.
    
    - - - - -
    9222b167 by Matthew Pickering at 2023-01-23T04:52:57-05:00
    ghcup metadata: Fix subdir for windows bindist
    
    - - - - -
    9a9bec57 by Matthew Pickering at 2023-01-23T04:52:57-05:00
    ghcup metadata: Remove viPostRemove field from generated metadata
    
    This has been removed from the downstream metadata.
    
    - - - - -
    82884ce0 by Simon Peyton Jones at 2023-01-23T04:53:32-05:00
    Fix #22742
    
    runtimeRepLevity_maybe was panicing unnecessarily; and
    the error printing code made use of the case when it should
    return Nothing rather than panicing.
    
    For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime
    peak-megagbytes-used, on a single architecture (alpine). See !9753 for
    commentary, but I'm going to accept it.
    
    Metric Increase:
        T21839r
    
    - - - - -
    2c6deb18 by Bryan Richter at 2023-01-23T14:12:22+02:00
    codeowners: Add Ben, Matt, and Bryan to CI
    
    - - - - -
    eee3bf05 by Matthew Craven at 2023-01-23T21:46:41-05:00
    Do not collect compile-time metrics for T21839r
    
    ...the testsuite doesn't handle this properly since it
    also collects run-time metrics.  Compile-time metrics
    for this test are already tracked via T21839c.
    
    Metric Decrease:
        T21839r
    
    - - - - -
    1d1dd3fb by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Fix recompilation checking for multiple home units
    
    The key part of this change is to store a UnitId in the
    `UsageHomeModule` and `UsageHomeModuleInterface`.
    
    * Fine-grained dependency tracking is used if the dependency comes from
      any home unit.
    * We actually look up the right module when checking whether we need to
      recompile in the `UsageHomeModuleInterface` case.
    
    These scenarios are both checked by the new tests (
    multipleHomeUnits_recomp and multipleHomeUnits_recomp_th )
    
    Fixes #22675
    
    - - - - -
    7bfb30f9 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Augment target filepath by working directory when checking if module satisfies target
    
    This fixes a spurious warning in -Wmissing-home-modules.
    
    This is a simple oversight where when looking for the target in the
    first place we augment the search by the -working-directory flag but
    then fail to do so when checking this warning.
    
    Fixes #22676
    
    - - - - -
    69500dd4 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Use NodeKey rather than ModuleName in pruneCache
    
    The `pruneCache` function assumes that the list of `CachedInfo` all have unique `ModuleName`, this is not true:
    
    * In normal compilation, the same module name can appear for a file and it's boot file.
    * In multiple home unit compilation the same ModuleName can appear in different units
    
    The fix is to use a `NodeKey` as the actual key for the interfaces which includes `ModuleName`, `IsBoot` and `UnitId`.
    
    Fixes #22677
    
    - - - - -
    336b2b1c by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Recompilation checking: Don't try to find artefacts for Interactive & hs-boot combo
    
    In interactive mode we don't produce any linkables for hs-boot files. So
    we also need to not going looking for them when we check to see if we
    have all the right objects needed for recompilation.
    
    Ticket #22669
    
    - - - - -
    6469fea7 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Don't write o-boot files in Interactive mode
    
    We should not be producing object files when in interactive mode but we
    still produced the dummy o-boot files. These never made it into a
    `Linkable` but then confused the recompilation checker.
    
    Fixes #22669
    
    - - - - -
    06cc0a95 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Improve driver diagnostic messages by including UnitId in message
    
    Currently the driver diagnostics don't give any indication about which unit they correspond to.
    
    For example `-Wmissing-home-modules` can fire multiple times for each different home unit and gives no indication about which unit it's actually reporting about.
    
    Perhaps a longer term fix is to generalise the providence information away from a SrcSpan so that these kind of whole project errors can be reported with an accurate provenance. For now we can just include the `UnitId` in the error message.
    
    Fixes #22678
    
    - - - - -
    4fe9eaff by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Key ModSummary cache by UnitId as well as FilePath
    
    Multiple units can refer to the same files without any problem. Just
    another assumption which needs to be updated when we may have multiple
    home units.
    
    However, there is the invariant that within each unit each file only
    maps to one module, so as long as we also key the cache by UnitId then
    we are all good.
    
    This led to some confusing behaviour in GHCi when reloading,
    multipleHomeUnits_shared distils the essence of what can go wrong.
    
    Fixes #22679
    
    - - - - -
    ada29f5c by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Finder: Look in current unit before looking in any home package dependencies
    
    In order to preserve existing behaviour it's important to look within the current component before consideirng a module might come from an external component.
    
    This already happened by accident in `downsweep`, (because roots are used to repopulated the cache) but in the `Finder` the logic was the wrong way around.
    
    Fixes #22680
    
    -------------------------
    Metric Decrease:
        MultiComponentModules
        MultiComponentModulesRecomp
    -------------------------p
    
    - - - - -
    be701cc6 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Debug: Print full NodeKey when pretty printing ModuleGraphNode
    
    This is helpful when debugging multiple component issues.
    
    - - - - -
    34d2d463 by Krzysztof Gogolewski at 2023-01-24T05:38:32-05:00
    Fix Lint check for duplicate external names
    
    Lint was checking for duplicate external names by calling removeDups,
    which needs a comparison function that is passed to Data.List.sortBy.
    But the comparison was not a valid ordering - it returned LT
    if one of the names was not external.
    For example, the previous implementation won't find a duplicate in
    [M.x, y, M.x].
    Instead, we filter out non-external names before looking for duplicates.
    
    - - - - -
    1c050ed2 by Matthew Pickering at 2023-01-24T05:39:08-05:00
    Add test for T22671
    
    This was fixed by b13c6ea5
    
    Closes #22671
    
    - - - - -
    05e6a2d9 by Tom Ellis at 2023-01-24T12:10:52-05:00
    Clarify where `f` is defined
    
    - - - - -
    d151546e by Cheng Shao at 2023-01-24T12:11:29-05:00
    CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target
    
    We used to print the offset value to a platform word sized integer.
    This is incorrect when the offset is negative (e.g. output of cmm
    constant folding) and the register is 64-bit but on a 32-bit target,
    and may lead to incorrect runtime result (e.g. #22607).
    
    The fix is simple: just treat it as a proper MO_Add, with the correct
    width info inferred from the register itself.
    
    Metric Increase:
        T12707
        T13379
        T4801
        T5321FD
        T5321Fun
    
    - - - - -
    e5383a29 by Wander Hillen at 2023-01-24T20:02:26-05:00
    Allow waiting for timerfd to be interrupted during rts shutdown
    
    - - - - -
    1957eda1 by Ryan Scott at 2023-01-24T20:03:01-05:00
    Restore Compose's Read/Show behavior to match Read1/Show1 instances
    
    Fixes #22816.
    
    - - - - -
    30972827 by Matthew Pickering at 2023-01-25T03:54:14-05:00
    docs: Update INSTALL.md
    
    Removes references to make.
    
    Fixes #22480
    
    - - - - -
    bc038c3b by Cheng Shao at 2023-01-25T03:54:50-05:00
    compiler: fix handling of MO_F_Neg in wasm NCG
    
    In the wasm NCG, we used to compile MO_F_Neg to 0.0-x. It was an
    oversight, there actually exists f32.neg/f64.neg opcodes in the wasm
    spec and those should be used instead! The old behavior almost works,
    expect when GHC compiles the -0.0 literal, which will incorrectly
    become 0.0.
    
    - - - - -
    e987e345 by Sylvain Henry at 2023-01-25T14:47:41-05:00
    Hadrian: correctly detect AR at-file support
    
    Stage0's ar may not support at-files. Take it into account.
    
    Found while cross-compiling from Darwin to Windows.
    
    - - - - -
    48131ee2 by Sylvain Henry at 2023-01-25T14:47:41-05:00
    Hadrian: fix Windows cross-compilation
    
    Decision to build either unix or Win32 package must be stage specific
    for cross-compilation to be supported.
    
    - - - - -
    288fa017 by Sylvain Henry at 2023-01-25T14:47:41-05:00
    Fix RTS build on Windows
    
    This change fixes a cross-compilation issue from ArchLinux to Windows
    because these symbols weren't found.
    
    - - - - -
    2fdf22ae by Sylvain Henry at 2023-01-25T14:47:41-05:00
    configure: support "windows" as an OS
    
    - - - - -
    13a0566b by Simon Peyton Jones at 2023-01-25T14:48:16-05:00
    Fix in-scope set in specImports
    
    Nothing deep here; I had failed to bring some
    floated dictionary binders into scope.
    
    Exposed by -fspecialise-aggressively
    
    Fixes #22715.
    
    - - - - -
    b7efdb24 by Matthew Pickering at 2023-01-25T14:48:51-05:00
    ci: Disable HLint job due to excessive runtime
    
    The HLint jobs takes much longer to run (20 minutes) after "Give the RTS it's own configure script" eb5a6b91
    
    Now the CI job will build the stage0 compiler before it generates the necessary RTS headers.
    
    We either need to:
    
    * Fix the linting rules so they take much less time
    * Revert the commit
    * Remove the linting of base from the hlint job
    * Remove the hlint job
    
    This is highest priority as it is affecting all CI pipelines.
    
    For now I am just disabling the job because there are many more pressing
    matters at hand.
    
    Ticket #22830
    
    - - - - -
    1bd32a35 by Sylvain Henry at 2023-01-26T12:34:21-05:00
    Factorize hptModulesBelow
    
    Create and use moduleGraphModulesBelow in GHC.Unit.Module.Graph that
    doesn't need anything from the driver to be used.
    
    - - - - -
    1262d3f8 by Matthew Pickering at 2023-01-26T12:34:56-05:00
    Store dehydrated data structures in CgModBreaks
    
    This fixes a tricky leak in GHCi where we were retaining old copies of
    HscEnvs when reloading. If not all modules were recompiled then these
    hydrated fields in break points would retain a reference to the old
    HscEnv which could double memory usage.
    
    Fixes #22530
    
    - - - - -
    e27eb80c by Matthew Pickering at 2023-01-26T12:34:56-05:00
    Force more in NFData Name instance
    
    Doesn't force the lazy `OccName` field (#19619) which is already known
    as a really bad source of leaks.
    
    When we slam the hammer storing Names on disk (in interface files or the
    like), all this should be forced as otherwise a `Name` can easily retain
    an `Id` and hence the entire world.
    
    Fixes #22833
    
    - - - - -
    3d004d5a by Matthew Pickering at 2023-01-26T12:34:56-05:00
    Force OccName in tidyTopName
    
    This occname has just been derived from an `Id`, so need to force it
    promptly so we can release the Id back to the world.
    
    Another symptom of the bug caused by #19619
    
    - - - - -
    f2a0fea0 by Matthew Pickering at 2023-01-26T12:34:56-05:00
    Strict fields in ModNodeKey (otherwise retains HomeModInfo)
    
    Towards #22530
    
    - - - - -
    5640cb1d by Sylvain Henry at 2023-01-26T12:35:36-05:00
    Hadrian: fix doc generation
    
    Was missing dependencies on files generated by templates (e.g.
    ghc.cabal)
    
    - - - - -
    3e827c3f by Richard Eisenberg at 2023-01-26T20:06:53-05:00
    Do newtype unwrapping in the canonicaliser and rewriter
    
    See Note [Unwrap newtypes first], which has the details.
    
    Close #22519.
    
    - - - - -
    b3ef5c89 by doyougnu at 2023-01-26T20:07:48-05:00
    tryFillBuffer: strictify
    
    more speculative bangs
    
    - - - - -
    d0d7ba0f by Vladislav Zavialov at 2023-01-26T20:08:25-05:00
    base: NoImplicitPrelude in Data.Void and Data.Kind
    
    This change removes an unnecessary dependency on Prelude
    from two modules in the base package.
    
    - - - - -
    fa1db923 by Matthew Pickering at 2023-01-26T20:09:00-05:00
    ci: Add ubuntu18_04 nightly and release jobs
    
    This adds release jobs for ubuntu18_04 which uses glibc 2.27 which is
    older than the 2.28 which is used by Rocky8 bindists.
    
    Ticket #22268
    
    - - - - -
    807310a1 by Matthew Pickering at 2023-01-26T20:09:00-05:00
    rel-eng: Add missing rocky8 bindist
    
    We intend to release rocky8 bindist so the fetching script needs to know
    about them.
    
    - - - - -
    c7116b10 by Ben Gamari at 2023-01-26T20:09:35-05:00
    base: Make changelog proposal references more consistent
    
    Addresses #22773.
    
    - - - - -
    6932cfc7 by Sylvain Henry at 2023-01-26T20:10:27-05:00
    Fix spurious change from !9568
    
    - - - - -
    e480fbc2 by Ben Gamari at 2023-01-27T05:01:24-05:00
    rts: Use C11-compliant static assertion syntax
    
    Previously we used `static_assert` which is only available in C23. By
    contrast, C11 only provides `_Static_assert`.
    
    Fixes #22777
    
    - - - - -
    2648c09c by Andrei Borzenkov at 2023-01-27T05:02:07-05:00
    Replace errors from badOrigBinding with new one (#22839)
    
    Problem: in 02279a9c the type-level [] syntax was changed from a built-in name
    to an alias for the GHC.Types.List constructor. badOrigBinding assumes that if
    a name is not built-in then it must have come from TH quotation, but this is
    not necessarily the case with [].
    
    The outdated assumption in badOrigBinding leads to incorrect error messages.
    This code:
      data []
    Fails with "Cannot redefine a Name retrieved by a Template Haskell quote: []"
    
    Unfortunately, there is not enough information in RdrName to directly determine
    if the name was constructed via TH or by the parser, so this patch changes the
    error message instead.
    
    It unifies TcRnIllegalBindingOfBuiltIn and TcRnNameByTemplateHaskellQuote
    into a new error TcRnBindingOfExistingName and changes its wording to avoid
    guessing the origin of the name.
    
    - - - - -
    545bf8cf by Matthew Pickering at 2023-01-27T14:58:53+00:00
    Revert "base: NoImplicitPrelude in Data.Void and Data.Kind"
    
    Fixes CI errors of the form.
    
    ```
    ===> Command failed with error code: 1
    ghc: panic! (the 'impossible' happened)
      GHC version 9.7.20230127:
    	lookupGlobal
      Failed to load interface for ‘GHC.Num.BigNat’
      There are files missing in the ‘ghc-bignum’ package,
      try running 'ghc-pkg check'.
      Use -v (or `:set -v` in ghci) to see a list of the files searched for.
      Call stack:
          CallStack (from HasCallStack):
            callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic
            pprPanic, called at compiler/GHC/Tc/Utils/Env.hs:154:32 in ghc:GHC.Tc.Utils.Env
      CallStack (from HasCallStack):
        panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error
    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug
    ```
    
    This reverts commit d0d7ba0fb053ebe7f919a5932066fbc776301ccd.
    
    The module now lacks a dependency on GHC.Num.BigNat which it implicitly
    depends on. It is causing all CI jobs to fail so we revert without haste
    whilst the patch can be fixed.
    
    Fixes #22848
    
    - - - - -
    638277ba by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Detect family instance orphans correctly
    
    We were treating a type-family instance as a non-orphan if there
    was a type constructor on its /right-hand side/ that was local. Boo!
    Utterly wrong. With this patch, we correctly check the /left-hand side/
    instead!
    
    Fixes #22717
    
    - - - - -
    46a53bb2 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Report family instance orphans correctly
    
    This fixes the fact that we were not reporting orphan family instances
    at all. The fix here is easy, but touches a bit of code. I refactored
    the code to be much more similar to the way that class instances are done:
    
       - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst
       - Make newFamInst initialise this field, just like newClsInst
       - And make newFamInst report a warning for an orphan, just like newClsInst
       - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate,
         just like newClsInst.
       - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv
       - TcRnOrphanInstance and SuggestFixOrphanInstance are now parametrised
         over class instances vs type/data family instances.
    
    Fixes #19773
    
    - - - - -
    faa300fb by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Avoid orphans in STG
    
    This patch removes some orphan instances in the STG namespace
    by introducing the GHC.Stg.Lift.Types module, which allows various
    type family instances to be moved to GHC.Stg.Syntax, avoiding orphan
    instances.
    
    - - - - -
    0f25a13b by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Avoid orphans in the parser
    
    This moves Anno instances for PatBuilder from GHC.Parser.PostProcess
    to GHC.Parser.Types to avoid orphans.
    
    - - - - -
    15750d33 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Accept an orphan declaration (sadly)
    
    This accepts the orphan type family instance
    
      type instance DsForeignHook = ...
    
    in GHC.HsToCore.Types.
    
    See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks
    
    - - - - -
    c9967d13 by Zubin Duggal at 2023-01-27T23:55:31-05:00
    bindist configure: Fail if find not found (#22691)
    
    - - - - -
    ad8cfed4 by John Ericson at 2023-01-27T23:56:06-05:00
    Put hadrian bootstrap plans through `jq`
    
    This makes it possible to review changes with conventional diffing
    tools.
    
    - - - - -
    d0ddc01b by Ben Gamari at 2023-01-27T23:56:42-05:00
    testsuite: Introduce threaded2_sanity way
    
    Incredibly, we previously did not have a single way which would test the
    threaded RTS with multiple capabilities and the sanity-checker enabled.
    
    - - - - -
    38ad8351 by Ben Gamari at 2023-01-27T23:56:42-05:00
    rts: Relax Messages assertion
    
    `doneWithMsgThrowTo` was previously too strict in asserting that the
    `Message` is locked. Specifically, it failed to consider that the
    `Message` may not be locked if we are deleting all threads during RTS
    shutdown.
    
    - - - - -
    a9fe81af by Ben Gamari at 2023-01-27T23:56:42-05:00
    testsuite: Fix race in UnliftedTVar2
    
    Previously UnliftedTVar2 would fail when run with multiple capabilities
    (and possibly even with one capability) as it would assume that
    `killThread#` would immediately kill the "increment" thread.
    
    Also, refactor the the executable to now succeed with no output and
    fails with an exit code.
    
    - - - - -
    8519af60 by Ben Gamari at 2023-01-27T23:56:42-05:00
    testsuite: Make listThreads more robust
    
    Previously it was sensitive to the labels of threads which it did not
    create (e.g. the IO manager event loop threads). Fix this.
    
    - - - - -
    55a81995 by Ben Gamari at 2023-01-27T23:56:43-05:00
    rts: Fix non-atomic mutation of enabled_capabilities
    
    - - - - -
    b5c75f1d by Ben Gamari at 2023-01-27T23:56:43-05:00
    rts: Fix C++ compilation issues
    
    Make the RTS compilable with a C++ compiler by inserting necessary
    casts.
    
    - - - - -
    c261b62f by Ben Gamari at 2023-01-27T23:56:43-05:00
    rts: Fix typo
    
    "tracingAddCapabilities" was mis-named
    
    - - - - -
    77fdbd3f by Ben Gamari at 2023-01-27T23:56:43-05:00
    rts: Drop long-dead fallback definitions for INFINITY & NAN
    
    These are no longer necessary since we now compile as C99.
    
    - - - - -
    56c1bd98 by Ben Gamari at 2023-01-28T02:57:59-05:00
    Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)"
    
    This reverts commit 99aca26b652603bc62953157a48e419f737d352d.
    
    - - - - -
    b3a3534b by nineonine at 2023-01-28T02:57:59-05:00
    CApiFFI: add ConstPtr for encoding const-qualified pointer return types
    
    Previously, when using `capi` calling convention in foreign declarations,
    code generator failed to handle const-cualified pointer return types.
    This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers`
    warning.
    
    `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases -
    special treatment was put in place to generate appropritetly qualified C
    wrapper that no longer triggers the above mentioned warning.
    
    Fixes #22043.
    
    - - - - -
    082b7d43 by Oleg Grenrus at 2023-01-28T02:58:38-05:00
    Add Foldable1 Solo instance
    
    - - - - -
    50b1e2e8 by Andrei Borzenkov at 2023-01-28T02:59:18-05:00
    Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115)
    
    I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind
    module. Instead, these TcRnMessage messages were introduced:
      TcRnMultipleFixityDecls
      TcRnIllegalPatternSynonymDecl
      TcRnIllegalClassBiding
      TcRnOrphanCompletePragma
      TcRnEmptyCase
      TcRnNonStdGuards
      TcRnDuplicateSigDecl
      TcRnMisplacedSigDecl
      TcRnUnexpectedDefaultSig
      TcRnBindInBootFile
      TcRnDuplicateMinimalSig
    
    - - - - -
    3330b819 by Matthew Pickering at 2023-01-28T02:59:54-05:00
    hadrian: Fix library-dirs, dynamic-library-dirs and static-library-dirs in inplace .conf files
    
    Previously we were just throwing away the contents of the library-dirs
    fields but really we have to do the same thing as for include-dirs,
    relativise the paths into the current working directory and maintain any
    extra libraries the user has specified.
    
    Now the relevant section of the rts.conf file looks like:
    
    ```
    library-dirs:
        ${pkgroot}/../rts/build
        ${pkgroot}/../../..//_build/stage1/rts/build
        /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
        /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib
    
    library-dirs-static:
        ${pkgroot}/../rts/build
        ${pkgroot}/../../..//_build/stage1/rts/build
        /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
        /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib
    
    dynamic-library-dirs:
        ${pkgroot}/../rts/build
        ${pkgroot}/../../..//_build/stage1/rts/build
        /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
        /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib
    ```
    
    Fixes #22209
    
    - - - - -
    c9ad8852 by Andrew Lelechenko at 2023-01-28T03:00:33-05:00
    Document differences between Data.{Monoid,Semigroup}.{First,Last}
    
    - - - - -
    7e11c6dc by Cheng Shao at 2023-01-28T03:01:09-05:00
    compiler: fix subword literal narrowing logic in the wasm NCG
    
    This patch fixes the W8/W16 literal narrowing logic in the wasm NCG,
    which used to lower it to something like i32.const -1, without
    properly zeroing-out the unused higher bits. Fixes #22608.
    
    - - - - -
    6ea2aa02 by Cheng Shao at 2023-01-28T03:01:46-05:00
    compiler: fix lowering of CmmBlock in the wasm NCG
    
    The CmmBlock datacon was not handled in lower_CmmLit, since I thought
    it would have been eliminated after proc-point splitting. Turns out it
    still occurs in very rare occasions, and this patch is needed to fix
    T9329 for wasm.
    
    - - - - -
    2b62739d by Andrew Lelechenko at 2023-01-28T17:16:11-05:00
    Assorted changes to avoid Data.List.{head,tail}
    
    - - - - -
    78c07219 by Cheng Shao at 2023-01-28T17:16:48-05:00
    compiler: properly handle ForeignHints in the wasm NCG
    
    Properly handle ForeignHints of ccall arguments/return value, insert
    sign extends and truncations when handling signed subwords. Fixes #22852.
    
    - - - - -
    8bed166b by Ben Gamari at 2023-01-30T05:06:26-05:00
    nativeGen: Disable asm-shortcutting on Darwin
    
    Asm-shortcutting may produce relative references to symbols defined in
    other compilation units. This is not something that MachO relocations
    support (see #21972). For this reason we disable the optimisation on
    Darwin. We do so without a warning since this flag is enabled by `-O2`.
    
    Another way to address this issue would be to rather implement a
    PLT-relocatable jump-table strategy. However, this would only benefit
    Darwin and does not seem worth the effort.
    
    Closes #21972.
    
    - - - - -
    da468391 by Cheng Shao at 2023-01-30T05:07:03-05:00
    compiler: fix data section alignment in the wasm NCG
    
    Previously we tried to lower the alignment requirement as far as
    possible, based on the section kind inferred from the CLabel. For info
    tables, .p2align 1 was applied given the GC should only need the
    lowest bit to tag forwarding pointers. But this would lead to
    unaligned loads/stores, which has a performance penalty even if the
    wasm spec permits it. Furthermore, the test suite has shown memory
    corruption in a few cases when compacting gc is used.
    
    This patch takes a more conservative approach: all data sections
    except C strings align to word size.
    
    - - - - -
    08ba8720 by Andreas Klebinger at 2023-01-30T21:18:45-05:00
    ghc-the-library: Retain cafs in both static in dynamic builds.
    
    We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a
    __attribute__((constructor)) function.
    
    This broke for static builds where the linker discarded the object file
    since it was not reverenced from any exported code. We fix this by
    asserting that the flag is enabled using a function in the same module
    as the constructor. Which causes the object file to be retained by the
    linker, which in turn causes the constructor the be run in static builds.
    
    This changes nothing for dynamic builds using the ghc library. But causes
    static to also retain CAFs (as we expect them to).
    
    Fixes #22417.
    
    -------------------------
    Metric Decrease:
        T21839r
    -------------------------
    
    - - - - -
    20598ef6 by Ryan Scott at 2023-01-30T21:19:20-05:00
    Handle `type data` properly in tyThingParent_maybe
    
    Unlike most other data constructors, data constructors declared with `type data`
    are represented in `TyThing`s as `ATyCon` rather than `ADataCon`. The `ATyCon`
    case in `tyThingParent_maybe` previously did not consider the possibility of
    the underlying `TyCon` being a promoted data constructor, which led to the
    oddities observed in #22817. This patch adds a dedicated special case in
    `tyThingParent_maybe`'s `ATyCon` case for `type data` data constructors to fix
    these oddities.
    
    Fixes #22817.
    
    - - - - -
    2f145052 by Ryan Scott at 2023-01-30T21:19:56-05:00
    Fix two bugs in TypeData TH reification
    
    This patch fixes two issues in the way that `type data` declarations were
    reified with Template Haskell:
    
    * `type data` data constructors are now properly reified using `DataConI`.
      This is accomplished with a special case in `reifyTyCon`. Fixes #22818.
    
    * `type data` type constructors are now reified in `reifyTyCon` using
      `TypeDataD` instead of `DataD`. Fixes #22819.
    
    - - - - -
    d0f34f25 by Simon Peyton Jones at 2023-01-30T21:20:35-05:00
    Take account of loop breakers in specLookupRule
    
    The key change is that in GHC.Core.Opt.Specialise.specLookupRule
    we were using realIdUnfolding, which ignores the loop-breaker
    flag.  When given a loop breaker, rule matching therefore
    looped infinitely -- #22802.
    
    In fixing this I refactored a bit.
    
    * Define GHC.Core.InScopeEnv as a data type, and use it.
      (Previously it was a pair: hard to grep for.)
    
    * Put several functions returning an IdUnfoldingFun into
      GHC.Types.Id, namely
         idUnfolding
         alwaysActiveUnfoldingFun,
         whenActiveUnfoldingFun,
         noUnfoldingFun
      and use them.  (The are all loop-breaker aware.)
    
    - - - - -
    de963cb6 by Matthew Pickering at 2023-01-30T21:21:11-05:00
    ci: Remove FreeBSD job from release pipelines
    
    We no longer attempt to build or distribute this release
    
    - - - - -
    f26d27ec by Matthew Pickering at 2023-01-30T21:21:11-05:00
    rel_eng: Add check to make sure that release jobs are downloaded by fetch-gitlab
    
    This check makes sure that if a job is a prefixed by "release-" then the
    script downloads it and understands how to map the job name to the
    platform.
    
    - - - - -
    7619c0b4 by Matthew Pickering at 2023-01-30T21:21:11-05:00
    rel_eng: Fix the name of the ubuntu-* jobs
    
    These were not uploaded for alpha1
    
    Fixes #22844
    
    - - - - -
    68eb8877 by Matthew Pickering at 2023-01-30T21:21:11-05:00
    gen_ci: Only consider release jobs for job metadata
    
    In particular we do not have a release job for FreeBSD so the generation
    of the platform mapping was failing.
    
    - - - - -
    b69461a0 by Jason Shipman at 2023-01-30T21:21:50-05:00
    User's guide: Clarify overlapping instance candidate elimination
    
    This commit updates the user's guide section on overlapping instance candidate
    elimination to use "or" verbiage instead of "either/or" in regards to the
    current pair of candidates' being overlappable or overlapping. "Either IX is
    overlappable, or IY is overlapping" can cause confusion as it suggests "Either
    IX is overlappable, or IY is overlapping, but not both".
    
    This was initially discussed on this Discourse topic:
    
    https://discourse.haskell.org/t/clarification-on-overlapping-instance-candidate-elimination/5677
    
    - - - - -
    7cbdaad0 by Matthew Pickering at 2023-01-31T07:53:53-05:00
    Fixes for cabal-reinstall CI job
    
    * Allow filepath to be reinstalled
    * Bump some version bounds to allow newer versions of libraries
    * Rework testing logic to avoid "install --lib" and package env files
    
    Fixes #22344
    
    - - - - -
    fd8f32bf by Cheng Shao at 2023-01-31T07:54:29-05:00
    rts: prevent potential divide-by-zero when tickInterval=0
    
    This patch fixes a few places in RtsFlags.c that may result in
    divide-by-zero error when tickInterval=0, which is the default on
    wasm. Fixes #22603.
    
    - - - - -
    085a6db6 by Joachim Breitner at 2023-01-31T07:55:05-05:00
    Update note at beginning of GHC.Builtin.NAmes
    
    some things have been renamed since it was written, it seems.
    
    - - - - -
    7716cbe6 by Cheng Shao at 2023-01-31T07:55:41-05:00
    testsuite: use tgamma for cg007
    
    gamma is a glibc-only deprecated function, use tgamma instead. It's
    required for fixing cg007 when testing the wasm unregisterised
    codegen.
    
    - - - - -
    19c1fbcd by doyougnu at 2023-01-31T13:08:03-05:00
    InfoTableProv: ShortText --> ShortByteString
    
    - - - - -
    765fab98 by doyougnu at 2023-01-31T13:08:03-05:00
    FastString: add fastStringToShorText
    
    - - - - -
    a83c810d by Simon Peyton Jones at 2023-01-31T13:08:38-05:00
    Improve exprOkForSpeculation for classops
    
    This patch fixes #22745 and #15205, which are about GHC's
    failure to discard unnecessary superclass selections that
    yield coercions.  See
      GHC.Core.Utils Note [exprOkForSpeculation and type classes]
    
    The main changes are:
    
    * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and
      refer to it
    
    * Define new function isTerminatingType, to identify those
      guaranteed-terminating dictionary types.
    
    * exprOkForSpeculation has a new (very simple) case for ClassOpId
    
    * ClassOpId has a new field that says if the return type is
      an unlifted type, or a terminating type.
    
    This was surprisingly tricky to get right.  In particular note
    that unlifted types are not terminating types; you can write an
    expression of unlifted type, that diverges.  Not so for dictionaries
    (or, more precisely, for the dictionaries that GHC constructs).
    
    Metric Decrease:
        LargeRecord
    
    - - - - -
    f83374f8 by Krzysztof Gogolewski at 2023-01-31T13:09:14-05:00
    Support "unusable UNPACK pragma" warning with -O0
    
    Fixes #11270
    
    - - - - -
    a2d814dc by Ben Gamari at 2023-01-31T13:09:50-05:00
    configure: Always create the VERSION file
    
    Teach the `configure` script to create the `VERSION` file.
    This will serve as the stable interface to allow the user to determine
    the version number of a working tree.
    
    Fixes #22322.
    
    - - - - -
    5618fc21 by sheaf at 2023-01-31T15:51:06-05:00
    Cmm: track the type of global registers
    
    This patch tracks the type of Cmm global registers. This is needed
    in order to lint uses of polymorphic registers, such as SIMD vector
    registers that can be used both for floating-point and integer values.
    
    This changes allows us to refactor VanillaReg to not store VGcPtr,
    as that information is instead stored in the type of the usage of the
    register.
    
    Fixes #22297
    
    - - - - -
    78b99430 by sheaf at 2023-01-31T15:51:06-05:00
    Revert "Cmm Lint: relax SIMD register assignment check"
    
    This reverts commit 3be48877, which weakened a Cmm Lint check involving
    SIMD vectors. Now that we keep track of the type a global register is
    used at, we can restore the original stronger check.
    
    - - - - -
    be417a47 by Ben Gamari at 2023-01-31T15:51:45-05:00
    nativeGen/AArch64: Fix debugging output
    
    Previously various panics would rely on a half-written Show
    instance, leading to very unhelpful errors. Fix this.
    
    See #22798.
    
    - - - - -
    30989d13 by Ben Gamari at 2023-01-31T15:51:45-05:00
    nativeGen: Teach graph-colouring allocator that x18 is unusable
    
    Previously trivColourable for AArch64 claimed that at 18 registers were
    trivially-colourable. This is incorrect as x18 is reserved by the platform on
    AArch64/Darwin.
    
    See #22798.
    
    - - - - -
    7566fd9d by Ben Gamari at 2023-01-31T15:51:45-05:00
    nativeGen/AArch64: Fix graph-colouring allocator
    
    Previously various `Instr` queries used by the graph-colouring allocator
    failed to handle a few pseudo-instructions. This manifested in compiler
    panicks while compiling `SHA`, which uses `-fregs-graph`.
    
    Fixes #22798.
    
    - - - - -
    2cb500a5 by Ben Gamari at 2023-01-31T15:51:45-05:00
    testsuite: Add regression test for #22798
    
    - - - - -
    03d693b2 by Ben Gamari at 2023-01-31T15:52:32-05:00
    Revert "Hadrian: fix doc generation"
    
    This is too large of a hammer.
    
    This reverts commit 5640cb1d84d3cce4ce0a9e90d29b2b20d2b38c2f.
    
    - - - - -
    f838815c by Ben Gamari at 2023-01-31T15:52:32-05:00
    hadrian: Sphinx docs require templated cabal files
    
    The package-version discovery logic in
    `doc/users_guide/package_versions.py` uses packages' cabal files to
    determine package versions. Teach Sphinx about these dependencies in
    cases where the cabal files are generated by templates.
    
    - - - - -
    2e48c19a by Ben Gamari at 2023-01-31T15:52:32-05:00
    hadrian: Refactor templating logic
    
    This refactors Hadrian's autoconf-style templating logic to be explicit
    about which interpolation variables should be substituted in which
    files. This clears the way to fix #22714 without incurring rule cycles.
    
    - - - - -
    93f0e3c4 by Ben Gamari at 2023-01-31T15:52:33-05:00
    hadrian: Substitute LIBRARY_*_VERSION variables
    
    This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables
    in `libraries/prologue.txt`, fixing #22714.
    
    Fixes #22714.
    
    - - - - -
    22089f69 by Ben Gamari at 2023-01-31T20:46:27-05:00
    Bump transformers submodule to 0.6.0.6
    
    Fixes #22862.
    
    - - - - -
    f0eefa3c by Cheng Shao at 2023-01-31T20:47:03-05:00
    compiler: properly handle non-word-sized CmmSwitch scrutinees in the wasm NCG
    
    Currently, the wasm NCG has an implicit assumption: all CmmSwitch
    scrutinees are 32-bit integers. This is not always true; #22864 is one
    counter-example with a 64-bit scrutinee. This patch fixes the logic by
    explicitly converting the scrutinee to a word that can be used as a
    br_table operand. Fixes #22871. Also includes a regression test.
    
    - - - - -
    9f95db54 by Simon Peyton Jones at 2023-02-01T08:55:08+00:00
    Improve treatment of type applications in patterns
    
    This patch fixes a subtle bug in the typechecking of type
    applications in patterns, e.g.
       f (MkT @Int @a x y) = ...
    
    See Note [Type applications in patterns] in GHC.Tc.Gen.Pat.
    
    This fixes #19847, #22383, #19577, #21501
    
    - - - - -
    955a99ea by Simon Peyton Jones at 2023-02-01T12:31:23-05:00
    Treat existentials correctly in dubiousDataConInstArgTys
    
    Consider (#22849)
    
     data T a where
       MkT :: forall k (t::k->*) (ix::k). t ix -> T @k a
    
    Then dubiousDataConInstArgTys MkT [Type, Foo] should return
            [Foo (ix::Type)]
    NOT     [Foo (ix::k)]
    
    A bit of an obscure case, but it's an outright bug, and the fix is easy.
    
    - - - - -
    0cc16aaf by Matthew Pickering at 2023-02-01T12:31:58-05:00
    Bump supported LLVM range from 10 through 15 to 11 through 16
    
    LLVM 15 turns on the new pass manager by default, which we have yet to
    migrate to so for new we pass the `-enable-new-pm-0` flag in our
    llvm-passes flag.
    
    LLVM 11 was the first version to support the `-enable-new-pm` flag so we
    bump the lowest supported version to 11.
    
    Our CI jobs are using LLVM 12 so they should continue to work despite
    this bump to the lower bound.
    
    Fixes #21936
    
    - - - - -
    f94f1450 by Matthew Pickering at 2023-02-01T12:31:58-05:00
    Bump DOCKER_REV to use alpine image without LLVM installed
    
    alpine_3_12 only supports LLVM 10, which is now outside the supported
    version range.
    
    - - - - -
    083e26ed by Matthew Pickering at 2023-02-01T17:43:21-05:00
    Remove tracing OPTIONS_GHC
    
    These were accidentally left over from !9542
    
    - - - - -
    354aa47d by Teo Camarasu at 2023-02-01T17:44:00-05:00
    doc: fix gcdetails_block_fragmentation_bytes since annotation
    
    - - - - -
    61ce5bf6 by Jaro Reinders at 2023-02-02T00:15:30-05:00
    compiler: Implement higher order patterns in the rule matcher
    
    This implements proposal 555 and closes ticket #22465.
    See the proposal and ticket for motivation.
    
    The core changes of this patch are in the GHC.Core.Rules.match function
    and they are explained in the Note [Matching higher order patterns].
    
    - - - - -
    394b91ce by doyougnu at 2023-02-02T00:16:10-05:00
    CI: JavaScript backend runs testsuite
    
    This MR runs the testsuite for the JS backend. Note that this is a
    temporary solution until !9515 is merged.
    
    Key point: The CI runs hadrian on the built cross compiler _but not_ on
    the bindist.
    
    Other Highlights:
    
     - stm submodule gets a bump to mark tests as broken
     - several tests are marked as broken or are fixed by adding more
     - conditions to their test runner instance.
    
    List of working commit messages:
    
    CI: test cross target _and_ emulator
    
    CI: JS: Try run testsuite with hadrian
    
    JS.CI: cleanup and simplify hadrian invocation
    
    use single bracket, print info
    
    JS CI: remove call to test_compiler from hadrian
    
    don't build haddock
    
    JS: mark more tests as broken
    
    Tracked in https://gitlab.haskell.org/ghc/ghc/-/issues/22576
    
    JS testsuite: don't skip sum_mod test
    
    Its expected to fail, yet we skipped it which automatically makes it
    succeed leading to an unexpected success,
    
    JS testsuite: don't mark T12035j as skip
    
    leads to an unexpected pass
    
    JS testsuite: remove broken on T14075
    
    leads to unexpected pass
    
    JS testsuite: mark more tests as broken
    
    JS testsuite: mark T11760 in base as broken
    
    JS testsuite: mark ManyUnbSums broken
    
    submodules: bump process and hpc for JS tests
    
    Both submodules has needed tests skipped or marked broken for th JS
    backend. This commit now adds these changes to GHC.
    
    See:
    
    HPC: https://gitlab.haskell.org/hpc/hpc/-/merge_requests/21
    
    Process: https://github.com/haskell/process/pull/268
    
    remove js_broken on now passing tests
    
    separate wasm and js backend ci
    
    test: T11760: add threaded, non-moving only_ways
    
    test: T10296a add req_c
    
    T13894: skip for JS backend
    
    tests: jspace, T22333: mark as js_broken(22573)
    
    test: T22513i mark as req_th
    
    stm submodule: mark stm055, T16707 broken for JS
    
    tests: js_broken(22374) on unpack_sums_6, T12010
    
    dont run diff on JS CI, cleanup
    
    fixup: More CI cleanup
    
    fix: align text to master
    
    fix: align exceptions submodule to master
    
    CI: Bump DOCKER_REV
    
    Bump to ci-images commit that has a deb11 build with node. Required for
    !9552
    
    testsuite: mark T22669 as js_skip
    
    See #22669
    
    This test tests that .o-boot files aren't created when run in using the
    interpreter backend. Thus this is not relevant for the JS backend.
    
    testsuite: mark T22671 as broken on JS
    
    See #22835
    
    base.testsuite: mark Chan002 fragile for JS
    
    see #22836
    
    revert: submodule process bump
    
    bump stm submodule
    
    New hash includes skips for the JS backend.
    
    testsuite: mark RnPatternSynonymFail broken on JS
    
    Requires TH:
     - see !9779
     - and #22261
    
    compiler: GHC.hs ifdef import Utils.Panic.Plain
    
    - - - - -
    1ffe770c by Cheng Shao at 2023-02-02T09:40:38+00:00
    docs: 9.6 release notes for wasm backend
    
    - - - - -
    0ada4547 by Matthew Pickering at 2023-02-02T11:39:44-05:00
    Disable unfolding sharing for interface files with core definitions
    
    Ticket #22807 pointed out that the RHS sharing was not compatible with
    -fignore-interface-pragmas because the flag would remove unfoldings from
    identifiers before the `extra-decls` field was populated.
    
    For the 9.6 timescale the only solution is to disable this sharing,
    which will make interface files bigger but this is acceptable for the
    first release of `-fwrite-if-simplified-core`.
    
    For 9.8 it would be good to fix this by implementing #20056 due to the
    large number of other bugs that would fix.
    
    I also improved the error message in tc_iface_binding to avoid the "no match
    in record selector" error but it should never happen now as the entire
    sharing logic is disabled.
    
    Also added the currently broken test for #22807 which could be fixed by
    !6080
    
    Fixes #22807
    
    - - - - -
    7e2d3eb5 by lrzlin at 2023-02-03T05:23:27-05:00
    Enable tables next to code for LoongArch64
    
    - - - - -
    2931712a by Wander Hillen at 2023-02-03T05:24:06-05:00
    Move pthread and timerfd ticker implementations to separate files
    
    - - - - -
    41c4baf8 by Ben Gamari at 2023-02-03T05:24:44-05:00
    base: Fix Note references in GHC.IO.Handle.Types
    
    - - - - -
    31358198 by Andrew Lelechenko at 2023-02-03T05:25:22-05:00
    Bump submodule containers to 0.6.7
    
    Metric Decrease:
        ManyConstructors
        T10421
        T12425
        T12707
        T13035
        T13379
        T15164
        T1969
        T783
        T9198
        T9961
        WWRec
    
    - - - - -
    8feb9301 by Ben Gamari at 2023-02-03T05:25:59-05:00
    gitlab-ci: Eliminate redundant ghc --info output
    
    Previously ci.sh would emit the output of `ghc --info` every time it ran
    when using the nix toolchain. This produced a significant amount of
    noise.
    
    See #22861.
    - - - - -
    de1d1512 by Ryan Scott at 2023-02-03T14:07:30-05:00
    Windows: Remove mingwex dependency
    
    The clang based toolchain uses ucrt as its math library
    and so mingwex is no longer needed.  In fact using mingwex
    will cause incompatibilities as the default routines in both
    have differing ULPs and string formatting modifiers.
    
    ```
    $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe
    [1 of 2] Compiling Main             ( Bug.hs, Bug.o )
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info'
    ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above.
    
    <no location info>: error:
    
    GHC.ByteCode.Linker.lookupCE
    During interactive linking, GHCi couldn't find the following symbol:
      templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure
    This may be due to you not asking GHCi to load extra object files,
    archives or DLLs needed by your current session.  Restart GHCi, specifying
    the missing library using the -L/path/to/object/dir and -lmissinglibname
    flags, or simply by naming the relevant files on the GHCi command line.
    Alternatively, this link failure might indicate a bug in GHCi.
    If you suspect the latter, please report this as a GHC bug:
      https://www.haskell.org/ghc/reportabug
    ```
    
    - - - - -
    48e39195 by Tamar Christina at 2023-02-03T14:07:30-05:00
    linker: Fix BFD import libraries
    
    This commit fixes the BFD style import library support in the runtime
    linker.  This was accidentally broken during the refactoring to clang
    and went unnoticed because clang itself is unable to generate the BFD
    style import libraries.
    
    With this change we can not link against both GCC or Clang produced
    libraries again and intermix code produced by both compilers.
    
    - - - - -
    b2bb3e62 by Ben Gamari at 2023-02-03T14:07:30-05:00
    Bump Windows toolchain
    
    Updates to LLVM 14, hopefully fixing #21964.
    
    - - - - -
    bf3f88a1 by Andreas Klebinger at 2023-02-03T14:08:07-05:00
    Fix CallerCC potentially shadowing other cost centres.
    
    Add a CallerCC cost centre flavour for cost centres added by the
    CallerCC pass. This avoids potential accidental shadowing between
    CCs added by user annotations and ones added by CallerCC.
    
    - - - - -
    faea4bcd by j at 2023-02-03T14:08:47-05:00
    Disable several ignore-warning flags in genapply.
    - - - - -
    25537dfd by Ben Gamari at 2023-02-04T04:12:57-05:00
    Revert "Use fix-sized bit-fiddling primops for fixed size boxed types"
    
    This reverts commit 4512ad2d6a8e65ea43c86c816411cb13b822f674.
    
    This was never applied to master/9.6 originally.
    
    (cherry picked from commit a44bdc2720015c03d57f470b759ece7fab29a57a)
    
    - - - - -
    7612dc71 by Krzysztof Gogolewski at 2023-02-04T04:13:34-05:00
    Minor refactor
    
    * Introduce refactorDupsOn f = refactorDups (comparing f)
    * Make mkBigTupleCase and coreCaseTuple monadic.
      Every call to those functions was preceded by calling newUniqueSupply.
    * Use mkUserLocalOrCoVar, which is equivalent to combining
      mkLocalIdOrCoVar with mkInternalName.
    
    - - - - -
    5a54ac0b by Andrew Lelechenko at 2023-02-04T18:48:32-05:00
    Fix colors in emacs terminal
    
    - - - - -
    3c0f0c6d by Andrew Lelechenko at 2023-02-04T18:49:11-05:00
    base changelog: move entries which were not backported to ghc-9.6 to base-4.19 section
    
    - - - - -
    b18fbf52 by Josh Meredith at 2023-02-06T07:47:57+00:00
    Update JavaScript fileStat to match Emscripten layout
    
    - - - - -
    6636b670 by Sylvain Henry at 2023-02-06T09:43:21-05:00
    JS: replace "js" architecture with "javascript"
    
    Despite Cabal supporting any architecture name, `cabal --check` only
    supports a few built-in ones. Sadly `cabal --check` is used by Hackage
    hence using any non built-in name in a package (e.g. `arch(js)`) is
    rejected and the package is prevented from being uploaded on Hackage.
    
    Luckily built-in support for the `javascript` architecture was added for
    GHCJS a while ago. In order to allow newer `base` to be uploaded on
    Hackage we make the switch from `js` to `javascript` architecture.
    
    Fixes #22740.
    
    Co-authored-by: Ben Gamari <ben at smart-cactus.org>
    
    - - - - -
    77a8234c by Luite Stegeman at 2023-02-06T09:43:59-05:00
    Fix marking async exceptions in the JS backend
    
    Async exceptions are posted as a pair of the exception and
    the thread object. This fixes the marking pass to correctly
    follow the two elements of the pair.
    
    Potentially fixes #22836
    
    - - - - -
    3e09cf82 by Jan Hrček at 2023-02-06T09:44:38-05:00
    Remove extraneous word in Roles user guide
    
    - - - - -
    b17fb3d9 by sheaf at 2023-02-07T10:51:33-05:00
    Don't allow . in overloaded labels
    
    This patch removes . from the list of allowed characters in a non-quoted
    overloaded label, as it was realised this steals syntax, e.g. (#.).
    
    Users who want this functionality will have to add quotes around the
    label, e.g. `#"17.28"`.
    
    Fixes #22821
    
    - - - - -
    5dce04ee by romes at 2023-02-07T10:52:10-05:00
    Update kinds in comments in GHC.Core.TyCon
    
    Use `Type` instead of star kind (*)
    Fix comment with incorrect kind * to have kind `Constraint`
    
    - - - - -
    92916194 by Ben Gamari at 2023-02-07T10:52:48-05:00
    Revert "Use fix-sized equality primops for fixed size boxed types"
    
    This reverts commit 024020c38126f3ce326ff56906d53525bc71690c.
    
    This was never applied to master/9.6 originally.
    
    See #20405 for why using these primops is a bad idea.
    
    (cherry picked from commit b1d109ad542e4c37ae5af6ace71baf2cb509d865)
    
    - - - - -
    c1670c6b by Sylvain Henry at 2023-02-07T21:25:18-05:00
    JS: avoid head/tail and unpackFS
    
    - - - - -
    a9912de7 by Krzysztof Gogolewski at 2023-02-07T21:25:53-05:00
    testsuite: Fix Python warnings (#22856)
    
    - - - - -
    9ee761bf by sheaf at 2023-02-08T14:40:40-05:00
    Fix tyvar scoping within class SPECIALISE pragmas
    
    Type variables from class/instance headers scope over class/instance
    method type signatures, but DO NOT scope over the type signatures in
    SPECIALISE and SPECIALISE instance pragmas.
    
    The logic in GHC.Rename.Bind.rnMethodBinds correctly accounted for
    SPECIALISE inline pragmas, but forgot to apply the same treatment
    to method SPECIALISE pragmas, which lead to a Core Lint failure with
    an out-of-scope type variable. This patch makes sure we apply the same
    logic for both cases.
    
    Fixes #22913
    
    - - - - -
    7eac2468 by Matthew Pickering at 2023-02-08T14:41:17-05:00
    Revert "Don't keep exit join points so much"
    
    This reverts commit caced75765472a1a94453f2e5a439dba0d04a265.
    
    It seems the patch "Don't keep exit join points so much" is causing
    wide-spread regressions in the bytestring library benchmarks. If I
    revert it then the 9.6 numbers are better on average than 9.4.
    
    See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525
    
    -------------------------
    Metric Decrease:
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModules
        MultiLayerModulesRecomp
        MultiLayerModulesTH_Make
        T12150
        T13386
        T13719
        T21839c
        T3294
        parsing001
    -------------------------
    
    - - - - -
    633f2799 by Cheng Shao at 2023-02-08T18:42:16-05:00
    testsuite: remove config.use_threads
    
    This patch simplifies the testsuite driver by removing the use_threads
    config field. It's just a degenerate case of threads=1.
    
    - - - - -
    ca6673e3 by Cheng Shao at 2023-02-08T18:42:16-05:00
    testsuite: use concurrent.futures.ThreadPoolExecutor in the driver
    
    The testsuite driver used to create one thread per test case, and
    explicitly use semaphore and locks for rate limiting and
    synchronization. This is a bad practice in any language, and
    occasionally may result in livelock conditions (e.g. #22889). This
    patch uses concurrent.futures.ThreadPoolExecutor for scheduling test
    case runs, which is simpler and more robust.
    
    - - - - -
    f22cce70 by Alan Zimmerman at 2023-02-08T18:42:51-05:00
    EPA: Comment between module and where should be in header comments
    
    Do not apply the heuristic to associate a comment with a prior
    declaration for the first declaration in the file.
    
    Closes #22919
    
    - - - - -
    d69ecac2 by Josh Meredith at 2023-02-09T03:24:05-05:00
    JS generated refs: update testsuite conditions
    
    - - - - -
    2ea1a6bc by sheaf at 2023-02-09T03:24:44-05:00
    Bump transformers to 0.6.1.0
    
    This allows us to avoid orphans for Foldable1 instances,
    fixing #22898.
    
    Updates transformers submodule.
    
    - - - - -
    d9d0c28d by konsumlamm at 2023-02-09T14:07:48-05:00
    Update `Data.List.singleton` doc comment
    - - - - -
    fe9cd6ef by Ben Gamari at 2023-02-09T14:08:23-05:00
    gitlab-template: Emphasize `user facing` label
    
    My sense is that the current mention of the ~"user facing" label is
    overlooked by many MR authors.
    
    Let's move this point up in the list to make it more likely that it is
    seen. Also rephrase some of the points.
    
    - - - - -
    e45eb828 by Simon Peyton Jones at 2023-02-10T06:51:28-05:00
    Refactor the simplifier a bit to fix #22761
    
    The core change in this commit, which fixes #22761, is that
    
    * In a Core rule, ru_rhs is always occ-analysed.
    
    This means adding a couple of calls to occurAnalyseExpr when
    building a Rule, in
    * GHC.Core.Rules.mkRule
    * GHC.Core.Opt.Simplify.Iteration.simplRules
    
    But diagosing the bug made me stare carefully at the code of the
    Simplifier, and I ended up doing some only-loosely-related refactoring.
    
    * I think that RULES could be lost because not every code path
      did addBndrRules
    
    * The code around lambdas was very convoluted
    
    It's mainly moving deck chairs around, but I like it more now.
    
    - - - - -
    11e0cacb by Rebecca Turner at 2023-02-10T06:52:09-05:00
    Detect the `mold` linker
    
    Enables support for the `mold` linker by rui314.
    
    - - - - -
    59556235 by parsonsmatt at 2023-02-10T09:53:11-05:00
    Add Lift instance for Fixed
    
    - - - - -
    c44e5f30 by Sylvain Henry at 2023-02-10T09:53:51-05:00
    Testsuite: decrease length001 timeout for JS (#22921)
    
    - - - - -
    133516af by Zubin Duggal at 2023-02-10T09:54:27-05:00
    compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData`
    instances
    
    This is a minor refactor that makes it easy to add and remove fields from
    `ModIface_` and `ModIfaceBackend`.
    
    Also change the formatting to make it clear exactly which fields are
    fully forced with `rnf`
    
    - - - - -
    1e9eac1c by Matthew Pickering at 2023-02-13T11:36:41+01:00
    Refresh profiling docs
    
    I went through the whole of the profiling docs and tried to amend them
    to reflect current best practices and tooling. In particular I removed
    some old references to tools such as hp2any and replaced them with
    references to eventlog2html.
    
    - - - - -
    da208b9a by Matthew Pickering at 2023-02-13T11:36:41+01:00
    docs: Add section about profiling and foreign calls
    
    Previously there was no documentation for how foreign calls interacted
    with the profiler. This can be quite confusing for users so getting it
    into the user guide is the first step to a potentially better solution.
    See the ticket for more insightful discussion.
    
    Fixes #21764
    
    - - - - -
    081640f1 by Andrew Lelechenko at 2023-02-13T12:51:52-05:00
    Document that -fproc-alignment was introduced only in GHC 8.6
    
    - - - - -
    16adc349 by Sven Tennie at 2023-02-14T11:26:31-05:00
    Add clangd flag to include generated header files
    
    This enables clangd to correctly check C files that import Rts.h.
    (The added include directory contains ghcautoconf.h et. al.)
    
    - - - - -
    c399ccd9 by amesgen at 2023-02-14T11:27:14-05:00
    Mention new `Foreign.Marshal.Pool` implementation in User's Guide
    
    - - - - -
    b9282cf7 by Ben Gamari at 2023-02-14T11:27:50-05:00
    upload_ghc_libs: More control over which packages to operate on
    
    Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to
    limit which packages to upload. This is often necessary when one package
    is not uploadable (e.g. see #22740).
    
    - - - - -
    aa3a262d by PHO at 2023-02-14T11:28:29-05:00
    Assume platforms support rpaths if they use either ELF or Mach-O
    
    Not only Linux, Darwin, and FreeBSD support rpaths. Determine the usability
    of rpaths based on the object format, not on OS.
    
    - - - - -
    47716024 by PHO at 2023-02-14T11:29:09-05:00
    RTS linker: Improve compatibility with NetBSD
    
    1. Hint address to NetBSD mmap(2) has a different semantics from that of
       Linux. When a hint address is provided, mmap(2) searches for a free
       region at or below the hint but *never* above it. This means we can't
       reliably search for free regions incrementally on the userland,
       especially when ASLR is enabled. Let the kernel do it for us if we don't
       care where the mapped address is going to be.
    
    2. NetBSD not only hates to map pages as rwx, but also disallows to switch
       pages from rw- to r-x unless the intention is declared when pages are
       initially requested. This means we need a new MemoryAccess mode for
       pages that are going to be changed to r-x.
    
    - - - - -
    11de324a by Li-yao Xia at 2023-02-14T11:29:49-05:00
    base: Move changelog entry to its place
    
    - - - - -
    75930424 by Ben Gamari at 2023-02-14T11:30:27-05:00
    nativeGen/AArch64: Emit Atomic{Read,Write} inline
    
    Previously the AtomicRead and AtomicWrite operations were emitted as
    out-of-line calls. However, these tend to be very important for
    performance, especially the RELAXED case (which only exists for
    ThreadSanitizer checking).
    
    Fixes #22115.
    
    - - - - -
    d6411d6c by Andreas Klebinger at 2023-02-14T11:31:04-05:00
    Fix some correctness issues around tag inference when targeting the bytecode generator.
    
    * Let binders are now always assumed untagged for bytecode.
    * Imported referenced are now always assumed to be untagged for bytecode.
    
    Fixes #22840
    
    - - - - -
    9fb4ca89 by sheaf at 2023-02-14T11:31:49-05:00
    Introduce warning for loopy superclass solve
    
    Commit aed1974e completely re-engineered the treatment of loopy
    superclass dictionaries in instance declarations. Unfortunately,
    it has the potential to break (albeit in a rather minor way) user code.
    
    To alleviate migration concerns, this commit re-introduces the old
    behaviour. Any reliance on this old behaviour triggers a warning,
    controlled by `-Wloopy-superclass-solve`. The warning text explains
    that GHC might produce bottoming evidence, and provides a migration
    strategy.
    
    This allows us to provide a graceful migration period, alerting users
    when they are relying on this unsound behaviour.
    
    Fixes #22912 #22891 #20666 #22894 #22905
    
    - - - - -
    1928c7f3 by Cheng Shao at 2023-02-14T11:32:26-05:00
    rts: make it possible to change mblock size on 32-bit targets
    
    The MBLOCK_SHIFT macro must be the single source of truth for defining
    the mblock size, and changing it should only affect performance, not
    correctness. This patch makes it truly possible to reconfigure mblock
    size, at least on 32-bit targets, by fixing places which implicitly
    relied on the previous MBLOCK_SHIFT constant. Fixes #22901.
    
    - - - - -
    78aa3b39 by Simon Hengel at 2023-02-14T11:33:06-05:00
    Update outdated references to notes
    
    - - - - -
    e8baecd2 by meooow25 at 2023-02-14T11:33:49-05:00
    Documentation: Improve Foldable1 documentation
    
    * Explain foldrMap1, foldlMap1, foldlMap1', and foldrMap1' in greater
      detail, the text is mostly adapted from documentation of Foldable.
    * Describe foldr1, foldl1, foldl1' and foldr1' in terms of the above
      functions instead of redoing the full explanation.
    * Small updates to documentation of fold1, foldMap1 and toNonEmpty,
      again adapting from Foldable.
    * Update the foldMap1 example to lists instead of Sum since this is
      recommended for lazy right-associative folds.
    
    Fixes #22847
    
    - - - - -
    85a1a575 by romes at 2023-02-14T11:34:25-05:00
    fix: Mark ghci Prelude import as implicit
    
    Fixes #22829
    
    In GHCi, we were creating an import declaration for Prelude but we were
    not setting it as an implicit declaration. Therefore, ghci's import of
    Prelude triggered -Wmissing-import-lists.
    
    Adds regression test T22829 to testsuite
    
    - - - - -
    3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05:00
    compiler: fix generateCgIPEStub for no-tables-next-to-code builds
    
    generateCgIPEStub already correctly implements the CmmTick finding
    logic for when tables-next-to-code is on/off, but it used the wrong
    predicate to decide when to switch between the two. Previously it
    switches based on whether the codegen is unregisterised, but there do
    exist registerised builds that disable tables-next-to-code! This patch
    corrects that problem. Fixes #22896.
    
    - - - - -
    08c0822c by doyougnu at 2023-02-15T00:16:39-05:00
    docs: release notes, user guide: add js backend
    
    Follow up from #21078
    
    - - - - -
    79d8fd65 by Bryan Richter at 2023-02-15T00:17:15-05:00
    Allow failure in nightly-x86_64-linux-deb10-no_tntc-validate
    
    See #22343
    
    - - - - -
    9ca51f9e by Cheng Shao at 2023-02-15T00:17:53-05:00
    rts: add the rts_clearMemory function
    
    This patch adds the rts_clearMemory function that does its best to
    zero out unused RTS memory for a wasm backend use case. See the
    comment above rts_clearMemory() prototype declaration for more
    detailed explanation. Closes #22920.
    
    - - - - -
    26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00
    Add -single-threaded flag to force single threaded rts
    
    This is the small part of implementing
    https://github.com/ghc-proposals/ghc-proposals/pull/240
    
    - - - - -
    631c6c72 by Cheng Shao at 2023-02-16T06:43:09-05:00
    docs: add a section for the wasm backend
    
    Fixes #22658
    
    - - - - -
    1878e0bd by Bryan Richter at 2023-02-16T06:43:47-05:00
    tests: Mark T12903 fragile everywhere
    
    See #21184
    
    - - - - -
    b9420eac by Bryan Richter at 2023-02-16T06:43:47-05:00
    Mark all T5435 variants as fragile
    
    See #22970.
    
    - - - - -
    df3d94bd by Sylvain Henry at 2023-02-16T06:44:33-05:00
    Testsuite: mark T13167 as fragile for JS (#22921)
    
    - - - - -
    324e925b by Sylvain Henry at 2023-02-16T06:45:15-05:00
    JS: disable debugging info for heap objects
    
    - - - - -
    518af814 by Josh Meredith at 2023-02-16T10:16:32-05:00
    Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name caching
    
    - - - - -
    34cd308e by Ben Gamari at 2023-02-16T10:17:08-05:00
    base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog
    
    Fixes #22883.
    
    - - - - -
    12965aba by Simon Peyton Jones at 2023-02-16T10:17:46-05:00
    Narrow the dont-decompose-newtype test
    
    Following #22924 this patch narrows the test that stops
    us decomposing newtypes.  The key change is the use of
    noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp.
    
    We went to and fro on the solution, as you can see in #22924.
    The result is carefully documented in
      Note [Decomoposing newtype equalities]
    
    On the way I had revert most of
      commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90
      Author: Richard Eisenberg <rae at cs.brynmawr.edu>
      Date:   Mon Dec 5 10:14:02 2022 -0500
    
        Do newtype unwrapping in the canonicaliser and rewriter
    
        See Note [Unwrap newtypes first], which has the details.
    
    It turns out that
    
    (a) 3e827c3f makes GHC behave worse on some recursive newtypes
        (see one of the tests on this commit)
    (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders
        3e827c3f unnecessary
    
    - - - - -
    5b038888 by Andrew Lelechenko at 2023-02-16T10:18:24-05:00
    Documentation: add an example of SPEC usage
    
    - - - - -
    681e0e8c by sheaf at 2023-02-16T14:09:56-05:00
    No default finalizer exception handler
    
    Commit cfc8e2e2 introduced a mechanism for handling of exceptions
    that occur during Handle finalization, and 372cf730 set the default
    handler to print out the error to stderr.
    
    However, #21680 pointed out we might not want to set this by default,
    as it might pollute users' terminals with unwanted information.
    So, for the time being, the default handler discards the exception.
    
    Fixes #21680
    
    - - - - -
    b3ac17ad by Matthew Pickering at 2023-02-16T14:10:31-05:00
    unicode: Don't inline bitmap in generalCategory
    
    generalCategory contains a huge literal string but is marked INLINE,
    this will duplicate the string into any use site of generalCategory. In
    particular generalCategory is used in functions like isSpace and the
    literal gets inlined into this function which makes it massive.
    
    https://github.com/haskell/core-libraries-committee/issues/130
    
    Fixes #22949
    
    -------------------------
    Metric Decrease:
        T4029
        T18304
    -------------------------
    
    - - - - -
    8988eeef by sheaf at 2023-02-16T20:32:27-05:00
    Expand synonyms in RoughMap
    
    We were failing to expand type synonyms in the function
    GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the
    RoughMap infrastructure crucially relies on type synonym expansion
    to work.
    
    This patch adds the missing type-synonym expansion.
    
    Fixes #22985
    
    - - - - -
    3dd50e2f by Matthew Pickering at 2023-02-16T20:33:03-05:00
    ghcup-metadata: Add test artifact
    
    Add the released testsuite tarball to the generated ghcup metadata.
    
    - - - - -
    c6a967d9 by Matthew Pickering at 2023-02-16T20:33:03-05:00
    ghcup-metadata: Use Ubuntu and Rocky bindists
    
    Prefer to use the Ubuntu 20.04 and 18.04 binary distributions on Ubuntu
    and Linux Mint. Prefer to use the Rocky 8 binary distribution on
    unknown distributions.
    
    - - - - -
    be0b7209 by Matthew Pickering at 2023-02-17T09:37:16+00:00
    Add INLINABLE pragmas to `generic*` functions in Data.OldList
    
    These functions are
    
    * recursive
    * overloaded
    
    So it's important to add an `INLINABLE` pragma to each so that they can be
    specialised at the use site when the specific numeric type is known.
    Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020)
    
    https://github.com/haskell/core-libraries-committee/issues/129
    
    - - - - -
    a203ad85 by Sylvain Henry at 2023-02-17T15:59:16-05:00
    Merge libiserv with ghci
    
    `libiserv` serves no purpose. As it depends on `ghci` and doesn't have
    more dependencies than the `ghci` package, its code could live in the
    `ghci` package too.
    
    This commit also moves most of the code from the `iserv` program into
    the `ghci` package as well so that it can be reused. This is especially
    useful for the implementation of TH for the JS backend (#22261, !9779).
    
    - - - - -
    7080a93f by Simon Peyton Jones at 2023-02-20T12:06:32+01:00
    Improve GHC.Tc.Gen.App.tcInstFun
    
    It wasn't behaving right when inst_final=False, and the
    function had no type variables
       f :: Foo => Int
    
    Rather a corner case, but we might as well do it right.
    
    Fixes #22908
    
    Unexpectedly, three test cases (all using :type in GHCi) got
    slightly better output as a result:
      T17403, T14796, T12447
    
    - - - - -
    2592ab69 by Cheng Shao at 2023-02-20T10:35:30-05:00
    compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping
    
    The wasm NCG used to map CCCS to a wasm global, based on the
    observation that CCCS is a transient register that's already handled
    by thread state load/store logic, so it doesn't need to be backed by
    the rCCCS field in the register table.
    
    Unfortunately, this is wrong, since even when Cmm execution hasn't
    yielded back to the scheduler, the Cmm code may call enterFunCCS,
    which does use rCCCS.
    
    This breaks cost centre profiling in a subtle way, resulting in
    inaccurate stack traces in some test cases. The fix is simple though:
    just remove the CCCS mapping.
    
    - - - - -
    26243de1 by Alexis King at 2023-02-20T15:27:17-05:00
    Handle top-level Addr# literals in the bytecode compiler
    
    Fixes #22376.
    
    - - - - -
    0196cc2b by romes at 2023-02-20T15:27:52-05:00
    fix: Explicitly flush stdout on plugin
    
    Because of #20791, the plugins tests often fail.  This is a temporary
    fix to stop the tests from failing due to unflushed outputs on windows
    and the explicit flush should be removed when #20791 is fixed.
    
    - - - - -
    4327d635 by Ryan Scott at 2023-02-20T20:44:34-05:00
    Don't generate datacon wrappers for `type data` declarations
    
    Data constructor wrappers only make sense for _value_-level data constructors,
    but data constructors for `type data` declarations only exist at the _type_
    level. This patch does the following:
    
    * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data
      constructor receives a wrapper now consider whether or not its parent data
      type was declared with `type data`, omitting a wrapper if this is the case.
    
    * Now that `type data` data constructors no longer receive wrappers, there is a
      spot of code in `refineDefaultAlt` that panics when it encounters a value
      headed by a `type data` type constructor. I've fixed this with a special case
      in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]`
      to explain why we do this.
    
    Fixes #22948.
    
    - - - - -
    96dc58b9 by Ryan Scott at 2023-02-20T20:44:35-05:00
    Treat type data declarations as empty when checking pattern-matching coverage
    
    The data constructors for a `type data` declaration don't exist at the value
    level, so we don't want GHC to warn users to match on them.
    
    Fixes #22964.
    
    - - - - -
    ff8e99f6 by Ryan Scott at 2023-02-20T20:44:35-05:00
    Disallow `tagToEnum#` on `type data` types
    
    We don't want to allow users to conjure up values of a `type data` type using
    `tagToEnum#`, as these simply don't exist at the value level.
    
    - - - - -
    8e765aff by Andrew Lelechenko at 2023-02-21T12:03:24-05:00
    Bump submodule text to 2.0.2
    
    - - - - -
    172ff88f by Georgi Lyubenov at 2023-02-21T18:35:56-05:00
    GHC proposal 496 - Nullary record wildcards
    
    This patch implements GHC proposal 496, which allows record wildcards
    to be used for nullary constructors, e.g.
    
      data A = MkA1 | MkA2 { fld1 :: Int }
      f :: A -> Int
      f (MkA1 {..}) = 0
      f (MkA2 {..}) = fld1
    
    To achieve this, we add arity information to the record field
    environment, so that we can accept a constructor which has no fields
    while continuing to reject non-record constructors with more than 1
    field. See Note [Nullary constructors and empty record wildcards],
    as well as the more general overview in Note [Local constructor info in the renamer],
    both in the newly introduced GHC.Types.ConInfo module.
    
    Fixes #22161
    
    - - - - -
    f70a0239 by sheaf at 2023-02-21T18:36:35-05:00
    ghc-prim: levity-polymorphic array equality ops
    
    This patch changes the pointer-equality comparison operations in
    GHC.Prim.PtrEq to work with arrays of unlifted values, e.g.
    
      sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int#
    
    Fixes #22976
    
    - - - - -
    9296660b by Andreas Klebinger at 2023-02-21T23:58:05-05:00
    base: Correct @since annotation for FP<->Integral bit cast operations.
    
    Fixes #22708
    
    - - - - -
    f11d9c27 by romes at 2023-02-21T23:58:42-05:00
    fix: Update documentation links
    
    Closes #23008
    
    Additionally batches some fixes to pointers to the Note [Wired-in units],
    and a typo in said note.
    
    - - - - -
    fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00
    Propagate failure if unable to push notes
    
    - - - - -
    8e170f86 by Alexis King at 2023-02-23T16:59:22-05:00
    rts: Fix `prompt#` when profiling is enabled
    
    This commit also adds a new -Dk RTS option to the debug RTS to assist
    debugging continuation captures. Currently, the printed information is
    quite minimal, but more can be added in the future if it proves to be
    useful when debugging future issues.
    
    fixes #23001
    
    - - - - -
    e9e7a00d by sheaf at 2023-02-23T17:00:01-05:00
    Explicit migration timeline for loopy SC solving
    
    This patch updates the warning message introduced in commit
    9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit
    migration timeline: GHC will no longer support this constraint solving
    mechanism starting from GHC 9.10.
    
    Fixes #22912
    
    - - - - -
    4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00
    JS: make some arithmetic primops faster (#22835)
    
    Don't use BigInt for wordAdd2, mulWord32, and timesInt32.
    
    Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org>
    
    - - - - -
    92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump terminfo submodule to 0.4.1.6
    
    - - - - -
    f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump unix submodule to 2.8.1.0
    
    - - - - -
    47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump deepseq submodule to 1.4.8.1
    
    - - - - -
    d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump directory submodule to 1.3.8.1
    
    - - - - -
    df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump process submodule to v1.6.17.0
    
    - - - - -
    4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump hsc2hs submodule to 0.68.8
    
    - - - - -
    81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump array submodule to 0.5.4.0
    
    - - - - -
    6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump Cabal submodule to 3.9 pre-release
    
    - - - - -
    4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump filepath submodule to 1.4.100.1
    
    - - - - -
    2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump haskeline submodule to 0.8.2.1
    
    - - - - -
    fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00
    gitlab-ci: Run nix-build with -v0
    
    This significantly cuts down on the amount of
    noise in the job log.
    
    Addresses #22861.
    - - - - -
    69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00
    Fix ParallelListComp out of scope suggestion
    
    This patch makes it so vars from one block of a parallel list
    comprehension are not in scope in a subsequent block during type
    checking. This was causing GHC to emit a faulty suggestion when an out
    of scope variable shared the occ name of a var from a different block.
    
    Fixes #22940
    
    - - - - -
    ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-05:00
    Fix shadowing bug in prepareAlts
    
    As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was
    using an OutType to construct an InAlt.  When shadowing is in play,
    this is outright wrong.
    
    See Note [Shadowing in prepareAlts].
    
    - - - - -
    7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00
    JS: Store CI perf results (fix #22923)
    
    - - - - -
    b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00
    Don't specialise incoherent instance applications
    
    Using incoherent instances, there can be situations where two
    occurrences of the same overloaded function at the same type use two
    different instances (see #22448). For incoherently resolved instances,
    we must mark them with `nospec` to avoid the specialiser rewriting one
    to the other. This marking is done during the desugaring of the
    `WpEvApp` wrapper.
    
    Fixes #22448
    
    Metric Increase:
        T15304
    
    - - - - -
    d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00
    Fix SCC grouping example
    
    - - - - -
    f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00
    Mark setnumcapabilities001 fragile
    
    - - - - -
    29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00
    Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail
    
    See #22520
    
    - - - - -
    9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00
    ghc-prim: fix hs_cmpxchg64 function prototype
    
    hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime
    results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised
    builds, which go unnoticed at compile-time due to C implicit casting
    in .hc files.
    
    - - - - -
    0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-05:00
    Account for local rules in specImports
    
    As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were
    generating specialisations (a locally-define function) for imported
    functions; and then generating specialisations for those
    locally-defined functions.  The RULE for the latter should be
    attached to the local Id, not put in the rules-for-imported-ids
    set.
    
    Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules
    
    - - - - -
    8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-05:00
    JS: fix for overlap with copyMutableByteArray# (#23033)
    
    The code wasn't taking into account some kind of overlap.
    
    cgrun070 has been extended to test the missing case.
    
    - - - - -
    239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00
    Testsuite: replace some js_skip with req_cmm
    
    req_cmm is more informative than js_skip
    
    - - - - -
    7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-05:00
    Take more care with unlifted bindings in the specialiser
    
    As #22998 showed, we were floating an unlifted binding to top
    level, which breaks a Core invariant.
    
    The fix is easy, albeit a little bit conservative.  See
    Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise
    
    - - - - -
    bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-05:00
    Account for TYPE vs CONSTRAINT in mkSelCo
    
    As #23018 showed, in mkRuntimeRepCo we need to account for coercions
    between TYPE and COERCION.
    
    See Note [mkRuntimeRepCo] in GHC.Core.Coercion.
    
    - - - - -
    79ffa170 by Ben Gamari at 2023-03-01T04:17:20-05:00
    hadrian: Add dependency from lib/settings to mk/config.mk
    
    In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253
    by adding logic to the bindist Makefile to regenerate the `settings`
    file from information gleaned by the bindist `configure` script.
    However, this fix had no effect as `lib/settings` is shipped in the
    binary distribution (to allow in-place use of the binary distribution).
    As `lib/settings` already existed and its rule declared no dependencies,
    `make` would fail to use the added rule to regenerate it.
    
    Fix this by explicitly declaring a dependency from `lib/settings` on
    `mk/config.mk`.
    
    Fixes #22982.
    
    - - - - -
    a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-05:00
    Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)"
    
    This reverts the bits affecting fusion of `drop` and `dropWhile` of commit
    0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring
    unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`.
    
    It also adds a new test for #23021 (which was the reason for reverting) as
    well as adds a clarifying comment to T18964.
    
    Fixes #23021, unfixes #18964.
    
    Metric Increase:
        T18964
    Metric Decrease:
        T18964
    
    - - - - -
    cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-05:00
    Refine the test for naughty record selectors
    
    The test for naughtiness in record selectors is surprisingly subtle.
    See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils.
    
    Fixes #23038.
    
    - - - - -
    86f240ca by romes at 2023-03-01T04:19:10-05:00
    fix: Consider strictness annotation in rep_bind
    
    Fixes #23036
    
    - - - - -
    1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00
    Don't suppress *all* Wanteds
    
    Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its
    rewriters have unfilled coercion holes; see
    Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint.
    
    But if we thereby suppress *all* errors that's really confusing,
    and as #22707 shows, GHC goes on without even realising that the
    program is broken. Disaster.
    
    This MR arranges to un-suppress them all if they all get suppressed.
    
    Close #22707
    
    - - - - -
    8919f341 by Luite Stegeman at 2023-03-02T22:42:45-05:00
    Check for platform support for JavaScript foreign imports
    
    GHC was accepting `foreign import javascript` declarations
    on non-JavaScript platforms. This adds a check so that these
    are only supported on an platform that supports the JavaScript
    calling convention.
    
    Fixes #22774
    
    - - - - -
    db83f8bb by Ben Gamari at 2023-03-02T22:43:22-05:00
    rts: Statically assert alignment of Capability
    
    In #22965 we noticed that changes in the size of `Capability` can result
    in unsound behavior due to the `align` pragma claiming an alignment
    which we don't in practice observe. Avoid this by statically asserting
    that the size is a multiple of the alignment.
    
    - - - - -
    5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00
    rts: Introduce stgMallocAlignedBytes
    
    - - - - -
    8a6f745d by Ben Gamari at 2023-03-02T22:43:22-05:00
    rts: Correctly align Capability allocations
    
    Previously we failed to tell the C allocator that `Capability`s needed
    to be aligned, resulting in #22965.
    
    Fixes #22965.
    Fixes #22975.
    
    - - - - -
    5464c73f by Ben Gamari at 2023-03-02T22:43:22-05:00
    rts: Drop no-alignment special case for Windows
    
    For reasons that aren't clear, we were previously not giving Capability
    the same favorable alignment on Windows that we provided on other
    platforms. Fix this.
    
    - - - - -
    a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-05:00
    constant folding: Correct type of decodeDouble_Int64 rule
    
    The first argument is Int64# unconditionally, so we better produce
    something of that type. This fixes a core lint error found in the ad
    package.
    
    Fixes #23019
    
    - - - - -
    68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-05:00
    ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs
    
    Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was
    incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and
    didn't completly fix the compiler panics when compiling with `-fregs-graph`.
    
    Fixes #23002
    
    - - - - -
    2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00
    Get the right in-scope set in etaBodyForJoinPoint
    
    Fixes #23026
    
    - - - - -
    45af8482 by David Feuer at 2023-03-03T11:40:47-05:00
    Export getSolo from Data.Tuple
    
    Proposed in
    [CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113)
    and
    [approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191)
    
    - - - - -
    0c694895 by David Feuer at 2023-03-03T11:40:47-05:00
    Document getSolo
    
    - - - - -
    bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00
    More fixes for `type data` declarations
    
    This MR fixes #23022 and #23023.  Specifically
    
    * Beef up Note [Type data declarations] in GHC.Rename.Module,
      to make invariant (I1) explicit, and to name the several
      wrinkles.
    
      And add references to these specific wrinkles.
    
    * Add a Lint check for invariant (I1) above.
      See GHC.Core.Lint.checkTypeDataConOcc
    
    * Disable the `caseRules` for dataToTag# for `type data` values.
      See Wrinkle (W2c) in the Note above.  Fixes #23023.
    
    * Refine the assertion in dataConRepArgTys, so that it does not
      complain about the absence of a wrapper for a `type data` constructor
      Fixes #23022.
    
    Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00
    Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT
    
    These all type-level equality decision procedures.
    
    Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98
    
    - - - - -
    bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00
    Add test for T22793
    
    - - - - -
    c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00
    Fix typo in docs referring to threadLabel
    
    - - - - -
    232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00
    Add regression test for #22328
    
    - - - - -
    5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Enable response files for linker if supported
    
    - - - - -
    1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Synchronize `configure.ac` and `distrib/configure.ac.in`
    
    - - - - -
    70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Fix `hadrian/bindist/config.mk.in`
    
    … as suggested by @bgamari
    
    - - - - -
    b042b125 by sheaf at 2023-03-06T17:06:50-05:00
    Apply 1 suggestion(s) to 1 file(s)
    - - - - -
    674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Try to create somewhat portable `ld` command
    
    I cannot figure out a good way to generate an `ld` command
    that works on both Linux and macOS.  Normally you'd use something
    like `AC_LINK_IFELSE` for this purpose (I think), but that won't
    let us test response file support.
    
    - - - - -
    83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Quote variables
    
    … as suggested by @bgamari
    
    - - - - -
    845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Fix configure failure on alpine linux
    
    - - - - -
    c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Small fixes to configure script
    
    - - - - -
    cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00
    Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115)
    
    I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module
    module into a proper TcRnMessage.
    Instead, these TcRnMessage messages were introduced:
      TcRnIllegalInstanceHeadDecl
      TcRnUnexpectedStandaloneDerivingDecl
      TcRnUnusedVariableInRuleDecl
      TcRnUnexpectedStandaloneKindSig
      TcRnIllegalRuleLhs
      TcRnBadAssocRhs
      TcRnDuplicateRoleAnnot
      TcRnDuplicateKindSig
      TcRnIllegalDerivStrategy
      TcRnIllegalMultipleDerivClauses
      TcRnNoDerivStratSpecified
      TcRnStupidThetaInGadt
      TcRnBadImplicitSplice
      TcRnShadowedTyVarNameInFamResult
      TcRnIncorrectTyVarOnLhsOfInjCond
      TcRnUnknownTyVarsOnRhsOfInjCond
    
    Was introduced one helper type:
      RuleLhsErrReason
    
    - - - - -
    c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00
    Constraint simplification loop now depends on `ExpansionFuel`
    instead of a boolean flag for `CDictCan.cc_pend_sc`.
    Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1.
    This helps pending given constraints to keep up with pending wanted constraints in case of
    `UndecidableSuperClasses` and superclass expansions while simplifying the infered type.
    
    Adds 3 dynamic flags for controlling the fuels for each type of constraints
    `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints
    
    Fixes #21909
    Added Tests T21909, T21909b
    Added Note [Expanding Recursive Superclasses and ExpansionFuel]
    
    - - - - -
    a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00
    Documentation: describe laziness of several function from Data.List
    
    - - - - -
    fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00
    Add `Data.Functor.unzip`
    
    This function is currently present in `Data.List.NonEmpty`, but `Data.Functor`
    is a better home for it. This change was discussed and approved by the CLC
    at https://github.com/haskell/core-libraries-committee/issues/88.
    
    - - - - -
    2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00
    Fix documentation for traceWith and friends
    
    - - - - -
    f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00
    Remove utils/hpc subdirectory and its contents
    
    - - - - -
    cf98e286 by David Binder at 2023-03-08T01:24:17-05:00
    Add git submodule for utils/hpc
    
    - - - - -
    605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00
    Update commit for utils/hpc git submodule
    
    - - - - -
    606793d4 by David Binder at 2023-03-08T01:24:18-05:00
    Update commit for utils/hpc git submodule
    
    - - - - -
    4158722a by Sylvain Henry at 2023-03-08T01:24:58-05:00
    linker: fix linking with aligned sections (#23066)
    
    Take section alignment into account instead of assuming 16 bytes (which
    is wrong when the section requires 32 bytes, cf #23066).
    
    - - - - -
    1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00
    Change hostSupportsRPaths to report False on OpenBSD
    
    OpenBSD does support -rpath but ghc build process relies on some
    related features that don't work there. See ghc/ghc#23011
    
    - - - - -
    bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00
    bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args
    
    fixes #23068
    
    - - - - -
    321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts: Drop redundant prototype
    
    - - - - -
    abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Fix style
    
    - - - - -
    be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Deduplicate assertion
    
    - - - - -
    b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts: Fix type issues in Sparks.h
    
    Adds explicit casts to satisfy a C++ compiler.
    
    - - - - -
    da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts: Use release ordering when storing thread labels
    
    Since this makes the ByteArray# visible from other cores.
    
    - - - - -
    5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts/BlockAlloc: Allow disabling of internal assertions
    
    These can be quite expensive and it is sometimes useful to compile a
    DEBUG RTS without them.
    
    - - - - -
    6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts/Sanity: Mark pinned_object_blocks
    
    - - - - -
    9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts/Sanity: Look at nonmoving saved_filled lists
    
    - - - - -
    0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00
    Evac: Squash data race in eval_selector_chain
    
    - - - - -
    7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Clarify implementation
    
    This makes the intent of this implementation a bit clearer.
    
    - - - - -
    532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Clarify comment
    
    - - - - -
    bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Add missing no-op in busy-wait loop
    
    - - - - -
    c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Don't push empty arrays to update remembered set
    
    Previously the write barrier of resizeSmallArray# incorrectly handled
    resizing of zero-sized arrays, pushing an invalid pointer to the update
    remembered set.
    
    Fixes #22931.
    
    - - - - -
    92227b60 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Fix handling of weak pointers
    
    This fixes an interaction between aging and weak pointer handling which
    prevented the finalization of some weak pointers. In particular, weak
    pointers could have their keys incorrectly marked by the preparatory
    collector, preventing their finalization by the subsequent concurrent
    collection.
    
    While in the area, we also significantly improve the assertions
    regarding weak pointers.
    
    Fixes #22327.
    
    - - - - -
    ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Sanity check nonmoving large objects and compacts
    
    - - - - -
    71b038a1 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Sanity check mutable list
    
    Assert that entries in the nonmoving generation's generational
    remembered set (a.k.a. mutable list) live in nonmoving generation.
    
    - - - - -
    99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Don't show occupancy if we didn't collect live words
    
    - - - - -
    81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Fix tracking of FILLED_SWEEPING segments
    
    Previously we only updated the state of the segment at the head of each
    allocator's filled list.
    
    - - - - -
    58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Assert state of swept segments
    
    - - - - -
    2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Handle new closures in nonmovingIsNowAlive
    
    We must conservatively assume that new closures are reachable since we
    are not guaranteed to mark such blocks.
    
    - - - - -
    e4c3249f by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Don't clobber update rem sets of old capabilities
    
    Previously `storageAddCapabilities` (called by `setNumCapabilities`) would
    clobber the update remembered sets of existing capabilities when
    increasing the capability count. Fix this by only initializing the
    update remembered sets of the newly-created capabilities.
    
    Fixes #22927.
    
    - - - - -
    1b069671 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Add missing write barriers in selector optimisation
    
    This fixes the selector optimisation, adding a few write barriers which
    are necessary for soundness. See the inline comments for details.
    
    Fixes #22930.
    
    - - - - -
    d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Post-sweep sanity checking
    
    - - - - -
    0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Avoid n_caps race
    
    - - - - -
    5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Don't push if nonmoving collector isn't enabled
    
    - - - - -
    0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Be more paranoid in segment tracking
    
    Previously we left various segment link pointers dangling. None of this
    wrong per se, but it did make it harder than necessary to debug.
    
    - - - - -
    7c817c0a by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Sync-phase mark budgeting
    
    Here we significantly improve the bound on sync phase pause times by
    imposing a limit on the amount of work that we can perform during the
    sync. If we find that we have exceeded our marking budget then we allow
    the mutators to resume, return to concurrent marking, and try
    synchronizing again later.
    
    Fixes #22929.
    
    - - - - -
    ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Allow pinned gen0 objects to be WEAK keys
    
    - - - - -
    78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Reenable assertion
    
    - - - - -
    b500867a by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Move current segment array into Capability
    
    The current segments are conceptually owned by the mutator, not the
    collector. Consequently, it was quite tricky to prove that the mutator
    would not race with the collect due to this shared state. It turns out
    that such races are possible: when resizing the current segment array
    we may concurrently try to take a heap census. This will attempt to walk
    the current segment array, causing a data race.
    
    Fix this by moving the current segment array into `Capability`, where it
    belongs.
    
    Fixes #22926.
    
    - - - - -
    56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Fix Note references
    
    Some references to Note [Deadlock detection under the non-moving
    collector] were missing an article.
    
    - - - - -
    4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts/Sanity: Fix block count assertion with non-moving collector
    
    The nonmoving collector does not use `oldest_gen->blocks` to track its
    block list. However, it nevertheless updates `oldest_gen->n_blocks` to
    ensure that its size is accounted for by the storage manager.
    Consequently, we must not attempt to assert consistency between the two.
    
    - - - - -
    96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Don't call prepareUnloadCheck
    
    When the nonmoving GC is in use we do not call `checkUnload` (since we
    don't unload code) and therefore should not call `prepareUnloadCheck`,
    lest we run into assertions.
    
    - - - - -
    6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Encapsulate block allocator spinlock
    
    This makes it a bit easier to add instrumentation on this spinlock
    while debugging.
    
    - - - - -
    e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00
    testsuite: Skip some tests when sanity checking is enabled
    
    - - - - -
    3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Fix unregisterised build
    
    - - - - -
    4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Ensure that sanity checker accounts for saved_filled segments
    
    - - - - -
    f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00
    hadrian: Add +boot_nonmoving_gc flavour transformer
    
    For using GHC bootstrapping to validate the non-moving GC.
    
    - - - - -
    581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00
    gitlab-ci: Add job bootstrapping with nonmoving GC
    
    - - - - -
    487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Move allocator into new source file
    
    - - - - -
    8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Split out nonmovingAllocateGC
    
    - - - - -
    662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00
    testsuite: Only run T22795* in the normal way
    
    It doesn't make sense to run these in multiple ways as they merely test
    whether `-threaded`/`-single-threaded` flags.
    
    - - - - -
    0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Rename clear_segment(_free_blocks)?
    
    To reflect the fact that these are to do with the nonmoving collector,
    now since they are exposed no longer static.
    
    - - - - -
    7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Fix incorrect STATIC_INLINE
    
    This should be INLINE_HEADER lest we get unused declaration warnings.
    
    - - - - -
    f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00
    testsuite: Mark ffi023 as broken due to #23089
    
    - - - - -
    a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00
    testsuite: Skip T7160 in the nonmoving way
    
    Finalization order is different under the nonmoving collector.
    
    - - - - -
    f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Capture GC configuration in a struct
    
    The number of distinct arguments passed to GarbageCollect was getting a
    bit out of hand.
    
    - - - - -
    ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Non-concurrent collection
    
    - - - - -
    7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00
    hadrian: Fix flavour compiler stage options off-by-one error
    
    !9193 pointed out that ghcDebugAssertions was supposed to be a predicate
    on the stage of the built compiler, but in practice it was a predicate
    on the stage of the compiler used to build. Unfortunately, while it
    fixed that issue for ghcDebugAssertions, it documented every other
    similar option as behaving the same way when in fact they all used the
    old behavior.
    
    The new behavior of ghcDebugAssertions seems more intuitive, so this
    commit changes the interpretation of every other option to match. It
    also improves the enableProfiledGhc and debugGhc flavour transformers by
    making them more selective about which stages in which they build
    additional library/RTS ways.
    
    - - - - -
    f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00
    Delete created temporary subdirectories at end of session.
    
    This patch adds temporary subdirectories to the list of
    paths do clean up at the end of the GHC session. This
    fixes warnings about non-empty temporary directories.
    
    Fixes #22952
    
    - - - - -
    9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00
    Fixes #19627.
    
    Previously the solver failed with an unhelpful "solver reached too may iterations" error.
    With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up.
    
    This commit adds:
    * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel]
    * Test `typecheck/should_fail/T19627.hs` for regression purposes
    
    - - - - -
    ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00
    DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997)
    
    We should not panic in `add_demands` (now `set_lam_dmds`), because that code
    path is legimitely taken for OPAQUE PAP bindings, as in T22997.
    
    Fixes #22997.
    
    - - - - -
    5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00
    JS: remove dead code for old integer-gmp
    
    - - - - -
    bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00
    JS: Fix implementation of MK_JSVAL
    
    - - - - -
    ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00
    Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check
    
    There is no need to run arity analysis and what not if we are not in a
    Simplifier phase that eta-expands or if we don't want to eta-expand the
    expression in the first place.
    
    Purely a refactoring with the goal of improving compiler perf.
    
    - - - - -
    047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00
    JS: fix implementation of forceBool to use JS backend syntax
    
    - - - - -
    559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00
    Simplifier: `countValArgs` should not count Type args (#23102)
    
    I observed miscompilations while working on !10088 caused by this.
    
    Fixes #23102.
    
    Metric Decrease:
        T10421
    
    - - - - -
    536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00
    Bump Win32 to 2.13.4.0
    
    Updates Win32 submodule
    
    - - - - -
    ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00
    ghc-bignum: Drop redundant include-dirs field
    - - - - -
    c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00
    Fix BCO creation setting caps when -j > -N
    
    * Remove calls to 'setNumCapabilities' in 'createBCOs'
    These calls exist to ensure that 'createBCOs' can benefit from
    parallelism. But this is not the right place to call
    `setNumCapabilities`. Furthermore the logic differs from that in the
    driver causing the capability count to be raised and lowered at each TH
    call if -j > -N.
    
    * Remove 'BCOOpts'
    No longer needed as it was only used to thread the job count down to `createBCOs`
    
    Resolves #23049
    
    - - - - -
    5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00
    Add changelog entry for #23049
    
    - - - - -
    6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00
    configure: Fix FIND_CXX_STD_LIB test on Darwin
    
    Annoyingly, Darwin's <cstddef> includes <version> and APFS is
    case-insensitive. Consequently, it will end up #including the
    `VERSION` file generated by the `configure` script on the second
    and subsequent runs of the `configure` script.
    
    See #23116.
    - - - - -
    19d6d039 by sheaf at 2023-03-16T21:31:22+01:00
    ghci: only keep the GlobalRdrEnv in ModInfo
    
    The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo,
    which includes a TypeEnv. This can easily cause space leaks as we
    have no way of forcing everything in a type environment.
    
    In GHC, we only use the GlobalRdrEnv, which we can force completely.
    So we only store that instead of a fully-fledged ModuleInfo.
    
    - - - - -
    73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00
    Add structured error messages for GHC.Tc.Utils.Backpack
    
    Tracking ticket: #20119
    
    MR: !10127
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    One occurrence, when handing a nested error from the interface loading
    machinery, was omitted. It will be handled by a subsequent changeset
    that addresses interface errors.
    
    - - - - -
    a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00
    Rename () into Unit, (,,...,,) into Tuple<n> (#21294)
    
    This patch implements a part of GHC Proposal #475.
    The key change is in GHC.Tuple.Prim:
    
      - data () = ()
      - data (a,b) = (a,b)
      - data (a,b,c) = (a,b,c)
      ...
      + data Unit = ()
      + data Tuple2 a b = (a,b)
      + data Tuple3 a b c = (a,b,c)
      ...
    
    And the rest of the patch makes sure that Unit and Tuple<n>
    are pretty-printed as () and (,,...,,) in various contexts.
    
    Updates the haddock submodule.
    
    Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com>
    
    - - - - -
    23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: fix some wrongs in the eventlog format documentation
    
    - - - - -
    90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: explain the BLOCK_MARKER event
    
    - - - - -
    ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: add BlockedOnMVarRead thread status in eventlog encodings
    
    - - - - -
    898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: add TASK_DELETE event in eventlog encodings
    
    - - - - -
    bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: add WALL_CLOCK_TIME event in eventlog encodings
    
    - - - - -
    eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00
    Add structured error messages for GHC.Tc.Utils.Env
    
    Tracking ticket: #20119
    
    MR: !10129
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00
    Document pdep / pext primops
    
    - - - - -
    e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00
    Allow LLVM backend to use HDoc for faster file generation.
    
    Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement.
    
    Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045)
    
    - - - - -
    ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00
    Compute LambdaFormInfo when using JavaScript backend.
    
    CmmCgInfos is needed to write interface files, but the
    JavaScript backend does not generate it, causing
    "Name without LFInfo" warnings.
    
    This patch adds a conservative but always correct
    CmmCgInfos when the JavaScript backend is used.
    
    Fixes #23053
    
    - - - - -
    926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00
    Be more careful about quantification
    
    This MR is driven by #23051. It does several things:
    
    * It is guided by the generalisation plan described in #20686.
      But it is still far from a complete implementation of that plan.
    
    * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind.
      This explains that we don't (yet, pending #20686) directly
      prevent generalising over escaping kinds.
    
    * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep
      and Multiplicity variables, beause we don't want to quantify over
      them.  We want to do the same for a Concrete tyvar, but there is
      nothing sensible to default it to (unless it has kind RuntimeRep,
      in which case it'll be caught by an earlier case). So we promote
      instead.
    
    * Pure refactoring in GHC.Tc.Solver:
      * Rename decideMonoTyVars to decidePromotedTyVars, since that's
        what it does.
    
      * Move the actual promotion of the tyvars-to-promote from
        `defaultTyVarsAndSimplify` to `decidePromotedTyVars`.  This is a
        no-op; just tidies up the code.  E.g then we don't need to
        return the promoted tyvars from `decidePromotedTyVars`.
    
      * A little refactoring in `defaultTyVarsAndSimplify`, but no
        change in behaviour.
    
    * When making a TauTv unification variable into a ConcreteTv
      (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name
      of the type variable.  This just improves error messages.
    
    * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole
    
    - - - - -
    0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00
    Testsuite: use appropriate predicate for ManyUbxSums test (#22576)
    
    - - - - -
    048c881e by romes at 2023-03-22T01:04:24-04:00
    fix: Incorrect @since annotations in GHC.TypeError
    
    Fixes #23128
    
    - - - - -
    a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00
    Testsuite: use req_interp predicate for T16318 (#22370)
    
    - - - - -
    ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00
    Testsuite: use req_interp predicate for T20214
    
    - - - - -
    e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00
    Refactor the constraint solver pipeline
    
    The big change is to put the entire type-equality solver into
    GHC.Tc.Solver.Equality, rather than scattering it over Canonical
    and Interact.  Other changes
    
    * EqCt becomes its own data type, a bit like QCInst.  This is
      great because EqualCtList is then just [EqCt]
    
    * New module GHC.Tc.Solver.Dict has come of the class-contraint
      solver.  In due course it will be all.  One step at a time.
    
    This MR is intended to have zero change in behaviour: it is a
    pure refactor.  It opens the way to subsequent tidying up, we
    believe.
    
    - - - - -
    cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00
    Add structured error messages for GHC.Tc.Utils.TcMType
    
    Tracking ticket: #20119
    
    MR: !10138
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00
    Testsuite: use js_skip for T2615 (#22374)
    
    - - - - -
    8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00
    Optimized Foldable methods for Data.Functor.Compose
    
    Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose
    
    Implementation of https://github.com/haskell/core-libraries-committee/issues/57
    
    - - - - -
    bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00
    Additional optimized versions
    
    - - - - -
    80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00
    Simplify minimum/maximum in instance Foldable (Compose f g)
    
    - - - - -
    8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00
    Update changelog to mention changes to instance Foldable (Compose f g)
    
    - - - - -
    e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00
    Add structured error messages for GHC.Tc.TyCl.PatSyn
    
    Tracking ticket: #20117
    
    MR: !10158
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00
    Allow WARNING pragmas to be controlled with custom categories
    
    Closes #17209. This implements GHC Proposal 541, allowing a WARNING
    pragma to be annotated with a category like so:
    
        {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-}
    
    The user can then enable, disable and set the severity of such warnings
    using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on.  There
    is a new warning group `-Wextended-warnings` containing all these warnings.
    Warnings without a category are treated as if the category was `deprecations`,
    and are (still) controlled by the flags `-Wdeprecations`
    and `-Wwarnings-deprecations`.
    
    Updates Haddock submodule.
    
    - - - - -
    0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00
    Move mention of warning groups change to 9.8.1 release notes
    
    - - - - -
    b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00
    nativeGen/AArch64: Fix bitmask immediate predicate
    
    Previously the predicate for determining whether a logical instruction
    operand could be encoded as a bitmask immediate was far too
    conservative. This meant that, e.g., pointer untagged required five
    instructions whereas it should only require one.
    
    Fixes #23030.
    
    - - - - -
    46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00
    User's guide: Improve docs for -Wall
    
    previously it would list the warnings _not_ enabled by -Wall. That’s
    unnecessary round-about and was out of date. So let's just name
    the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`).
    
    - - - - -
    509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00
    codeGen/tsan: Disable instrumentation of unaligned stores
    
    There is some disagreement regarding the prototype of
    `__tsan_unaligned_write` (specifically whether it takes just the written
    address, or the address and the value as an argument). Moreover, I have
    observed crashes which appear to be due to it. Disable instrumentation
    of unaligned stores as a temporary mitigation.
    
    Fixes #23096.
    
    - - - - -
    6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00
    base: Document GHC versions associated with past base versions in the changelog
    
    - - - - -
    43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00
    Add regression test for #17574
    
    This test currently fails in the nonmoving way
    
    - - - - -
    f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00
    fix: account for large and compact object stats with nonmoving gc
    
    Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap.
    We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap.
    
    Resolves #17574
    
    - - - - -
    7131b705 by David Feuer at 2023-03-25T00:04:04-04:00
    Modify ThreadId documentation and comments
    
    For a long time, `GHC.Conc.Sync` has said
    
    ```haskell
    -- ToDo: data ThreadId = ThreadId (Weak ThreadId#)
    -- But since ThreadId# is unlifted, the Weak type must use open
    -- type variables.
    ```
    
    We are now actually capable of using `Weak# ThreadId#`, but the
    world has moved on. To support the `Show` and `Ord` instances, we'd
    need to store the thread ID number in the `ThreadId`. And it seems
    very difficult to continue to support `threadStatus` in that regime,
    since it needs to be able to explain how threads died. In addition,
    garbage collection of weak references can be quite expensive, and it
    would be hard to evaluate the cost over he whole ecosystem. As discussed
    in
    [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125),
    it doesn't seem very likely that we'll actually switch to weak
    references here.
    
    - - - - -
    c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00
    rts: Fix barriers of IND and IND_STATIC
    
    Previously IND and IND_STATIC lacked the acquire barriers enjoyed by
    BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers],
    this barrier is critical to ensure that the indirectee is visible to the
    entering core.
    
    Fixes #22872.
    
    - - - - -
    62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00
    Improve documentation of atomicModifyMutVar2#
    
    - - - - -
    b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00
    rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023
    
    This patch does a few things:
    
    - Add the missing RtsSymbols.c entry of performBlockingMajorGC
    - Make hs_perform_gc call performBlockingMajorGC, which restores
      previous behavior
    - Use hs_perform_gc in ffi023
    - Remove rts_clearMemory() call in ffi023, it now works again in some
      test ways previously marked as broken. Fixes #23089
    
    - - - - -
    d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00
    testsuite: add the rts_clearMemory test case
    
    This patch adds a standalone test case for rts_clearMemory that mimics
    how it's typically used by wasm backend users and ensures this RTS API
    isn't broken by future RTS refactorings. Fixes #23901.
    
    - - - - -
    80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00
    Improve documentation for resizing of byte arrays
    
    - - - - -
    c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00
    rts: Don't rely on EXTERN_INLINE for slop-zeroing logic
    
    Previously we relied on calling EXTERN_INLINE functions defined in
    ClosureMacros.h from Cmm to zero slop. However, as far as I can tell,
    this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted
    in each compilation unit.
    
    Fix this by explicitly declaring a new set of non-inline functions in
    ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h
    definitions as INLINE_HEADER.
    
    In the future we should try to eliminate EXTERN_INLINE.
    
    - - - - -
    c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00
    rts: Fix capability-count check in zeroSlop
    
    Previously `zeroSlop` examined `RtsFlags` to determine whether the
    program was single-threaded. This is wrong; a program may be started
    with `+RTS -N1` yet the process may later increase the capability count
    with `setNumCapabilities`. This lead to quite subtle and rare crashes.
    
    Fixes #23088.
    
    - - - - -
    656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00
    Add Eq/Ord instances for SSymbol, SChar, and SNat
    
    This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148).
    
    - - - - -
    4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00
    Update and expand atomic modification Haddocks
    
    * The documentation for `atomicModifyIORef` and `atomicModifyIORef'`
      were incomplete, and the documentation for `atomicModifyIORef` was
      out of date. Update and expand.
    
    * Remove a useless lazy pattern match in the definition of
      `atomicModifyIORef`. The pair it claims to match lazily
      was already forced by `atomicModifyIORef2`.
    
    - - - - -
    e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00
    Document the constructor name for lists
    
    Derived `Data` instances use raw infix constructor names when applicable.
    The `Data.Data [a]` instance, if derived, would have a constructor name
    of `":"`. However, it actually uses constructor name `"(:)"`. Document this
    peculiarity.
    
    See https://github.com/haskell/core-libraries-committee/issues/147
    
    - - - - -
    c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00
    Make exprIsConApp_maybe a bit cleverer
    
    Addresses #23159.
    
    See Note Note [Exploit occ-info in exprIsConApp_maybe]
    in GHC.Core.SimpleOpt.
    
    Compile times go down very slightly, but always go down,
    never up.  Good!
    
    Metrics: compile_time/bytes allocated
    ------------------------------------------------
     CoOpt_Singletons(normal)   -1.8%
               T15703(normal)   -1.2% GOOD
    
                    geo. mean   -0.1%
                    minimum     -1.8%
                    maximum     +0.0%
    
    Metric Decrease:
        CoOpt_Singletons
        T15703
    
    - - - - -
    76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00
    Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat
    
    This implements
    [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149).
    
    - - - - -
    3f374399 by sheaf at 2023-03-29T13:57:33+02:00
    Handle records in the renamer
    
    This patch moves the field-based logic for disambiguating record updates
    to the renamer. The type-directed logic, scheduled for removal, remains
    in the typechecker.
    
    To do this properly (and fix the myriad of bugs surrounding the treatment
    of duplicate record fields), we took the following main steps:
    
      1. Create GREInfo, a renamer-level equivalent to TyThing which stores
         information pertinent to the renamer.
         This allows us to uniformly treat imported and local Names in the
         renamer, as described in Note [GREInfo].
    
      2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which
         distinguished between normal names and field names, we now store
         simple Names in GlobalRdrElt, along with the new GREInfo information
         which allows us to recover the FieldLabel for record fields.
    
      3. Add namespacing for record fields, within the OccNames themselves.
         This allows us to remove the mangling of duplicate field selectors.
    
         This change ensures we don't print mangled names to the user in
         error messages, and allows us to handle duplicate record fields
         in Template Haskell.
    
      4. Move record disambiguation to the renamer, and operate on the
         level of data constructors instead, to handle #21443.
    
         The error message text for ambiguous record updates has also been
         changed to reflect that type-directed disambiguation is on the way
         out.
    
    (3) means that OccEnv is now a bit more complex: we first key on the
    textual name, which gives an inner map keyed on NameSpace:
    
      OccEnv a ~ FastStringEnv (UniqFM NameSpace a)
    
    Note that this change, along with (2), both increase the memory residency
    of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to
    regress somewhat in compile-time allocation.
    
    Even though (3) simplified a lot of code (in particular the treatment of
    field selectors within Template Haskell and in error messages), it came
    with one important wrinkle: in the situation of
    
      -- M.hs-boot
      module M where { data A; foo :: A -> Int }
      -- M.hs
      module M where { data A = MkA { foo :: Int } }
    
    we have that M.hs-boot exports a variable foo, which is supposed to match
    with the record field foo that M exports. To solve this issue, we add a
    new impedance-matching binding to M
    
      foo{var} = foo{fld}
    
    This mimics the logic that existed already for impedance-binding DFunIds,
    but getting it right was a bit tricky.
    See Note [Record field impedance matching] in GHC.Tc.Module.
    
    We also needed to be careful to avoid introducing space leaks in GHCi.
    So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in
    ModIface. This means stubbing out all the GREInfo fields, with the
    function forceGlobalRdrEnv.
    When we read it back in, we rehydrate with rehydrateGlobalRdrEnv.
    This robustly avoids any space leaks caused by retaining old type
    environments.
    
    Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063
    
    Updates haddock submodule
    
    -------------------------
    Metric Increase:
        MultiComponentModules
        MultiLayerModules
        MultiLayerModulesDefsGhci
        MultiLayerModulesNoCode
        T13701
        T14697
        hard_hole_fits
    -------------------------
    
    - - - - -
    4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00
    Avoid repeatedly shadowing in shadowNames
    
    This commit refactors GHC.Type.Name.Reader.shadowNames to first
    accumulate all the shadowing arising from the introduction of a new
    set of GREs, and then applies all the shadowing to the old GlobalRdrEnv
    in one go.
    
    - - - - -
    d246049c by sheaf at 2023-03-29T13:57:34+02:00
    igre_prompt_env: discard "only-qualified" names
    
    We were unnecessarily carrying around names only available qualified
    in igre_prompt_env, violating the icReaderEnv invariant.
    We now get rid of these, as they aren't needed for the shadowing
    computation that igre_prompt_env exists for.
    
    Fixes #23177
    
    -------------------------
    Metric Decrease:
        T14052
        T14052Type
    -------------------------
    
    - - - - -
    41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00
    hadrian: Fix path to HpcParser.y
    
    The source for this project has been moved into a src/ folder so we also
    need to update this path.
    
    Fixes #23187
    
    - - - - -
    b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00
    js: split JMacro into JS eDSL and JS syntax
    
    This commit:
    
    Splits JExpr and JStat into two nearly identical DSLs:
    - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a
    value cannot be unsaturated, or, a value of this DSL is a witness that a
    value of GHC.JS.Unsat has been saturated
    - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation.
    
    Then all binary and outputable instances are changed to use
    GHC.JS.Syntax.
    
    This moves us closer to closing out #22736 and #22352. See #22736 for
    roadmap.
    
    -------------------------
    Metric Increase:
        CoOpt_Read
        LargeRecord
        ManyAlternatives
        PmSeriesS
        PmSeriesT
        PmSeriesV
        T10421
        T10858
        T11195
        T11374
        T11822
        T12227
        T12707
        T13035
        T13253
        T13253-spj
        T13379
        T14683
        T15164
        T15703
        T16577
        T17096
        T17516
        T17836
        T18140
        T18282
        T18304
        T18478
        T18698a
        T18698b
        T18923
        T1969
        T19695
        T20049
        T21839c
        T3064
        T4801
        T5321FD
        T5321Fun
        T5631
        T5642
        T783
        T9198
        T9233
        T9630
        TcPlugin_RewritePerf
        WWRec
    -------------------------
    
    - - - - -
    f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00
    ghc-heap: remove wrong Addr# coercion (#23181)
    
    Conversion from Addr# to I# isn't correct with the JS backend.
    
    Also used the opportunity to reenable 64-bit Word/Int tests
    
    - - - - -
    a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00
    testsuite: Fix racing prints in T21465
    
    As noted in #23155, we previously failed to add flushes necessary to
    ensure predictable output.
    
    Fixes #23155.
    
    - - - - -
    98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00
    Revert "ghc-heap: remove wrong Addr# coercion (#23181)"
    
    This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02.
    
    This fails to build with GHC-9.2 as a boot compiler.
    
    See #23195 for tracking this issue.
    
    - - - - -
    61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
    Add {-# WARNING #-} to Data.List.{head,tail}
    
    - - - - -
    8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
    Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-}
    
    - - - - -
    7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
    Bump submodules
    
    - - - - -
    d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
    Fix tests
    
    - - - - -
    3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00
    Proxies for head and tail: review suggestions
    - - - - -
    930edcfd by sheaf at 2023-03-30T14:36:33-04:00
    docs: move RecordUpd changelog entry to 9.8
    
    This was accidentally included in the 9.6 changelog
    instead of the 9.6 changelog.
    - - - - -
    6f885e65 by sheaf at 2023-03-30T14:37:09-04:00
    Add LANGUAGE GADTs to GHC.Rename.Env
    
    We need to enable this extension for the file to compile with ghc 9.2,
    as we are pattern matching on a GADT and this required the GADT extension
    to be enabled until 9.4.
    - - - - -
    6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: make lint-ci-config job fast again
    
    We don't pin our nixpkgs revision and tracks the default
    nixpkgs-unstable channel anyway. Instead of using
    haskell.packages.ghc924, we should be using haskell.packages.ghc92 to
    maximize the binary cache hit rate and make lint-ci-config job fast
    again. Also bumps the nix docker image to the latest revision.
    
    - - - - -
    ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: ensure that all non-i386 pipelines do parallel xz compression
    
    We can safely enable parallel xz compression for non-i386 pipelines.
    However, previously we didn't export XZ_OPT, so the xz process won't
    see it if XZ_OPT hasn't already been set in the current job.
    
    - - - - -
    20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: unset CROSS_EMULATOR for js job
    
    - - - - -
    4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: fix lint-testsuite job
    
    The list_broken make target will transitively depend on the
    calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It
    really should be TEST_HC since that's what get passed in the gitlab CI
    config.
    
    - - - - -
    cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: use alpine3_17-wasm image for wasm jobs
    
    Bump the ci-images dependency and use the new alpine3_17-wasm docker
    image for wasm jobs.
    
    - - - - -
    79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00
    testsuite/driver: Add basic support for testing cross-compilers
    
    - - - - -
    e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00
    testsuite/driver: Normalize away differences in ghc executable name
    
    - - - - -
    ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00
    hadrian: Pass CROSS_EMULATOR to runtests.py
    
    - - - - -
    30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: don't add optllvm way for wasm32
    
    - - - - -
    f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: normalize the .wasm extension
    
    - - - - -
    a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: strip the cross ghc prefix in output and error message
    
    - - - - -
    f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: handle target executable extension
    
    - - - - -
    8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: mypy typing error fixes
    
    This patch fixes some mypy typing errors which weren't caught in
    previous linting jobs.
    
    - - - - -
    0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: use context variable instead of thread-local variable
    
    This patch changes a thread-local variable to context variable
    instead, which works as intended when the testsuite transitions to use
    asyncio & coroutines instead of multi-threading to concurrently run
    test cases. Note that this also raises the minimum Python version to
    3.7.
    
    - - - - -
    ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: asyncify the testsuite driver
    
    This patch refactors the testsuite driver, gets rid of multi-threading
    logic for running test cases concurrently, and uses asyncio &
    coroutines instead. This is not yak shaving for its own sake; the
    previous multi-threading logic is prone to livelock/deadlock
    conditions for some reason, even if the total number of threads is
    bounded to a thread pool's capacity.
    
    The asyncify change is an internal implementation detail of the
    testsuite driver and does not impact most GHC maintainers out there.
    The patch does not touch the .T files, test cases can be
    added/modified the exact same way as before.
    
    - - - - -
    0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00
    Add test for T23184
    
    There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch:
    
    ```
    commit 6656f0165a30fc2a22208532ba384fc8e2f11b46
    Author: Simon Peyton Jones <simonpj at microsoft.com>
    Date:   Fri Jul 23 23:57:01 2021 +0100
    
        A bunch of changes related to eta reduction
    
        This is a large collection of changes all relating to eta
        reduction, originally triggered by #18993, but there followed
        a long saga.
    
        Specifics:
    
    ...lots of lines omitted...
    
        Other incidental changes
    
        * Fix a fairly long-standing outright bug in the ApplyToVal case of
          GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the
          tail of 'dmds' in the recursive call, which meant the demands were All
          Wrong.  I have no idea why this has not caused problems before now.
    ```
    
    Note this "Fix a fairly longstanding outright bug".   This is the specific fix
    ```
    @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds
             --              let a = ...arg...
             --              in [...hole...] a
             -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable
    -    do  { let (dmd:_) = dmds   -- Never fails
    -        ; (floats1, cont') <- mkDupableContWithDmds env dmds cont
    +    do  { let (dmd:cont_dmds) = dmds   -- Never fails
    +        ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont
             ; let env' = env `setInScopeFromF` floats1
             ; (_, se', arg') <- simplArg env' dup se arg
             ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg'
    ```
    Ticket #23184 is a report of the bug that this diff fixes.
    
    - - - - -
    62d25071 by mangoiv at 2023-04-01T04:20:01-04:00
    [feat] make ($) representation polymorphic
    - this change was approved by the CLC in [1] following a CLC proposal [2]
    - make ($) representation polymorphic (adjust the type signature)
    - change ($) implementation to allow additional polymorphism
    - adjust the haddock of ($) to reflect these changes
    - add additional documentation to document these changes
    - add changelog entry
    - adjust tests (move now succeeding tests and adjust stdout of some
      tests)
    
    [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854
    [2] https://github.com/haskell/core-libraries-committee/issues/132
    
    - - - - -
    77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00
    User Guide: update copyright year: 2020->2023
    
    - - - - -
    3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00
    driver: Unit State Data.Map -> GHC.Unique.UniqMap
    
    In pursuit of #22426. The driver and unit state are major contributors.
    
    This commit also bumps the haddock submodule to reflect the API changes in
    UniqMap.
    
    -------------------------
    Metric Decrease:
        MultiComponentModules
        MultiComponentModulesRecomp
        T10421
        T10547
        T12150
        T12234
        T12425
        T13035
        T16875
        T18140
        T18304
        T18698a
        T18698b
        T18923
        T20049
        T5837
        T6048
        T9198
    -------------------------
    
    - - - - -
    a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00
    Add structured error messages for GHC.Tc.TyCl
    
    Tracking ticket: #20117
    
    MR: !10183
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00
    JS: Linker: use saturated JExpr
    
    Follow on to MR!10142 in pursuit of #22736
    
    - - - - -
    3da69346 by sheaf at 2023-04-01T18:28:37-04:00
    Improve haddocks of template-haskell Con datatype
    
    This adds a bit more information, in particular about the lists of
    constructors in the GadtC and RecGadtC cases.
    
    - - - - -
    3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00
    TH: revert changes to GadtC & RecGadtC
    
    Commit 3f374399 included a breaking-change to the template-haskell
    library when it made the GadtC and RecGadtC constructors take non-empty
    lists of names. As this has the potential to break many users' packages,
    we decided to revert these changes for now.
    
    - - - - -
    f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00
    Rework documentation for data Char
    
    - - - - -
    43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00
    cmm: implement parsing of MO_AtomicRMW from hand-written CMM files
    
    Fixes #23206
    
    - - - - -
    ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00
    ghc-heap: remove wrong Addr# coercion (#23181)
    
    Conversion from Addr# to I# isn't correct with the JS backend.
    
    - - - - -
    2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00
    hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1
    
    Also fixes the ./generate_bootstrap_plans script which was recently
    broken
    
    We can hopefully drop the 9.2 plans soon but they still work so kept
    them around for now.
    
    - - - - -
    c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00
    ci: Add job to test 9.6 bootstrapping
    
    - - - - -
    53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00
    hadrian: Improve option parsing
    
    Several options in Hadrian had their argument marked as optional
    (`OptArg`), but if the argument wasn't there they were just giving an
    error. It's more idiomatic to mark the argument as required instead;
    the code uses less Maybes, the parser can enforce that the argument
    is present, --help gives better output.
    
    - - - - -
    a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00
    JS: fix issues with FD api support
    
    - Add missing implementations for fcntl_read/write/lock
    - Fix fdGetMode
    
    These were found while implementing TH in !9779. These functions must be
    used somehow by the external interpreter code.
    
    - - - - -
    8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00
    Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage
    
    I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType
    module into a proper TcRnMessage.
    Instead, these TcRnMessage messages were introduced:
    
    TcRnDataKindsError
    TcRnUnusedQuantifiedTypeVar
    TcRnIllegalKindSignature
    TcRnUnexpectedPatSigType
    TcRnSectionPrecedenceError
    TcRnPrecedenceParsingError
    TcRnIllegalKind
    TcRnNegativeNumTypeLiteral
    TcRnUnexpectedKindVar
    TcRnBindMultipleVariables
    TcRnBindVarAlreadyInScope
    
    - - - - -
    220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00
    Fixes around unsafeCoerce#
    
    1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul
    in 74ad75e87317, `unsafeCoerce#` is no longer defined there.
    I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module.
    
    2. The documentation of `unsafeCoerce#` stated that you should not
    cast a function to an algebraic type, even if you later cast it back
    before applying it. But ghci was doing that type of cast, as can be seen
    with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any
    following the documentation.
    
    - - - - -
    9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00
    Add a few more memcpy-ish primops
    
    * copyMutableByteArrayNonOverlapping#
    * copyAddrToAddr#
    * copyAddrToAddrNonOverlapping#
    * setAddrRange#
    
    The implementations of copyBytes, moveBytes, and fillBytes
    in base:Foreign.Marshal.Utils now use these new primops,
    which can cause us to work a bit harder generating code for them,
    resulting in the metric increase in T21839c observed by CI on
    some architectures.  But in exchange, we get better code!
    
    Metric Increase:
        T21839c
    
    - - - - -
    f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00
    StgToCmm: Upgrade -fcheck-prim-bounds behavior
    
    Fixes #21054. Additionally, we can now check for range overlap
    when generating Cmm for primops that use memcpy internally.
    
    - - - - -
    cd00e321 by sheaf at 2023-04-04T01:04:50-04:00
    Relax assertion in varToRecFieldOcc
    
    When using Template Haskell, it is possible to re-parent a field OccName
    belonging to one data constructor to another data constructor. The
    lsp-types package did this in order to "extend" a data constructor
    with additional fields.
    
    This ran into an assertion in 'varToRecFieldOcc'. This assertion
    can simply be relaxed, as the resulting splices are perfectly sound.
    
    Fixes #23220
    
    - - - - -
    eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00
    GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201)
    
    - - - - -
    071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00
    Make INLINE pragmas for pattern synonyms work with TH
    
    Previously, the code for converting `INLINE <name>` pragmas from TH splices
    used `vNameN`, which assumed that `<name>` must live in the variable namespace.
    Pattern synonyms, on the other hand, live in the constructor namespace. I've
    fixed the issue by switching to `vcNameN` instead, which works for both the
    variable and constructor namespaces.
    
    Fixes #23203.
    
    - - - - -
    7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00
    Fix unification with oversaturated type families
    
    unify_ty was incorrectly saying that F x y ~ T x are surely apart,
    where F x y is an oversaturated type family and T x is a tyconapp.
    As a result, the simplifier dropped a live case alternative (#23134).
    
    - - - - -
    c165f079 by sheaf at 2023-04-04T17:13:40-04:00
    Add testcase for #23192
    
    This issue around solving of constraints arising from superclass
    expansion using other constraints also borned from superclass expansion
    was the topic of commit aed1974e. That commit made sure we don't emit
    a "redundant constraint" warning in a situation in which removing the
    constraint would cause errors.
    
    Fixes #23192
    
    - - - - -
    d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00
    nonmoving: Disable slop-zeroing
    
    As noted in #23170, the nonmoving GC can race with a mutator zeroing the
    slop of an updated thunk (in much the same way that two mutators would
    race). Consequently, we must disable slop-zeroing when the nonmoving GC
    is in use.
    
    Closes #23170
    
    - - - - -
    04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00
    Fix reverse flag for -Wunsupported-llvm-version
    - - - - -
    0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00
    Add release note for GHC.Unicode refactor in base-4.18.
    
    Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in
    base-4.18 and add proper release date.
    
    - - - - -
    cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00
    Improve documentation for ($) (#22963)
    
    - - - - -
    5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00
    Remove trailing whitespace from ($) commentary
    
    - - - - -
    b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00
    Adjust wording wrt representation polymorphism of ($)
    - - - - -
    6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00
    Add structured error messages for GHC.Tc.TyCl.Utils
    
    Tracking ticket: #20117
    
    MR: !10251
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00
    Renamer: don't call addUsedGRE on an exact Name
    
    When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc,
    we could end up calling addUsedGRE on an exact Name, which would then
    lead to a panic in the bestImport function: it would be incapable of
    processing a GRE which is not local but also not brought into scope
    by any imports (as it is referred to by its unique instead).
    
    Fixes #23240
    
    - - - - -
    bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00
    Add support for -debug in the testsuite
    
    Confusingly, GhcDebugged referred to GhcDebugAssertions.
    
    - - - - -
    b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00
    Add missing cases in -Di prettyprinter
    
    Fixes #23142
    
    - - - - -
    6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00
    compiler: make WasmCodeGenM an instance of MonadUnique
    
    - - - - -
    05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00
    compiler: apply cmm node-splitting for wasm backend
    
    This patch applies cmm node-splitting for wasm32 NCG, which is
    required when handling irreducible CFGs. Fixes #23237.
    
    - - - - -
    f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00
    Set base 'maintainer' field to CLC
    
    - - - - -
    ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00
    Clarify a couple of Notes about 'nospec'
    
    - - - - -
    ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00
    Allow generation of TTH syntax with TH
    
    In other words allow generation of typed splices and brackets with
    Untyped Template Haskell.
    
    That is useful in cases where a library is build with TTH in mind,
    but we still want to generate some auxiliary declarations,
    where TTH cannot help us, but untyped TH can.
    Such example is e.g. `staged-sop` which works with TTH,
    but we would like to derive `Generic` declarations with TH.
    
    An alternative approach is to use `unsafeCodeCoerce`, but then the
    derived `Generic` instances would be type-checked only at use sites,
    i.e. much later. Also `-ddump-splices` output is quite ugly:
    user-written instances would use TTH brackets, not `unsafeCodeCoerce`.
    
    This commit doesn't allow generating of untyped template splices
    and brackets with untyped TH, as I don't know why one would want to do
    that (instead of merging the splices, e.g.)
    
    - - - - -
    690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00
    Add regression test for #23229
    
    - - - - -
    59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00
    Add quotRem rules (#22152)
    
      case quotRemInt# x y of
         (# q, _ #) -> body
      ====>
       case quotInt# x y of
         q -> body
    
      case quotRemInt# x y of
         (# _, r #) -> body
      ====>
       case remInt# x y of
         r -> body
    
    - - - - -
    4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00
    Add quot folding rule (#22152)
    
       (x / l1) / l2
       l1 and l2 /= 0
       l1*l2 doesn't overflow
       ==> x / (l1 * l2)
    
    - - - - -
    1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00
    Make Int64/Word64 division ok for speculation too.
    
    Only when the divisor is definitely non-zero.
    
    - - - - -
    8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00
    Make WordQuotRem2Op ok-for-speculation too
    
    - - - - -
    27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00
    Base/JS: GHC.JS.Foreign.Callback module (issue 23126)
    
    * Add the Callback module for "exporting" Haskell functions
    to be available to plain JavaScript code
    
    * Fix some primitives defined in GHC.JS.Prim
    
    * Add a JavaScript section to the user guide with instructions
    on how to use the JavaScript FFI, building up to using Callbacks
    to interact with the browser
    
    * Add tests for the JavaScript FFI and Callbacks
    
    - - - - -
    a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00
    rts: improve memory ordering and add some comments in the StablePtr implementation
    
    - - - - -
    d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00
    docs: Generate docs/index.html with version number
    
    * Generate docs/index.html to include the version of the ghc library
    
    * This also fixes the packageVersions interpolations which were
      - Missing an interpolation for `LIBRARY_ghc_VERSION`
      - Double quoting the version so that "9.7" was being inserted.
    
    Fixes #23121
    
    - - - - -
    d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00
    Stop if type constructors have kind errors
    
    Otherwise we get knock-on errors, such as #23252.
    
    This makes GHC fail a bit sooner, and I have not attempted to add
    recovery code, to add a fake TyCon place of the erroneous one,
    in an attempt to get more type errors in one pass.  We could
    do that (perhaps) if there was a call for it.
    
    - - - - -
    2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
    Major refactor in the handling of equality constraints
    
    This MR substantially refactors the way in which the constraint
    solver deals with equality constraints.  The big thing is:
    
    * Intead of a pipeline in which we /first/ canonicalise and /then/
      interact (the latter including performing unification) the two steps
      are more closely integreated into one.  That avoids the current
      rather indirect communication between the two steps.
    
    The proximate cause for this refactoring is fixing #22194, which involve
    solving   [W] alpha[2] ~ Maybe (F beta[4])
    by doing this:
              alpha[2] := Maybe delta[2]
              [W] delta[2] ~ F beta[4]
    That is, we don't promote beta[4]!  This is very like introducing a cycle
    breaker, and was very awkward to do before, but now it is all nice.
    See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and
    Note [Family applications in canonical constraints].
    
    The big change is this:
    
    * Several canonicalisation checks (occurs-check, cycle-breaking,
      checking for concreteness) are combined into one new function:
         GHC.Tc.Utils.Unify.checkTyEqRhs
    
      This function is controlled by `TyEqFlags`, which says what to do
      for foralls, type families etc.
    
    * `canEqCanLHSFinish` now sees if unification is possible, and if so,
      actually does it: see `canEqCanLHSFinish_try_unification`.
    
    There are loads of smaller changes:
    
    * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a
      cheap-and-cheerful version of `checkTyEqRhs`, called
      `simpleUnifyCheck`.  If `simpleUnifyCheck` succeeds, it can unify,
      otherwise it defers by emitting a constraint. This is simpler than
      before.
    
    * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`.
      Especially the nasty stuff involving `swap_for_occurs` and
      `canEqTyVarFunEq`.  Much nicer now.  See
          Note [Orienting TyVarLHS/TyFamLHS]
          Note [Orienting TyFamLHS/TyFamLHS]
    
    * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the
      problems that can be discovered by `checkTyEqRhs`.
    
    * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to
      to accept both cases in #22194 rather than rejecting both.
    
    Yet smaller:
    
    * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`)
      to reduce the need for synonym expansion when checking concreteness.
      Use it in `isConcreteType`.
    
    * Renamed `isConcrete` to `isConcreteType`
    
    * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient
      way to find if a particular type variable is used injectively than
      finding all the injective variables.  It is called in
      `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a
      lot.
    
    * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the
      constraint solver.
    
    Fixes #22194, #23199
    
    Compile times decrease by an average of 0.1%; but there is a 7.4%
    drop in compiler allocation on T15703.
    
    Metric Decrease:
        T15703
    
    - - - - -
    99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
    Add some documentation about redundant constraints
    
    - - - - -
    3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
    Improve partial signatures
    
    This MR fixes #23223. The changes are in two places:
    
    * GHC.Tc.Bind.checkMonomorphismRestriction
      See the new `Note [When the MR applies]`
      We now no longer stupidly attempt to apply the MR when the user
      specifies a context, e.g.   f :: Eq a => _ -> _
    
    * GHC.Tc.Solver.decideQuantification
      See rewritten `Note [Constraints in partial type signatures]`
    
    Fixing this bug apparently breaks three tests:
    
    * partial-sigs/should_compile/T11192
    * partial-sigs/should_fail/Defaulting1MROff
    * partial-sigs/should_fail/T11122
    
    However they are all symptoms of #23232, so I'm marking them as
    expect_broken(23232).
    
    I feel happy about this MR. Nice.
    
    - - - - -
    23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
    Make approximateWC a bit cleverer
    
    This MR fixes #23224: making approximateWC more clever
    
    See the long `Note [ApproximateWC]` in GHC.Tc.Solver
    
    All this is delicate and ad-hoc -- but it /has/ to be: we are
    talking about inferring a type for a binding in the presence of
    GADTs, type families and whatnot: known difficult territory.
    We just try as hard as we can.
    
    - - - - -
    2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00
    docs: Update template-haskell docs to use Code Q a rather than Q (TExp a)
    
    Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a
    rather than Q (TExp a). The documentation in the `template-haskell`
    library wasn't updated to reflect this change.
    
    Fixes #23148
    
    - - - - -
    0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00
    Show an error when we cannot default a concrete tyvar
    
    Fixes #23153
    
    - - - - -
    bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00
    Handle ConcreteTvs in inferResultToType
    
    inferResultToType was discarding the ir_frr information, which meant
    some metavariables ended up being MetaTvs instead of ConcreteTvs.
    
    This function now creates new ConcreteTvs as necessary, instead of
    always creating MetaTvs.
    
    Fixes #23154
    
    - - - - -
    3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00
    Transfer DFunId_ness onto specialised bindings
    
    Whether a binding is a DFunId or not has consequences for the `-fdicts-strict`
    flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does
    not apply because the constraint solver can create recursive groups of dictionaries.
    
    In #22549 this was fixed for the "normal" case, see
    Note [Do not strictify the argument dictionaries of a dfun].
    However the loop still existed if the DFunId was being specialised.
    
    The problem was that the specialiser would specialise a DFunId and
    turn it into a VanillaId and so the demand analyser didn't know to
    apply special treatment to the binding anymore and the whole recursive
    group was optimised to bottom.
    
    The solution is to transfer over the DFunId-ness of the binding in the specialiser so
    that the demand analyser knows not to apply the `-fstrict-dicts`.
    
    Fixes #22549
    
    - - - - -
    a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00
    Add import lists to few GHC.Driver.Session imports
    
    Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261.
    There are a lot of GHC.Driver.Session which only use DynFlags,
    but not the parsing code.
    
    - - - - -
    51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00
    Account for special GHC.Prim import in warnUnusedPackages
    
    The GHC.Prim import is treated quite specially primarily because there
    isn't an interface file for GHC.Prim. Therefore we record separately in
    the ModSummary if it's imported or not so we don't go looking for it.
    
    This logic hasn't made it's way to `-Wunused-packages` so if you
    imported GHC.Prim then the warning would complain you didn't use
    `-package ghc-prim`.
    
    Fixes #23212
    
    - - - - -
    1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00
    Add regression test for #23199
    
    - - - - -
    0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00
    validDerivPred: Reject exotic constraints in IrredPreds
    
    This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as
    described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely,
    we should reject `IrredPred`s that are inferred from `deriving` clauses whose
    arguments contain other type constructors, as described in `(VD2) Reject exotic
    constraints` of that Note.  This has the nice property that `deriving` clauses
    whose inferred instance context mention `TypeError` will now emit the type
    error in the resulting error message, which better matches existing intuitions
    about how `TypeError` should work.
    
    While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]`
    was duplicated in a separate `Note [Exotic derived instance contexts]` in
    `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that
    there is a single authority on describing the conditions under which an
    inferred `deriving` constraint can be considered valid.
    
    This changes the behavior of `deriving` in a way that existing code might
    break, so I have made a mention of this in the GHC User's Guide. It seems very,
    very unlikely that much code is relying on this strange behavior, however, and
    even if there is, there is a clear, backwards-compatible migration path using
    `StandaloneDeriving`.
    
    Fixes #22696.
    
    - - - - -
    10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00
    Misc cleanup
    
    - Use dedicated list functions
    - Make cloneBndrs and cloneRecIdBndrs monadic
    - Fix invalid haddock comments in libraries/base
    
    - - - - -
    5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00
    Convert interface file loading errors into proper diagnostics
    
    This patch converts all the errors to do with loading interface files
    into proper structured diagnostics.
    
    * DriverMessage: Sometimes in the driver we attempt to load an interface
      file so we embed the IfaceMessage into the DriverMessage.
    * TcRnMessage: Most the time we are loading interface files during
      typechecking, so we embed the IfaceMessage
    
    This patch also removes the TcRnInterfaceLookupError constructor which
    is superceded by the IfaceMessage, which is now structured compared to
    just storing an SDoc before.
    
    - - - - -
    df1a5811 by sheaf at 2023-04-18T10:31:43-04:00
    Don't panic in ltPatersonSize
    
    The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it
    encountered a type family on the RHS, as usually these are not allowed
    (type families are not allowed on the RHS of class instances or of
    quantified constraints). However, it is possible to still encounter
    type families on the RHS after doing a bit of constraint solving, as
    seen in test case T23171. This could trigger the panic in the call to
    ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which
    is involved in avoiding loopy superclass constraints.
    
    This patch simply changes ltPatersonSize to return "I don't know, because
    there's a type family involved" in these cases.
    
    Fixes #23171
    
    - - - - -
    d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00
    JS: fix thread-related primops
    
    - - - - -
    7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00
    CI: Disable abi-test-nightly
    
    See #23269
    
    - - - - -
    ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00
    Testsuite: don't use obsolescent egrep (#22351)
    
    Recent egrep displays the following message, breaking golden tests:
    
      egrep: warning: egrep is obsolescent; using grep -E
    
    Switch to using "grep -E" instead
    
    - - - - -
    f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00
    hadrian: Pass haddock file arguments in a response file
    
    In !10119 CI was failing on windows because the command line was too
    long. We can mitigate this by passing the file arguments to haddock in a
    response file.
    
    We can't easily pass all the arguments in a response file because the
    `+RTS` arguments can't be placed in the response file.
    
    Fixes #23273
    
    - - - - -
    7012ec2f by tocic at 2023-04-20T11:01:42-04:00
    Fix doc typo in GHC.Read.readList
    
    - - - - -
    5c873124 by sheaf at 2023-04-20T18:33:34-04:00
    Implement -jsem: parallelism controlled by semaphores
    
    See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a
    complete description for the motivation for this feature.
    
    The `-jsem` option allows a build tool to pass a semaphore to GHC which
    GHC can use in order to control how much parallelism it requests.
    
    GHC itself acts as a client in the GHC jobserver protocol.
    
    ```
    GHC Jobserver Protocol
    ~~~~~~~~~~~~~~~~~~~~~~
    
    This proposal introduces the GHC Jobserver Protocol. This protocol allows
    a server to dynamically invoke many instances of a client process,
    while restricting all of those instances to use no more than <n> capabilities.
    This is achieved by coordination over a system semaphore (either a POSIX
    semaphore [6]_  in the case of Linux and Darwin, or a Win32 semaphore [7]_
    in the case of Windows platforms).
    
    There are two kinds of participants in the GHC Jobserver protocol:
    
    - The *jobserver* creates a system semaphore with a certain number of
      available tokens.
    
      Each time the jobserver wants to spawn a new jobclient subprocess, it **must**
      first acquire a single token from the semaphore, before spawning
      the subprocess. This token **must** be released once the subprocess terminates.
    
      Once work is finished, the jobserver **must** destroy the semaphore it created.
    
    - A *jobclient* is a subprocess spawned by the jobserver or another jobclient.
    
      Each jobclient starts with one available token (its *implicit token*,
      which was acquired by the parent which spawned it), and can request more
      tokens through the Jobserver Protocol by waiting on the semaphore.
    
      Each time a jobclient wants to spawn a new jobclient subprocess, it **must**
      pass on a single token to the child jobclient. This token can either be the
      jobclient's implicit token, or another token which the jobclient acquired
      from the semaphore.
    
      Each jobclient **must** release exactly as many tokens as it has acquired from
      the semaphore (this does not include the implicit tokens).
    ```
    
    Build tools such as cabal act as jobservers in the protocol and are
    responsibile for correctly creating, cleaning up and managing the
    semaphore.
    
    Adds a new submodule (semaphore-compat) for managing and interacting
    with semaphores in a cross-platform way.
    
    Fixes #19349
    
    - - - - -
    52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00
    rts: Initialize Array# header in listThreads#
    
    Previously the implementation of listThreads# failed to initialize the
    header of the created array, leading to various nastiness.
    
    Fixes #23071
    
    - - - - -
    1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00
    testsuite: Add test for #23071
    
    - - - - -
    dae514f9 by tocic at 2023-04-21T13:31:21-04:00
    Fix doc typos in libraries/base/GHC
    
    - - - - -
    113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00
    Testsuite: replace some js_broken/js_skip predicates with req_c
    
    Using req_c is more precise.
    
    - - - - -
    038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00
    Minor doc fixes
    
    - Add docs/index.html to .gitignore.
      It is created by ./hadrian/build docs, and it was the only file
      in Hadrian's templateRules not present in .gitignore.
    - Mention that MultiWayIf supports non-boolean guards
    - Remove documentation of optdll - removed in 2007, 763daed95
    - Fix markdown syntax
    
    - - - - -
    e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00
    User's guide: DeepSubsumption is implied by Haskell{98,2010}
    
    - - - - -
    499a1c20 by PHO at 2023-04-23T13:39:32-04:00
    Implement executablePath for Solaris and make getBaseDir less platform-dependent
    
    Use base-4.17 executablePath when possible, and fall back on
    getExecutablePath when it's not available. The sole reason why getBaseDir
    had #ifdef's was apparently that getExecutablePath wasn't reliable, and we
    could reduce the number of CPP conditionals by making use of
    executablePath instead.
    
    Also export executablePath on js_HOST_ARCH.
    
    - - - - -
    97a6f7bc by tocic at 2023-04-23T13:40:08-04:00
    Fix doc typos in libraries/base
    
    - - - - -
    787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00
    testsuite/T20137: Avoid impl.-defined behavior
    
    Previously we would cast pointers to uint64_t. However, implementations
    are allowed to either zero- or sign-extend such casts. Instead cast to
    uintptr_t to avoid this.
    
    Fixes #23247.
    
    - - - - -
    87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00
    rts: always build 64-bit atomic ops
    
    This patch does a few things:
    
    - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit
      platforms
    - Remove legacy "64bit" cabal flag of rts package
    - Fix hs_xchg64 function prototype for 32-bit platforms
    - Fix AtomicFetch test for wasm32
    
    - - - - -
    2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00
    compiler: don't install signal handlers when the host platform doesn't have signals
    
    Previously, large parts of GHC API will transitively invoke
    withSignalHandlers, which doesn't work on host platforms without
    signal functionality at all (e.g. wasm32-wasi). By making
    withSignalHandlers a no-op on those platforms, we can make more parts
    of GHC API work out of the box when signals aren't supported.
    
    - - - - -
    1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00
    hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC
    
    - - - - -
    1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00
    Add since pragma to Data.Functor.unzip
    
    - - - - -
    0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00
    More informative errors for bad imports (#21826)
    
    - - - - -
    ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00
    JS/base: provide implementation for mkdir (issue 22374)
    
    - - - - -
    8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00
    JS: Fix h$base_access implementation (issue 22576)
    
    - - - - -
    74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00
    Give more guarntees about ImplicitParams (#23289)
    
    - Added new section in the GHC user's guide that legends behavior of
    nested implicit parameter bindings in these two cases:
    
      let ?f = 1 in let ?f = 2 in ?f
    
    and
    
      data T where MkT :: (?f :: Int) => T
    
      f :: T -> T -> Int
      f MkT MkT = ?f
    
    - Added new test case to examine this behavior.
    
    - - - - -
    c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00
    DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208)
    
    In #23208 we observed that the demand signature of a binder occuring in a RULE
    wasn't unleashed, leading to a transitively used binder being discarded as
    absent. The solution was to use the same code path that we already use for
    handling exported bindings.
    
    See the changes to `Note [Absence analysis for stable unfoldings and RULES]`
    for more details.
    
    I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a
    `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our
    existing framework. As a result, I had to touch quite a few places in the code.
    
    This refactoring exposed a few small bugs around correct handling of bottoming
    demand environments. As a result, some strictness signatures now mention uniques
    that weren't there before which caused test output changes to T13143, T19969 and
    T22112. But these tests compared whole -ddump-simpl listings which is a very
    fragile thing to begin with. I changed what exactly they test for based on the
    symptoms in the corresponding issues.
    
    There is a single regression in T18894 because we are more conservative around
    stable unfoldings now. Unfortunately it is not easily fixed; let's wait until
    there is a concrete motivation before invest more time.
    
    Fixes #23208.
    
    - - - - -
    77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00
    Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364)
    
    Carry the actual type of an expression through the PreStgRhs and into GenStgRhs
    for use in later stages. Currently this is used in the JavaScript backend to fix
    some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2,
    T13822, T14749.
    
    - - - - -
    052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00
    EPA: Use ExplicitBraces only in HsModule
    
    !9018 brought in exact print annotations in LayoutInfo for open and
    close braces at the top level.
    
    But it retained them in the HsModule annotations too.
    
    Remove the originals, so exact printing uses LayoutInfo
    
    - - - - -
    d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00
    ci: update ci.sh to actually run the entire testsuite for wasm backend
    
    For the time being, we still need to use in-tree mode and can't test
    the bindist yet.
    
    - - - - -
    533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00
    ci: additional wasm32 manual jobs in validate pipelines
    
    This patch enables bignum native & unregisterised wasm32 jobs as
    manual jobs in validate pipelines, which can be useful to prevent
    breakage when working on wasm32 related patches.
    
    - - - - -
    b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: fix cross prefix stripping
    
    This patch fixes cross prefix stripping in the testsuite driver. The
    normalization logic used to only handle prefixes of the triple form
    <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens
    in the prefix tuple, so the cross prefix stripping logic would work
    when ghc is configured with something like --target=wasm32-wasi.
    
    - - - - -
    6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: include target exe extension in heap profile filenames
    
    This patch fixes hp2ps related framework failures when testing the
    wasm backend by including target exe extension in heap profile
    filenames.
    
    - - - - -
    e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: exclude ghci ways if no rts linker is present
    
    This patch implements logic to automatically exclude ghci ways when
    there is no rts linker. It's way better than having to annotate
    individual test cases.
    
    - - - - -
    791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: fix permission bits in copy_files
    
    When the testsuite driver copy files instead of symlinking them, it
    should also copy the permission bits, otherwise there'll be permission
    denied errors. Also, enforce file copying when testing wasm32, since
    wasmtime doesn't handle host symlinks quite well
    (https://github.com/bytecodealliance/wasmtime/issues/6227).
    
    - - - - -
    aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: add the req_ghc_with_threaded_rts predicate
    
    This patch adds the req_ghc_with_threaded_rts predicate to the
    testsuite to assert the platform has threaded RTS, and mark some tests
    as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a
    config field instead of a global variable.
    
    - - - - -
    ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: add the req_process predicate
    
    This patch adds the req_process predicate to the testsuite to assert
    the platform has a process model, also marking tests that involve
    spawning processes as req_process. Also bumps hpc & process submodule.
    
    - - - - -
    cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: add the req_host_target_ghc predicate
    
    This patch adds the req_host_target_ghc predicate to the testsuite to
    assert the ghc compiler being tested can compile both host/target
    code. When testing cross GHCs this is not supported yet, but it may
    change in the future.
    
    - - - - -
    b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: add missing annotations for some tests
    
    This patch adds missing annotations (req_th, req_dynamic_lib_support,
    req_rts_linker) to some tests. They were discovered when testing
    wasm32, though it's better to be explicit about what features they
    require, rather than simply adding when(arch('wasm32'), skip).
    
    - - - - -
    bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: wasm32-specific fixes
    
    This patch includes all wasm32-specific testsuite fixes.
    
    - - - - -
    4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00
    JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304)
    
    - - - - -
    57277662 by sheaf at 2023-04-29T20:23:06+02:00
    Add the Unsatisfiable class
    
    This commit implements GHC proposal #433, adding the Unsatisfiable
    class to the GHC.TypeError module. This provides an alternative to
    TypeError for which error reporting is more predictable: we report it
    when we are reporting unsolved Wanted constraints.
    
    Fixes #14983 #16249 #16906 #18310 #20835
    
    - - - - -
    00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00
    Add structured error messages for GHC.Rename.Names
    
    Tracking ticket: #20115
    
    MR: !10336
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00
    Add sized primitive literal syntax
    
    Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining
    unboxed numeric literals such as `0xFF#Word8 :: Word8#`.
    
    Implements GHC proposal 0451:
    https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst
    
    Fixes #21422.
    
    Bumps haddock submodule.
    
    Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io>
    
    - - - - -
    f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00
    Document instances of Double
    
    - - - - -
    1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00
    Bump Cabal submodule (#22356)
    
    - - - - -
    4eafb52a by sheaf at 2023-05-03T20:18:16-04:00
    Don't forget to check the parent in an export list
    
    Commit 3f374399 introduced a bug which caused us to forget to include
    the parent of an export item of the form T(..) (that is, IEThingAll)
    when checking for duplicate exports.
    
    Fixes #23318
    
    - - - - -
    8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00
    Fix unlit path in cross bindists
    
    - - - - -
    8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00
    hadrian: Flavour: Change args -> extraArgs
    
    Previously in a flavour definition you could override all the flags
    which were passed to GHC. This causes issues when needed to compute a
    package hash because we need to know what these extra arguments are
    going to be before computing the hash. The solution is to modify flavour
    so that the arguments you pass here are just extra ones rather than all
    the arguments that you need to compile something.
    
    This makes things work more like how cabal.project files work when you
    give extra arguments to a package and also means that flavour
    transformers correctly affect the hash.
    
    - - - - -
    3fdb18f8 by romes at 2023-05-04T14:58:14-04:00
    Hardwire a better unit-id for ghc
    
    Previously, the unit-id of ghc-the-library was fixed as `ghc`.
    This was done primarily because the compiler must know the unit-id of
    some packages (including ghc) a-priori to define wired-in names.
    
    However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed
    to `ghc` might result in subtle bugs when different ghc's interact.
    
    A good example of this is having GHC_A load a plugin compiled by GHC_B,
    where GHC_A and GHC_B are linked to ghc-libraries that are ABI
    incompatible. Without a distinction between the unit-id of the ghc library
    GHC_A is linked against and the ghc library the plugin it is loading was
    compiled against, we can't check compatibility.
    
    This patch gives a slightly better unit-id to ghc (ghc-version) by
    (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0)
    (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id.
        (2.1) `GHC.Settings.Config` is generated by Hadrian
        (2.2) and also by cabal through `compiler/Setup.hs`
    This unit-id definition is imported by `GHC.Unit.Types` and used to
    set the wired-in unit-id of "ghc", which was previously fixed to "ghc"
    
    The commits following this one will improve the unit-id with a
    cabal-style package hash and check compatibility when loading plugins.
    
    Note that we also ensure that ghc's unit key matches unit id both when
    hadrian or cabal builds ghc, and in this way we no longer need to add
    `ghc` to the WiringMap.
    
    - - - - -
    6689c9c6 by romes at 2023-05-04T14:58:14-04:00
    Validate compatibility of ghcs when loading plugins
    
    Ensure, when loading plugins, that the ghc the plugin depends on is the
    ghc loading the plugin -- otherwise fail to load the plugin.
    
    Progress towards #20742.
    
    - - - - -
    db4be339 by romes at 2023-05-04T14:58:14-04:00
    Add hashes to unit-ids created by hadrian
    
    This commit adds support for computing an inputs hash for packages
    compiled by hadrian. The result is that ABI incompatible packages should
    be given different hashes and therefore be distinct in a cabal store.
    
    Hashing is enabled by the `--flag`, and is off by default as the hash
    contains a hash of the source files. We enable it when we produce
    release builds so that the artifacts we distribute have the right unit
    ids.
    
    - - - - -
    944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00
    Use hash-unit-ids in release jobs
    
    Includes fix upload_ghc_libs glob
    
    - - - - -
    116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00
    JS: fix bounds checking (Issue 23123)
    
    * For ByteArray-based bounds-checking, the JavaScript backend must use the
    `len` field, instead of the inbuild JavaScript `length` field.
    
    * Range-based operations must also check both the start and end of the range
    for bounds
    
    * All indicies are valid for ranges of size zero, since they are essentially no-ops
    
    * For cases of ByteArray accesses (e.g. read as Int), the end index is
    (i * sizeof(type) + sizeof(type) - 1), while the previous implementation
    uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3)
    
    * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike
    the previous point), but now check both start and end indicies
    
    * Byte array copies now check if the arrays are the same by identity and
    then if the ranges overlap.
    
    - - - - -
    2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00
    Fix remaining issues with bound checking (#23123)
    
    While fixing these I've also changed the way we store addresses into
    ByteArray#. Addr# are composed of two parts: a JavaScript array and an
    offset (32-bit number).
    
    Suppose we want to store an Addr# in a ByteArray# foo at offset i.
    Before this patch, we were storing both fields as a tuple in the "arr"
    array field:
    
      foo.arr[i] = [addr_arr, addr_offset];
    
    Now we only store the array part in the "arr" field and the offset
    directly in the array:
    
      foo.dv.setInt32(i, addr_offset):
      foo.arr[i] = addr_arr;
    
    It avoids wasting space for the tuple.
    
    - - - - -
    98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00
    JavaScript: Correct arguments to h$appendToHsStringA
    
    fixes #23278
    
    - - - - -
    ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00
    base/encoding: add an allocations performance test (#22946)
    
    - - - - -
    e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00
    linear types: Don't add external names to the usage env
    
    This has no observable effect, but avoids storing useless data.
    
    - - - - -
    b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00
    Improved documentation for the Data.OldList.nub function
    
    There was recomentation to use map head . group . sort instead of nub
    function, but containers library has more suitable and efficient
    analogue
    
    - - - - -
    e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00
    Fix type variable substitution in gen_Newtype_fam_insts
    
    Previously, `gen_Newtype_fam_insts` was substituting the type variable binders
    of a type family instance using `substTyVars`, which failed to take type
    variable dependencies into account. There is similar code in
    `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly,
    so this patch:
    
    1. Factors out this code into a top-level `substATBndrs` function, and
    2. Uses `substATBndrs` in `gen_Newtype_fam_insts`.
    
    Fixes #23329.
    
    - - - - -
    275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00
    Add structured error messages for GHC.Rename.Utils
    
    Tracking ticket: #20115
    
    MR: !10350
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00
    Use TemplateHaskellQuotes in TH.Syntax to construct Names
    
    - - - - -
    a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00
    driver: Use hooks from plugin_hsc_env
    
    This fixes a bug in oneshot mode where hooks modified in a plugin
    wouldn't be used in oneshot mode because we neglected to use the right
    hsc_env. This was observed by @csabahruska.
    
    - - - - -
    18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00
    Rework plugin initialisation points
    
    In general this patch pushes plugin initialisation points to earlier in
    the pipeline. As plugins can modify the `HscEnv`, it's imperative that
    the plugins are initialised as soon as possible and used thereafter.
    
    For example, there are some new tests which modify hsc_logger and other
    hooks which failed to fire before (and now do)
    
    One consequence of this change is that the error for specifying the
    usage of a HPT plugin from the command line has changed, because it's
    now attempted to be loaded at initialisation rather than causing a
    cyclic module import.
    
    Closes #21279
    
    Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00
    docs: Add Note [Timing of plugin initialization]
    
    - - - - -
    e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00
    Incrementally update ghcup metadata in ghc/ghcup-metadata
    
    This job paves the way for distributing nightly builds
    
    * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the
      metadata on the "updates" branch.
    * Each night this metadata is downloaded and the nightly builds are
      appended to the end of the metadata.
    * The update job only runs on the scheduled nightly pipeline, not just
      when NIGHTLY=1.
    
    Things which are not done yet
    
    * Modify the retention policy for nightly jobs
    * Think about building release flavour compilers to distribute nightly.
    
    Fixes #23334
    
    - - - - -
    8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00
    docs: Remove mentions of ArrayArray# from unlifted FFI section
    
    Fixes #23277
    
    - - - - -
    994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00
    Add structured error messages for GHC.Rename.Module
    
    Tracking ticket: #20115
    
    MR: !10361
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    Only addresses the single warning missing from the previous MR.
    
    - - - - -
    3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00
    rts: Fix data-race in hs_init_ghc
    
    As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic
    increment/decrement on the RTS's initialization count. This may go wrong
    in a multithreaded program which initializes the runtime multiple times.
    
    Closes #22756.
    
    - - - - -
    78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00
    Add structured error messages for GHC.IfaceToCore
    
    Tracking ticket: #20114
    
    MR: !10390
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00
    Fix up rules for ghcup-metadata-nightly-push
    
    - - - - -
    b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00
    testsuite: Add test for atomicSwapIORef
    
    - - - - -
    81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00
    compiler: Implement atomicSwapIORef with xchg
    
    As requested by @treeowl in CLC#139.
    
    - - - - -
    6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00
    Make atomicSwapMutVar# an inline primop
    
    - - - - -
    64064cfe by doyougnu at 2023-05-09T18:40:01-04:00
    JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt
    
    This MR changes some simple optimizations and is a first step in re-architecting
    the JS backend pipeline to add the optimizer. In particular it:
    
    - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module
    - adds module `GHC.JS.Optimizer`
    - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations
    - hooks the optimizer into code gen
    - adds FuncStat and ForStat constructors to the backend.
    
    Working Ticket:
    - #22736
    
    Related MRs:
    - MR !10142
    - MR !10000
    
    -------------------------
    Metric Decrease:
        CoOpt_Read
        ManyAlternatives
        PmSeriesS
        PmSeriesT
        PmSeriesV
        T10421
        T12707
        T13253
        T13253-spj
        T15164
        T17516
        T18140
        T18282
        T18698a
        T18698b
        T18923
        T1969
        T19695
        T20049
        T3064
        T5321FD
        T5321Fun
        T783
        T9198
        T9233
        T9630
    -------------------------
    
    - - - - -
    6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00
    Add a regression test for #21050
    
    - - - - -
    b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00
    nonmoving: Account for mutator allocations in bytes_allocated
    
    Previously we failed to account direct mutator allocations into the
    nonmoving heap against the mutator's allocation limit and
    `cap->total_allocated`. This only manifests during CAF evaluation (since
    we allocate the CAF's blackhole directly into the nonmoving heap).
    
    Fixes #23312.
    
    - - - - -
    0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00
    Adjust AArch64 stackFrameHeaderSize
    
    The prologue of each stack frame are the saved LR and FP registers, 8
    byte each. I.e. the size of the stack frame header is 2 * 8 byte.
    
    - - - - -
    7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00
    Make `(&)` representation polymorphic in the return type
    
    - - - - -
    b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00
    ghc-prim: Generalize keepAlive#/touch# in state token type
    
    Closes #23163.
    
    - - - - -
    1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00
    Bump hsc2hs submodule
    
    Fixes #22981.
    
    - - - - -
    0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00
    base: Export GHC.Conc.Sync.fromThreadId
    
    Closes #22706.
    
    - - - - -
    29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00
    Build vanilla alpine bindists
    
    We currently attempt to build and distribute fully static alpine
    bindists (ones which could be used on any linux platform) but most
    people who use the alpine bindists want to use alpine to build their own
    static applications (for which a fully static bindist is not necessary).
    We should build and distribute these bindists for these users whilst the
    fully-static bindist is still unusable.
    
    Fixes #23349
    
    - - - - -
    40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00
    Look both ways when looking for quantified equalities
    
    When looking up (t1 ~# t2) in the quantified constraints,
    check both orientations.  Forgetting this led to #23333.
    
    - - - - -
    c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00
    Move "target has RTS linker" out of settings
    
    We move the "target has RTS linker" information out of configure into a
    predicate in GHC, and remove this option from the settings file where it
    is unnecessary -- it's information statically known from the platform.
    
    Note that previously we would consider `powerpc`s and `s390x`s other
    than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker,
    but the RTS linker supports neither platform.
    
    Closes #23361
    
    - - - - -
    bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00
    Add a test for #17284
    
    Since !10123 we now reject this program.
    
    - - - - -
    630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00
    Document unlawfulness of instance Num Fixed
    
    Fixes #22712
    
    - - - - -
    87eebf98 by sheaf at 2023-05-11T11:55:22-04:00
    Add fused multiply-add instructions
    
    This patch adds eight new primops that fuse a multiplication and an
    addition or subtraction:
    
      - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#`
    
    fmadd x y z is x * y + z, computed with a single rounding step.
    
    This patch implements code generation for these primops in the following
    backends:
    
      - X86, AArch64 and PowerPC NCG,
      - LLVM
      - C
    
    WASM uses the C implementation. The primops are unsupported in the
    JavaScript backend.
    
    The following constant folding rules are also provided:
    
      - compute a * b + c when a, b, c are all literals,
      - x * y + 0 ==> x * y,
      - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x.
    
    NB: the constant folding rules incorrectly handle signed zero.
    This is a known limitation with GHC's floating-point constant folding
    rules (#21227), which we hope to resolve in the future.
    
    - - - - -
    ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00
    Add a test for #21278
    
    - - - - -
    05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00
    rts: Refine memory retention behaviour to account for pinned/compacted objects
    
    When using the copying collector there is still a lot of data which
    isn't copied (such as pinned, compacted, large objects etc). The logic
    to decide how much memory to retain didn't take into account that these
    wouldn't be copied. Therefore we pessimistically retained 2* the amount
    of memory for these blocks even though they wouldn't be copied by the
    collector.
    
    The solution is to split up the heap into two parts, the parts which
    will be copied and the parts which won't be copied. Then the appropiate
    factor is applied to each part individually (2 * for copying and 1.2 *
    for not copying).
    
    The T23221 test demonstrates this improvement with a program which first
    allocates many unpinned ByteArray# followed by many pinned ByteArray#
    and observes the difference in the ultimate memory baseline between the
    two.
    
    There are some charts on #23221.
    
    Fixes #23221
    
    - - - - -
    1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00
    hadrian: fix no_dynamic_libs flavour transformer
    
    This patch fixes the no_dynamic_libs flavour transformer and make
    fully_static reuse it. Previously building with no_dynamic_libs fails
    since ghc program is still dynamic and transitively brings in dyn ways
    of rts which are produced by no rules.
    
    - - - - -
    0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00
    JS: refactor jsSaturate to return a saturated JStat (#23328)
    
    - - - - -
    a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00
    Doc: Fix out-of-sync using-optimisation page
    
    - Make explicit that default flag values correspond to their -O0 value.
    - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction,
      -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper.
    
    - - - - -
    c176ad18 by sheaf at 2023-05-12T06:10:57-04:00
    Don't panic in mkNewTyConRhs
    
    This function could come across invalid newtype constructors, as we
    only perform validity checking of newtypes once we are outside the
    knot-tied typechecking loop.
    This patch changes this function to fake up a stub type in the case of
    an invalid newtype, instead of panicking.
    
    This patch also changes "checkNewDataCon" so that it reports as many
    errors as possible at once.
    
    Fixes #23308
    
    - - - - -
    ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00
    Allow Core optimizations when interpreting bytecode
    
    Tracking ticket: #23056
    
    MR: !10399
    
    This adds the flag `-funoptimized-core-for-interpreter`, permitting use
    of the `-O` flag to enable optimizations when compiling with the
    interpreter backend, like in ghci.
    
    - - - - -
    c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00
    hadrian: Fix mention of non-existent removeFiles function
    
    Previously Hadrian's bindist Makefile referred to a `removeFiles`
    function that was previously defined by the `make` build system. Since
    the `make` build system is no longer around, this function is now
    undefined. Naturally, make being make, this appears to be silently
    ignored instead of producing an error.
    
    Fix this by rewriting it to `rm -f`.
    
    Closes #23373.
    
    - - - - -
    eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00
    Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog
    
    - - - - -
    aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00
    rts: Ensure non-moving gc is not running when pausing
    
    - - - - -
    5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00
    rts: Teach listAllBlocks about nonmoving heap
    
    List all blocks on the non-moving heap.
    
    Resolves #22627
    
    - - - - -
    d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00
    Fix coercion optimisation for SelCo (#23362)
    
    setNominalRole_maybe is supposed to output a nominal coercion.
    In the SelCo case, it was not updating the stored role to Nominal,
    causing #23362.
    
    - - - - -
    59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00
    hadrian: Fix linker script flag for MergeObjects builder
    
    This fixes what appears to have been a typo in !9530. The `-t` flag just
    enables tracing on all versions of `ld` I’ve looked at, while `-T` is
    used to specify a linker script. It seems that this worked anyway for
    some reason on some `ld` implementations (perhaps because they
    automatically detect linker scripts), but the missing `-T` argument
    causes `gold` to complain.
    
    - - - - -
    4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00
    Less coercion optimization for non-newtype axioms
    
    See Note [Push transitivity inside newtype axioms only] for an explanation
    of the change here.  This change substantially improves the performance of
    coercion optimization for programs involving transitive type family reductions.
    
    -------------------------
    Metric Decrease:
        CoOpt_Singletons
        LargeRecord
        T12227
        T12545
        T13386
        T15703
        T5030
        T8095
    -------------------------
    
    - - - - -
    dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00
    Move checkAxInstCo to GHC.Core.Lint
    
    A consequence of the previous change is that checkAxInstCo is no longer
    called during coercion optimization, so it can be moved back where it belongs.
    
    Also includes some edits to Note [Conflict checking with AxiomInstCo] as
    suggested by @simonpj.
    
    - - - - -
    8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00
    Use the eager unifier in the constraint solver
    
    This patch continues the refactoring of the constraint solver
    described in #23070.
    
    The Big Deal in this patch is to call the regular, eager unifier from the
    constraint solver, when we want to create new equalities. This
    replaces the existing, unifyWanted which amounted to
    yet-another-unifier, so it reduces duplication of a rather subtle
    piece of technology. See
    
      * Note [The eager unifier] in GHC.Tc.Utils.Unify
      * GHC.Tc.Solver.Monad.wrapUnifierTcS
    
    I did lots of other refactoring along the way
    
    * I simplified the treatment of right hand sides that contain CoercionHoles.
      Now, a constraint that contains a hetero-kind CoercionHole is non-canonical,
      and cannot be used for rewriting or unification alike.  This required me
      to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on
      effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in
      GHC.Tc.Solver.Equality.
    
    * I refactored the StopOrContinue type to add StartAgain, so that after a
      fundep improvement (for example) we can simply start the pipeline again.
    
    * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions.
      With Richard I concluded that they are never needed.
    
    * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in
      GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities.
    
    Quite a few error messages change, I think always for the better.
    
    Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836
    
    Metric Decrease:
        T17836
        T18223
    
    - - - - -
    5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00
    Cleanup of dynflags override in export renaming
    The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean.
    
    - - - - -
    d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00
    Use a uniform return convention in bytecode for unary results
    
    fixes #22958
    
    - - - - -
    8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00
    Add more instances for Compose: Enum, Bounded, Num, Real, Integral
    
    See https://github.com/haskell/core-libraries-committee/issues/160 for discussion
    
    - - - - -
    902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00
    Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever
    
    As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the
    table, failing to unpack arguments that are perfectly unpackable.
    
    The fix is pretty easy; see Note [Recursive unboxing]
    
    - - - - -
    a5451438 by sheaf at 2023-05-13T14:59:13-04:00
    Fix bad multiplicity role in tyConAppFunCo_maybe
    
    The function tyConAppFunCo_maybe produces a multiplicity coercion
    for the multiplicity argument of the function arrow, except that
    it could be at the wrong role if asked to produce a representational
    coercion. We fix this by using the 'funRole' function, which computes
    the right roles for arguments to the function arrow TyCon.
    
    Fixes #23386
    
    - - - - -
    5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00
    Turn "ambiguous import" error into a panic
    
    This error should never occur, as a lookup of a type or data constructor
    should never be ambiguous. This is because a single module cannot export
    multiple Names with the same OccName, as per item (1) of
    Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export.
    
    This code path was intended to handle duplicate record fields, but the
    rest of the code had since been refactored to handle those in a
    different way.
    
    We also remove the AmbiguousImport constructor of IELookupError, as
    it is no longer used.
    
    Fixes #23302
    
    - - - - -
    e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00
    Unbreak some tests with latest GNU grep, which now warns about stray '\'.
    
    Confusingly, the testsuite mangled the error to say "stray /".
    
    We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex.
    
    Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default).
    
    - - - - -
    5ae81842 by sheaf at 2023-05-15T14:49:17-04:00
    Improve "ambiguous occurrence" error messages
    
    This error was sometimes a bit confusing, especially when data families
    were involved. This commit improves the general presentation of the
    "ambiguous occurrence" error, and adds a bit of extra context in the
    case of data families.
    
    Fixes #23301
    
    - - - - -
    2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00
    Fix GHCJS OS platform (fix #23346)
    
    - - - - -
    86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00
    Split DynFlags structure into own module
    
    This will allow to make command line parsing to depend on
    diagnostic system (which depends on dynflags)
    
    - - - - -
    fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00
    Replace the implementation of CodeBuffers with unboxed types
    
    - - - - -
    21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00
    Use unboxed codebuffers in base
    
    Metric Decrease:
        encodingAllocations
    
    - - - - -
    18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Weak pointer cleanups
    
    Various stylistic cleanups. No functional changes.
    
    - - - - -
    c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Don't force debug output to stderr
    
    Previously `+RTS -Dw -l` would emit debug output to the eventlog while
    `+RTS -l -Dw` would emit it to stderr. This was because the parser for
    `-D` would unconditionally override the debug output target. Now we
    instead only do so if no it is currently `TRACE_NONE`.
    
    - - - - -
    a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Forcibly flush eventlog on barf
    
    Previously we would attempt to flush via `endEventLogging` which can
    easily deadlock, e.g., if `barf` fails during GC.
    
    Using `flushEventLog` directly may result in slightly less consistent
    eventlog output (since we don't take all capabilities before flushing)
    but avoids deadlocking.
    
    - - - - -
    73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Assert that pointers aren't cleared by -DZ
    
    This turns many segmentation faults into much easier-to-debug assertion
    failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns
    produced by `+RTS -DZ` clearing as invalid pointers.
    
    This is a bit ad-hoc but this is the debug runtime.
    
    - - - - -
    37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Introduce printGlobalThreads
    
    - - - - -
    451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Don't sanity-check StgTSO.global_link
    
    See Note [Avoid dangling global_link pointers].
    
    Fixes #19146.
    
    - - - - -
    d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00
    Split up tyThingToIfaceDecl from GHC.Iface.Make
    
    This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl
    from GHC.Iface.Make into GHC.Iface.Decl.
    This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl,
    transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad.
    
    - - - - -
    4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00
    Migrate errors to diagnostics in GHC.Tc.Module
    
    This commit migrates the errors in GHC.Tc.Module to use the new
    diagnostic infrastructure.
    
    It required a significant overhaul of the compatibility checks between
    an hs-boot or signature module and its implementation; we now use
    a Writer monad to accumulate errors; see the BootMismatch datatype
    in GHC.Tc.Errors.Types, with its panoply of subtypes.
    For the sake of readability, several local functions inside the
    'checkBootTyCon' function were split off into top-level functions.
    
    We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file"
    datatype, as this mirrors the logic in several other places where we
    want to treat hs-boot and hsig files in a similar fashion.
    
    This commit also refactors the Backpack checks for type synonyms
    implementing abstract data, to correctly reject implementations that
    contain qualified or quantified types (this fixes #23342 and #23344).
    
    - - - - -
    d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00
    configure: Drop unused AC_PROG_CPP
    
    In configure, we were calling `AC_PROG_CPP` but never making use of the
    $CPP variable it sets or reads.
    
    The issue is $CPP will show up in the --help output of configure,
    falsely advertising a configuration option that does nothing.
    
    The reason we don't use the $CPP variable is because HS_CPP_CMD is
    expected to be a single command (without flags), but AC_PROG_CPP, when
    CPP is unset, will set said variable to something like `/usr/bin/gcc -E`.
    Instead, we configure HS_CPP_CMD through $CC.
    
    - - - - -
    a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00
    rts: fix --disable-large-address-space
    
    This patch moves
    ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from
    Storage.h to HeapAlloc.h. When --disable-large-address-space is passed
    to configure, the code in HeapAlloc.h makes use of these two macros.
    Fixes #23385.
    
    - - - - -
    bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00
    Add -Wmissing-role-annotations
    
    Implements #22702
    
    - - - - -
    41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00
    base: Export {get,set}ExceptionFinalizer from System.Mem.Weak
    
    As proposed in CLC Proposal #126 [1].
    
    [1]: https://github.com/haskell/core-libraries-committee/issues/126
    
    - - - - -
    67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00
    base: Introduce printToHandleFinalizerExceptionHandler
    
    - - - - -
    5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00
    JS: Implement h$clock_gettime in the JavaScript RTS (#23360)
    
    - - - - -
    90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00
    compiler: Use compact representation for SourceText
    
    SourceText is serialized along with INLINE pragmas into interface files. Many of
    these SourceTexts are identical, for example "{-# INLINE#". When deserialized,
    each such SourceText was previously expanded out into a [Char], which is highly
    wasteful of memory, and each such instance of the text would allocate an
    independent list with its contents as deserializing breaks any sharing that might
    have existed.
    
    Instead, we use a `FastString` to represent these, so that each instance unique
    text will be interned and stored in a memory efficient manner.
    
    - - - - -
    b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00
    compiler: Use compact representation/FastStrings for `SourceNote`s
    
    `SourceNote`s should not be stored as [Char] as this is highly wasteful
    and in certain scenarios can be highly duplicated.
    
    Metric Decrease:
      hard_hole_fits
    
    - - - - -
    6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00
    compiler: Use compact representation for UsageFile (#22744)
    
    Use FastString to store filepaths in interface files, as this data is
    highly redundant so we want to share all instances of filepaths in the
    compiler session.
    
    - - - - -
    47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00
    testsuite: add test for T22744
    
    This test checks for #22744 by compiling 100 modules which each have
    a dependency on 1000 distinct external files.
    
    Previously, when loading these interfaces from disk, each individual instance
    of a filepath in the interface will would be allocated as an individual object
    on the heap, meaning we have heap objects for 100*1000 files, when there are
    only 1000 distinct files we care about.
    
    This test checks this by first compiling the module normally, then measuring
    the peak memory usage in a no-op recompile, as the recompilation checking will
    force the allocation of all these filepaths.
    
    - - - - -
    0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00
    users guide: Add glossary
    
    Currently this merely explains the meaning of "technology preview" in
    the context of released features.
    
    - - - - -
    0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00
    Update glossary.rst
    - - - - -
    3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00
    Use glossary directive
    - - - - -
    2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00
    JS: fix getpid (fix #23399)
    
    - - - - -
    5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00
    Use setSrcSpan rather than setLclEnv in solveForAll
    
    In subsequent MRs (#23409) we want to remove the TcLclEnv argument from
    a CtLoc. This MR prepares us for that by removing the one place where
    the entire TcLclEnv is used, by using it more precisely to just set the
    contexts source location.
    
    Fixes #23390
    
    - - - - -
    385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00
    Update the users guide paragraph on -O in GHCi
    
    In relation to #23056
    
    - - - - -
    87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Add test for #13660
    
    - - - - -
    9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Move implementation of GHC.Foreign to GHC.Internal
    
    - - - - -
    174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Introduce {new,with}CStringLen0
    
    These are useful helpers for implementing the internal-NUL code unit
    check needed to fix #13660.
    
    - - - - -
    a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Clean up documentation
    
    - - - - -
    b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Ensure that FilePaths don't contain NULs
    
    POSIX filepaths may not contain the NUL octet but previously we did not
    reject such paths. This could be exploited by untrusted input to cause
    discrepancies between various `FilePath` queries and the opened
    filename. For instance, `readFile "hello.so\x00.txt"` would open the
    file `"hello.so"` yet `takeFileExtension` would return `".txt"`.
    
    The same argument applies to Windows FilePaths
    
    Fixes #13660.
    
    - - - - -
    7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00
    Allow the demand analyser to unpack tuple and equality dictionaries
    
    Addresses #23398. The demand analyser usually does not unpack class
    dictionaries: see Note [Do not unbox class dictionaries] in
    GHC.Core.Opt.DmdAnal.
    
    This patch makes an exception for tuple dictionaries and equality
    dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of
    the above Note.
    
    Compile times fall by 0.1% for some reason (max 0.7% on T18698b).
    
    - - - - -
    b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00
    Use a simpler and more portable construct in ld.ldd check
    
    printf '%q\n' is a bash extension which led to incorrectly
    failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh
    
    - - - - -
    dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00
    Update the warning about interpreter optimizations
    
    to reflect that they're not incompatible anymore, but guarded by a flag
    
    - - - - -
    4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00
    Remove stray dump flags in GHC.Rename.Names
    
    - - - - -
    4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00
    Make Warn = Located DriverMessage
    
    This change makes command line argument parsing use diagnostic
    framework for producing warnings.
    
    - - - - -
    525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00
    Type inference for data family newtype instances
    
    This patch addresses #23408, a tricky case with data family
    newtype instances.  Consider
    
      type family TF a where TF Char = Bool
      data family DF a
      newtype instance DF Bool = MkDF Int
    
    and [W] Int ~R# DF (TF a), with a Given (a ~# Char).   We must fully
    rewrite the Wanted so the tpye family can fire; that wasn't happening.
    
    - - - - -
    c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00
    testsuite: fix predicate on rdynamic test
    
    Test rdynamic requires dynamic linking support, which is
    orthogonal to RTS linker support. Change the predicate accordingly.
    
    Fixes #23316
    
    - - - - -
    735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00
    docs: Use ghc-ticket directive where appropiate in users guide
    
    Using the directive automatically formats and links the ticket
    appropiately.
    
    - - - - -
    b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00
    NCG: remove useless .align directive (#20758)
    
    - - - - -
    15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00
    Add test for #23156
    
    This program had exponential typechecking time in GHC 9.4 and 9.6
    
    - - - - -
    2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00
    Revert "Change hostSupportsRPaths to report False on OpenBSD"
    
    This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2.
    
    - - - - -
    882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00
    Disable T17414 on OpenBSD
    
    Like on other systems it's not guaranteed that there's sufficient
    space in /tmp to write 2G out.
    
    - - - - -
    9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00
    Bring back getExecutablePath to getBaseDir on OpenBSD
    
    Fix #18173
    
    - - - - -
    9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00
    Add an error origin for impedance matching (#23427)
    
    - - - - -
    33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00
    testsuite: Add tests for #23146
    
    Both lifted and unlifted variants.
    
    - - - - -
    76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00
    codeGen: Fix some Haddocks
    
    - - - - -
    33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00
    codeGen: Give proper LFInfo to datacon wrappers
    
    As noted in `Note [Conveying CAF-info and LFInfo between modules]`,
    when importing a binding from another module we must ensure that it gets
    the appropriate `LambdaFormInfo` if it is in WHNF to ensure that
    references to it are tagged correctly.
    
    However, the implementation responsible for doing this,
    `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and
    not wrappers. This lead to the crash of this program in #23146:
    
        module B where
    
        type NP :: [UnliftedType] -> UnliftedType
        data NP xs where
          UNil :: NP '[]
    
        module A where
        import B
    
        fieldsSam :: NP xs -> NP xs -> Bool
        fieldsSam UNil UNil = True
    
        x = fieldsSam UNil UNil
    
    Due to its GADT nature, `UNil` produces a trivial wrapper
    
        $WUNil :: NP '[]
        $WUNil = UNil @'[] @~(<co:1>)
    
    which is referenced in the RHS of `A.x`. Due to the above-mentioned bug
    in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were
    not tagged. This is problematic as `fieldsSam` expected its arguments to
    be tagged as they are unlifted.
    
    The fix is straightforward: extend the logic in `mkLFImported` to cover
    (nullary) datacon wrappers as well as workers. This is safe because we
    know that the wrapper of a nullary datacon will be in WHNF, even if it
    includes equalities evidence (since such equalities are not runtime
    relevant).
    
    Thanks to @MangoIV for the great ticket and @alt-romes for his
    minimization and help debugging.
    
    Fixes #23146.
    
    - - - - -
    2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    codeGen: Fix LFInfo of imported datacon wrappers
    
    As noted in #23231 and in the previous commit, we were failing to give a
    an LFInfo of LFCon to a nullary datacon wrapper from another module,
    failing to properly tag pointers which ultimately led to the
    segmentation fault in #23146.
    
    On top of the previous commit which now considers wrappers where we
    previously only considered workers, we change the order of the guards so
    that we check for the arity of the binding before we check whether it is
    a constructor. This allows us to
    (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was
    nullary, which we previously would fail to do
    (2) Remove the `isNullaryRepDataCon` predicate:
        (a) which was previously wrong, since it considered wrappers whose
        workers had zero-width arguments to be non-nullary and would fail to
        give `LFCon` to them
        (b) is now unnecessary, since arity == 0 guarantees
            - that the worker takes no arguments at all
            - and the wrapper takes no arguments and its RHS must be an
              application of the worker to zero-width-args only.
            - we lint these two items with an assertion that the datacon
              `hasNoNonZeroWidthArgs`
    
    We also update `isTagged` to use the new logic in determining the
    LFInfos of imported Ids.
    
    The creation of LFInfos for imported Ids and this detail are explained
    in Note [The LFInfo of Imported Ids].
    
    Note that before the patch to those issues we would already consider these
    nullary wrappers to have `LFCon` lambda form info; but failed to re-construct
    that information in `mkLFImported`
    
    Closes #23231, #23146
    
    (I've additionally batched some fixes to documentation I found while
    investigating this issue)
    
    - - - - -
    0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Make LFInfos for DataCons on construction
    
    As a result of the discussion in !10165, we decided to amend the
    previous commit which fixed the logic of `mkLFImported` with regard to
    datacon workers and wrappers.
    
    Instead of having the logic for the LFInfo of datacons be in
    `mkLFImported`, we now construct an LFInfo for all data constructors on
    GHC.Types.Id.Make and store it in the `lfInfo` field.
    
    See the new Note [LFInfo of DataCon workers and wrappers] and
    ammendments to Note [The LFInfo of Imported Ids]
    
    - - - - -
    12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Update Note [Core letrec invariant]
    
    Authored by @simonpj
    
    - - - - -
    e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Rename mkLFImported to importedIdLFInfo
    
    The `mkLFImported` sounded too much like a constructor of sorts, when
    really it got the `LFInfo` of an imported Id from its `lf_info` field
    when this existed, and otherwise returned a conservative estimate of
    that imported Id's LFInfo. This in contrast to functions such as
    `mkLFReEntrant` which really are about constructing an `LFInfo`.
    
    - - - - -
    e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Enforce invariant on typePrimRepArgs in the types
    
    As part of the documentation effort in !10165 I came across this
    invariant on 'typePrimRepArgs' which is easily expressed at the
    type-level through a NonEmpty list.
    
    It allowed us to remove one panic.
    
    - - - - -
    b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Merge outdated Note [Data con representation] into Note [Data constructor representation]
    
    Introduce new Note [Constructor applications in STG] to better support
    the merge, and reference it from the relevant bits in the STG syntax.
    
    - - - - -
    e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00
    Add the SolverStage monad
    
    This refactoring makes a substantial improvement in the
    structure of the type-checker's constraint solver: #23070.
    
    Specifically:
    
    * Introduced the SolverStage monad.   See GHC.Tc.Solver.Monad
      Note [The SolverStage monad]
    
    * Make each solver pipeline (equalities, dictionaries, irreds etc)
      deal with updating the inert set, as a separate SolverStage.  There
      is sometimes special stuff to do, and it means that each full
      pipeline can have type SolverStage Void, indicating that they never
      return anything.
    
    * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage.  Much nicer.
    
    * Combined the remnants of GHC.Tc.Solver.Canonical and
      GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve.
      (Interact and Canonical are removed.)
    
    * Gave the same treatment to dictionary and irred constraints
      as I have already done for equality constraints:
        * New types (akin to EqCt): IrredCt and DictCt
        * Ct is now just a simple sum type
              data Ct
                = CDictCan      DictCt
                | CIrredCan     IrredCt
                | CEqCan        EqCt
                | CQuantCan     QCInst
                | CNonCanonical CtEvidence
        * inert_dicts can now have the better type DictMap DictCt, instead of
          DictMap Ct; and similarly inert_irreds.
    
    * Significantly simplified the treatment of implicit parameters.
      Previously we had a number of special cases
        * interactGivenIP, an entire function
        * special case in maybeKickOut
        * special case in findDict, when looking up dictionaries
      But actually it's simpler than that. When adding a new Given, implicit
      parameter constraint to the InertSet, we just need to kick out any
      existing inert constraints that mention that implicit parameter.
    
      The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with
      its auxiliary GHC.Core.Predicate.mentionsIP.
    
      See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict.
    
    * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit.
      See Note [Fast path for tcCheckHoleFit].  This is a big win in some cases:
      test hard_hole_fits gets nearly 40% faster (at compile time).
    
    * Add a new fast-path for solving /boxed/ equality constraints
      (t1 ~ t2).  See Note [Solving equality classes] in GHC.Tc.Solver.Dict.
      This makes a big difference too: test T17836 compiles 40% faster.
    
    * Implement the PermissivePlan of #23413, which concerns what happens with
      insoluble Givens.   Our previous treatment was wildly inconsistent as that
      ticket pointed out.
    
      A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply
      don't run the ambiguity check at all if -XAllowAmbiguousTypes is on.
    
    Smaller points:
    
    * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for
      insoluble /occurs/ checks, broaden in to all insouluble constraints.
      Just generally better. See Note [Insoluble mis-match] in that module.
    
    As noted above, compile time perf gets better.  Here are the changes
    over 0.5% on Fedora.  (The figures are slightly larger on Windows for
    some reason.)
    
    Metrics: compile_time/bytes allocated
    -------------------------------------
                    LargeRecord(normal)   -0.9%
    MultiLayerModulesTH_OneShot(normal)   +0.5%
                         T11822(normal)   -0.6%
                         T12227(normal)   -1.8% GOOD
                         T12545(normal)   -0.5%
                         T13035(normal)   -0.6%
                         T15703(normal)   -1.4% GOOD
                         T16875(normal)   -0.5%
                         T17836(normal)  -40.7% GOOD
                        T17836b(normal)  -12.3% GOOD
                        T17977b(normal)   -0.5%
                          T5837(normal)   -1.1%
                          T8095(normal)   -2.7% GOOD
                          T9020(optasm)   -1.1%
                 hard_hole_fits(normal)  -37.0% GOOD
    
                              geo. mean   -1.3%
                              minimum    -40.7%
                              maximum     +0.5%
    
    Metric Decrease:
        T12227
        T15703
        T17836
        T17836b
        T8095
        hard_hole_fits
        LargeRecord
        T9198
        T13035
    
    - - - - -
    6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00
    Avoid an assertion failure in abstractFloats
    
    The function GHC.Core.Opt.Simplify.Utils.abstractFloats
    was carelessly calling lookupIdSubst_maybe on a CoVar;
    but a precondition of the latter is being given an Id.
    
    In fact it's harmless to call it on a CoVar, but still, the
    precondition on lookupIdSubst_maybe makes sense, so I added
    a test for CoVars.
    
    This avoids a crash in a DEBUG compiler, but otherwise has
    no effect. Fixes #23426.
    
    - - - - -
    838aaf4b by hainq at 2023-05-24T12:41:19-04:00
    Migrate errors in GHC.Tc.Validity
    
    This patch migrates the error messages in GHC.Tc.Validity to use
    the new diagnostic infrastructure.
    
    It adds the constructors:
    
      - TcRnSimplifiableConstraint
      - TcRnArityMismatch
      - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors
        and fundep coverage condition errors.
    
    - - - - -
    8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00
    linear lint: Add missing processing of DEFAULT
    
    In this correct program
    
    f :: a %1 -> a
    f x = case x of x { _DEFAULT -> x }
    
    after checking the alternative we weren't popping the case binder 'x'
    from the usage environment, which meant that the lambda-bound 'x'
    was counted twice: in the scrutinee and (incorrectly) in the alternative.
    In fact, we weren't checking the usage of 'x' at all.
    Now the code for handling _DEFAULT is similar to the one handling
    data constructors.
    
    Fixes #23025.
    
    - - - - -
    ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00
    Remove outdated "Don't check hs-boot type family instances too early" note
    
    This note was introduced in 25b70a29f623 which delayed performing some
    consistency checks for type families. However, the change was reverted
    later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not
    removed.
    
    I found it confusing when reading to code to try and work out what
    special behaviour there was for hs-boot files (when in-fact there isn't
    any).
    
    - - - - -
    44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00
    rts: Define ticky macro stubs
    
    These macros have long been undefined which has meant we were missing
    reporting these allocations in ticky profiles.
    
    The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was
    missing all the RTS calls to allocate, this leads to a the overall
    ALLOC_RTS_tot number to be severaly underreported.
    
    Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot
    counters which are useful to tracking stack allocations.
    
    Fixes #23421
    
    - - - - -
    b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00
    rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS
    
    This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes
    more sense to name it after that rather than the suffix NOCTR, whose
    meaning has been lost to the mists of time.
    
    - - - - -
    eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00
    users guide: A few small mark-up fixes
    
    - - - - -
    a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00
    configure: Fix support check for response files.
    
    In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument
    to printf, the writing of the arguments response file always failed.
    
    The fix is to pass the arguments after `--` so that they are treated
    positional arguments rather than flags to printf.
    
    Closes #23435
    
    - - - - -
    f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00
    [feat] add .direnv to the .gitignore file
    
    - - - - -
    36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00
    Add Data.List.unsnoc
    
    See https://github.com/haskell/core-libraries-committee/issues/165 for discussion
    
    - - - - -
    c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00
    Fix crash in backpack signature merging with -ddump-rn-trace
    
    In some cases, backpack signature merging could crash in addUsedGRE
    when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause
    unavailable interfaces to be loaded.
    This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE
    when -ddump-rn-trace is enabled.
    
    Fixes #23424
    
    Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>
    
    - - - - -
    5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00
    Add a regression test for #13981
    
    The panic was fixed by 6998772043a7f0b. Fixes #13981.
    
    - - - - -
    182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00
    Add a test for #23355
    
    It was fixed by !10061, so I'm adding it in the same group.
    
    - - - - -
    1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00
    Migrate errors in GHC.Rename.Splice GHC.Rename.Pat
    
    This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat
    to use the new diagnostic infrastructure.
    
    - - - - -
    56abe494 by sheaf at 2023-05-25T12:09:55+02:00
    Common up Template Haskell errors in TcRnMessage
    
    This commit commons up the various Template Haskell errors into a
    single constructor, TcRnTHError, of TcRnMessage.
    
    - - - - -
    a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00
    Enable ghci tests for unboxed tuples
    
    The tests were originally skipped because ghci used not to support
    unboxed tuples/sums.
    
    - - - - -
    dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00
    rts: Build ticky GHC with single-threaded RTS
    
    The threaded RTS allows you to use ticky profiling but only for the
    counters in the generated code. The counters used in the C portion of
    the RTS are disabled. Updating the counters is also racy using the
    threaded RTS which can lead to misleading or incorrect ticky results.
    
    Therefore we change the hadrian flavour to build using the
    single-threaded RTS (mainly in order to get accurate C code counter
    increments)
    
    Fixes #23430
    
    - - - - -
    fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00
    Propagate long-distance info in generated code
    
    When desugaring generated pattern matches, we skip pattern match checks.
    However, this ended up also discarding long-distance information, which
    might be needed for user-written sub-expressions.
    
    Example:
    
    ```haskell
    okay (GADT di) cd =
      let sr_field :: ()
          sr_field = case getFooBar di of { Foo -> () }
      in case cd of { SomeRec _ -> SomeRec sr_field }
    ```
    
    With sr_field a generated FunBind, we still want to propagate the outer
    long-distance information from the GADT pattern match into the checks
    for the user-written RHS of sr_field.
    
    Fixes #23445
    
    - - - - -
    f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00
    Introduce GHCiMessage to wrap GhcMessage
    
    By introducing a wrapped message type we can control how certain
    messages are printed in GHCi (to add extra information for example)
    
    - - - - -
    58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00
    Generalise UnknownDiagnostic to allow embedded diagnostics to access
    parent diagnostic options.
    
    * Split default diagnostic options from Diagnostic class into
      HasDefaultDiagnosticOpts class.
    * Generalise UnknownDiagnostic to allow embedded diagnostics to access
      options.
    
    The principle idea here is that when wrapping an error message (such as
    GHCMessage to make GHCiMessage) then we need to also be able to lift the
    configuration when overriding how messages are printed (see load' for an
    example).
    
    - - - - -
    b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00
    Allow API users to wrap error messages created during 'load'
    
    This allows API users to configure how messages are rendered when they
    are emitted from the load function. For an example see how
    'loadWithCache' is used in GHCi.
    
    - - - - -
    2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00
    Abstract cantFindError and turn Opt_BuildingCabal into a print-time option
    
    * cantFindError is abstracted so that the parts which mention specific
      things about ghc/ghci are parameters. The intention being that
      GHC/GHCi can specify the right values to put here but otherwise
      display the same error message.
    * The BuildingCabalPackage argument from GenericMissing is removed and
      turned into a print-time option. The reason for the error is not
      dependent on whether `-fbuilding-cabal-package` is passed, so we don't
      want to store that in the error message.
    
    - - - - -
    34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00
    error messages: Don't display ghci specific hints for missing packages
    
    Tickets like #22884 suggest that it is confusing that GHC used on the
    command line can suggest options which only work in GHCi.
    
    This ticket uses the error message infrastructure to override certain
    error messages which displayed GHCi specific information so that this
    information is only showed when using GHCi.
    
    The main annoyance is that we mostly want to display errors in the same
    way as before, but with some additional information. This means that the
    error rendering code has to be exported from the Iface/Errors/Ppr.hs
    module.
    
    I am unsure about whether the approach taken here is the best or most
    maintainable solution.
    
    Fixes #22884
    
    - - - - -
    05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Don't override existing metadata if version already exists.
    
    If a nightly pipeline runs twice for some reason for the same version
    then we really don't want to override an existing entry with new
    bindists. This could cause ABI compatability issues for users or break
    ghcup's caching logic.
    
    - - - - -
    fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Use proper API url for bindist download
    
    Previously we were using links from the web interface, but it's more
    robust and future-proof to use the documented links to the artifacts.
    
    https://docs.gitlab.com/ee/api/job_artifacts.html
    
    - - - - -
    5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Set Nightly and LatestNightly tags
    
    The latest nightly release needs the LatestNightly tag, and all other
    nightly releases need the Nightly tag. Therefore when the metadata is
    updated we need to replace all LatestNightly with Nightly.`
    
    - - - - -
    914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Download nightly metadata for correct date
    
    The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata
    with one metadata file per year. When we update the metadata we download
    and update the right file for the current year.
    
    - - - - -
    16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Download metadata and update for correct year
    
    something about pipeline date
    
    - - - - -
    14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Don't skip CI
    
    On a push we now have a CI job which updates gitlab pages with the
    metadata files.
    
    - - - - -
    1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00
    ghcup-metadata: Add --date flag to specify the release date
    
    The ghcup-metadata now has a viReleaseDay field which needs to be
    populated with the day of the release.
    
    - - - - -
    bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00
    ghcup-metadata: Add dlOutput field
    
    ghcup now requires us to add this field which specifies where it should
    download the bindist to. See
    https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more
    discussion.
    
    - - - - -
    2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00
    JS: Convert rendering to use HLine instead of SDoc (#22455)
    
    - - - - -
    abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00
    testsuite: add WasmControlFlow test
    
    This patch adds the WasmControlFlow test to test the wasm backend's
    relooper component.
    
    - - - - -
    07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00
    Factorize getLinkDeps
    
    Prepare reuse of getLinkDeps for TH implementation in the JS backend
    (cf #22261 and review of !9779).
    
    - - - - -
    fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00
    Change GHC.Driver.Session import to .DynFlags
    
    Also move targetPlatform selector
    
    Plenty of GHC needs just DynFlags.
    Even more can be made to use .DynFlags if more selectors is migrated.
    This is a low hanging fruit.
    
    - - - - -
    69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00
    EPA: Better fix for #22919
    
    The original fix for #22919 simply removed the ability to match up
    prior comments with the first declaration in the file.
    
    Restore it, but add a check that the comment is on a single line, by
    ensuring that it comes immediately prior to the next thing (comment or
    start of declaration), and that the token preceding it is not on the
    same line.
    
    closes #22919
    
    - - - - -
    0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00
    Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214)
    
    - - - - -
    b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00
    testsuite: Pass -kb16k -kc128k for performance tests
    
    Setting a larger stack chunk size gives a greater protection
    from stack thrashing (where the repeated overflow/underflow allocates a lot of
    stack chunks which sigificantly impact allocations). This
    stabilises some tests against differences cause by more things being
    pushed onto the stack.
    
    The performance tests are generally testing work done by the compiler,
    using allocation as a proxy, so removing/stabilising the allocations due
    to the stack gives us more stable tests which are also more sensitive
    to actual changes in compiler performance.
    
    The tests which increase are ones where we compile a lot of modules, and
    for each module we spawn a thread to compile the module in. Therefore
    increasing these numbers has a multiplying effect on these tests because
    there are many more stacks which we can increase in size.
    
    The most significant improvements though are cases such as T8095 which
    reduce significantly in allocations (30%). This isn't a performance
    improvement really but just helps stabilise the test against this
    threshold set by the defaults.
    
    Fixes #23439
    
    -------------------------
    Metric Decrease:
        InstanceMatching
        T14683
        T8095
        T9872b_defer
        T9872d
        T9961
        hie002
        T19695
        T3064
    Metric Increase:
        MultiLayerModules
        T13701
        T14697
    -------------------------
    
    - - - - -
    6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00
    Move via-C flags into GHC
    
    These were previously hardcoded in configure (with no option for
    overriding them) and simply passed onto ghc through the settings file.
    
    Since configure already guarantees gcc supports those flags, we simply
    move them into GHC.
    
    - - - - -
    981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00
    Allow CPR on unrestricted constructors
    
    Per the new `Note [Linting linearity]`, we want optimisations over
    trying to preserve linearity. This will allow CPR to handle `Ur`, in
    particular.
    
    - - - - -
    bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00
    Push coercions across multiplicity boundaries
    
    Per the new `Note [Linting linearity]`, we want optimisations over
    trying to preserve linearity. This will avoid preventing inlinings and
    reductions and make linear programs more efficient.
    
    - - - - -
    d56dd695 by sheaf at 2023-05-31T11:37:12-04:00
    Data.Bag: add INLINEABLE to polymorphic functions
    
    This commit allows polymorphic methods in GHC.Data.Bag to be
    specialised, avoiding having to pass explicit dictionaries when they
    are instantiated with e.g. a known monad.
    
    - - - - -
    5366cd35 by sheaf at 2023-05-31T11:37:12-04:00
    Split off TcBinderStack into its own module
    
    This commit splits off TcBinderStack into its own module,
    to avoid module cycles: we might want to refer to it without also
    pulling in the TcM monad.
    
    - - - - -
    09d4d307 by sheaf at 2023-05-31T11:37:12-04:00
    Split off TcRef into its own module
    
    This helps avoid pull in the full TcM monad when we just want access
    to mutable references in the typechecker. This facilitates later patches
    which introduce a slimmed down TcM monad for zonking.
    
    - - - - -
    88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00
    Introduce Codensity monad
    
    The Codensity monad is useful to write state-passing computations in
    continuation-passing style, e.g. to implement a State monad as
    continuation-passing style over a Reader monad.
    
    - - - - -
    f62d8195 by sheaf at 2023-05-31T11:37:12-04:00
    Restructure the zonker
    
    This commit splits up the zonker into a few separate components, described
    in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`.
    
    1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`,
         which has enough information for zonking types.
         This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`,
         which guarantees we don't throw an error while reporting an error.
    
    2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines
        two zonking monad transformers, `ZonkT` and `ZonkBndrT`.
        `ZonkT` is a reader monad transformer over `ZonkEnv`.
        `ZonkBndrT m` is the codensity monad over `ZonkT m`.
    
         `ZonkBndrT` is used for computations that accumulate binders
         in the `ZonkEnv`.
    
    3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use
        in the typechecker. It uses the `ZonkM` monad.
    
    4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`,
        which has been refactored to use `ZonkTcM = ZonkT TcM` and
        `ZonkBndrTcM = ZonkBndrT TcM`.
    
    Allocations slightly decrease on the whole due to using
    continuation-passing style instead of manual state passing of ZonkEnv
    in the final zonking to Type.
    
    -------------------------
    Metric Decrease:
        T4029
        T8095
        T14766
        T15304
        hard_hole_fits
        RecordUpdPerf
    Metric Increase:
        T10421
    -------------------------
    
    - - - - -
    70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00
    Update rdt-theme to latest upstream version
    
    Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444
    
    - - - - -
    f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Restructure IPE buffer layout
    
    Reference ticket #21766
    
    This commit restructures IPE buffer list entries to not contain
    references to their corresponding info tables. IPE buffer list nodes now
    point to two lists of equal length, one holding the list of info table
    pointers and one holding the corresponding entries for each info table.
    This will allow the entry data to be compressed without losing the
    references to the info tables.
    
    - - - - -
    5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Add IPE compression to configure
    
    Reference ticket #21766
    
    Adds an `--enable-ipe-data-compreesion` flag to the configure script
    which will check for libzstd and set the appropriate flags to allow for
    IPE data compression in the compiler
    
    - - - - -
    b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    IPE data compression
    
    Reference ticket #21766
    
    When IPE data compression is enabled, compress the emitted IPE buffer
    entries and decompress them in the RTS.
    
    - - - - -
    5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Fix libzstd detection in configure and RTS
    
    Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases
    and properly check that before IPE data decompression in the RTS. See
    ticket #21766.
    
    - - - - -
    69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Add note describing IPE data compression
    
    See ticket #21766
    
    - - - - -
    7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Fix byte order of IPE data, fix IPE tests
    
    Make sure byte order of written IPE buffer entries matches target.
    
    Make sure the IPE-related tests properly access the fields of IPE buffer
    entry nodes with the new IPE layout.
    
    This commit also introduces checks to avoid importing modules if IPE
    compression is not enabled.
    
    See ticket #21766.
    
    - - - - -
    0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Fix IPE data decompression buffer allocation
    
    Capacity of buffers allocated for decompressed IPE data was
    incorrect due to a misuse of the `ZSTD_findFrameCompressedSize`
    function. Fix by always storing decompressed size of IPE data in IPE
    buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine
    the size of the compressed data.
    
    See ticket #21766
    
    - - - - -
    a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Add optional dependencies to ./configure output
    
    Changes the configure script to indicate whether libnuma, libzstd, or
    libdw are being used as dependencies due to their optional features
    being enabled.
    
    - - - - -
    09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Add IPE-enabled builds to CI
    
    - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label
    - Introduces CI logic to enable IPE data compression
    - Enables uncompressed IPE data on debug CI job
    - Regenerates jobs.yaml
    
    MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the
    images repository is meant to ensure that the proper images have
    libzstd-dev installed.
    
    - - - - -
    3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Update user's guide and release notes, small fixes
    
    Add mention of IPE data compression to user's guide and the release
    notes for 9.8.1. Also note the impact compression has on binary size in
    both places.
    
    Change IpeBufferListNode compression check so only the value `1`
    indicates compression.
    
    See ticket #21766
    
    - - - - -
    41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Remove IPE enabled builds from CI
    
    We don't need to explicitly specify the +ipe transformer to test IPE data
    since there are tests which manually enable IPE information. This commit does
    leave zstd IPE data compression enabled on the debian CI jobs.
    
    - - - - -
    982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00
    Fix build with 9.2
    
    GHC.Tc.Zonk.Type uses an equality constraint.
    ghc.nix currently provides 9.2.
    
    - - - - -
    1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00
    Output Lint errors to stderr instead of stdout
    
    This is a continuation of 7b095b99, which fixed warnings but not errors.
    
    Refs #13342
    
    - - - - -
    8e81f140 by sheaf at 2023-06-01T10:56:51-04:00
    Refactor lookupExactOrOrig & friends
    
    This refactors the panoply of renamer lookup functions relating to
    lookupExactOrOrig to more graciously handle Exact and Orig names.
    
    In particular, we avoid the situation in which we would add Exact/Orig
    GREs to the tcg_used_gres field, which could cause a panic in bestImport
    like in #23240.
    
    Fixes #23428
    
    - - - - -
    5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00
    Use the one-shot trick for UM and RewriteM functors
    
    As described in Note [The one-shot state monad trick],
    we shouldn't use derived Functor instances for monads using
    one-shot. This was done for most of them, but UM and RewriteM
    were missed.
    
    - - - - -
    2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00
    Fix testsuite skipping Lint
    
    setTestOpts() is used to modify the test options for an entire .T file,
    rather than a single test.
    If there was a test using collect_compiler_stats, all of the tests
    in the same file had lint disabled.
    
    Fixes #21247
    
    - - - - -
    00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00
    Add testcases for already fixed #16432
    
    They were fixed by 40c7daed0.
    
    Fixes #16432
    
    - - - - -
    f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00
    cleanup: Remove unused field from SelfBoot
    
    It is no longer needed since Note [Extra dependencies from .hs-boot files]
    was deleted in 6998772043.
    
    I've also added tildes to Note headers, otherwise they're not detected
    by the linter.
    
    - - - - -
    82eacab6 by sheaf at 2023-06-02T09:08:01-04:00
    Delete GHC.Tc.Utils.Zonk
    
    This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType
    in commit f62d8195, but I forgot to delete the original module
    - - - - -
    4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00
    base: Add build-order import of GHC.Types in GHC.IO.Handle.Types
    
    For reasons similar to those described in Note [Depend on
    GHC.Num.Integer].
    
    Fixes #23411.
    
    - - - - -
    f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00
    JS: fix and enhance non-minimized code generation (#22455)
    
    Flag -ddisable-js-minimizer was producing invalid code. Fix that and
    also a few other things to generate nicer JS code for debugging.
    
    The added test checks that we don't regress when using the flag.
    
    - - - - -
    f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00
    [hadrian] Fix multiline synopsis rendering
    
    - - - - -
    b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00
    Elaborate on performance properties of Data.List.++
    
    - - - - -
    7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00
    Big TcLclEnv and CtLoc refactoring
    
    The overall goal of this refactoring is to reduce the dependency
    footprint of the parser and syntax tree. Good reasons include:
    
    - Better module graph parallelisability
    - Make it easier to migrate error messages without introducing module loops
    - Philosophically, there's not reason for the AST to depend on half the
      compiler.
    
    One of the key edges which added this dependency was
    
    > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv)
    
    As this in turn depending on TcM which depends on HscEnv and so on.
    
    Therefore the goal of this patch is to move `TcLclEnv` out of
    `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without
    incurring a huge dependency chain.
    
    The changes in this patch are:
    
    * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv
    * Create new smaller modules for the types used in TcLclEnv
      New Modules:
      - GHC.Tc.Types.ErrCtxt
      - GHC.Tc.Types.BasicTypes
      - GHC.Tc.Types.TH
      - GHC.Tc.Types.LclEnv
      - GHC.Tc.Types.CtLocEnv
      - GHC.Tc.Errors.Types.PromotionErr
    
      Removed Boot File:
      - {-# SOURCE #-} GHC.Tc.Types
    
    * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't
      participate in restoreLclEnv.
    
    * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in
      GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the
      location of the implication and constraint.
    
    By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no
    longer depend on the TcM monad and all that entails.
    
    Fixes #23389 #23409
    
    - - - - -
    3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00
    Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session
    
    This removes the usage of DynFlags from Tc.Utils.TcType  so that it no
    longer depends on GHC.Driver.Session. In general we don't want anything
    which is a dependency of Language.Haskell.Syntax to depend on
    GHC.Driver.Session and removing this edge gets us closer to that goal.
    
    - - - - -
    18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00
    Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn
    
    This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes
    Language.Haskell.Syntax end up depending on GHC.Driver.Session.
    
    - - - - -
    12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00
    Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session
    
    - - - - -
    eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00
    hole fit plugins: Split definition into own module
    
    The hole fit plugins are defined in terms of TcM, a type we want to
    avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own
    module we can remove this dependency. It also simplifies the necessary
    boot file.
    
    - - - - -
    9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00
    Move GHC.Core.Opt.CallerCC Types into separate module
    
    This allows `GHC.Driver.DynFlags` to depend on these types without
    depending on CoreM and hence the entire simplifier pipeline.
    
    We can also remove a hs-boot file with this change.
    
    - - - - -
    52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00
    Remove unecessary SOURCE import
    
    - - - - -
    698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00
    testsuite: Accept new output for CountDepsAst and CountDepsParser tests
    
    These are in a separate commit as the improvement to these tests is the
    cumulative effect of the previous set of patches rather than just the
    responsibility of the last one in the patchset.
    
    - - - - -
    58ccf02e by sheaf at 2023-06-05T16:00:47-04:00
    TTG: only allow VarBind at GhcTc
    
    The VarBind constructor of HsBind is only used at the GhcTc stage.
    This commit makes that explicit by setting the extension field of
    VarBind to be DataConCantHappen at all other stages.
    
    This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind,
    and remove some panics.
    
    - - - - -
    54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00
    Generate Addr# access ops programmatically
    
    The existing utils/genprimopcode/gen_bytearray_ops.py was
    relocated and extended for this purpose.  Additionally, hadrian
    now knows about this script and uses it when generating primops.txt
    
    - - - - -
    ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00
    ghcup-metadata: Only add Nightly tag when replacing LatestNightly
    
    Previously we were always adding the Nightly tag, but this led to all
    the previous builds getting an increasing number of nightly tags over
    time. Now we just add it once, when we remove the LatestNightly tag.
    
    - - - - -
    4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00
    Invisible binders in type declarations (#22560)
    
    This patch implements @k-binders introduced in GHC Proposal #425
    and guarded behind the TypeAbstractions extension:
    
    	type D :: forall k j. k -> j -> Type
    	data D @k @j a b = ...
    	       ^^ ^^
    
    To represent the new syntax, we modify LHsQTyVars as follows:
    
    	-  hsq_explicit :: [LHsTyVarBndr () pass]
    	+  hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass]
    
    HsBndrVis is a new data type that records the distinction between
    type variable binders written with and without the @ sign:
    
    	data HsBndrVis pass
    	  = HsBndrRequired
    	  | HsBndrInvisible (LHsToken "@" pass)
    
    The rest of the patch updates GHC, template-haskell, and haddock
    to handle the new syntax.
    
    Parser:
      The PsErrUnexpectedTypeAppInDecl error message is removed.
      The syntax it used to reject is now permitted.
    
    Renamer:
      The @ sign does not affect the scope of a binder, so the changes to
      the renamer are minimal.  See rnLHsTyVarBndrVisFlag.
    
    Type checker:
      There are three code paths that were updated to deal with the newly
      introduced invisible type variable binders:
    
        1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl
        2. checking CUSK: see kcCheckDeclHeader_cusk
        3. inference: see kcInferDeclHeader, rejectInvisibleBinders
    
      Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv
      are generalized to work with HsBndrVis.
    
    Updates the haddock submodule.
    
    Metric Increase:
        MultiLayerModulesTH_OneShot
    
    Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00
    JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481)
    
    - - - - -
    e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00
    Update CODEOWNERS
    - - - - -
    960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Remove IPE enabled builds from CI"
    
    This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951.
    
    - - - - -
    bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Update user's guide and release notes, small fixes"
    
    This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7.
    
    - - - - -
    12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Add IPE-enabled builds to CI"
    
    This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f.
    
    - - - - -
    dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Add optional dependencies to ./configure output"
    
    This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58.
    
    - - - - -
    240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Fix IPE data decompression buffer allocation"
    
    This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a.
    
    - - - - -
    9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Fix byte order of IPE data, fix IPE tests"
    
    This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327.
    
    - - - - -
    3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Add note describing IPE data compression"
    
    This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0.
    
    - - - - -
    fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Fix libzstd detection in configure and RTS"
    
    This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0.
    
    - - - - -
    1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "IPE data compression"
    
    This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553.
    
    - - - - -
    fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Add IPE compression to configure"
    
    This reverts commit 5d1f2411f4becea8650d12d168e989241edee186.
    
    - - - - -
    2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Restructure IPE buffer layout"
    
    This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91.
    
    - - - - -
    2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00
    Don't report redundant Givens from quantified constraints
    
    This fixes #23323
    
    See (RC4) in Note [Tracking redundant constraints]
    
    - - - - -
    567b32e1 by David Binder at 2023-06-08T18:41:29-04:00
    Update the outdated instructions in HACKING.md on how to compile GHC
    
    - - - - -
    2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00
    Restore mingwex dependency on Windows
    
    This partially reverts some of the changes in !9475 to make `base` and
    `ghc-prim` depend on the `mingwex` library on Windows. It also restores the
    RTS's stubs for `mingwex`-specific symbols such as `_lock_file`.
    
    This is done because the C runtime provides `libmingwex` nowadays, and
    moreoever, not linking against `mingwex` requires downstream users to link
    against it explicitly in difficult-to-predict circumstances. Better to always
    link against `mingwex` and prevent users from having to do the guesswork
    themselves.
    
    See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for
    the discussion that led to this.
    
    - - - - -
    28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00
    RtsSymbols.c: Remove mingwex symbol stubs
    
    As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows,
    which means that the RTS no longer needs to declare stubs for the `__mingw_*`
    family of symbols. Let's remove these stubs to avoid confusion.
    
    Fixes #23309.
    
    - - - - -
    3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00
    Consistently use validity checks for TH conversion of data constructors
    
    We were checking that TH-spliced data declarations do not look like this:
    
    ```hs
    data D :: Type = MkD Int
    ```
    
    But we were only doing so for `data` declarations' data constructors, not for
    `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out
    the necessary validity checks into its own `cvtDataDefnCons` function and uses
    it in all of the places where it needs to be.
    
    Fixes #22559.
    
    - - - - -
    a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00
    Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma
    
    This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC
    pragma for files with module level scope.
    
    Instead of simple not deleting the files, we also need to remove them
    from the TmpFs so they are not deleted later on when all the other files
    are deleted.
    
    There are additional complications because you also need to remove the
    directory where these files live from the TmpFs so we don't try to
    delete those later either.
    
    I added two tests.
    
    1. Tests simply that -keep-tmp-files works at all with a single module
       and --make mode.
    2. The other tests that temporary files are deleted for other modules
       which don't enable -keep-tmp-files.
    
    Fixes #23339
    
    - - - - -
    dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00
    withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free.
    
    Ticket #23305 reports an error where we were attempting to use the
    logger which was created by withDeferredDiagnostics after its scope had
    ended.
    
    This problem would have been caught by this patch and a validate build:
    
    ```
    +*** Exception: Use after free
    +CallStack (from HasCallStack):
    +  error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make
    ```
    
    This general issue is tracked by #20981
    
    - - - - -
    432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00
    Don't return complete HscEnv from upsweep
    
    By returning a complete HscEnv from upsweep the logger (as introduced by
    withDeferredDiagnostics) was escaping the scope of
    withDeferredDiagnostics and hence we were losing error messages.
    
    This is reminiscent of #20981, which also talks about writing errors
    into messages after their scope has ended.
    
    See #23305 for details.
    
    - - - - -
    26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00
    Dump `SpecConstr` specialisations separately
    
    Introduce a `-ddump-spec-constr` flag which debugs specialisations from
    `SpecConstr`. These are no longer shown when you use `-ddump-spec`.
    
    - - - - -
    4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00
    Add role annotations to SNat, SSymbol and SChar
    
    Ticket #23454 explained it was possible to implement unsafeCoerce
    because SNat was lacking a role annotation.
    
    As these are supposed to be singleton types but backed by an efficient
    representation the correct annotation is nominal to ensure these kinds
    of coerces are forbidden.
    
    These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85
    which was implemented in 532de36870ed9e880d5f146a478453701e9db25d.
    
    CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170
    
    Fixes #23454
    
    - - - - -
    9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00
    Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in
    
    This broke the sdist generation.
    
    Fixes #23489
    
    - - - - -
    273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00
    Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver.
    
    - - - - -
    b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00
    Fix -Wterm-variable-capture scope (#23434)
    
    -Wterm-variable-capture wasn't accordant with type variable
    scoping in associated types, in type classes. For example,
    this code produced the warning:
      k = 12
    
      class C k a where
        type AT a :: k -> Type
    
    I solved this issue by reusing machinery of newTyVarNameRn function
    that is accordand with associated types: it does lookup for each free type
    variable when we are in the type class context. And in this patch I
    use result of this work to make sure that -Wterm-variable-capture warns
    only on implicitly quantified type variables.
    
    - - - - -
    9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00
    Remove redundant case statement in rts/js/mem.js.
    - - - - -
    a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00
    Change WarningWithFlag to plural WarningWithFlags
    
    Resolves #22825
    
    Now each diagnostic can name multiple different warning flags for its reason.
    
    There is currently one use case: missing signatures.
    Currently we need to check which warning flags are enabled when
    generating the diagnostic, which is against the declarative nature of
    the diagnostic framework.
    
    This patch allows a warning diagnostic to have multiple warning flags,
    which makes setup more declarative.
    
    The WarningWithFlag pattern synonym is added for backwards compatibility
    
    The 'msgEnvReason' field is added to MsgEnvelope to store the
    `ResolvedDiagnosticReason`, which accounts for the enabled flags, and
    then that is used for pretty printing the diagnostic.
    
    - - - - -
    ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00
    Add a test Way for running ghci with Core optimizations
    
    Tracking ticket: #23059
    
    This runs compile_and_run tests with optimised code with bytecode
    interpreter
    
    Changed submodules: hpc, process
    
    Co-authored-by: Torsten Schmits <git at tryp.io>
    
    - - - - -
    c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00
    Configure -Qunused-arguments instead of hardcoding it
    
    When GHC invokes clang, it currently passes -Qunused-arguments to
    discard warnings resulting from GHC using multiple options that aren't
    used.
    
    In this commit, we configure -Qunused-arguments into the Cc options
    instead of checking if the compiler is clang at runtime and hardcoding
    the flag into GHC.
    
    This is part of the effort to centralise toolchain information in
    toolchain target files at configure time with the end goal of a runtime
    retargetable GHC.
    
    This also means we don't need to call getCompilerInfo ever, which
    improves performance considerably (see !10589).
    
    Metric Decrease:
        PmSeriesG
        T10421
        T11303b
        T12150
        T12227
        T12234
        T12425
        T13035
        T13253-spj
        T13386
        T15703
        T16875
        T17836b
        T17977
        T17977b
        T18140
        T18282
        T18304
        T18698a
        T18698b
        T18923
        T20049
        T21839c
        T3064
        T5030
        T5321FD
        T5321Fun
        T5837
        T6048
        T9020
        T9198
        T9872d
        T9961
    
    - - - - -
    0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00
    Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion
    between different precisions.
    
    - - - - -
    95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00
    Add regression test for #23143
    
    !10541, the fix for #23323, also fixes #23143. Let's add a regression test to
    ensure that it stays fixed.
    
    Fixes #23143.
    
    - - - - -
    ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00
    delete GHCi.UI.Tags module and remove remaining references
    
    Co-authored-by: Tilde Rose <t1lde at protonmail.com>
    
    - - - - -
    c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00
    Add regression test for 17328
    
    - - - - -
    de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00
    Skip checking whether constructors are in scope when deriving
    newtype instances.
    
    Fixes #17328
    
    - - - - -
    5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00
    Don't suggest `DeriveAnyClass` when instance can't be derived.
    
    Fixes #19692.
    
    Prototypical cases:
    
        class C1 a where
          x1 :: a -> Int
        data G1 = G1 deriving C1
    
        class C2 a where
          x2 :: a -> Int
          x2 _ = 0
        data G2 = G2 deriving C2
    
    Both of these used to give this suggestion, but for C1 the suggestion
    would have failed (generated code with undefined methods, which compiles
    but warns). Now C2 still gives the suggestion but C1 doesn't.
    
    - - - - -
    80a0b099 by David Binder at 2023-06-13T09:47:49-04:00
    Add testcase for error GHC-00711 to testsuite
    
    - - - - -
    e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00
    Add -Wmissing-poly-kind-signatures
    
    Implements #22826
    
    This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types.
    
    - - - - -
    f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00
    ci: special case in req_host_target_ghc for JS
    
    - - - - -
    b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00
    When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions
    
    Fixes #23486
    
    - - - - -
    c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00
    Add a testcase for #20076
    
    Remove 'recursive' in the error message, since the error
    can arise without recursion.
    
    - - - - -
    b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00
    Use tcInferFRR to prevent bad generalisation
    
    Fixes #23176
    
    - - - - -
    bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00
    ci: Add dependenices on necessary aarch64 jobs for head.hackage ci
    
    These need to be added since we started testing aarch64 on head.hackage
    CI. The jobs will sometimes fail because they will start before the
    relevant aarch64 job has finished.
    
    Fixes #23511
    
    - - - - -
    a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00
    Add standalone kind signatures for Code and TExp
    
    CodeQ and TExpQ already had standalone kind signatures
    even before this change:
    
    	type TExpQ :: TYPE r -> Kind.Type
    	type CodeQ :: TYPE r -> Kind.Type
    
    Now Code and TExp have signatures too:
    
    	type TExp :: TYPE r -> Kind.Type
    	type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type
    
    This is a stylistic change.
    
    - - - - -
    e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00
    Warn that GHC.TypeLits.Internal should not be used
    
    - - - - -
    100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00
    Warn that GHC.TypeNats.Internal should not be used
    
    - - - - -
    078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00
    Add more flags for dumping core passes (#23491)
    
    - - - - -
    1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00
    Add tests for dumping flags (#23491)
    
    - - - - -
    42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00
    Provide a demand signature for atomicModifyMutVar.# (#23047)
    
    Fixes #23047
    
    - - - - -
    8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00
    compiler: Cross-reference Note [StgToJS design]
    
    In particular, the numeric representations are quite useful context in a
    few places.
    
    - - - - -
    a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00
    Implement the -Wimplicit-rhs-quantification warning (#23510)
    
    GHC Proposal #425 "Invisible binders in type declarations" forbids
    implicit quantification of type variables that occur free on the
    right-hand side of a type synonym but are not mentioned on the left-hand side.
    The users are expected to rewrite this using invisible binders:
    
        type T1 :: forall a . Maybe a
        type T1    = 'Nothing :: Maybe a      -- old
        type T1 @a = 'Nothing :: Maybe a      -- new
    
    Since the @k-binders are a new feature, we need to wait for three releases
    before we require the use of the new syntax. In the meantime, we ought to
    provide users with a new warning, -Wimplicit-rhs-quantification, that would
    detect when such implicit quantification takes place, and include it in -Wcompat.
    
    - - - - -
    0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00
    Minor refactorings to mkSpillInstr and mkLoadInstr
    
    Better error messages. And, use the existing `off` constant to reduce
    duplication.
    
    - - - - -
    1792b57a by doyougnu at 2023-06-15T03:12:17-04:00
    JS: merge util modules
    
    Merge Core and StgUtil modules for StgToJS pass.
    Closes: #23473
    
    - - - - -
    469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00
    Check visibility of nested foralls in can_eq_nc (#18863)
    
    Prior to this change, `can_eq_nc` checked the visibility of the
    outermost layer of foralls:
    
    	forall a. forall b. forall c. phi1
    	forall x. forall y. forall z. phi2
    	        ^^
    	     up to here
    
    Then it delegated the rest of the work to `can_eq_nc_forall`, which
    split off all foralls:
    
    	forall a. forall b. forall c. phi1
    	forall x. forall y. forall z. phi2
    	                            ^^
    	                         up to here
    
    This meant that some visibility flags were completely ignored.
    We fix this oversight by moving the check to `can_eq_nc_forall`.
    
    - - - - -
    59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00
    JS: use regular mask for blocking IO
    
    Blocking IO used uninterruptibleMask which should make any thread
    blocked on IO unreachable by async exceptions (such as those from
    timeout). This changes it to a regular mask.
    
    It's important to note that the nodejs runtime does not actually
    interrupt the blocking IO when the Haskell thread receives an
    async exception, and that file positions may be updated and buffers
    may be written after the Haskell thread has already resumed.
    
    Any file descriptor affected by an async exception interruption
    should therefore be used with caution.
    
    - - - - -
    907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00
    JS: nodejs: do not set 'readable' handler on stdin at startup
    
    The Haskell runtime used to install a 'readable' handler on stdin
    at startup in nodejs. This would cause the nodejs system to start
    buffering the stream, causing data loss if the stdin file
    descriptor is passed to another process.
    
    This change delays installation of the 'readable' handler until
    the first read of stdin by Haskell code.
    
    - - - - -
    a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00
    JS: reserve one more virtual (negative) file descriptor
    
    This is needed for upcoming support of the process package
    
    - - - - -
    78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00
    Report scoped kind variables at the type-checking phase (#16635)
    
    This patch modifies the renamer to respect ScopedTypeVariables in kind
    signatures. This means that kind variables bound by the outermost
    `forall` now scope over the type:
    
      type F = '[Right @a @() () :: forall a. Either a ()]
      --         ^^^^^^^^^^^^^^^          ^^^
      --          in scope here        bound here
    
    However, any use of such variables is a type error, because we don't
    have type-level lambdas to bind them in Core. This is described in the
    new Note [Type variable scoping errors during type check] in GHC.Tc.Types.
    
    - - - - -
    4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00
    JS: testsuite: use correct ticket number
    
    Replace #22356 with #22349 for these tests because #22356 has been fixed
    but now these tests fail because of #22349.
    
    - - - - -
    15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00
    JS: testsuite: update ticket numbers
    
    - - - - -
    08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00
    JS: more triage
    
    - - - - -
    e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00
    Fix test T18522-deb-ppr
    
    Fixes #23509
    
    - - - - -
    62c56416 by Ben Price at 2023-06-16T05:52:39-04:00
    Lint: more details on "Occurrence is GlobalId, but binding is LocalId"
    
    This is helpful when debugging a pass which accidentally shadowed a
    binder.
    
    - - - - -
    d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00
    Clean a stray bit of text in user guide
    
    - - - - -
    93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00
    testsuite: Add forall visibility test cases
    
    The added tests ensure that the type checker does not confuse
    visible and invisible foralls.
    
    VisFlag1:    kind-checking type applications and inferred type variable instantiations
    VisFlag1_ql: kind-checking Quick Look instantiations
    VisFlag2:    kind-checking type family instances
    VisFlag3:    checking kind annotations on type parameters of associated type families
    VisFlag4:    checking kind annotations on type parameters in type declarations with SAKS
    VisFlag5:    checking the result kind annotation of data family instances
    
    - - - - -
    a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00
    JS: factorize SaneDouble into its own module
    
    Follow-up of b159e0e9 whose ticket is #22736
    
    - - - - -
    0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00
    Add tests for #21973
    
    - - - - -
    640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00
    Update documentation for `<**>`
    
    - - - - -
    2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00
    Update text
    
    - - - - -
    1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00
    Update examples
    
    - - - - -
    7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00
    Update documentation to actually display code correctly
    
    - - - - -
    800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00
    Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512)
    
    GHC Proposal #425 "Invisible binders in type declarations" restricts the
    scope of type and data family instances as follows:
    
      In type family and data family instances, require that every variable
      mentioned on the RHS must also occur on the LHS.
    
    For example, here are three equivalent type instance definitions accepted before this patch:
    
      type family F1 a :: k
      type instance F1 Int = Any :: j -> j
    
      type family F2 a :: k
      type instance F2 @(j -> j) Int = Any :: j -> j
    
      type family F3 a :: k
      type instance forall j. F3 Int = Any :: j -> j
    
    - In F1, j is implicitly quantified and it occurs only on the RHS;
    - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS;
    - In F3, j is explicitly quantified.
    
    Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted.
    
    - - - - -
    9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00
    JS: testsuite: use correct ticket numbers
    
    - - - - -
    c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00
    JS: don't dump eventlog to stderr by default
    
    Fix T16707
    
    Bump stm submodule
    
    - - - - -
    89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00
    Fix TH name lookup for symbolic tycons (#23525)
    
    - - - - -
    cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00
    IPE data compression
    
    IPE data resulting from the `-finfo-table-map` flag may now be
    compressed by configuring the GHC build with the
    `--enable-ipe-data-compression` flag. This results in about a 20%
    reduction in the size of IPE-enabled build results.
    
    The compression library, zstd, may optionally be statically linked by
    configuring with the `--enabled-static-libzstd` flag (on non-darwin
    platforms)
    
    libzstd version 1.4.0 or greater is required.
    
    - - - - -
    0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00
    Add `IfaceWarnings` to represent the `ModIface`-storable parts
    of a `Warnings GhcRn`.
    
    Fixes #23516
    
    - - - - -
    3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00
    Avoid desugaring non-recursive lets into recursive lets
    
    This prepares for having linear let expressions in the frontend.
    
    When desugaring lets, SPECIALISE statements create more copies of a
    let binding. Because of the rewrite rules attached to the bindings,
    there are dependencies between the generated binds.
    
    Before this commit, we simply wrapped all these in a mutually
    recursive let block, and left it to the simplified to sort it out.
    
    With this commit: we are careful to generate the bindings in
    dependency order, so that we can wrap them in consecutive lets (if the
    source is non-recursive).
    
    - - - - -
    9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00
    rts: Do not call exit() from SIGINT handler
    
    Previously `shutdown_handler` would call `stg_exit` if the scheduler was
    Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However,
    `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit`
    handlers). The only safe thing to do in this situation is to call
    `_exit`, which terminates with minimal cleanup.
    
    Fixes #23417.
    
    - - - - -
    7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00
    Bump Cabal submodule
    
    This requires changing the recomp007 test because now cabal passes
    `this-unit-id` to executable components, and that unit-id contains a
    hash which includes the ABI of the dependencies. Therefore changing the
    dependencies means that -this-unit-id changes and recompilation is
    triggered.
    
    The spririt of the test is to test GHC's recompilation logic assuming
    that `-this-unit-id` is constant, so we explicitly pass `-ipid` to
    `./configure` rather than letting `Cabal` work it out.
    
    - - - - -
    1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00
    [feat] add a hint to `HasField` error message
    - add a hint that indicates that the record that the record dot is used
      on might just be missing a field
    - as the intention of the programmer is not entirely clear, it is only
      shown if the type is known
    - This addresses in part issue #22382
    
    - - - - -
    b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00
    rts/ipe: Fix unused lock warning
    
    - - - - -
    6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts/ProfilerReportJson: Fix memory leak
    
    - - - - -
    1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Various warnings fixes
    
    - - - - -
    471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix printf format mismatch
    
    - - - - -
    80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix incorrect #include <sys/poll.h>
    
    According to Alpine's warnings and poll(2), <poll.h> should be
    preferred.
    
    - - - - -
    ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00
    nonmoving: Fix unused definition warrnings
    
    - - - - -
    6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00
    Disable futimens on Darwin.
    
    See #22938
    
    - - - - -
    b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix incorrect CPP guard
    
    - - - - -
    94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00
    hadrian: Ensure that -Werror is passed when compiling the RTS.
    
    Previously the `+werror` transformer would only pass `-Werror` to GHC,
    which does not ensure that the same is passed to the C compiler when
    building the RTS. Arguably this is itself a bug but for now we will just
    work around this by passing `-optc-Werror` to GHC.
    
    I tried to enable `-Werror` in all C compilations but the boot libraries
    are something of a portability nightmare.
    
    - - - - -
    5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Disable `#pragma GCC`s on clang compilers
    
    Otherwise the build fails due to warnings. See #23530.
    
    - - - - -
    cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix capitalization of prototype
    
    - - - - -
    17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix incorrect format specifier
    
    - - - - -
    0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00
    JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576)
    
    - - - - -
    3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00
    Memory usage fixes for Haddock
    
    - Do not include `mi_globals` in the `NoBackend` backend. It was only included
      for Haddock, but Haddock does not actually need it. This causes a 200MB
      reduction in max residency when generating haddocks on the Agda codebase
      (roughly 1GB to 800MB).
    
    - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to
      be written to interface files using `-fwrite-interface`
    
    Bumps haddock submodule.
    
    Metric Decrease:
        haddock.base
    
    - - - - -
    8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00
    Fix associated data family doc structure items
    
    Associated data families were being given their own export DocStructureItems,
    which resulted in them being documented separately from their classes in
    haddocks. This commit fixes it.
    
    - - - - -
    4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    JS: implement TH support
    
    - Add ghc-interp.js bootstrap script for the JS interpreter
    - Interactively link and execute iserv code from the ghci package
    - Incrementally load and run JS code for splices into the running iserv
    
    Co-authored-by: Luite Stegeman <stegeman at gmail.com>
    
    - - - - -
    3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    Don't use getKey
    
    - - - - -
    f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    Stg: return imported FVs
    
    This is used to determine what to link when using the interpreter.
    For now it's only used by the JS interpreter but it could easily be used
    by the native interpreter too (instead of extracting names from compiled BCOs).
    
    - - - - -
    fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    Fix some recompilation avoidance tests
    
    - - - - -
    a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    TH_import_loop is now broken as expected
    
    - - - - -
    dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    JS: always recompile when TH is enabled (cf #23013)
    
    - - - - -
    711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00
    Add support for deprecating exported items (proposal #134)
    
    This is an implementation of the deprecated exports proposal #134.
    The proposal introduces an ability to introduce warnings to exports.
    This allows for deprecating a name only when it is exported from a specific
    module, rather than always depreacting its usage. In this example:
    
        module A ({-# DEPRECATED "do not use" #-} x) where
        x = undefined
        ---
        module B where
        import A(x)
    
    `x` will emit a warning when it is explicitly imported.
    
    Like the declaration warnings, export warnings are first accumulated within
    the `Warnings` struct, then passed into the ModIface, from which they are
    then looked up and warned about in the importing module in the `lookup_ie`
    helpers of the `filterImports` function (for the explicitly imported names)
    and in the `addUsedGRE(s)` functions where they warn about regular usages
    of the imported name.
    
    In terms of the AST information, the custom warning is stored in the
    extension field of the variants of the `IE` type (see Trees that Grow for
    more information).
    
    The commit includes a bump to the haddock submodule added in MR #28
    
    Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>
    
    - - - - -
    c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00
    configure: Bump version to 9.8
    
    Bumps Haddock submodule
    
    - - - - -
    4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00
    configure: Bump version to 9.9
    
    Bumps haddock submodule.
    
    - - - - -
    5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00
    rts: Work around missing prototypes errors
    
    Darwin's toolchain inexpliciably claims that `write_barrier` and friends
    have declarations without prototypes, despite the fact that (a) they are
    definitions, and (b) the prototypes appear only a few lines above. Work
    around this by making the definitions proper prototypes.
    
    - - - - -
    43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00
    ghcup-metadata: Fix date modifier (M = minutes, m = month)
    
    Fixes #23552
    
    - - - - -
    564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00
    Support large stack frames/offsets in GHCi bytecode interpreter
    
    Bytecode instructions like PUSH_L (push a local variable) contain
    an operand that refers to the stack slot. Before this patch, the
    operand type was SmallOp (Word16), limiting the maximum stack
    offset to 65535 words. This could cause compiler panics in some
    cases (See #22888).
    
    This patch changes the operand type for stack offsets from
    SmallOp to Op, removing the stack offset limit.
    
    Fixes #22888
    
    - - - - -
    8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00
    JS: support levity-polymorphic datatypes (#22360,#22291)
    
    - thread knowledge about levity into PrimRep instead of panicking
    - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.)
    
    Doing this also fixes #22291 (test added).
    
    There is a small performance hit (~1% more allocations).
    
    Metric Increase:
        T18698a
        T18698b
    
    - - - - -
    5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00
    MR Review Template: Mention "Blocked on Review" label
    
    In order to improve our MR review processes we now have the label
    "Blocked on Review" which allows people to signal that a MR is waiting
    on a review to happen.
    
    See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html
    
    - - - - -
    4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00
    Move MR template to Default.md
    
    This makes it more obvious what you have to modify to affect the default
    template rather than looking in the project settings.
    
    - - - - -
    522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00
    Revert "Avoid desugaring non-recursive lets into recursive lets"
    
    This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef.
    
    Fixes #23550
    
    - - - - -
    c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00
    Propagate breakpoint information when inlining across modules
    
    Tracking ticket: #23394
    
    MR: !10448
    
    * Add constructor `IfaceBreakpoint` to `IfaceTickish`
    * Store breakpoint data in interface files
    * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs
    * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's
      state
    * Allocate module name in `ModBreaks`, like `BreakArray`
    * Lookup breakpoint by module name in GHCi
    * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the
      linker when breakpoints are enabled, and panicking when `ModBreaks` is missing
    
    - - - - -
    6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00
    Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's
    
    - - - - -
    e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00
    Remove arity inference in type declarations (#23514)
    
    Arity inference in type declarations was introduced
    as a workaround for the lack of @k-binders.
    
    They were added in 4aea0a72040, so I simplified all
    of this by simply removing arity inference altogether.
    
    This is part of GHC Proposal #425 "Invisible binders in type
    declarations".
    
    - - - - -
    459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00
    Relax defaulting of RuntimeRep/Levity when printing
    
    Fixes #16468
    
    MR: !10702
    
    Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall
    
    - - - - -
    151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00
    Remove duplicate link label in linear types docs
    
    - - - - -
    ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00
    Stop configuring unused Ld command in `settings`
    
    GHC has no direct dependence on the linker. Rather, we depend upon the C
    compiler for linking and an object-merging program (which is typically
    `ld`) for production of GHCi objects and merging of C stubs into final
    object files.
    
    Despite this, for historical reasons we still recorded information about
    the linker into `settings`. Remove these entries from `settings`,
    `hadrian/cfg/system.config`, as well as the `configure` logic
    responsible for this information.
    
    Closes #23566.
    
    - - - - -
    bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00
    Remove extraneous debug output
    
    - - - - -
    7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00
    Work with unset vars in -e mode
    
    - - - - -
    49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00
    Pass positional arguments in their positions
    
    By quoting $cmd, the default "bash -i" is a single argument to run, and
    no file named "bash -i" actually exists to be run.
    
    - - - - -
    887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00
    Handle unset value in -e context
    
    - - - - -
    5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00
    Configure CPP into settings
    
    There is a distinction to be made between the Haskell Preprocessor and
    the C preprocessor. The former is used to preprocess Haskell files,
    while the latter is used in C preprocessing such as Cmm files.
    
    In practice, they are both the same program (usually the C compiler) but
    invoked with different flags.
    
    Previously we would, at configure time, configure the haskell
    preprocessor and save the configuration in the settings file, but,
    instead of doing the same for CPP, we had hardcoded in GHC that the CPP
    program was either `cc -E` or `cpp`.
    
    This commit fixes that asymmetry by also configuring CPP at configure
    time, and tries to make more explicit the difference between HsCpp and
    Cpp (see Note [Preprocessing invocations]).
    
    Note that we don't use the standard CPP and CPPFLAGS to configure Cpp,
    but instead use the non-standard --with-cpp and --with-cpp-flags.
    The reason is that autoconf sets CPP to "$CC -E", whereas we expect the
    CPP command to be configured as a standalone executable rather than a
    command. These are symmetrical with --with-hs-cpp and
    --with-hs-cpp-flags.
    
    Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP
             to be C99 compatible through -optP, since we now configure that
             into settings.
    
    Closes #23422
    
    - - - - -
    5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00
    hadrian: Always canonicalize topDirectory
    
    Hadrian's `topDirectory` is intended to provide an absolute path to the
    root of the GHC tree. However, if the tree is reached via a symlink this
    
    One question here is whether the `canonicalizePath` call is expensive
    enough to warrant caching. In a quick microbenchmark I observed that
    `canonicalizePath "."` takes around 10us per call; this seems
    sufficiently low not to worry.
    
    Alternatively, another approach here would have been to rather move the
    canonicalization into `m4/fp_find_root.m4`. This would have avoided
    repeated canonicalization but sadly path canonicalization is a hard
    problem in POSIX shell.
    
    Addresses #22451.
    
    - - - - -
    b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00
    Optimise ELF linker (#23464)
    
    - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF`
    - cache shndx table in ObjectCode
    - run `checkProddableBlock` only with debug rts
    
    - - - - -
    30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00
    compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE
    
    - - - - -
    b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00
    compiler: Drop MO_WriteBarrier
    
    rts: Drop write_barrier
    
    - - - - -
    7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00
    rts: Drop load_store_barrier()
    
    This is no longer used.
    
    - - - - -
    d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00
    rts: Drop last instances of prim_{write,read}_barrier
    
    - - - - -
    965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00
    rts: Eliminate remaining uses of load_load_barrier
    
    - - - - -
    0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00
    compiler: Drop MO_ReadBarrier
    
    - - - - -
    7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00
    rts: Drop load_load_barrier
    
    This is no longer used.
    
    - - - - -
    9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00
    Delete write_barrier function
    
    - - - - -
    bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00
    rts: Make collectFreshWeakPtrs definition a prototype
    
    x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs
    needs to be a prototype.
    
    - - - - -
    ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00
    Fix number of free double regs
    
    D1..D4 are defined for aarch64 and thus not free.
    
    - - - - -
    c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00
    Fix typechecking of promoted empty lists
    
    The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of
    `'[]` (see the newly added `T23543` test case for an example), but the `'[]`
    case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to
    invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type
    checker]`.
    
    There are some benign changes to test cases' expected output due to the new
    code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`.
    
    Fixes #23543.
    
    - - - - -
    fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00
    Configure MergeObjs supports response files rather than Ld
    
    The previous configuration script to test whether Ld supported response
    files was
    * Incorrect (see #23542)
    * Used, in practice, to check if the *merge objects tool* supported
      response files.
    
    This commit modifies the macro to run the merge objects tool (rather
    than Ld), using a response file, and checking the result with $NM
    
    Fixes #23542
    
    - - - - -
    78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00
    JS: fix JS stack printing (#23565)
    
    - - - - -
    9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00
    Add -fpolymorphic-specialisation flag (off by default at all optimisation levels)
    
    Polymorphic specialisation has led to a number of hard to diagnose
    incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so
    this commit introduces a flag `-fpolymorhphic-specialisation` which
    allows users to turn on this experimental optimisation if they are
    willing to buy into things going very wrong.
    
    Ticket #23469
    
    - - - - -
    b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00
    Rip out runtime linker/compiler checks
    
    We used to choose flags to pass to the toolchain at runtime based on the
    platform running GHC, and in this commit we drop all of those runtime
    linker checks
    
    Ultimately, this represents a change in policy: We no longer adapt at
    runtime to the toolchain being used, but rather make final decisions
    about the toolchain used at /configure time/
    (we have deleted Note [Run-time linker info] altogether!).
    
    This works towards the goal of having all toolchain configuration logic
    living in the same place, which facilities the work towards a
    runtime-retargetable GHC (see #19877).
    
    As of this commit, the runtime linker/compiler logic was moved to
    autoconf, but soon it, and the rest of the existing toolchain
    configuration logic, will live in the standalone ghc-toolchain program
    (see !9263)
    
    In particular, what used to be done at runtime is now as follows:
    * The flags -Wl,--no-as-needed for needed shared libs are configured
      into settings
    * The flag -fstack-check is configured into settings
    * The check for broken tables-next-to-code was outdated
    * We use the configured c compiler by default as the assembler program
    * We drop `asmOpts` because we already configure -Qunused-arguments flag
      into settings (see !10589)
    
    Fixes #23562
    
    Co-author: Rodrigo Mesquita (@alt-romes)
    
    - - - - -
    8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00
    Define FFI_GO_CLOSURES
    
    The libffi shipped with Apple's XCode toolchain does not contain a
    definition of the FFI_GO_CLOSURES macro, despite containing references
    to said macro. Work around this by defining the macro, following the
    model of a similar workaround in OpenJDK [1].
    
    [1] https://github.com/openjdk/jdk17u-dev/pull/741/files
    
    - - - - -
    d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00
    base: Fix incorrect CPP guard
    
    This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`.
    
    - - - - -
    7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00
    rts/Trace: Ensure that debugTrace arguments are used
    
    As debugTrace is a macro we must take care to ensure that
    the fact is clear to the compiler lest we see warnings.
    
    - - - - -
    cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00
    rts: Various warnings fixes
    
    - - - - -
    dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00
    hadrian: Ignore warnings in unix and semaphore-compat
    
    - - - - -
    d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00
    hadrian: Fix dependencies of docs:* rule
    
    For the docs:* rule we need to actually build the package rather than
    just the haddocks for the dependent packages. Therefore we depend on the
    .conf files of the packages we are trying to build documentation for as
    well as the .haddock files.
    
    Fixes #23472
    
    - - - - -
    cec90389 by sheaf at 2023-06-30T12:39:27-04:00
    Add tests for #22106
    
    Fixes #22106
    
    - - - - -
    083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00
    Add -fbreak-points to control breakpoint insertion
    
    Rather than statically enabling breakpoints only for the interpreter,
    this adds a new flag.
    
    Tracking ticket: #23057
    
    MR: !10466
    
    - - - - -
    fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00
    rts: Ensure that pinned allocations respect block size
    
    Previously, it was possible for pinned, aligned allocation requests to
    allocate beyond the end of the pinned accumulator block. Specifically,
    we failed to account for the padding needed to achieve the requested
    alignment in the "large object" check. With large alignment requests,
    this can result in the allocator using the capability's pinned object
    accumulator block to service a request which is larger than
    `PINNED_EMPTY_SIZE`.
    
    To fix this we reorganize `allocatePinned` to consistently account for
    the alignment padding in all large object checks. This is a bit subtle
    as we must handle the case of a small allocation request filling the
    accumulator block, as well as large requests.
    
    Fixes #23400.
    
    - - - - -
    98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00
    testsuite: Add test for #23400
    
    - - - - -
    4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00
    ghc-heap: Support for BLOCKING_QUEUE closures
    
    - - - - -
    03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00
    Add some structured diagnostics in Tc/Validity.hs
    
    This addresses the work of ticket #20118
    Created the following constructors for TcRnMessage
     - TcRnInaccessibleCoAxBranch
     - TcRnPatersonCondFailure
    
    - - - - -
    6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00
    Add failing test case for #23492
    
    - - - - -
    356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
    Use generated src span for catch-all case of record selector functions
    
    This fixes #23492. The problem was that we used the real source span
    of the field declaration for the generated catch-all case in the
    selector function, in particular in the generated call to
    `recSelError`, which meant it was included in the HIE output. Using
    `generatedSrcSpan` instead means that it is not included.
    
    - - - - -
    3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
    Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils
    
    - - - - -
    dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
    Construct catch-all default case using helpers
    
    GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors
    
    - - - - -
    0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00
    Add regression test for #23549
    
    - - - - -
    32741743 by Alexis King at 2023-07-03T03:31:36-04:00
    perf tests: Increase default stack size for MultiLayerModules
    
    An unhelpfully small stack size appears to have been the real culprit
    behind the metric fluctuations in #19293. Debugging metric decreases
    triggered by !10729 helped to finally identify the problem.
    
    Metric Decrease:
        MultiLayerModules
        MultiLayerModulesTH_Make
        T13701
        T14697
    
    - - - - -
    82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00
    Add missing void prototypes to rts functions
    
    See #23561.
    
    - - - - -
    6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00
    gitlab-ci: Refactor compilation of gen_ci
    
    Flakify and document it, making it far less sensitive to the build
    environment.
    
    - - - - -
    aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00
    testsuite: Update documentation
    - - - - -
    924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00
    Better error for data deriving of type synonym/family. Closes #23522
    
    - - - - -
    4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00
    Fix some broken links and typos
    
    - - - - -
    de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00
    configure: Rip out Solaris dyld check
    
    Solaris 11 was released over a decade ago and, moreover, I doubt we have
    any Solaris users
    
    - - - - -
    59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00
    CI: add JS release and debug builds, regen CI jobs
    
    - - - - -
    679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00
    testsuite: Do not require CUSKs
    
    Numerous tests make use of CUSKs (complete user-supplied kinds),
    a legacy feature scheduled for deprecation. In order to proceed
    with the said deprecation, the tests have been updated to use SAKS
    instead (standalone kind signatures).
    
    This also allows us to remove the Haskell2010 language pragmas that
    were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021.
    
    - - - - -
    945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00
    gitlab: Drop backport-for-8.8 MR template
    
    Its usefulness has long passed.
    - - - - -
    66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00
    EPA: Simplify GHC/Parser.y comb2
    
    Use the HasLoc instance from Ast.hs to allow comb2 to work with
    anything with a SrcSpan
    
    This gets rid of the custom comb2A, comb2Al, comb2N functions, and
    removes various reLoc calls.
    
    - - - - -
    2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00
    Fix deprecation warning when deprecated identifier is from another module
    
    A stray 'Just' was being printed in the deprecation message.
    
    Fixes #23573
    
    - - - - -
    46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00
    rts: Don't rely on initializers for sigaction_t
    
    As noted in #23577, CentOS's ancient toolchain throws spurious
    missing-field-initializer warnings.
    
    - - - - -
    ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00
    hadrian: Don't treat -Winline warnings as fatal
    
    Such warnings are highly dependent upon the toolchain, platform, and
    build configuration. It's simply too fragile to rely on these.
    
    - - - - -
    3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00
    hadrian: Only pass -Wno-nonportable-include-path on Darwin
    
    This flag, which was introduced due to #17798, is only understood by
    Clang and consequently throws warnings on platforms using gcc. Sadly,
    there is no good way to treat such warnings as non-fatal with `-Werror`
    so for now we simply make this flag specific to platforms known to use
    Clang and case-insensitive filesystems (Darwin and Windows).
    
    See #23577.
    
    - - - - -
    4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00
    Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals
    
    - - - - -
    2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00
    compiler: Make OccSet opaque
    
    - - - - -
    cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00
    Add Note about why we need forall in Code to be on the right
    
    - - - - -
    fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00
    Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall.
    - - - - -
    9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00
    Improve the situation with the stimes cycle
    
    Currently the Semigroup stimes cycle is resolved in GHC.Base by
    importing stimes implementations from a hs-boot file. Resolve the cycle
    using hs-boot files for required classes (Num, Integral) instead. Now
    stimes can be defined directly in GHC.Base, making inlining and
    specialization possible.
    
    This leads to some new boot files for `GHC.Num` and `GHC.Real`, the
    methods for those are only used to implement `stimes` so it doesn't
    appear that these boot files will introduce any new performance traps.
    
    Metric Decrease:
        T13386
        T8095
    Metric Increase:
        T13253
        T13386
        T18698a
        T18698b
        T19695
        T8095
    
    - - - - -
    9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00
    Refactor Unique to be represented by Word64
    
    In #22010 we established that Int was not always sufficient to store all
    the uniques we generate during compilation on 32-bit platforms. This
    commit addresses that problem by using Word64 instead of Int for
    uniques.
    
    The core of the change is in GHC.Core.Types.Unique and
    GHC.Core.Types.Unique.Supply. However, the representation of uniques is
    used in many other places, so those needed changes too. Additionally, the RTS
    has been extended with an atomic_inc64 operation.
    
    One major change from this commit is the introduction of the Word64Set and
    Word64Map data types. These are adapted versions of IntSet and IntMap
    from the containers package. These are planned to be upstreamed in the
    future.
    
    As a natural consequence of these changes, the compiler will be a bit
    slower and take more space on 32-bit platforms. Our CI tests indicate
    around a 5% residency increase.
    
    Metric Increase:
        CoOpt_Read
        CoOpt_Singletons
        LargeRecord
        ManyAlternatives
        ManyConstructors
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModulesTH_OneShot
        RecordUpdPerf
        T10421
        T10547
        T12150
        T12227
        T12234
        T12425
        T12707
        T13035
        T13056
        T13253
        T13253-spj
        T13379
        T13386
        T13719
        T14683
        T14697
        T14766
        T15164
        T15703
        T16577
        T16875
        T17516
        T18140
        T18223
        T18282
        T18304
        T18698a
        T18698b
        T18923
        T1969
        T19695
        T20049
        T21839c
        T3064
        T3294
        T4801
        T5030
        T5321FD
        T5321Fun
        T5631
        T5642
        T5837
        T6048
        T783
        T8095
        T9020
        T9198
        T9233
        T9630
        T9675
        T9872a
        T9872b
        T9872b_defer
        T9872c
        T9872d
        T9961
        TcPlugin_RewritePerf
        UniqLoop
        WWRec
        hard_hole_fits
    
    - - - - -
    6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00
    Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro
    - - - - -
    40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00
    Substitute free variables captured by breakpoints in SpecConstr
    
    Fixes #23267
    
    - - - - -
    2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00
    Reinstate untouchable variable error messages
    
    This extra bit of information was accidentally being discarded after
    a refactoring of the way we reported problems when unifying a type
    variable with another type. This patch rectifies that.
    
    - - - - -
    53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00
    configure: Drop Clang command from settings
    
    Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the
    `runClang` function, and no longer need to configure into settings the
    Clang command. We used to determine options at runtime to pass clang when
    it was used as an assembler, but now that we configure at configure time
    we no longer need to.
    
    - - - - -
    6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00
    Filter out nontrivial substituted expressions in substTickish
    
    Fixes #23272
    
    - - - - -
    41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00
    JS: testsuite: use req_c predicate instead of js_broken
    
    - - - - -
    74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00
    JS: implement some file primitives (lstat,rmdir) (#22374)
    
    - Implement lstat and rmdir.
    - Implement base_c_s_is* functions (testing a file type)
    - Enable passing tests
    
    - - - - -
    7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00
    JS: cleanup utils (#23314)
    
    - Removed unused code
    - Don't export unused functions
    - Move toTypeList to Closure module
    
    - - - - -
    f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00
    JS: rename VarType/Vt into JSRep
    
    - - - - -
    19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00
    JS: remove custom PrimRep conversion (#23314)
    
    We use the usual conversion to PrimRep and then we convert these
    PrimReps to JSReps.
    
    - - - - -
    d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00
    JS: don't use isRuntimeRepKindedTy in JS FFI
    
    - - - - -
    8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00
    ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file
    
    Fixes #23600
    
    - - - - -
    e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00
    ghcup-metadata: Use dynamically linked alpine bindists
    
    In theory these will work much better on alpine to allow people to build
    statically linked applications there. We don't need to distribute a
    statically linked application ourselves in order to allow that.
    
    Fixes #23602
    
    - - - - -
    b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00
    Drop circle-ci-job.sh
    
    - - - - -
    9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00
    testsuite: Allow preservation of unexpected output
    
    Here we introduce a new flag to the testsuite driver,
    --unexpected-output-dir=<dir>, which allows the user to ask
    the driver to preserve unexpected output from tests. The intent is for
    this to be used in CI to allow users to more easily fix unexpected
    platform-dependent output.
    
    - - - - -
    48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00
    gitlab-ci: Preserve unexpected output
    
    Here we enable use of the testsuite driver's `--unexpected-output-dir`
    flag by CI, preserving the result as an artifact for use by users.
    
    - - - - -
    76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00
    driver: Fix -S with .cmm files
    
    There was an oversight in the driver which assumed that you would always
    produce a `.o` file when compiling a .cmm file.
    
    Fixes #23610
    
    - - - - -
    6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00
    Update Hadrian's stack.yaml
    - - - - -
    1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00
    compiler: Rework ShowSome
    
    Previously the field used to filter the sub-declarations to show
    was rather ad-hoc and was only able to show at most one sub-declaration.
    
    - - - - -
    8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00
    testsuite: Add test to catch changes in core libraries
    
    This adds testing infrastructure to ensure that changes in core
    libraries (e.g. `base` and `ghc-prim`) are caught in CI.
    
    - - - - -
    ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00
    Deprecate Data.List.NonEmpty.unzip
    
    - - - - -
    5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00
    Drop latent mentions of -split-objs
    
    Closes #21134.
    
    - - - - -
    a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00
    Add warn_and_run test kind
    
    This is a compile_and_run variant which also captures the GHC's
    stderr. The warn_and_run name is best I can come up with,
    as compile_and_run is taken.
    
    This is useful specifically for testing warnings.  We want to test that
    when warning triggers, and it's not a false positive, i.e. that the
    runtime behaviour is indeed "incorrect".
    
    As an example a single test is altered to use warn_and_run
    
    - - - - -
    c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00
    configure: Don't use ld.gold on i386
    
    ld.gold appears to produce invalid static constructor tables on i386.
    While ideally we would add an autoconf check to check for this
    brokenness, sadly such a check isn't easy to compose. Instead to
    summarily reject such linkers on i386.
    
    Somewhat hackily closes #23579.
    
    - - - - -
    054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00
    Add since annotations for Data.Foldable1
    
    - - - - -
    550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00
    JS: support -this-unit-id for programs in the linker (#23613)
    
    - - - - -
    d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00
    Bump text submodule
    
    - - - - -
    8e11630e by jade at 2023-07-10T16:58:40-04:00
    Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007)
    
    As suggested in #20007 and implemented in !8895, trying to import type operators
    will suggest a fix to use the 'type' keyword, without considering whether
    ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces
    is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled,
    alongside the suggestion of adding the 'type' keyword.
    
    - - - - -
    61b1932e by sheaf at 2023-07-10T16:59:26-04:00
    tyThingLocalGREs: include all DataCons for RecFlds
    
    The GREInfo for a record field should include the collection of all
    the data constructors of the parent TyCon that have this record field.
    This information was being incorrectly computed in the tyThingLocalGREs
    function for a DataCon, as we were not taking into account other
    DataCons with the same parent TyCon.
    
    Fixes #23546
    
    - - - - -
    e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00
    EPA: Simplify GHC/Parser.y comb3
    
    A follow up to !10743
    
    - - - - -
    ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00
    Document that compareByteArrays# is available since ghc-prim-0.5.2.0
    
    - - - - -
    4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00
    Revert "Bump text submodule"
    
    This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a.
    
    This commit requires that we bootstrap with ghc-9.4, which we do not
    require until #23195 has been completed.
    
    Subsequently this has broken nighty jobs such as the rocky8 job which in
    turn has broken nightly releases.
    
    - - - - -
    d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00
    compiler: Fingerprint more code generation flags
    
    Previously our recompilation check was quite inconsistent in its
    coverage of non-optimisation code generation flags. Specifically, we
    failed to account for most flags that would affect the behavior of
    generated code in ways that might affect the result of a program's
    execution (e.g. `-feager-blackholing`, `-fstrict-dicts`)
    
    Closes #23369.
    
    - - - - -
    eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00
    compiler: Record original thunk info tables on stack
    
    Here we introduce a new code generation option, `-forig-thunk-info`,
    which ensures that an `stg_orig_thunk_info` frame is pushed before every
    update frame. This can be invaluable when debugging thunk cycles and
    similar.
    
    See Note [Original thunk info table frames] for details.
    
    Closes #23255.
    
    - - - - -
    4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00
    Fix wrong MIN_VERSION_GLASGOW_HASKELL macros
    
    I forgot to change these after rebasing.
    
    - - - - -
    dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00
    Hadrian: enable GHCi support on riscv64
    
    - - - - -
    09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00
    JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628)
    
    - - - - -
    29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00
    Remove references to make build system in mk/build.mk
    
    Fixes #23636
    
    - - - - -
    630e3026 by sheaf at 2023-07-12T11:26:43-04:00
    Valid hole fits: don't panic on a Given
    
    The function GHC.Tc.Errors.validHoleFits would end up panicking when
    encountering a Given constraint. To fix this, it suffices to filter out
    the Givens before continuing.
    
    Fixes #22684
    
    - - - - -
    c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00
    Use deb10 for i386 bindists
    
    deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10
    
    Fixes #23585
    
    - - - - -
    bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00
    Fix #23567, a specializer bug
    
    Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834
    
    The testcase isn't ideal because it doesn't detect the bug in master,
    unless doNotUnbox is removed as in
    https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692.
    But I have confirmed that with that modification, it fails before
    and passes afterwards.
    
    - - - - -
    84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
    Comments
    
    - - - - -
    b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
    updates to comments
    
    - - - - -
    2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
    changes
    
    - - - - -
    6143838a by sheaf at 2023-07-13T08:02:17-04:00
    Fix deprecation of record fields
    
    Commit 3f374399 inadvertently broke the deprecation/warning mechanism
    for record fields due to its introduction of record field namespaces.
    
    This patch ensures that, when a top-level deprecation is applied to
    an identifier, it applies to all the record fields as well.
    This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and
    GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of
    NameSpaces but to look up all NameSpaces and filter out the irrelevant
    ones.
    
    - - - - -
    6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00
    Introduce greInfo, greParent
    
    These are simple helper functions that wrap the internal
    field names gre_info, gre_par.
    
    - - - - -
    7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00
    Refactor lookupGRE_... functions
    
    This commit consolidates all the logic for looking up something in
    the Global Reader Environment into the single function lookupGRE.
    This allows us to declaratively specify all the different modes of
    looking up in the GlobalRdrEnv, and avoids manually passing around
    filtering functions as was the case in e.g. the function
    GHC.Rename.Env.lookupSubBndrOcc_helper.
    
    -------------------------
    Metric Decrease:
        T8095
    -------------------------
    -------------------------
    Metric Increase:
        T8095
    -------------------------
    
    - - - - -
    5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00
    configure: Drop DllWrap command
    
    We used to configure into settings a DllWrap command for windows
    builds and distributions, however, we no longer do, and dllwrap is
    effectively unused.
    
    This simplification is motivated in part by the larger
    toolchain-selection project (#19877, !9263)
    
    - - - - -
    e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00
    base: fix haddock syntax in GHC.Profiling
    
    - - - - -
    0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00
    Revert "CI: add JS release and debug builds, regen CI jobs"
    
    This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af.
    
    This commit added two duplicate jobs on all validate pipelines, so we
    are reverting for now whilst we work out what the best way forward is.
    
    Ticket #23618
    
    - - - - -
    54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00
    EPA: Simplify GHC/Parser.y sLL
    
    Follow up to !10743
    
    - - - - -
    c8863828 by sheaf at 2023-07-15T03:24:06-04:00
    Configure: canonicalise PythonCmd on Windows
    
    This change makes PythonCmd resolve to a canonical absolute path on
    Windows, which prevents HLS getting confused (now that we have a
    build-time dependency on python).
    
    fixes #23652
    
    - - - - -
    ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00
    Improve Note [Binder-swap during float-out]
    
    - - - - -
    cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00
    Equality of forall-types is visibility aware
    
    This patch finally (I hope) nails the question of whether
       (forall a. ty) and (forall a -> ty)
    are `eqType`: they aren't!
    
    There is a long discussion in #22762, plus useful Notes:
    
    * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare
    * Note [Comparing visiblities] in GHC.Core.TyCo.Compare
    * Note [ForAllCo] in GHC.Core.TyCo.Rep
    
    It also establishes a helpful new invariant for ForAllCo,
    and ForAllTy, when the bound variable is a CoVar:in that
    case the visibility must be coreTyLamForAllTyFlag.
    
    All this is well documented in revised Notes.
    
    - - - - -
    7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00
    List and Tuple<n>: update documentation
    
    Add the missing changelog.md entries and @since-annotations.
    
    - - - - -
    2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00
    Type patterns (#22478, #18986)
    
    Improved name resolution and type checking of type patterns in constructors:
    
    1. HsTyPat: a new dedicated data type that represents type patterns in
       HsConPatDetails instead of reusing HsPatSigType
    
    2. rnHsTyPat: a new function that renames a type
       pattern and collects its binders into three groups:
        - explicitly bound type variables, excluding locally bound
          variables
        - implicitly bound type variables from kind signatures
          (only if ScopedTypeVariables are enabled)
        - named wildcards (only from kind signatures)
    2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat
    2b. rnImplcitTvBndrs: removed because no longer needed
    
    3. collect_pat: updated to collect type variable binders from type patterns
       (this means that types and terms use the same infrastructure to detect
       conflicting bindings, unused variables and name shadowing)
    3a. CollVarTyVarBinders: a new CollectFlag constructor that enables
        collection of type variables
    
    4. tcHsTyPat: a new function that typechecks type patterns, capable of
       handling polymorphic kinds.
       See Note [Type patterns: binders and unifiers]
    
    Examples of code that is now accepted:
    
       f = \(P @a) -> \(P @a) -> ...  -- triggers -Wname-shadowing
    
       g :: forall a. Proxy a -> ...
       g (P @a) = ...                 -- also triggers -Wname-shadowing
    
       h (P @($(TH.varT (TH.mkName "t")))) = ...
                                      -- t is bound at splice time
    
       j (P @(a :: (x,x))) = ...      -- (x,x) is no longer rejected
    
       data T where
         MkT :: forall (f :: forall k. k -> Type).
           f Int -> f Maybe -> T
       k :: T -> ()
       k (MkT @f (x :: f Int) (y :: f Maybe)) = ()
                                      -- f :: forall k. k -> Type
    
    Examples of code that is rejected with better error messages:
    
      f (Left @a @a _) = ...
      -- new message:
      --     • Conflicting definitions for ‘a’
      --       Bound at: Test.hs:1:11
      --                 Test.hs:1:14
    
    Examples of code that is now rejected:
    
      {-# OPTIONS_GHC -Werror=unused-matches #-}
      f (P @a) = ()
      -- Defined but not used: type variable ‘a’
    
    - - - - -
    eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00
    Don't use substTyUnchecked in newMetaTyVar
    
    There were some comments that explained that we needed to use an
    unchecked substitution function because of issue #12931, but that
    has since been fixed, so we should be able to use substTy instead now.
    
    - - - - -
    c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00
    rnImports: var shouldn't import NoFldSelectors
    
    In an import declaration such as
    
      import M ( var )
    
    the import of the variable "var" should **not** bring into scope record
    fields named "var" which are defined with NoFieldSelectors.
    Doing so can cause spurious "unused import" warnings, as reported in
    ticket #23557.
    
    Fixes #23557
    
    - - - - -
    1af2e773 by sheaf at 2023-07-17T02:48:19-04:00
    Suggest similar names in imports
    
    This commit adds similar name suggestions when importing. For example
    
      module A where { spelling = 'o' }
      module B where { import B ( speling ) }
    
    will give rise to the error message:
    
      Module ‘A’ does not export ‘speling’.
      Suggested fix: Perhaps use ‘spelling’
    
    This also provides hints when users try to import record fields defined
    with NoFieldSelectors.
    
    - - - - -
    654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00
    EPA: Store leading AnnSemi for decllist in al_rest
    
    This simplifies the markAnnListA implementation in ExactPrint
    
    - - - - -
    22565506 by sheaf at 2023-07-17T21:12:59-04:00
    base: add COMPLETE pragma to BufferCodec PatSyn
    
    This implements CLC proposal #178, rectifying an oversight in the
    implementation of CLC proposal #134 which could lead to spurious
    pattern match warnings.
    
    https://github.com/haskell/core-libraries-committee/issues/178
    https://github.com/haskell/core-libraries-committee/issues/134
    
    - - - - -
    860f6269 by sheaf at 2023-07-17T21:13:00-04:00
    exactprint: silence incomplete record update warnings
    
    - - - - -
    df706de3 by sheaf at 2023-07-17T21:13:00-04:00
    Re-instate -Wincomplete-record-updates
    
    Commit e74fc066 refactored the handling of record updates to use
    the HsExpanded mechanism. This meant that the pattern matching inherent
    to a record update was considered to be "generated code", and thus we
    stopped emitting "incomplete record update" warnings entirely.
    
    This commit changes the "data Origin = Source | Generated" datatype,
    adding a field to the Generated constructor to indicate whether we
    still want to perform pattern-match checking. We also have to do a bit
    of plumbing with HsCase, to record that the HsCase arose from an
    HsExpansion of a RecUpd, so that the error message continues to mention
    record updates as opposed to a generic "incomplete pattern matches in case"
    error.
    
    Finally, this patch also changes the way we handle inaccessible code
    warnings. Commit e74fc066 was also a regression in this regard, as we
    were emitting "inaccessible code" warnings for case statements spuriously
    generated when desugaring a record update (remember: the desugaring mechanism
    happens before typechecking; it thus can't take into account e.g. GADT information
    in order to decide which constructors to include in the RHS of the desugaring
    of the record update).
    We fix this by changing the mechanism through which we disable inaccessible
    code warnings: we now check whether we are in generated code in
    GHC.Tc.Utils.TcMType.newImplication in order to determine whether to
    emit inaccessible code warnings.
    
    Fixes #23520
    Updates haddock submodule, to avoid incomplete record update warnings
    
    - - - - -
    1d05971e by sheaf at 2023-07-17T21:13:00-04:00
    Propagate long-distance information in do-notation
    
    The preceding commit re-enabled pattern-match checking inside record
    updates. This revealed that #21360 was in fact NOT fixed by e74fc066.
    
    This commit makes sure we correctly propagate long-distance information
    in do blocks, e.g. in
    
    ```haskell
    data T = A { fld :: Int } | B
    
    f :: T -> Maybe T
    f r = do
      a at A{} <- Just r
      Just $ case a of { A _ -> A 9 }
    ```
    
    we need to propagate the fact that "a" is headed by the constructor "A"
    to see that the case expression "case a of { A _ -> A 9 }" cannot fail.
    
    Fixes #21360
    
    - - - - -
    bea0e323 by sheaf at 2023-07-17T21:13:00-04:00
    Skip PMC for boring patterns
    
    Some patterns introduce no new information to the pattern-match
    checker (such as plain variable or wildcard patterns). We can thus
    skip doing any pattern-match checking on them when the sole purpose
    for doing so was introducing new long-distance information.
    
    See Note [Boring patterns] in GHC.Hs.Pat.
    
    Doing this avoids regressing in performance now that we do additional
    pattern-match checking inside do notation.
    
    - - - - -
    ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00
    Split GHC.Platform.ArchOS from ghc-boot into ghc-platform
    
    Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package
    into this reinstallable standalone package which abides by the PVP, in
    part motivated by the ongoing work on `ghc-toolchain` towards runtime
    retargetability.
    
    - - - - -
    b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00
    JS: better implementation for plusWord64 (#23597)
    
    - - - - -
    889c2bbb by sheaf at 2023-07-18T06:37:32-04:00
    Do primop rep-poly checks when instantiating
    
    This patch changes how we perform representation-polymorphism checking
    for primops (and other wired-in Ids such as coerce).
    When instantiating the primop, we check whether each type variable
    is required to instantiated to a concrete type, and if so we create a
    new concrete metavariable (a ConcreteTv) instead of a simple MetaTv.
    (A little subtlety is the need to apply the substitution obtained from
    instantiating to the ConcreteTvOrigins, see
    Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.)
    
    This allows us to prevent representation-polymorphism in non-argument
    position, as that is required for some of these primops.
    
    We can also remove the logic in tcRemainingValArgs, except for
    the part concerning representation-polymorphic unlifted newtypes.
    The function has been renamed rejectRepPolyNewtypes; all it does now
    is reject unsaturated occurrences of representation-polymorphic newtype
    constructors when the representation of its argument isn't a concrete
    RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check).
    The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head
    gives more explanation about a possible path to PHASE 2, which would be
    in line with the treatment for primops taken in this patch.
    
    We also update the Core Lint check to handle this new framework. This
    means Core Lint now checks representation-polymorphism in continuation
    position like needed for catch#.
    
    Fixes #21906
    
    -------------------------
    Metric Increase:
        LargeRecord
    -------------------------
    
    - - - - -
    00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00
    Core Lint: distinguish let and letrec in locations
    
    Lint messages were saying "in the body of letrec" even for non-recursive
    let.
    
    I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no
    separate letrec.
    
    - - - - -
    787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00
    Use extended literals when deriving Show
    
    This implements GHC proposal
    https://github.com/ghc-proposals/ghc-proposals/pull/596
    
    Also add support for Int64# and Word64#; see testcase ShowPrim.
    
    - - - - -
    257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00
    Add StgFromCore and StgCodeGen linting
    
    - - - - -
    34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00
    Reg.Liveness: Strictness
    
    - - - - -
    c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00
    Reg.Liveness: Don't repeatedly construct UniqSets
    
    - - - - -
    b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00
    compiler/Types: Ensure that fromList-type operations can fuse
    
    In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing
    it to do so makes a considerable difference in allocations due to the
    backend.
    
    Metric Decrease:
        T12707
        T13379
        T3294
        T4801
        T5321FD
        T5321Fun
        T783
    
    - - - - -
    6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00
    x86 Codegen: Implement MO_S_MulMayOflo for W16
    
    - - - - -
    5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00
    x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64
    
    It's useful to see which value made the pattern match fail. (If it ever
    occurs.)
    
    - - - - -
    e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00
    x86 CodeGen: Implement MO_S_MulMayOflo for W8
    
    This case wasn't handled before. But, the test-primops test suite showed
    that it actually might appear.
    
    - - - - -
    a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00
    Add test for %mulmayoflo primop
    
    The test expects a perfect implementation with no false positives.
    
    - - - - -
    38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00
    lint-ci-config: Generate jobs-metadata.json
    
    We also now save the jobs-metadata.json and jobs.yaml file as artifacts
    as:
    
    * It might be useful for someone who is modifying CI to copy jobs.yaml
      if they are having trouble regenerating locally.
    * jobs-metadata.json is very useful for downstream pipelines to work out
      the right job to download.
    
    Fixes #23654
    
    - - - - -
    1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00
    Initialize 9.10.1-notes.rst
    
    Create new release notes for the next GHC release (GHC 9.10)
    
    - - - - -
    3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00
    Prioritise Parent when looking up class sub-binder
    
    When we look up children GlobalRdrElts of a given Parent, we sometimes
    would rather prioritise those GlobalRdrElts which have the right Parent,
    and sometimes prioritise those that have the right NameSpace:
    
      - in export lists, we should prioritise NameSpace
      - for class/instance binders, we should prioritise Parent
    
    See Note [childGREPriority] in GHC.Types.Name.Reader.
    
    fixes #23664
    
    - - - - -
    9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00
    EPA: Improve annotation management in getMonoBind
    
    Ensure the LHsDecl for a FunBind has the correct leading comments and
    trailing annotations.
    
    See the added note for details.
    
    - - - - -
    ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00
    Remove unused files in .gitlab
    
    These were left over after 6078b429
    
    - - - - -
    29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00
    gen_ci: Add hie.yaml file
    
    This allows you to load `gen_ci.hs` into HLS, and now it is a huge
    module, that is quite useful.
    
    - - - - -
    808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00
    ci: Make "fast-ci" the default validate configuration
    
    We are trying out a lighter weight validation pipeline where by default
    we just test on 5 platforms:
    
    * x86_64-deb10-slow-validate
    * windows
    * x86_64-fedora33-release
    * aarch64-darwin
    * aarch64-linux-deb10
    
    In order to enable the "full" validation pipeline you can apply the
    `full-ci` label which will enable all the validation pipelines.
    
    All the validation jobs are still run on a marge batch.
    
    The goal is to reduce the overall CI capacity so that pipelines start
    faster for MRs and marge bot batches are faster.
    
    Fixes #23694
    
    - - - - -
    0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00
    EPA: Simplify GHC/Parser.y sL1
    
    This is the next patch in a series simplifying location management in
    GHC/Parser.y
    
    This one simplifies sL1, to use the HasLoc instances introduced in
    !10743 (closed)
    
    - - - - -
    3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00
    nativeGen: Explicitly set flags of text sections on Windows
    
    The binutils documentation (for COFF) claims,
    
    > If no flags are specified, the default flags depend upon the section
    > name. If the section name is not recognized, the default will be for the
    > section to be loaded and writable.
    
    We previously assumed that this would do the right thing for split
    sections (e.g. a section named `.text$foo` would be correctly inferred
    to be a text section). However, we have observed that this is not the
    case (at least under the clang toolchain used on Windows): when
    split-sections is enabled, text sections are treated by the assembler as
    data (matching the "default" behavior specified by the documentation).
    
    Avoid this by setting section flags explicitly. This should fix split
    sections on Windows.
    
    Fixes #22834.
    
    - - - - -
    db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00
    nativeGen: Set explicit section types on all platforms
    
    - - - - -
    b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00
    Insert documentation into parsed signature modules
    
    Causes haddock comments in signature modules to be properly
    inserted into the AST (just as they are for regular modules)
    if the `-haddock` flag is given.
    
    Also adds a test that compares `-ddump-parsed-ast` output
    for a signature module to prevent further regressions.
    
    Fixes #23315
    
    - - - - -
    c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00
    primops: Introduce unsafeThawByteArray#
    
    This addresses an odd asymmetry in the ByteArray# primops, which
    previously provided unsafeFreezeByteArray# but no corresponding
    thaw operation.
    
    Closes #22710
    
    - - - - -
    87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00
    testsuite: Elaborate in interface stability README
    
    This discussion didn't make it into the original MR.
    
    - - - - -
    e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00
    Allow users to override non-essential haddock options in a Flavour
    
    We now supply the non-essential options to haddock using the `extraArgs`
    field, which can be specified in a Flavour so that if an advanced user
    wants to change how documentation is generated then they can use
    something other than the `defaultHaddockExtraArgs`.
    
    This does have the potential to regress some packaging if a user has
    overridden `extraArgs` themselves, because now they also need to add
    the haddock options to extraArgs. This can easily be done by appending
    `defaultHaddockExtraArgs` to their extraArgs invocation but someone
    might not notice this behaviour has changed.
    
    In any case, I think passing the non-essential options in this manner is
    the right thing to do and matches what we do for the "ghc" builder,
    which by default doesn't pass any optmisation levels, and would likewise
    be very bad if someone didn't pass suitable `-O` levels for builds.
    
    Fixes #23625
    
    - - - - -
    fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00
    ghc-prim: Link against libatomic
    
    Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures.
    Unfortunately this made GHC to fail to build on armel, since armel needs
    libatomic to support atomic operations on 64-bit word sizes.
    
    Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic,
    the same way as we do in rts/rts.cabal.
    
    - - - - -
    4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00
    simplifier: Correct InScopeSet in rule matching
    
    The in-scope set passedto the `exprIsLambda_maybe` call lacked all the
    in-scope binders. @simonpj suggests this fix where we augment the
    in-scope set with the free variables of expression which fixes this
    failure mode in quite a direct way.
    
    Fixes #23630
    
    - - - - -
    5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00
    Add a test for #23413
    
    It was fixed by commit e1590ddc661d6: Add the SolverStage monad.
    
    - - - - -
    7e05f6df by sheaf at 2023-07-21T23:26:56-04:00
    Finish migration of diagnostics in GHC.Tc.Validity
    
    This patch finishes migrating the error messages in GHC.Tc.Validity
    to use the new diagnostic infrastructure.
    
    It also refactors the error message datatypes for class and family
    instances, to common them up under a single datatype as much as possible.
    
    - - - - -
    4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00
    ci: Enable some more jobs to run in a marge batch
    
    In !10907 I made the majority of jobs not run on a validate pipeline but
    then forgot to renable a select few jobs on the marge batch MR.
    
    - - - - -
    026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00
    user_guide/flags.py: python-3.12 no longer includes distutils
    
    packaging.version seems able to handle this fine
    
    - - - - -
    b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00
    ci: Mention ~full-ci label in MR template
    
    We mention that if you need a full validation pipeline then you can
    apply the ~full-ci label to your MR in order to test against the full
    validation pipeline (like we do for marge).
    
    - - - - -
    42b05e9b by sheaf at 2023-07-22T12:36:00-04:00
    RTS: declare setKeepCAFs symbol
    
    Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on
    the symbol setKeepCAFs in the RTS, which led to undefined symbol errors
    on Windows, as exhibited by the testcase frontend001.
    
    Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix.
    
    Fixes #22961
    
    - - - - -
    a72015d6 by sheaf at 2023-07-22T12:36:01-04:00
    Mark plugins-external as broken on Windows
    
    This test is broken on Windows, so we explicitly mark it as such now
    that we stop skipping plugin tests on Windows.
    
    - - - - -
    cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00
    Stop marking plugin tests as fragile on Windows
    
    Now that b2bb3e62 has landed we are in a better situation with
    regards to plugins on Windows, allowing us to unmark many plugin tests
    as fragile.
    
    Fixes #16405
    
    - - - - -
    a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00
    Misc cleanup
    
    - Remove unused RDR names
    - Fix typos in comments
    - Deriving: simplify boxConTbl and remove unused litConTbl
    - chmod -x GHC/Exts.hs, this seems accidental
    
    - - - - -
    33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00
    Visible forall in types of terms: Part 1 (#22326)
    
    This patch implements part 1 of GHC Proposal #281,
    introducing explicit `type` patterns and `type` arguments.
    
    Summary of the changes:
    
    1. New extension flag:
         RequiredTypeArguments
    
    2. New user-facing syntax:
         `type p` patterns    (represented by EmbTyPat)
         `type e` expressions (represented by HsEmbTy)
    
    3. Functions with required type arguments (visible forall)
       can now be defined and applied:
          idv :: forall a -> a -> a    -- signature   (relevant change: checkVdqOK in GHC/Tc/Validity.hs)
          idv (type a) (x :: a) = x    -- definition  (relevant change: tcPats in GHC/Tc/Gen/Pat.hs)
          x = idv (type Int) 42        -- usage       (relevant change: tcInstFun in GHC/Tc/Gen/App.hs)
    
    4. template-haskell support:
          TH.TypeE corresponds to HsEmbTy
          TH.TypeP corresponds to EmbTyPat
    
    5. Test cases and a new User's Guide section
    
    Changes *not* included here are the t2t (term-to-type) transformation
    and term variable capture; those belong to part 2.
    
    - - - - -
    73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00
    Add test for #22424
    
    This is a simple Template Haskell test in which we refer to
    record selectors by their exact Names, in two different ways.
    
    Fixes #22424
    
    - - - - -
    83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00
    ghc-toolchain: Initial commit
    
    - - - - -
    31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
    ghc-toolchain: Toolchain Selection
    
    This commit integrates ghc-toolchain, the brand new way of configuring
    toolchains for GHC, with the Hadrian build system, with configure, and
    extends and improves the first iteration of ghc-toolchain.
    
    The general overview is
    
    * We introduce a program invoked `ghc-toolchain --triple=...` which, when run,
      produces a file with a `Target`. A `GHC.Toolchain.Target.Target`
      describes the properties of a target and the toolchain (executables
      and configured flags) to produce code for that target
    
    * Hadrian was modified to read Target files, and will both
      * Invoke the toolchain configured in the Target file as needed
      * Produce a `settings` file for GHC based on the Target file for that stage
    
    * `./configure` will invoke ghc-toolchain to generate target files, but
      it will also generate target files based on the flags configure itself
      configured (through `.in` files that are substituted)
    
      * By default, the Targets generated by configure are still (for now) the ones used by Hadrian
    
      * But we additionally validate the Target files generated by
        ghc-toolchain against the ones generated by configure, to get a head
        start on catching configuration bugs before we transition
        completely.
    
      * When we make that transition, we will want to drop a lot of the
        toolchain configuration logic from configure, but keep it otherwise.
    
    * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine)
      * We just have a HOST target file, which we use as the target for stage0
      * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling)
      * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST
      * (for more details on cross-compilation see discussion on !9263)
    
    See also
    * Note [How we configure the bundled windows toolchain]
    * Note [ghc-toolchain consistency checking]
    * Note [ghc-toolchain overview]
    
    Ticket: #19877
    MR: !9263
    
    - - - - -
    a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
    Add flag to enable/disable ghc-toolchain based configurations
    
    This flag is disabled by default, and we'll use the
    configure-generated-toolchains by default until we remove the toolchain
    configuration logic from configure.
    
    - - - - -
    61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
    Split ghc-toolchain executable to new packge
    
    In light of #23690, we split the ghc-toolchain executable out of the
    library package to be able to ship it in the bindist using Hadrian.
    
    Ideally, we eventually revert this commit.
    
    - - - - -
    38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
    Ship ghc-toolchain in the bindist
    
    Add the ghc-toolchain binary to the binary distribution we ship to
    users, and teach the bindist configure to use the existing ghc-toolchain.
    
    - - - - -
    32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00
    Kill off gen_bytearray_addr_access_ops.py
    
    The relevant primop descriptions are now
    generated directly by genprimopcode.
    
    This makes progress toward fixing #23490, but it is not
    a complete fix since there is more than one way in which
    cabal-reinstall (hadrian/build build-cabal) is broken.
    
    - - - - -
    02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00
    compiler: Remove unused `containers.h` include
    
    Fixes #23712
    
    - - - - -
    822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00
    Fix pretty printing of WARNING pragmas
    
    There is still something quite unsavoury going on with WARNING pragma
    printing because the printing relies on the fact that for decl
    deprecations the SourceText of WarningTxt is empty. However, I let that
    lion sleep and just fixed things directly.
    
    Fixes #23465
    
    - - - - -
    e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00
    ci-images: Bump to commit which has 9.6 image
    
    The test-bootstrap job has been failing for 9.6 because we accidentally
    used a non-master commit.
    
    - - - - -
    bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00
    Update bootstrap plans for 9.6.2 and 9.4.5
    
    - - - - -
    355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00
    EPA: Simplify GHC/Parser.y comb4/comb5
    
    Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with
    anything with a SrcSpan
    
    Also get rid of some more now unnecessary reLoc calls.
    
    - - - - -
    9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00
    compiler: make -ddump-asm work with wasm backend NCG
    
    Fixes #23503.
    
    Now the `-ddump-asm` flag is respected in the wasm backend
    NCG, so developers can directly view the generated ASM instead of
    needing to pass `-S` or `-keep-tmp-files` and manually find & open
    the assembly file.
    
    Ideally, we should be able to output the assembly files in smaller
    chunks like in other NCG backends. This would also make dumping assembly
    stats easier. However, this would require a large refactoring, so for
    short-term debugging purposes I think the current approach works fine.
    
    Signed-off-by: Gavin Zhao <git at gzgz.dev>
    
    - - - - -
    79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00
    llvm: Restore accidentally deleted code in 0fc5cb97
    
    Fixes #23711
    
    - - - - -
    20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00
    configure: Default missing options to False when preparing ghc-toolchain Targets
    
    This commit fixes building ghc with 9.2 as the boostrap compiler.
    
    The ghc-toolchain patch assumed all _STAGE0 options were available, and
    forgot to account for this missing information in 9.2.
    
    Ghc 9.2 does not have in settings whether ar supports -l, hence can't
    report it with --info (unliked 9.4 upwards).
    
    The fix is to default the missing information (we default "ar supports
    -l" and other missing options to False)
    
    - - - - -
    fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00
    docs: Fix typo
    - - - - -
    503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00
    This MR is an implementation of the proposal #516.
    
    It adds a warning -Wincomplete-record-selectors for usages of a record
    field access function (either a record selector or getField @"rec"),
    while trying to silence the warning whenever it can be sure that a constructor
    without the record field would not be invoked (which would otherwise cause
    the program to fail). For example:
    
        data T = T1 | T2 {x :: Bool}
    
        f a = x a -- this would throw an error
    
        g T1 = True
        g a = x a -- this would not throw an error
    
        h :: HasField "x" r Bool => r -> Bool
        h = getField @"x"
    
        j :: T -> Bool
        j = h -- this would throw an error because of the `HasField`
              -- constraint being solved
    
    See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning.
    See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details
    
    - - - - -
    af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00
    Fix user-facing label in MR template
    
    - - - - -
    5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00
    ci: Test bootstrapping configurations with full-ci and on marge batches
    
    There have been two incidents recently where bootstrapping has been
    broken by removing support for building with 9.2.*.
    
    The process for bumping the minimum required version starts with bumping
    the configure version and then other CI jobs such as the bootstrap jobs
    have to be updated. We must not silently bump the minimum required
    version.
    
    Now we are running a slimmed down validate pipeline it seems worthwile
    to test these bootstrap configurations in the full-ci pipeline.
    
    - - - - -
    25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00
    bootstrap: Remove ghc-9_2_* plans
    
    We are anticipating shortly making it necessary to use ghc-9.4 to boot
    the compiler.
    
    - - - - -
    2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00
    Update bootstrap plans for ghc-platform and ghc-toolchain dependencies
    
    Fixes #23735
    
    - - - - -
    c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00
    bootstrap: Disable -selftest flag from bootstrap plans
    
    This saves on building one dependency (QuickCheck) which is unecessary
    for bootstrapping.
    
    - - - - -
    a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00
    Link reference paper and package from System.Mem.{StableName,Weak}
    
    - - - - -
    a5319358 by David Knothe at 2023-07-28T13:13:10-04:00
    Update Match Datatype
    
    EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation.
    All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list.
    We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows:
    
    data EquationInfo
        = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo }
        | EqnDone { eqn_rhs = MatchResult CoreExpr }
    
    An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated.
    
    - - - - -
    86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00
    Improve documentation for Data.Fixed
    
    - - - - -
    f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00
    ghc-prim: Use C11 atomics
    
    Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*`
    family of C builtins. Here we refactor these to rather use the
    appropriate C11 atomic equivalents, allowing us to be more explicit
    about the expected ordering semantics.
    
    - - - - -
    0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00
    Include -haddock in DynFlags fingerprint
    
    The -haddock flag determines whether or not the resulting .hi files
    contain haddock documentation strings. If the existing .hi files do
    not contain haddock documentation strings and the user requests them,
    we should recompile.
    
    - - - - -
    40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00
    Bump filepath submodule to 1.4.100.4
    
    Resolves #23741
    
    Metric Decrease:
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModules
        MultiLayerModulesRecomp
        T10421
        T12234
        T12425
        T13035
        T13701
        T13719
        T16875
        T18304
        T18698a
        T18698b
        T21839c
        T9198
        TcPlugin_RewritePerf
        hard_hole_fits
    
    Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183
    
    - - - - -
    ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00
    Add since pragmas to GHC.IO.Handle.FD
    
    - - - - -
    d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00
    Make the occurrence analyser smarter about join points
    
    This MR addresses #22404.  There is a big Note
    
       Note [Occurrence analysis for join points]
    
    that explains it all.  Significant changes
    
    * New field occ_join_points in OccEnv
    
    * The NonRec case of occAnalBind splits into two cases:
      one for existing join points (which does the special magic for
      Note [Occurrence analysis for join points], and one for other
      bindings.
    
    * mkOneOcc adds in info from occ_join_points.
    
    * All "bring into scope" activity is centralised in the
      new function `addInScope`.
    
    * I made a local data type LocalOcc for use inside the occurrence analyser
      It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn
      makes computationns over it simpler and more efficient.
    
    * I found quite a bit of allocation in GHC.Core.Rules.getRules
      so I optimised it a bit.
    
    More minor changes
    
    * I found I was using (Maybe Arity) a lot, so I defined a new data
      type JoinPointHood and used it everwhere.  This touches a lot of
      non-occ-anal files, but it makes everything more perspicuous.
    
    * Renamed data constructor WithUsageDetails to WUD, and
      WithTailUsageDetails to WTUD
    
    This also fixes #21128, on the way.
    
    --------- Compiler perf -----------
    I spent quite a time on performance tuning, so even though it
    does more than before, the occurrence analyser runs slightly faster
    on average.  Here are the compile-time allocation changes over 0.5%
    
          CoOpt_Read(normal) ghc/alloc    766,025,520    754,561,992  -1.5%
    CoOpt_Singletons(normal) ghc/alloc    759,436,840    762,925,512  +0.5%
         LargeRecord(normal) ghc/alloc  1,814,482,440  1,799,530,456  -0.8%
           PmSeriesT(normal) ghc/alloc     68,159,272     67,519,720  -0.9%
              T10858(normal) ghc/alloc    120,805,224    118,746,968  -1.7%
              T11374(normal) ghc/alloc    164,901,104    164,070,624  -0.5%
              T11545(normal) ghc/alloc     79,851,808     78,964,704  -1.1%
              T12150(optasm) ghc/alloc     73,903,664     71,237,544  -3.6% GOOD
              T12227(normal) ghc/alloc    333,663,200    331,625,864  -0.6%
              T12234(optasm) ghc/alloc     52,583,224     52,340,344  -0.5%
              T12425(optasm) ghc/alloc     81,943,216     81,566,720  -0.5%
              T13056(optasm) ghc/alloc    294,517,928    289,642,512  -1.7%
          T13253-spj(normal) ghc/alloc    118,271,264     59,859,040 -49.4% GOOD
              T15164(normal) ghc/alloc  1,102,630,352  1,091,841,296  -1.0%
              T15304(normal) ghc/alloc  1,196,084,000  1,166,733,000  -2.5%
              T15630(normal) ghc/alloc    148,729,632    147,261,064  -1.0%
              T15703(normal) ghc/alloc    379,366,664    377,600,008  -0.5%
              T16875(normal) ghc/alloc     32,907,120     32,670,976  -0.7%
              T17516(normal) ghc/alloc  1,658,001,888  1,627,863,848  -1.8%
              T17836(normal) ghc/alloc    395,329,400    393,080,248  -0.6%
              T18140(normal) ghc/alloc     71,968,824     73,243,040  +1.8%
              T18223(normal) ghc/alloc    456,852,568    453,059,088  -0.8%
              T18282(normal) ghc/alloc    129,105,576    131,397,064  +1.8%
              T18304(normal) ghc/alloc     71,311,712     70,722,720  -0.8%
             T18698a(normal) ghc/alloc    208,795,112    210,102,904  +0.6%
             T18698b(normal) ghc/alloc    230,320,736    232,697,976  +1.0%  BAD
              T19695(normal) ghc/alloc  1,483,648,128  1,504,702,976  +1.4%
              T20049(normal) ghc/alloc     85,612,024     85,114,376  -0.6%
             T21839c(normal) ghc/alloc    415,080,992    410,906,216  -1.0% GOOD
               T4801(normal) ghc/alloc    247,590,920    250,726,272  +1.3%
               T6048(optasm) ghc/alloc     95,699,416     95,080,680  -0.6%
                T783(normal) ghc/alloc    335,323,384    332,988,120  -0.7%
               T9233(normal) ghc/alloc    709,641,224    685,947,008  -3.3% GOOD
               T9630(normal) ghc/alloc    965,635,712    948,356,120  -1.8%
               T9675(optasm) ghc/alloc    444,604,152    428,987,216  -3.5% GOOD
               T9961(normal) ghc/alloc    303,064,592    308,798,800  +1.9%  BAD
               WWRec(normal) ghc/alloc    503,728,832    498,102,272  -1.1%
    
                   geo. mean                                          -1.0%
                   minimum                                           -49.4%
                   maximum                                            +1.9%
    
    In fact these figures seem to vary between platforms; generally worse
    on i386 for some reason.  The Windows numbers vary by 1% espec in
    benchmarks where the total allocation is low. But the geom mean stays
    solidly negative, which is good.  The "increase/decrease" list below
    covers all platforms.
    
    The big win on T13253-spj comes because it has a big nest of join
    points, each occurring twice in the next one.  The new occ-anal takes
    only one iteration of the simplifier to do the inlining; the old one
    took four.  Moreover, we get much smaller code with the new one:
    
      New: Result size of Tidy Core
        = {terms: 429, types: 84, coercions: 0, joins: 14/14}
    
      Old: Result size of Tidy Core
        = {terms: 2,437, types: 304, coercions: 0, joins: 10/10}
    
    --------- Runtime perf -----------
    No significant changes in nofib results, except a 1% reduction in
    compiler allocation.
    
    Metric Decrease:
        CoOpt_Read
        T13253-spj
        T9233
        T9630
        T9675
        T12150
        T21839c
        LargeRecord
        MultiComponentModulesRecomp
        T10421
        T13701
        T10421
        T13701
        T12425
    
    Metric Increase:
        T18140
        T9961
        T18282
        T18698a
        T18698b
        T19695
    
    - - - - -
    42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00
    Improve documentation around IOException and ioe_filename
    
    See:
    
    * https://github.com/haskell/core-libraries-committee/issues/189
    * https://github.com/haskell/unix/pull/279
    * https://github.com/haskell/unix/pull/289
    
    - - - - -
    33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00
    JS: implement getMonotonicTime (fix #23687)
    
    - - - - -
    d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00
    Implementation of the Deprecated Instances proposal #575
    
    This commit implements the ability to deprecate certain instances,
    which causes the compiler to emit the desired deprecation message
    whenever they are instantiated. For example:
    
      module A where
      class C t where
      instance {-# DEPRECATED "dont use" #-} C Int where
    
      module B where
      import A
      f :: C t => t
      f = undefined
      g :: Int
      g = f -- "dont use" emitted here
    
    The implementation is as follows:
      - In the parser, we parse deprecations/warnings attached to instances:
    
          instance {-# DEPRECATED "msg" #-} Show X
          deriving instance {-# WARNING "msg2" #-} Eq Y
    
        (Note that non-standalone deriving instance declarations do not support
        this mechanism.)
    
      - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`).
        In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`),
        we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too).
    
      - Finally, when we solve a constraint using such an instance, in
        `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning
        that was stored in `ClsInst`.
        Note that we only emit a warning when the instance is used in a different module
        than it is defined, which keeps the behaviour in line with the deprecation of
        top-level identifiers.
    
    Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>
    
    - - - - -
    d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00
    compiler: Style fixes
    
    - - - - -
    7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Fix implicit cast
    
    This ensures that Task.h can be built with a C++ compiler.
    
    - - - - -
    d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00
    testsuite: Fix warning in hs_try_putmvar001
    
    - - - - -
    d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00
    testsuite: Add AtomicModifyIORef test
    
    - - - - -
    f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Introduce NO_WARN macro
    
    This allows fine-grained ignoring of warnings.
    
    - - - - -
    497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Simplify atomicModifyMutVar2# implementation
    
    Previously we would perform a redundant load in the non-threaded RTS in
    atomicModifyMutVar2# implementation for the benefit of the non-moving
    GC's write barrier. Eliminate this.
    
    - - - - -
    52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Introduce more principled fence operations
    
    - - - - -
    cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Introduce SET_INFO_RELAXED
    
    - - - - -
    6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Style fixes
    
    - - - - -
    4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00
    codeGen/tsan: Rework handling of spilling
    
    - - - - -
    f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00
    hadrian: More debug information
    
    - - - - -
    df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00
    Improve TSAN documentation
    
    - - - - -
    fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00
    hadrian: More selective TSAN instrumentation
    
    - - - - -
    465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00
    EPA: Provide correct annotation span for ImportDecl
    
    Use the whole declaration, rather than just the span of the 'import'
    keyword.
    
    Metric Decrease:
       T9961
       T5205
    Metric Increase:
      T13035
    
    - - - - -
    ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00
    Add cases to T23279: HasField for deprecated record fields
    
    This commit adds additional tests from ticket #23279 to ensure that we don't
    regress on reporting deprecated record fields in conjunction with HasField,
    either when using overloaded record dot syntax or directly through `getField`.
    
    Fixes #23279
    
    - - - - -
    00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00
    AArch NCG: Pure refactor
    
    Combine some alternatives. Add some line breaks for overly long lines
    
    - - - - -
    8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    74a882dc by MorrowM at 2023-08-02T06:00:03-04:00
    Add a RULE to make lookup fuse
    
    See https://github.com/haskell/core-libraries-committee/issues/175
    
    Metric Increase:
        T18282
    
    - - - - -
    cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00
    hadrian: Ensure that way-flags are passed to CC
    
    Previously the way-specific compilation flags (e.g. `-DDEBUG`,
    `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant
    that C dependency files would not correctly reflect
    dependencies predicated on the way, resulting in the rather
    painful #23554.
    
    Closes #23554.
    
    - - - - -
    622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00
    Native 32-bit Enum Int64/Word64 instances
    
    This commits adds more performant Enum Int64 and Enum Word64 instances
    for 32-bit platforms, replacing the Integer-based implementation.
    
    These instances are a copy of the Enum Int and Enum Word instances with
    minimal changes to manipulate Int64 and Word64 instead.
    
    On i386 this yields a 1.5x performance increase and for the JavaScript
    back end it even yields a 5.6x speedup.
    
    Metric Decrease:
        T18964
    
    - - - - -
    c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00
    JS: fix typos in constants (#23650)
    
    - - - - -
    b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00
    JavaScript: update MK_TUP macros to use current tuple constructors (#23659)
    
    - - - - -
    28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00
    ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job
    
    Warnings when building Hadrian can end up cluttering the output of HLS,
    and we've had bug reports in the past about these warnings when building
    Hadrian. It would be nice to turn on -Werror on at least one build of
    Hadrian in CI to avoid a patch introducing warnings when building
    Hadrian.
    
    Fixes #23638
    
    - - - - -
    aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00
    codeGen: Ensure that TSAN is aware of writeArray# write barriers
    
    By using a proper release store instead of a fence.
    
    - - - - -
    453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00
    codeGen: Ensure that array reads have necessary barriers
    
    This was the cause of #23541.
    
    - - - - -
    93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00
    Add test for #23550
    
    - - - - -
    6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00
    Desugar non-recursive lets to non-recursive lets (take 2)
    
    This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And
    takes care of the case that I missed in my previous attempt. Namely
    the case of an AbsBinds with no type variables and no dictionary
    variable.
    
    Ironically, the comment explaining why non-recursive lets were
    desugared to recursive lets were pointing specifically at this case
    as the reason. I just failed to understand that it was until Simon PJ
    pointed it out to me.
    
    See #23550 for more discussion.
    
    - - - - -
    ff81d53f by jade at 2023-08-02T06:05:20-04:00
    Expand documentation of List & Data.List
    
    This commit aims to improve the documentation and examples
    of symbols exported from Data.List
    
    - - - - -
    fa4e5913 by Jade at 2023-08-02T06:06:03-04:00
    Improve documentation of Semigroup & Monoid
    
    This commit aims to improve the documentation of various symbols
    exported from Data.Semigroup and Data.Monoid
    
    - - - - -
    e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00
    Desugar bindings in the context of their evidence
    
    Closes #23172
    
    - - - - -
    481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00
    Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of
    incoherent instances
    
    Fixes #23287
    
    - - - - -
    d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00
    base: Improve String & IsString documentation
    
    - - - - -
    01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00
    rts/win32: Ensure reliability of IO manager shutdown
    
    When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an
    `IO_MANAGER_DIE` event to the IO manager thread using the
    `io_manager_event` event object. Finally, it will closes the event object,
    and invalidate `io_manager_event`.
    
    Previously, `readIOManagerEvent` would see that `io_manager_event` is
    invalid and return `0`, suggesting that everything is right with the
    world. This meant that if `ioManagerDie` invalidated the handle before
    the event manager was blocked on the event we would end up in a
    situation where the event manager would never realize it was asked to
    shut down.
    
    Fix this by ensuring that `readIOManagerEvent` instead returns
    `IO_MANAGER_DIE` when we detect that the event object has been
    invalidated by `ioManagerDie`.
    
    Fixes #23691.
    
    - - - - -
    fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00
    Look through TH splices in splitHsApps
    
    This modifies `splitHsApps` (a key function used in typechecking function
    applications) to look through untyped TH splices and quasiquotes. Not doing so
    was the cause of #21077. This builds on !7821 by making `splitHsApps` match on
    `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as
    part of invoking the TH splice. See the new `Note [Looking through Template
    Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`.
    
    Along the way, I needed to make the type of `splitHsApps.set` slightly more
    general to accommodate the fact that the location attached to a quasiquote is
    a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`.
    
    Fixes #21077.
    
    - - - - -
    e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00
    Bump deepseq submodule to 1.5.
    
    And bump bounds
    
    (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b)
    
    - - - - -
    cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00
    configure: Bump minimal boot GHC version to 9.4
    
    (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e)
    
    - - - - -
    83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00
    template-haskell: Bump version to 2.21.0.0
    
    Bumps exceptions submodule.
    
    (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb)
    
    - - - - -
    1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00
    base: Bump version to 4.19
    
    Updates all boot library submodules.
    
    (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143)
    
    - - - - -
    3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00
    testsuite: Normalise versions more aggressively
    
    In backpack hashes can contain `+` characters.
    
    (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93)
    
    - - - - -
    d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00
    testsuite: Declare bkpcabal08 as fragile
    
    Due to spurious output changes described in #23648.
    
    (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b)
    
    - - - - -
    e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00
    gitlab-ci: Only mark linker_unload_native as broken in static jobs
    
    This test passes on dynamically-linked Alpine.
    
    (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87)
    
    - - - - -
    8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00
    testsuite: Update base-exports
    
    - - - - -
    4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00
    testsuite/interface-stability: normalise versions
    
    This eliminates spurious changes from version bumps.
    
    - - - - -
    0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00
    linker/PEi386: Don't sign-extend symbol section number
    
    Previously we incorrectly interpreted PE section numbers as signed
    values. However, this isn't the case; rather, it's an unsigned 16-bit number
    with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941
    as the linker would conclude that the sections were invalid.
    
    Fixing this required quite a bit of refactoring.
    
    Closes #22941.
    
    - - - - -
    fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00
    testsuite: Mark MulMayOflo_full as broken rather than skipping
    
    To ensure that we don't accidentally fix it.
    
    See #23742.
    
    - - - - -
    824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00
    nativeGen/AArch64: Fix sign extension in MulMayOflo
    
    Previously the 32-bit implementations of MulMayOflo would use the
    a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11
    produces. Also similarly rework the 16- and 8-bit cases.
    
    This now passes the MulMayOflo tests in ghc/test-primops> in all four
    widths, including the precision tests.
    
    Fixes #23721.
    
    - - - - -
    1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00
    Fix haddock markup in code example for coerce
    
    - - - - -
    46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00
    Fix (~) and (@) infix operators in TH splices (#23748)
    
    8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept
    the following infix operators:
    
    	a ~ b = ()
    	a @ b = ()
    
    But not if TH is used to generate those declarations:
    
    	$([d| a ~ b = ()
    	      a @ b = ()
    	    |])
    
    	-- Test.hs:5:2: error: [GHC-55017]
    	--    Illegal variable name: ‘~’
    	--    When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.()
    
    This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme
    
    - - - - -
    a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00
    [#23663] Show Flag Suggestions in GHCi
    
    Makes suggestions when using `:set` in GHCi with a misspelled flag. This
    mirrors how invalid flags are handled when passed to GHC directly. Logic
    for producing flag suggestions was moved to GHC.Driver.Sesssion so it
    can be shared.
    
    resolves #23663
    
    - - - - -
    03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00
    Improve ghc-toolchain validation configure warning
    
    Fixes the layout of the ghc-toolchain validation warning produced by
    configure.
    
    - - - - -
    de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00
    EPA make getLocA a synonym for getHasLoc
    
    This is basically a no-op change, but allows us to make future changes
    that can rely on the HasLoc instances
    
    And I presume this means we can use more precise functions based on
    class resolution, so the Windows CI build reports
    
    Metric Decrease:
        T12234
        T13035
    
    - - - - -
    3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00
    ghc-platform: Add upper bound on base
    
    Hackage upload requires this.
    - - - - -
    8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00
    Adjust and clarify handling of primop effects
    
    Fixes #17900; fixes #20195.
    
    The existing "can_fail" and "has_side_effects" primop attributes
    that previously governed this were used in inconsistent and
    confusingly-documented ways, especially with regard to raising
    exceptions.  This patch replaces them with a single "effect"
    attribute, which has four possible values: NoEffect, CanFail,
    ThrowsException, and ReadWriteEffect.  These are described in
    Note [Classifying primop effects].
    
    A substantial amount of related documentation has been re-drafted
    for clarity and accuracy.
    
    In the process of making this attribute format change for literally
    every primop, several existing mis-classifications were detected and
    corrected.  One of these mis-classifications was tagToEnum#, which
    is now considered CanFail; this particular fix is known to cause a
    regression in performance for derived Enum instances.  (See #23782.)
    Fixing this is left as future work.
    
    New primop attributes "cheap" and "work_free" were also added,
    and used in the corresponding parts of GHC.Core.Utils.
    
    In view of their actual meaning and uses, `primOpOkForSideEffects`
    and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard`
    and `exprOkToDiscard`, respectively.
    
    Metric Increase:
        T21839c
    
    - - - - -
    41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00
    Update inert_solved_dicts for ImplicitParams
    
    When adding an implicit parameter dictionary to the inert set, we must
    make sure that it replaces any previous implicit parameter dictionaries
    that overlap, in order to get the appropriate shadowing behaviour, as in
    
      let ?x = 1 in let ?x = 2 in ?x
    
    We were already doing this for inert_cans, but we weren't doing the same
    thing for inert_solved_dicts, which lead to the bug reported in #23761.
    
    The fix is thus to make sure that, when handling an implicit parameter
    dictionary in updInertDicts, we update **both** inert_cans and
    inert_solved_dicts to ensure a new implicit parameter dictionary
    correctly shadows old ones.
    
    Fixes #23761
    
    - - - - -
    43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00
    Bump bytestring submodule to 0.11.5.1
    
    - - - - -
    91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00
    Initial commit of Note [Thunks, blackholes, and indirections]
    
    This Note attempts to summarize the treatment of thunks, thunk update,
    and indirections.
    
    This fell out of work on #23185.
    
    - - - - -
    8d686854 by sheaf at 2023-08-05T01:06:54-04:00
    Remove zonk in tcVTA
    
    This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its
    accompanying Note [Visible type application zonk]. Indeed, this zonk
    is no longer necessary, as we no longer maintain the invariant that
    types are well-kinded without zonking; only that typeKind does not
    crash; see Note [The Purely Kinded Type Invariant (PKTI)].
    
    This commit removes this zonking step (as well as a secondary zonk),
    and replaces the aforementioned Note with the explanatory
    Note [Type application substitution], which justifies why the
    substitution performed in tc_inst_forall_arg remains valid without
    this zonking step.
    
    Fixes #23661
    
    - - - - -
    19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00
    Bump nofib submodule
    
    Ensuring that nofib can be build using the same range of bootstrap
    compilers as GHC itself.
    
    - - - - -
    aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00
    JS: Improve compatibility with recent emsdk
    
    The JavaScript code in libraries/base/jsbits/base.js had some
    hardcoded offsets for fields in structs, because we expected
    the layout of the data structures to remain unchanged. Emsdk
    3.1.42 changed the layout of the stat struct, breaking this
    assumption, and causing code in .hsc files accessing the
    stat struct to fail.
    
    This patch improves compatibility with recent emsdk by
    removing the assumption that data layouts stay unchanged:
    
        1. offsets of fields in structs used by JavaScript code are
           now computed by the configure script, so both the .js and
           .hsc files will automatically use the new layout if anything
           changes.
        2. the distrib/configure script checks that the emsdk version
           on a user's system is the same version that a bindist was
           booted with, to avoid data layout inconsistencies
    
    See #23641
    
    - - - - -
    b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00
    JS: Fix missing local variable declarations
    
    This fixes some missing local variable declarations that were
    found by running the testsuite in strict mode.
    
    Fixes #23775
    
    - - - - -
    6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00
    Update Haddock submodule to fix #23368
    
    This submodule update adds the following three commits:
    
    bbf1c8ae - Check for puns
    0550694e - Remove fake exports for (~), List, and Tuple<n>
    5877bceb - Fix pretty-printing of Solo and MkSolo
    
    These commits fix the issues with Haddock HTML rendering reported in
    ticket #23368.
    
    Fixes #23368
    
    - - - - -
    5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00
    Revert "Bump bytestring submodule to 0.11.5.1"
    
    This reverts commit 43578d60bfc478e7277dcd892463cec305400025.
    
    Fixes #23789
    
    - - - - -
    01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00
    configure: Derive library version from ghc-prim.cabal.in
    
    Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon
    it.
    
    Closes #23726.
    
    - - - - -
    3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00
    tcExpr: Push expected types for untyped TH splices inwards
    
    In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much
    simpler case that simply delegates to `tcApp`. Although this passed the test
    suite at the time, this was actually an error, as the previous `tcExpr` case
    was critically pushing the expected type inwards. This actually matters for
    programs like the one in #23796, which GHC would not accept with type inference
    alone—we need full-blown type _checking_ to accept these.
    
    I have added back the previous `tcExpr` case for `HsUntypedSplice` and now
    explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and
    another in `splitHsApps`) in `Note [Looking through Template Haskell splices in
    splitHsApps]` in `GHC.Tc.Gen.Head`.
    
    Fixes #23796.
    
    - - - - -
    0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00
    Compute all emitted diagnostic codes
    
    This commit introduces in GHC.Types.Error.Codes the function
    
      constructorCodes :: forall diag. (...) => Map DiagnosticCode String
    
    which computes a collection of all the diagnostic codes that correspond
    to a particular type. In particular, we can compute the collection of
    all diagnostic codes emitted by GHC using the invocation
    
      constructorCodes @GhcMessage
    
    We then make use of this functionality in the new "codes" test which
    checks consistency and coverage of GHC diagnostic codes.
    It performs three checks:
    
      - check 1: all non-outdated GhcDiagnosticCode equations
        are statically used.
      - check 2: all outdated GhcDiagnosticCode equations
        are statically unused.
      - check 3: all statically used diagnostic codes are covered by
        the testsuite (modulo accepted exceptions).
    
    - - - - -
    4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00
    numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int)
    
    Currently a negative exponent less than `minBound :: Int` results in
    Infinity, which is very surprising and obviously wrong.
    
    ```
    λ> read "1e-9223372036854775808" :: Double
    0.0
    λ> read "1e-9223372036854775809" :: Double
    Infinity
    ```
    
    There is a further edge case where the exponent can overflow when
    increased by the number of tens places in the integer part, or
    underflow when decreased by the number of leading zeros in the
    fractional part if the integer part is zero:
    
    ```
    λ> read "10e9223372036854775807" :: Double
    0.0
    λ> read "0.01e-9223372036854775808" :: Double
    Infinity
    ```
    
    To resolve both of these issues, perform all arithmetic and
    comparisons involving the exponent in type `Integer`.  This approach
    also eliminates the need to explicitly check the exponent against
    `maxBound :: Int` and `minBound :: Int`, because the allowed range
    of the exponent (i.e. the result of `floatRange` for the target
    floating point type) is certainly within those bounds.
    
    This change implements CLC proposal 192:
    https://github.com/haskell/core-libraries-committee/issues/192
    
    - - - - -
    6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00
    EPA: Remove Location from WarningTxt source
    
    This is not needed.
    
    - - - - -
    1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00
    Cleanup a TODO introduced in 1f94e0f7
    
    The change must have slipped through review of !4412
    
    - - - - -
    2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00
    More explicit strictness in GHC.Real
    
    - - - - -
    ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00
    exprIsTrivial: Factor out shared implementation
    
    The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has
    been bugging me for a long time.
    
    This patch introduces an inlinable worker function `trivial_expr_fold` acting
    as the single, shared decision procedure of triviality. It "returns" a
    Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar
    code as before.
    (Better code, even, in the case of `getIdFromTrivialExpr` which presently
    allocates a `Just` constructor that cancels away after this patch.)
    
    - - - - -
    d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Simplify: Simplification of arguments in a single function
    
    The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`,
    which seems to be the main way to simplify args. Hence I consolidated the code
    path to call `simplArg`, too, renaming to `simplLazyArg`.
    
    - - - - -
    8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Core.Ppr: Omit case binder for empty case alternatives
    
    A minor improvement to pretty-printing
    
    - - - - -
    d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend
    
    ... because those coerce between incompatible/unknown PrimReps.
    
    - - - - -
    f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Inlining literals into boring contexts is OK
    
    - - - - -
    4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Clarify floating of unsafeEqualityProofs (#23754)
    
    - - - - -
    b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Kill SetLevel.notWorthFloating.is_triv (#23270)
    
    We have had it since b84ba676034, when it operated on annotated expressions.
    Nowadays it operates on vanilla `CoreExpr` though, so we should just call
    `exprIsTrivial`; thus handling empty cases and string literals correctly.
    
    - - - - -
    7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00
    ANFise string literal arguments (#23270)
    
    This instates the invariant that a trivial CoreExpr translates to an atomic
    StgExpr. Nice.
    
    Annoyingly, in -O0 we sometimes generate
    ```
    foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat }
    ```
    which makes it a bit harder to spot that we can emit a standard
    `stg_unpack_cstring` thunk.
    
    Fixes #23270.
    
    - - - - -
    357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345)
    
    - - - - -
    59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead
    
    We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now.
    The main reason is that it plays far better in conjunction with eta expansion
    (as we aim to do for arguments in CorePrep, #23083), because we can discard
    any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta`
    it's impossible to discard the argument.
    
    We do also give the same treatment to unsafeCoerce proofs and treat them as
    trivial iff their RHS is trivial.
    
    It is also both much simpler to describe than the previous mechanism of emitting
    an unsafe coercion and simpler to implement, removing quite a bit of commentary
    and `CorePrepProv`.
    
    In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier
    iteration due to #17910. E.g., FloatOut produces a binding
    ```
    lvl_s6uK [Occ=Once1] :: GHC.Types.Int
    [LclId]
    lvl_s6uK = GHC.Types.I# 2#
    
    lvl_s6uL [Occ=Once1] :: GHC.Types.Any
    [LclId]
    lvl_s6uL
      = case Unsafe.Coerce.unsafeEqualityProof ... of
        { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...)
        }
    ```
    That occurs once and hence is pre-inlined unconditionally in the next Simplifier
    pass. It's non-trivial to find a way around that, but not really harmful
    otherwise. Hence we accept a 1.2% increase on some architectures.
    
    Metric Increase:
        LargeRecord
    
    - - - - -
    00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    CorePrep: Eta expand arguments (#23083)
    
    Previously, we'd only eta expand let bindings and lambdas,
    now we'll also eta expand arguments such as in T23083:
    ```hs
    g f h = f (h `seq` (h $))
    ```
    Unless `-fpedantic-bottoms` is set, we'll now transform to
    ```hs
    g f h = f (\eta -> h eta)
    ```
    in CorePrep.
    
    See the new `Note [Eta expansion of arguments in CorePrep]` for the details.
    
    We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions
    in T4801 and T5321FD.
    
    Fixes #23083.
    
    - - - - -
    bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00
    Bump bytestring submodule to 0.11.5, again
    
    Fixes #23789.
    
    The bytestring commit used here is unreleased;
    a release can be made when necessary.
    
    - - - - -
    7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00
    Serialize CmmRetInfo in .rodata
    
    The handling of case was missing.
    
    - - - - -
    0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Reference StgRetFun payload by its struct field address
    
    This is easier to grasp than relative pointer offsets.
    
    - - - - -
    f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Better variable name: u -> frame
    
    The 'u' was likely introduced by copy'n'paste.
    
    - - - - -
    0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00
    Make checkSTACK() public
    
    Such that it can also be used in tests.
    
    - - - - -
    7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Publish stack related fields in DerivedConstants.h
    
    These will be used in ghc-heap to decode these parts of the stack.
    
    - - - - -
    907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00
    ghc-heap: Decode StgStack and its stack frames
    
    Previously, ghc-heap could only decode heap closures.
    
    The approach is explained in detail in note
    [Decoding the stack].
    
    - - - - -
    6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Remove RetFunType from RetFun stack frame representation
    
    It's a technical detail. The single usage is replaced by a predicate.
    
    - - - - -
    006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Better parameter name
    
    The call-site uses the term "offset", too.
    
    - - - - -
    d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00
    Make closure boxing pure
    
    There seems to be no need to do something complicated. However, the
    strictness of the closure pointer matters, otherwise a thunk gets
    decoded.
    
    - - - - -
    8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Document entertainGC in test
    
    It wasn't obvious why it's there and what its role is.
    
    Also, increase the "entertainment level" a bit.
    
    I checked in STG and Cmm dumps that this really generates closures (and
    is not e.g. constant folded away.)
    
    - - - - -
    cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00
    Add -dipe-stats flag
    
    This is useful for seeing which info tables have information.
    
    - - - - -
    261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00
    Add -finfo-table-map-with-fallback -finfo-table-map-with-stack
    
    The -fno-info-table-map-with-stack flag omits STACK info tables from the info
    table map, and the -fno-info-table-map-with-fallback flag omits info tables
    with defaulted source locations from the map. In a test on the Agda codebase
    the build results were about 7% smaller when both of those types of tables
    were omitted.
    
    Adds a test that verifies that passing each combination of these flags
    results in the correct output for -dipe-stats, which is disabled for the js
    backend since profiling is not implemented.
    
    This commit also refactors a lot of the logic around extracting info tables
    from the Cmm results and building the info table map.
    
    This commit also fixes some issues in the users guide rst source to fix
    warnings that were noticed while debugging the documentation for these flags.
    
    Fixes #23702
    
    - - - - -
    d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00
    Add changelog entry for specialised Enum Int64/Word64 instances
    
    - - - - -
    52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00
    Fix -ddump-to-file and -ddump-timings interaction (#20316)
    
    - - - - -
    1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00
    Update release notes (#20316)
    
    - - - - -
    8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00
    base: Add changelog entry for CLC #188
    
    This proposal modified the implementations of copyBytes, moveBytes and
    fillBytes (as detailed in the proposal)
    
    https://github.com/haskell/core-libraries-committee/issues/188
    
    - - - - -
    026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00
    packaging: Build manpage in separate directory to other documentation
    
    We were installing two copies of the manpage:
    
    * One useless one in the `share/doc` folder, because we copy the doc/
      folder into share/
    * The one we deliberately installed into `share/man` etc
    
    The solution is to build the manpage into the `manpage` directory when
    building the bindist, and then just install it separately.
    
    Fixes #23707
    
    - - - - -
    524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00
    Report deprecated fields bound by record wildcards when used
    
    This commit ensures that we emit the appropriate warnings when
    a deprecated record field bound by a record wildcard is used.
    
    For example:
    
        module A where
        data Foo = Foo {x :: Int, y :: Bool, z :: Char}
    
        {-# DEPRECATED x "Don't use x" #-}
        {-# WARNING y "Don't use y" #-}
    
        module B where
        import A
    
        foo (Foo {..}) = x
    
    This will cause us to emit a "Don't use x" warning, with location the
    location of the record wildcard. Note that we don't warn about `y`,
    because it is unused in the RHS of `foo`.
    
    Fixes #23382
    
    - - - - -
    d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00
    Add zstd suffix to jobs which rely on zstd
    
    This was causing some confusion as the job was named simply
    "x86_64-linux-deb10-validate", which implies a standard configuration
    rather than any dependency on libzstd.
    
    - - - - -
    e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00
    ci: Always run project-version job
    
    This is needed for the downstream test-primops pipeline to workout what
    the version of a bindist produced by a pipeline is.
    
    - - - - -
    f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00
    gen_ci: Rework how jobs-metadata.json is generated
    
    * We now represent a job group a triple of Maybes, which makes it easier
      to work out when jobs are enabled/disabled on certain pipelines.
    
    ```
    data JobGroup a = StandardTriple { v :: Maybe (NamedJob a)
                                     , n :: Maybe (NamedJob a)
                                     , r :: Maybe (NamedJob a) }
    ```
    
    * `jobs-metadata.json`  generation is reworked using the following
      algorithm.
      - For each pipeline type, find all the platforms we are doing builds
        for.
      - Select one build per platform
      - Zip together the results
    
    This way we can choose different pipelines for validate/nightly/release
    which makes the metadata also useful for validate pipelines. This
    feature is used by the test-primops downstream CI in order to select the
    right bindist for testing validate pipelines.
    
    This makes it easier to inspect which jobs are going to be enabled on a
    particular pipeline.
    
    - - - - -
    f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00
    gen_ci: Rules rework
    
    In particular we now distinguish between whether we are dealing with a
    Nightly/Release pipeline (which labels don't matter for) and a validate
    pipeline where labels do matter.
    
    The overall goal here is to allow a disjunction of labels for validate
    pipelines, for example,
    
    > Run a job if we have the full-ci label or test-primops label
    
    Therefore the "ValidateOnly" rules are treated as a set of disjunctions
    rather than conjunctions like before.
    
    What this means in particular is that if we want to ONLY run a job if a
    label is set, for example, "FreeBSD" label then we have to override the
    whole label set.
    
    Fixes #23772
    
    - - - - -
    d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00
    ci: set -e for lint-ci-config scripts
    
    - - - - -
    994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00
    ci: Fix job metadata generation
    
    - - - - -
    e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00
    users-guide: Note that GHC2021 doesn't include ExplicitNamespaces
    
    As noted in #23801.
    
    - - - - -
    d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00
    users-guide: Support both distutils and packaging
    
    As noted in #23818, some old distributions (e.g. Debian 9) only include
    `distutils` while newer distributions only include `packaging`.
    
    Fixes #23818.
    
    - - - - -
    1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00
    users-guide: Ensure extlinks is compatible with Sphinx <4
    
    The semantics of the `extlinks` attribute annoyingly changed in Sphinx
    4. Reflect this in our configuration. See #22690.
    
    Fixes #23807.
    
    - - - - -
    173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00
    ci: Run full-ci on master and release branches
    
    Fixes #23737
    
    - - - - -
    bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00
    Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp
    
    - - - - -
    662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00
    ghc-toolchain: Match CPP args with configure script
    
    At the moment we need ghc-toolchain to precisely match the output as
    provided by the normal configure script. The normal configure script
    (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc
    so we match that logic exactly in ghc-toolchain.
    
    The old implementation (which checks if certain flags are supported) is
    better but for now we have to match to catch any potential errors in the
    configuration.
    
    Ticket: #23720
    
    - - - - -
    09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00
    configure: Fix `-Wl,--no-as-needed` check
    
    The check was failing because the args supplied by $$1 were quoted which
    failed because then the C compiler thought they were an input file.
    
    Fixes #23720
    
    - - - - -
    2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00
    configure: Add flag which turns ghc-toolchain check into error
    
    We want to catch these errors in CI, but first we need to a flag which
    turns this check into an error.
    
    - - - - -
    6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs
    
    This will cause any CI job to fail if we have a mismatch between what
    ghc-toolchain reports and what ./configure natively reports. Fixing
    these kinds of issues is highest priority for 9.10 release.
    
    - - - - -
    12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
    Pass user-specified options to ghc-toolchain
    
    The current user interface to configuring target toolchains is `./configure`.
    
    In !9263 we added a new tool to configure target toolchains called
    `ghc-toolchain`, but the blessed way of creating these toolchains is
    still through configure.
    
    However, we were not passing the user-specified options given with the
    `./configure` invocation to the ghc-toolchain tool.
    
    This commit remedies that by storing the user options and environment
    variables in USER_* variables, which then get passed to GHC-toolchain.
    
    The exception to the rule is the windows bundled toolchain, which
    overrides the USER_* variables with whatever flags the windows bundled
    toolchain requires to work.
    We consider the bundled toolchain to be effectively the user specifying
    options, since the actual user delegated that configuration work.
    
    Closes #23678
    
    - - - - -
    f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
    ghc-toolchain: Parse javascript and ghcjs as a Arch and OS
    
    - - - - -
    8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
    ghc-toolchain: Fix ranlib option
    
    - - - - -
    31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
    Check Link Works with -Werror
    
    - - - - -
    bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    Only check for no_compact_unwind support on darwin
    
    While writing ghc-toolchain we noticed that the
    FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we
    pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as
    -n o_compact_unwind, which is a valid argument.
    
    Fixes #23676
    
    - - - - -
    0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00
    Add some javascript special cases to ghc-toolchain
    
    On javascript there isn't a choice of toolchain but some of the
    configure checks were not accurately providing the correct answer.
    
    1. The linker was reported as gnu LD because the --version output
       mentioned gnu LD.
    2. The --target flag makes no sense on javascript but it was just
       ignored by the linker, so we add a special case to stop ghc-toolchain
       thinking that emcc supports --target when used as a linker.
    
    - - - - -
    a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    check for emcc in gnu_LD check
    
    - - - - -
    50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    Add ldOverrideWhitelist to only default to ldOverride on windows/linux
    
    On some platforms - ie darwin, javascript etc we really do not want to
    allow the user to use any linker other than the default one as this
    leads to all kinds of bugs. Therefore it is a bit more prudant to add a
    whitelist which specifies on which platforms it might be possible to use
    a different linker.
    
    - - - - -
    a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00
    Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS
    
    A normal triple may look like
    
    x86_64-unknown-linux
    
    but when cross-compiling you get $target set to a quad such as..
    
    aarch64-unknown-linux-gnu
    
    Which should also match this check.
    
    - - - - -
    c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    ghc-toolchain: Pass ld-override onto ghc-toolchain
    
    - - - - -
    039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00
    ld override: Make whitelist override user given option
    
    - - - - -
    d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00
    ghc-toolchain: Add format mode to normalise differences before diffing.
    
    The "format" mode takes an "--input" and "--ouput" target file and
    formats it.
    
    This is intended to be useful on windows where the
    configure/ghc-toolchain target files can't be diffed very easily because
    the path separators are different.
    
    - - - - -
    f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00
    ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta
    
    We needed to remove -Wno-unused-command-line-argument from the arguments
    passed in order for the configure check to report correctly.
    
    See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335
    
    - - - - -
    92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00
    configure: MergeObjsCmd - distinguish between empty string and unset variable
    
    If `MergeObjsCmd` is explicitly set to the empty string then we should
    assume that MergeObjs is just not supported.
    
    This is especially important for windows where we set MergeObjsCmd to ""
    in m4/fp_setup_windows_toolchain.m4.
    
    - - - - -
    3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00
    configure: Add proper check to see if object merging works
    
    - - - - -
    08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00
    ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing
    
    If the user explicitly chooses to not set a MergeObjsCmd then it is
    correct to use Nothing for tgtMergeObjs field in the Target file.
    
    - - - - -
    c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00
    HsCppArgs: Augment the HsCppOptions
    
    This is important when we pass -I when setting up the windows toolchain.
    
    - - - - -
    294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00
    Set USER_CPP_ARGS when setting up windows toolchain
    
    - - - - -
    bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00
    Improve handling of Cc as a fallback
    
    - - - - -
    f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00
    ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags
    
    In ghc-toolchain, we were only /not/ configuring required flags when the
    user specified any flags at all for the  of the HsCpp and Cpp tools.
    
    Otherwise, the linker takes into consideration the user specified flags
    to determine whether to search for a better linker implementation, but
    already configured the remaining GHC and platform-specific flags
    regardless of the user options.
    
    Other Tools consider the user options as a baseline for further
    configuration (see `findProgram`), so #23689 is not applicable.
    
    Closes #23689
    
    - - - - -
    bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00
    CPP_ARGS: Put new options after user specified options
    
    This matches up with the behaviour of ghc-toolchain, so that the output
    of both matches.
    
    - - - - -
    a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00
    If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting
    
    Fixes #23821.
    
    - - - - -
    e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00
    JS: implement openat(AT_FDCWD...) (#23697)
    
    Use `openSync` to implement `openat(AT_FDCWD...)`.
    
    - - - - -
    a975c663 by sheaf at 2023-08-17T07:54:47-04:00
    Use unsatisfiable for missing methods w/ defaults
    
    When a class instance has an Unsatisfiable constraint in its context
    and the user has not explicitly provided an implementation of a method,
    we now always provide a RHS of the form `unsatisfiable @msg`, even
    if the method has a default definition available. This ensures that,
    when deferring type errors, users get the appropriate error message
    instead of a possible runtime loop, if class default methods were
    defined recursively.
    
    Fixes #23816
    
    - - - - -
    45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00
    ghc-internal: Initial commit of the skeleton
    
    - - - - -
    88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00
    ghc-experimental: Initial commit
    
    - - - - -
    664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00
    testsuite/cloneStackLib: Fix incorrect format specifiers
    
    - - - - -
    eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00
    rts/ipe: Fix const-correctness of IpeBufferListNode
    
    Both info tables and the string table should be `const`
    
    - - - - -
    78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00
    nonmoving: Drop dead debugging utilities
    
    These are largely superceded by support in the ghc-utils GDB extension.
    
    - - - - -
    3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00
    nonmoving: Refactor management of mark thread
    
    Here we refactor that treatment of the worker thread used by the
    nonmoving GC for concurrent marking, avoiding creating a new thread with
    every major GC cycle. As well, the new scheme is considerably easier to
    reason about, consolidating all state in one place, accessed via a small
    set of accessors with clear semantics.
    
    - - - - -
    88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00
    testsuite: Skip T23221 in nonmoving GC ways
    
    This test is very dependent upon GC behavior.
    
    - - - - -
    381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00
    ghc-heap: Don't expose stack dirty and marking fields
    
    These are GC metadata and are not relevant to the end-user. Moreover,
    they are unstable which makes ghc-heap harder to test than necessary.
    
    - - - - -
    16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00
    bump process submodule to include macOS fix and JS support
    
    - - - - -
    b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00
    ci: Add support for triggering test-primops pipelines
    
    This commit adds 4 ways to trigger testing with test-primops.
    
    1. Applying the ~test-primops label to a validate pipeline.
    2. A manually triggered job on a validate pipeline
    3. A nightly pipeline job
    4. A release pipeline job
    
    Fixes #23695
    
    - - - - -
    32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00
    Add test-primops label support
    
    The test-primops CI job requires some additional builds in the
    validation pipeline, so we make sure to enable these jobs when
    test-primops label is set.
    
    - - - - -
    73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00
    Revert "Aarch ncg: Optimize immediate use for address calculations"
    
    This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631.
    
    See #23793
    
    - - - - -
    5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00
    Revert "AArch NCG: Pure refactor"
    
    This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d.
    
    See #23793
    
    - - - - -
    02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00
    Revert "Aarch64 NCG: Use encoded immediates for literals."
    
    This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c.
    
    See #23793
    
    -------------------------
    Metric Increase:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00
    ci: Remove manually triggered test-ci job
    
    This doesn't work on slimmed down pipelines as the needed jobs don't
    exist.
    
    If you want to run test-primops then apply the label.
    
    - - - - -
    76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00
    Remove Ptr example from roles docs
    
    - - - - -
    069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00
    Guard against duplicate pipelines in forks
    
    - - - - -
    f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00
    dump-decls: fix "Ambiguous module name"-error
    
    Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package.
    
    ```
    dump-decls: <no location info>: error:
        Ambiguous module name `System.Console.ANSI.Types':
          it was found in multiple packages:
          ansi-terminal-0.11.4 ansi-terminal-types-0.11.5
    ```
    
    - - - - -
    edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00
    Fix MultiWayIf linearity checking (#23814)
    
    Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io>
    
    - - - - -
    4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00
    Update `Control.Concurrent.*` documentation
    
    - - - - -
    015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00
    Support 128-bit SIMD on AArch64 via LLVM backend
    
    - - - - -
    52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00
    Testsuite cleanup
    
    - Remove misleading help text in perf_notes, ways are not metrics
    - Remove no_print_summary - this was used for Phabricator
    - In linters tests, run 'git ls-files' just once.
      Previously, it was called on each has_ls_files()
    - Add ghc-prim.cabal to gitignore, noticed in #23726
    - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd
    
    - - - - -
    ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00
    EPA: Use Introduce [DeclTag] in AnnSortKey
    
    The AnnSortKey is used to keep track of the order of declarations for
    printing when the container has split them apart.
    
    This applies to HsValBinds and ClassDecl, ClsInstDecl.
    
    When making modifications to the list of declarations, the new order
    must be captured for when it must be printed. For each list of
    declarations (binds and sigs for a HsValBind) we can just store the
    list in order.
    
    To recreate the list when printing, we must merge them, and this is
    what the AnnSortKey records. It used to be indexed by SrcSpan, we now
    simply index by a marker as to which list to take the next item from.
    
    - - - - -
    e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00
    Don't attempt pattern synonym error recovery
    
    This commit gets rid of the pattern synonym error recovery mechanism
    (recoverPSB). The rationale is that the fake pattern synonym binding
    that the recovery mechanism introduced could lead to undesirable
    knock-on errors, and it isn't really feasible to conjure up a
    satisfactory binding as pattern synonyms can be used both in expressions
    and patterns.
    See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn.
    
    It isn't such a big deal to eagerly fail compilation on a pattern synonym
    that doesn't typecheck anyway.
    
    Fixes #23467
    
    - - - - -
    6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00
    base: Don't use Data.ByteString.Internals.memcpy
    
    This function is now deprecated from `bytestring`. Use
    `Foreign.Marshal.Utils.copyBytes` instead.
    
    Fixes #23880.
    
    - - - - -
    0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    hadrian: Uniformly pass buildOptions to all builders in runBuilder
    
    In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo.
    
    This leads to hard to diagnose bugs as any build options you pass with
    runBuilderWithCmdOptions are ignored for many builders.
    
    Solution: Uniformly pass buildOptions to the invocation of cmd.
    
    Fixes #23845
    
    - - - - -
    9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    Abstract windows toolchain setup
    
    This commit splits up the windows toolchain setup logic into two
    functions.
    
    * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if
      it isn't already downloaded
    * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point
      to the correct place
    
    FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw
    toolchain and also the eventual location where we will install the
    toolchain in the installed bindist.
    
    This is the first step towards #23608
    
    - - - - -
    6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    Generate build.mk for bindists
    
    The config.mk.in script was relying on some variables which were
    supposed to be set by build.mk but therefore never were when used to
    install a bindist.
    
    Specifically
    
    * BUILD_PROF_LIBS to determine whether we had profiled libraries or not
    * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or
      not
    
    Not only were these never set but also not really accurate because you
    could have shared libaries but still statically linked ghc executable.
    
    In addition variables like GhcLibWays were just never used, so those
    have been deleted from the script.
    
    Now instead we generate a build.mk file which just directly specifies
    which RtsWays we have supplied in the bindist and whether we have
    DYNAMIC_GHC_PROGRAMS.
    
    - - - - -
    fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00
    hadrian: Add reloc-binary-dist-* targets
    
    This adds a command line option to build a "relocatable" bindist.
    
    The bindist is created by first creating a normal bindist and then
    installing it using the `RelocatableBuild=YES` option. This creates a
    bindist without any wrapper scripts pointing to the libdir.
    
    The motivation for this feature is that we want to ship relocatable
    bindists on windows and this method is more uniform than the ad-hoc
    method which lead to bugs such as #23608 and #23476
    
    The relocatable bindist can be built with the "reloc-binary-dist" target
    and supports the same suffixes as the normal "binary-dist" command to
    specify the compression style.
    
    - - - - -
    41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    packaging: Fix installation scripts on windows/RelocatableBuild case
    
    This includes quite a lot of small fixes which fix the installation
    makefile to work on windows properly. This also required fixing the
    RelocatableBuild variable which seemed to have been broken for a long
    while.
    
    Sam helped me a lot writing this patch by providing a windows machine to
    test the changes. Without him it would have taken ages to tweak
    everything.
    
    Co-authored-by: sheaf <sam.derbyshire at gmail.com>
    
    - - - - -
    03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    ci: Build relocatable bindist on windows
    
    We now build the relocatable bindist target on windows, which means we
    test and distribute the new method of creating a relocatable bindist.
    
    - - - - -
    d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    hadrian: Add error when trying to build binary-dist target on windows
    
    The binary dist produced by `binary-dist` target doesn't work on windows
    because of the wrapper script the makefile installs. In order to not
    surprise any packagers we just give an error if someone tries to build
    the old binary-dist target rather than the reloc-binary-dist target.
    
    - - - - -
    7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    hadrian: Remove query' logic to use tooldir
    
    - - - - -
    03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00
    configure: Set WindresCmd directly and removed unused variables
    
    For some reason there was an indirection via the Windres variable before
    setting WindresCmd. That indirection led to #23855.
    
    I then also noticed that these other variables were just not used
    anywhere when trying to work out what the correct condition was for this
    bit of the configure script.
    
    - - - - -
    c82770f5 by sheaf at 2023-08-23T13:43:48-04:00
    Apply shellcheck suggestion to SUBST_TOOLDIR
    - - - - -
    896e35e5 by sheaf at 2023-08-23T13:44:34-04:00
    Compute hints from TcSolverReportMsg
    
    This commit changes how hints are handled in conjunction with
    constraint solver report messages.
    
    Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor,
    we compute the hints depending on the underlying TcSolverReportMsg.
    This disentangles the logic and makes it easier to add new hints for
    certain errors.
    
    - - - - -
    a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00
    users-guide: remove note about fatal Haddock parse failures
    
    - - - - -
    4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Introduce Data.Enum
    
    - - - - -
    f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Num.Integer
    
    - - - - -
    b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Num
    
    - - - - -
    6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Num.Natural
    
    - - - - -
    2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Float
    
    - - - - -
    f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Real
    
    - - - - -
    94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Eliminate module reexport in GHC.Exception
    
    The metric increase here isn't strictly due to this commit but it's a
    rather small, incidental change.
    
    Metric Increase:
        T8095
        T13386
    
    Metric Decrease:
        T8095
        T13386
        T18304
    
    - - - - -
    be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add disclaimers in internal modules
    
    To warn users that these modules are internal and their interfaces may
    change with little warning.
    
    As proposed in Core Libraries Committee #146 [CLC146].
    
    [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146
    
    - - - - -
    0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00
    Bump Cabal submodule
    
    We need to bump the Cabal submodule to include commit ec75950
    which fixes an issue with a dodgy import Rep(..) which relied
    on GHC bug #23570
    
    - - - - -
    0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00
    Fix typos in the documentation of Data.OldList.permutations
    - - - - -
    1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00
    Be more eager in TyCon boot validity checking
    
    This commit performs boot-file consistency checking for TyCons into
    checkValidTyCl. This ensures that we eagerly catch any mismatches,
    which prevents the compiler from seeing these inconsistencies and
    panicking as a result.
    
    See Note [TyCon boot consistency checking] in GHC.Tc.TyCl.
    
    Fixes #16127
    
    - - - - -
    d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00
    Refactor estimation of stack info table provenance
    
    This commit greatly refactors the way we compute estimated provenance for stack
    info tables. Previously, this process was done using an entirely separate traversal
    of the whole Cmm code stream to build the map from info tables to source locations.
    The separate traversal is now fused with the Cmm code generation pipeline in
    GHC.Driver.Main.
    
    This results in very significant code generation speed ups when -finfo-table-map is
    enabled. In testing, this patch reduces code generation times by almost 30% with
    -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 .
    
    Fixes #23103
    
    - - - - -
    d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00
    Add a test checking overhead of -finfo-table-map
    
    We want to make sure we don't end up with poor codegen performance resulting from
    -finfo-table-map again as in #23103. This test adds a performance test tracking
    total allocations while compiling ExactPrint with -finfo-table-map.
    
    - - - - -
    fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00
    llvmGen: Add export list to GHC.Llvm.MetaData
    
    - - - - -
    5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00
    llvmGen: Allow LlvmLits in MetaExprs
    
    This omission appears to be an oversight.
    
    - - - - -
    86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00
    compiler: Move platform feature predicates to GHC.Driver.DynFlags
    
    These are useful in `GHC.Driver.Config.*`.
    
    - - - - -
    a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00
    llvmGen: Introduce infrastructure for module flag metadata
    
    - - - - -
    e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00
    llvmGen: Don't pass stack alignment via command line
    
    As of https://reviews.llvm.org/D103048 LLVM no longer supports the
    `-stack-alignment=...` flag. Instead this information is passed via a
    module flag metadata node.
    
    This requires dropping support for LLVM 11 and 12.
    
    Fixes #23870
    
    - - - - -
    a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00
    EPA: Keep track of "in" token for WarningTxt category
    
    A warning can now be written with a category, e.g.
    
        {-# WARNInG in "x-c" e "d" #-}
    
    Keep track of the location of the 'in' keyword and string, as well as
    the original SourceText of the label, in case it uses character escapes.
    
    - - - - -
    3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00
    Remove redundant import in InfoTableProv
    
    The copyBytes function is provided by the import of Foreign.
    
    Fixes #23889
    
    - - - - -
    d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00
    gitlab/issue-template: Mention report-a-bug
    - - - - -
    50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30
    Added StandaloneKindSignature examples to replace CUSKs ones
    
    - - - - -
    2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00
    Remove outdated CPP in compiler/* and template-haskell/*
    
    The boot compiler was bumped to 9.4 in cebb5819b43.
    There is no point supporting older GHC versions with CPP.
    
    - - - - -
    5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30
    testsuite: Add regression test for #23861
    
    Simon says this was fixed by
    
    commit 8d68685468d0b6e922332a3ee8c7541efbe46137
    Author: sheaf <sam.derbyshire at gmail.com>
    Date:   Fri Aug 4 15:28:45 2023 +0200
    
        Remove zonk in tcVTA
    
    - - - - -
    b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00
    testsuite: Add regression test for #23864
    
    Simon says this was fixed by
    
    commit 59202c800f2c97c16906120ab2561f6e1556e4af
    Author: Sebastian Graf <sebastian.graf at kit.edu>
    Date:   Fri Mar 31 17:35:22 2023 +0200
    
        CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead
    
        We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now.
        The main reason is that it plays far better in conjunction with eta expansion
        (as we aim to do for arguments in CorePrep, #23083), because we can discard
        any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta`
        it's impossible to discard the argument.
    
    - - - - -
    9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00
    Remove ScopedTypeVariables => TypeAbstractions
    
    This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/)
    to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448)
    by removing the implication of language extensions
    
      ScopedTypeVariables => TypeAbstractions
    
    To limit breakage, we now allow type arguments in constructor patterns
    when both ScopedTypeVariables and TypeApplications are enabled, but
    we emit a warning notifying the user that this is deprecated behaviour
    that will go away starting in GHC 9.12.
    
    Fixes #23776
    
    - - - - -
    fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00
    .stderr: ScopedTypeVariables =/> TypeAbstractions
    
    This commit accepts testsuite changes for the changes in the previous
    commit, which mean that TypeAbstractions is no longer implied by
    ScopedTypeVariables.
    
    - - - - -
    4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00
    Repair `codes` test on OpenBSD by explicitly requesting extended RE
    
    - - - - -
    6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
    Add test for #23540
    
    `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so
    `explainEv` has been moved to `TestUtils.hs`.
    
    - - - - -
    257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
    Add test for #23120
    
    - - - - -
    4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
    Make some evidence uses reachable by toHie
    
    Resolves #23540, #23120
    
    This adds spans to certain expressions in the typechecker and renamer,
    and lets 'toHie' make use of those spans. Therefore the relevant
    evidence uses for the following syntax will now show up under the
    expected nodes in 'HieAst's:
    
    - Overloaded literals ('IsString', 'Num', 'Fractional')
    
    - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the
      overloaded literals being matched on)
    
    - Arithmetic sequences ('Enum')
    
    - Monadic bind statements ('Monad')
    
    - Monadic body statements ('Monad', 'Alternative')
    
    - ApplicativeDo ('Applicative', 'Functor')
    
    - Overloaded lists ('IsList')
    
    Also see Note [Source locations for implicit function calls]
    
    In the process of handling overloaded lists I added an extra 'SrcSpan'
    field to 'VAExpansion' - this allows us to more accurately reconstruct
    the locations from the renamer in 'rebuildHsApps'. This also happens to
    fix #23120.
    
    See the additions to Note [Looking through HsExpanded]
    
    - - - - -
    fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00
    ghc-heap: rename C file (fix #23898)
    
    - - - - -
    b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00
    Misc cleanup
    
    - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples.
      Rename to ReturnsTuple.
    - Builtin.Utils: use SDoc for a panic message.
      The comment about <<details unavailable>> was obsoleted by e8d356773b56.
    - TagCheck: fix wrong logic. It was zipping a list 'args' with its
      version 'args_cmm' after filtering.
    - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types
    - hadrian: remove leftover debugging print
    
    - - - - -
    3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00
    Add a regression test for #23903
    
    The bug has been fixed by commit bad2f8b8aa8424.
    
    - - - - -
    21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00
    README: Refer to ghc-hq repository for contributor and governance information
    
    - - - - -
    e542d590 by sheaf at 2023-08-29T19:52:40-04:00
    Export setInertSet from GHC.Tc.Solver.Monad
    
    We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad.
    These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed
    the export of setInertSet, but that function is useful for the GHC API.
    
    - - - - -
    694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00
    Don't bundle children for non-parent Avails
    
    We used to bundle all children of the parent Avail with things that
    aren't the parent, e.g. with
    
      class C a where
        type T a
        meth :: ..
    
    we would bundle the whole Avail (C, T, meth) with all of C, T and meth,
    instead of only with C.
    
    Avoiding this fixes #23570
    
    - - - - -
    d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00
    Fix typos
    
    - - - - -
    d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00
    JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806)
    
    - - - - -
    e2940272 by David Binder at 2023-08-30T19:43:08-04:00
    Bump submodules of hpc and hpc-bin to version 0.7.0.0
    
    hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify
    compatibility with newer versions of the directory package which
    dropped all SafeHaskell guarantees.
    
    - - - - -
    5d56d05c by David Binder at 2023-08-30T19:43:08-04:00
    Bump hpc bound in ghc.cabal.in
    
    - - - - -
    99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
    ghc classes documentation: rm redundant comment
    
    - - - - -
    fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00
    prelude documentation: various nits
    
    - - - - -
    48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
    integer documentation: minor corrections
    
    - - - - -
    20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
    real documentation: nits
    
    - - - - -
    dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00
    Add a test for #21765
    
    This issue (of reporting a constraint as being redundant even though
    removing it causes typechecking to fail) was fixed in aed1974e.
    This commit simply adds a regression test.
    
    Fixes #21765
    
    - - - - -
    f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00
    Export foldl' from Prelude and bump submodules
    
    See https://github.com/haskell/core-libraries-committee/issues/167 for discussion
    
    Metric Decrease:
        T8095
        T13386
    Metric Increase:
        T13386
        T8095
    
    T8095 ghc/alloc decreased on x86_64, but increased on aarch64.
    T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms.
    Neither has anything to do with `foldl'`, so I conclude that both are flaky.
    
    - - - - -
    3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00
    Allow cross-tyvar defaulting proposals from plugins
    
    Fixes #23832.
    
    - - - - -
    e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00
    Clarify Note [GlobalId/LocalId] after CorePrep (#23797)
    
    Fixes #23797.
    
    - - - - -
    ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00
    Fix warning with UNPACK on sum type (#23921)
    
    - - - - -
    9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00
    hadrian: track python dependencies in doc rules
    
    - - - - -
    1578215f by sheaf at 2023-09-05T00:38:26-04:00
    Bump Haddock to fix #23616
    
    This commit updates the Haddock submodule to include
    the fix to #23616.
    
    Fixes #23616
    
    - - - - -
    5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00
    Fix example in GHC user guide in SafeHaskell section
    
    The example given in the SafeHaskell section uses an implementation of
    Monad which no longer works. This MR removes the non-canonical return
    instance and adds the necessary instances of Functor and Applicative.
    
    - - - - -
    291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00
    driver: Check transitive closure of haskell package dependencies when deciding whether to relink
    
    We were previously just checking whether direct package dependencies had
    been modified. This caused issues when compiling without optimisations
    as we wouldn't relink the direct dependency if one of its dependenices
    changed.
    
    Fixes #23724
    
    - - - - -
    35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00
    Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic
    
    Fixes #23930
    
    - - - - -
    3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00
    Make STG rewriter produce updatable closures
    
    - - - - -
    0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00
    configure: update message to use hadrian (#22616)
    
    - - - - -
    b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00
    EPA: Incorrect locations for UserTyVar with '@'
    
    In T13343.hs, the location for the @ is not within the span of the
    surrounding UserTyVar.
    
      type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v
    
    Widen it so it is captured.
    
    Closes #23887
    
    - - - - -
    8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00
    Bump haddock submodule to fix #23920
    
    Removes the fake export of `FUN` from Prelude. Fixes #23920.
    
    Bumps haddock submodule.
    
    - - - - -
    e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00
    Fix wrong role in mkSelCo_maybe
    
    In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a,
    and call mkSelCo (SelTyCon 1 nominal) Refl.
    The function incorrectly returned Refl :: a ~R a. The returned role
    should be nominal, according to the SelCo rule:
    
          co : (T s1..sn) ~r0 (T t1..tn)
          r = tyConRole tc r0 i
          ----------------------------------
          SelCo (SelTyCon i r) : si ~r ti
    
    In this test case, r is nominal while r0 is representational.
    
    - - - - -
    1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00
    If we have multiple defaulting plugins, then we should zonk in between them
    
    after any defaulting has taken place, to avoid a defaulting plugin seeing
    a metavariable that has already been filled.
    
    Fixes #23821.
    
    - - - - -
    eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00
    Improvements to the documentation of defaulting plugins
    
    Based on @simonpj's draft and comments in !11117
    
    - - - - -
    ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00
    EPA: Incorrect span for LWarnDec GhcPs
    
    The code (from T23465.hs)
    
        {-# WARNInG in "x-c" e "d" #-}
        e = e
    
    gives an incorrect span for the LWarnDecl GhcPs
    
    Closes #23892
    
    It also fixes the Test23465/Test23464 mixup
    
    - - - - -
    a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00
    Valid hole fits: don't suggest unsafeCoerce (#17940)
    
    - - - - -
    88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00
    Add warning for badly staged types.
    
    Resolves #23829.
    
    The stage violation results in out-of-bound names in splices.
    Technically this is an error, but someone might rely on this!?
    
    Internal changes:
    - we now track stages for TyVars.
    - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does
      in fact rename its argument type, and it can contain variables.
    
    - - - - -
    9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00
    rts: Fix invalid symbol type
    
    I suspect this code is dead since we haven't observed this failing
    despite the obviously incorrect macro name.
    
    - - - - -
    03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00
    testsuite: Add simple test exercising C11 atomics in GHCi
    
    See #22012.
    
    - - - - -
    1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00
    rts/RtsSymbols: Add AArch64 outline atomic operations
    
    Fixes #22012 by adding the symbols described in
    https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic.
    
    Ultimately this would be better addressed by #22011, but this is a first
    step in the right direction and fixes the immediate symptom.
    
    Note that we dropped the `__arch64_cas16` operations as these provided
    by all platforms's compilers. Also, we don't link directly against the
    libgcc/compiler-rt definitions but rather provide our own wrappers to
    work around broken toolchains (e.g. https://bugs.gentoo.org/868018).
    
    Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733.
    
    - - - - -
    8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00
    ci: Build debian12 and fedora38 bindists
    
    This adds builds for the latest releases for fedora and debian
    
    We build these bindists in nightly and release pipelines.
    
    - - - - -
    a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00
    Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods.
    
    - - - - -
    98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00
    docs: move -xn flag beside --nonmoving-gc
    
    It makes sense to have these beside each other as they are aliases.
    
    - - - - -
    f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00
    nonmoving: introduce a family of dense allocators
    
    Supplement the existing power 2 sized nonmoving allocators with a family
    of dense allocators up to a configurable threshold.
    
    This should reduce waste from rounding up block sizes while keeping the
    amount of allocator sizes manageable.
    
    This patch:
      - Adds a new configuration option `--nonmoving-dense-allocator-count`
        to control the amount of these new dense allocators.
      - Adds some constants to `NonmovingAllocator` in order to keep
        marking fast with the new allocators.
    
    Resolves #23340
    
    - - - - -
    2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00
    Add changelog entry for #23340
    
    - - - - -
    f96fe681 by sheaf at 2023-09-12T04:31:44-04:00
    Use printGhciException in run{Stmt, Decls}
    
    When evaluating statements in GHCi, we need to use printGhciException
    instead of the printException function that GHC provides in order to
    get the appropriate error messages that are customised for ghci use.
    
    - - - - -
    d09b932b by psilospore at 2023-09-12T04:31:44-04:00
    T23686: Suggest how to enable Language Extension when in ghci
    Fixes #23686
    
    - - - - -
    da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00
    Unarise: Split Rubbish literals in function args
    
    Fixes #23914.  Also adds a check to STG lint that
    these args are properly unary or nullary after unarisation
    
    - - - - -
    261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00
    darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13
    
    This bumps the minumum supported version to 10.13 (High Sierra) which is
    6 years old at this point.
    
    Fixes #22938
    
    - - - - -
    f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00
    Fix TH pretty-printing of nested GADTs, issue #23937
    
    This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly
    pretty-prints GADTs declarations contained within data family instances.
    
    Fixes #23937
    
    - - - - -
    d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00
    Put hadrian non-bootstrap plans through `jq`
    
    This makes it possible to review changes with conventional diffing
    tools.
    
    This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left
    off.
    
    - - - - -
    ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00
    JS: fix some tests
    
    - Tests using Setup programs need to pass --with-hc-pkg
    - Several other fixes
    
    See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage
    for the current status
    
    - - - - -
    fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00
    Fix in-scope set assertion failure (#23918)
    
    Patch by Simon
    
    - - - - -
    21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00
    Add -Winconsistent-flags warning
    
    The warning fires when inconsistent command line flags are passed.
    
    For example:
    
    * -dynamic-too and -dynamic
    * -dynamic-too on windows
    * -O and --interactive
    * etc
    
    This is on by default and allows users to control whether the warning is
    displayed and whether it should be an error or not.
    
    Fixes #22572
    
    - - - - -
    dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00
    Avoid serializing BCOs with the internal interpreter
    
    Refs #23919
    
    - - - - -
    9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00
    Fix numa auto configure
    
    - - - - -
    98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00
    Add -fno-cse to T15426 and T18964
    
    This -fno-cse change is to avoid these performance tests depending on
    flukey CSE stuff.  Each contains several independent tests, and we don't
    want them to interact.
    
    See #23925.
    
    By killing CSE we expect a 400% increase in T15426, and 100% in T18964.
    
    Metric Increase:
        T15426
        T18964
    
    - - - - -
    236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00
    Tiny refactor
    
    canEtaReduceToArity was only called internally, and always with
    two arguments equal to zero.  This patch just specialises the
    function, and renames it to cantEtaReduceFun.
    
    No change in behaviour.
    
    - - - - -
    56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00
    spec-constr: Lift argument limit for SPEC-marked functions
    
    When the user adds a SPEC argument to a function, they are informing us
    that they expect the function to be specialised. However, previously
    this instruction could be preempted by the specialised-argument limit
    (sc_max_args). Fix this.
    
    This fixes #14003.
    
    - - - - -
    6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00
    Fix eta reduction
    
    Issue #23922 showed that GHC was bogusly eta-reducing a join point.
    We should never eta-reduce (\x -> j x) to j, if j is a join point.
    
    It is extremly difficult to trigger this bug.  It took me 45 mins of
    trying to make a small tests case, here immortalised as T23922a.
    
    - - - - -
    e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00
    Profiling: Properly escape characters when using `-pj`.
    
    There are some ways in which unusual characters like quotes or others
    can make it into cost centre names. So properly escape these.
    
    Fixes #23924
    
    - - - - -
    ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00
    Use clearer example variable names for bool eliminator
    
    - - - - -
    5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00
    Add missing int64/word64-to-double/float rules (#23907)
    
    CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203
    
    - - - - -
    566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00
    Fix and test TH pretty-printing of type operator role declarations
    
    This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it
    correctly pretty-prints `type role` declarations for operator names.
    
    Fixes #23954
    
    - - - - -
    8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00
    Use correct FunTyFlag in adjustJoinPointType
    
    As the Lint error in #23952 showed, the function adjustJoinPointType
    was failing to adjust the FunTyFlag when adjusting the type.
    
    I don't think this caused the seg-fault reported in the ticket,
    but it is definitely.  This patch fixes it.
    
    It is tricky to come up a small test case; Krzysztof came up with
    this one, but it only triggers a failure in GHC 9.6.
    
    - - - - -
    778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00
    Update to Unicode 15.1.0
    
    See: https://www.unicode.org/versions/Unicode15.1.0/
    
    - - - - -
    f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00
    EPA: track unicode version for unrestrictedFunTyCon
    
    Closes #23885
    
    Updates haddock submodule
    
    - - - - -
    9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00
    Bump parsec submodule to allow text-2.1 and bytestring-0.12
    
    - - - - -
    7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00
    base: Advertise linear time of readFloat
    
    As noted in #23538, `readFloat` has runtime that scales nonlinearly in
    the size of its input. Consequently, its use on untrusted input can
    be exploited as a denial-of-service vector. Point this out and suggest
    use of `read` instead.
    
    See #23538.
    
    - - - - -
    f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00
    Remove dead code GHC.CoreToStg.Prep.canFloat
    
    This function never fires, so we can delete it: #23965.
    
    - - - - -
    ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00
    base/changelog: Move fix for #23907 to 9.8.1 section
    
    Since the fix was backported to 9.8.1
    
    - - - - -
    51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00
    Add aarch64 alpine bindist
    
    This is dynamically linked and makes creating statically linked
    executables more straightforward.
    
    Fixes #23482
    
    - - - - -
    02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00
    Add aarch64-deb11 bindist
    
    This adds a debian 11 release job for aarch64.
    
    Fixes #22005
    
    - - - - -
    8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00
    Don’t store the async exception masking state in CATCH frames
    
    - - - - -
    86d2971e by doyougnu at 2023-09-19T19:08:19-04:00
    compiler,ghci: error codes link to HF error index
    
    closes: #23259
    
    - adds -fprint-error-index-links={auto|always|never} flag
    
    - - - - -
    5f826c18 by sheaf at 2023-09-19T19:09:03-04:00
    Pass quantified tyvars in tcDefaultAssocDecl
    
    This commit passes the correct set of quantified type variables written
    by the user in associated type default declarations for validity
    checking. This ensures that validity checking of associated type defaults
    mirrors that of standalone type family instances.
    
    Fixes #23768 (see testcase T23734 in subsequent commit)
    
    - - - - -
    aba18424 by sheaf at 2023-09-19T19:09:03-04:00
    Avoid panic in mkGADTVars
    
    This commit avoids panicking in mkGADTVars when we encounter
    a type variable as in #23784 that is bound by a user-written
    forall but not actually used.
    
    Fixes #23784
    
    - - - - -
    a525a92a by sheaf at 2023-09-19T19:09:03-04:00
    Adjust reporting of unused tyvars in data FamInsts
    
    This commit adjusts the validity checking of data family
    instances to improve the reporting of unused type variables.
    
    See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity.
    
    The problem was that, in a situation such as
    
      data family D :: Type
      data instance forall (d :: Type). D = MkD
    
    the RHS passed to 'checkFamPatBinders' would be the TyCon app
    
      R:D d
    
    which mentions the type variable 'd' quantified in the user-written
    forall. Thus, when computing the set of unused type variables in
    the RHS of the data family instance, we would find that 'd' is used,
    and report a strange error message that would say that 'd' is not
    bound on the LHS.
    
    To fix this, we special-case the data-family instance case,
    manually extracting all the type variables that appear in the
    arguments of all the data constructores of the data family instance.
    
    Fixes #23778
    
    - - - - -
    28dd52ee by sheaf at 2023-09-19T19:09:03-04:00
    Unused tyvars in FamInst: only report user tyvars
    
    This commit changes how we perform some validity checking for
    coercion axioms to mirror how we handle default declarations for
    associated type families. This allows us to keep track of whether
    type variables in type and data family instances were user-written
    or not, in order to only report the user-written ones in
    "unused type variable" error messages.
    
    Consider for example:
    
      {-# LANGUAGE PolyKinds #-}
      type family F
      type instance forall a. F = ()
    
    In this case, we get two quantified type variables,
    (k :: Type) and (a :: k); the second being user-written, but the first
    is introduced by the typechecker. We should only report 'a' as being
    unused, as the user has no idea what 'k' is.
    
    Fixes #23734
    
    - - - - -
    1eed645c by sheaf at 2023-09-19T19:09:03-04:00
    Validity: refactor treatment of data families
    
    This commit refactors the reporting of unused type variables in type
    and data family instances to be more principled. This avoids ad-hoc
    logic in the treatment of data family instances.
    
    - - - - -
    35bc506b by John Ericson at 2023-09-19T19:09:40-04:00
    Remove `ghc-cabal`
    
    It is dead code since the Make build system was removed.
    
    I tried to go over every match of `git grep -i ghc-cabal` to find other
    stray bits. Some of those might be workarounds that can be further
    removed.
    
    - - - - -
    665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00
    Re-add unregisterised build support for sparc and sparc64
    
    Closes #23959
    
    - - - - -
    142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00
    Bump ci-images to use updated version of Alex
    
    Fixes #23977
    
    - - - - -
    fa977034 by John Ericson at 2023-09-21T12:55:25-04:00
    Use Cabal 3.10 for Hadrian
    
    We need the newer version for `CABAL_FLAG_*` env vars for #17191.
    
    - - - - -
    a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: `need` any `configure` script we will call
    
    When the script is changed, we should reconfigure.
    
    - - - - -
    db882b57 by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: Make it easier to debug Cabal configure
    
    Right now, output is squashed. This make per-package configure scripts
    extremely hard to maintain, because we get vague "library is missing"
    errors when the actually probably is usually completely unrelated except
    for also involving the C/C++ toolchain.
    
    (I can always pass `-VVV` to Hadrian locally, but these errors are
    subtle and I often cannot reproduce them locally!)
    
    `--disable-option-checking` was added back in
    75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill;
    if other flags are passed that are not recognized behind the two from
    Cabal mentioned in the former comment, we *do* want to know about it.
    
    - - - - -
    7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: Increase verbosity of certain cabal commands
    
    This is a hack to get around the cabal function we're calling
    *decreasing* the verbosity it passes to another function, which is the
    stuff we often actually care about. Sigh.
    
    Keeping this a separate commit so if this makes things too verbose it is
    easy to revert.
    
    - - - - -
    a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00
    rts: Move most external symbols logic to the configure script
    
    This is much more terse because we are programmatically handling the
    leading underscore.
    
    `findPtr` however is still handled in the Cabal file because we need a
    newer Cabal to pass flags to the configure script automatically.
    
    Co-Authored-By: Ben Gamari <ben at well-typed.com>
    
    - - - - -
    56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00
    Bump Cabal submodule to allow text-2.1 and bytestring-0.12
    
    - - - - -
    0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00
    hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist
    
    - - - - -
    b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00
    Bump hadrian's index-state to upgrade alex at least to 3.2.7.3
    
    - - - - -
    11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00
    JS: correct file size and times
    
    Programs produced by the JavaScript backend were returning
    incorrect file sizes and modification times, causing cabal
    related tests to fail.
    
    This fixes the problem and adds an additional test that verifies
    basic file information operations.
    
    fixes #23980
    
    - - - - -
    b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00
    gitlab-ci: Drop libiserv from upload_ghc_libs
    
    libiserv has been merged into the ghci package.
    
    - - - - -
    37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00
    testsuite: Fix Windows line endings
    
    - - - - -
    5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00
    testsuite: Use makefile_test
    
    - - - - -
    15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00
    system-cxx-std-lib: Add license and description
    - - - - -
    0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00
    gitlab/issue-templates: Rename bug.md -> default.md
    
    So that it is visible by default.
    
    - - - - -
    23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00
    Bump submodule text to 2.1
    
    - - - - -
    b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00
    Bump submodule unix to 2.8.2.1
    
    - - - - -
    54b2016e by John Ericson at 2023-09-23T11:40:41-04:00
    Move lib{numa,dw} defines to RTS configure
    
    Clean up the m4 to handle the auto case always and be more consistent.
    Also simplify the CPP --- we should always have both headers if we are
    using libnuma.
    
    "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to
    better separate searching from actions taken based on search results.
    This might seem overkill now, but will make shuffling logic between
    configure scripts easier later.
    
    The macro comments are converted from `dnl` to `#` following the
    recomendation in
    https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html
    
    - - - - -
    d51b601b by John Ericson at 2023-09-23T11:40:50-04:00
    Shuffle libzstd configuring between scripts
    
    Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS
    configure, `AC_SUBST` goes to the top-level configure script, and the
    documentation of the m4 macro is improved.
    
    - - - - -
    d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00
    Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure
    
    It is just `AC_DEFINE` it belongs there instead.
    
    - - - - -
    18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00
    Move mmap in the runtime linker check to the RTS configure
    
    `AC_DEFINE` should go there instead.
    
    - - - - -
    74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00
    Elaborate comment on GHC_NO_UNICODE
    
    - - - - -
    de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00
    gitlab-ci: Mark T22012 as broken on CentOS 7
    
    Due to #23979.
    
    - - - - -
    6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00
    hadrian: better error for failing to find file's dependencies
    
    Resolves #24004
    
    - - - - -
    d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Refactor uses of `partitionEithers . map`
    
    This patch changes occurences of the idiom
    `partitionEithers (map f xs)` by the simpler form
    `partitionWith f xs` where `partitionWith` is the utility function
    defined in `GHC.Utils.Misc`.
    
    Resolves: #23953
    
    - - - - -
    8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Refactor uses of `partitionEithers <$> mapM f xs`
    
    This patch changes occurences of the idiom
    `partitionEithers <$> mapM f xs` by the simpler form
    `partitionWithM f xs` where `partitionWithM` is a utility function
    newly added to `GHC.Utils.Misc`.
    
    - - - - -
    6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Mark `GHC.Utils.Misc.partitionWithM` as inlineable
    
    This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure
    that the right-hand side of the definition of this function remains
    available for specialisation at call sites.
    
    - - - - -
    f1e5245a by David Binder at 2023-09-27T01:19:00-04:00
    Add RTS option to supress tix file
    
    - - - - -
    1f43124f by David Binder at 2023-09-27T01:19:00-04:00
    Add expected output to testsuite in test interface-stability/base-exports
    
    - - - - -
    b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00
    Expose HpcFlags and getHpcFlags from GHC.RTS.Flags
    
    - - - - -
    345675c6 by David Binder at 2023-09-27T01:19:00-04:00
    Fix expected output of interface-stability test
    
    - - - - -
    146e1c39 by David Binder at 2023-09-27T01:19:00-04:00
    Implement getHpcFlags
    
    - - - - -
    61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00
    Add section in user guide
    
    - - - - -
    ea05f890 by David Binder at 2023-09-27T01:19:01-04:00
    Rename --emit-tix-file to --write-tix-file
    
    - - - - -
    cabce2ce by David Binder at 2023-09-27T01:19:01-04:00
    Update the golden files for interface stability
    
    - - - - -
    1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00
    Refactor: introduce stgArgRep
    
    The function 'stgArgType' returns the type in STG. But this violates
    the abstraction: in STG we're supposed to operate on PrimReps.
    
    This introduces
    stgArgRep ty = typePrimRep (stgArgType ty)
    stgArgRep1 ty = typePrimRep1 (stgArgType ty)
    stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty)
    
    stgArgType is still directly used for unboxed tuples (should be fixable), FFI
    and in ticky.
    
    - - - - -
    b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00
    Fix TH pretty-printer's parenthesization
    
    This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed.
    
    Fixes #23962, #23968, #23971, and #23986
    
    - - - - -
    79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00
    Add a testcase for #17564
    
    The code in the ticket relied on the behaviour of Derived constraints.
    Derived constraints were removed in GHC 9.4 and now the code works
    as expected.
    
    - - - - -
    d7a80143 by sheaf at 2023-09-28T03:25:53-04:00
    lint-codes: add new modes of operation
    
    This commit adds two new modes of operation to the lint-codes
    utility:
    
      list - list all statically used diagnostic codes
      outdated - list all outdated diagnostic codes
    
    The previous behaviour is now:
    
      test - test consistency and coverage of diagnostic codes
    
    - - - - -
    477d223c by sheaf at 2023-09-28T03:25:53-04:00
    lint codes: avoid using git-grep
    
    We manually traverse through the filesystem to find the diagnostic codes
    embedded in .stdout and .stderr files, to avoid any issues with old
    versions of grep.
    
    Fixes #23843
    
    - - - - -
    a38ae69a by sheaf at 2023-09-28T03:25:53-04:00
    lint-codes: add Hadrian targets
    
    This commit adds new Hadrian targets:
    
      codes, codes:used - list all used diagnostic codes
      codes:outdated - list outdated diagnostic codes
    
    This allows users to easily query GHC for used and outdated
    diagnostic codes, e.g.
    
      hadrian/build -j --flavour=<..> codes
    
    will list all used diagnostic codes in the command line by running
    the lint-codes utility in the "list codes" mode of operation.
    
    The diagnostic code consistency and coverage test is still run as usual,
    through the testsuite:
    
      hadrian/build test --only="codes"
    
    - - - - -
    9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00
    hadrian: Install LICENSE files in bindists
    
    Fixes #23548.
    
    - - - - -
    b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00
    Fix visibility when eta-reducing a type lambda
    
    Fixes #24014.
    
    - - - - -
    d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00
    Fix several mistakes around free variables in iface breakpoints
    
    Fixes #23612 , #23607, #23998 and #23666.
    
    MR: !11026
    
    The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons:
    
    * IfaceBreakpoint created binders for free variables instead of expressions
    
    * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped
    
    - - - - -
    ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00
    Refactor to combine HsLam and HsLamCase
    
    This MR is pure refactoring (#23916):
    * Combine `HsLam` and `HsLamCase`
    * Combine `HsCmdLam` and `HsCmdLamCase`
    
    This just arranges to treat uniformly
       \x -> e
       \case pi -> ei
       \cases pis -> ie
    
    In the exising code base the first is treated differently
    to the latter two.
    
    No change in behaviour.
    
    More specifics:
    
    * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering
      * Lambda
      * `\case`
      * `\cases`
    
    * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases.
    
    * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one.
    
    * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.)
    
    * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument.
    
    * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument.
    
    * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
    
    * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
    
    * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one.
    
    * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one.
    
    p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one.
    
    Phew!
    
    - - - - -
    b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
    Arm: Make ppr methods easier to use by not requiring NCGConfig
    
    - - - - -
    2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
    AArch64: Fix broken conditional jumps for offsets >= 1MB
    
    Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps
    to avoid overflowing the immediate.
    
    Fixes #23746
    
    - - - - -
    1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00
    EPA: Replace Monoid with NoAnn
    
    We currently use the Monoid class as a constraint on Exact Print
    Annotation functions, so we can use mempty. But this leads to
    requiring Semigroup instances too, which do not always make sense.
    
    Instead, introduce a class NoAnn, with a function noAnn analogous to
    mempty.
    
    Closes #20372
    
    Updates haddock submodule
    
    - - - - -
    c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00
    users-guide: Refactor handling of :base-ref: et al.
    
    - - - - -
    bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00
    Simplify and correct nasty case in coercion opt
    
    This fixes #21062.
    
    No test case, because triggering this code seems challenging.
    
    - - - - -
    9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Bump bytestring submodule to 0.12.0.2
    
    - - - - -
    4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Inline bucket_match
    
    - - - - -
    f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00
    configure: Fix #21712 again
    
    This is a bit of a shot in the dark to fix #24033, which appears to be
    another instance of #21712. For some reason the ld-override logic
    *still* appears to be active on Darwin targets (or at least one).
    Consequently, on misconfigured systems we may choose a non-`ld64`
    linker.
    
    It's a bit unclear exactly what happened in #24033 but ultimately the
    check added for #21712 was not quite right, checking for the
    `ghc_host_os` (the value of which depends upon the bootstrap compiler)
    instead of the target platform. Fix this.
    
    Fixes #24033.
    
    - - - - -
    2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00
    Add a regression test for #24029
    
    - - - - -
    8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00
    Fix non-symbolic children lookup of fixity decl
    
    The fix for #23664 did not correctly account for non-symbolic names
    when looking up children of a given parent. This one-line fix changes
    that.
    
    Fixes #24037
    
    - - - - -
    a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00
    rts: fix incorrect ticket reference
    
    - - - - -
    e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00
    users-guide: Fix discussion of -Wpartial-fields
    
     * fix a few typos
     * add a new example showing when the warning fires
     * clarify the existing example
     * point out -Wincomplete-record-selects
    
    Fixes #24049.
    
    - - - - -
    8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00
    Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"
    
    This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.
    
    `-optP` should pass options to the preprocessor, that might be a very
    different program to the C compiler, so passing the options to the C
    compiler is likely to result in `-optP` being useless.
    
    Fixes #17185 and #21291
    
    - - - - -
    8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00
    rts/nonmoving: Fix on LLP64 platforms
    
    Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL`
    size suffix. However, this is wrong on LLP64 platforms like Windows,
    where `long` is 32-bits.
    
    Fixes #23003.
    Fixes #24042.
    
    - - - - -
    f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00
    Fix isAArch64Bitmask for 32bit immediates.
    
    Fixes #23802
    
    - - - - -
    63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00
    Work around perf note fetch failure
    
    Addresses #24055.
    
    - - - - -
    242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00
    Add a test for #21348
    
    - - - - -
    7d390bce by Rewbert at 2023-10-05T05:38:08-04:00
    Fixes #24046
    
    - - - - -
    69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00
    Ensure unconstrained instance dictionaries get IPE info
    
    In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up
    with an initial source span based on the span of the binder, which was causing
    instance dictionaries without dynamic superclass constraints to not have source
    locations in their IPE info. Now they do.
    
    Resolves #24005
    
    - - - - -
    390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00
    rts: Split up rts/include/stg/MachRegs.h by arch
    
    - - - - -
    3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00
    Actually set hackage index state
    
    Or at least, use a version of the cabal command that *claims* to set the
    index state.
    
    Time will tell.
    
    - - - - -
    46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00
    Update hackage index state
    
    - - - - -
    d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00
    Ensure hadrian uses CI's hackage index state
    
    - - - - -
    e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00
    Do not use O_NONBLOCK on regular files or block devices
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/166
    
    - - - - -
    a06197c4 by David Binder at 2023-10-08T15:06:55-04:00
    Update hpc-bin submodule to 0.69
    
    - - - - -
    ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00
    Update Hadrian with correct path to happy file for hpc-bin
    
    - - - - -
    94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00
    EPA: Introduce HasAnnotation class
    
    The class is defined as
    
        class HasAnnotation e where
          noAnnSrcSpan :: SrcSpan -> e
    
    This generalises noAnnSrcSpan, and allows
    
        noLocA :: (HasAnnotation e) => a -> GenLocated e a
        noLocA = L (noAnnSrcSpan noSrcSpan)
    
    - - - - -
    8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00
    Bump unix submodule to v2.8.3.0
    
    - - - - -
    e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00
    Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.
    
    The motivation for the flag is given in #21917.
    
    - - - - -
    3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Add ghcToolchain to tool args list
    
    This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.
    
    - - - - -
    476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Normalise triple via config.sub
    
    We were not normalising the target triple anymore like we did with the
    old make build system.
    
    Fixes #23856
    
    - - - - -
    303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add missing vendor normalisation
    
    This is copied from m4/ghc_convert_vendor.m4
    
    Towards #23868
    
    - - - - -
    838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add loongarch64 to parseArch
    
    Towards #23868
    
    - - - - -
    1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Add same LD hack to ghc-toolchain
    
    In the ./configure script, if you pass the `LD` variable then this has
    the effect of stopping use searching for a linker and hence passing
    `-fuse-ld=...`.
    
    We want to emulate this logic in ghc-toolchain, if a use explicilty
    specifies `LD` variable then don't add `-fuse-ld=..` with the goal of
    making ./configure and ghc-toolchain agree on which flags to use when
    using the C compiler as a linker.
    
    This is quite unsavoury as we don't bake the choice of LD into the
    configuration anywhere but what's important for now is making
    ghc-toolchain and ./configure agree as much as possible.
    
    See #23857 for more discussion
    
    - - - - -
    42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check for C99 support with -std=c99
    
    Previously we failed to try enabling C99 support with `-std=c99`, as
    `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which
    don't enable C99 by default.
    
    Fixes #23879.
    
    - - - - -
    da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro
    
    In very old toolchains the BYTE_ORDER macro is not set but thankfully
    the __BYTE_ORDER__ macro can be used instead.
    
    - - - - -
    d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: AC_PATH_TARGET_TOOL for LD
    
    We want to make sure that LD is set to an absolute path in order to be
    consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL
    macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which
    might use a relative path.
    
    - - - - -
    171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check whether we need -std=gnu99 for CPP as well
    
    In ./configure the C99 flag is passed to the C compiler when used as a C
    preprocessor. So we also check the same thing in ghc-toolchain.
    
    - - - - -
    89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Check for --target linker flag separately to C compiler
    
    There are situations where the C compiler doesn't accept `--target` but
    when used as a linker it does (but doesn't do anything most likely)
    
    In particular with old gcc toolchains, the C compiler doesn't support
    --target but when used as a linker it does.
    
    - - - - -
    37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Use Cc to compile test file in nopie check
    
    We were attempting to use the C compiler, as a linker, to compile a file
    in the nopie check, but that won't work in general as the flags we pass
    to the linker might not be compatible with the ones we pass when using
    the C compiler.
    
    - - - - -
    9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Error when ghc-toolchain fails to compile
    
    This is a small QOL change as if you are working on ghc-toolchain and it
    fails to compile then configure will continue and can give you outdated
    results.
    
    - - - - -
    1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Check whether -no-pie works when the C compiler is used as a linker
    
    `-no-pie` is a flag we pass when using the C compiler as a linker (see
    pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
    compiler used as a linker supports the flag, rather than just the C
    compiler.
    
    - - - - -
    62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Remove javascript special case for --target detection
    
    emcc when used as a linker seems to ignore the --target flag, and for
    consistency with configure which now tests for --target, we remove this
    special case.
    
    - - - - -
    0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00
    toolchain: Don't pass --target to emscripten toolchain
    
    As noted in `Note [Don't pass --target to emscripten toolchain]`,
    emscripten's `emcc` is rather inconsistent with respect to its treatment
    of the `--target` flag. Avoid this by special-casing this toolchain
    in the `configure` script and `ghc-toolchain`.
    
    Fixes on aspect of #23744.
    
    - - - - -
    6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure
    
    Stop passing -gcc-options which mixed together linker flags and
    non-linker flags. There's no guarantee the C compiler will accept both
    of these in each mode.
    
    - - - - -
    c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00
    configure: Probe stage0 link flags
    
    For consistency with later stages and CC.
    
    - - - - -
    1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00
    Stricter Binary.get in GHC.Types.Unit (#23964)
    
    I noticed some thunking while looking at Core.
    This change has very modest, but throughout positive ghc/alloc effect:
    
    ```
     hard_hole_fits(normal) ghc/alloc    283,057,664    281,620,872  -0.5%
    
                  geo. mean                                          -0.1%
                  minimum                                            -0.5%
                  maximum                                            +0.0%
    ```
    
    Fixes #23964.
    
    - - - - -
    a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00
    rel_eng/upload.sh cleanups
    
    - - - - -
    80705335 by doyougnu at 2023-10-10T19:03:18-04:00
    ci: add javascript label rule
    
    This adds a rule which triggers the javascript job when the "javascript"
    label is assigned to an MR.
    
    - - - - -
    a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00
    Make 'wWarningFlagsDeps' include every WarningFlag
    
    Fixes #24071.
    
    - - - - -
    d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00
    Fix pretty printing of overlap pragmas in TH splices (fixes #24074)
    
    - - - - -
    0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    AArch NCG: Refactor getRegister'
    
    Remove some special cases which can be handled just as well by the
    generic case.
    
    This increases code re-use while also fixing #23749. Since some of the
    special case wasn't upholding Note [Signed arithmetic on AArch64].
    
    - - - - -
    1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over mem management checks
    
    These are for heap allocation, a strictly RTS concern.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    The RTS configure one has a new
    ```
    AC_CHECK_SIZEOF([void *])
    ```
    that the top-level configure version didn't have, so that
    `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
    commits, that can go away.
    
    Progress towards #17191
    
    - - - - -
    41130a65 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `__thread` check
    
    This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over misc function checks
    
    These are for general use in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `eventfd` check
    
    This check is for the RTS part of the event manager and has a
    corresponding part in `base`.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    58f3babf by John Ericson at 2023-10-11T16:02:48-04:00
    Split `FP_CHECK_PTHREADS` and move part to RTS configure
    
    `NEED_PTHREAD_LIB` is unused since
    3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
    system), and so is no longer defined.
    
    Progress towards #17191
    
    - - - - -
    e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00
    nativeGen: section flags for .text$foo only
    
    Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
    #22834 in !9810.
    
    It does however add "xr" indiscriminatly to .text sections
    even if splitSections is disabled. This leads to the assembler saying:
    
    ghc_1.s:7849:0: error:
         Warning: Ignoring changed section attributes for .text
         |
    7849 | .section .text,"xr"
         | ^
    
    - - - - -
    f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00
    Modularity: pass TempDir instead of DynFlags (#17957)
    
    - - - - -
    34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00
    Test that functions from `mingwex` are available
    
    Ryan wrote these two minimizations, but they never got added to the test
    suite.
    
    See #23309, #23378
    
    Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com>
    Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com>
    
    - - - - -
    bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00
    Do not check for the `mingwex` library in `/configure`
    
    See the recent discussion in !10360 --- Cabal will itself check for the
    library for the packages that need it, and while the autoconf check
    additionally does some other things like define a `HAS_LIBMINGWEX` C
    Preprocessor macro, those other things are also unused and unneeded.
    
    Progress towards #17191, which aims to get rid of `/configure` entirely.
    
    - - - - -
    43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00
    base: Introduce move modules into src
    
    The only non-move changes here are whitespace changes to pass the
    `whitespace` test and a few testsuite adaptations.
    
    - - - - -
    df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00
    [PEi386 linker] Bounds check and null-deref guard
    
    We should resonably be able to expect that we won't exceed the number of
    sections if we assume to be dealing with legal object files. We can however
    not guarantee that we get some negative values, and while we try to
    special case most, we should exclude negative indexing into the sections
    array.
    
    We also need to ensure that we do not try to derefences targetSection,
    if it is NULL, due to the switch statement.
    
    - - - - -
    c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
    Move apple compat check to RTS configure
    
    - - - - -
    c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
    Move clock/timer fun checks to RTS configure
    
    Actual library check (which will set the Cabal flag) is left in the
    top-level configure for now.
    
    Progress towards #17191
    
    - - - - -
    7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
    Move visibility and "musttail" annotation checks to the RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
    Move leading underscore checks to RTS configure
    
    `CabalLeadingUnderscore` is done via Hadrian already, so we can stop
    `AC_SUBST`ing it completely.
    
    - - - - -
    25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
    Move alloca, fork, const, and big endian checks to RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    - - - - -
    5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
    Move libdl check to RTS configure
    
    - - - - -
    ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
    Adjust `FP_FIND_LIBFFI`
    
    Just set vars, and `AC_SUBST` in top-level configure.
    
    Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
    be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
    make build system).
    
    - - - - -
    f399812c by John Ericson at 2023-10-12T10:31:13-04:00
    Split BFD support to RTS configure
    
    The flag is still in the top-level configure, but the other checks
    (which define various macros --- important) are in the RTS configure.
    
    - - - - -
    f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
    Split libm check between top level and RTS
    
    - - - - -
    dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
    CgUtils.fixStgRegStmt respect register width
    
    This change ensure that the reg + offset computation is always of the
    same size.  Before this we could end up with a 64bit register, and then
    add a 32bit offset (on 32bit platforms).  This not only would fail type
    sanity checking, but also incorrectly truncate 64bit values into 32bit
    values silently on 32bit architectures.
    
    - - - - -
    3fe9e906 by John Ericson at 2023-10-12T13:29:42-04:00
    Get rid of `narrow<N>{Int,Word}#` as primops
    
    These were used to truncate operations when we were using the native
    primops for fixed-sized types, to stay in bounds. But now that we used
    fixed sized unboxed types for those, I don't believe these primops have
    much motivation. There were, after all, compiled by the NCG as just the
    `aToB# . bToA#` round tip anyways.
    
    If we get rid of them and just detect such round trips directly, we can
    optimize more cases. And similar to @hsyl20's recent `fromIntegral`
    changes, once we do handle the "underlying" round tip, there is no point
    having the combination be atomic because it's just more work for no gain
    to handle it too.
    
    To avoid breakage, we have a new `GHC.Prim.Deprecated` module from which
    functions equivalent to the primops are exported.
    
    CC @Bodigrim
    
    - - - - -
    
    
    12 changed files:
    
    - − .appveyor.sh
    - .editorconfig
    - .gitignore
    - .gitlab-ci.yml
    - .gitlab/ci.sh
    - − .gitlab/circle-ci-job.sh
    - .gitlab/darwin/nix/sources.json
    - .gitlab/darwin/toolchain.nix
    - + .gitlab/generate-ci/LICENSE
    - + .gitlab/generate-ci/README.mkd
    - + .gitlab/generate-ci/flake.lock
    - + .gitlab/generate-ci/flake.nix
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c51d9f0b14414ee09a662f75f44959748f4f221...3fe9e906c18334b0cc119c48a2eecc1419dc5387
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c51d9f0b14414ee09a662f75f44959748f4f221...3fe9e906c18334b0cc119c48a2eecc1419dc5387
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 12 18:02:15 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Thu, 12 Oct 2023 14:02:15 -0400
    Subject: [Git][ghc/ghc][wip/no-narrow-n] Get rid of `narrow{Int, Word}#` as
     primops
    Message-ID: <652834a7bdec6_24a445ca939ac183669@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/no-narrow-n at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    8cd6f681 by John Ericson at 2023-10-12T14:02:01-04:00
    Get rid of `narrow<N>{Int,Word}#` as primops
    
    These were used to truncate operations when we were using the native
    primops for fixed-sized types, to stay in bounds. But now that we used
    fixed sized unboxed types for those, I don't believe these primops have
    much motivation. There were, after all, compiled by the NCG as just the
    `aToB# . bToA#` round tip anyways.
    
    If we get rid of them and just detect such round trips directly, we can
    optimize more cases. And similar to @hsyl20's recent `fromIntegral`
    changes, once we do handle the "underlying" round tip, there is no point
    having the combination be atomic because it's just more work for no gain
    to handle it too.
    
    To avoid breakage, we have a new `GHC.Prim.Deprecated` module from which
    functions equivalent to the primops are exported.
    
    CC @Bodigrim
    
    - - - - -
    
    
    10 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - compiler/GHC/StgToJS/Prim.hs
    - + libraries/base/GHC/Prim/Deprecated.hs
    - libraries/base/base.cabal
    - libraries/base/src/GHC/Bits.hs
    - libraries/base/src/GHC/Exts.hs
    - libraries/base/src/GHC/Float/ConversionUtils.hs
    - libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -1053,18 +1053,6 @@ primop   BRev64Op   "bitReverse64#"   GenPrimOp   Word64# -> Word64#
     primop   BRevOp     "bitReverse#"     GenPrimOp   Word# -> Word#
         {Reverse the order of the bits in a word.}
     
    -------------------------------------------------------------------------
    -section "Narrowings"
    -        {Explicit narrowing of native-sized ints or words.}
    -------------------------------------------------------------------------
    -
    -primop   Narrow8IntOp      "narrow8Int#"      GenPrimOp   Int# -> Int#
    -primop   Narrow16IntOp     "narrow16Int#"     GenPrimOp   Int# -> Int#
    -primop   Narrow32IntOp     "narrow32Int#"     GenPrimOp   Int# -> Int#
    -primop   Narrow8WordOp     "narrow8Word#"     GenPrimOp   Word# -> Word#
    -primop   Narrow16WordOp    "narrow16Word#"    GenPrimOp   Word# -> Word#
    -primop   Narrow32WordOp    "narrow32Word#"    GenPrimOp   Word# -> Word#
    -
     ------------------------------------------------------------------------
     section "Double#"
             {Operations on double-precision (64 bit) floating-point numbers.}
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -624,39 +624,6 @@ primOpRules nm = \case
        WordToIntOp    -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumInt) ]
        IntToWordOp    -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumWord) ]
     
    -   Narrow8IntOp   -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumInt8)
    -                                       , subsumedByPrimOp Narrow8IntOp
    -                                       , Narrow8IntOp `subsumesPrimOp` Narrow16IntOp
    -                                       , Narrow8IntOp `subsumesPrimOp` Narrow32IntOp
    -                                       , narrowSubsumesAnd IntAndOp Narrow8IntOp 8 ]
    -   Narrow16IntOp  -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumInt16)
    -                                       , subsumedByPrimOp Narrow8IntOp
    -                                       , subsumedByPrimOp Narrow16IntOp
    -                                       , Narrow16IntOp `subsumesPrimOp` Narrow32IntOp
    -                                       , narrowSubsumesAnd IntAndOp Narrow16IntOp 16 ]
    -   Narrow32IntOp  -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumInt32)
    -                                       , subsumedByPrimOp Narrow8IntOp
    -                                       , subsumedByPrimOp Narrow16IntOp
    -                                       , subsumedByPrimOp Narrow32IntOp
    -                                       , removeOp32
    -                                       , narrowSubsumesAnd IntAndOp Narrow32IntOp 32 ]
    -   Narrow8WordOp  -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumWord8)
    -                                       , subsumedByPrimOp Narrow8WordOp
    -                                       , Narrow8WordOp `subsumesPrimOp` Narrow16WordOp
    -                                       , Narrow8WordOp `subsumesPrimOp` Narrow32WordOp
    -                                       , narrowSubsumesAnd WordAndOp Narrow8WordOp 8 ]
    -   Narrow16WordOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumWord16)
    -                                       , subsumedByPrimOp Narrow8WordOp
    -                                       , subsumedByPrimOp Narrow16WordOp
    -                                       , Narrow16WordOp `subsumesPrimOp` Narrow32WordOp
    -                                       , narrowSubsumesAnd WordAndOp Narrow16WordOp 16 ]
    -   Narrow32WordOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumWord32)
    -                                       , subsumedByPrimOp Narrow8WordOp
    -                                       , subsumedByPrimOp Narrow16WordOp
    -                                       , subsumedByPrimOp Narrow32WordOp
    -                                       , removeOp32
    -                                       , narrowSubsumesAnd WordAndOp Narrow32WordOp 32 ]
    -
        OrdOp          -> mkPrimOpRule nm 1 [ liftLit charToIntLit
                                            , semiInversePrimOp ChrOp ]
        ChrOp          -> mkPrimOpRule nm 1 [ do [Lit lit] <- getArgs
    @@ -1460,18 +1427,6 @@ semiInversePrimOp primop = do
       matchPrimOpId primop primop_id
       return e
     
    -subsumesPrimOp :: PrimOp -> PrimOp -> RuleM CoreExpr
    -this `subsumesPrimOp` that = do
    -  [Var primop_id `App` e] <- getArgs
    -  matchPrimOpId that primop_id
    -  return (Var (primOpId this) `App` e)
    -
    -subsumedByPrimOp :: PrimOp -> RuleM CoreExpr
    -subsumedByPrimOp primop = do
    -  [e@(Var primop_id `App` _)] <- getArgs
    -  matchPrimOpId primop primop_id
    -  return e
    -
     -- | Transform `extendWordN (narrowWordN x)` into `x .&. 0xFF..FF`
     extendNarrowPassthrough :: PrimOp -> Integer -> RuleM CoreExpr
     extendNarrowPassthrough narrow_primop n = do
    @@ -1531,7 +1486,7 @@ Consider this code:
       chunkToBitmap :: [Bool] -> Word32
       chunkToBitmap chunk = foldr (.|.) 0 [ 1 `shiftL` n | (True,n) <- zip chunk [0..] ]
     
    -This optimises to:
    +This optimised to:
     Shift.$wgo = \ (w_sCS :: GHC.Prim.Int#) (w1_sCT :: [GHC.Types.Bool]) ->
         case w1_sCT of _ {
           [] -> 0##;
    @@ -1669,16 +1624,6 @@ liftLitPlatform f = do
       [Lit lit] <- getArgs
       return $ Lit (f platform lit)
     
    -removeOp32 :: RuleM CoreExpr
    -removeOp32 = do
    -  platform <- getPlatform
    -  case platformWordSize platform of
    -    PW4 -> do
    -      [e] <- getArgs
    -      return e
    -    PW8 ->
    -      mzero
    -
     getArgs :: RuleM [CoreExpr]
     getArgs = RuleM $ \_ _ _ args -> Just args
     
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -1081,13 +1081,6 @@ emitPrimOp cfg primop =
       ChrOp           -> \args -> opNop args  -- Int# and Char# are rep'd the same
       OrdOp           -> \args -> opNop args
     
    -  Narrow8IntOp   -> \args -> opNarrow args (MO_SS_Conv, W8)
    -  Narrow16IntOp  -> \args -> opNarrow args (MO_SS_Conv, W16)
    -  Narrow32IntOp  -> \args -> opNarrow args (MO_SS_Conv, W32)
    -  Narrow8WordOp  -> \args -> opNarrow args (MO_UU_Conv, W8)
    -  Narrow16WordOp -> \args -> opNarrow args (MO_UU_Conv, W16)
    -  Narrow32WordOp -> \args -> opNarrow args (MO_UU_Conv, W32)
    -
       DoublePowerOp  -> \args -> opCallish args MO_F64_Pwr
       DoubleSinOp    -> \args -> opCallish args MO_F64_Sin
       DoubleCosOp    -> \args -> opCallish args MO_F64_Cos
    @@ -1664,14 +1657,6 @@ emitPrimOp cfg primop =
       opNop args = opIntoRegs $ \[res] -> emitAssign (CmmLocal res) arg
         where [arg] = args
     
    -  opNarrow
    -    :: [CmmExpr]
    -    -> (Width -> Width -> MachOp, Width)
    -    -> PrimopCmmEmit
    -  opNarrow args (mop, rep) = opIntoRegs $ \[res] -> emitAssign (CmmLocal res) $
    -    CmmMachOp (mop rep (wordWidth platform)) [CmmMachOp (mop (wordWidth platform) rep) [arg]]
    -    where [arg] = args
    -
       -- These primops are implemented by CallishMachOps, because they sometimes
       -- turn into foreign calls depending on the backend.
       opCallish :: [CmmExpr] -> CallishMachOp -> PrimopCmmEmit
    
    
    =====================================
    compiler/GHC/StgToJS/Prim.hs
    =====================================
    @@ -445,15 +445,6 @@ genPrim prof bound ty op = case op of
                                                             , rh |= app "h$reverseWord" [l]
                                                             ]
     
    ------------------------------- Narrow -------------------------------------------
    -
    -  Narrow8IntOp    -> \[r] [x] -> PrimInline $ r |= signExtend8  x
    -  Narrow16IntOp   -> \[r] [x] -> PrimInline $ r |= signExtend16 x
    -  Narrow32IntOp   -> \[r] [x] -> PrimInline $ r |= toI32  x
    -  Narrow8WordOp   -> \[r] [x] -> PrimInline $ r |= mask8  x
    -  Narrow16WordOp  -> \[r] [x] -> PrimInline $ r |= mask16 x
    -  Narrow32WordOp  -> \[r] [x] -> PrimInline $ r |= toU32  x
    -
     ------------------------------ Double -------------------------------------------
     
       DoubleGtOp        -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>.   y)
    
    
    =====================================
    libraries/base/GHC/Prim/Deprecated.hs
    =====================================
    @@ -0,0 +1,39 @@
    +{-# LANGUAGE MagicHash #-}
    +{-# LANGUAGE UnboxedTuples #-}
    +{-# LANGUAGE NoImplicitPrelude #-}
    +
    +-- | Provide some functions with the same names and interfaces as removed
    +-- primops.
    +module GHC.Prim.Deprecated
    +  (
    +  -- narrowing ops
    +    narrow8Int#
    +  , narrow16Int#
    +  , narrow32Int#
    +  , narrow8Word#
    +  , narrow16Word#
    +  , narrow32Word#
    +  ) where
    +
    +import GHC.Prim
    +import GHC.Types () -- Make implicit dependency known to build system
    +
    +default () -- Double and Integer aren't available yet
    +
    +narrow8Int#   :: Int# -> Int#
    +narrow8Int# i = i `andI#` 0xFF#
    +
    +narrow16Int#  :: Int# -> Int#
    +narrow16Int# i = i `andI#` 0xFFFF#
    +
    +narrow32Int#  :: Int# -> Int#
    +narrow32Int# i = i `andI#` 0xFFFFFFFF#
    +
    +narrow8Word#  :: Word# -> Word#
    +narrow8Word# i = i `and#` 0xFF##
    +
    +narrow16Word# :: Word# -> Word#
    +narrow16Word# i = i `and#` 0xFFFF##
    +
    +narrow32Word# :: Word# -> Word#
    +narrow32Word# i = i `and#` 0xFFFFFFFF##
    
    
    =====================================
    libraries/base/base.cabal
    =====================================
    @@ -354,6 +354,7 @@ Library
             GHC.Event.PSQ
             GHC.Event.Unique
             GHC.Foreign.Internal
    +        GHC.Prim.Deprecated
             -- GHC.IOPort -- TODO: hide again after debug
             GHC.Unicode.Internal.Bits
             GHC.Unicode.Internal.Char.DerivedCoreProperties
    
    
    =====================================
    libraries/base/src/GHC/Bits.hs
    =====================================
    @@ -719,6 +719,6 @@ own to enable constant folding; for example 'shift':
     -- > i16_to_w16 = \x -> case eta of _
     -- >   { I16# b1 -> case tagToEnum# (<=# 0 b1) of _
     -- >       { False -> Nothing
    --- >       ; True -> Just (W16# (narrow16Word# (int2Word# b1)))
    +-- >       ; True -> Just (W16# (WordToWord16# (int2Word# b1)))
     -- >       }
     -- >   }
    
    
    =====================================
    libraries/base/src/GHC/Exts.hs
    =====================================
    @@ -38,6 +38,7 @@ module GHC.Exts
     
             module GHC.Prim,
             module GHC.Prim.Ext,
    +        module GHC.Prim.Deprecated,
     
             -- ** Running 'RealWorld' state thread
             runRW#,
    @@ -138,6 +139,7 @@ import GHC.Types
                -- GHC's internal representation of 'TyCon's, for 'Typeable'
              , Module, TrName, TyCon, TypeLitSort, KindRep, KindBndr )
     import qualified GHC.Prim.Ext
    +import qualified GHC.Prim.Deprecated
     import GHC.ArrayArray
     import GHC.Base hiding ( coerce )
     import GHC.Ptr
    
    
    =====================================
    libraries/base/src/GHC/Float/ConversionUtils.hs
    =====================================
    @@ -61,6 +61,6 @@ elimZerosInt# n e =
     
     -- | Number of trailing zero bits in a byte
     zeroCount :: Int# -> Int#
    -zeroCount i = int8ToInt# (indexInt8OffAddr# arr (word2Int# (narrow8Word# (int2Word# i)))) -- index must be in [0,255]
    +zeroCount i = int8ToInt# (indexInt8OffAddr# arr (i `andI#` 255#)) -- index must be in [0,255]
       where
         arr = "\8\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\6\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\7\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\6\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0"#
    
    
    =====================================
    libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
    =====================================
    @@ -57,11 +57,11 @@ narrowGmpSize# x = x
     -- On IL32P64 (i.e. Win64), we have to be careful with CLong not being
     -- 64bit.  This is mostly an issue on values returned from C functions
     -- due to sign-extension.
    -narrowGmpSize# = narrow32Int#
    +narrowGmpSize# i = int32ToInt# (intToInt32# i)
     #endif
     
     narrowCInt# :: Int# -> Int#
    -narrowCInt# = narrow32Int#
    +narrowCInt# i = int32ToInt# (intToInt32# i)
     
     bignat_compare :: WordArray# -> WordArray# -> Int#
     bignat_compare x y = narrowCInt# (c_mpn_cmp x y (wordArraySize# x))
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cd6f6815f2b3820763ea15c29e1a5f2757ac719
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cd6f6815f2b3820763ea15c29e1a5f2757ac719
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 12 18:43:40 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Thu, 12 Oct 2023 14:43:40 -0400
    Subject: [Git][ghc/ghc][wip/rts-cabal-file-no-stage-specific-subst] Do not
     substitute `@...@` for stage-specific values in cabal files
    Message-ID: <65283e5c449bb_24a445daa091c1845f8@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/rts-cabal-file-no-stage-specific-subst at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    49f00097 by John Ericson at 2023-10-12T14:35:42-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    
    
    6 changed files:
    
    - .gitignore
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Settings/Packages.hs
    - libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    - rts/.gitignore
    - rts/rts.cabal.in → rts/rts.cabal
    
    
    Changes:
    
    =====================================
    .gitignore
    =====================================
    @@ -167,7 +167,6 @@ _darcs/
     /libraries/ghc-boot-th/ghc-boot-th.cabal
     /libraries/ghc-boot-th/ghc.mk
     /libraries/ghc-heap/ghc-heap.cabal
    -/libraries/ghc-prim/ghc-prim.cabal
     /libraries/ghci/GNUmakefile
     /libraries/ghci/ghci.cabal
     /libraries/ghci/ghc.mk
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -268,17 +268,6 @@ runInterpolations (Interpolations mk_substs) input = do
             subst = foldr (.) id [replace ("@"++k++"@") v | (k,v) <- substs]
         return (subst input)
     
    -toCabalBool :: Bool -> String
    -toCabalBool True  = "True"
    -toCabalBool False = "False"
    -
    --- | Interpolate the given variable with the value of the given 'Flag', using
    --- Cabal's boolean syntax.
    -interpolateCabalFlag :: String -> Flag -> Interpolations
    -interpolateCabalFlag name flg = interpolateVar name $ do
    -    val <- flag flg
    -    return (toCabalBool val)
    -
     -- | Interpolate the given variable with the value of the given 'Setting'.
     interpolateSetting :: String -> Setting -> Interpolations
     interpolateSetting name settng = interpolateVar name $ setting settng
    @@ -290,31 +279,6 @@ projectVersion = mconcat
         , interpolateSetting "ProjectVersionMunged" ProjectVersionMunged
         ]
     
    -rtsCabalFlags :: Interpolations
    -rtsCabalFlags = mconcat
    -    [ flag "CabalHaveLibdw" UseLibdw
    -    , flag "CabalHaveLibm" UseLibm
    -    , flag "CabalHaveLibrt" UseLibrt
    -    , flag "CabalHaveLibdl" UseLibdl
    -    , flag "CabalNeedLibpthread" UseLibpthread
    -    , flag "CabalHaveLibbfd" UseLibbfd
    -    , flag "CabalHaveLibNuma" UseLibnuma
    -    , flag "CabalHaveLibZstd" UseLibzstd
    -    , flag "CabalStaticLibZstd" StaticLibzstd
    -    , flag "CabalNeedLibatomic" NeedLibatomic
    -    , flag "CabalUseSystemLibFFI" UseSystemFfi
    -    , targetFlag "CabalLibffiAdjustors" tgtUseLibffiForAdjustors
    -    , targetFlag "CabalLeadingUnderscore" tgtSymbolsHaveLeadingUnderscore
    -    ]
    -  where
    -    flag = interpolateCabalFlag
    -    targetFlag name q = interpolateVar name $ do
    -      val <- queryTargetTarget q
    -      return (toCabalBool val)
    -
    -ghcPrimCabalFlags :: Interpolations
    -ghcPrimCabalFlags = interpolateCabalFlag "CabalNeedLibatomic" NeedLibatomic
    -
     packageVersions :: Interpolations
     packageVersions = foldMap f [ base, ghcPrim, compiler, ghc, cabal, templateHaskell, ghcCompact, array ]
       where
    @@ -347,8 +311,6 @@ templateRule outPath interps = do
     templateRules :: Rules ()
     templateRules = do
       templateRule "compiler/ghc.cabal" $ projectVersion
    -  templateRule "rts/rts.cabal" $ rtsCabalFlags
    -  templateRule "libraries/ghc-prim/ghc-prim.cabal" $ ghcPrimCabalFlags
       templateRule "driver/ghci/ghci-wrapper.cabal" $ projectVersion
       templateRule "ghc/ghc-bin.cabal" $ projectVersion
       templateRule "utils/iserv/iserv.cabal" $ projectVersion
    
    
    =====================================
    hadrian/src/Settings/Packages.hs
    =====================================
    @@ -114,7 +114,7 @@ packageArgs = do
     
             -------------------------------- ghcPrim -------------------------------
             , package ghcPrim ? mconcat
    -          [ builder (Cabal Flags) ? arg "include-ghc-prim"
    +          [ builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic"
     
               , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ?
                 input "**/cbits/atomic.c"  ? arg "-Wno-sync-nand" ]
    @@ -401,8 +401,19 @@ rtsPackageArgs = package rts ? do
               , any (wayUnit Debug) rtsWays     `cabalFlag` "debug"
               , any (wayUnit Dynamic) rtsWays   `cabalFlag` "dynamic"
               , any (wayUnit Threaded) rtsWays  `cabalFlag` "threaded"
    +          , flag UseLibm                    `cabalFlag` "libm"
    +          , flag UseLibrt                   `cabalFlag` "librt"
    +          , flag UseLibdl                   `cabalFlag` "libdl"
               , useSystemFfi                    `cabalFlag` "use-system-libffi"
               , useLibffiForAdjustors           `cabalFlag` "libffi-adjustors"
    +          , flag UseLibpthread              `cabalFlag` "need-pthread"
    +          , flag UseLibbfd                  `cabalFlag` "libbfd"
    +          , flag NeedLibatomic              `cabalFlag` "need-atomic"
    +          , flag UseLibdw                   `cabalFlag` "libdw"
    +          , flag UseLibnuma                 `cabalFlag` "libnuma"
    +          , flag UseLibzstd                 `cabalFlag` "libzstd"
    +          , flag StaticLibzstd              `cabalFlag` "static-libzstd"
    +          , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
               , Debug `wayUnit` way             `cabalFlag` "find-ptr"
               ]
             , builder (Cabal Setup) ? mconcat
    
    
    =====================================
    libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    =====================================
    @@ -28,7 +28,7 @@ custom-setup
         setup-depends: base >= 4 && < 5, process, filepath, directory, Cabal >= 1.23 && < 3.9
     
     flag need-atomic
    -  default: @CabalNeedLibatomic@
    +  default: False
     
     Library
         default-language: Haskell2010
    
    
    =====================================
    rts/.gitignore
    =====================================
    @@ -2,8 +2,6 @@
     /dist/
     /dist-*/
     
    -/rts.cabal
    -
     /include/ghcversion.h
     
     /package.conf.inplace
    
    
    =====================================
    rts/rts.cabal.in → rts/rts.cabal
    =====================================
    @@ -29,31 +29,31 @@ source-repository head
         subdir:   rts
     
     flag libm
    -  default: @CabalHaveLibm@
    +  default: False
     flag librt
    -  default: @CabalHaveLibrt@
    +  default: False
     flag libdl
    -  default: @CabalHaveLibdl@
    +  default: False
     flag use-system-libffi
    -  default: @CabalUseSystemLibFFI@
    +  default: False
     flag libffi-adjustors
    -  default: @CabalLibffiAdjustors@
    +  default: False
     flag need-pthread
    -  default: @CabalNeedLibpthread@
    +  default: False
     flag libbfd
    -  default: @CabalHaveLibbfd@
    +  default: False
     flag need-atomic
    -  default: @CabalNeedLibatomic@
    +  default: False
     flag libdw
    -  default: @CabalHaveLibdw@
    +  default: False
     flag libnuma
    -  default: @CabalHaveLibNuma@
    +  default: False
     flag libzstd
    -  default: @CabalHaveLibZstd@
    +  default: False
     flag static-libzstd
    -  default: @CabalStaticLibZstd@
    +  default: False
     flag leading-underscore
    -  default: @CabalLeadingUnderscore@
    +  default: False
     flag smp
       default: True
     flag find-ptr
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49f0009706922dbd39064ea13098fa2535558fab
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49f0009706922dbd39064ea13098fa2535558fab
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 12 18:43:50 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Thu, 12 Oct 2023 14:43:50 -0400
    Subject: [Git][ghc/ghc][wip/rts-configure] 8 commits: Do not substitute
     `@...@` for stage-specific values in cabal files
    Message-ID: <65283e66b0f8b_24a445dca22d81850da@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/rts-configure at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    49f00097 by John Ericson at 2023-10-12T14:35:42-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    512b884b by John Ericson at 2023-10-12T14:36:38-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    8766b7ce by John Ericson at 2023-10-12T14:36:41-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    960fc54f by John Ericson at 2023-10-12T14:36:44-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    58944c9d by John Ericson at 2023-10-12T14:38:33-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    d357e533 by John Ericson at 2023-10-12T14:38:40-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    4ecdde35 by John Ericson at 2023-10-12T14:41:23-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    47c36720 by John Ericson at 2023-10-12T14:41:24-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    
    
    19 changed files:
    
    - .gitignore
    - compiler/GHC/Builtin/primops.txt.pp
    - configure.ac
    - distrib/cross-port
    - docs/coding-style.html
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Rules/Lint.hs
    - hadrian/src/Rules/Register.hs
    - hadrian/src/Rules/SourceDist.hs
    - hadrian/src/Settings/Packages.hs
    - libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    - m4/fp_cc_supports__atomics.m4
    - m4/fptools_set_haskell_platform_vars.m4
    - m4/ghc_convert_os.m4
    - rts/.gitignore
    - rts/configure.ac
    - + rts/ghcplatform.h.bottom
    - + rts/ghcplatform.h.top.in
    - rts/rts.cabal.in → rts/rts.cabal
    
    
    Changes:
    
    =====================================
    .gitignore
    =====================================
    @@ -167,7 +167,6 @@ _darcs/
     /libraries/ghc-boot-th/ghc-boot-th.cabal
     /libraries/ghc-boot-th/ghc.mk
     /libraries/ghc-heap/ghc-heap.cabal
    -/libraries/ghc-prim/ghc-prim.cabal
     /libraries/ghci/GNUmakefile
     /libraries/ghci/ghci.cabal
     /libraries/ghci/ghc.mk
    @@ -185,8 +184,8 @@ _darcs/
     /linter.log
     /mk/are-validating.mk
     /mk/build.mk
    -/mk/config.h
    -/mk/config.h.in
    +/mk/unused.h
    +/mk/unused.h.in
     /mk/config.mk
     /mk/config.mk.old
     /mk/system-cxx-std-lib-1.0.conf
    
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -229,7 +229,7 @@ section "The word size story."
              must contain at least 30 bits. GHC always implements
              'Int' using the primitive type 'Int#', whose size equals
              the @MachDeps.h@ constant @WORD\_SIZE\_IN\_BITS at .
    -         This is normally set based on the @config.h@ parameter
    +         This is normally set based on the RTS @ghcautoconf.h@ parameter
              @SIZEOF\_HSWORD@, i.e., 32 bits on 32-bit machines, 64
              bits on 64-bit machines.
     
    
    
    =====================================
    configure.ac
    =====================================
    @@ -32,8 +32,8 @@ AC_CONFIG_MACRO_DIRS([m4])
     # checkout), then we ship a file 'VERSION' containing the full version
     # when the source distribution was created.
     
    -if test ! -f mk/config.h.in; then
    -   echo "mk/config.h.in doesn't exist: perhaps you haven't run 'python3 boot'?"
    +if test ! -f rts/ghcautoconf.h.autoconf.in; then
    +   echo "rts/ghcautoconf.h.autoconf.in doesn't exist: perhaps you haven't run 'python3 boot'?"
        exit 1
     fi
     
    @@ -101,8 +101,11 @@ AC_PREREQ([2.69])
     # Prepare to generate the following header files
     #
     
    -# This one is autogenerated by autoheader.
    -AC_CONFIG_HEADER(mk/config.h)
    +dnl so the next header, which is manually maintained, doesn't get
    +dnl overwritten by an autogenerated header. Once we have no more
    +dnl `AC_CONFIG_HEADER` calls (issue #23966) we can delete all mention
    +dnl of `mk/unused.h`.
    +AC_CONFIG_HEADER(mk/unused.h)
     # This one is manually maintained.
     AC_CONFIG_HEADER(compiler/ghc-llvm-version.h)
     dnl manually outputted above, for reasons described there.
    @@ -157,27 +160,6 @@ if test "$EnableDistroToolchain" = "YES"; then
       TarballsAutodownload=NO
     fi
     
    -AC_ARG_ENABLE(asserts-all-ways,
    -[AS_HELP_STRING([--enable-asserts-all-ways],
    -                [Usually ASSERTs are only compiled in the DEBUG way,
    -                 this will enable them in all ways.])],
    -  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    -  [EnableAssertsAllWays=NO]
    -)
    -if test "$enable_asserts_all_ways" = "yes" ; then
    -   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    -fi
    -
    -AC_ARG_ENABLE(native-io-manager,
    -[AS_HELP_STRING([--enable-native-io-manager],
    -                [Enable the native I/O manager by default.])],
    -  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    -  [EnableNativeIOManager=NO]
    -)
    -if test "$EnableNativeIOManager" = "YES"; then
    -  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    -fi
    -
     AC_ARG_ENABLE(ghc-toolchain,
     [AS_HELP_STRING([--enable-ghc-toolchain],
                     [Whether to use the newer ghc-toolchain tool to configure ghc targets])],
    @@ -338,9 +320,6 @@ dnl ** Do a build with tables next to code?
     dnl --------------------------------------------------------------
     
     GHC_TABLES_NEXT_TO_CODE
    -if test x"$TablesNextToCode" = xYES; then
    -   AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])
    -fi
     AC_SUBST(TablesNextToCode)
     
     # Requires FPTOOLS_SET_PLATFORMS_VARS to be run first.
    @@ -636,12 +615,15 @@ dnl    unregisterised, Sparc, and PPC backends. Also determines whether
     dnl    linking to libatomic is required for atomic operations, e.g. on
     dnl    RISCV64 GCC.
     FP_CC_SUPPORTS__ATOMICS
    +if test "$need_latomic" = 1; then
    +    AC_SUBST([NeedLibatomic],[YES])
    +else
    +    AC_SUBST([NeedLibatomic],[NO])
    +fi
     
     dnl ** look to see if we have a C compiler using an llvm back end.
     dnl
     FP_CC_LLVM_BACKEND
    -AS_IF([test x"$CcLlvmBackend" = x"YES"],
    -  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
     AC_SUBST(CcLlvmBackend)
     
     FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
    @@ -864,88 +846,14 @@ dnl --------------------------------------------------
     dnl ### program checking section ends here ###
     dnl --------------------------------------------------
     
    -dnl --------------------------------------------------
    -dnl * Platform header file and syscall feature tests
    -dnl ### checking the state of the local header files and syscalls ###
    -
    -dnl ** Enable large file support.  NB. do this before testing the type of
    -dnl    off_t, because it will affect the result of that test.
    -AC_SYS_LARGEFILE
    -
    -dnl ** check for specific header (.h) files that we are interested in
    -AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    -
    -dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    -AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    -[[#if HAVE_SYS_PARAM_H
    -# include 
    -#endif
    -]])
    -
    -dnl ** check whether a declaration for `environ` is provided by libc.
    -FP_CHECK_ENVIRON
    -
    -dnl ** do we have long longs?
    -AC_CHECK_TYPES([long long])
    -
    -dnl ** what are the sizes of various types
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    -if test "$ac_cv_type_long_long" = yes; then
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    -fi
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    -if test "$ac_cv_type_long_long" = yes; then
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    -fi
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    -
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    -
    -
     dnl for use in settings file
    +AC_CHECK_SIZEOF([void *])
     TargetWordSize=$ac_cv_sizeof_void_p
     AC_SUBST(TargetWordSize)
     
     AC_C_BIGENDIAN([TargetWordBigEndian=YES],[TargetWordBigEndian=NO])
     AC_SUBST(TargetWordBigEndian)
     
    -FP_CHECK_FUNC([WinExec],
    -  [@%:@include ], [WinExec("",0)])
    -
    -FP_CHECK_FUNC([GetModuleFileName],
    -  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    -
    -dnl ** check for more functions
    -dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    -AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    -
    -dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    -dnl ** _POSIX_C_SOURCE is defined
    -AC_CHECK_DECLS([ctime_r], , ,
    -[#define _POSIX_SOURCE 1
    -#define _POSIX_C_SOURCE 199506L
    -#include ])
    -
    -dnl On Linux we should have program_invocation_short_name
    -AC_CHECK_DECLS([program_invocation_short_name], , ,
    -[#define _GNU_SOURCE 1
    -#include ])
    -
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    
    
    =====================================
    distrib/cross-port
    =====================================
    @@ -28,7 +28,7 @@ if [ ! -f b1-stamp ]; then
     
        # For cross-compilation, at this stage you may want to set up a source
        # tree on the target machine, run the configure script there, and bring
    -   # the resulting mk/config.h file back into this tree before building
    +   # the resulting rts/ghcautoconf.h.autoconf file back into this tree before building
        # the libraries.
     
        touch mk/build.mk
    @@ -38,7 +38,7 @@ if [ ! -f b1-stamp ]; then
     
        # We could optimise slightly by not building hslibs here.  Also, building
        # the RTS is not necessary (and might not be desirable if we're using
    -   # a config.h from the target system).
    +   # a ghcautoconf.h from the target system).
        make stage1
     
       cd ..
    
    
    =====================================
    docs/coding-style.html
    =====================================
    @@ -108,7 +108,7 @@ POSIX-compliant to explicitly say so by having #include
     
     

  • Some architectures have memory alignment constraints. Others don't have any constraints but go faster if you align things. These -macros (from config.h) tell you which alignment to use +macros (from ghcautoconf.h) tell you which alignment to use
       /* minimum alignment of unsigned int */
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -155,10 +155,10 @@ generatePackageCode context@(Context stage pkg _ _) = do
         when (pkg == rts) $ do
             root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file ->
                 build $ target context GenApply [] [file]
    -        let go gen file = generate file (semiEmptyTarget stage) gen
             root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ ->
                 need . pure =<< pkgSetupConfigFile context
    -        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH
    +        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ ->
    +            need . pure =<< pkgSetupConfigFile context
             root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context
             root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines"
             root -/- "**" -/- dir -/- "include/rts/EventTypes.h" %> genEventTypes "--event-types-array"
    @@ -268,17 +268,6 @@ runInterpolations (Interpolations mk_substs) input = do
             subst = foldr (.) id [replace ("@"++k++"@") v | (k,v) <- substs]
         return (subst input)
     
    -toCabalBool :: Bool -> String
    -toCabalBool True  = "True"
    -toCabalBool False = "False"
    -
    --- | Interpolate the given variable with the value of the given 'Flag', using
    --- Cabal's boolean syntax.
    -interpolateCabalFlag :: String -> Flag -> Interpolations
    -interpolateCabalFlag name flg = interpolateVar name $ do
    -    val <- flag flg
    -    return (toCabalBool val)
    -
     -- | Interpolate the given variable with the value of the given 'Setting'.
     interpolateSetting :: String -> Setting -> Interpolations
     interpolateSetting name settng = interpolateVar name $ setting settng
    @@ -290,31 +279,6 @@ projectVersion = mconcat
         , interpolateSetting "ProjectVersionMunged" ProjectVersionMunged
         ]
     
    -rtsCabalFlags :: Interpolations
    -rtsCabalFlags = mconcat
    -    [ flag "CabalHaveLibdw" UseLibdw
    -    , flag "CabalHaveLibm" UseLibm
    -    , flag "CabalHaveLibrt" UseLibrt
    -    , flag "CabalHaveLibdl" UseLibdl
    -    , flag "CabalNeedLibpthread" UseLibpthread
    -    , flag "CabalHaveLibbfd" UseLibbfd
    -    , flag "CabalHaveLibNuma" UseLibnuma
    -    , flag "CabalHaveLibZstd" UseLibzstd
    -    , flag "CabalStaticLibZstd" StaticLibzstd
    -    , flag "CabalNeedLibatomic" NeedLibatomic
    -    , flag "CabalUseSystemLibFFI" UseSystemFfi
    -    , targetFlag "CabalLibffiAdjustors" tgtUseLibffiForAdjustors
    -    , targetFlag "CabalLeadingUnderscore" tgtSymbolsHaveLeadingUnderscore
    -    ]
    -  where
    -    flag = interpolateCabalFlag
    -    targetFlag name q = interpolateVar name $ do
    -      val <- queryTargetTarget q
    -      return (toCabalBool val)
    -
    -ghcPrimCabalFlags :: Interpolations
    -ghcPrimCabalFlags = interpolateCabalFlag "CabalNeedLibatomic" NeedLibatomic
    -
     packageVersions :: Interpolations
     packageVersions = foldMap f [ base, ghcPrim, compiler, ghc, cabal, templateHaskell, ghcCompact, array ]
       where
    @@ -347,8 +311,6 @@ templateRule outPath interps = do
     templateRules :: Rules ()
     templateRules = do
       templateRule "compiler/ghc.cabal" $ projectVersion
    -  templateRule "rts/rts.cabal" $ rtsCabalFlags
    -  templateRule "libraries/ghc-prim/ghc-prim.cabal" $ ghcPrimCabalFlags
       templateRule "driver/ghci/ghci-wrapper.cabal" $ projectVersion
       templateRule "ghc/ghc-bin.cabal" $ projectVersion
       templateRule "utils/iserv/iserv.cabal" $ projectVersion
    @@ -384,62 +346,6 @@ ghcWrapper stage  = do
                                          else [])
                                    ++ [ "$@" ]
     
    --- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that
    --- the resulting 'String' is a valid C preprocessor identifier.
    -cppify :: String -> String
    -cppify = replaceEq '-' '_' . replaceEq '.' '_'
    -
    --- | Generate @ghcplatform.h@ header.
    --- ROMES:TODO: For the runtime-retargetable GHC, these will eventually have to
    --- be determined at runtime, and no longer hardcoded to a file (passed as -D
    --- flags to the preprocessor, probably)
    -generateGhcPlatformH :: Expr String
    -generateGhcPlatformH = do
    -    trackGenerateHs
    -    stage    <- getStage
    -    let chooseSetting x y = case stage of { Stage0 {} -> x; _ -> y }
    -    buildPlatform  <- chooseSetting (queryBuild targetPlatformTriple) (queryHost targetPlatformTriple)
    -    buildArch      <- chooseSetting (queryBuild queryArch)   (queryHost queryArch)
    -    buildOs        <- chooseSetting (queryBuild queryOS)     (queryHost queryOS)
    -    buildVendor    <- chooseSetting (queryBuild queryVendor) (queryHost queryVendor)
    -    hostPlatform   <- chooseSetting (queryHost targetPlatformTriple) (queryTarget targetPlatformTriple)
    -    hostArch       <- chooseSetting (queryHost queryArch)    (queryTarget queryArch)
    -    hostOs         <- chooseSetting (queryHost queryOS)      (queryTarget queryOS)
    -    hostVendor     <- chooseSetting (queryHost queryVendor)  (queryTarget queryVendor)
    -    ghcUnreg       <- queryTarget tgtUnregisterised
    -    return . unlines $
    -        [ "#if !defined(__GHCPLATFORM_H__)"
    -        , "#define __GHCPLATFORM_H__"
    -        , ""
    -        , "#define BuildPlatform_TYPE  " ++ cppify buildPlatform
    -        , "#define HostPlatform_TYPE   " ++ cppify hostPlatform
    -        , ""
    -        , "#define " ++ cppify buildPlatform   ++ "_BUILD 1"
    -        , "#define " ++ cppify hostPlatform ++ "_HOST 1"
    -        , ""
    -        , "#define " ++ buildArch   ++ "_BUILD_ARCH 1"
    -        , "#define " ++ hostArch ++ "_HOST_ARCH 1"
    -        , "#define BUILD_ARCH " ++ show buildArch
    -        , "#define HOST_ARCH "  ++ show hostArch
    -        , ""
    -        , "#define " ++ buildOs   ++ "_BUILD_OS 1"
    -        , "#define " ++ hostOs ++ "_HOST_OS 1"
    -        , "#define BUILD_OS " ++ show buildOs
    -        , "#define HOST_OS "  ++ show hostOs
    -        , ""
    -        , "#define " ++ buildVendor   ++ "_BUILD_VENDOR 1"
    -        , "#define " ++ hostVendor ++ "_HOST_VENDOR 1"
    -        , "#define BUILD_VENDOR " ++ show buildVendor
    -        , "#define HOST_VENDOR "  ++ show hostVendor
    -        , ""
    -        ]
    -        ++
    -        [ "#define UnregisterisedCompiler 1" | ghcUnreg ]
    -        ++
    -        [ ""
    -        , "#endif /* __GHCPLATFORM_H__ */"
    -        ]
    -
     generateSettings :: Expr String
     generateSettings = do
         ctx <- getContext
    
    
    =====================================
    hadrian/src/Rules/Lint.hs
    =====================================
    @@ -22,6 +22,8 @@ lintRules = do
           cmd_ (Cwd "libraries/base") "./configure"
       "rts" -/- "include" -/- "ghcautoconf.h" %> \_ ->
           cmd_ (Cwd "rts") "./configure"
    +  "rts" -/- "include" -/- "ghcplatform.h" %> \_ ->
    +      cmd_ (Cwd "rts") "./configure"
     
     lint :: Action () -> Action ()
     lint lintAction = do
    @@ -68,7 +70,6 @@ base = do
       let includeDirs =
             [ "rts/include"
             , "libraries/base/include"
    -        , stage1RtsInc
             ]
       runHLint includeDirs [] "libraries/base"
     
    
    
    =====================================
    hadrian/src/Rules/Register.hs
    =====================================
    @@ -51,12 +51,6 @@ configurePackageRules = do
               isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend
               when isGmp $
                 need [buildP -/- "include/ghc-gmp.h"]
    -        when (pkg == rts) $ do
    -          -- Rts.h is a header listed in the cabal file, and configuring
    -          -- therefore wants to ensure that the header "works" post-configure.
    -          -- But it (transitively) includes this, so we must ensure it exists
    -          -- for that check to work.
    -          need [buildP -/- "include/ghcplatform.h"]
             Cabal.configurePackage ctx
     
         root -/- "**/autogen/cabal_macros.h" %> \out -> do
    
    
    =====================================
    hadrian/src/Rules/SourceDist.hs
    =====================================
    @@ -156,7 +156,8 @@ prepareTree dest = do
           , pkgPath terminfo -/- "configure"
           , "configure"
           , "aclocal.m4"
    -      , "mk" -/- "config.h.in" ]
    +      , "mk" -/- "unused.h.in"
    +      ]
     
         copyAlexHappyFiles =
           forM_ alexHappyFiles $ \(stg, pkg, inp, out) -> do
    
    
    =====================================
    hadrian/src/Settings/Packages.hs
    =====================================
    @@ -114,7 +114,7 @@ packageArgs = do
     
             -------------------------------- ghcPrim -------------------------------
             , package ghcPrim ? mconcat
    -          [ builder (Cabal Flags) ? arg "include-ghc-prim"
    +          [ builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic"
     
               , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ?
                 input "**/cbits/atomic.c"  ? arg "-Wno-sync-nand" ]
    @@ -281,8 +281,8 @@ rtsPackageArgs = package rts ? do
         targetArch     <- queryTarget queryArch
         targetOs       <- queryTarget queryOS
         targetVendor   <- queryTarget queryVendor
    -    ghcUnreg       <- yesNo <$> queryTarget tgtUnregisterised
    -    ghcEnableTNC   <- yesNo <$> queryTarget tgtTablesNextToCode
    +    ghcUnreg       <- queryTarget tgtUnregisterised
    +    ghcEnableTNC   <- queryTarget tgtTablesNextToCode
         rtsWays        <- getRtsWays
         way            <- getWay
         path           <- getBuildPath
    @@ -355,8 +355,8 @@ rtsPackageArgs = package rts ? do
                 , "-DTargetArch="                ++ show targetArch
                 , "-DTargetOS="                  ++ show targetOs
                 , "-DTargetVendor="              ++ show targetVendor
    -            , "-DGhcUnregisterised="         ++ show ghcUnreg
    -            , "-DTablesNextToCode="          ++ show ghcEnableTNC
    +            , "-DGhcUnregisterised="         ++ show (yesNo ghcUnreg)
    +            , "-DTablesNextToCode="          ++ show (yesNo ghcEnableTNC)
                 , "-DRtsWay=\"rts_" ++ show way ++ "\""
                 ]
     
    @@ -401,8 +401,21 @@ rtsPackageArgs = package rts ? do
               , any (wayUnit Debug) rtsWays     `cabalFlag` "debug"
               , any (wayUnit Dynamic) rtsWays   `cabalFlag` "dynamic"
               , any (wayUnit Threaded) rtsWays  `cabalFlag` "threaded"
    +          , flag UseLibm                    `cabalFlag` "libm"
    +          , flag UseLibrt                   `cabalFlag` "librt"
    +          , flag UseLibdl                   `cabalFlag` "libdl"
               , useSystemFfi                    `cabalFlag` "use-system-libffi"
               , useLibffiForAdjustors           `cabalFlag` "libffi-adjustors"
    +          , flag UseLibpthread              `cabalFlag` "need-pthread"
    +          , flag UseLibbfd                  `cabalFlag` "libbfd"
    +          , flag NeedLibatomic              `cabalFlag` "need-atomic"
    +          , flag UseLibdw                   `cabalFlag` "libdw"
    +          , flag UseLibnuma                 `cabalFlag` "libnuma"
    +          , flag UseLibzstd                 `cabalFlag` "libzstd"
    +          , flag StaticLibzstd              `cabalFlag` "static-libzstd"
    +          , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
    +          , ghcUnreg                        `cabalFlag` "unregisterised"
    +          , ghcEnableTNC                    `cabalFlag` "tables-next-to-code"
               , Debug `wayUnit` way             `cabalFlag` "find-ptr"
               ]
             , builder (Cabal Setup) ? mconcat
    
    
    =====================================
    libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    =====================================
    @@ -28,7 +28,7 @@ custom-setup
         setup-depends: base >= 4 && < 5, process, filepath, directory, Cabal >= 1.23 && < 3.9
     
     flag need-atomic
    -  default: @CabalNeedLibatomic@
    +  default: False
     
     Library
         default-language: Haskell2010
    
    
    =====================================
    m4/fp_cc_supports__atomics.m4
    =====================================
    @@ -61,12 +61,4 @@ AC_DEFUN([FP_CC_SUPPORTS__ATOMICS],
             AC_MSG_RESULT(no)
             AC_MSG_ERROR([C compiler needs to support __atomic primitives.])
         ])
    -    AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    -    if test "$need_latomic" = 1; then
    -        AC_SUBST([NeedLibatomic],[YES])
    -    else
    -        AC_SUBST([NeedLibatomic],[NO])
    -    fi
    -    AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    -        [Define to 1 if we need -latomic.])
     ])
    
    
    =====================================
    m4/fptools_set_haskell_platform_vars.m4
    =====================================
    @@ -82,7 +82,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS],
             solaris2)
                 test -z "[$]2" || eval "[$]2=OSSolaris2"
                 ;;
    -        mingw32|windows)
    +        mingw32|mingw64|windows)
                 test -z "[$]2" || eval "[$]2=OSMinGW32"
                 ;;
             freebsd)
    @@ -162,8 +162,6 @@ AC_DEFUN([GHC_SUBSECTIONS_VIA_SYMBOLS],
                 TargetHasSubsectionsViaSymbols=NO
              else
                 TargetHasSubsectionsViaSymbols=YES
    -            AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    -                   [Define to 1 if Apple-style dead-stripping is supported.])
              fi
             ],
             [TargetHasSubsectionsViaSymbols=NO
    
    
    =====================================
    m4/ghc_convert_os.m4
    =====================================
    @@ -22,7 +22,7 @@ AC_DEFUN([GHC_CONVERT_OS],[
           openbsd*)
             $3="openbsd"
             ;;
    -      windows|mingw32)
    +      windows|mingw32|mingw64)
             $3="mingw32"
             ;;
           # As far as I'm aware, none of these have relevant variants
    
    
    =====================================
    rts/.gitignore
    =====================================
    @@ -2,8 +2,6 @@
     /dist/
     /dist-*/
     
    -/rts.cabal
    -
     /include/ghcversion.h
     
     /package.conf.inplace
    
    
    =====================================
    rts/configure.ac
    =====================================
    @@ -22,17 +22,153 @@ dnl     #define SIZEOF_CHAR 0
     dnl   recently.
     AC_PREREQ([2.69])
     
    +AC_CONFIG_FILES([ghcplatform.h.top])
    +
     AC_CONFIG_HEADERS([ghcautoconf.h.autoconf])
     
    +AC_ARG_ENABLE(asserts-all-ways,
    +[AS_HELP_STRING([--enable-asserts-all-ways],
    +                [Usually ASSERTs are only compiled in the DEBUG way,
    +                 this will enable them in all ways.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    +  [EnableAssertsAllWays=NO]
    +)
    +if test "$enable_asserts_all_ways" = "yes" ; then
    +   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    +fi
    +
    +AC_ARG_ENABLE(native-io-manager,
    +[AS_HELP_STRING([--enable-native-io-manager],
    +                [Enable the native I/O manager by default.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    +  [EnableNativeIOManager=NO]
    +)
    +if test "$EnableNativeIOManager" = "YES"; then
    +  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    +fi
    +
     # We have to run these unconditionally, but we may discard their
     # results in the following code
     AC_CANONICAL_BUILD
     AC_CANONICAL_HOST
     
    +dnl ** Do a build with tables next to code?
    +dnl --------------------------------------------------------------
    +
    +AS_IF(
    +  [test "$CABAL_FLAG_tables_next_to_code" = 1],
    +  [AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])])
    +
    +dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set),
    +dnl later CC is copied to CC_STAGE{1,2,3}
    +AC_PROG_CC([cc gcc clang])
    +
    +dnl make extensions visible to allow feature-tests to detect them lateron
    +AC_USE_SYSTEM_EXTENSIONS
    +
    +dnl ** Used to determine how to compile ghc-prim's atomics.c, used by
    +dnl    unregisterised, Sparc, and PPC backends. Also determines whether
    +dnl    linking to libatomic is required for atomic operations, e.g. on
    +dnl    RISCV64 GCC.
    +FP_CC_SUPPORTS__ATOMICS
    +AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    +AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    +    [Define to 1 if we need -latomic for sub-word atomic operations.])
    +
    +dnl ** look to see if we have a C compiler using an llvm back end.
    +dnl
    +FP_CC_LLVM_BACKEND
    +AS_IF([test x"$CcLlvmBackend" = x"YES"],
    +  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
    +
    +GHC_CONVERT_PLATFORM_PARTS([build], [Build])
    +FPTOOLS_SET_PLATFORM_VARS([build],[Build])
    +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Build])
    +
     GHC_CONVERT_PLATFORM_PARTS([host], [Host])
     FPTOOLS_SET_PLATFORM_VARS([host], [Host])
     FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
     
    +GHC_SUBSECTIONS_VIA_SYMBOLS
    +AS_IF([test x"${TargetHasSubsectionsViaSymbols}" = x"YES"],
    +  [AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    +    [Define to 1 if Apple-style dead-stripping is supported.])])
    +
    +dnl --------------------------------------------------
    +dnl * Platform header file and syscall feature tests
    +dnl ### checking the state of the local header files and syscalls ###
    +
    +dnl ** Enable large file support.  NB. do this before testing the type of
    +dnl    off_t, because it will affect the result of that test.
    +AC_SYS_LARGEFILE
    +
    +dnl ** check for specific header (.h) files that we are interested in
    +AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    +
    +dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    +AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    +[[#if HAVE_SYS_PARAM_H
    +# include 
    +#endif
    +]])
    +
    +dnl ** check whether a declaration for `environ` is provided by libc.
    +FP_CHECK_ENVIRON
    +
    +dnl ** do we have long longs?
    +AC_CHECK_TYPES([long long])
    +
    +dnl ** what are the sizes of various types
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    +
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    +
    +
    +FP_CHECK_FUNC([WinExec],
    +  [@%:@include ], [WinExec("",0)])
    +
    +FP_CHECK_FUNC([GetModuleFileName],
    +  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    +
    +dnl ** check for more functions
    +dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    +AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    +
    +dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    +dnl ** _POSIX_C_SOURCE is defined
    +AC_CHECK_DECLS([ctime_r], , ,
    +[#define _POSIX_SOURCE 1
    +#define _POSIX_C_SOURCE 199506L
    +#include ])
    +
    +dnl On Linux we should have program_invocation_short_name
    +AC_CHECK_DECLS([program_invocation_short_name], , ,
    +[#define _GNU_SOURCE 1
    +#include ])
    +
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    @@ -140,7 +276,6 @@ AC_ARG_ENABLE(large-address-space,
     )
     
     use_large_address_space=no
    -AC_CHECK_SIZEOF([void *])
     if test "$ac_cv_sizeof_void_p" -eq 8 ; then
         if test "x$EnableLargeAddressSpace" = "xyes" ; then
             if test "$ghc_host_os" = "darwin" ; then
    @@ -223,19 +358,41 @@ dnl --------------------------------------------------------------
     AC_OUTPUT
     
     dnl ######################################################################
    -dnl Generate ghcautoconf.h
    +dnl Generate ghcplatform.h
     dnl ######################################################################
     
     [
     mkdir -p include
    +
    +touch include/ghcplatform.h
    +> include/ghcplatform.h
    +
    +cat ghcplatform.h.top                          >> include/ghcplatform.h
    +]
    +
    +dnl ** Do an unregisterised build?
    +dnl --------------------------------------------------------------
    +AS_IF(
    +  [test "$CABAL_FLAG_unregisterised" = 1],
    +  [echo "#define UnregisterisedCompiler 1"     >> include/ghcplatform.h])
    +
    +[
    +cat $srcdir/ghcplatform.h.bottom               >> include/ghcplatform.h
    +]
    +
    +dnl ######################################################################
    +dnl Generate ghcautoconf.h
    +dnl ######################################################################
    +
    +[
     touch include/ghcautoconf.h
     > include/ghcautoconf.h
     
     echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h
     echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h
    -# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO
    +# Copy the contents of ghcautoconf.h.autoconf, turning '#define PACKAGE_FOO
     # "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
    -cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \
    +cat ghcautoconf.h.autoconf | sed \
        -e 's,^\([	 ]*\)#[	 ]*define[	 ][	 ]*\(PACKAGE_[A-Z]*\)[	 ][ 	]*".*".*$,\1/* #undef \2 */,' \
        -e '/__GLASGOW_HASKELL/d' \
        -e '/REMOVE ME/d' \
    
    
    =====================================
    rts/ghcplatform.h.bottom
    =====================================
    @@ -0,0 +1,2 @@
    +
    +#endif /* __GHCPLATFORM_H__ */
    
    
    =====================================
    rts/ghcplatform.h.top.in
    =====================================
    @@ -0,0 +1,23 @@
    +#if !defined(__GHCPLATFORM_H__)
    +#define __GHCPLATFORM_H__
    +
    +#define BuildPlatform_TYPE  @BuildPlatform_CPP@
    +#define HostPlatform_TYPE   @HostPlatform_CPP@
    +
    +#define @BuildPlatform_CPP at _BUILD  1
    +#define @HostPlatform_CPP at _HOST  1
    +
    +#define @BuildArch_CPP at _BUILD_ARCH  1
    +#define @HostArch_CPP at _HOST_ARCH  1
    +#define BUILD_ARCH  "@BuildArch_CPP@"
    +#define HOST_ARCH  "@HostArch_CPP@"
    +
    +#define @BuildOS_CPP at _BUILD_OS  1
    +#define @HostOS_CPP at _HOST_OS  1
    +#define BUILD_OS  "@BuildOS_CPP@"
    +#define HOST_OS  "@HostOS_CPP@"
    +
    +#define @BuildVendor_CPP at _BUILD_VENDOR  1
    +#define @HostVendor_CPP at _HOST_VENDOR  1
    +#define BUILD_VENDOR  "@BuildVendor_CPP@"
    +#define HOST_VENDOR  "@HostVendor_CPP@"
    
    
    =====================================
    rts/rts.cabal.in → rts/rts.cabal
    =====================================
    @@ -29,31 +29,35 @@ source-repository head
         subdir:   rts
     
     flag libm
    -  default: @CabalHaveLibm@
    +  default: False
     flag librt
    -  default: @CabalHaveLibrt@
    +  default: False
     flag libdl
    -  default: @CabalHaveLibdl@
    +  default: False
     flag use-system-libffi
    -  default: @CabalUseSystemLibFFI@
    +  default: False
     flag libffi-adjustors
    -  default: @CabalLibffiAdjustors@
    +  default: False
     flag need-pthread
    -  default: @CabalNeedLibpthread@
    +  default: False
     flag libbfd
    -  default: @CabalHaveLibbfd@
    +  default: False
     flag need-atomic
    -  default: @CabalNeedLibatomic@
    +  default: False
     flag libdw
    -  default: @CabalHaveLibdw@
    +  default: False
     flag libnuma
    -  default: @CabalHaveLibNuma@
    +  default: False
     flag libzstd
    -  default: @CabalHaveLibZstd@
    +  default: False
     flag static-libzstd
    -  default: @CabalStaticLibZstd@
    +  default: False
     flag leading-underscore
    -  default: @CabalLeadingUnderscore@
    +  default: False
    +flag unregisterised
    +  default: False
    +flag tables-next-to-code
    +  default: False
     flag smp
       default: True
     flag find-ptr
    @@ -240,7 +244,7 @@ library
     
           include-dirs: include
           includes: Rts.h
    -      autogen-includes: ghcautoconf.h
    +      autogen-includes: ghcautoconf.h ghcplatform.h
           install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
                             ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
                             -- ^ from include
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac288d14bb99657393ff69a607c568702d3c65c7...47c3672018b1480178cbf81be64537d58cc68dc7
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac288d14bb99657393ff69a607c568702d3c65c7...47c3672018b1480178cbf81be64537d58cc68dc7
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 12 22:03:50 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Thu, 12 Oct 2023 18:03:50 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-internals-move-2
    Message-ID: <65286d465498a_24a445129ffb202016e8@gitlab.mail>
    
    
    
    Ben Gamari pushed new branch wip/ghc-internals-move-2 at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-internals-move-2
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 12 22:05:03 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Thu, 12 Oct 2023 18:05:03 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 12 commits: Move apple
     compat check to RTS configure
    Message-ID: <65286d8f2cb26_24a445129b7dc02018ee@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
    Move apple compat check to RTS configure
    
    - - - - -
    c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
    Move clock/timer fun checks to RTS configure
    
    Actual library check (which will set the Cabal flag) is left in the
    top-level configure for now.
    
    Progress towards #17191
    
    - - - - -
    7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
    Move visibility and "musttail" annotation checks to the RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
    Move leading underscore checks to RTS configure
    
    `CabalLeadingUnderscore` is done via Hadrian already, so we can stop
    `AC_SUBST`ing it completely.
    
    - - - - -
    25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
    Move alloca, fork, const, and big endian checks to RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    - - - - -
    5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
    Move libdl check to RTS configure
    
    - - - - -
    ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
    Adjust `FP_FIND_LIBFFI`
    
    Just set vars, and `AC_SUBST` in top-level configure.
    
    Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
    be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
    make build system).
    
    - - - - -
    f399812c by John Ericson at 2023-10-12T10:31:13-04:00
    Split BFD support to RTS configure
    
    The flag is still in the top-level configure, but the other checks
    (which define various macros --- important) are in the RTS configure.
    
    - - - - -
    f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
    Split libm check between top level and RTS
    
    - - - - -
    dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
    CgUtils.fixStgRegStmt respect register width
    
    This change ensure that the reg + offset computation is always of the
    same size.  Before this we could end up with a 64bit register, and then
    add a 32bit offset (on 32bit platforms).  This not only would fail type
    sanity checking, but also incorrectly truncate 64bit values into 32bit
    values silently on 32bit architectures.
    
    - - - - -
    8ebb1316 by Matthew Pickering at 2023-10-12T18:04:55-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    6cda769e by John Ericson at 2023-10-12T18:04:55-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    
    
    12 changed files:
    
    - .gitignore
    - compiler/GHC/StgToCmm/CgUtils.hs
    - configure.ac
    - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Settings/Packages.hs
    - libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    - m4/fp_bfd_support.m4
    - m4/fp_find_libffi.m4
    - rts/.gitignore
    - rts/configure.ac
    - rts/rts.cabal.in → rts/rts.cabal
    
    
    Changes:
    
    =====================================
    .gitignore
    =====================================
    @@ -167,7 +167,6 @@ _darcs/
     /libraries/ghc-boot-th/ghc-boot-th.cabal
     /libraries/ghc-boot-th/ghc.mk
     /libraries/ghc-heap/ghc-heap.cabal
    -/libraries/ghc-prim/ghc-prim.cabal
     /libraries/ghci/GNUmakefile
     /libraries/ghci/ghci.cabal
     /libraries/ghci/ghc.mk
    
    
    =====================================
    compiler/GHC/StgToCmm/CgUtils.hs
    =====================================
    @@ -177,16 +177,18 @@ fixStgRegStmt platform stmt = fixAssign $ mapExpDeep fixExpr stmt
                                          (globalRegSpillType platform reg)
                                          NaturallyAligned
     
    -        CmmRegOff (CmmGlobal reg_use) offset ->
    +        CmmRegOff greg@(CmmGlobal reg) offset ->
                 -- RegOf leaves are just a shorthand form. If the reg maps
                 -- to a real reg, we keep the shorthand, otherwise, we just
                 -- expand it and defer to the above code.
    -            let reg = globalRegUseGlobalReg reg_use in
    -            case reg `elem` activeStgRegs platform of
    +            -- NB: to ensure type correctness we need to ensure the Add
    +            --     as well as the Int need to be of the same size as the
    +            --     register.
    +            case globalRegUseGlobalReg reg `elem` activeStgRegs platform of
                     True  -> expr
    -                False -> CmmMachOp (MO_Add (wordWidth platform)) [
    -                                    fixExpr (CmmReg (CmmGlobal reg_use)),
    +                False -> CmmMachOp (MO_Add (cmmRegWidth greg)) [
    +                                    fixExpr (CmmReg greg),
                                         CmmLit (CmmInt (fromIntegral offset)
    -                                                   (wordWidth platform))]
    +                                                   (cmmRegWidth greg))]
     
             other_expr -> other_expr
    
    
    =====================================
    configure.ac
    =====================================
    @@ -951,18 +951,13 @@ dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
     dnl    for math functions or not
     dnl    (see https://gitlab.haskell.org/ghc/ghc/issues/3730)
    -AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO)
    -if test $HaveLibM = YES
    -then
    -  AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])
    -  AC_SUBST([UseLibm],[YES])
    -else
    -  AC_SUBST([UseLibm],[NO])
    -fi
    -TargetHasLibm=$HaveLibM
    +AC_CHECK_LIB(m, atan, UseLibm=YES, UseLibm=NO)
    +AC_SUBST([UseLibm])
    +TargetHasLibm=$UseLibm
     AC_SUBST(TargetHasLibm)
     
    -FP_BFD_SUPPORT
    +FP_BFD_FLAG
    +AC_SUBST([UseLibbfd])
     
     dnl ################################################################
     dnl Check for libraries
    @@ -970,70 +965,20 @@ dnl ################################################################
     
     FP_FIND_LIBFFI
     AC_SUBST(UseSystemLibFFI)
    +AC_SUBST(FFILibDir)
    +AC_SUBST(FFIIncludeDir)
     
     dnl ** check whether we need -ldl to get dlopen()
    -AC_CHECK_LIB([dl], [dlopen])
    -AC_CHECK_LIB([dl], [dlopen], HaveLibdl=YES, HaveLibdl=NO)
    -AC_SUBST([UseLibdl],[$HaveLibdl])
    -dnl ** check whether we have dlinfo
    -AC_CHECK_FUNCS([dlinfo])
    -
    -dnl --------------------------------------------------
    -dnl * Miscellaneous feature tests
    -dnl --------------------------------------------------
    -
    -dnl ** can we get alloca?
    -AC_FUNC_ALLOCA
    -
    -dnl ** working vfork?
    -AC_FUNC_FORK
    -
    -dnl ** determine whether or not const works
    -AC_C_CONST
    -
    -dnl ** are we big endian?
    -AC_C_BIGENDIAN
    -FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
    +AC_CHECK_LIB([dl], [dlopen], UseLibdl=YES, UseLibdl=NO)
    +AC_SUBST([UseLibdl])
     
     dnl ** check for leading underscores in symbol names
     FP_LEADING_UNDERSCORE
     AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`])
    -if test x"$fptools_cv_leading_underscore" = xyes; then
    -   AC_SUBST([CabalLeadingUnderscore],[True])
    -   AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.])
    -else
    -   AC_SUBST([CabalLeadingUnderscore],[False])
    -fi
    -
    -FP_VISIBILITY_HIDDEN
    -
    -FP_MUSTTAIL
     
     dnl ** check for librt
    -AC_CHECK_LIB([rt], [clock_gettime])
    -AC_CHECK_LIB([rt], [clock_gettime], HaveLibrt=YES, HaveLibrt=NO)
    -if test $HaveLibrt = YES
    -then
    -  AC_SUBST([UseLibrt],[YES])
    -else
    -  AC_SUBST([UseLibrt],[NO])
    -fi
    -AC_CHECK_FUNCS(clock_gettime timer_settime)
    -FP_CHECK_TIMER_CREATE
    -
    -dnl ** check for Apple's "interesting" long double compatibility scheme
    -AC_MSG_CHECKING(for printf\$LDBLStub)
    -AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])],
    -    [
    -        AC_MSG_RESULT(yes)
    -        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
    -            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
    -    ],
    -    [
    -        AC_MSG_RESULT(no)
    -        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
    -            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
    -    ])
    +AC_CHECK_LIB([rt], [clock_gettime], UseLibrt=YES, UseLibrt=NO)
    +AC_SUBST([UseLibrt])
     
     FP_CHECK_PTHREAD_LIB
     AC_SUBST([UseLibpthread])
    
    
    =====================================
    hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    =====================================
    @@ -198,9 +198,10 @@ copyPackage context at Context {..} = do
     shakeVerbosityToCabalFlag :: Verbosity -> String
     shakeVerbosityToCabalFlag = \case
         Diagnostic -> "-v3"
    -    Verbose -> "-v3"
    +    Verbose -> "-v2"
    +    -- Normal levels should not produce output to stdout
         Silent -> "-v0"
    -    _ -> "-v2"
    +    _ -> "-v1"
     
     -- | What type of file is Main
     data MainSourceType = HsMain | CppMain | CMain
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -268,17 +268,6 @@ runInterpolations (Interpolations mk_substs) input = do
             subst = foldr (.) id [replace ("@"++k++"@") v | (k,v) <- substs]
         return (subst input)
     
    -toCabalBool :: Bool -> String
    -toCabalBool True  = "True"
    -toCabalBool False = "False"
    -
    --- | Interpolate the given variable with the value of the given 'Flag', using
    --- Cabal's boolean syntax.
    -interpolateCabalFlag :: String -> Flag -> Interpolations
    -interpolateCabalFlag name flg = interpolateVar name $ do
    -    val <- flag flg
    -    return (toCabalBool val)
    -
     -- | Interpolate the given variable with the value of the given 'Setting'.
     interpolateSetting :: String -> Setting -> Interpolations
     interpolateSetting name settng = interpolateVar name $ setting settng
    @@ -290,31 +279,6 @@ projectVersion = mconcat
         , interpolateSetting "ProjectVersionMunged" ProjectVersionMunged
         ]
     
    -rtsCabalFlags :: Interpolations
    -rtsCabalFlags = mconcat
    -    [ flag "CabalHaveLibdw" UseLibdw
    -    , flag "CabalHaveLibm" UseLibm
    -    , flag "CabalHaveLibrt" UseLibrt
    -    , flag "CabalHaveLibdl" UseLibdl
    -    , flag "CabalNeedLibpthread" UseLibpthread
    -    , flag "CabalHaveLibbfd" UseLibbfd
    -    , flag "CabalHaveLibNuma" UseLibnuma
    -    , flag "CabalHaveLibZstd" UseLibzstd
    -    , flag "CabalStaticLibZstd" StaticLibzstd
    -    , flag "CabalNeedLibatomic" NeedLibatomic
    -    , flag "CabalUseSystemLibFFI" UseSystemFfi
    -    , targetFlag "CabalLibffiAdjustors" tgtUseLibffiForAdjustors
    -    , targetFlag "CabalLeadingUnderscore" tgtSymbolsHaveLeadingUnderscore
    -    ]
    -  where
    -    flag = interpolateCabalFlag
    -    targetFlag name q = interpolateVar name $ do
    -      val <- queryTargetTarget q
    -      return (toCabalBool val)
    -
    -ghcPrimCabalFlags :: Interpolations
    -ghcPrimCabalFlags = interpolateCabalFlag "CabalNeedLibatomic" NeedLibatomic
    -
     packageVersions :: Interpolations
     packageVersions = foldMap f [ base, ghcPrim, compiler, ghc, cabal, templateHaskell, ghcCompact, array ]
       where
    @@ -347,8 +311,6 @@ templateRule outPath interps = do
     templateRules :: Rules ()
     templateRules = do
       templateRule "compiler/ghc.cabal" $ projectVersion
    -  templateRule "rts/rts.cabal" $ rtsCabalFlags
    -  templateRule "libraries/ghc-prim/ghc-prim.cabal" $ ghcPrimCabalFlags
       templateRule "driver/ghci/ghci-wrapper.cabal" $ projectVersion
       templateRule "ghc/ghc-bin.cabal" $ projectVersion
       templateRule "utils/iserv/iserv.cabal" $ projectVersion
    
    
    =====================================
    hadrian/src/Settings/Packages.hs
    =====================================
    @@ -114,7 +114,7 @@ packageArgs = do
     
             -------------------------------- ghcPrim -------------------------------
             , package ghcPrim ? mconcat
    -          [ builder (Cabal Flags) ? arg "include-ghc-prim"
    +          [ builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic"
     
               , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ?
                 input "**/cbits/atomic.c"  ? arg "-Wno-sync-nand" ]
    @@ -401,8 +401,19 @@ rtsPackageArgs = package rts ? do
               , any (wayUnit Debug) rtsWays     `cabalFlag` "debug"
               , any (wayUnit Dynamic) rtsWays   `cabalFlag` "dynamic"
               , any (wayUnit Threaded) rtsWays  `cabalFlag` "threaded"
    +          , flag UseLibm                    `cabalFlag` "libm"
    +          , flag UseLibrt                   `cabalFlag` "librt"
    +          , flag UseLibdl                   `cabalFlag` "libdl"
               , useSystemFfi                    `cabalFlag` "use-system-libffi"
               , useLibffiForAdjustors           `cabalFlag` "libffi-adjustors"
    +          , flag UseLibpthread              `cabalFlag` "need-pthread"
    +          , flag UseLibbfd                  `cabalFlag` "libbfd"
    +          , flag NeedLibatomic              `cabalFlag` "need-atomic"
    +          , flag UseLibdw                   `cabalFlag` "libdw"
    +          , flag UseLibnuma                 `cabalFlag` "libnuma"
    +          , flag UseLibzstd                 `cabalFlag` "libzstd"
    +          , flag StaticLibzstd              `cabalFlag` "static-libzstd"
    +          , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
               , Debug `wayUnit` way             `cabalFlag` "find-ptr"
               ]
             , builder (Cabal Setup) ? mconcat
    
    
    =====================================
    libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    =====================================
    @@ -28,7 +28,7 @@ custom-setup
         setup-depends: base >= 4 && < 5, process, filepath, directory, Cabal >= 1.23 && < 3.9
     
     flag need-atomic
    -  default: @CabalNeedLibatomic@
    +  default: False
     
     Library
         default-language: Haskell2010
    
    
    =====================================
    m4/fp_bfd_support.m4
    =====================================
    @@ -1,49 +1,59 @@
     # FP_BFD_SUPPORT()
     # ----------------------
    -# whether to use libbfd for debugging RTS
    -AC_DEFUN([FP_BFD_SUPPORT], [
    -    HaveLibbfd=NO
    -    AC_ARG_ENABLE(bfd-debug,
    -        [AS_HELP_STRING([--enable-bfd-debug],
    -              [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
    -        [
    -            # don't pollute general LIBS environment
    -            save_LIBS="$LIBS"
    -            AC_CHECK_HEADERS([bfd.h])
    -            dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
    -            dnl    the order of these tests matters: bfd needs libiberty
    -            AC_CHECK_LIB(iberty, xmalloc)
    -            dnl 'bfd_init' is a rare non-macro in libbfd
    -            AC_CHECK_LIB(bfd,    bfd_init)
    +# Whether to use libbfd for debugging RTS
    +#
    +# Sets:
    +#   UseLibbfd: [YES|NO]
    +AC_DEFUN([FP_BFD_FLAG], [
    +  UseLibbfd=NO
    +  AC_ARG_ENABLE(bfd-debug,
    +    [AS_HELP_STRING([--enable-bfd-debug],
    +          [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
    +    [UseLibbfd=YES],
    +    [UseLibbfd=NO])
    +])
    +
    +# FP_WHEN_ENABLED_BFD
    +# ----------------------
    +# Checks for libraries in the default way, which will define various
    +# `HAVE_*` macros.
    +AC_DEFUN([FP_WHEN_ENABLED_BFD], [
    +  # don't pollute general LIBS environment
    +  save_LIBS="$LIBS"
    +  AC_CHECK_HEADERS([bfd.h])
    +  dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
    +  dnl    the order of these tests matters: bfd needs libiberty
    +  AC_CHECK_LIB(iberty, xmalloc)
    +  dnl 'bfd_init' is a rare non-macro in libbfd
    +  AC_CHECK_LIB(bfd,    bfd_init)
     
    -            AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]],
    -                        [[
    -                                /* mimic our rts/Printer.c */
    -                                bfd* abfd;
    -                                const char * name;
    -                                char **matching;
    +  AC_LINK_IFELSE(
    +    [AC_LANG_PROGRAM(
    +      [[#include ]],
    +      [[
    +        /* mimic our rts/Printer.c */
    +        bfd* abfd;
    +        const char * name;
    +        char **matching;
     
    -                                name = "some.executable";
    -                                bfd_init();
    -                                abfd = bfd_openr(name, "default");
    -                                bfd_check_format_matches (abfd, bfd_object, &matching);
    -                                {
    -                                    long storage_needed;
    -                                    storage_needed = bfd_get_symtab_upper_bound (abfd);
    -                                }
    -                                {
    -                                    asymbol **symbol_table;
    -                                    long number_of_symbols;
    -                                    symbol_info info;
    +        name = "some.executable";
    +        bfd_init();
    +        abfd = bfd_openr(name, "default");
    +        bfd_check_format_matches (abfd, bfd_object, &matching);
    +        {
    +            long storage_needed;
    +            storage_needed = bfd_get_symtab_upper_bound (abfd);
    +        }
    +        {
    +            asymbol **symbol_table;
    +            long number_of_symbols;
    +            symbol_info info;
     
    -                                    number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
    -                                    bfd_get_symbol_info(abfd,symbol_table[0],&info);
    -                                }
    -                        ]])],
    -                        HaveLibbfd=YES,dnl bfd seems to work
    -                        [AC_MSG_ERROR([can't use 'bfd' library])])
    -            LIBS="$save_LIBS"
    -        ]
    -    )
    -    AC_SUBST([UseLibbfd],[$HaveLibbfd])
    +            number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
    +            bfd_get_symbol_info(abfd,symbol_table[0],&info);
    +        }
    +      ]])],
    +    [], dnl bfd seems to work
    +    [AC_MSG_ERROR([can't use 'bfd' library])])
    +  LIBS="$save_LIBS"
     ])
    
    
    =====================================
    m4/fp_find_libffi.m4
    =====================================
    @@ -1,6 +1,11 @@
    -dnl ** Have libffi?
    -dnl --------------------------------------------------------------
    -dnl Sets UseSystemLibFFI.
    +# FP_FIND_LIBFFI
    +# --------------------------------------------------------------
    +# Should we used libffi? (yes or no)
    +#
    +# Sets variables:
    +#   - UseSystemLibFFI: [YES|NO]
    +#   - FFILibDir: optional path
    +#   - FFIIncludeDir: optional path
     AC_DEFUN([FP_FIND_LIBFFI],
     [
       # system libffi
    @@ -28,8 +33,6 @@ AC_DEFUN([FP_FIND_LIBFFI],
        fi
       ])
     
    -  AC_SUBST(FFIIncludeDir)
    -
       AC_ARG_WITH([ffi-libraries],
       [AS_HELP_STRING([--with-ffi-libraries=ARG],
         [Find libffi in ARG [default=system default]])
    @@ -42,8 +45,6 @@ AC_DEFUN([FP_FIND_LIBFFI],
        fi
       ])
     
    -  AC_SUBST(FFILibDir)
    -
       AS_IF([test "$UseSystemLibFFI" = "YES"], [
        CFLAGS2="$CFLAGS"
        CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
    @@ -63,7 +64,7 @@ AC_DEFUN([FP_FIND_LIBFFI],
        AC_CHECK_LIB(ffi, ffi_call,
         [AC_CHECK_HEADERS(
           [ffi.h],
    -      [AC_DEFINE([HAVE_SYSTEM_LIBFFI], [1], [Define to 1 if you have libffi.])],
    +      [],
           [AC_MSG_ERROR([Cannot find ffi.h for system libffi])]
          )],
         [AC_MSG_ERROR([Cannot find system libffi])]
    
    
    =====================================
    rts/.gitignore
    =====================================
    @@ -2,8 +2,6 @@
     /dist/
     /dist-*/
     
    -/rts.cabal
    -
     /include/ghcversion.h
     
     /package.conf.inplace
    
    
    =====================================
    rts/configure.ac
    =====================================
    @@ -33,6 +33,70 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host])
     FPTOOLS_SET_PLATFORM_VARS([host], [Host])
     FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
     
    +dnl ** check for math library
    +dnl    Keep that check as early as possible.
    +dnl    as we need to know whether we need libm
    +dnl    for math functions or not
    +dnl    (see https://gitlab.haskell.org/ghc/ghc/issues/3730)
    +AS_IF(
    +  [test "$CABAL_FLAG_libm" = 1],
    +  [AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])])
    +
    +AS_IF([test "$CABAL_FLAG_libbfd" = 1], [FP_WHEN_ENABLED_BFD])
    +
    +dnl ################################################################
    +dnl Check for libraries
    +dnl ################################################################
    +
    +dnl ** check whether we need -ldl to get dlopen()
    +AC_CHECK_LIB([dl], [dlopen])
    +dnl ** check whether we have dlinfo
    +AC_CHECK_FUNCS([dlinfo])
    +
    +dnl --------------------------------------------------
    +dnl * Miscellaneous feature tests
    +dnl --------------------------------------------------
    +
    +dnl ** can we get alloca?
    +AC_FUNC_ALLOCA
    +
    +dnl ** working vfork?
    +AC_FUNC_FORK
    +
    +dnl ** determine whether or not const works
    +AC_C_CONST
    +
    +dnl ** are we big endian?
    +AC_C_BIGENDIAN
    +FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
    +
    +dnl ** check for leading underscores in symbol names
    +if test "$CABAL_FLAG_leading_underscore" = 1; then
    +   AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.])
    +fi
    +
    +FP_VISIBILITY_HIDDEN
    +
    +FP_MUSTTAIL
    +
    +dnl ** check for librt
    +AC_CHECK_FUNCS(clock_gettime timer_settime)
    +FP_CHECK_TIMER_CREATE
    +
    +dnl ** check for Apple's "interesting" long double compatibility scheme
    +AC_MSG_CHECKING(for printf\$LDBLStub)
    +AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])],
    +    [
    +        AC_MSG_RESULT(yes)
    +        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
    +            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
    +    ],
    +    [
    +        AC_MSG_RESULT(no)
    +        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
    +            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
    +    ])
    +
     FP_CHECK_PTHREAD_FUNCS
     
     dnl ** check for eventfd which is needed by the I/O manager
    
    
    =====================================
    rts/rts.cabal.in → rts/rts.cabal
    =====================================
    @@ -29,31 +29,31 @@ source-repository head
         subdir:   rts
     
     flag libm
    -  default: @CabalHaveLibm@
    +  default: False
     flag librt
    -  default: @CabalHaveLibrt@
    +  default: False
     flag libdl
    -  default: @CabalHaveLibdl@
    +  default: False
     flag use-system-libffi
    -  default: @CabalUseSystemLibFFI@
    +  default: False
     flag libffi-adjustors
    -  default: @CabalLibffiAdjustors@
    +  default: False
     flag need-pthread
    -  default: @CabalNeedLibpthread@
    +  default: False
     flag libbfd
    -  default: @CabalHaveLibbfd@
    +  default: False
     flag need-atomic
    -  default: @CabalNeedLibatomic@
    +  default: False
     flag libdw
    -  default: @CabalHaveLibdw@
    +  default: False
     flag libnuma
    -  default: @CabalHaveLibNuma@
    +  default: False
     flag libzstd
    -  default: @CabalHaveLibZstd@
    +  default: False
     flag static-libzstd
    -  default: @CabalStaticLibZstd@
    +  default: False
     flag leading-underscore
    -  default: @CabalLeadingUnderscore@
    +  default: False
     flag smp
       default: True
     flag find-ptr
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81c169678de4004246212a1c5b2914ac171895ed...6cda769ec00498de73f7642c8fa9505eecc4b019
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81c169678de4004246212a1c5b2914ac171895ed...6cda769ec00498de73f7642c8fa9505eecc4b019
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 12 22:20:54 2023
    From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz))
    Date: Thu, 12 Oct 2023 18:20:54 -0400
    Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 46 commits:
     Simplify and correct nasty case in coercion opt
    Message-ID: <652871461dd67_24a445130111a8206878@gitlab.mail>
    
    
    
    Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00
    Simplify and correct nasty case in coercion opt
    
    This fixes #21062.
    
    No test case, because triggering this code seems challenging.
    
    - - - - -
    9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Bump bytestring submodule to 0.12.0.2
    
    - - - - -
    4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Inline bucket_match
    
    - - - - -
    f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00
    configure: Fix #21712 again
    
    This is a bit of a shot in the dark to fix #24033, which appears to be
    another instance of #21712. For some reason the ld-override logic
    *still* appears to be active on Darwin targets (or at least one).
    Consequently, on misconfigured systems we may choose a non-`ld64`
    linker.
    
    It's a bit unclear exactly what happened in #24033 but ultimately the
    check added for #21712 was not quite right, checking for the
    `ghc_host_os` (the value of which depends upon the bootstrap compiler)
    instead of the target platform. Fix this.
    
    Fixes #24033.
    
    - - - - -
    2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00
    Add a regression test for #24029
    
    - - - - -
    8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00
    Fix non-symbolic children lookup of fixity decl
    
    The fix for #23664 did not correctly account for non-symbolic names
    when looking up children of a given parent. This one-line fix changes
    that.
    
    Fixes #24037
    
    - - - - -
    a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00
    rts: fix incorrect ticket reference
    
    - - - - -
    e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00
    users-guide: Fix discussion of -Wpartial-fields
    
     * fix a few typos
     * add a new example showing when the warning fires
     * clarify the existing example
     * point out -Wincomplete-record-selects
    
    Fixes #24049.
    
    - - - - -
    8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00
    Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"
    
    This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.
    
    `-optP` should pass options to the preprocessor, that might be a very
    different program to the C compiler, so passing the options to the C
    compiler is likely to result in `-optP` being useless.
    
    Fixes #17185 and #21291
    
    - - - - -
    8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00
    rts/nonmoving: Fix on LLP64 platforms
    
    Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL`
    size suffix. However, this is wrong on LLP64 platforms like Windows,
    where `long` is 32-bits.
    
    Fixes #23003.
    Fixes #24042.
    
    - - - - -
    f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00
    Fix isAArch64Bitmask for 32bit immediates.
    
    Fixes #23802
    
    - - - - -
    63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00
    Work around perf note fetch failure
    
    Addresses #24055.
    
    - - - - -
    242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00
    Add a test for #21348
    
    - - - - -
    7d390bce by Rewbert at 2023-10-05T05:38:08-04:00
    Fixes #24046
    
    - - - - -
    69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00
    Ensure unconstrained instance dictionaries get IPE info
    
    In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up
    with an initial source span based on the span of the binder, which was causing
    instance dictionaries without dynamic superclass constraints to not have source
    locations in their IPE info. Now they do.
    
    Resolves #24005
    
    - - - - -
    390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00
    rts: Split up rts/include/stg/MachRegs.h by arch
    
    - - - - -
    3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00
    Actually set hackage index state
    
    Or at least, use a version of the cabal command that *claims* to set the
    index state.
    
    Time will tell.
    
    - - - - -
    46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00
    Update hackage index state
    
    - - - - -
    d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00
    Ensure hadrian uses CI's hackage index state
    
    - - - - -
    e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00
    Do not use O_NONBLOCK on regular files or block devices
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/166
    
    - - - - -
    a06197c4 by David Binder at 2023-10-08T15:06:55-04:00
    Update hpc-bin submodule to 0.69
    
    - - - - -
    ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00
    Update Hadrian with correct path to happy file for hpc-bin
    
    - - - - -
    94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00
    EPA: Introduce HasAnnotation class
    
    The class is defined as
    
        class HasAnnotation e where
          noAnnSrcSpan :: SrcSpan -> e
    
    This generalises noAnnSrcSpan, and allows
    
        noLocA :: (HasAnnotation e) => a -> GenLocated e a
        noLocA = L (noAnnSrcSpan noSrcSpan)
    
    - - - - -
    8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00
    Bump unix submodule to v2.8.3.0
    
    - - - - -
    61ca0891 by Alan Zimmerman at 2023-10-10T18:43:46+01:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT where clause span
    - Capture full range for a CaseAlt Match
    
    info: patch template saved to `-`
    
    - - - - -
    035778e7 by Alan Zimmerman at 2023-10-11T21:28:45+01:00
    EPA: Use full range for Anchor
    
    EPA Use full range for Anchor, and do not widen for [TrailingAnn]
    
    Known failures at the end of this
      Ppr023
      Ppr034
      TestBoolFormula
    
    Fixed in subsequent commits
    
    EPA: Use the current Anchor end as prior end
    
    Use the original anchor location end as the source of truth for
    calculating print deltas.
    
    This allows original spacing to apply in most cases, only changed AST
    items need initial delta positions.
    
    [2023-08-14 Mon]
    121 unexpected failures
    
    EPA: Add DArrow to TrailingAnn
    
    [EPA] Introduce HasTrailing in ExactPrint
    
    29 Failing tests by 4600 processed
    
    info: patch template saved to `-`
    
    EPA use [TrailingAnn] in enterAnn
    
    And remove it from ExactPrint (LocatedN RdrName)
    
    Summary: Patch:  epa-in-hsdo-put-trailinganns
    Author: Alan Zimmerman <alan.zimm at gmail.com>
    Date:   2023-07-03 22:33:49 +0100
    
    EPA: In HsDo, put TrailingAnns at top of LastStmt
    
    Failures
    5300 of 9700 [0, 103, 0]
    
    EPA: do not convert comments to deltas when balancing.
    
    It seems its not needed with the new approach
    
    [2023-08-15 Tue]
    104 unexpected failures
    
    EPA: deal with fallout from getMonoBind
    
    EPA fix captureLineSpacing
    
    EPA print any comments in the span before exiting it
    
    EPA: getting rid of tweakDelta
    
    WIP at present
    
    EPA: tweaks to ExactPrint
    
    EPA: Fix warnings in check-exact
    
    EPA: Add comments to AnchorOperation
    
    6000 of 9700 [0, 14, 0]
    Failures seem to be mainly in transform tests
    
    EPA: remove AnnEofComment
    
    It is no longer used
    
    At this point just failures
      HsDocTy
    
    [2023-08-31 Thu]
    And no warnings in check-exact
    
    info: patch template saved to `-`
    
    - - - - -
    a25678d9 by Alan Zimmerman at 2023-10-11T21:28:58+01:00
    EPA: make locA a function, not a field name
    
    - - - - -
    a3c74211 by Alan Zimmerman at 2023-10-11T21:28:58+01:00
    EPA: generalise reLoc
    
    [2023-10-01 Sun]
    Failures
       HsDocTy
    
    - - - - -
    1e5ac621 by Alan Zimmerman at 2023-10-11T21:28:59+01:00
    EPA: get rid of l2l and friends
    
    - - - - -
    e67a5c9f by Alan Zimmerman at 2023-10-11T21:28:59+01:00
    EPA: get rid of l2l and friends
    
    - - - - -
    f58d81ca by Alan Zimmerman at 2023-10-11T21:28:59+01:00
    EPA: harmonise acsa and acsA
    
    [2023-10-01 Sun]
    Failing tests
      HsDocTy
    
    - - - - -
    d348cd16 by Alan Zimmerman at 2023-10-11T22:13:52+01:00
    EPA: Replace Anchor with EpaLocation
    
    [2023-09-21 Thu]
    Only test failing is
       HsDocTy
    
    - - - - -
    ba1142c4 by Alan Zimmerman at 2023-10-11T22:13:57+01:00
    EPA: get rid of AnchorOperation
    
    [2023-09-21 Thu]
    Only error is
      HsDocTy
    
    - - - - -
    879cc2f1 by Alan Zimmerman at 2023-10-11T22:13:57+01:00
    EPA: splitLHsForAllTyInvis no ann returned
    
    - - - - -
    aee6f171 by Alan Zimmerman at 2023-10-11T22:13:57+01:00
    EPA: Replace Monoid with NoAnn
    
    [2023-08-19 Sat]
    AddClassMethod fails
    
    - - - - -
    9c53bbea by Alan Zimmerman at 2023-10-11T23:14:44+01:00
    EPA: Use SrcSpan in EpaSpan
    
    [2023-09-04 Mon]
    No errors or warnings in check-exact
    
    [2023-09-21 Thu]
    Test failures
       HsDocTy
    
    - - - - -
    7012f66c by Alan Zimmerman at 2023-10-11T23:14:48+01:00
    EPA: Present no longer has annotation
    
    - - - - -
    5be53a08 by Alan Zimmerman at 2023-10-11T23:14:48+01:00
    EPA: empty tup_tail has no ann
    
    Parser.y: tup_tail rule was
              | {- empty -} %shift   { return [Left noAnn] }
    
    This means we add an extra Missing constructor if the last item was a comma.
    
    Change the annotation type to a Bool to indicate this, and use the
    EpAnn Anchor for the print location for the others.
    
    - - - - -
    671bef2c by Alan Zimmerman at 2023-10-11T23:14:49+01:00
    EPA: Remove parenthesizeHsType
    
    - - - - -
    a304291c by Alan Zimmerman at 2023-10-12T18:29:46+01:00
    EPA: Remove EpAnnNotUsed
    
    [2023-10-01 Sun]
    Failures
      HsDocTy
      T15242
    
    - - - - -
    a56e8e06 by Alan Zimmerman at 2023-10-12T20:53:36+01:00
    EPA: Remove SrcSpanAnn
    
    [2023-10-12 Thu]
      Failures
        HsDocTy
        T15242
    
    - - - - -
    591f129d by Alan Zimmerman at 2023-10-12T21:51:15+01:00
    EPA: Remove SrcSpanAnn completely
    
    - - - - -
    f7bb637d by Alan Zimmerman at 2023-10-12T21:51:23+01:00
    Clean up mkScope
    
    - - - - -
    a0909978 by Alan Zimmerman at 2023-10-12T21:51:24+01:00
    EPA: Clean up TC Monad Utils
    
    - - - - -
    ce741cb3 by Alan Zimmerman at 2023-10-12T21:51:24+01:00
    EPA: EpaDelta for comment has no comments
    
    [2023-09-23 Sat]
    Current failures
       HsDocTy
       T15242
    
    - - - - -
    d847e83e by Alan Zimmerman at 2023-10-12T23:20:20+01:00
    Semigroup instances for AnnList and AnnContext
    
    - - - - -
    
    
    26 changed files:
    
    - .gitignore
    - .gitlab/ci.sh
    - .gitlab/test-metrics.sh
    - compiler/CodeGen.Platform.h
    - compiler/GHC/CmmToAsm.hs
    - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
    - compiler/GHC/Core/Coercion.hs
    - compiler/GHC/Core/Coercion/Opt.hs
    - compiler/GHC/Data/FastString.hs
    - compiler/GHC/Driver/Pipeline/Execute.hs
    - compiler/GHC/Hs.hs
    - compiler/GHC/Hs/Binds.hs
    - compiler/GHC/Hs/Decls.hs
    - compiler/GHC/Hs/Dump.hs
    - compiler/GHC/Hs/Expr.hs
    - compiler/GHC/Hs/Extension.hs
    - compiler/GHC/Hs/ImpExp.hs
    - compiler/GHC/Hs/Pat.hs
    - compiler/GHC/Hs/Type.hs
    - compiler/GHC/Hs/Utils.hs
    - compiler/GHC/HsToCore/Arrows.hs
    - compiler/GHC/HsToCore/Docs.hs
    - compiler/GHC/HsToCore/Monad.hs
    - compiler/GHC/Iface/Ext/Ast.hs
    - compiler/GHC/Iface/Ext/Utils.hs
    - compiler/GHC/Parser.y
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d035f64f27874c44ab1422ebe348b5f601f04dda...d847e83e7ddd6e3aa0be83cb40636fab0a5b10f0
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d035f64f27874c44ab1422ebe348b5f601f04dda...d847e83e7ddd6e3aa0be83cb40636fab0a5b10f0
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 00:18:15 2023
    From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani))
    Date: Thu, 12 Oct 2023 20:18:15 -0400
    Subject: [Git][ghc/ghc][wip/expand-do] - More notes rewriting
    Message-ID: <65288cc791586_24a44515d570a4208967@gitlab.mail>
    
    
    
    Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    da7079d1 by Apoorv Ingle at 2023-10-12T19:17:26-05:00
    - More notes rewriting
    
    - - - - -
    
    
    3 changed files:
    
    - compiler/GHC/Rename/Expr.hs
    - compiler/GHC/Tc/Gen/Do.hs
    - compiler/GHC/Tc/Gen/Expr.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Rename/Expr.hs
    =====================================
    @@ -210,14 +210,14 @@ typecheck the renamed-syntax call (fromLabel @"foo").
     
     Note [Doing HsExpansion in the Renamer vs Typechecker]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -We expand some `HsExpr GhcRn` code at various places, usually on the fly,
    +We expand some `HsExpr GhcRn` code at various places, usually, on the fly,
     depending on when it is more convenient. It may be beneficial to have a
     separate `HsExpr GhcRn -> HsExpr GhcRn` pass that does this expansion uniformly
     in the future when we have enough cases to cater for. For the time being,
     this note documents which language feature is expanded at which phase,
     and the reasons for doing so.
     
    -  Part 0. OpApp Expansions
    +  Part 0. `OpApp` Expansions
       ------------------------
       The typechecker turns `OpApp` into a use of `HsExpansion`
       on the fly, in `GHC.Tc.Gen.Head.splitHsApps`.
    @@ -227,16 +227,17 @@ and the reasons for doing so.
       form, because the renamer does precedence rearrangement after name
       resolution. So the renamer leaves an `OpApp` as an `OpApp`.
     
    -  Part 1. Record Update Syntax
    -  ----------------------------
    +  Part 1. Record Update Syntax `RecordUpd` Expansions
    +  ---------------------------------------------------
       This is done in the typechecker on the fly (`GHC.Tc.Expr.tcExpr`), and not the renamer, for two reasons:
     
         - (Until we implement GHC proposal #366)
           We need to know the type of the record to disambiguate its fields.
     
    -    - We use the type signature of the data constructor to provide IdSigs
    -      to the let-bound variables (x', y' in the example above). This is
    -      needed to accept programs such as
    +    - We use the type signature of the data constructor to provide `IdSigs`
    +      to the let-bound variables (x', y' in the example of
    +      Note [Handling overloaded and rebindable constructs] above).
    +      This is needed to accept programs such as
     
               data R b = MkR { f :: (forall a. a -> a) -> (Int,b), c :: Int }
               foo r = r { f = \ k -> (k 3, k 'x') }
    @@ -244,10 +245,10 @@ and the reasons for doing so.
           in which an updated field has a higher-rank type.
           See Wrinkle [Using IdSig] in Note [Record Updates] in GHC.Tc.Gen.Expr.
     
    -  Part 2. HsDo Statements
    -  -----------------------
    -  The expansion for do block statements is done on the fly right before typechecking in
    -  `GHC.Tc.Gen.Do.expandDoStmts`. There are 2 reasons:
    +  Part 2. `HsDo` Statement Expansions
    +  -----------------------------------
    +  The expansion for do block statements is done on the fly right before typechecking in `GHC.Tc.Gen.Expr`
    +  using `GHC.Tc.Gen.Do.expandDoStmts`. There are 2 main reasons:
     
       -  During the renaming phase, we may not have all the constructor details `HsConDetails` populated in the
          data structure. This would result in an inaccurate irrefutability analysis causing
    @@ -255,9 +256,10 @@ and the reasons for doing so.
          See Part 1. of Note [Expanding HsDo with HsExpansion] (test pattern-fails.hs)
     
       -  If the expansion is done on the fly during renaming, expressions that
    -     have explicit type applications using (-XTypeApplciations) will not work as the name freshening
    -     happens from the root of the AST to the leaves, but the expansion happens in the opposite
    -     direction (from leaves to the root), causing the renamer to miss the scoped type variables.
    +     have explicit type applications using (-XTypeApplciations) will not work (cf. Let statements expansion)
    +     as the name freshening happens from the root of the AST to the leaves,
    +     but the expansion happens in the opposite direction (from leaves to the root),
    +     causing the renamer to miss the scoped type variables.
     -}
     
     {-
    
    
    =====================================
    compiler/GHC/Tc/Gen/Do.hs
    =====================================
    @@ -49,7 +49,7 @@ import Data.List ((\\))
     ************************************************************************
     -}
     
    --- | Expand the `do` statments into expressions right after renaming
    +-- | Expand the `do`-statments into expressions right after renaming
     --   so that they can be typechecked.
     --   See Note [Expanding HsDo with HsExpansion] below for `HsDo` specific commentary
     --   and Note [Handling overloaded and rebindable constructs] for high level commentary
    @@ -227,19 +227,24 @@ mk_fail_block _ _ _ _ = pprPanic "mk_fail_block: impossible happened" empty
     
     {- Note [Expanding HsDo with HsExpansion]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -We expand `do` blocks before typechecking it rather than after type checking it using the
    -`HsExpansions` and `RebindableSyntax` machinery.
    -
    +We expand `do`-blocks before typechecking it, rather than type checking it and then
    +desugaring it by re-using the existing `HsExpansions` and `RebindableSyntax` machinery.
     This is very similar to:
       1. Expansions done in `GHC.Rename.Expr.rnHsIf` for expanding `HsIf`; and
       2. `desugarRecordUpd` in `GHC.Tc.Gen.Expr.tcExpr` for expanding `RecordUpd`
     
    +To disabmiguate desugaring (`HsExpr GhcTc -> Core.Expr`) we use the phrase expansion
    +(`HsExpr GhcRn -> HsExpr GhcRn`)
    +
     See Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr
     
    -In previous versions of GHC, the “do” notation wasn't expanded before typechecking,
    +This expansion is done right before typechecking and after renaming
    +See Part 2. of Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr`
    +
    +In previous versions of GHC, the `do`-notation wasn't expanded before typechecking,
     instead the typechecker would operate directly on the original.
     Why? because it ensured that type error messages were explained in terms of
    -what the programmer has written. In practice, however, it this didn't work very well:
    +what the programmer has written. In practice, however, this didn't work very well:
     
     * Attempts to typecheck the original source code turned out to be buggy, and virtually impossible
       to fix (#14963, #15598, #21206 and others)
    @@ -255,57 +260,57 @@ what the programmer has written. In practice, however, it this didn't work very
     
     * With `ImpredicativeTypes` the programmer will expect Quick Look to instantiate
       the quantifiers impredicatively (#18324). Again, that happens automatically if
    -  you typecheck the expansion expression.
    +  you typecheck the expanded expression.
     
    -* Equationally speaking, we have the following schema for expanding `do` statements.
    -  They capture the essense of statment expansions as implemented in `expand_do_stmts`
    +* Equationally speaking, we have the following schema for expanding `do`-statements.
    +  They capture the essence of statement expansions as implemented in `expand_do_stmts`
     
    -  DO【 _ 】 takes in a sequence of do statements and converts them into expressions, recursively
    +  DO【 _ 】 maps a sequence of do statements and recursively converts them into expressions
     
               (1) DO【 s; ss 】      = ‹ExpansionStmt s›((>>) s (‹PopErrCtxt›DO【 ss 】))
     
    -          (2) DO【 s 】          = s
    -
    -          (3) DO【 p <- s; ss 】 = if p is irrefutable
    -                                   then ‹ExpansionStmt (p <- s)›
    +          (2) DO【 p <- e; ss 】 = if p is irrefutable
    +                                   then ‹ExpansionStmt (p <- e)›
                                               (>>=) s (‹PopExprCtxt›(\ p -> DO【 ss 】))
    -                                   else ‹ExpansionStmt (p <- s)›
    +                                   else ‹ExpansionStmt (p <- e)›
                                               (>>=) s (‹PopExprCtxt›(\case p -> DO【 ss 】
                                                                            _ -> fail "pattern p failure"))
     
    -For a concrete example, consider a `do` block written by the user
    +          (3) DO【 let x = e; ss 】
    +                                = ‹ExpansionStmt (let x = e)› (let x = e in (‹PopErrCtxt›DO【 ss 】))
    +
    +          (4) DO【 s 】          = s
    +
    +For a concrete example, consider a `do`-block written by the user
     
         f = {l0} do {l1} {pl}p <- {l1'} e1
                     {l2} g p
                     {l3} return {l3'} p
     
    -The {l1} etc are location/source span information stored in the AST,
    -{g1} are compiler generated source spans
    -
    -The expanded version (performed by `expand_do_stmts`) looks as follows:
    +The expanded version (performed by `expand_do_stmts`) looks like:
     
         f = {g1} (>>=) ({l1'} e1) (\ {pl}p ->
                        {g2} (>>) ({l2} g p)
                                  ({l3} return p))
     
    -The 4 main points to consider are:
    -1. Wrap the expression with a `fail` block if the pattern match is not irrefutable.
    -   See Part 1. Below
    +The {l1} etc are location/source span information stored in the AST by the parser,
    +{g1} are compiler generated source spans.
     
    -2. Generate appropriate warnings for discarded results in a body statement
    -   eg. say `do { .. ; (g p :: m Int) ; ... }`
    -   See Part 2. Below
     
    -3. Generating appropriate type error messages which blame the correct source spans
    -   See Part 3 Below
    +The 3 main points to consider are:
     
    -4. Why is this expansion done in the type checker pass and not in renamer pass?
    -   See Part 2. of Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr`
    + 1. Wrap the expression with a `fail` block if the pattern match is not irrefutable.
    +    See Part 1. Below
    + 2. Generate appropriate warnings for discarded results in a body statement
    +    eg. say `do { .. ; (g p :: m Int) ; ... }`
    +    See Part 2. Below
    + 3. Generating appropriate type error messages which blame the correct source spans
    +    See Part 3 Below
     
     Part 1. Wrapping failable patterns with fail blocks
     ---------------------------------------------------
     If `p` is a failable pattern---checked by `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`---
    -we need to wrap it with a `fail` block. For example, the expansion of the `do` block
    +we need to wrap it with a `fail`-block. For example, the expansion of the `do`-block
     
             do { Just p <- e1; e2 }
     
    @@ -316,7 +321,7 @@ we need to wrap it with a `fail` block. For example, the expansion of the `do` b
                      Just p -> e2
                      _      -> fail "failable pattern p at location")
     
    -The `fail` block wrapping is done in `GHC.Tc.Gen.Do.mk_failable_expr`.
    +The `fail`-block wrapping is done in `GHC.Tc.Gen.Do.mk_failable_expr`.
     
     * Note the explicit call to `fail`, in the monad of the `do`-block.  Part of the specification
       of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash
    @@ -326,31 +331,32 @@ The `fail` block wrapping is done in `GHC.Tc.Gen.Do.mk_failable_expr`.
       pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate
       a `MonadFail` constraint that isn't needed.
     
    -* Why an anonymous lambda?
    +* Why an anonymous continuation lambda?
       We need a lambda for the types to match: this expression is a second
    -  argument to bind so it needs to be of type `a -> m b`
    -  It is anonymous because we do not want to introduce a new name that will
    -  never be seen by the user anyway.
    -
    -* Wrinkle 1: For pattern synonyms, we always wrap it with a `fail` block
    -  as the irrefutable pattern checker returns false but then during desugaring
    -  we would then get pattern match redundant warnings. To avoid such
    +  argument to `(>>=)` so it needs to be of type `a -> m b`, a function.
    +  It is anonymous because:
    +     a. the name will be compiler generated and will never be seen by the user, and;
    +     b. we are in the post renaming stage fresh naming will require non-trivial amount of plumbing for little gain.
    +
    +* Wrinkle 1: For pattern synonyms, we always wrap it with a `fail`-block.
    +  The irrefutable pattern checker returns false for pattern synonyms, but then after desugaring
    +  we would get a pattern match checker's redundant pattern warnings. To avoid such
       spurious warnings we filter out those type patterns that appear in a do expansion generated match
       in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs)
     
    -* Wrinkle 2: The `fail` call will give rise to a `MonadFail` constraint. What `CtOrigin` do we
    +* Wrinkle 2: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we
       attach to that constraint?  It should be a good one, because it'll show up in error
    -  messages if the `MonadFail` constraint can't be solved.  Ideally it should identify the
    +  messages when the `MonadFail` constraint can't be solved.  Ideally, it should identify the
       pattern `p`.  Hence, we wrap the `fail` alternative expression with a `ExpandedPat`
       that tags the fail expression with the failable pattern. (See testcase MonadFailErrors.hs)
     
     Part 2. Generate warnings for discarded body statement results
     --------------------------------------------------------------
    -If the `do` blocks' body statement is an expression that returns a
    -value that is not Unit or `()`, then we need to warn the user about discarded
    -value when -Wunused-binds flag is turned on (See testcase T3263-2.hs)
    +If the `do`-blocks' body statement is an expression that returns a
    +value that is not of type `()`, we need to warn the user about discarded
    +the value when `-Wunused-binds` flag is turned on. (See testcase T3263-2.hs)
     
    -For example the do expression
    +For example the `do`-block
     
         do { e1;  e2 }
     
    @@ -358,79 +364,81 @@ expands to
     
         (>>) e1 e2
     
    -* If `e1` returns a non-() value then we emit a warning. This check is done during desugaring
    -  `HsToCore.dsExpr` for the `HsApp` case calls `warnUnusedBindValue`.
    +* If `e1` returns a non-() value then we emit a value discarded warning. This check is done during desugaring
    +  `HsToCore.dsExpr` in the `HsApp` with a call to `HsToCore.warnUnusedBindValue`.
     
    -* The decision to trigger the warning is: if the function is a `(>>)`, it is a compiler generated
    -  and its first argument e1 is a non-() value
    +* The decision to trigger the warning is: if the function is a compiler generated `(>>)`,
    +  and its first argument `e1` has a non-() type
     
    -Part 3. Blaming offending source code and Generating Appropriate Error Messages
    +Part 3. Blaming Offending Source Code and Generating Appropriate Error Messages
     -------------------------------------------------------------------------------
     To ensure we correctly track source of the offending user written source code,
    -in this case do statements, we need to keep track of
    +in this case the `do`-statement, we need to keep track of
     which source statement's expansion the typechecker is currently typechecking.
     For this purpose we use the `XXExprGhcRn.ExpansionRn`.
     It stores the original statement (with location) and the expanded expression
     
       A. Expanding Body Statements
       -----------------------------
    -  For example, the do expression
    +  For example, the `do`-block
     
           do { e1;  e2 }
     
       expands (ignoring the location info) to
     
    -      ‹ExpandedExpr do { e1; e2 }›                               -- Original Do Expression
    +      ‹ExpandedThingRn do { e1; e2 }›                               -- Original Do Expression
                                                                      -- Expanded Do Expression
    -          (‹ExpandedStmt e1›                                     -- Original Statement
    +          (‹ExpandedThingRn e1›                                     -- Original Statement
                             ({(>>) e1}                               -- Expanded Expression
    -                            ‹PopErrCtxt› (‹ExpandedStmt e2› e2)))
    +                            ‹PopErrCtxt› (‹ExpandedThingRn e2› {e2})))
     
    -  * Whenever the typechecker steps through an `ExpandedStmt`,
    -    we push the original statement in the error context and typecheck the expanded expression.
    +  * Whenever the typechecker steps through an `ExpandedThingRn`,
    +    we push the original statement in the error context, set the error location to the
    +    location of the statement, and then typecheck the expanded expression.
         This is similar to vanilla `HsExpansion` and rebindable syntax
         See Note [Rebindable syntax and HsExpansion] in `GHC.Hs.Expr`.
     
       * Recall, that when a source function arugment fails to typecheck,
         we print an error message like "In the second argument of the function f..".
    -    However, `(>>)` is generated thus we don't want to display that to the user, it would be confusing.
    +    However, `(>>)` is generated thus, we don't want to display that to the user; it would be confusing.
         But also, we do not want to completely ignore it as we do want to keep the error blame carets
    -    as precise as possible and not just blame the complete `do` block.
    +    as precise as possible, and not just blame the complete `do`-block.
         Thus, when we typecheck the application `(>>) e1`, we push the "In the stmt of do block e1" with
    -    the source location of `e1` in the error context stack as we walk inside an `ExpandedStmt`.
    -    See also Note [splitHsApps]
    +    the source location of `e1` in the error context stack as we walk inside an `ExpandedThingRn`.
    +    See also Note [splitHsApps].
     
    -  * After the expanded expression of a `do` statement is typechecked
    -    and before moving to the next statement, we need to first pop the top
    -    of the error context which contains the error message for
    +  * After the expanded expression of a `do`-statement is typechecked
    +    and before moving to the next statement of the `do`-block, we need to first pop the top
    +    of the error context stack which contains the error message for
         the previous statement: eg. "In the stmt of a do block: e1".
         This is explicitly encoded in the expansion expression using
    -    the `XXExprGhcRn.PopErrCtxt`. Whenever `tcExpr` sees a `PopErrCtxt`
    -    it calls `popErrCtxt` to pop of the top of error context stack.
    -    See ‹PopErrCtxt› in the example above. Without this popping business for error context stack,
    -    If there is a type error in `e2`, we would get a spurious and confusing error message
    +    the `XXExprGhcRn.PopErrCtxt`. Whenever `GHC.Tc.Gen.Expr.tcExpr` (via `GHC.Tc.Gen.tcXExpr`)
    +    sees a `PopErrCtxt` it calls `GHC.Tc.Utils.Monad.popErrCtxt` to pop of the top of error context stack.
    +    See ‹PopErrCtxt› in the example above.
    +    Without this popping business for error context stack,
    +    if there is a type error in `e2`, we would get a spurious and confusing error message
         which mentions "In the stmt of a do block e1" along with the message
         "In the stmt of a do block e2".
     
       B. Expanding Bind Statements
       -----------------------------
    -  A `do` block with with a bind statement:
    +  A `do`-block with a bind statement:
     
           do { p <- e1; e2 }
     
       expands (ignoring the location information) to
     
    -     ‹ExpandedExpr do{ p <- e1; e2 }›                                      -- Original Do Expression
    +     ‹ExpandedThingRn do{ p <- e1; e2 }›                                      -- Original Do Expression
                                                                                --
    -         (‹ExpandedStmt (p <- e1)›                                         -- Original Statement
    +         (‹ExpandedThingRn (p <- e1)›                                         -- Original Statement
                             (((>>=) e1)                                        -- Expanded Expression
    -                           ‹PopErrCtxt› ((\ p -> ‹ExpandedStmt (e2)› e2)))
    +                           ‹PopErrCtxt› ((\ p -> ‹ExpandedThingRn (e2)› e2)))
              )
     
     
    -  However, the expansion lambda `(\p -> e2)` is special as it is generated from a `do` block expansion
    +  However, the expansion lambda `(\p -> e2)` is special as it is generated from a `do`-stmt expansion
       and if a type checker error occurs in the pattern `p` (which is source generated), we need to say
    -  "in a pattern binding in a do block" and not "in a lambda abstraction" (cf. Typeable1.hs).
    +  "in a pattern binding in a do block" and not "in the pattern of a lambda" (cf. Typeable1.hs).
       We hence use a tag `GenReason` in `Ghc.Tc.Origin`. When typechecking a `HsLam` in `Tc.Gen.Expr.tcExpr`
       the `match_ctxt` is set to a `StmtCtxt` if `GenOrigin` is a `DoExpansionOrigin`.
     -}
    
    
    =====================================
    compiler/GHC/Tc/Gen/Expr.hs
    =====================================
    @@ -270,7 +270,7 @@ tcExpr e@(HsLam x lam_variant matches) res_ty
       where
         match_ctxt
           | Just f <- doExpansionFlavour (mg_ext matches)
    -      -- See Part 3. of Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do`. Testcase: Typeable1
    +      -- See Part 3. B. of Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do`. Testcase: Typeable1
           = MC { mc_what = StmtCtxt (HsDoStmt f)
                , mc_body = tcBodyNC -- NB: Do not add any error contexts
                                     -- It has already been done
    @@ -660,7 +660,7 @@ tcXExpr (PopErrCtxt (L loc e)) res_ty
     
     tcXExpr xe@(ExpandedThingRn thing) res_ty
       | OrigStmt ls@(L loc s at LetStmt{}) <- original thing
    -  , HsLet x tkLet binds tkIn e <- (expanded thing)
    +  , HsLet x tkLet binds tkIn e <- expanded thing
       =  do { (binds', e') <-  setSrcSpanA loc $
                                 addStmtCtxt s $
                                 tcLocalBinds binds $
    @@ -679,11 +679,9 @@ tcXExpr xe@(ExpandedThingRn thing) res_ty
       | OrigStmt ls@(L loc _) <- original thing
       = setSrcSpanA loc $
            mkExpandedStmtTc ls <$> tcApp (XExpr xe) res_ty
    --- TODO: there is disgusting amount of packing unpacking going on here. Need to fix mkExpandStmtTc API
    ---       and addErrCtxt API
     
     tcXExpr xe res_ty = tcApp (XExpr xe) res_ty
    -                           -- See Wrinkle 2. of Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do`
    +
     {-
     ************************************************************************
     *                                                                      *
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da7079d11d428eca52f24e84b584082378fa6f5b
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da7079d11d428eca52f24e84b584082378fa6f5b
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 00:35:36 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Thu, 12 Oct 2023 20:35:36 -0400
    Subject: [Git][ghc/ghc][master] hadrian: Decrease verbosity of cabal commands
    Message-ID: <652890d854502_24a44516620e38217913@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    
    
    1 changed file:
    
    - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    
    
    Changes:
    
    =====================================
    hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    =====================================
    @@ -198,9 +198,10 @@ copyPackage context at Context {..} = do
     shakeVerbosityToCabalFlag :: Verbosity -> String
     shakeVerbosityToCabalFlag = \case
         Diagnostic -> "-v3"
    -    Verbose -> "-v3"
    +    Verbose -> "-v2"
    +    -- Normal levels should not produce output to stdout
         Silent -> "-v0"
    -    _ -> "-v2"
    +    _ -> "-v1"
     
     -- | What type of file is Main
     data MainSourceType = HsMain | CppMain | CMain
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e6ef7ba5949b8900b3a7efb3a443c2004ebe184
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e6ef7ba5949b8900b3a7efb3a443c2004ebe184
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 00:36:14 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Thu, 12 Oct 2023 20:36:14 -0400
    Subject: [Git][ghc/ghc][master] Do not substitute `@...@` for stage-specific
     values in cabal files
    Message-ID: <652890fe98cf9_24a4451661f57422133b@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    
    
    6 changed files:
    
    - .gitignore
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Settings/Packages.hs
    - libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    - rts/.gitignore
    - rts/rts.cabal.in → rts/rts.cabal
    
    
    Changes:
    
    =====================================
    .gitignore
    =====================================
    @@ -167,7 +167,6 @@ _darcs/
     /libraries/ghc-boot-th/ghc-boot-th.cabal
     /libraries/ghc-boot-th/ghc.mk
     /libraries/ghc-heap/ghc-heap.cabal
    -/libraries/ghc-prim/ghc-prim.cabal
     /libraries/ghci/GNUmakefile
     /libraries/ghci/ghci.cabal
     /libraries/ghci/ghc.mk
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -268,17 +268,6 @@ runInterpolations (Interpolations mk_substs) input = do
             subst = foldr (.) id [replace ("@"++k++"@") v | (k,v) <- substs]
         return (subst input)
     
    -toCabalBool :: Bool -> String
    -toCabalBool True  = "True"
    -toCabalBool False = "False"
    -
    --- | Interpolate the given variable with the value of the given 'Flag', using
    --- Cabal's boolean syntax.
    -interpolateCabalFlag :: String -> Flag -> Interpolations
    -interpolateCabalFlag name flg = interpolateVar name $ do
    -    val <- flag flg
    -    return (toCabalBool val)
    -
     -- | Interpolate the given variable with the value of the given 'Setting'.
     interpolateSetting :: String -> Setting -> Interpolations
     interpolateSetting name settng = interpolateVar name $ setting settng
    @@ -290,31 +279,6 @@ projectVersion = mconcat
         , interpolateSetting "ProjectVersionMunged" ProjectVersionMunged
         ]
     
    -rtsCabalFlags :: Interpolations
    -rtsCabalFlags = mconcat
    -    [ flag "CabalHaveLibdw" UseLibdw
    -    , flag "CabalHaveLibm" UseLibm
    -    , flag "CabalHaveLibrt" UseLibrt
    -    , flag "CabalHaveLibdl" UseLibdl
    -    , flag "CabalNeedLibpthread" UseLibpthread
    -    , flag "CabalHaveLibbfd" UseLibbfd
    -    , flag "CabalHaveLibNuma" UseLibnuma
    -    , flag "CabalHaveLibZstd" UseLibzstd
    -    , flag "CabalStaticLibZstd" StaticLibzstd
    -    , flag "CabalNeedLibatomic" NeedLibatomic
    -    , flag "CabalUseSystemLibFFI" UseSystemFfi
    -    , targetFlag "CabalLibffiAdjustors" tgtUseLibffiForAdjustors
    -    , targetFlag "CabalLeadingUnderscore" tgtSymbolsHaveLeadingUnderscore
    -    ]
    -  where
    -    flag = interpolateCabalFlag
    -    targetFlag name q = interpolateVar name $ do
    -      val <- queryTargetTarget q
    -      return (toCabalBool val)
    -
    -ghcPrimCabalFlags :: Interpolations
    -ghcPrimCabalFlags = interpolateCabalFlag "CabalNeedLibatomic" NeedLibatomic
    -
     packageVersions :: Interpolations
     packageVersions = foldMap f [ base, ghcPrim, compiler, ghc, cabal, templateHaskell, ghcCompact, array ]
       where
    @@ -347,8 +311,6 @@ templateRule outPath interps = do
     templateRules :: Rules ()
     templateRules = do
       templateRule "compiler/ghc.cabal" $ projectVersion
    -  templateRule "rts/rts.cabal" $ rtsCabalFlags
    -  templateRule "libraries/ghc-prim/ghc-prim.cabal" $ ghcPrimCabalFlags
       templateRule "driver/ghci/ghci-wrapper.cabal" $ projectVersion
       templateRule "ghc/ghc-bin.cabal" $ projectVersion
       templateRule "utils/iserv/iserv.cabal" $ projectVersion
    
    
    =====================================
    hadrian/src/Settings/Packages.hs
    =====================================
    @@ -114,7 +114,7 @@ packageArgs = do
     
             -------------------------------- ghcPrim -------------------------------
             , package ghcPrim ? mconcat
    -          [ builder (Cabal Flags) ? arg "include-ghc-prim"
    +          [ builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic"
     
               , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ?
                 input "**/cbits/atomic.c"  ? arg "-Wno-sync-nand" ]
    @@ -401,8 +401,19 @@ rtsPackageArgs = package rts ? do
               , any (wayUnit Debug) rtsWays     `cabalFlag` "debug"
               , any (wayUnit Dynamic) rtsWays   `cabalFlag` "dynamic"
               , any (wayUnit Threaded) rtsWays  `cabalFlag` "threaded"
    +          , flag UseLibm                    `cabalFlag` "libm"
    +          , flag UseLibrt                   `cabalFlag` "librt"
    +          , flag UseLibdl                   `cabalFlag` "libdl"
               , useSystemFfi                    `cabalFlag` "use-system-libffi"
               , useLibffiForAdjustors           `cabalFlag` "libffi-adjustors"
    +          , flag UseLibpthread              `cabalFlag` "need-pthread"
    +          , flag UseLibbfd                  `cabalFlag` "libbfd"
    +          , flag NeedLibatomic              `cabalFlag` "need-atomic"
    +          , flag UseLibdw                   `cabalFlag` "libdw"
    +          , flag UseLibnuma                 `cabalFlag` "libnuma"
    +          , flag UseLibzstd                 `cabalFlag` "libzstd"
    +          , flag StaticLibzstd              `cabalFlag` "static-libzstd"
    +          , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
               , Debug `wayUnit` way             `cabalFlag` "find-ptr"
               ]
             , builder (Cabal Setup) ? mconcat
    
    
    =====================================
    libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    =====================================
    @@ -28,7 +28,7 @@ custom-setup
         setup-depends: base >= 4 && < 5, process, filepath, directory, Cabal >= 1.23 && < 3.9
     
     flag need-atomic
    -  default: @CabalNeedLibatomic@
    +  default: False
     
     Library
         default-language: Haskell2010
    
    
    =====================================
    rts/.gitignore
    =====================================
    @@ -2,8 +2,6 @@
     /dist/
     /dist-*/
     
    -/rts.cabal
    -
     /include/ghcversion.h
     
     /package.conf.inplace
    
    
    =====================================
    rts/rts.cabal.in → rts/rts.cabal
    =====================================
    @@ -29,31 +29,31 @@ source-repository head
         subdir:   rts
     
     flag libm
    -  default: @CabalHaveLibm@
    +  default: False
     flag librt
    -  default: @CabalHaveLibrt@
    +  default: False
     flag libdl
    -  default: @CabalHaveLibdl@
    +  default: False
     flag use-system-libffi
    -  default: @CabalUseSystemLibFFI@
    +  default: False
     flag libffi-adjustors
    -  default: @CabalLibffiAdjustors@
    +  default: False
     flag need-pthread
    -  default: @CabalNeedLibpthread@
    +  default: False
     flag libbfd
    -  default: @CabalHaveLibbfd@
    +  default: False
     flag need-atomic
    -  default: @CabalNeedLibatomic@
    +  default: False
     flag libdw
    -  default: @CabalHaveLibdw@
    +  default: False
     flag libnuma
    -  default: @CabalHaveLibNuma@
    +  default: False
     flag libzstd
    -  default: @CabalHaveLibZstd@
    +  default: False
     flag static-libzstd
    -  default: @CabalStaticLibZstd@
    +  default: False
     flag leading-underscore
    -  default: @CabalLeadingUnderscore@
    +  default: False
     flag smp
       default: True
     flag find-ptr
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08fc27af4731a1cab4f82cfdedbf1dfb5f6fd563
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08fc27af4731a1cab4f82cfdedbf1dfb5f6fd563
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 10:39:04 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Fri, 13 Oct 2023 06:39:04 -0400
    Subject: [Git][ghc/ghc][wip/T20749] 49 commits: Fix several mistakes around
     free variables in iface breakpoints
    Message-ID: <65291e48de4b1_24a4452455a8882538cc@gitlab.mail>
    
    
    
    Sebastian Graf pushed to branch wip/T20749 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00
    Fix several mistakes around free variables in iface breakpoints
    
    Fixes #23612 , #23607, #23998 and #23666.
    
    MR: !11026
    
    The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons:
    
    * IfaceBreakpoint created binders for free variables instead of expressions
    
    * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped
    
    - - - - -
    ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00
    Refactor to combine HsLam and HsLamCase
    
    This MR is pure refactoring (#23916):
    * Combine `HsLam` and `HsLamCase`
    * Combine `HsCmdLam` and `HsCmdLamCase`
    
    This just arranges to treat uniformly
       \x -> e
       \case pi -> ei
       \cases pis -> ie
    
    In the exising code base the first is treated differently
    to the latter two.
    
    No change in behaviour.
    
    More specifics:
    
    * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering
      * Lambda
      * `\case`
      * `\cases`
    
    * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases.
    
    * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one.
    
    * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.)
    
    * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument.
    
    * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument.
    
    * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
    
    * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
    
    * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one.
    
    * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one.
    
    p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one.
    
    Phew!
    
    - - - - -
    b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
    Arm: Make ppr methods easier to use by not requiring NCGConfig
    
    - - - - -
    2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
    AArch64: Fix broken conditional jumps for offsets >= 1MB
    
    Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps
    to avoid overflowing the immediate.
    
    Fixes #23746
    
    - - - - -
    1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00
    EPA: Replace Monoid with NoAnn
    
    We currently use the Monoid class as a constraint on Exact Print
    Annotation functions, so we can use mempty. But this leads to
    requiring Semigroup instances too, which do not always make sense.
    
    Instead, introduce a class NoAnn, with a function noAnn analogous to
    mempty.
    
    Closes #20372
    
    Updates haddock submodule
    
    - - - - -
    c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00
    users-guide: Refactor handling of :base-ref: et al.
    
    - - - - -
    bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00
    Simplify and correct nasty case in coercion opt
    
    This fixes #21062.
    
    No test case, because triggering this code seems challenging.
    
    - - - - -
    9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Bump bytestring submodule to 0.12.0.2
    
    - - - - -
    4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Inline bucket_match
    
    - - - - -
    f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00
    configure: Fix #21712 again
    
    This is a bit of a shot in the dark to fix #24033, which appears to be
    another instance of #21712. For some reason the ld-override logic
    *still* appears to be active on Darwin targets (or at least one).
    Consequently, on misconfigured systems we may choose a non-`ld64`
    linker.
    
    It's a bit unclear exactly what happened in #24033 but ultimately the
    check added for #21712 was not quite right, checking for the
    `ghc_host_os` (the value of which depends upon the bootstrap compiler)
    instead of the target platform. Fix this.
    
    Fixes #24033.
    
    - - - - -
    2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00
    Add a regression test for #24029
    
    - - - - -
    8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00
    Fix non-symbolic children lookup of fixity decl
    
    The fix for #23664 did not correctly account for non-symbolic names
    when looking up children of a given parent. This one-line fix changes
    that.
    
    Fixes #24037
    
    - - - - -
    a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00
    rts: fix incorrect ticket reference
    
    - - - - -
    e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00
    users-guide: Fix discussion of -Wpartial-fields
    
     * fix a few typos
     * add a new example showing when the warning fires
     * clarify the existing example
     * point out -Wincomplete-record-selects
    
    Fixes #24049.
    
    - - - - -
    8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00
    Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"
    
    This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.
    
    `-optP` should pass options to the preprocessor, that might be a very
    different program to the C compiler, so passing the options to the C
    compiler is likely to result in `-optP` being useless.
    
    Fixes #17185 and #21291
    
    - - - - -
    8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00
    rts/nonmoving: Fix on LLP64 platforms
    
    Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL`
    size suffix. However, this is wrong on LLP64 platforms like Windows,
    where `long` is 32-bits.
    
    Fixes #23003.
    Fixes #24042.
    
    - - - - -
    f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00
    Fix isAArch64Bitmask for 32bit immediates.
    
    Fixes #23802
    
    - - - - -
    63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00
    Work around perf note fetch failure
    
    Addresses #24055.
    
    - - - - -
    242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00
    Add a test for #21348
    
    - - - - -
    7d390bce by Rewbert at 2023-10-05T05:38:08-04:00
    Fixes #24046
    
    - - - - -
    69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00
    Ensure unconstrained instance dictionaries get IPE info
    
    In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up
    with an initial source span based on the span of the binder, which was causing
    instance dictionaries without dynamic superclass constraints to not have source
    locations in their IPE info. Now they do.
    
    Resolves #24005
    
    - - - - -
    390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00
    rts: Split up rts/include/stg/MachRegs.h by arch
    
    - - - - -
    3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00
    Actually set hackage index state
    
    Or at least, use a version of the cabal command that *claims* to set the
    index state.
    
    Time will tell.
    
    - - - - -
    46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00
    Update hackage index state
    
    - - - - -
    d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00
    Ensure hadrian uses CI's hackage index state
    
    - - - - -
    e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00
    Do not use O_NONBLOCK on regular files or block devices
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/166
    
    - - - - -
    a06197c4 by David Binder at 2023-10-08T15:06:55-04:00
    Update hpc-bin submodule to 0.69
    
    - - - - -
    ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00
    Update Hadrian with correct path to happy file for hpc-bin
    
    - - - - -
    ec5314a5 by Simon Peyton Jones at 2023-10-09T17:30:03+01:00
    Several improvements to the handling of coercions
    
    * Make `mkSymCo` and `mkInstCo` smarter
      Fixes #23642
    
    * Fix return role of `SelCo` in the coercion optimiser.
      Fixes #23617
    
    * Make the coercion optimiser `opt_trans_rule` work better for newtypes
      Fixes #23619
    
    - - - - -
    37ea9daf by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    Simplifier improvements
    
    This MR started as: allow the simplifer to do more in one pass,
    arising from places I could see the simplifier taking two iterations
    where one would do.  But it turned into a larger project, because
    these changes unexpectedly made inlining blow up, especially join
    points in deeply-nested cases.
    
    The net result is good: a 2% improvement in compile time.  The table
    below shows changes over 1%.
    
    The main changes are:
    
    * The SimplEnv now has a seInlineDepth field, which says how deep
      in unfoldings we are.  See Note [Inline depth] in Simplify.Env
    
    * Avoid repeatedly simplifying coercions.
      see Note [Avoid re-simplifying coercions] in Simplify.Iteration
      As you'll see from the Note, this makes use of the seInlineDepth.
    
    * Allow Simplify.Utils.postInlineUnconditionally to inline variables
      that are used exactly once. See Note [Post-inline for single-use things].
    
    * Allow Simplify.Iteration.simplAuxBind to inline used-once things.
      This is another part of Note [Post-inline for single-use things], and
      is really good for reducing simplifier iterations in situations like
          case K e of { K x -> blah }
      wher x is used once in blah.
    
    * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case
      elimination.  Note [Case elim in exprIsConApp_maybe]
    
    * When making join points, don't do so if the join point is so small
      it will immediately be inlined.  See Note [Duplicating alternatives]
    
    * Do not add an unfolding to a join point at birth.  This is a tricky one
      and has a long Note [Do not add unfoldings to join points at birth]
      It shows up in two places
      - In `mkDupableAlt` do not add an inlining
      - (trickier) In `simplLetUnfolding` don't add an unfolding for a
        fresh join point
      I am not fully satisifed with this, but it works and is well documented.
    
    * Many new or rewritten Notes.  E.g. Note [Avoiding simplifying repeatedly]
    
    I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very
    delicately balanced.  It's a small, heavily used, overloaded function
    and it's important that it inlines. By a fluke it was before, but at
    various times in my journey it stopped doing so.  So I added an INLINE
    pragma to it.
    
    Metrics: compile_time/bytes allocated
    ------------------------------------------------
               CoOpt_Singletons(normal)   -4.3% GOOD
                    LargeRecord(normal)  -23.3% GOOD
                      PmSeriesS(normal)   -2.4%
                         T11195(normal)   -1.7%
                         T12227(normal)  -20.0% GOOD
                         T12545(normal)   -5.4%
                     T13253-spj(normal)  -50.7% GOOD
                         T13386(normal)   -5.1% GOOD
                         T14766(normal)   -2.4% GOOD
                         T15164(normal)   -1.7%
                         T15304(normal)   +1.0%
                         T15630(normal)   -7.7%
                        T15630a(normal)          NEW
                         T15703(normal)   -7.5% GOOD
                         T16577(normal)   -5.1% GOOD
                         T17516(normal)   -3.6%
                         T18223(normal)  -16.8% GOOD
                         T18282(normal)   -1.5%
                         T18304(normal)   +1.9%
                        T21839c(normal)   -3.5% GOOD
                          T3064(normal)   -1.5%
                          T5030(normal)  -16.2% GOOD
                       T5321Fun(normal)   -1.6%
                          T6048(optasm)   -2.1% GOOD
                          T8095(normal)   -6.1% GOOD
                          T9630(normal)   -5.1% GOOD
                          WWRec(normal)   -1.6%
    
                              geo. mean   -2.1%
                              minimum    -50.7%
                              maximum     +1.9%
    
    Metric Decrease:
        CoOpt_Singletons
        LargeRecord
        T12227
        T13253-spj
        T13386
        T14766
        T15703
        T16577
        T18223
        T21839c
        T5030
        T6048
        T8095
        T9630
    
    - - - - -
    a57fd42c by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    Improve postInlineUnconditionally
    
    This commit adds two things to postInlineUnconditionally:
    
    1. Do not postInlineUnconditionally join point, ever.
       Doing so does not reduce allocation, which is the main point,
       and with join points that are used a lot it can bloat code.
       See point (1) of Note [Duplicating join points] in
       GHC.Core.Opt.Simplify.Iteration.
    
    2. Do not postInlineUnconditionally a strict (demanded) binding.
       It will not allocate a thunk (it'll turn into a case instead)
       so again the main point of inlining it doesn't hold.  Better
       to check per-call-site.
    
    - - - - -
    498d8293 by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    Update testsuite output
    
    - - - - -
    4a16ecd9 by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    Try effect of
    
    * making multi-branch cases not work free (fixes #22423)
    * use plan A for dataToTag and tagToEnum
    
    - - - - -
    6517a2ff by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    More changes
    
    * No floating at all for join points
    
    * Never inline j x = I x
      Example: integerSignum !j = IS (integerSignum# j)
      We want this to inline and then cancel with an enclosing case.
      But it won't if we have changed it to
           integerSignum x = case x of
                                IN a -> IS (...)
                                IS b -> IS (...)
                                IP c -> IS (...)
    
      This involved changing
      - UnfoldingGuidance to not say always-inline for j x = Ix
      - callSiteInline to inline join points only if there is a real
        benefit
      - ok_to_dup_alt in Simplify.Iteration
    
    * Row back (for now) on changes to GHC.Core.Utils.ExprIsCheap
    
    - - - - -
    4c867702 by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    Wibble
    
    - - - - -
    f875ef1c by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    Wibble
    
    - - - - -
    7514e8de by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    Further wibbles
    
    - - - - -
    cb5f2a8e by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    One more wibble
    
    Don't float an unlifted join point
    
    - - - - -
    af4f30b1 by Simon Peyton Jones at 2023-10-09T17:31:06+01:00
    Small wibbles
    
    The most significant change is to mkSelCo.
    
    - - - - -
    9c7acc26 by Simon Peyton Jones at 2023-10-10T09:35:00+01:00
    Temporarily add -DDEBUG to Coercion.hs
    
    - - - - -
    735951dd by Simon Peyton Jones at 2023-10-10T15:57:04+01:00
    Fix a missing zonk in before mkSelCo
    
    - - - - -
    12609f12 by Simon Peyton Jones at 2023-10-10T16:26:33+01:00
    Wibbles
    
    - - - - -
    d5d52467 by Simon Peyton Jones at 2023-10-10T16:26:42+01:00
    Tickish comment
    
    - - - - -
    07bd48ae by Sebastian Graf at 2023-10-12T15:00:22+02:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    - - - - -
    fec58945 by Sebastian Graf at 2023-10-12T15:00:22+02:00
    Fix restarts in .ghcid
    
    Using the whole of `hadrian/` restarted in a loop for me.
    
    - - - - -
    5b226c89 by Sebastian Graf at 2023-10-13T12:38:55+02:00
    Make DataCon workers strict in strict fields (#20749)
    
    This patch tweaks `exprIsConApp_maybe`, `exprIsHNF` and friends, and Demand
    Analysis so that they exploit and maintain strictness of DataCon workers. See
    `Note [Strict fields in Core]` for details.
    
    Very little needed to change, and it puts field seq insertion done by Tag
    Inference into a new perspective: That of *implementing* strict field semantics.
    Before Tag Inference, DataCon workers are strict. Afterwards they are
    effectively lazy and field seqs happen around use sites. History has shown
    that there is no other way to guarantee taggedness and thus the STG Strict Field
    Invariant.
    
    Knock-on changes:
    
      * `exprIsHNF` previously used `exprOkForSpeculation` on unlifted arguments
        instead of recursing into `exprIsHNF`. That regressed the termination
        analysis in CPR analysis (which simply calls out to `exprIsHNF`), so I made
        it call `exprOkForSpeculation`, too.
    
      * There's a small regression in Demand Analysis, visible in the changed test
        output of T16859: Previously, a field seq on a variable would give that
        variable a "used exactly once" demand, now it's "used at least once",
        because `dmdTransformDataConSig` accounts for future uses of the field
        that actually all go through the case binder (and hence won't re-enter the
        potential thunk). The difference should hardly be observable.
    
      * The Simplifier's fast path for data constructors only applies to lazy
        data constructors now. I observed regressions involving Data.Binary.Put's
        `Pair` data type.
    
      * Unfortunately, T21392 does no longer reproduce after this patch, so I marked
        it as "not broken" in order to track whether we regress again in the future.
    
    Fixes #20749, the satisfying conclusion of an annoying saga (cf. the ideas
    in #21497 and #22475).
    
    - - - - -
    c1aca439 by Jaro Reinders at 2023-10-13T12:38:55+02:00
    Try fixing allocation regressions
    
    - - - - -
    fafb6d89 by Sebastian Graf at 2023-10-13T12:38:55+02:00
    CorePrep: Attach evaldUnfolding to floats to detect more values
    
    - - - - -
    7a8b97fb by Sebastian Graf at 2023-10-13T12:38:55+02:00
    Arity: Attach eval'd arity type of scrutinee to case binder
    
    Just a sensible thing to do; should be a straight win.
    
    - - - - -
    
    
    30 changed files:
    
    - .ghcid
    - .gitignore
    - .gitlab/ci.sh
    - .gitlab/test-metrics.sh
    - compiler/CodeGen.Platform.h
    - compiler/GHC/Builtin/Types.hs
    - compiler/GHC/CmmToAsm.hs
    - compiler/GHC/CmmToAsm/AArch64.hs
    - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
    - compiler/GHC/CmmToAsm/AArch64/Cond.hs
    - compiler/GHC/CmmToAsm/AArch64/Instr.hs
    - compiler/GHC/CmmToAsm/AArch64/Ppr.hs
    - compiler/GHC/CmmToAsm/BlockLayout.hs
    - compiler/GHC/CmmToAsm/Monad.hs
    - compiler/GHC/CmmToAsm/PPC/Instr.hs
    - compiler/GHC/CmmToAsm/X86.hs
    - compiler/GHC/Core.hs
    - compiler/GHC/Core/Coercion.hs
    - compiler/GHC/Core/Coercion/Opt.hs
    - compiler/GHC/Core/DataCon.hs
    - compiler/GHC/Core/Opt/Arity.hs
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Core/Opt/CprAnal.hs
    - compiler/GHC/Core/Opt/DmdAnal.hs
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/Core/Opt/SetLevels.hs
    - compiler/GHC/Core/Opt/Simplify/Env.hs
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Opt/Simplify/Iteration.hs
    - compiler/GHC/Core/Opt/Simplify/Monad.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2403009c6d12882197ae015a6c72d129236e7606...7a8b97fbf89f37eaba135a623ce9a79250cbc268
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2403009c6d12882197ae015a6c72d129236e7606...7a8b97fbf89f37eaba135a623ce9a79250cbc268
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 11:07:29 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Fri, 13 Oct 2023 07:07:29 -0400
    Subject: [Git][ghc/ghc][wip/T23442] CorePrep: Refactor FloatingBind (#23442)
    Message-ID: <652924f198b3d_24a445251706a42625d9@gitlab.mail>
    
    
    
    Sebastian Graf pushed to branch wip/T23442 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    59dee186 by Sebastian Graf at 2023-10-13T13:07:08+02:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    NoFib results (omitted = 0.0%):
    ```
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             pretty           0.0%     -1.6%
                scc           0.0%     -1.7%
    --------------------------------------------------------------------------------
                Min           0.0%     -1.7%
                Max           0.0%     -0.0%
     Geometric Mean          -0.0%     -0.0%
    ```
    
    - - - - -
    
    
    2 changed files:
    
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Data/OrdList.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/CoreToStg/Prep.hs
    =====================================
    @@ -1,4 +1,5 @@
     {-# LANGUAGE BangPatterns #-}
    +{-# LANGUAGE ViewPatterns #-}
     
     {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
     
    @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation.
         (The code generator can't deal with anything else.)
         Type lambdas are ok, however, because the code gen discards them.
     
    -5.  [Not any more; nuked Jun 2002] Do the seq/par munging.
    +5.  ANF-isation results in additional bindings that can obscure values.
    +    We float these out; see Note [Floating in CorePrep].
     
     6.  Clone all local Ids.
         This means that all such Ids are unique, rather than the
    @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep:
         Expressions
            body ::= app
                   | let(rec) x = rhs in body     -- Boxed only
    -              | case body of pat -> body
    +              | case app of pat -> body
                   | /\a. body | /\c. body
                   | body |> co
     
    @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg
             binds_out = initUs_ us $ do
                           floats1 <- corePrepTopBinds initialCorePrepEnv binds
                           floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds
    -                      return (deFloatTop (floats1 `appendFloats` floats2))
    +                      return (deFloatTop (floats1 `zipFloats` floats2))
     
         endPassIO logger (cpPgm_endPassConfig pgm_cfg)
                   binds_out []
    @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds
                                      -- Only join points get returned this way by
                                      -- cpeBind, and no join point may float to top
                                    floatss <- go env' binds
    -                               return (floats `appendFloats` floatss)
    +                               return (floats `zipFloats` floatss)
     
     mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind]
     -- See Note [Data constructor workers]
    @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons
                  LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name
                span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1
     
    -{-
    +{- Note [Floating in CorePrep]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +ANFisation risks producing a lot of nested lets that obscures values:
    +  let v = (:) (f 14) [] in e
    +  ==> { ANF in CorePrep }
    +  let v = let sat = f 14 in (:) sat [] in e
    +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that
    +allocates a thunk for `sat` and then allocates the cons cell.
    +Hence we carry around a bunch of floated bindings with us so that we again
    +expose the values:
    +  let v = let sat = f 14 in (:) sat [] in e
    +  ==> { Float sat }
    +  let sat = f 14 in
    +  let v = (:) sat [] in e
    +(We will not do this transformation if `v` does not become a value afterwards;
    +see Note [wantFloatLocal].)
    +If `v` is bound at the top-level, we might even float `sat` to top-level;
    +see Note [Floating out of top level bindings].
    +For nested let bindings, we have to keep in mind Note [Core letrec invariant]
    +and may exploit strict contexts; see Note [wantFloatLocal].
    +
    +There are 3 main categories of floats, encoded in the `FloatingBind` type:
    +
    +  * `Float`: A floated binding, as `sat` above.
    +    These come in different flavours as described by their `FloatInfo` and
    +    `BindInfo`, which captures how far the binding can be floated and whether or
    +    not we want to case-bind. See Note [BindInfo and FloatInfo].
    +  * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings;
    +    see (U3) of Note [Implementing unsafeCoerce].
    +    It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable`
    +    (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to
    +    bind the unsafe coercion field of the Refl constructor.
    +  * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep].
    +
     Note [Floating out of top level bindings]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     NB: we do need to float out of top-level bindings
    @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs)
                  floats1 | triv_rhs, isInternalName (idName bndr)
                          = floats
                          | otherwise
    -                     = addFloat floats new_float
    +                     = snocFloat floats new_float
     
    -             new_float = mkFloat env dmd is_unlifted bndr1 rhs1
    +             new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1
     
            ; return (env2, floats1, Nothing) }
     
    @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs)
            ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env')
                                bndrs1 rhss
     
    -       ; let (floats_s, rhss1) = unzip stuff
    -             -- Glom all floats into the Rec, *except* FloatStrings which can
    -             -- (and must, because unlifted!) float further.
    -             (string_floats, all_pairs) =
    -               foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1)
    -                                 (concatFloats floats_s)
    +       ; let (zipManyFloats -> floats, rhss1) = unzip stuff
    +             -- Glom all floats into the Rec, *except* FloatStrings; see
    +             -- see Note [ANF-ising literal string arguments], Wrinkle (FS1)
    +             is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs
    +             is_lit _                                                = False
    +             (string_floats, top) = partitionOL is_lit (fs_binds floats)
    +                 -- Strings will *always* be in `top_floats` (we made sure of
    +                 -- that in `snocOL`), so that's the only field we need to
    +                 -- partition.
    +             floats'   = floats { fs_binds = top }
    +             all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats')
            -- use env below, so that we reset cpe_rec_ids
            ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1),
    -                 string_floats `addFloat` FloatLet (Rec all_pairs),
    +                 snocFloat (emptyFloats { fs_binds = string_floats })
    +                           (Float (Rec all_pairs) LetBound TopLvlFloatable),
                      Nothing) }
     
       | otherwise -- See Note [Join points and floating]
    @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs)
     
             -- Flatten all the floats, and the current
             -- group into a single giant Rec
    -    add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r)    : prs2)
    -    add_float (FloatLet (Rec prs1))   (ss, prs2) = (ss, prs1    ++ prs2)
    -    add_float s at FloatString{}         (ss, prs2) = (addFloat ss s, prs2)
    -    add_float b                       _          = pprPanic "cpeBind" (ppr b)
    +    add_float (Float bind bound _) prs2
    +      | bound /= CaseBound = case bind of
    +          NonRec x e -> (x,e) : prs2
    +          Rec prs1 -> prs1 ++ prs2
    +    add_float f                       _    = pprPanic "cpeBind" (ppr f)
     
     ---------------
     cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool
    @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
         do { (floats1, rhs1) <- cpeRhsE env rhs
     
            -- See if we are allowed to float this stuff out of the RHS
    -       ; (floats2, rhs2) <- float_from_rhs floats1 rhs1
    +       ; let dec = want_float_from_rhs floats1 rhs1
    +       ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1
     
            -- Make the arity match up
            ; (floats3, rhs3)
    @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
                    else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $
                                    -- Note [Silly extra arguments]
                         (do { v <- newVar (idType bndr)
    -                        ; let float = mkFloat env topDmd False v rhs2
    -                        ; return ( addFloat floats2 float
    +                        ; let float = mkNonRecFloat env topDmd False v rhs2
    +                        ; return ( snocFloat floats2 float
                                      , cpeEtaExpand arity (Var v)) })
     
             -- Wrap floating ticks
    @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
       where
         arity = idArity bndr        -- We must match this arity
     
    -    ---------------------
    -    float_from_rhs floats rhs
    -      | isEmptyFloats floats = return (emptyFloats, rhs)
    -      | isTopLevel top_lvl   = float_top    floats rhs
    -      | otherwise            = float_nested floats rhs
    -
    -    ---------------------
    -    float_nested floats rhs
    -      | wantFloatNested is_rec dmd is_unlifted floats rhs
    -                  = return (floats, rhs)
    -      | otherwise = dontFloat floats rhs
    -
    -    ---------------------
    -    float_top floats rhs
    -      | allLazyTop floats
    -      = return (floats, rhs)
    -
    -      | otherwise
    -      = dontFloat floats rhs
    -
    -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody)
    --- Non-empty floats, but do not want to float from rhs
    --- So wrap the rhs in the floats
    --- But: rhs1 might have lambdas, and we can't
    ---      put them inside a wrapBinds
    -dontFloat floats1 rhs
    -  = do { (floats2, body) <- rhsToBody rhs
    -        ; return (emptyFloats, wrapBinds floats1 $
    -                               wrapBinds floats2 body) }
    +    want_float_from_rhs floats rhs
    +      | isTopLevel top_lvl = wantFloatTop floats
    +      | otherwise          = wantFloatLocal is_rec dmd is_unlifted floats rhs
     
     {- Note [Silly extra arguments]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body)
            ; (body_floats, body') <- cpeRhsE env' body
            ; let expr' = case maybe_bind' of Just bind' -> Let bind' body'
                                              Nothing    -> body'
    -       ; return (bind_floats `appendFloats` body_floats, expr') }
    +       ; return (bind_floats `appFloats` body_floats, expr') }
     
     cpeRhsE env (Tick tickish expr)
       -- Pull out ticks if they are allowed to be floated.
       | tickishFloatable tickish
       = do { (floats, body) <- cpeRhsE env expr
              -- See [Floating Ticks in CorePrep]
    -       ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) }
    +       ; return (FloatTick tickish `consFloat` floats, body) }
       | otherwise
       = do { body <- cpeBodyNF env expr
            ; return (emptyFloats, mkTick tickish' body) }
    @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _])
            ; (floats_rhs, rhs) <- cpeBody env rhs
              -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might
              -- become a value
    -       ; let case_float = FloatCase scrut bndr con bs True
    -         -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly.
    +       ; let case_float = UnsafeEqualityCase scrut bndr con bs
    +         -- NB: It is OK to "evaluate" the proof eagerly.
              --     Usually there's the danger that we float the unsafeCoerce out of
              --     a branching Case alt. Not so here, because the regular code path
              --     for `cpeRhsE Case{}` will not float out of alts.
    -             floats = addFloat floats_scrut case_float `appendFloats` floats_rhs
    +             floats = snocFloat floats_scrut case_float `appFloats` floats_rhs
            ; return (floats, rhs) }
     
     cpeRhsE env (Case scrut bndr ty alts)
    @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody)
     cpeBody env expr
       = do { (floats1, rhs) <- cpeRhsE env expr
            ; (floats2, body) <- rhsToBody rhs
    -       ; return (floats1 `appendFloats` floats2, body) }
    +       ; return (floats1 `appFloats` floats2, body) }
     
     --------
     rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody)
    @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {})   -- See Note [No eta reduction needed in rhsToBody]
       | otherwise                   -- Some value lambdas
       = do { let rhs = cpeEtaExpand (exprArity expr) expr
            ; fn <- newVar (exprType rhs)
    -       ; let float = FloatLet (NonRec fn rhs)
    +       ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable
            ; return (unitFloat float, Var fn) }
       where
         (bndrs,_) = collectBinders expr
    @@ -1125,7 +1142,8 @@ cpeApp top_env expr
             :: CorePrepEnv
             -> [ArgInfo]                  -- The arguments (inner to outer)
             -> CpeApp                     -- The function
    -        -> Floats
    +        -> Floats                     -- INVARIANT: These floats don't bind anything that is in the CpeApp!
    +                                      -- Just stuff floated out from the head of the application.
             -> [Demand]
             -> Maybe Arity
             -> UniqSM (CpeApp
    @@ -1170,7 +1188,7 @@ cpeApp top_env expr
                        (ss1 : ss_rest, False) -> (ss1,    ss_rest)
                        ([],            _)     -> (topDmd, [])
             (fs, arg') <- cpeArg top_env ss1 arg
    -        rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1)
    +        rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1)
     
           CpeCast co
             -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth
    @@ -1182,7 +1200,7 @@ cpeApp top_env expr
                rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth
             | otherwise
             -- See [Floating Ticks in CorePrep]
    -        -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth
    +        -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth
     
     isLazyExpr :: CoreExpr -> Bool
     -- See Note [lazyId magic] in GHC.Types.Id.Make
    @@ -1261,8 +1279,7 @@ Other relevant Notes:
      * Note [runRW arg] below, describing a non-obvious case where the
        late-inlining could go wrong.
     
    -
    - Note [runRW arg]
    +Note [runRW arg]
     ~~~~~~~~~~~~~~~~~~~
     Consider the Core program (from #11291),
     
    @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By
     contrast, in the non-bottoming case of `hello` above  the function will be
     deemed non-trivial and consequently will be case-bound.
     
    -
     Note [Simplification of runRW#]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Consider the program,
    @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to
         foo = Foo s
     
     (String literals are the only kind of binding allowed at top-level and hence
    -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted
    -floats are `IfUnboxedOk` so that they don't float to top-level.)
    +their `FloatInfo` is `TopLvlFloatable`.)
     
     This appears to lead to bad code if the arg is under a lambda, because CorePrep
     doesn't float out of RHSs, e.g., (T23270)
    @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm:
     
     Wrinkles:
     
    -(FS1) It is crucial that we float out String literals out of RHSs that could
    -      become values, e.g.,
    -
    -        let t = case "turtle"# of s { __DEFAULT -> MkT s }
    -        in f t
    -
    -      where `MkT :: Addr# -> T`. We want
    -
    -        let s = "turtle"#; t = MkT s
    -        in f t
    -
    -      because the former allocates an extra thunk for `t`.
    -      Normally, the `case turtle# of s ...` becomes a `FloatCase` and
    -      we don't float `FloatCase` outside of (recursive) RHSs, so we get the
    -      former program (this is the 'allLazyNested' test in 'wantFloatNested').
    -      That is what we use `FloatString` for: It is essentially a `FloatCase`
    -      which is always ok-to-spec/can be regarded as a non-allocating value and
    -      thus be floated aggressively to expose more value bindings.
    +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway;
    +      otherwise we'd try to bind a string literal in a letrec, violating
    +      Note [Core letrec invariant]. Since we know that literals don't have
    +      free variables, we float further.
    +      Arguably, we could just as well relax the letrec invariant for
    +      string literals, or anthing that is a value (lifted or not).
    +      This is tracked in #24036.
     -}
     
     -- This is where we arrange that a non-trivial argument is let-bound
    @@ -1459,10 +1463,9 @@ cpeArg env dmd arg
       = do { (floats1, arg1) <- cpeRhsE env arg     -- arg1 can be a lambda
            ; let arg_ty      = exprType arg1
                  is_unlifted = isUnliftedType arg_ty
    -             want_float  = wantFloatNested NonRecursive dmd is_unlifted
    -       ; (floats2, arg2) <- if want_float floats1 arg1
    -                            then return (floats1, arg1)
    -                            else dontFloat floats1 arg1
    +             dec         = wantFloatLocal NonRecursive dmd is_unlifted
    +                                                  floats1 arg1
    +       ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1
                     -- Else case: arg1 might have lambdas, and we can't
                     --            put them inside a wrapBinds
     
    @@ -1474,8 +1477,8 @@ cpeArg env dmd arg
              else do { v <- newVar arg_ty
                      -- See Note [Eta expansion of arguments in CorePrep]
                      ; let arg3 = cpeEtaExpandArg env arg2
    -                       arg_float = mkFloat env dmd is_unlifted v arg3
    -                 ; return (addFloat floats2 arg_float, varToCoreExpr v) }
    +                       arg_float = mkNonRecFloat env dmd is_unlifted v arg3
    +                 ; return (snocFloat floats2 arg_float, varToCoreExpr v) }
            }
     
     cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg
    @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity
     Eta expanding the join point would introduce crap that we can't
     generate code for
     
    -Note [Floating unlifted arguments]
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -Consider    C (let v* = expensive in v)
    -
    -where the "*" indicates "will be demanded".  Usually v will have been
    -inlined by now, but let's suppose it hasn't (see #2756).  Then we
    -do *not* want to get
    -
    -     let v* = expensive in C v
    -
    -because that has different strictness.  Hence the use of 'allLazy'.
    -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.)
    -
    -
     ------------------------------------------------------------------------------
     -- Building the saturated syntax
     -- ---------------------------------------------------------------------------
    @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments
     that are either
     
       1. Strictly evaluated anyway, according to the DmdSig of the callee, or
    -  2. ok-for-spec, according to 'exprOkForSpeculation'
    +  2. ok-for-spec, according to 'exprOkForSpeculation'.
    +     This includes DFuns `$fEqList a`, for example.
    +     (Could identify more in the future; see reference to !1866 below.)
     
     While (1) is a no-brainer and always beneficial, (2) is a bit
     more subtle, as the careful haddock for 'exprOkForSpeculation'
    @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting.
     It is also similar to Note [Do not strictify a DFun's parameter dictionaries],
     where marking recursive DFuns (of undecidable *instances*) strict in dictionary
     *parameters* leads to quite the same change in termination as above.
    +
    +Note [BindInfo and FloatInfo]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +The `BindInfo` of a `Float` describes whether it will be case-bound or
    +let-bound:
    +
    +  * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec.
    +  * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`.
    +                 (So always NonRec.)
    +                 Some case-bound things (string literals, lifted bindings)
    +                 can float to top-level (but not all), hence it is similar
    +                 to, but not the same as `StrictContextFloatable :: FloatInfo`
    +                 described below.
    +
    +This info is used in `wrapBinds` to pick the corresponding binding form.
    +
    +We want to case-bind iff the binding is (non-recursive, and) either
    +
    +  * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or
    +  * unlifted, or
    +  * strictly used
    +
    +The `FloatInfo` of a `Float` describes how far it can float without
    +(a) violating Core invariants and (b) changing semantics.
    +
    +  * Any binding is at least `StrictContextFloatable`, meaning we may float it
    +    out of a strict context such as `f <>` where `f` is strict.
    +
    +  * A binding is `LazyContextFloatable` if we may float it out of a lazy context
    +    such as `let x = <> in Just x`.
    +    Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval
    +                    such as `case divInt# x y of r -> { __DEFAULT -> I# r }`.
    +                    Here, we may not foat out the strict `r = divInt# x y`.
    +
    +  * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can
    +    be bound at the top level.
    +    Counterexample: A strict or unlifted binding (ok-for-spec-eval or not)
    +                    such as `case x +# y of r -> { __DEFAULT -> I# r }`.
    +
    +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`.
    +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with
    +the the following enum (check `mkNonRecFloat` for whether this is up to date):
    +
    +   LetBoundTopLvlFloatable          (lifted or boxed values)
    +  CaseBoundTopLvlFloatable          (strings, ok-for-spec-eval and lifted)
    +  CaseBoundLazyContextFloatable     (ok-for-spec-eval and unlifted)
    +  CaseBoundStrictContextFloatable   (not ok-for-spec-eval and unlifted)
    +
    +Although there is redundancy in the current encoding, SG thinks it is cleaner
    +conceptually.
    +
    +See also Note [Floats and FloatDecision] for how we maintain whole groups of
    +floats and how far they go.
    +
    +Note [Floats and FloatDecision]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +We have a special datatype `Floats` for modelling a telescope of `FloatingBind`
    +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs`
    +(see Note [BindInfo and FloatInfo] for the ordering).
    +There are several operations for creating and combining `Floats` that maintain
    +scoping and the cached `FloatInfo`.
    +
    +When deciding whether we want to float out a `Floats` out of a binding context
    +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level),
    +we consult the cached `FloatInfo` of the `Floats`:
    +
    +  * If we want to float to the top-level (`x = <>; ...`), we check whether
    +    we may float-at-least-as-far-as `TopLvlFloatable`, in which case we
    +    respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`.
    +  * If we want to float locally (let or app), then the floating decision is
    +    described in Note [wantFloatLocal].
    +
    +`executeFloatDecision` is then used to act on the particular `FloatDecision`.
     -}
     
    +-- See Note [BindInfo and FloatInfo]
    +data BindInfo
    +  = CaseBound -- ^ A strict binding
    +  | LetBound  -- ^ A lazy or value binding
    +  deriving Eq
    +
    +-- See Note [BindInfo and FloatInfo]
    +data FloatInfo
    +  = TopLvlFloatable
    +  -- ^ Anything that can be bound at top-level, such as arbitrary lifted
    +  -- bindings or anything that responds True to `exprIsHNF`, such as literals or
    +  -- saturated DataCon apps where unlifted or strict args are values.
    +
    +  | LazyContextFloatable
    +  -- ^ Anything that can be floated out of a lazy context.
    +  -- In addition to any 'TopLvlFloatable' things, this includes (unlifted)
    +  -- bindings that are ok-for-spec that we intend to case-bind.
    +
    +  | StrictContextFloatable
    +  -- ^ Anything that can be floated out of a strict evaluation context.
    +  -- That is possible for all bindings; this is the Top element of 'FloatInfo'.
    +
    +  deriving Eq
    +
    +instance Outputable BindInfo where
    +  ppr CaseBound = text "Case"
    +  ppr LetBound  = text "Let"
    +
    +instance Outputable FloatInfo where
    +  ppr TopLvlFloatable = text "top-lvl"
    +  ppr LazyContextFloatable = text "lzy-ctx"
    +  ppr StrictContextFloatable = text "str-ctx"
    +
    +-- See Note [Floating in CorePrep]
    +-- and Note [BindInfo and FloatInfo]
     data FloatingBind
    -  -- | Rhs of bindings are CpeRhss
    -  -- They are always of lifted type;
    -  -- unlifted ones are done with FloatCase
    -  = FloatLet CoreBind
    -
    -  -- | Float a literal string binding.
    -  -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`.
    -  --            It's just more convenient to keep around the expr rather than
    -  --            the wrapped `bs` and reallocate the expr.
    -  -- This is a special case of `FloatCase` that is unconditionally ok-for-spec.
    -  -- We want to float out strings quite aggressively out of RHSs if doing so
    -  -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1)
    -  -- in Note [ANF-ising literal string arguments].
    -  | FloatString !CoreExpr !Id
    -
    -  | FloatCase
    -       CpeBody         -- ^ Scrutinee
    -       Id              -- ^ Case binder
    -       AltCon [Var]    -- ^ Single alternative
    -       Bool            -- ^ Ok-for-speculation; False of a strict,
    -                       --   but lifted binding that is not OK for
    -                       --   Note [Speculative evaluation].
    -
    -  -- | See Note [Floating Ticks in CorePrep]
    +  = Float !CoreBind !BindInfo !FloatInfo
    +  | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr]
       | FloatTick CoreTickish
     
    -data Floats = Floats OkToSpec (OrdList FloatingBind)
    +-- See Note [Floats and FloatDecision]
    +data Floats
    +  = Floats
    +  { fs_info  :: !FloatInfo
    +  , fs_binds :: !(OrdList FloatingBind)
    +  }
     
     instance Outputable FloatingBind where
    -  ppr (FloatLet b) = ppr b
    -  ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e)
    -  ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r
    +  ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b
    +  ppr (FloatTick t) = ppr t
    +  ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut
                                     <+> text "of"<+> ppr b <> text "@"
                                     <> case bs of
                                        [] -> ppr k
                                        _  -> parens (ppr k <+> ppr bs)
    -  ppr (FloatTick t) = ppr t
     
     instance Outputable Floats where
    -  ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+>
    -                         braces (vcat (map ppr (fromOL fs)))
    -
    -instance Outputable OkToSpec where
    -  ppr OkToSpec    = text "OkToSpec"
    -  ppr IfUnliftedOk = text "IfUnliftedOk"
    -  ppr NotOkToSpec = text "NotOkToSpec"
    -
    --- Can we float these binds out of the rhs of a let?  We cache this decision
    --- to avoid having to recompute it in a non-linear way when there are
    --- deeply nested lets.
    -data OkToSpec
    -   = OkToSpec           -- ^ Lazy bindings of lifted type. Float as you please
    -   | IfUnliftedOk       -- ^ A mixture of lazy lifted bindings and n
    -                        -- ok-to-speculate unlifted bindings.
    -                        -- Float out of lets, but not to top-level!
    -   | NotOkToSpec        -- ^ Some not-ok-to-speculate unlifted bindings
    -
    -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind
    -mkFloat env dmd is_unlifted bndr rhs
    -  | Lit LitString{} <- rhs = FloatString rhs bndr
    -
    -  | is_strict || ok_for_spec
    -  , not is_hnf             = FloatCase rhs bndr DEFAULT [] ok_for_spec
    -      -- See Note [Speculative evaluation]
    -      -- Don't make a case for a HNF binding, even if it's strict
    -      -- Otherwise we get  case (\x -> e) of ...!
    -
    -  | is_unlifted            = FloatCase rhs bndr DEFAULT [] True
    -      -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled
    -      -- because exprOkForSpeculation isn't stable under ANF-ing. See for
    -      -- example #19489 where the following unlifted expression:
    -      --
    -      --    GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0]
    -      --                    (GHC.Types.: @a_ax0 a2_agq a3_agl)
    -      --
    -      -- is ok-for-spec but is ANF-ised into:
    -      --
    -      --    let sat = GHC.Types.: @a_ax0 a2_agq a3_agl
    -      --    in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat
    -      --
    -      -- which isn't ok-for-spec because of the let-expression.
    -
    -  | is_hnf                 = FloatLet (NonRec bndr                       rhs)
    -  | otherwise              = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs)
    -                   -- See Note [Pin demand info on floats]
    -  where
    -    is_hnf      = exprIsHNF rhs
    -    is_strict   = isStrUsedDmd dmd
    -    ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs
    -    is_rec_call = (`elemUnVarSet` cpe_rec_ids env)
    +  ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds)
    +
    +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo
    +lubFloatInfo StrictContextFloatable _                      = StrictContextFloatable
    +lubFloatInfo _                      StrictContextFloatable = StrictContextFloatable
    +lubFloatInfo LazyContextFloatable   _                      = LazyContextFloatable
    +lubFloatInfo _                      LazyContextFloatable   = LazyContextFloatable
    +lubFloatInfo TopLvlFloatable        TopLvlFloatable        = TopLvlFloatable
    +
    +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool
    +-- See Note [Floats and FloatDecision]
    +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r
     
     emptyFloats :: Floats
    -emptyFloats = Floats OkToSpec nilOL
    +emptyFloats = Floats TopLvlFloatable nilOL
     
     isEmptyFloats :: Floats -> Bool
    -isEmptyFloats (Floats _ bs) = isNilOL bs
    +isEmptyFloats (Floats _ b) = isNilOL b
     
    -wrapBinds :: Floats -> CpeBody -> CpeBody
    -wrapBinds (Floats _ binds) body
    -  = foldrOL mk_bind body binds
    -  where
    -    mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body]
    -    mk_bind (FloatString rhs bndr)        body = Case rhs bndr (exprType body) [Alt DEFAULT [] body]
    -    mk_bind (FloatLet bind)               body = Let bind body
    -    mk_bind (FloatTick tickish)           body = mkTick tickish body
    -
    -addFloat :: Floats -> FloatingBind -> Floats
    -addFloat (Floats ok_to_spec floats) new_float
    -  = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float)
    -  where
    -    check FloatLet {}   = OkToSpec
    -    check FloatTick{}   = OkToSpec
    -    check FloatString{} = OkToSpec
    -    check (FloatCase _ _ _ _ ok_for_spec)
    -      | ok_for_spec     = IfUnliftedOk
    -      | otherwise       = NotOkToSpec
    -        -- The ok-for-speculation flag says that it's safe to
    -        -- float this Case out of a let, and thereby do it more eagerly
    -        -- We need the IfUnliftedOk flag because it's never ok to float
    -        -- an unlifted binding to the top level.
    -        -- There is one exception: String literals! But those will become
    -        -- FloatString and thus OkToSpec.
    -        -- See Note [ANF-ising literal string arguments]
    +getFloats :: Floats -> OrdList FloatingBind
    +getFloats = fs_binds
     
     unitFloat :: FloatingBind -> Floats
    -unitFloat = addFloat emptyFloats
    -
    -appendFloats :: Floats -> Floats -> Floats
    -appendFloats (Floats spec1 floats1) (Floats spec2 floats2)
    -  = Floats (combine spec1 spec2) (floats1 `appOL` floats2)
    -
    -concatFloats :: [Floats] -> OrdList FloatingBind
    -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL
    -
    -combine :: OkToSpec -> OkToSpec -> OkToSpec
    -combine NotOkToSpec _  = NotOkToSpec
    -combine _ NotOkToSpec  = NotOkToSpec
    -combine IfUnliftedOk _ = IfUnliftedOk
    -combine _ IfUnliftedOk = IfUnliftedOk
    -combine _ _            = OkToSpec
    +unitFloat = snocFloat emptyFloats
    +
    +floatInfo :: FloatingBind -> FloatInfo
    +floatInfo (Float _ _ info)     = info
    +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep]
    +floatInfo FloatTick{}          = TopLvlFloatable      -- We filter these out in cpePair,
    +                                                      -- see Note [Floating Ticks in CorePrep]
    +
    +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any
    +-- binding of the 'Floats'.
    +snocFloat :: Floats -> FloatingBind -> Floats
    +snocFloat floats fb =
    +  Floats { fs_info  = lubFloatInfo (fs_info floats) (floatInfo fb)
    +         , fs_binds = fs_binds floats `snocOL` fb }
    +
    +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over
    +-- `b`.
    +consFloat :: FloatingBind -> Floats -> Floats
    +consFloat fb floats =
    +  Floats { fs_info  = lubFloatInfo (fs_info floats) (floatInfo fb)
    +         , fs_binds = fb `consOL`  fs_binds floats }
    +
    +-- | Append two telescopes, nesting the right inside the left.
    +appFloats :: Floats -> Floats -> Floats
    +appFloats outer inner =
    +  Floats { fs_info  = lubFloatInfo (fs_info outer) (fs_info inner)
    +         , fs_binds = fs_binds outer `appOL` fs_binds inner }
    +
    +-- | Zip up two `Floats`, none of which scope over the other
    +zipFloats :: Floats -> Floats -> Floats
    +-- We may certainly just nest one telescope in the other, so appFloats is a
    +-- valid implementation strategy.
    +zipFloats = appFloats
    +
    +-- | `zipFloats` a bunch of independent telescopes.
    +zipManyFloats :: [Floats] -> Floats
    +zipManyFloats = foldr zipFloats emptyFloats
    +
    +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind
    +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $
    +  Float (NonRec bndr' rhs) bound info
    +  where
    +    bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats]
    +    (bound,info)
    +      | is_lifted, is_hnf        = (LetBound, TopLvlFloatable)
    +          -- is_lifted: We currently don't allow unlifted values at the
    +          --            top-level or inside letrecs
    +          --            (but SG thinks that in principle, we should)
    +      | is_data_con bndr         = (LetBound, TopLvlFloatable)
    +          -- We need this special case for unlifted DataCon workers/wrappers
    +          -- until #17521 is fixed
    +      | exprIsTickedString rhs   = (CaseBound, TopLvlFloatable)
    +          -- String literals are unboxed (so must be case-bound) and float to
    +          -- the top-level
    +      | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable)
    +      | is_lifted,   ok_for_spec = (CaseBound, TopLvlFloatable)
    +          -- See Note [Speculative evaluation]
    +          -- Ok-for-spec-eval things will be case-bound, lifted or not.
    +          -- But when it's lifted we are ok with floating it to top-level
    +          -- (where it is actually bound lazily).
    +      | is_unlifted || is_strict = (CaseBound, StrictContextFloatable)
    +          -- These will never be floated out of a lazy RHS context
    +      | otherwise                = assertPpr is_lifted (ppr rhs) $
    +                                   (LetBound, TopLvlFloatable)
    +          -- And these float freely but can't be speculated, hence LetBound
    +
    +    is_lifted   = not is_unlifted
    +    is_hnf      = exprIsHNF rhs
    +    is_strict   = isStrUsedDmd dmd
    +    ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs
    +    is_rec_call = (`elemUnVarSet` cpe_rec_ids env)
    +    is_data_con = isJust . isDataConId_maybe
     
    +-- | Wrap floats around an expression
    +wrapBinds :: Floats -> CpeBody -> CpeBody
    +wrapBinds floats body
    +  = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $
    +    foldrOL mk_bind body (getFloats floats)
    +  where
    +    -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here
    +    mk_bind f@(Float bind CaseBound _) body
    +      | NonRec bndr rhs <- bind
    +      = mkDefaultCase rhs bndr body
    +      | otherwise
    +      = pprPanic "wrapBinds" (ppr f)
    +    mk_bind (Float bind _ _) body
    +      = Let bind body
    +    mk_bind (UnsafeEqualityCase scrut b con bs) body
    +      = mkSingleAltCase scrut b con bs body
    +    mk_bind (FloatTick tickish) body
    +      = mkTick tickish body
    +
    +-- | Put floats at top-level
     deFloatTop :: Floats -> [CoreBind]
    --- For top level only; we don't expect any FloatCases
    -deFloatTop (Floats _ floats)
    -  = foldrOL get [] floats
    +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks!
    +deFloatTop floats
    +  = foldrOL get [] (getFloats floats)
       where
    -    get (FloatLet b)               bs = get_bind b                 : bs
    -    get (FloatString body var)     bs = get_bind (NonRec var body) : bs
    -    get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs
    -    get b _ = pprPanic "corePrepPgm" (ppr b)
    +    get (Float b _ TopLvlFloatable) bs
    +      = get_bind b : bs
    +    get b _  = pprPanic "corePrepPgm" (ppr b)
     
         -- See Note [Dead code in CorePrep]
         get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e)
    @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats)
     
     ---------------------------------------------------------------------------
     
    -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool
    -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs
    -  =  isEmptyFloats floats
    -  || isStrUsedDmd dmd
    -  || rhs_is_unlifted
    -  || (allLazyNested is_rec floats && exprIsHNF rhs)
    -        -- Why the test for allLazyNested?
    -        --      v = f (x `divInt#` y)
    -        -- we don't want to float the case, even if f has arity 2,
    -        -- because floating the case would make it evaluated too early
    -
    -allLazyTop :: Floats -> Bool
    -allLazyTop (Floats OkToSpec _) = True
    -allLazyTop _                   = False
    -
    -allLazyNested :: RecFlag -> Floats -> Bool
    -allLazyNested _      (Floats OkToSpec    _)  = True
    -allLazyNested _      (Floats NotOkToSpec _)  = False
    -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec
    +{- Note [wantFloatLocal]
    +~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider
    +  let x = let y = e1 in e2
    +  in e
    +Similarly for `(\x. e) (let y = e1 in e2)`.
    +Do we want to float out `y` out of `x`?
    +(This is discussed in detail in the paper
    +"Let-floating: moving bindings to give faster programs".)
    +
    +`wantFloatLocal` is concerned with answering this question.
    +It considers the Demand on `x`, whether or not `e2` is unlifted and the
    +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value,
    +strict, or ok-for-spec).
    +
    +We float out if ...
    +  1. ... the binding context is strict anyway, so either `x` is used strictly
    +     or has unlifted type.
    +     Doing so is trivially sound and won`t increase allocations, so we
    +     return `FloatAll`.
    +     This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict:
    +       f (g (h 13))
    +       ==> { ANF }
    +       case (case h 13 of r -> g r) of r2 -> f r2
    +       ==> { Float }
    +       case h 13 of r -> case g r of r2 -> f r2
    +     The latter is easier to read and grows less stack.
    +  2. ... `e2` becomes a value in doing so, in which case we won't need to
    +     allocate a thunk for `x`/the arg that closes over the FVs of `e1`.
    +     In general, this is only sound if `y=e1` is `LazyContextFloatable`.
    +     (See Note [BindInfo and FloatInfo].)
    +     Nothing is won if `x` doesn't become a value
    +     (i.e., `let x = let sat = f 14 in g sat in e`),
    +     so we return `FloatNone` if there is any float that is
    +     `StrictContextFloatable`, and return `FloatAll` otherwise.
    +
    +To elaborate on (2), consider the case when the floated binding is
    +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`:
    +  let x = I# (a `divInt#` b)
    +  in e
    +this ANFises to
    +  let x = case a `divInt#` b of r { __DEFAULT -> I# r }
    +  in e
    +If `x` is used lazily, we may not float `r` further out.
    +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval
    +binding is `LazyContextFloatable`.
    +
    +Wrinkles:
    +
    + (W1) When the outer binding is a letrec, i.e.,
    +        letrec x = case a +# b of r { __DEFAULT -> f y r }
    +               y = [x]
    +        in e
    +      we don't want to float `LazyContextFloatable` bindings such as `r` either
    +      and require `TopLvlFloatable` instead.
    +      The reason is that we don't track FV of FloatBindings, so we would need
    +      to park them in the letrec,
    +        letrec r = a +# b -- NB: r`s RHS might scope over x and y
    +               x = f y r
    +               y = [x]
    +        in e
    +      and now we have violated Note [Core letrec invariant].
    +      So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless
    +      all floats are `TopLvlFloatable`.
    +-}
    +
    +data FloatDecision
    +  = FloatNone
    +  | FloatAll
    +
    +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs)
    +executeFloatDecision dec floats rhs = do
    +  let (float,stay) = case dec of
    +        _ | isEmptyFloats floats -> (emptyFloats,emptyFloats)
    +        FloatNone                -> (emptyFloats, floats)
    +        FloatAll                 -> (floats, emptyFloats)
    +  -- Wrap `stay` around `rhs`.
    +  -- NB: `rhs` might have lambdas, and we can't
    +  --     put them inside a wrapBinds, which expects a `CpeBody`.
    +  if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody`
    +    then return (float, rhs)
    +    else do
    +      (floats', body) <- rhsToBody rhs
    +      return (float, wrapBinds stay $ wrapBinds floats' body)
    +
    +wantFloatTop :: Floats -> FloatDecision
    +wantFloatTop fs
    +  | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll
    +  | otherwise                                         = FloatNone
    +
    +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision
    +-- See Note [wantFloatLocal]
    +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs
    +  |  isEmptyFloats floats -- Well yeah...
    +  || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal]
    +  || rhs_is_unlifted      -- dito
    +  || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs)
    +                          -- Case (2) of Note [wantFloatLocal]
    +  = FloatAll
    +
    +  | otherwise
    +  = FloatNone
    +  where
    +    max_float_info | isRec is_rec = TopLvlFloatable
    +                   | otherwise    = LazyContextFloatable
    +                    -- See Note [wantFloatLocal], Wrinkle (W1)
    +                    -- for 'is_rec'
     
     {-
     ************************************************************************
    @@ -2224,26 +2406,28 @@ newVar ty
     
     -- | Like wrapFloats, but only wraps tick floats
     wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr)
    -wrapTicks (Floats flag floats0) expr =
    -    (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1))
    -  where (floats1, ticks1) = foldlOL go ([], []) $ floats0
    +wrapTicks floats expr
    +  | (floats1, ticks1) <- fold_fun go floats
    +  = (floats1, foldrOL mkTick expr ticks1)
    +  where fold_fun f floats =
    +           let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats)
    +           in (floats { fs_binds = binds }, ticks)
             -- Deeply nested constructors will produce long lists of
             -- redundant source note floats here. We need to eliminate
             -- those early, as relying on mkTick to spot it after the fact
             -- can yield O(n^3) complexity [#11095]
    -        go (floats, ticks) (FloatTick t)
    +        go (flt_binds, ticks) (FloatTick t)
               = assert (tickishPlace t == PlaceNonLam)
    -            (floats, if any (flip tickishContains t) ticks
    -                     then ticks else t:ticks)
    -        go (floats, ticks) f at FloatString{}
    -          = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute.
    -        go (floats, ticks) f
    -          = (foldr wrap f (reverse ticks):floats, ticks)
    -
    -        wrap t (FloatLet bind)           = FloatLet (wrapBind t bind)
    -        wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok
    -        wrap _ other                     = pprPanic "wrapTicks: unexpected float!"
    -                                             (ppr other)
    +            (flt_binds, if any (flip tickishContains t) ticks
    +                        then ticks else ticks `snocOL` t)
    +        go (flt_binds, ticks) f at UnsafeEqualityCase{}
    +          -- unsafe equality case will be erased; don't wrap anything!
    +          = (flt_binds `snocOL` f, ticks)
    +        go (flt_binds, ticks) f at Float{}
    +          = (flt_binds `snocOL` foldrOL wrap f ticks, ticks)
    +
    +        wrap t (Float bind bound info) = Float (wrapBind t bind) bound info
    +        wrap _ f                 = pprPanic "Unexpected FloatingBind" (ppr f)
             wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs)
             wrapBind t (Rec pairs)         = Rec (mapSnd (mkTick t) pairs)
     
    
    
    =====================================
    compiler/GHC/Data/OrdList.hs
    =====================================
    @@ -16,8 +16,8 @@ module GHC.Data.OrdList (
             OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL,
             nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL,
             headOL,
    -        mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse,
    -        strictlyEqOL, strictlyOrdOL
    +        mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL,
    +        partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL
     ) where
     
     import GHC.Prelude
    @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x
     foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2
     foldlOL k z (Many xs)   = foldl' k z xs
     
    +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a)
    +partitionOL _ None = (None,None)
    +partitionOL f (One x)
    +  | f x       = (One x, None)
    +  | otherwise = (None, One x)
    +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2)
    +  where !(!ls1,!rs1) = partitionOL f xs
    +        !(!ls2,!rs2) = partitionOL f ys
    +partitionOL f (Cons x xs)
    +  | f x       = (Cons x ls, rs)
    +  | otherwise = (ls, Cons x rs)
    +  where !(!ls,!rs) = partitionOL f xs
    +partitionOL f (Snoc xs x)
    +  | f x       = (Snoc ls x, rs)
    +  | otherwise = (ls, Snoc rs x)
    +  where !(!ls,!rs) = partitionOL f xs
    +partitionOL f (Many xs) = (toOL ls, toOL rs)
    +  where !(!ls,!rs) = NE.partition f xs
    +
     toOL :: [a] -> OrdList a
     toOL [] = None
     toOL [x] = One x
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59dee186ef34d7b3b3f5a9d869252d5af20dd2fd
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59dee186ef34d7b3b3f5a9d869252d5af20dd2fd
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 11:28:37 2023
    From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott))
    Date: Fri, 13 Oct 2023 07:28:37 -0400
    Subject: [Git][ghc/ghc][wip/T22141] 137 commits: base: Advertise linear time
     of readFloat
    Message-ID: <652929e5662b5_24a44525bef5a8270429@gitlab.mail>
    
    
    
    Ryan Scott pushed to branch wip/T22141 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00
    base: Advertise linear time of readFloat
    
    As noted in #23538, `readFloat` has runtime that scales nonlinearly in
    the size of its input. Consequently, its use on untrusted input can
    be exploited as a denial-of-service vector. Point this out and suggest
    use of `read` instead.
    
    See #23538.
    
    - - - - -
    f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00
    Remove dead code GHC.CoreToStg.Prep.canFloat
    
    This function never fires, so we can delete it: #23965.
    
    - - - - -
    ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00
    base/changelog: Move fix for #23907 to 9.8.1 section
    
    Since the fix was backported to 9.8.1
    
    - - - - -
    51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00
    Add aarch64 alpine bindist
    
    This is dynamically linked and makes creating statically linked
    executables more straightforward.
    
    Fixes #23482
    
    - - - - -
    02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00
    Add aarch64-deb11 bindist
    
    This adds a debian 11 release job for aarch64.
    
    Fixes #22005
    
    - - - - -
    8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00
    Don’t store the async exception masking state in CATCH frames
    
    - - - - -
    86d2971e by doyougnu at 2023-09-19T19:08:19-04:00
    compiler,ghci: error codes link to HF error index
    
    closes: #23259
    
    - adds -fprint-error-index-links={auto|always|never} flag
    
    - - - - -
    5f826c18 by sheaf at 2023-09-19T19:09:03-04:00
    Pass quantified tyvars in tcDefaultAssocDecl
    
    This commit passes the correct set of quantified type variables written
    by the user in associated type default declarations for validity
    checking. This ensures that validity checking of associated type defaults
    mirrors that of standalone type family instances.
    
    Fixes #23768 (see testcase T23734 in subsequent commit)
    
    - - - - -
    aba18424 by sheaf at 2023-09-19T19:09:03-04:00
    Avoid panic in mkGADTVars
    
    This commit avoids panicking in mkGADTVars when we encounter
    a type variable as in #23784 that is bound by a user-written
    forall but not actually used.
    
    Fixes #23784
    
    - - - - -
    a525a92a by sheaf at 2023-09-19T19:09:03-04:00
    Adjust reporting of unused tyvars in data FamInsts
    
    This commit adjusts the validity checking of data family
    instances to improve the reporting of unused type variables.
    
    See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity.
    
    The problem was that, in a situation such as
    
      data family D :: Type
      data instance forall (d :: Type). D = MkD
    
    the RHS passed to 'checkFamPatBinders' would be the TyCon app
    
      R:D d
    
    which mentions the type variable 'd' quantified in the user-written
    forall. Thus, when computing the set of unused type variables in
    the RHS of the data family instance, we would find that 'd' is used,
    and report a strange error message that would say that 'd' is not
    bound on the LHS.
    
    To fix this, we special-case the data-family instance case,
    manually extracting all the type variables that appear in the
    arguments of all the data constructores of the data family instance.
    
    Fixes #23778
    
    - - - - -
    28dd52ee by sheaf at 2023-09-19T19:09:03-04:00
    Unused tyvars in FamInst: only report user tyvars
    
    This commit changes how we perform some validity checking for
    coercion axioms to mirror how we handle default declarations for
    associated type families. This allows us to keep track of whether
    type variables in type and data family instances were user-written
    or not, in order to only report the user-written ones in
    "unused type variable" error messages.
    
    Consider for example:
    
      {-# LANGUAGE PolyKinds #-}
      type family F
      type instance forall a. F = ()
    
    In this case, we get two quantified type variables,
    (k :: Type) and (a :: k); the second being user-written, but the first
    is introduced by the typechecker. We should only report 'a' as being
    unused, as the user has no idea what 'k' is.
    
    Fixes #23734
    
    - - - - -
    1eed645c by sheaf at 2023-09-19T19:09:03-04:00
    Validity: refactor treatment of data families
    
    This commit refactors the reporting of unused type variables in type
    and data family instances to be more principled. This avoids ad-hoc
    logic in the treatment of data family instances.
    
    - - - - -
    35bc506b by John Ericson at 2023-09-19T19:09:40-04:00
    Remove `ghc-cabal`
    
    It is dead code since the Make build system was removed.
    
    I tried to go over every match of `git grep -i ghc-cabal` to find other
    stray bits. Some of those might be workarounds that can be further
    removed.
    
    - - - - -
    665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00
    Re-add unregisterised build support for sparc and sparc64
    
    Closes #23959
    
    - - - - -
    142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00
    Bump ci-images to use updated version of Alex
    
    Fixes #23977
    
    - - - - -
    fa977034 by John Ericson at 2023-09-21T12:55:25-04:00
    Use Cabal 3.10 for Hadrian
    
    We need the newer version for `CABAL_FLAG_*` env vars for #17191.
    
    - - - - -
    a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: `need` any `configure` script we will call
    
    When the script is changed, we should reconfigure.
    
    - - - - -
    db882b57 by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: Make it easier to debug Cabal configure
    
    Right now, output is squashed. This make per-package configure scripts
    extremely hard to maintain, because we get vague "library is missing"
    errors when the actually probably is usually completely unrelated except
    for also involving the C/C++ toolchain.
    
    (I can always pass `-VVV` to Hadrian locally, but these errors are
    subtle and I often cannot reproduce them locally!)
    
    `--disable-option-checking` was added back in
    75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill;
    if other flags are passed that are not recognized behind the two from
    Cabal mentioned in the former comment, we *do* want to know about it.
    
    - - - - -
    7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: Increase verbosity of certain cabal commands
    
    This is a hack to get around the cabal function we're calling
    *decreasing* the verbosity it passes to another function, which is the
    stuff we often actually care about. Sigh.
    
    Keeping this a separate commit so if this makes things too verbose it is
    easy to revert.
    
    - - - - -
    a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00
    rts: Move most external symbols logic to the configure script
    
    This is much more terse because we are programmatically handling the
    leading underscore.
    
    `findPtr` however is still handled in the Cabal file because we need a
    newer Cabal to pass flags to the configure script automatically.
    
    Co-Authored-By: Ben Gamari <ben at well-typed.com>
    
    - - - - -
    56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00
    Bump Cabal submodule to allow text-2.1 and bytestring-0.12
    
    - - - - -
    0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00
    hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist
    
    - - - - -
    b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00
    Bump hadrian's index-state to upgrade alex at least to 3.2.7.3
    
    - - - - -
    11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00
    JS: correct file size and times
    
    Programs produced by the JavaScript backend were returning
    incorrect file sizes and modification times, causing cabal
    related tests to fail.
    
    This fixes the problem and adds an additional test that verifies
    basic file information operations.
    
    fixes #23980
    
    - - - - -
    b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00
    gitlab-ci: Drop libiserv from upload_ghc_libs
    
    libiserv has been merged into the ghci package.
    
    - - - - -
    37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00
    testsuite: Fix Windows line endings
    
    - - - - -
    5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00
    testsuite: Use makefile_test
    
    - - - - -
    15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00
    system-cxx-std-lib: Add license and description
    - - - - -
    0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00
    gitlab/issue-templates: Rename bug.md -> default.md
    
    So that it is visible by default.
    
    - - - - -
    23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00
    Bump submodule text to 2.1
    
    - - - - -
    b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00
    Bump submodule unix to 2.8.2.1
    
    - - - - -
    54b2016e by John Ericson at 2023-09-23T11:40:41-04:00
    Move lib{numa,dw} defines to RTS configure
    
    Clean up the m4 to handle the auto case always and be more consistent.
    Also simplify the CPP --- we should always have both headers if we are
    using libnuma.
    
    "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to
    better separate searching from actions taken based on search results.
    This might seem overkill now, but will make shuffling logic between
    configure scripts easier later.
    
    The macro comments are converted from `dnl` to `#` following the
    recomendation in
    https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html
    
    - - - - -
    d51b601b by John Ericson at 2023-09-23T11:40:50-04:00
    Shuffle libzstd configuring between scripts
    
    Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS
    configure, `AC_SUBST` goes to the top-level configure script, and the
    documentation of the m4 macro is improved.
    
    - - - - -
    d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00
    Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure
    
    It is just `AC_DEFINE` it belongs there instead.
    
    - - - - -
    18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00
    Move mmap in the runtime linker check to the RTS configure
    
    `AC_DEFINE` should go there instead.
    
    - - - - -
    74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00
    Elaborate comment on GHC_NO_UNICODE
    
    - - - - -
    de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00
    gitlab-ci: Mark T22012 as broken on CentOS 7
    
    Due to #23979.
    
    - - - - -
    6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00
    hadrian: better error for failing to find file's dependencies
    
    Resolves #24004
    
    - - - - -
    d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Refactor uses of `partitionEithers . map`
    
    This patch changes occurences of the idiom
    `partitionEithers (map f xs)` by the simpler form
    `partitionWith f xs` where `partitionWith` is the utility function
    defined in `GHC.Utils.Misc`.
    
    Resolves: #23953
    
    - - - - -
    8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Refactor uses of `partitionEithers <$> mapM f xs`
    
    This patch changes occurences of the idiom
    `partitionEithers <$> mapM f xs` by the simpler form
    `partitionWithM f xs` where `partitionWithM` is a utility function
    newly added to `GHC.Utils.Misc`.
    
    - - - - -
    6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Mark `GHC.Utils.Misc.partitionWithM` as inlineable
    
    This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure
    that the right-hand side of the definition of this function remains
    available for specialisation at call sites.
    
    - - - - -
    f1e5245a by David Binder at 2023-09-27T01:19:00-04:00
    Add RTS option to supress tix file
    
    - - - - -
    1f43124f by David Binder at 2023-09-27T01:19:00-04:00
    Add expected output to testsuite in test interface-stability/base-exports
    
    - - - - -
    b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00
    Expose HpcFlags and getHpcFlags from GHC.RTS.Flags
    
    - - - - -
    345675c6 by David Binder at 2023-09-27T01:19:00-04:00
    Fix expected output of interface-stability test
    
    - - - - -
    146e1c39 by David Binder at 2023-09-27T01:19:00-04:00
    Implement getHpcFlags
    
    - - - - -
    61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00
    Add section in user guide
    
    - - - - -
    ea05f890 by David Binder at 2023-09-27T01:19:01-04:00
    Rename --emit-tix-file to --write-tix-file
    
    - - - - -
    cabce2ce by David Binder at 2023-09-27T01:19:01-04:00
    Update the golden files for interface stability
    
    - - - - -
    1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00
    Refactor: introduce stgArgRep
    
    The function 'stgArgType' returns the type in STG. But this violates
    the abstraction: in STG we're supposed to operate on PrimReps.
    
    This introduces
    stgArgRep ty = typePrimRep (stgArgType ty)
    stgArgRep1 ty = typePrimRep1 (stgArgType ty)
    stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty)
    
    stgArgType is still directly used for unboxed tuples (should be fixable), FFI
    and in ticky.
    
    - - - - -
    b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00
    Fix TH pretty-printer's parenthesization
    
    This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed.
    
    Fixes #23962, #23968, #23971, and #23986
    
    - - - - -
    79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00
    Add a testcase for #17564
    
    The code in the ticket relied on the behaviour of Derived constraints.
    Derived constraints were removed in GHC 9.4 and now the code works
    as expected.
    
    - - - - -
    d7a80143 by sheaf at 2023-09-28T03:25:53-04:00
    lint-codes: add new modes of operation
    
    This commit adds two new modes of operation to the lint-codes
    utility:
    
      list - list all statically used diagnostic codes
      outdated - list all outdated diagnostic codes
    
    The previous behaviour is now:
    
      test - test consistency and coverage of diagnostic codes
    
    - - - - -
    477d223c by sheaf at 2023-09-28T03:25:53-04:00
    lint codes: avoid using git-grep
    
    We manually traverse through the filesystem to find the diagnostic codes
    embedded in .stdout and .stderr files, to avoid any issues with old
    versions of grep.
    
    Fixes #23843
    
    - - - - -
    a38ae69a by sheaf at 2023-09-28T03:25:53-04:00
    lint-codes: add Hadrian targets
    
    This commit adds new Hadrian targets:
    
      codes, codes:used - list all used diagnostic codes
      codes:outdated - list outdated diagnostic codes
    
    This allows users to easily query GHC for used and outdated
    diagnostic codes, e.g.
    
      hadrian/build -j --flavour=<..> codes
    
    will list all used diagnostic codes in the command line by running
    the lint-codes utility in the "list codes" mode of operation.
    
    The diagnostic code consistency and coverage test is still run as usual,
    through the testsuite:
    
      hadrian/build test --only="codes"
    
    - - - - -
    9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00
    hadrian: Install LICENSE files in bindists
    
    Fixes #23548.
    
    - - - - -
    b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00
    Fix visibility when eta-reducing a type lambda
    
    Fixes #24014.
    
    - - - - -
    d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00
    Fix several mistakes around free variables in iface breakpoints
    
    Fixes #23612 , #23607, #23998 and #23666.
    
    MR: !11026
    
    The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons:
    
    * IfaceBreakpoint created binders for free variables instead of expressions
    
    * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped
    
    - - - - -
    ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00
    Refactor to combine HsLam and HsLamCase
    
    This MR is pure refactoring (#23916):
    * Combine `HsLam` and `HsLamCase`
    * Combine `HsCmdLam` and `HsCmdLamCase`
    
    This just arranges to treat uniformly
       \x -> e
       \case pi -> ei
       \cases pis -> ie
    
    In the exising code base the first is treated differently
    to the latter two.
    
    No change in behaviour.
    
    More specifics:
    
    * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering
      * Lambda
      * `\case`
      * `\cases`
    
    * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases.
    
    * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one.
    
    * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.)
    
    * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument.
    
    * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument.
    
    * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
    
    * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
    
    * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one.
    
    * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one.
    
    p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one.
    
    Phew!
    
    - - - - -
    b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
    Arm: Make ppr methods easier to use by not requiring NCGConfig
    
    - - - - -
    2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
    AArch64: Fix broken conditional jumps for offsets >= 1MB
    
    Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps
    to avoid overflowing the immediate.
    
    Fixes #23746
    
    - - - - -
    1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00
    EPA: Replace Monoid with NoAnn
    
    We currently use the Monoid class as a constraint on Exact Print
    Annotation functions, so we can use mempty. But this leads to
    requiring Semigroup instances too, which do not always make sense.
    
    Instead, introduce a class NoAnn, with a function noAnn analogous to
    mempty.
    
    Closes #20372
    
    Updates haddock submodule
    
    - - - - -
    c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00
    users-guide: Refactor handling of :base-ref: et al.
    
    - - - - -
    bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00
    Simplify and correct nasty case in coercion opt
    
    This fixes #21062.
    
    No test case, because triggering this code seems challenging.
    
    - - - - -
    9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Bump bytestring submodule to 0.12.0.2
    
    - - - - -
    4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Inline bucket_match
    
    - - - - -
    f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00
    configure: Fix #21712 again
    
    This is a bit of a shot in the dark to fix #24033, which appears to be
    another instance of #21712. For some reason the ld-override logic
    *still* appears to be active on Darwin targets (or at least one).
    Consequently, on misconfigured systems we may choose a non-`ld64`
    linker.
    
    It's a bit unclear exactly what happened in #24033 but ultimately the
    check added for #21712 was not quite right, checking for the
    `ghc_host_os` (the value of which depends upon the bootstrap compiler)
    instead of the target platform. Fix this.
    
    Fixes #24033.
    
    - - - - -
    2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00
    Add a regression test for #24029
    
    - - - - -
    8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00
    Fix non-symbolic children lookup of fixity decl
    
    The fix for #23664 did not correctly account for non-symbolic names
    when looking up children of a given parent. This one-line fix changes
    that.
    
    Fixes #24037
    
    - - - - -
    a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00
    rts: fix incorrect ticket reference
    
    - - - - -
    e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00
    users-guide: Fix discussion of -Wpartial-fields
    
     * fix a few typos
     * add a new example showing when the warning fires
     * clarify the existing example
     * point out -Wincomplete-record-selects
    
    Fixes #24049.
    
    - - - - -
    8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00
    Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"
    
    This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.
    
    `-optP` should pass options to the preprocessor, that might be a very
    different program to the C compiler, so passing the options to the C
    compiler is likely to result in `-optP` being useless.
    
    Fixes #17185 and #21291
    
    - - - - -
    8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00
    rts/nonmoving: Fix on LLP64 platforms
    
    Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL`
    size suffix. However, this is wrong on LLP64 platforms like Windows,
    where `long` is 32-bits.
    
    Fixes #23003.
    Fixes #24042.
    
    - - - - -
    f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00
    Fix isAArch64Bitmask for 32bit immediates.
    
    Fixes #23802
    
    - - - - -
    63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00
    Work around perf note fetch failure
    
    Addresses #24055.
    
    - - - - -
    242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00
    Add a test for #21348
    
    - - - - -
    7d390bce by Rewbert at 2023-10-05T05:38:08-04:00
    Fixes #24046
    
    - - - - -
    69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00
    Ensure unconstrained instance dictionaries get IPE info
    
    In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up
    with an initial source span based on the span of the binder, which was causing
    instance dictionaries without dynamic superclass constraints to not have source
    locations in their IPE info. Now they do.
    
    Resolves #24005
    
    - - - - -
    390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00
    rts: Split up rts/include/stg/MachRegs.h by arch
    
    - - - - -
    3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00
    Actually set hackage index state
    
    Or at least, use a version of the cabal command that *claims* to set the
    index state.
    
    Time will tell.
    
    - - - - -
    46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00
    Update hackage index state
    
    - - - - -
    d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00
    Ensure hadrian uses CI's hackage index state
    
    - - - - -
    e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00
    Do not use O_NONBLOCK on regular files or block devices
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/166
    
    - - - - -
    a06197c4 by David Binder at 2023-10-08T15:06:55-04:00
    Update hpc-bin submodule to 0.69
    
    - - - - -
    ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00
    Update Hadrian with correct path to happy file for hpc-bin
    
    - - - - -
    94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00
    EPA: Introduce HasAnnotation class
    
    The class is defined as
    
        class HasAnnotation e where
          noAnnSrcSpan :: SrcSpan -> e
    
    This generalises noAnnSrcSpan, and allows
    
        noLocA :: (HasAnnotation e) => a -> GenLocated e a
        noLocA = L (noAnnSrcSpan noSrcSpan)
    
    - - - - -
    8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00
    Bump unix submodule to v2.8.3.0
    
    - - - - -
    e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00
    Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.
    
    The motivation for the flag is given in #21917.
    
    - - - - -
    3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Add ghcToolchain to tool args list
    
    This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.
    
    - - - - -
    476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Normalise triple via config.sub
    
    We were not normalising the target triple anymore like we did with the
    old make build system.
    
    Fixes #23856
    
    - - - - -
    303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add missing vendor normalisation
    
    This is copied from m4/ghc_convert_vendor.m4
    
    Towards #23868
    
    - - - - -
    838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add loongarch64 to parseArch
    
    Towards #23868
    
    - - - - -
    1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Add same LD hack to ghc-toolchain
    
    In the ./configure script, if you pass the `LD` variable then this has
    the effect of stopping use searching for a linker and hence passing
    `-fuse-ld=...`.
    
    We want to emulate this logic in ghc-toolchain, if a use explicilty
    specifies `LD` variable then don't add `-fuse-ld=..` with the goal of
    making ./configure and ghc-toolchain agree on which flags to use when
    using the C compiler as a linker.
    
    This is quite unsavoury as we don't bake the choice of LD into the
    configuration anywhere but what's important for now is making
    ghc-toolchain and ./configure agree as much as possible.
    
    See #23857 for more discussion
    
    - - - - -
    42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check for C99 support with -std=c99
    
    Previously we failed to try enabling C99 support with `-std=c99`, as
    `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which
    don't enable C99 by default.
    
    Fixes #23879.
    
    - - - - -
    da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro
    
    In very old toolchains the BYTE_ORDER macro is not set but thankfully
    the __BYTE_ORDER__ macro can be used instead.
    
    - - - - -
    d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: AC_PATH_TARGET_TOOL for LD
    
    We want to make sure that LD is set to an absolute path in order to be
    consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL
    macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which
    might use a relative path.
    
    - - - - -
    171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check whether we need -std=gnu99 for CPP as well
    
    In ./configure the C99 flag is passed to the C compiler when used as a C
    preprocessor. So we also check the same thing in ghc-toolchain.
    
    - - - - -
    89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Check for --target linker flag separately to C compiler
    
    There are situations where the C compiler doesn't accept `--target` but
    when used as a linker it does (but doesn't do anything most likely)
    
    In particular with old gcc toolchains, the C compiler doesn't support
    --target but when used as a linker it does.
    
    - - - - -
    37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Use Cc to compile test file in nopie check
    
    We were attempting to use the C compiler, as a linker, to compile a file
    in the nopie check, but that won't work in general as the flags we pass
    to the linker might not be compatible with the ones we pass when using
    the C compiler.
    
    - - - - -
    9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Error when ghc-toolchain fails to compile
    
    This is a small QOL change as if you are working on ghc-toolchain and it
    fails to compile then configure will continue and can give you outdated
    results.
    
    - - - - -
    1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Check whether -no-pie works when the C compiler is used as a linker
    
    `-no-pie` is a flag we pass when using the C compiler as a linker (see
    pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
    compiler used as a linker supports the flag, rather than just the C
    compiler.
    
    - - - - -
    62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Remove javascript special case for --target detection
    
    emcc when used as a linker seems to ignore the --target flag, and for
    consistency with configure which now tests for --target, we remove this
    special case.
    
    - - - - -
    0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00
    toolchain: Don't pass --target to emscripten toolchain
    
    As noted in `Note [Don't pass --target to emscripten toolchain]`,
    emscripten's `emcc` is rather inconsistent with respect to its treatment
    of the `--target` flag. Avoid this by special-casing this toolchain
    in the `configure` script and `ghc-toolchain`.
    
    Fixes on aspect of #23744.
    
    - - - - -
    6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure
    
    Stop passing -gcc-options which mixed together linker flags and
    non-linker flags. There's no guarantee the C compiler will accept both
    of these in each mode.
    
    - - - - -
    c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00
    configure: Probe stage0 link flags
    
    For consistency with later stages and CC.
    
    - - - - -
    1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00
    Stricter Binary.get in GHC.Types.Unit (#23964)
    
    I noticed some thunking while looking at Core.
    This change has very modest, but throughout positive ghc/alloc effect:
    
    ```
     hard_hole_fits(normal) ghc/alloc    283,057,664    281,620,872  -0.5%
    
                  geo. mean                                          -0.1%
                  minimum                                            -0.5%
                  maximum                                            +0.0%
    ```
    
    Fixes #23964.
    
    - - - - -
    a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00
    rel_eng/upload.sh cleanups
    
    - - - - -
    80705335 by doyougnu at 2023-10-10T19:03:18-04:00
    ci: add javascript label rule
    
    This adds a rule which triggers the javascript job when the "javascript"
    label is assigned to an MR.
    
    - - - - -
    a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00
    Make 'wWarningFlagsDeps' include every WarningFlag
    
    Fixes #24071.
    
    - - - - -
    d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00
    Fix pretty printing of overlap pragmas in TH splices (fixes #24074)
    
    - - - - -
    0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    AArch NCG: Refactor getRegister'
    
    Remove some special cases which can be handled just as well by the
    generic case.
    
    This increases code re-use while also fixing #23749. Since some of the
    special case wasn't upholding Note [Signed arithmetic on AArch64].
    
    - - - - -
    1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over mem management checks
    
    These are for heap allocation, a strictly RTS concern.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    The RTS configure one has a new
    ```
    AC_CHECK_SIZEOF([void *])
    ```
    that the top-level configure version didn't have, so that
    `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
    commits, that can go away.
    
    Progress towards #17191
    
    - - - - -
    41130a65 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `__thread` check
    
    This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over misc function checks
    
    These are for general use in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `eventfd` check
    
    This check is for the RTS part of the event manager and has a
    corresponding part in `base`.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    58f3babf by John Ericson at 2023-10-11T16:02:48-04:00
    Split `FP_CHECK_PTHREADS` and move part to RTS configure
    
    `NEED_PTHREAD_LIB` is unused since
    3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
    system), and so is no longer defined.
    
    Progress towards #17191
    
    - - - - -
    e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00
    nativeGen: section flags for .text$foo only
    
    Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
    #22834 in !9810.
    
    It does however add "xr" indiscriminatly to .text sections
    even if splitSections is disabled. This leads to the assembler saying:
    
    ghc_1.s:7849:0: error:
         Warning: Ignoring changed section attributes for .text
         |
    7849 | .section .text,"xr"
         | ^
    
    - - - - -
    f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00
    Modularity: pass TempDir instead of DynFlags (#17957)
    
    - - - - -
    34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00
    Test that functions from `mingwex` are available
    
    Ryan wrote these two minimizations, but they never got added to the test
    suite.
    
    See #23309, #23378
    
    Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com>
    Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com>
    
    - - - - -
    bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00
    Do not check for the `mingwex` library in `/configure`
    
    See the recent discussion in !10360 --- Cabal will itself check for the
    library for the packages that need it, and while the autoconf check
    additionally does some other things like define a `HAS_LIBMINGWEX` C
    Preprocessor macro, those other things are also unused and unneeded.
    
    Progress towards #17191, which aims to get rid of `/configure` entirely.
    
    - - - - -
    43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00
    base: Introduce move modules into src
    
    The only non-move changes here are whitespace changes to pass the
    `whitespace` test and a few testsuite adaptations.
    
    - - - - -
    df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00
    [PEi386 linker] Bounds check and null-deref guard
    
    We should resonably be able to expect that we won't exceed the number of
    sections if we assume to be dealing with legal object files. We can however
    not guarantee that we get some negative values, and while we try to
    special case most, we should exclude negative indexing into the sections
    array.
    
    We also need to ensure that we do not try to derefences targetSection,
    if it is NULL, due to the switch statement.
    
    - - - - -
    c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
    Move apple compat check to RTS configure
    
    - - - - -
    c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
    Move clock/timer fun checks to RTS configure
    
    Actual library check (which will set the Cabal flag) is left in the
    top-level configure for now.
    
    Progress towards #17191
    
    - - - - -
    7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
    Move visibility and "musttail" annotation checks to the RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
    Move leading underscore checks to RTS configure
    
    `CabalLeadingUnderscore` is done via Hadrian already, so we can stop
    `AC_SUBST`ing it completely.
    
    - - - - -
    25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
    Move alloca, fork, const, and big endian checks to RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    - - - - -
    5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
    Move libdl check to RTS configure
    
    - - - - -
    ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
    Adjust `FP_FIND_LIBFFI`
    
    Just set vars, and `AC_SUBST` in top-level configure.
    
    Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
    be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
    make build system).
    
    - - - - -
    f399812c by John Ericson at 2023-10-12T10:31:13-04:00
    Split BFD support to RTS configure
    
    The flag is still in the top-level configure, but the other checks
    (which define various macros --- important) are in the RTS configure.
    
    - - - - -
    f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
    Split libm check between top level and RTS
    
    - - - - -
    dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
    CgUtils.fixStgRegStmt respect register width
    
    This change ensure that the reg + offset computation is always of the
    same size.  Before this we could end up with a 64bit register, and then
    add a 32bit offset (on 32bit platforms).  This not only would fail type
    sanity checking, but also incorrectly truncate 64bit values into 32bit
    values silently on 32bit architectures.
    
    - - - - -
    9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    5513961a by Ryan Scott at 2023-10-13T07:27:58-04:00
    More robust checking for DataKinds
    
    As observed in #22141, GHC was not doing its due diligence in catching code
    that should require `DataKinds` in order to use. Most notably, it was allowing
    the use of arbitrary data types in kind contexts without `DataKinds`, e.g.,
    
    ```hs
    data Vector :: Nat -> Type -> Type where
    ```
    
    This patch revamps how GHC tracks `DataKinds`. The full specification is
    written out in the `DataKinds` section of the GHC User's Guide, and the
    implementation thereof is described in `Note [Checking for DataKinds]` in
    `GHC.Tc.Validity`. In brief:
    
    * We catch _type_-level `DataKinds` violations in the renamer. See
      `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in
      `GHC.Rename.Pat`.
    
    * We catch _kind_-level `DataKinds` violations in the typechecker, as this
      allows us to catch things that appear beneath type synonyms. (We do *not*
      want to do this in type-level contexts, as it is perfectly fine for a type
      synonym to mention something that requires DataKinds while still using the
      type synonym in a module that doesn't enable DataKinds.) See `checkValidType`
      in `GHC.Tc.Validity`.
    
    * There is now a single `TcRnDataKindsError` that classifies all manner of
      `DataKinds` violations, both in the renamer and the typechecker. The
      `NoDataKindsDC` error has been removed, as it has been subsumed by
      `TcRnDataKindsError`.
    
    * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit
      uses of data types at the kind level without `DataKinds`. Previously,
      `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is
      inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`.
      Moreover, it thwarted the implementation of the `DataKinds` check in
      `checkValidType`, since we would expand `Constraint` (which was OK without
      `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and
      reject it. Now both are allowed.
    
    * I have added a flurry of additional test cases that test various corners of
      `DataKinds` checking.
    
    Fixes #22141.
    
    - - - - -
    
    
    30 changed files:
    
    - .gitignore
    - .gitlab-ci.yml
    - .gitlab/ci.sh
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md
    - .gitlab/jobs.yaml
    - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
    - .gitlab/rel_eng/upload.sh
    - .gitlab/rel_eng/upload_ghc_libs.py
    - .gitlab/test-metrics.sh
    - compiler/CodeGen.Platform.h
    - compiler/GHC/Cmm/DebugBlock.hs
    - compiler/GHC/Cmm/Pipeline.hs
    - compiler/GHC/CmmToAsm.hs
    - compiler/GHC/CmmToAsm/AArch64.hs
    - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
    - compiler/GHC/CmmToAsm/AArch64/Cond.hs
    - compiler/GHC/CmmToAsm/AArch64/Instr.hs
    - compiler/GHC/CmmToAsm/AArch64/Ppr.hs
    - compiler/GHC/CmmToAsm/AArch64/Regs.hs
    - compiler/GHC/CmmToAsm/BlockLayout.hs
    - compiler/GHC/CmmToAsm/Monad.hs
    - compiler/GHC/CmmToAsm/PPC/Instr.hs
    - compiler/GHC/CmmToAsm/Ppr.hs
    - compiler/GHC/CmmToAsm/X86.hs
    - compiler/GHC/Core/Class.hs
    - compiler/GHC/Core/Coercion.hs
    - compiler/GHC/Core/Coercion/Axiom.hs
    - compiler/GHC/Core/Coercion/Opt.hs
    - compiler/GHC/Core/Opt/Arity.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e721af5d5641f8588c3e4e72208b63f574b791fc...5513961aa68ecb696b4ad1b0126951cb497d004c
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e721af5d5641f8588c3e4e72208b63f574b791fc...5513961aa68ecb696b4ad1b0126951cb497d004c
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 12:25:37 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Fri, 13 Oct 2023 08:25:37 -0400
    Subject: [Git][ghc/ghc][wip/ghc-internals-move] 58 commits: Revert "Pass
     preprocessor options to C compiler when building foreign C files (#16737)"
    Message-ID: <652937411ee59_24a44526dc93f027833b@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/ghc-internals-move at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00
    Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"
    
    This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.
    
    `-optP` should pass options to the preprocessor, that might be a very
    different program to the C compiler, so passing the options to the C
    compiler is likely to result in `-optP` being useless.
    
    Fixes #17185 and #21291
    
    - - - - -
    8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00
    rts/nonmoving: Fix on LLP64 platforms
    
    Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL`
    size suffix. However, this is wrong on LLP64 platforms like Windows,
    where `long` is 32-bits.
    
    Fixes #23003.
    Fixes #24042.
    
    - - - - -
    f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00
    Fix isAArch64Bitmask for 32bit immediates.
    
    Fixes #23802
    
    - - - - -
    63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00
    Work around perf note fetch failure
    
    Addresses #24055.
    
    - - - - -
    242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00
    Add a test for #21348
    
    - - - - -
    7d390bce by Rewbert at 2023-10-05T05:38:08-04:00
    Fixes #24046
    
    - - - - -
    8192e9eb by Ben Gamari at 2023-10-11T19:41:02-04:00
    base: Introduce move modules into src
    
    - - - - -
    902b9bce by Ben Gamari at 2023-10-11T19:41:02-04:00
    Move base to ghc-internal
    
    - - - - -
    c91a2cb4 by Ben Gamari at 2023-10-11T19:41:02-04:00
    testsuite fallout
    
    - - - - -
    5ba35cc8 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move System.IO.Unsafe back to base
    
    - - - - -
    29ded354 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move System.Info back to base
    
    - - - - -
    b780a492 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move Data.STRef.Lazy back to base
    
    - - - - -
    bf6bc649 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move System.Console.GetOpt back to base
    
    - - - - -
    a415a352 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move System.Mem.Weak back to base
    
    - - - - -
    96fcb4b7 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Bitraversable.hs back to base
    
    - - - - -
    d3b267b1 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Bifoldable1.hs back to base
    
    - - - - -
    f3693dd3 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/System/Timeout.hs back to base
    
    - - - - -
    82341c6e by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Control/Applicative.hs back to base
    
    - - - - -
    198e09d7 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Control/Monad/IO/Class.hs back to base
    
    - - - - -
    de2f4415 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Array/Byte.hs back to base
    
    - - - - -
    8a4c9832 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Fixed.hs back to base
    
    - - - - -
    73491d52 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Foldable1.hs back to base
    
    - - - - -
    9881f98a by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Complex.hs back to base
    
    - - - - -
    c301be58 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Functor/Compose.hs back to base
    
    - - - - -
    7f868d3d by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Functor/Contravariant.hs back to base
    
    - - - - -
    ecc52707 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Ratio.hs back to base
    
    - - - - -
    a0a60c48 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Data/Char.hs back to base
    
    - - - - -
    d24ee6a2 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Control/Concurrent/QSemN.hs back to base
    
    - - - - -
    e9145d61 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Control/Concurrent/QSem.hs back to base
    
    - - - - -
    d1122a91 by Ben Gamari at 2023-10-11T19:41:03-04:00
    Move src/Control/Concurrent/Chan.hs back to base
    
    - - - - -
    54854a8a by Ben Gamari at 2023-10-11T19:41:41-04:00
    Move src/Text/Printf.hs back to base
    
    - - - - -
    5a259083 by Ben Gamari at 2023-10-11T19:41:42-04:00
    Move src/Control/Monad/Zip.hs back to base
    
    - - - - -
    bdba5fcc by Ben Gamari at 2023-10-11T19:41:42-04:00
    Move src/Data/List/NonEmpty.hs back to base
    
    - - - - -
    c3eee8af by Ben Gamari at 2023-10-11T19:41:42-04:00
    Data.Char
    
    - - - - -
    601e08cb by Ben Gamari at 2023-10-11T19:41:42-04:00
    Expose Data.Functor.Utils
    
    For Bitraversable
    
    - - - - -
    d4af956c by Ben Gamari at 2023-10-11T19:41:42-04:00
    ghc-internal: Reexport GHC.Tuple
    
    To avoid direct dependence on ghc-prim in base
    
    - - - - -
    08f9850e by Ben Gamari at 2023-10-11T19:41:42-04:00
    Add ZipLis
    
    - - - - -
    e15745ec by Ben Gamari at 2023-10-11T19:41:42-04:00
    Move src/System/CPUTime.hsc back to base
    
    - - - - -
    51a173a1 by Ben Gamari at 2023-10-11T19:41:42-04:00
    Move src/System/CPUTime/Windows.hsc back to base
    
    - - - - -
    3030b8cf by Ben Gamari at 2023-10-11T19:41:42-04:00
    Move src/System/CPUTime/Posix/ClockGetTime.hsc back to base
    
    - - - - -
    a1c820ac by Ben Gamari at 2023-10-11T19:41:42-04:00
    Move src/System/CPUTime/Posix/Times.hsc back to base
    
    - - - - -
    38762691 by Ben Gamari at 2023-10-11T19:41:42-04:00
    Move src/System/CPUTime/Posix/RUsage.hsc back to base
    
    - - - - -
    90943558 by Ben Gamari at 2023-10-11T19:41:43-04:00
    Move src/System/CPUTime/Unsupported.hs back to base
    
    - - - - -
    39c771fc by Ben Gamari at 2023-10-11T19:41:43-04:00
    Move src/System/CPUTime/Javascript.hs back to base
    
    - - - - -
    6c9039f3 by Ben Gamari at 2023-10-11T19:41:43-04:00
    Move src/System/CPUTime/Utils.hs back to base
    
    - - - - -
    57afcc70 by Ben Gamari at 2023-10-11T19:47:39-04:00
    Hi
    
    - - - - -
    76789207 by Ben Gamari at 2023-10-11T19:48:43-04:00
    Move src/Data/Bifunctor.hs back to base
    
    - - - - -
    e7ca739d by Ben Gamari at 2023-10-11T19:49:22-04:00
    Move src/Data/Bifoldable.hs back to base
    
    - - - - -
    6b076597 by Ben Gamari at 2023-10-12T15:14:49-04:00
    Move src/Data/Functor/Classes.hs back to base
    
    - - - - -
    2e7f1130 by Ben Gamari at 2023-10-12T15:17:19-04:00
    Move src/Control/Concurrent.hs back to base
    
    - - - - -
    89875c24 by Ben Gamari at 2023-10-12T15:50:23-04:00
    Move src/Data/Functor/Sum.hs back to base
    
    - - - - -
    596ef4d0 by Ben Gamari at 2023-10-12T15:51:15-04:00
    Move src/Data/Functor/Product.hs back to base
    
    - - - - -
    f4953687 by Ben Gamari at 2023-10-12T15:57:40-04:00
    hi
    
    - - - - -
    af6c81ec by Ben Gamari at 2023-10-12T16:28:02-04:00
    Move src/Data/Semigroup.hs back to base
    
    - - - - -
    1ef57f83 by Ben Gamari at 2023-10-12T16:43:16-04:00
    Fix it
    
    - - - - -
    5e32382b by Ben Gamari at 2023-10-12T17:21:02-04:00
    Fix it
    
    - - - - -
    8c17eb0d by Ben Gamari at 2023-10-12T17:21:22-04:00
    Move tests back to base
    
    - - - - -
    455a4804 by Ben Gamari at 2023-10-12T18:03:43-04:00
    Testsuite
    
    - - - - -
    
    
    30 changed files:
    
    - .gitlab/test-metrics.sh
    - compiler/GHC/Builtin/Names.hs
    - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
    - compiler/GHC/Driver/Pipeline/Execute.hs
    - compiler/GHC/StgToJS/Rts/Rts.hs
    - compiler/GHC/Unit/Types.hs
    - configure.ac
    - driver/ghci/ghci-wrapper.cabal.in
    - hadrian/src/Rules/BinaryDist.hs
    - hadrian/src/Settings/Packages.hs
    - libraries/base/base.cabal
    - libraries/base/Control/Applicative.hs → libraries/base/src/Control/Applicative.hs
    - libraries/base/Control/Concurrent.hs → libraries/base/src/Control/Concurrent.hs
    - libraries/base/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs
    - libraries/base/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs
    - libraries/base/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs
    - libraries/base/Control/Monad/IO/Class.hs → libraries/base/src/Control/Monad/IO/Class.hs
    - libraries/base/Control/Monad/Zip.hs → libraries/base/src/Control/Monad/Zip.hs
    - libraries/base/Data/Array/Byte.hs → libraries/base/src/Data/Array/Byte.hs
    - libraries/base/Data/Bifoldable.hs → libraries/base/src/Data/Bifoldable.hs
    - libraries/base/Data/Bifoldable1.hs → libraries/base/src/Data/Bifoldable1.hs
    - libraries/base/Data/Bifunctor.hs → libraries/base/src/Data/Bifunctor.hs
    - libraries/base/Data/Bitraversable.hs → libraries/base/src/Data/Bitraversable.hs
    - libraries/base/Data/Char.hs → libraries/base/src/Data/Char.hs
    - libraries/base/Data/Complex.hs → libraries/base/src/Data/Complex.hs
    - libraries/base/Data/Fixed.hs → libraries/base/src/Data/Fixed.hs
    - libraries/base/Data/Foldable1.hs → libraries/base/src/Data/Foldable1.hs
    - libraries/base/Data/Functor/Classes.hs → libraries/base/src/Data/Functor/Classes.hs
    - libraries/base/Data/Functor/Compose.hs → libraries/base/src/Data/Functor/Compose.hs
    - libraries/base/Data/Functor/Contravariant.hs → libraries/base/src/Data/Functor/Contravariant.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f4287ca904cbc1b20549455c3837e80f2b8048e3...455a48049f8316e0f72fedb1b751b6a0535ddb23
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f4287ca904cbc1b20549455c3837e80f2b8048e3...455a48049f8316e0f72fedb1b751b6a0535ddb23
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 12:25:51 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Fri, 13 Oct 2023 08:25:51 -0400
    Subject: [Git][ghc/ghc][wip/ghc-internals-move-2] 52 commits: base: Introduce
     move modules into src
    Message-ID: <6529374f59add_24a445269f5d64279594@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/ghc-internals-move-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    e1a4f0cc by Ben Gamari at 2023-10-04T20:30:59-04:00
    base: Introduce move modules into src
    
    - - - - -
    45f727be by Ben Gamari at 2023-10-04T21:35:32-04:00
    Move base to ghc-internal
    
    - - - - -
    cd5ff115 by Ben Gamari at 2023-10-04T22:42:18-04:00
    testsuite fallout
    
    - - - - -
    f8dd8f02 by Ben Gamari at 2023-10-05T08:39:39-04:00
    Move System.IO.Unsafe back to base
    
    - - - - -
    075c606e by Ben Gamari at 2023-10-05T08:40:00-04:00
    Move System.Info back to base
    
    - - - - -
    c1e60bb8 by Ben Gamari at 2023-10-05T08:40:01-04:00
    Move Data.STRef.Lazy back to base
    
    - - - - -
    a54bca60 by Ben Gamari at 2023-10-05T08:40:01-04:00
    Move System.Console.GetOpt back to base
    
    - - - - -
    55971d15 by Ben Gamari at 2023-10-05T08:40:01-04:00
    Move System.Mem.Weak back to base
    
    - - - - -
    039d4ba2 by Ben Gamari at 2023-10-05T08:40:01-04:00
    Move src/Data/Bitraversable.hs back to base
    
    - - - - -
    b65f1058 by Ben Gamari at 2023-10-05T08:40:01-04:00
    Move src/Data/Bifoldable1.hs back to base
    
    - - - - -
    c5a1c442 by Ben Gamari at 2023-10-05T08:40:01-04:00
    Move src/System/Timeout.hs back to base
    
    - - - - -
    407c3d2b by Ben Gamari at 2023-10-05T08:40:01-04:00
    Move src/Control/Applicative.hs back to base
    
    - - - - -
    36af3525 by Ben Gamari at 2023-10-05T08:49:03-04:00
    Move src/Control/Monad/IO/Class.hs back to base
    
    - - - - -
    736a8191 by Ben Gamari at 2023-10-05T08:49:05-04:00
    Move src/Foreign/Concurrent.hs back to base
    
    - - - - -
    831a9a74 by Ben Gamari at 2023-10-05T08:49:05-04:00
    Move src/Foreign/Ptr.hs back to base
    
    - - - - -
    cbeafacf by Ben Gamari at 2023-10-05T08:49:25-04:00
    Move src/Data/Array/Byte.hs back to base
    
    - - - - -
    f8389def by Ben Gamari at 2023-10-05T08:49:26-04:00
    Move src/Data/Fixed.hs back to base
    
    - - - - -
    f4662afd by Ben Gamari at 2023-10-05T08:49:26-04:00
    Move src/Data/Foldable1.hs back to base
    
    - - - - -
    4adf7eaa by Ben Gamari at 2023-10-05T08:49:26-04:00
    Move src/Data/Complex.hs back to base
    
    - - - - -
    f05b7671 by Ben Gamari at 2023-10-05T08:49:26-04:00
    Move src/Data/Functor/Compose.hs back to base
    
    - - - - -
    07262de6 by Ben Gamari at 2023-10-05T08:49:26-04:00
    Move src/Data/Functor/Contravariant.hs back to base
    
    - - - - -
    96baafde by Ben Gamari at 2023-10-05T08:49:26-04:00
    Move src/Data/Ratio.hs back to base
    
    - - - - -
    0d634cbc by Ben Gamari at 2023-10-05T08:49:26-04:00
    Move src/Data/Char.hs back to base
    
    - - - - -
    f70f8fe8 by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Control/Concurrent/QSemN.hs back to base
    
    - - - - -
    5bad1c15 by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Control/Concurrent/QSem.hs back to base
    
    - - - - -
    1b9c5d24 by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Control/Concurrent/Chan.hs back to base
    
    - - - - -
    724bbbc0 by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Text/Printf.hs back to base
    
    - - - - -
    005ccfaa by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Foreign/Marshal/Pool.hs back to base
    
    - - - - -
    e1c3613d by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Foreign/Marshal/Error.hs back to base
    
    - - - - -
    08043f17 by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Foreign/Marshal/Unsafe.hs back to base
    
    - - - - -
    a3c16f60 by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Control/Monad/Zip.hs back to base
    
    - - - - -
    5feef2ed by Ben Gamari at 2023-10-05T09:15:55-04:00
    Move src/Data/List/NonEmpty.hs back to base
    
    - - - - -
    9cefdf69 by Ben Gamari at 2023-10-05T11:18:38-04:00
    Move src/Foreign/Marshal/Safe.hs back to base
    
    - - - - -
    5896628a by Ben Gamari at 2023-10-05T11:22:24-04:00
    Move src/Foreign/Marshal.hs back to base
    
    - - - - -
    ccc4e60f by Ben Gamari at 2023-10-05T11:23:26-04:00
    Move src/Foreign/Safe.hs back to base
    
    - - - - -
    4f5572ba by Ben Gamari at 2023-10-05T11:24:50-04:00
    Move src/Foreign.hs back to base
    
    - - - - -
    8dcb77d1 by Ben Gamari at 2023-10-05T11:25:57-04:00
    Data.Char
    
    - - - - -
    43f3d353 by Ben Gamari at 2023-10-05T11:26:15-04:00
    Foreign.Ptr
    
    - - - - -
    f7be4069 by Ben Gamari at 2023-10-05T11:30:59-04:00
    Expose Data.Functor.Utils
    
    For Bitraversable
    
    - - - - -
    7df1853f by Ben Gamari at 2023-10-05T11:31:08-04:00
    ghc-internal: Reexport GHC.Tuple
    
    To avoid direct dependence on ghc-prim in base
    
    - - - - -
    4ad29219 by Ben Gamari at 2023-10-05T11:36:49-04:00
    Foreign.hs
    
    - - - - -
    e21d40b3 by Ben Gamari at 2023-10-05T11:40:51-04:00
    Foreign.Ptr
    
    - - - - -
    ab6c01f2 by Ben Gamari at 2023-10-11T18:13:40-04:00
    Foreign
    
    - - - - -
    c01e6a93 by Ben Gamari at 2023-10-11T19:28:56-04:00
    Move src/System/CPUTime.hsc back to base
    
    - - - - -
    93b78405 by Ben Gamari at 2023-10-11T19:30:01-04:00
    Add ZipLis
    
    - - - - -
    dffeb049 by Ben Gamari at 2023-10-11T19:33:04-04:00
    Move src/System/CPUTime/Windows.hsc back to base
    
    - - - - -
    4599210f by Ben Gamari at 2023-10-11T19:33:04-04:00
    Move src/System/CPUTime/Posix/ClockGetTime.hsc back to base
    
    - - - - -
    585e4086 by Ben Gamari at 2023-10-11T19:33:04-04:00
    Move src/System/CPUTime/Posix/Times.hsc back to base
    
    - - - - -
    5437f1ea by Ben Gamari at 2023-10-11T19:33:04-04:00
    Move src/System/CPUTime/Posix/RUsage.hsc back to base
    
    - - - - -
    2cb6fcf1 by Ben Gamari at 2023-10-11T19:33:04-04:00
    Move src/System/CPUTime/Unsupported.hs back to base
    
    - - - - -
    0552ed64 by Ben Gamari at 2023-10-11T19:33:04-04:00
    Move src/System/CPUTime/Javascript.hs back to base
    
    - - - - -
    3321ca6a by Ben Gamari at 2023-10-11T19:33:22-04:00
    Move src/System/CPUTime/Utils.hs back to base
    
    - - - - -
    
    
    30 changed files:
    
    - compiler/GHC/Builtin/Names.hs
    - compiler/GHC/StgToJS/Rts/Rts.hs
    - compiler/GHC/Unit/Types.hs
    - configure.ac
    - libraries/base/base.cabal
    - libraries/base/Control/Applicative.hs → libraries/base/src/Control/Applicative.hs
    - libraries/base/Control/Concurrent/Chan.hs → libraries/base/src/Control/Concurrent/Chan.hs
    - libraries/base/Control/Concurrent/QSem.hs → libraries/base/src/Control/Concurrent/QSem.hs
    - libraries/base/Control/Concurrent/QSemN.hs → libraries/base/src/Control/Concurrent/QSemN.hs
    - libraries/base/Control/Monad/IO/Class.hs → libraries/base/src/Control/Monad/IO/Class.hs
    - libraries/base/Control/Monad/Zip.hs → libraries/base/src/Control/Monad/Zip.hs
    - libraries/base/Data/Array/Byte.hs → libraries/base/src/Data/Array/Byte.hs
    - libraries/base/Data/Bifoldable1.hs → libraries/base/src/Data/Bifoldable1.hs
    - libraries/base/Data/Bitraversable.hs → libraries/base/src/Data/Bitraversable.hs
    - libraries/base/Data/Char.hs → libraries/base/src/Data/Char.hs
    - libraries/base/Data/Complex.hs → libraries/base/src/Data/Complex.hs
    - libraries/base/Data/Fixed.hs → libraries/base/src/Data/Fixed.hs
    - libraries/base/Data/Foldable1.hs → libraries/base/src/Data/Foldable1.hs
    - libraries/base/Data/Functor/Compose.hs → libraries/base/src/Data/Functor/Compose.hs
    - libraries/base/Data/Functor/Contravariant.hs → libraries/base/src/Data/Functor/Contravariant.hs
    - libraries/base/Data/List/NonEmpty.hs → libraries/base/src/Data/List/NonEmpty.hs
    - libraries/base/Data/Ratio.hs → libraries/base/src/Data/Ratio.hs
    - libraries/base/Data/STRef/Lazy.hs → libraries/base/src/Data/STRef/Lazy.hs
    - + libraries/base/src/Dummy.hs
    - libraries/base/Foreign.hs → libraries/base/src/Foreign.hs
    - libraries/base/Foreign/Concurrent.hs → libraries/base/src/Foreign/Concurrent.hs
    - libraries/base/Foreign/Marshal.hs → libraries/base/src/Foreign/Marshal.hs
    - libraries/base/Foreign/Marshal/Error.hs → libraries/base/src/Foreign/Marshal/Error.hs
    - libraries/base/Foreign/Marshal/Pool.hs → libraries/base/src/Foreign/Marshal/Pool.hs
    - libraries/base/Foreign/Marshal/Safe.hs → libraries/base/src/Foreign/Marshal/Safe.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/455a48049f8316e0f72fedb1b751b6a0535ddb23...3321ca6a5827c25f8efa285ff747b1baf23ac39b
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/455a48049f8316e0f72fedb1b751b6a0535ddb23...3321ca6a5827c25f8efa285ff747b1baf23ac39b
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 12:39:43 2023
    From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott))
    Date: Fri, 13 Oct 2023 08:39:43 -0400
    Subject: [Git][ghc/ghc][wip/T22141] More robust checking for DataKinds
    Message-ID: <65293a8f65e42_24a44527609484280191@gitlab.mail>
    
    
    
    Ryan Scott pushed to branch wip/T22141 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    2616c71d by Ryan Scott at 2023-10-13T08:39:32-04:00
    More robust checking for DataKinds
    
    As observed in #22141, GHC was not doing its due diligence in catching code
    that should require `DataKinds` in order to use. Most notably, it was allowing
    the use of arbitrary data types in kind contexts without `DataKinds`, e.g.,
    
    ```hs
    data Vector :: Nat -> Type -> Type where
    ```
    
    This patch revamps how GHC tracks `DataKinds`. The full specification is
    written out in the `DataKinds` section of the GHC User's Guide, and the
    implementation thereof is described in `Note [Checking for DataKinds]` in
    `GHC.Tc.Validity`. In brief:
    
    * We catch _type_-level `DataKinds` violations in the renamer. See
      `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in
      `GHC.Rename.Pat`.
    
    * We catch _kind_-level `DataKinds` violations in the typechecker, as this
      allows us to catch things that appear beneath type synonyms. (We do *not*
      want to do this in type-level contexts, as it is perfectly fine for a type
      synonym to mention something that requires DataKinds while still using the
      type synonym in a module that doesn't enable DataKinds.) See `checkValidType`
      in `GHC.Tc.Validity`.
    
    * There is now a single `TcRnDataKindsError` that classifies all manner of
      `DataKinds` violations, both in the renamer and the typechecker. The
      `NoDataKindsDC` error has been removed, as it has been subsumed by
      `TcRnDataKindsError`.
    
    * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit
      uses of data types at the kind level without `DataKinds`. Previously,
      `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is
      inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`.
      Moreover, it thwarted the implementation of the `DataKinds` check in
      `checkValidType`, since we would expand `Constraint` (which was OK without
      `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and
      reject it. Now both are allowed.
    
    * I have added a flurry of additional test cases that test various corners of
      `DataKinds` checking.
    
    Fixes #22141.
    
    - - - - -
    
    
    30 changed files:
    
    - compiler/GHC/Core/TyCon.hs
    - compiler/GHC/Driver/Flags.hs
    - compiler/GHC/Driver/Session.hs
    - compiler/GHC/Rename/HsType.hs
    - compiler/GHC/Rename/Pat.hs
    - compiler/GHC/Tc/Errors/Ppr.hs
    - compiler/GHC/Tc/Errors/Types.hs
    - compiler/GHC/Tc/Errors/Types/PromotionErr.hs
    - compiler/GHC/Tc/Gen/HsType.hs
    - compiler/GHC/Tc/Validity.hs
    - compiler/GHC/Types/Error/Codes.hs
    - docs/users_guide/9.10.1-notes.rst
    - docs/users_guide/exts/data_kinds.rst
    - docs/users_guide/using-warnings.rst
    - testsuite/tests/polykinds/T7433.stderr
    - testsuite/tests/rename/should_fail/T22478e.hs
    - testsuite/tests/rename/should_fail/T22478e.stderr
    - + testsuite/tests/typecheck/should_compile/T22141a.hs
    - + testsuite/tests/typecheck/should_compile/T22141a.stderr
    - + testsuite/tests/typecheck/should_compile/T22141b.hs
    - + testsuite/tests/typecheck/should_compile/T22141b.stderr
    - + testsuite/tests/typecheck/should_compile/T22141c.hs
    - + testsuite/tests/typecheck/should_compile/T22141c.stderr
    - + testsuite/tests/typecheck/should_compile/T22141d.hs
    - + testsuite/tests/typecheck/should_compile/T22141d.stderr
    - + testsuite/tests/typecheck/should_compile/T22141e.hs
    - + testsuite/tests/typecheck/should_compile/T22141e.stderr
    - + testsuite/tests/typecheck/should_compile/T22141e_Aux.hs
    - + testsuite/tests/typecheck/should_compile/T22141f.hs
    - + testsuite/tests/typecheck/should_compile/T22141g.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2616c71dfbc014e94ce1fe19a57f707bc8641d2f
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2616c71dfbc014e94ce1fe19a57f707bc8641d2f
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 13:13:25 2023
    From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering))
    Date: Fri, 13 Oct 2023 09:13:25 -0400
    Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 2 commits: Fix libdir
    Message-ID: <65294275cc361_24a4452844ec382827e3@gitlab.mail>
    
    
    
    Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    3e88ba82 by Matthew Pickering at 2023-10-12T15:15:55+01:00
    Fix libdir
    
    - - - - -
    70f66d4b by Matthew Pickering at 2023-10-13T14:13:08+01:00
    SMP fix
    
    - - - - -
    
    
    2 changed files:
    
    - hadrian/src/Settings/Builders/RunTest.hs
    - m4/fp_settings.m4
    
    
    Changes:
    
    =====================================
    hadrian/src/Settings/Builders/RunTest.hs
    =====================================
    @@ -166,9 +166,7 @@ outOfTreeCompilerArgs = do
         withInterpreter     <- getBooleanSetting TestGhcWithInterpreter
         unregisterised      <- getBooleanSetting TestGhcUnregisterised
         tables_next_to_code <- getBooleanSetting TestGhcTablesNextToCode
    -    -- MP: Wrong
    ---    targetWithSMP       <- targetSupportsSMP stage
    -    let targetWithSMP   = True
    +    targetWithSMP       <- getBooleanSetting TestGhcWithSMP
     
         debugAssertions     <- getBooleanSetting TestGhcDebugAssertions
     
    
    
    =====================================
    m4/fp_settings.m4
    =====================================
    @@ -75,7 +75,7 @@ AC_DEFUN([FP_SETTINGS],
         fi
     
         if test "$HostOS" = "mingw32"; then
    -        SettingsTouchCommand='$$topdir/bin/touchy.exe'
    +        SettingsTouchCommand='$$topdir/../bin/touchy.exe'
         else
             SettingsTouchCommand='touch'
         fi
    @@ -109,7 +109,7 @@ AC_DEFUN([FP_SETTINGS],
             SUBST_TOOLDIR([SettingsArCommand])
             SUBST_TOOLDIR([SettingsRanlibCommand])
             SUBST_TOOLDIR([SettingsWindresCommand])
    -        SettingsTouchCommand='$$topdir/bin/touchy.exe'
    +        SettingsTouchCommand='$$topdir/../bin/touchy.exe'
         fi
     
         # LLVM backend tools
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a17827a405c5731a469b8e6adde25dd85ad474d2...70f66d4b25c4ecc889930a6a7e175869c8dd72a2
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a17827a405c5731a469b8e6adde25dd85ad474d2...70f66d4b25c4ecc889930a6a7e175869c8dd72a2
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 13:28:28 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Fri, 13 Oct 2023 09:28:28 -0400
    Subject: [Git][ghc/ghc] Deleted branch
     wip/rts-cabal-file-no-stage-specific-subst
    Message-ID: <652945fc7b48c_24a44528c2e3902892cc@gitlab.mail>
    
    
    
    John Ericson deleted branch wip/rts-cabal-file-no-stage-specific-subst at Glasgow Haskell Compiler / GHC
    
    -- 
    
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 13 13:42:16 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Fri, 13 Oct 2023 09:42:16 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: hadrian:
     Decrease verbosity of cabal commands
    Message-ID: <65294937d23c9_24a445290eeb00304444@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    eed25eee by Sylvain Henry at 2023-10-13T09:41:25-04:00
    Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)
    
    bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".
    
    - - - - -
    a5fc1478 by Sylvain Henry at 2023-10-13T09:41:25-04:00
    Rts: expose rtsOutOfBoundsAccess symbol
    
    - - - - -
    b291930e by Sylvain Henry at 2023-10-13T09:41:25-04:00
    Hadrian: enable `-fcheck-prim-bounds` in validate flavour
    
    This allows T24066 to fail when the bug is present.
    
    Otherwise the out-of-bound access isn't detected as it happens in
    ghc-bignum which wasn't compiled with the bounds check.
    
    - - - - -
    b60fa193 by Ilias Tsitsimpis at 2023-10-13T09:41:27-04:00
    hadrian: Pass -DNOSMP to C compiler when needed
    
    Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
    SMP, but doesn't pass it to CC as well, leading to the following
    compilation error on mips64el:
    
    | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
    Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
    ===> Command failed with error code: 1
    In file included from rts/include/Stg.h:348,
                     from rts/include/Rts.h:38,
                     from rts/hooks/FlagDefaults.c:8:
    rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
      416 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
      440 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
      464 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    
    The old make system correctly passed this flag to both GHC and CC [1].
    
    Fix this error by passing -DNOSMP to CC as well.
    
    [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
    
    Closes #24082
    
    - - - - -
    
    
    16 changed files:
    
    - .gitignore
    - hadrian/doc/flavours.md
    - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Settings/Flavours/Validate.hs
    - hadrian/src/Settings/Packages.hs
    - libraries/ghc-bignum/src/GHC/Num/BigNat.hs
    - libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal
    - rts/.gitignore
    - rts/RtsMessages.c
    - rts/RtsSymbols.c
    - rts/include/rts/Messages.h
    - rts/rts.cabal.in → rts/rts.cabal
    - + testsuite/tests/numeric/should_run/T24066.hs
    - + testsuite/tests/numeric/should_run/T24066.stdout
    - testsuite/tests/numeric/should_run/all.T
    
    
    Changes:
    
    =====================================
    .gitignore
    =====================================
    @@ -167,7 +167,6 @@ _darcs/
     /libraries/ghc-boot-th/ghc-boot-th.cabal
     /libraries/ghc-boot-th/ghc.mk
     /libraries/ghc-heap/ghc-heap.cabal
    -/libraries/ghc-prim/ghc-prim.cabal
     /libraries/ghci/GNUmakefile
     /libraries/ghci/ghci.cabal
     /libraries/ghci/ghc.mk
    
    
    =====================================
    hadrian/doc/flavours.md
    =====================================
    @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
         validate
         
         -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -198,9 +198,10 @@ copyPackage context at Context {..} = do shakeVerbosityToCabalFlag :: Verbosity -> String shakeVerbosityToCabalFlag = \case Diagnostic -> "-v3" - Verbose -> "-v3" + Verbose -> "-v2" + -- Normal levels should not produce output to stdout Silent -> "-v0" - _ -> "-v2" + _ -> "-v1" -- | What type of file is Main data MainSourceType = HsMain | CppMain | CMain ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -268,17 +268,6 @@ runInterpolations (Interpolations mk_substs) input = do subst = foldr (.) id [replace ("@"++k++"@") v | (k,v) <- substs] return (subst input) -toCabalBool :: Bool -> String -toCabalBool True = "True" -toCabalBool False = "False" - --- | Interpolate the given variable with the value of the given 'Flag', using --- Cabal's boolean syntax. -interpolateCabalFlag :: String -> Flag -> Interpolations -interpolateCabalFlag name flg = interpolateVar name $ do - val <- flag flg - return (toCabalBool val) - -- | Interpolate the given variable with the value of the given 'Setting'. interpolateSetting :: String -> Setting -> Interpolations interpolateSetting name settng = interpolateVar name $ setting settng @@ -290,31 +279,6 @@ projectVersion = mconcat , interpolateSetting "ProjectVersionMunged" ProjectVersionMunged ] -rtsCabalFlags :: Interpolations -rtsCabalFlags = mconcat - [ flag "CabalHaveLibdw" UseLibdw - , flag "CabalHaveLibm" UseLibm - , flag "CabalHaveLibrt" UseLibrt - , flag "CabalHaveLibdl" UseLibdl - , flag "CabalNeedLibpthread" UseLibpthread - , flag "CabalHaveLibbfd" UseLibbfd - , flag "CabalHaveLibNuma" UseLibnuma - , flag "CabalHaveLibZstd" UseLibzstd - , flag "CabalStaticLibZstd" StaticLibzstd - , flag "CabalNeedLibatomic" NeedLibatomic - , flag "CabalUseSystemLibFFI" UseSystemFfi - , targetFlag "CabalLibffiAdjustors" tgtUseLibffiForAdjustors - , targetFlag "CabalLeadingUnderscore" tgtSymbolsHaveLeadingUnderscore - ] - where - flag = interpolateCabalFlag - targetFlag name q = interpolateVar name $ do - val <- queryTargetTarget q - return (toCabalBool val) - -ghcPrimCabalFlags :: Interpolations -ghcPrimCabalFlags = interpolateCabalFlag "CabalNeedLibatomic" NeedLibatomic - packageVersions :: Interpolations packageVersions = foldMap f [ base, ghcPrim, compiler, ghc, cabal, templateHaskell, ghcCompact, array ] where @@ -347,8 +311,6 @@ templateRule outPath interps = do templateRules :: Rules () templateRules = do templateRule "compiler/ghc.cabal" $ projectVersion - templateRule "rts/rts.cabal" $ rtsCabalFlags - templateRule "libraries/ghc-prim/ghc-prim.cabal" $ ghcPrimCabalFlags templateRule "driver/ghci/ghci-wrapper.cabal" $ projectVersion templateRule "ghc/ghc-bin.cabal" $ projectVersion templateRule "utils/iserv/iserv.cabal" $ projectVersion ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -114,7 +114,7 @@ packageArgs = do -------------------------------- ghcPrim ------------------------------- , package ghcPrim ? mconcat - [ builder (Cabal Flags) ? arg "include-ghc-prim" + [ builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic" , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ? input "**/cbits/atomic.c" ? arg "-Wno-sync-nand" ] @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" @@ -401,8 +401,19 @@ rtsPackageArgs = package rts ? do , any (wayUnit Debug) rtsWays `cabalFlag` "debug" , any (wayUnit Dynamic) rtsWays `cabalFlag` "dynamic" , any (wayUnit Threaded) rtsWays `cabalFlag` "threaded" + , flag UseLibm `cabalFlag` "libm" + , flag UseLibrt `cabalFlag` "librt" + , flag UseLibdl `cabalFlag` "libdl" , useSystemFfi `cabalFlag` "use-system-libffi" , useLibffiForAdjustors `cabalFlag` "libffi-adjustors" + , flag UseLibpthread `cabalFlag` "need-pthread" + , flag UseLibbfd `cabalFlag` "libbfd" + , flag NeedLibatomic `cabalFlag` "need-atomic" + , flag UseLibdw `cabalFlag` "libdw" + , flag UseLibnuma `cabalFlag` "libnuma" + , flag UseLibzstd `cabalFlag` "libzstd" + , flag StaticLibzstd `cabalFlag` "static-libzstd" + , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore" , Debug `wayUnit` way `cabalFlag` "find-ptr" ] , builder (Cabal Setup) ? mconcat ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -28,7 +28,7 @@ custom-setup setup-depends: base >= 4 && < 5, process, filepath, directory, Cabal >= 1.23 && < 3.9 flag need-atomic - default: @CabalNeedLibatomic@ + default: False Library default-language: Haskell2010 ===================================== rts/.gitignore ===================================== @@ -2,8 +2,6 @@ /dist/ /dist-*/ -/rts.cabal - /include/ghcversion.h /package.conf.inplace ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== rts/rts.cabal.in → rts/rts.cabal ===================================== @@ -29,31 +29,31 @@ source-repository head subdir: rts flag libm - default: @CabalHaveLibm@ + default: False flag librt - default: @CabalHaveLibrt@ + default: False flag libdl - default: @CabalHaveLibdl@ + default: False flag use-system-libffi - default: @CabalUseSystemLibFFI@ + default: False flag libffi-adjustors - default: @CabalLibffiAdjustors@ + default: False flag need-pthread - default: @CabalNeedLibpthread@ + default: False flag libbfd - default: @CabalHaveLibbfd@ + default: False flag need-atomic - default: @CabalNeedLibatomic@ + default: False flag libdw - default: @CabalHaveLibdw@ + default: False flag libnuma - default: @CabalHaveLibNuma@ + default: False flag libzstd - default: @CabalHaveLibZstd@ + default: False flag static-libzstd - default: @CabalStaticLibZstd@ + default: False flag leading-underscore - default: @CabalLeadingUnderscore@ + default: False flag smp default: True flag find-ptr ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6cda769ec00498de73f7642c8fa9505eecc4b019...b60fa19354638c0321002a47a29b0c15598242e2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6cda769ec00498de73f7642c8fa9505eecc4b019...b60fa19354638c0321002a47a29b0c15598242e2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 14:10:42 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 13 Oct 2023 10:10:42 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/hadrian-substitutes-doc-config Message-ID: <65294fe28d918_24a44529c36bc03094d8@gitlab.mail> John Ericson pushed new branch wip/hadrian-substitutes-doc-config at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hadrian-substitutes-doc-config You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 14:18:42 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 13 Oct 2023 10:18:42 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/docs-no-ref-parallel Message-ID: <652951c21d074_24a44529a4012c31303b@gitlab.mail> John Ericson pushed new branch wip/docs-no-ref-parallel at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/docs-no-ref-parallel You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 15:02:53 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 13 Oct 2023 11:02:53 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 118 commits: gitlab-ci: Mark T22012 as broken on CentOS 7 Message-ID: <65295c1d80769_24a4452b573bec3521b6@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 1432d6eb by John Ericson at 2023-10-13T15:06:20+01:00 Move mingwex check to RTS configure - - - - - d86dd5ed by John Ericson at 2023-10-13T15:06:20+01:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - 077c6cca by John Ericson at 2023-10-13T15:06:20+01:00 Move over a number of C-style checks to RTS configure - - - - - 8af80e4a by John Ericson at 2023-10-13T15:06:20+01:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - 068ed9bd by John Ericson at 2023-10-13T15:09:11+01:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 7831bdae by John Ericson at 2023-10-13T15:09:14+01:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 3e89ac0e by John Ericson at 2023-10-13T15:10:37+01:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - a93eacf6 by John Ericson at 2023-10-13T15:10:39+01:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - 9a8f8f85 by Matthew Pickering at 2023-10-13T15:10:39+01:00 hadrian: Build all executables in bin/ folder In the end the bindist creation logic copies them all into the bin folder. There is no benefit to building a specific few binaries in the lib/bin folder anymore. This also removes the ad-hoc logic to copy the touchy and unlit executables from stage0 into stage1. It takes <1s to build so we might as well just build it. - - - - - bb76a51b by Matthew Pickering at 2023-10-13T15:44:51+01:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - a7d20ba4 by GHC GitLab CI at 2023-10-13T15:44:51+01:00 fail when bindist configure fails - - - - - f16d31fe by GHC GitLab CI at 2023-10-13T15:44:51+01:00 Correctly propagate build/host/target to bindist fix host/target bindist t - - - - - 98ce473c by Matthew Pickering at 2023-10-13T15:44:51+01:00 ci: Test cross bindists - - - - - 666f5deb by Matthew Pickering at 2023-10-13T15:44:51+01:00 CROSS_STAGE variable - - - - - f3bf9d98 by Matthew Pickering at 2023-10-13T15:44:51+01:00 Use explicit syntax rather than pure - - - - - b72d9f6b by Matthew Pickering at 2023-10-13T15:44:51+01:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - e32278af by Matthew Pickering at 2023-10-13T16:00:04+01:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - 89f7421b by Matthew Pickering at 2023-10-13T16:00:31+01:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 30 changed files: - .gitignore - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - .gitlab/test-metrics.sh - compiler/CodeGen.Platform.h - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Data/FastString.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/70f66d4b25c4ecc889930a6a7e175869c8dd72a2...89f7421ba6e73fdd55c118fb3c10c3ed29ae2106 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/70f66d4b25c4ecc889930a6a7e175869c8dd72a2...89f7421ba6e73fdd55c118fb3c10c3ed29ae2106 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 15:11:48 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 13 Oct 2023 11:11:48 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 8 commits: fail when bindist configure fails Message-ID: <65295e3417d0c_24a4452b8cf6c4359079@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: 987edc45 by Matthew Pickering at 2023-10-13T16:11:34+01:00 fail when bindist configure fails - - - - - 57796a4b by Matthew Pickering at 2023-10-13T16:11:38+01:00 Correctly propagate build/host/target to bindist fix host/target bindist t - - - - - db8efc52 by Matthew Pickering at 2023-10-13T16:11:40+01:00 ci: Test cross bindists - - - - - 178cb6c6 by Matthew Pickering at 2023-10-13T16:11:41+01:00 CROSS_STAGE variable - - - - - 75deb47e by Matthew Pickering at 2023-10-13T16:11:41+01:00 Use explicit syntax rather than pure - - - - - 774c40be by Matthew Pickering at 2023-10-13T16:11:41+01:00 ci: Javascript don't set CROSS_EMULATOR There is no CROSS_EMULATOR needed to run javascript binaries, so we don't set the CROSS_EMULATOR to some dummy value. - - - - - dcdf2dd8 by Matthew Pickering at 2023-10-13T16:11:41+01:00 hadrian: Fill in more of the default.host toolchain file When you are building a cross compiler this file will be used to build stage1 and it's libraries, so we need enough information here to work accurately. There is still more work to be done (see for example, word size is still fixed). - - - - - 222be3d7 by Matthew Pickering at 2023-10-13T16:11:41+01:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 30 changed files: - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/default.host.target.in - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Hadrian/Expression.hs - hadrian/src/Hadrian/Haskell/Hash.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Flavour.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Packages.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/CabalReinstall.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Gmp.hs - hadrian/src/Rules/Libffi.hs - hadrian/src/Rules/Library.hs - hadrian/src/Rules/Program.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/89f7421ba6e73fdd55c118fb3c10c3ed29ae2106...222be3d78721c56e5597cc171585b3cff8c9532a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/89f7421ba6e73fdd55c118fb3c10c3ed29ae2106...222be3d78721c56e5597cc171585b3cff8c9532a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 15:12:40 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 13 Oct 2023 11:12:40 -0400 Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] hadrian: Build stage 2 cross compilers Message-ID: <65295e68edfee_24a4452b89d7a0359846@gitlab.mail> Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC Commits: cc566a6d by Matthew Pickering at 2023-10-13T16:12:33+01:00 hadrian: Build stage 2 cross compilers * Most of hadrian is abstracted over the stage in order to remove the assumption that the target of all stages is the same platform. This allows the RTS to be built for two different targets for example. * Abstracts the bindist creation logic to allow building either normal or cross bindists. Normal bindists use stage 1 libraries and a stage 2 compiler. Cross bindists use stage 2 libararies and a stage 2 compiler. ------------------------- Metric Decrease: T10421a T10858 T11195 T11276 T11374 T11822 T15630 T17096 T18478 T20261 Metric Increase: parsing001 ------------------------- - - - - - 30 changed files: - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Hadrian/Expression.hs - hadrian/src/Hadrian/Haskell/Hash.hs - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Oracles/Flavour.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Packages.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/CabalReinstall.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Gmp.hs - hadrian/src/Rules/Libffi.hs - hadrian/src/Rules/Library.hs - hadrian/src/Rules/Program.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/Rts.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cc566a6dd92850f5da695400e43273ef73afe3c6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cc566a6dd92850f5da695400e43273ef73afe3c6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 17:03:25 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 13 Oct 2023 13:03:25 -0400 Subject: [Git][ghc/ghc][wip/romes/eqsat-pmc] 260 commits: Don't attempt pattern synonym error recovery Message-ID: <6529785dcd83c_24a4452e4370dc3874c1@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/eqsat-pmc at Glasgow Haskell Compiler / GHC Commits: e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - f5f41e7f by Rodrigo Mesquita at 2023-10-13T13:33:47+01:00 Add e-graphs submodule (hegg) - - - - - e7028558 by Rodrigo Mesquita at 2023-10-13T13:33:49+01:00 Create Core.Equality module This module defines CoreExprF -- the base functor of CoreExpr, and equality and ordering operations on the debruijnized CoreExprF. Furthermore, it provides a function to represent a CoreExpr in an e-graph. This is a requirement to represent, reason about equality, and manipulate CoreExprs in e-graphs. E-graphs are going to be used in the pattern match checker (#19272), and potentially for type family rewriting (#TODO) -- amongst other oportunities that are unlocked by having them available. - - - - - 6046a80d by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 Question - - - - - 03f1acc0 by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 Was going great until I started needing to thread ClassIds together with Ids. Ret-think this. - - - - - 65db630f by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 A solution with more lookups Fixes to Pmc.Ppr module Wow, a lot (stage1) is working actually, without PMC errprs We're still not there yet. WiP - - - - - ab4a48df by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 Add instances for debugging - - - - - d0f30aac by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 Things that were broken due to unlawfulness of e-graph instances - - - - - 78f7f2c8 by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 Scuffed merging without effects to salvage some information that might get lost in merging that happens outside of addVarCt - - - - - 9d452d86 by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 This is the commit where it does works: * Drops SDFM module - - - - - f9890ddf by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 Improve a little bit the mixing of Ids and ClassIds tWeaks Don't use EG.rebuild as a view pattern Debuggging Touches Fix to representId over multiple (different) nablas Paper over Chagnes2 Then....Start going the other direction - - - - - daf63365 by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 Get compilation with more exhaustiveness working again, but this time with a cleaner story, since in PhiCt we already only have ClassIds. It works for the first two examples in #19272, but it does not solve the latest contrived example we came up with -- I think it's likely because of rebuilding. RE rebuilding: It doesn't look like usually there are many/any things in the worklist, meaning it's probably quite cheap to rebuild often. - - - - - 4fd67809 by Rodrigo Mesquita at 2023-10-13T13:33:50+01:00 Improve term representation in e-graph and code complexity too, it's almost reasonable Fixes - - - - - 54a887ce by Rodrigo Mesquita at 2023-10-13T17:59:25+01:00 WIP: Deeper rewrite of the backend with e-graphs to pursue best performance - - - - - 753bd0e5 by Rodrigo Mesquita at 2023-10-13T17:59:25+01:00 Don't use dsHsConLike to desugar a pattern... - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitlab/test-metrics.sh - .gitmodules - README.md - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Cond.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/490e1c8d2b256bb4d9ae06754b0906d1c921a13d...753bd0e5062261c3a2a1c14026f0ecc485ad0004 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/490e1c8d2b256bb4d9ae06754b0906d1c921a13d...753bd0e5062261c3a2a1c14026f0ecc485ad0004 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 17:29:44 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 13 Oct 2023 13:29:44 -0400 Subject: [Git][ghc/ghc][wip/romes/eqsat-pmc] 3 commits: WIP: Deeper rewrite of the backend with e-graphs to pursue best performance Message-ID: <65297e88ca523_24a4452eca4ee0393862@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/eqsat-pmc at Glasgow Haskell Compiler / GHC Commits: a2b3ff58 by Rodrigo Mesquita at 2023-10-13T18:29:25+01:00 WIP: Deeper rewrite of the backend with e-graphs to pursue best performance - - - - - e38391d6 by Rodrigo Mesquita at 2023-10-13T18:29:25+01:00 Don't use dsHsConLike to desugar a pattern... - - - - - 5ec798cb by Rodrigo Mesquita at 2023-10-13T18:29:25+01:00 debug - - - - - 5 changed files: - compiler/GHC/Core/Equality.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Check.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs Changes: ===================================== compiler/GHC/Core/Equality.hs ===================================== @@ -5,10 +5,12 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE DerivingVia #-} +-- TODO: Rename to GHC.HsToCore.CoreEquality or something module GHC.Core.Equality where import GHC.Prelude +-- import GHC.Types.Name (Name) import GHC.Core import GHC.Core.DataCon import GHC.Core.TyCo.Rep @@ -18,7 +20,7 @@ import GHC.Types.Literal import GHC.Types.Tickish import Data.Equality.Graph as EG -import Data.Equality.Analysis +import Data.Equality.Analysis.Monadic import qualified Data.Equality.Graph.Monad as EGM import GHC.Utils.Outputable import GHC.Core.Coercion (coercionType) @@ -37,7 +39,7 @@ import Control.Monad.Trans.Reader -- In practice, no-one writes gigantic lambda expressions in guards and view patterns data AltF a - = AltF AltCon' [()] a + = AltF AltCon' [()] a -- [()] tells us the number of constructors..., bad representation TODO deriving (Functor, Foldable, Traversable, Eq, Ord) data BindF a @@ -46,14 +48,19 @@ data BindF a deriving (Functor, Foldable, Traversable, Eq, Ord, Show) type BoundVar = Int -data ExprF a +-- If we use this datatype specifically for representing HsToCore.Pmc, we may +-- be able to drop the coercion field, and add a specific one for constructor +-- application +data ExprF r = VarF BoundVar + -- ROMES:TODO: what about using Names for comparison? Since this is only for equality purposes... + -- It makes it possible to use the ConLikeName as the FreeVar Name, since there is conLikeName for PmAltConLike | FreeVarF Id | LitF Literal - | AppF a a - | LamF a - | LetF (BindF a) a - | CaseF a [AltF a] -- can we drop the case type for expr equality? we don't need them back, we just need to check equality. (perhaps this specialization makes this more suitable in the Pmc namespace) + | AppF r r + | LamF r + | LetF (BindF r) r + | CaseF r [AltF r] -- can we drop the case type for expr equality? we don't need them back, we just need to check equality. (perhaps this specialization makes this more suitable in the Pmc namespace) -- | CastF a (DeBruijn CoercionR) -- can we drop this -- | TickF CoreTickish a -- this, when representing expressions for equality? @@ -83,17 +90,18 @@ instance Ord AltCon' where -- this makes perfect sense, if we already have to represent this in the e-graph -- we might as well make it a better suited representation for the e-graph... -- keeping the on-fly debruijn is harder -representCoreExprEgr :: forall a - . Analysis a CoreExprF +representCoreExprEgr :: forall a m + . Analysis m a CoreExprF => CoreExpr -> EGraph a CoreExprF - -> (ClassId, EGraph a CoreExprF) -representCoreExprEgr expr egr = EGM.runEGraphM egr (runReaderT (go expr) emptyCME) where - go :: CoreExpr -> ReaderT CmEnv (EGM.EGraphM a CoreExprF) ClassId + -> m (ClassId, EGraph a CoreExprF) +representCoreExprEgr expr egr = EGM.runEGraphMT egr (runReaderT (go expr) emptyCME) where + go :: CoreExpr -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId go = \case Var v -> do env <- ask case lookupCME env v of + -- Nothing -> addE (FreeVarF $ varName v) Nothing -> addE (FreeVarF v) Just i -> addE (VarF i) Lit lit -> addE (LitF lit) @@ -121,13 +129,13 @@ representCoreExprEgr expr egr = EGM.runEGraphM egr (runReaderT (go expr) emptyCM as' <- traverse (local (`extendCME` b) . goAlt) as addE (CaseF e' as') - goAlt :: CoreAlt -> ReaderT CmEnv (EGM.EGraphM a CoreExprF) (CoreAltF ClassId) + goAlt :: CoreAlt -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) (CoreAltF ClassId) goAlt (Alt c bs e) = do e' <- local (`extendCMEs` bs) $ go e return (AltF (AC' c) (map (const ()) bs) e') - addE :: Analysis a CoreExprF => CoreExprF ClassId -> ReaderT CmEnv (EGM.EGraphM a CoreExprF) ClassId - addE e = lift $ EGM.add $ Node e + addE :: Analysis m a CoreExprF => CoreExprF ClassId -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId + addE e = lift $ EGM.addM $ Node e type CoreExprF = ExprF type CoreAltF = AltF ===================================== compiler/GHC/HsToCore/Pmc.hs ===================================== @@ -75,6 +75,8 @@ import qualified Data.List.NonEmpty as NE import Data.Coerce import GHC.Tc.Utils.Monad +import Control.Monad.Trans.Maybe + import Data.Maybe (fromJust) -- @@ -106,7 +108,7 @@ pmcPatBind ctxt@(DsMatchContext match_ctxt loc) var p !missing0 <- getLdiNablas -- See Note (TODO) [Represent the MatchIds before the CheckAction] - let missing = representIdNablas var missing0 + Just missing <- runMaybeT $ representIdNablas var missing0 pat_bind <- noCheckDs $ desugarPatBind loc var p tracePm "pmcPatBind {" (vcat [ppr ctxt, ppr var, ppr p, ppr pat_bind, ppr missing]) @@ -179,7 +181,7 @@ pmcMatches ctxt vars matches = {-# SCC "pmcMatches" #-} do !missing0 <- getLdiNablas -- See Note (TODO) [Represent the MatchIds before the CheckAction] - let missing = representIdsNablas vars missing0 + Just missing <- runMaybeT $ representIdsNablas vars missing0 tracePm "pmcMatches {" $ hang (vcat [ppr ctxt, ppr vars, text "Matches:"]) @@ -266,7 +268,7 @@ pmcRecSel sel_id arg !missing0 <- getLdiNablas -- See Note (TODO) [Represent the MatchIds before the CheckAction] - let missing = representIdNablas sel_id missing0 + Just missing <- runMaybeT $ representIdNablas sel_id missing0 tracePm "pmcRecSel {" (ppr sel_id) CheckResult{ cr_ret = PmRecSel{ pr_arg_var = arg_id }, cr_uncov = uncov_nablas } ===================================== compiler/GHC/HsToCore/Pmc/Check.hs ===================================== @@ -44,6 +44,8 @@ import GHC.Types.Var import GHC.Core import GHC.Core.Utils +import Control.Monad.Trans.Maybe + -- | Coverage checking action. Can be composed 'leftToRight' or 'topToBottom'. newtype CheckAction a = CA { unCA :: Nablas -> DsM (CheckResult a) } deriving Functor @@ -198,12 +200,12 @@ checkRecSel pr@(PmRecSel { pr_arg = arg, pr_cons = cons }) = CA $ \inc -> do Var arg_id -> return arg_id _ -> mkPmId $ exprType arg - unc <- liftNablasM (\d -> - let (arg_id', d') = representId arg_id d - con_cts = map (PhiNotConCt arg_id' . PmAltConLike) cons + unc <- liftNablasM (\d -> do + Just (arg_id', d') <- runMaybeT $ representId arg_id d + let con_cts = map (PhiNotConCt arg_id' . PmAltConLike) cons arg_ct = PhiCoreCt arg_id' arg phi_cts = listToBag (arg_ct : con_cts) - in addPhiCts d' phi_cts) inc + addPhiCts d' phi_cts) inc pure CheckResult { cr_ret = pr{ pr_arg_var = arg_id }, cr_uncov = unc, cr_approx = mempty } ===================================== compiler/GHC/HsToCore/Pmc/Solver.hs ===================================== @@ -1,9 +1,14 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiWayIf #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE ViewPatterns #-} -{-# LANGUAGE RankNTypes, GADTs #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE RankNTypes, GADTs #-} +{-# OPTIONS_GHC -Wno-orphans #-} -- Analysis........ +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -- ROMES:TODO: THIS IS FOR DEBUGGING REMOVE {- Authors: George Karachalias @@ -34,12 +39,15 @@ module GHC.HsToCore.Pmc.Solver ( addPhiCts, isInhabited, - generateInhabitingPatterns, GenerateInhabitingPatternsMode(..) + generateInhabitingPatterns, GenerateInhabitingPatternsMode(..), + + representId, representIds, representIdNablas, representIdsNablas ) where import GHC.Prelude +import GHC.HsToCore.Monad import GHC.HsToCore.Pmc.Types import GHC.HsToCore.Pmc.Utils (tracePm, traceWhenFailPm, mkPmId) @@ -67,7 +75,8 @@ import GHC.Core.Equality import GHC.Core.Predicate (typeDeterminesValue) import GHC.Core.SimpleOpt (simpleOptExpr, exprIsConApp_maybe) import GHC.Core.Utils (exprType) -import GHC.Core.Make (mkListExpr, mkCharExpr, mkImpossibleExpr) +import GHC.Core.Make (mkListExpr, mkCharExpr, mkImpossibleExpr, mkCoreApp) +import GHC.Core.Map.Type (deBruijnize) -- ROMES:TODO: Doesn't look good great. At least export some function from HsToCore Equality module to create the types. It's wrong; we should keep a debruijn map while representing the expression, and assign it correctly to each type? Not sure. import GHC.Data.FastString import GHC.Types.SrcLoc @@ -86,8 +95,8 @@ import GHC.Tc.Solver (tcNormalise, tcCheckGivens, tcCheckWanteds) import GHC.Core.Unify (tcMatchTy) import GHC.Core.Coercion import GHC.Core.Reduction -import GHC.HsToCore.Monad hiding (foldlM) import GHC.Tc.Instance.Family +import GHC.Types.Id.Make (unboxedUnitExpr) import GHC.Core.FamInstEnv import Control.Applicative ((<|>)) @@ -95,16 +104,17 @@ import Control.Monad (foldM, forM, guard, mzero, when, filterM) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.State.Strict import Data.Coerce -import Data.Foldable (foldlM, minimumBy, toList) +import Data.Foldable (minimumBy, toList) import Data.Monoid (Any(..)) import Data.List (sortBy, find) import qualified Data.List.NonEmpty as NE import Data.Ord (comparing) +import Data.Equality.Analysis.Monadic import Data.Equality.Graph (ClassId) import Data.Equality.Graph.Lens import qualified Data.Equality.Graph as EG -import Data.Bifunctor (second) +import qualified Data.Equality.Graph.Monad as EGM import Data.Function ((&)) import qualified Data.IntSet as IS @@ -124,12 +134,12 @@ addPhiCtNablas nablas ct = addPhiCtsNablas nablas (unitBag ct) -- | 'addPmCtsNablas' for a single 'PmCt', but first represent the Id in each Nabla. addPhiCtNablasWithRep :: Nablas -> Id -> (ClassId -> PhiCt) -> DsM Nablas addPhiCtNablasWithRep nablas x ctf - = liftNablasM (\d -> let (xi, d') = representId x d in addPhiCts d' (unitBag (ctf xi))) nablas + = liftNablasM (\d -> do Just (xi, d') <- runMaybeT (representId x d); addPhiCts d' (unitBag (ctf xi))) nablas -- | Represent all Id in each Nabla. addPhiCtNablasWithReps :: Nablas -> [Id] -> ([ClassId] -> PhiCt) -> DsM Nablas addPhiCtNablasWithReps nablas xs ctf - = liftNablasM (\d -> let (xsi, d') = representIds xs d in addPhiCts d' (unitBag (ctf xsi))) nablas + = liftNablasM (\d -> do Just (xsi, d') <- runMaybeT (representIds xs d); addPhiCts d' (unitBag (ctf xsi))) nablas liftNablasM :: Monad m => (Nabla -> m (Maybe Nabla)) -> Nablas -> m Nablas liftNablasM f (MkNablas ds) = MkNablas . catBagMaybes <$> (traverse f ds) @@ -575,9 +585,7 @@ where you can find the solution in a perhaps more digestible format. -- | A high-level pattern-match constraint. Corresponds to φ from Figure 3 of -- the LYG paper. --- ROMES:TODO: Ultimately, all these Ids could be replaced by e-class ids which --- are generated during desugaring, but there are some details to it --- (propagating the e-graphs in which these e-classes were created) +-- Additionally, we use class-ids instead of ids (note... TODO) data PhiCt = PhiTyCt !PredType -- ^ A type constraint "T ~ U". @@ -708,25 +716,30 @@ filterUnliftedFields nabla con args = -- surely diverges. Quite similar to 'addConCt', only that it only cares about -- ⊥. addBotCt :: Nabla -> ClassId -> MaybeT DsM Nabla -addBotCt nabla x = updateVarInfo x go nabla - where - go :: VarInfo -> MaybeT DsM VarInfo - go vi at VI { vi_bot = bot } - = case bot of - IsNotBot -> mzero -- There was x ≁ ⊥. Contradiction! - IsBot -> return vi -- There already is x ~ ⊥. Nothing left to do - MaybeBot -- We add x ~ ⊥ - | definitelyUnliftedType (eclassType x nabla) - -- Case (3) in Note [Strict fields and variables of unlifted type] - -> mzero -- unlifted vars can never be ⊥ - | otherwise - -> do - return vi{ vi_bot = IsBot } +addBotCt nabla x = updateVarInfo x mergeBotCt nabla + +-- ROMES:TODO: we should only add bot constraints to the "underlying" match-id of newtypes... +mergeBotCt :: VarInfo -> MaybeT DsM VarInfo +mergeBotCt vi at VI { vi_bot = bot } +-- oops, we should be looking up VarInfo NT here too. + -- ROMES:TODO:!!!! let (y, vi at VI { vi_bot = bot }) = lookupVarInfoNT (nabla_tm_st nabla) x + = case bot of + IsNotBot -> mzero -- There was x ≁ ⊥. Contradiction! + IsBot -> return vi -- There already is x ~ ⊥. Nothing left to do + MaybeBot -- We add x ~ ⊥ + | definitelyUnliftedType (idType (vi_id vi)) + -- Case (3) in Note [Strict fields and variables of unlifted type] + -> mzero -- unlifted vars can never be ⊥ + | otherwise + -> do + return vi{ vi_bot = IsBot } -- | Adds the constraint @x ~/ ⊥@ to 'Nabla'. Quite similar to 'addNotConCt', -- but only cares for the ⊥ "constructor". addNotBotCt :: Nabla -> ClassId -> MaybeT DsM Nabla addNotBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts=env} } x = do + -- This means we only add not-bottom constraints to the true match-id of newtype constructors (ie skipping NT classes) + -- This is the only occurrence of lookupVarInfoNT. let (yid, vi at VI { vi_bot = bot }) = lookupVarInfoNT ts x case bot of IsBot -> mzero -- There was x ~ ⊥. Contradiction! @@ -745,40 +758,40 @@ addNotConCt :: Nabla -> ClassId -> PmAltCon -> MaybeT DsM Nabla addNotConCt _ _ (PmAltConLike (RealDataCon dc)) | isNewDataCon dc = mzero -- (3) in Note [Coverage checking Newtype matches] addNotConCt nabla x nalt = do - (mb_mark_dirty, nabla') <- trvVarInfo go nabla x + (mb_mark_dirty, nabla') <- trvVarInfo (mergeNotConCt nalt) nabla x pure $ case mb_mark_dirty of True -> markDirty x nabla' False -> nabla' - where - -- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction, - -- otherwise return updated entry and `Just x'` if `x` should be marked dirty, - -- where `x'` is the representative of `x`. - go :: VarInfo -> MaybeT DsM (Bool, VarInfo) - go vi@(VI _x' pos neg _ rcm) = do - -- 1. Bail out quickly when nalt contradicts a solution - let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal - guard (not (any (contradicts nalt) pos)) - -- 2. Only record the new fact when it's not already implied by one of the - -- solutions - let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint - let neg' - | any (implies nalt) pos = neg - -- See Note [Completeness checking with required Thetas] - | hasRequiredTheta nalt = neg - | otherwise = extendPmAltConSet neg nalt - massert (isPmAltConMatchStrict nalt) - let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot } - -- 3. Make sure there's at least one other possible constructor - mb_rcm' <- lift (markMatched nalt rcm) - pure $ case mb_rcm' of - -- If nalt could be removed from a COMPLETE set, we'll get back Just and - -- have to mark x dirty, by returning Just x'. - Just rcm' -> (True, vi'{ vi_rcm = rcm' }) - -- Otherwise, nalt didn't occur in any residual COMPLETE set and we - -- don't have to mark it dirty. So we return Nothing, which in the case - -- above would have compromised precision. - -- See Note [Shortcutting the inhabitation test], grep for T17836. - Nothing -> (False, vi') + +-- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction, +-- otherwise return updated entry and `Just x'` if `x` should be marked dirty, +-- where `x'` is the representative of `x`. +mergeNotConCt :: PmAltCon -> VarInfo -> MaybeT DsM (Bool, VarInfo) +mergeNotConCt nalt vi@(VI _x' pos neg _ rcm) = do + -- 1. Bail out quickly when nalt contradicts a solution + let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal + guard (not (any (contradicts nalt) pos)) + -- 2. Only record the new fact when it's not already implied by one of the + -- solutions + let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint + let neg' + | any (implies nalt) pos = neg + -- See Note [Completeness checking with required Thetas] + | hasRequiredTheta nalt = neg + | otherwise = extendPmAltConSet neg nalt + massert (isPmAltConMatchStrict nalt) + let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot } + -- 3. Make sure there's at least one other possible constructor + mb_rcm' <- lift (markMatched nalt rcm) + pure $ case mb_rcm' of + -- If nalt could be removed from a COMPLETE set, we'll get back Just and + -- have to mark x dirty, by returning Just x'. + Just rcm' -> (True, vi'{ vi_rcm = rcm' }) + -- Otherwise, nalt didn't occur in any residual COMPLETE set and we + -- don't have to mark it dirty. So we return Nothing, which in the case + -- above would have compromised precision. + -- See Note [Shortcutting the inhabitation test], grep for T17836. + Nothing -> (False, vi') hasRequiredTheta :: PmAltCon -> Bool hasRequiredTheta (PmAltConLike cl) = notNull req_theta @@ -793,9 +806,102 @@ hasRequiredTheta _ = False -- -- See Note [TmState invariants]. addConCt :: Nabla -> ClassId -> PmAltCon -> [TyVar] -> [ClassId] -> MaybeT DsM Nabla -addConCt nabla at MkNabla{ nabla_tm_st = ts } x alt tvs args = do - -- ROMES:TODO: Also looks like a function on varinfo (adjust) - let vi@(VI _ pos neg bot _) = lookupVarInfo ts x +addConCt (MkNabla tyst ts at TmSt{ts_facts=egr0}) _x alt tvs args = do + (((), egr), tyst') <- (`runStateT` tyst) $ EGM.runEGraphMT egr0 $ do + -- ROMES:TODO: using the conLikeName will not allow us to match the pattern + -- constructors with core expressions that use the same constructor? + -- ROMES:TODO: what about using Names for comparison? Since this is only for equality purposes... + -- It makes it possible to use the ConLikeName as the FreeVar Name + -- Better thing is to just call the correct builder, using Ids. + case alt of + PmAltLit _ -> + -- We don't need to do anything in the case of PmAltLit. + -- The Constructor information is recorded in the positive info e-class + -- it is represented in, so when we merge we take care of handling this + -- equality right. + -- If we did this even more ideally, we'd just represent PmAltLit in the e-graph and it would fail on merge without having to edit the e-class. + -- Wait, is it even safe to edit the e-class? Won't that *NOT* trigger the merging?? + -- Here I suppose we're creating the e-class. So we can add information at will. When we eventually merge this class with another one, we can do things. + -- But we could definitely check whether the information we're adding isn't colliding with the existing one. + return () + PmAltConLike conLike -> do + -- We must represent the constructor application in the e-graph to make + -- sure the children are recursively merged against other children of + -- other constructors represneted in the same e-class. + -- We need to represent the constructor correctly to ensure existing + -- constructors match or not the new one + -- dsHsConLike basically implements the logic we want. + -- ROMES:TODO: Nevermind, the dsHsConLike won't work because we want to + -- talk about pattern synonyms in their "matching" form, and converting + -- them with dsHsConLike assumes they are used as a constructor, + -- meaning we will fail for unidirectional patterns + desugaredCon <- lift . lift . lift $ ds_hs_con_like_pat conLike -- DsM action to desugar the conlike into the expression we'll represent for this constructor + conLikeId <- StateT $ representCoreExprEgr desugaredCon + tvs' <- mapM (EGM.addM . EG.Node . TypeF . DBT . deBruijnize . TyVarTy) tvs + _ <- foldlM (\acc i -> EGM.addM (EG.Node $ AppF acc i)) conLikeId (tvs' ++ args) + return () + where + -- do something cleaner... + -- inlined dsHsConLike but use patSynMatcher instead of patSynBuilder + ds_hs_con_like_pat :: ConLike -> DsM CoreExpr + ds_hs_con_like_pat (RealDataCon dc) + = return (varToCoreExpr (dataConWrapId dc)) + ds_hs_con_like_pat (PatSynCon ps) + | (builder_name, _, add_void) <- patSynMatcher ps + = do { builder_id <- dsLookupGlobalId builder_name + ; return (if add_void + then mkCoreApp (text "dsConLike" <+> ppr ps) + (Var builder_id) unboxedUnitExpr + else Var builder_id) } + + -- Do (2) in Note [Coverage checking Newtype matches] + -- ROMES:TODO: SOMEWHERE <-------------------------------- this is likely the next thing to do! + -- case (alt, args) of + -- (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> + return (MkNabla tyst' ts{ts_facts=egr}) + + + -- case find ((== Equal) . eqPmAltCon alt . paca_con) pos of + -- Just (PACA _con other_tvs other_args) -> do + -- -- We must unify existentially bound ty vars and arguments! + -- -- (We may be able to do this eventually through e-graph analysis joining, but for now we keep it separate.) + -- let ty_cts = equateTys (map mkTyVarTy tvs) (map mkTyVarTy other_tvs) + -- nabla' <- MaybeT $ addPhiCts nabla (listToBag ty_cts) + -- let add_var_ct nabla (a, b) = addVarCt nabla a b + -- foldlM add_var_ct nabla' $ zipEqual "addConCt" args other_args + -- Nothing -> do + -- -- Instead of adding all the pos info to the pos info we should instead + -- -- just represent all Con Cts as e-graph nodes, which will handle + -- -- automatically all recursive merging of children ty vars and terms. + -- -- That means we only need to record the said pos constructor in the var + -- -- info, since the children and ty vars are stored in the e-graph. + -- let pos' = PACA alt tvs args : pos + -- let nabla_with bot' = + -- nabla{nabla_tm_st = ts{ts_facts = ts_facts ts & _class x ._data .~ vi{vi_pos = pos', vi_bot = bot'}}} + -- -- Do (2) in Note [Coverage checking Newtype matches] + -- case (alt, args) of + -- (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> + -- case bot of + -- MaybeBot -> pure (nabla_with MaybeBot) + -- IsBot -> addBotCt (nabla_with MaybeBot) y + -- IsNotBot -> addNotBotCt (nabla_with MaybeBot) y + -- _ -> assert (isPmAltConMatchStrict alt ) + -- pure (nabla_with IsNotBot) -- strict match ==> not ⊥ + +-- | Extend the 'VarInfo' of x with the @x ~ K tvs args ts@ constraint. +-- @mergeConCt x K tvs args ts@ extends the 'VarInfo' with a solution TODO +-- @x :-> (K, tvs, args)@ if compatible with the negative and positive info we +-- have on @x@, reject (@Nothing@) otherwise. +-- +-- The children args are automatically merged by congruence (see that new note) TODO +-- +-- See Note [TmState invariants]?? +mergeConCt :: VarInfo -- ^ The 'VarInfo' of @x@ into which we're merging the ConCt. + -> PmAltCon -- ^ The constructor @K@ + -> [TyVar] -- ^ The type vars of the constructor + -> [ClassId] -- ^ The constructor arguments (unused for merging, but stored in the PACA) + -> StateT TyState (MaybeT DsM) VarInfo -- ^ We also track the type information to merge constructor existential variables against. +mergeConCt vi@(VI _ pos neg bot _) alt tvs args = StateT $ \tyst -> do -- First try to refute with a negative fact guard (not (elemPmAltConSet alt neg)) -- Then see if any of the other solutions (remember: each of them is an @@ -805,25 +911,36 @@ addConCt nabla at MkNabla{ nabla_tm_st = ts } x alt tvs args = do -- Now we should be good! Add (alt, tvs, args) as a possible solution, or -- refine an existing one case find ((== Equal) . eqPmAltCon alt . paca_con) pos of - Just (PACA _con other_tvs other_args) -> do + Just (PACA _con other_tvs _other_args) -> do -- We must unify existentially bound ty vars and arguments! + -- But this is already done automatically by representing K in + -- the e-class...! all equivalent things will be merged. let ty_cts = equateTys (map mkTyVarTy tvs) (map mkTyVarTy other_tvs) - nabla' <- MaybeT $ addPhiCts nabla (listToBag ty_cts) - let add_var_ct nabla (a, b) = addVarCt nabla a b - foldlM add_var_ct nabla' $ zipEqual "addConCt" args other_args + tyst' <- MaybeT (tyOracle tyst (listToBag $ map (\(PhiTyCt pred) -> pred) ty_cts)) + return (vi, tyst') -- All good, and we get no new information. Nothing -> do let pos' = PACA alt tvs args : pos - let nabla_with bot' = - nabla{nabla_tm_st = ts{ts_facts = ts_facts ts & _class x ._data .~ vi{vi_pos = pos', vi_bot = bot'}}} + let varinfo_with bot' = (vi{vi_pos = pos', vi_bot = bot'}, tyst) -- Do (2) in Note [Coverage checking Newtype matches] - case (alt, args) of - (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> + case alt of + -- Now (2) is done here and elsewhere, when we're merging VarInfos we + -- only have to worry about merging them into a valid VarInfo. (In the + -- place where the Newtype will be merged into the @x@ e-class we must + -- take this care. Probably addConCt) + PmAltConLike (RealDataCon dc) | isNewDataCon dc -> case bot of - MaybeBot -> pure (nabla_with MaybeBot) - IsBot -> addBotCt (nabla_with MaybeBot) y - IsNotBot -> addNotBotCt (nabla_with MaybeBot) y - _ -> assert (isPmAltConMatchStrict alt ) - pure (nabla_with IsNotBot) -- strict match ==> not ⊥ + MaybeBot -> pure (varinfo_with MaybeBot) + IsBot -> pure (varinfo_with MaybeBot) + IsNotBot -> pure (varinfo_with MaybeBot) + -- ROMES:TODO: Still have to do the two cases that we used to have here: + -- Likely in addConCt + -- Or better, in the analysis merge function, if we're merging a Newtype + -- constructor application, we should do something like this... + -- IsBot -> addBotCt (nabla_with MaybeBot) y + -- IsNotBot -> addNotBotCt (nabla_with MaybeBot) y + _ -> assert (isPmAltConMatchStrict alt) + pure (varinfo_with IsNotBot) -- strict match ==> not ⊥ + equateTys :: [Type] -> [Type] -> [PhiCt] equateTys ts us = @@ -844,44 +961,15 @@ equateTys ts us = -- See Note [TmState invariants]. addVarCt :: Nabla -> ClassId -> ClassId -> MaybeT DsM Nabla -- This is where equality-graphs really come into play. -addVarCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts = env } } x y = - -- ROMES:TODO: equate auxiliary var that finds both vars, and lookups up the domain associated. However, I think we no longer should have Just/Nothing but rather always store emptyVarInfo for new e-nodes - -- equate should also update e-graph, basically re-implement "equateUSDFM" in terms of the e-graph, or inline it or so - case equate env x y of - -- Add the constraints we had for x to y - -- See Note (TODO) Joining e-classes PMC] todo mention from joinA - -- Now, here's a really tricky bit (TODO Write note, is it the one above?) - -- Bc the joinA operation is unlawful, and because the makeA operation for - -- expressions is also unlawful (sets the type to ()::(), mostly out of - -- laziness, we could reconstruct the type if we wanted), - -- Then we must make sure that when we're "completing the joinA manually", - -- We *also update the type* (WTF1). - -- This is because every e-class should always have a match-var first, which will always have a type, and it should appear on "the left" - -- We also rebuild here, we did just merge two things. TODO: Where and when exactly should we merge? - (vi_x, env') -> do - let nabla_equated = nabla{ nabla_tm_st = ts{ts_facts = env'} } - -- and then gradually merge every positive fact we have on x into y - let add_pos nabla (PACA cl tvs args) = addConCt nabla y cl tvs args - nabla_pos <- foldlM add_pos nabla_equated (vi_pos vi_x) - -- Do the same for negative info - let add_neg nabla nalt = addNotConCt nabla y nalt - foldlM add_neg nabla_pos (pmAltConSetElems (vi_neg vi_x)) - where - -- @equate env x y@ makes @x@ and @y@ point to the same entry, - -- thereby merging @x@'s class with @y@'s. - -- If both @x@ and @y@ are in the domain of the map, then @y@'s entry will be - -- chosen as the new entry and @x@'s old entry will be returned. - -- - -- Examples in terms of the model (see 'UniqSDFM'): - -- >>> equate [] u1 u2 == (Nothing, [({u1,u2}, Nothing)]) - -- >>> equate [({u1,u3}, Just ele1)] u3 u4 == (Nothing, [({u1,u3,u4}, Just ele1)]) - -- >>> equate [({u1,u3}, Just ele1)] u4 u3 == (Nothing, [({u1,u3,u4}, Just ele1)]) - -- >>> equate [({u1,u3}, Just ele1), ({u2}, Just ele2)] u3 u2 == (Just ele1, [({u2,u1,u3}, Just ele2)]) - equate :: TmEGraph -> ClassId -> ClassId -> (VarInfo, TmEGraph) - equate eg x y = let (_, eg') = EG.merge x y eg - in (eg ^. _class x ._data, EG.rebuild eg') - -- Note: lookup in @eg@, not @eg'@, because we want to return x's data before the merge. - +addVarCt (MkNabla tyst ts at TmSt{ts_facts = egr}) x y = do + -- @merge env x y@ makes @x@ and @y@ point to the same entry, + -- thereby merging @x@'s class with @y@'s. + (egr', tyst') <- (`runStateT` tyst) $ do + -- Merging will also merge all the constraints from x with y + -- However, doing so + (_, egr') <- EG.mergeM x y egr + EG.rebuildM egr' + return (MkNabla tyst' ts{ts_facts=egr'}) -- | Inspects a 'PmCoreCt' @let x = e@ by recording constraints for @x@ based -- on the shape of the 'CoreExpr' @e at . Examples: @@ -936,8 +1024,9 @@ addCoreCt nabla x e = do -- ROMES:TODO: Can we fix this more easily with e-graphs? | Var y <- e, Nothing <- isDataConId_maybe (eclassMatchId x nabla') -- We don't consider DataCons flexible variables - -> modifyT (\nabla -> let (yid, nabla') = representId y nabla - in lift (tracePm "foundIdVar:" (ppr y <+> text "->>>" <+> ppr yid)) >> addVarCt nabla' x yid) + -> modifyT (\nabla -> do (yid, nabla') <- representId y nabla + lift (tracePm "foundIdVar:" (ppr y <+> text "->>>" <+> ppr yid)) + addVarCt nabla' x yid) | otherwise -- Any other expression. Try to find other uses of a semantically -- equivalent expression and represent them by the same variable! @@ -957,7 +1046,7 @@ addCoreCt nabla x e = do -- @x ~ y at . equate_with_similar_expr :: ClassId -> CoreExpr -> StateT Nabla (MaybeT DsM) () equate_with_similar_expr _x e = do - rep <- StateT $ \nabla -> pure (representCoreExpr nabla e) + rep <- StateT $ (`representCoreExpr` e) -- Note that @rep == x@ if we encountered @e@ for the first time. -- ROMES:TODO: I don't think we need to do the following anymore, represent should directly do so in the right e-class (if rebuilt) @@ -1017,9 +1106,13 @@ modifyT f = StateT $ fmap ((,) ()) . f -- Which is the @x@ of a @let x = e'@ constraint (with @e@ semantically -- equivalent to @e'@) we encountered earlier, or a fresh identifier if -- there weren't any such constraints. -representCoreExpr :: Nabla -> CoreExpr -> (ClassId, Nabla) -representCoreExpr nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts = egraph } } e = - second (\g -> nabla{nabla_tm_st = ts{ts_facts = EG.rebuild g}}) $ representCoreExprEgr (makeDictsCoherent e) egraph +representCoreExpr :: Nabla -> CoreExpr -> MaybeT DsM (ClassId, Nabla) +representCoreExpr (MkNabla tyst ts at TmSt{ ts_facts = egraph }) e = do + ((xid, egr''), tysty') <- (`runStateT` tyst) $ do + (xid, egr') <- representCoreExprEgr (makeDictsCoherent e) egraph + egr'' <- EG.rebuildM egr' + return (xid, egr'') + return (xid, MkNabla tysty' ts{ts_facts = egr''}) -- Use a key in which dictionaries for the same type become equal. -- See Note [Unique dictionaries in the TmOracle CoreMap] @@ -1117,7 +1210,8 @@ In the end, replacing dictionaries with an error value in the pattern-match checker was the most self-contained, although we might want to revisit once we implement a more robust approach to computing equality in the pattern-match checker (see #19272). -ROMES:TODO: I don't think e-graphs avoid this situation, because the names of the binders will still differ (although the Eq instance could take this into account?) + +ROMES:TODO: Looks like a good idea, we could try to do this now. -} {- Note [The Pos/Neg invariant] @@ -2168,3 +2262,91 @@ mkPmMatchId ty (MkNabla tyst ts at TmSt{ts_facts = egr}) = do return (xid, MkNabla tyst ts{ts_facts=egr'}) {-# NOINLINE mkPmMatchId #-} -- We'll CPR deeply, that should be enough +-- There are too many cycles for this to be in Solver.Types... +-- We need the TyState to check insoluble constraints while merging VarInfos +instance Analysis (StateT TyState (MaybeT DsM)) VarInfo ExprF where + {-# INLINE makeA #-} + + -- When an e-class is created for a variable, we create an VarInfo from it. + -- It doesn't matter if this variable is bound or free, since it's the first + -- variable in this e-class (and all others would have to be equivalent to + -- it) + -- + -- Also, the Eq instance for DeBruijn Vars will ensure that two free + -- variables with the same Id are equal and so they will be represented in + -- the same e-class + makeA (FreeVarF x) = pure $ emptyVarInfo x + makeA _ = pure $ emptyVarInfo unitDataConId + -- makeA _ = Nothing + -- Always start with Nothing, and add things as we go? + + -- romes: so currently, variables are joined in 'addVarCt' manually by getting the old value of $x$ and assuming the value of $y$ was chosen. + -- That's obviously bad now, it'd be much more clearer to do it here. It's just the nabla threading that's more trouble + -- Hacks hacks hacks + -- Do some "obvious" things in this merge, despite keeping all the nuanced + -- joining operations in addVarCt. Some part of them will be redundant, but + -- if we don't do the simple things here we might end up losing information + -- when merging things through the e-graph outside of 'addVarCt' + +-- I think we really need effects, because the operation is only well-defined +-- since it can fail when it is conflicting +-- and that would allow us to do the merge procedure correcly here instead of in addVarCt +-- we may be able to have Analysis (Effect VarInfo) (...) + -- joinA Nothing Nothing = Nothing + -- joinA Nothing (Just b) = Just b + -- joinA (Just a) Nothing = Just a + -- joinA (Just a) (Just b) + + -- Add the constraints we had for x to y + joinA vi_x vi_y = do + -- Gradually merge every positive fact we have on x into y + -- The args are merged by congruence, since we represent the + -- constructor in the e-graph in addConCt. + let add_pos y (PACA cl tvs args) = mergeConCt y cl tvs args + vi_res <- foldlM add_pos vi_y (vi_pos vi_x) + + -- Do the same for negative info + let add_neg vi nalt = lift $ snd <$> mergeNotConCt nalt vi + foldlM add_neg vi_res (pmAltConSetElems (vi_neg vi_x)) + +{- +Note [mergeXXXCt vs addXXXCt in the Pmc Solver] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- mergeXXXCt handles merging information into some VarInfo +- addXXXCt handles adding information into the nablas by representing + expressions in the e-graph which will end up calling out to mergeXXXCt to merge + (congruently) equivalent things + +-} + +-- | Represents a match-id in 'Nablas' +representIdNablas :: Id -> Nablas -> MaybeT DsM Nablas +representIdNablas x (MkNablas nbs) = MkNablas <$> mapBagM (fmap snd . representId x) nbs + +representIdsNablas :: [Id] -> Nablas -> MaybeT DsM Nablas +representIdsNablas xs = execStateT (mapM (\x -> StateT (fmap (((),)) . representIdNablas x)) xs) + +-- Are these even used? don't we always use the ones above? +-- | Like 'representId' but for a single Nabla +representId :: Id -> Nabla -> MaybeT DsM (ClassId, Nabla) +representId x (MkNabla tyst tmst at TmSt{ts_facts=eg0, ts_reps=idmp}) + = do + ((xid, tmst'),tyst') <- (`runStateT` tyst) $ + case lookupVarEnv idmp x of + -- The reason why we can't use an empty new class is that we don't account for the IdMap in the 'representCoreExprEgr' + -- In particular, if we represent "reverse @a xs" in the e-graph, the + -- node in which "xs" will be represented won't match the e-class id + -- representing "xs", because that class doesn't contain "VarF xs" + -- (but at least we can still mkMatchIds without storing the VarF for that one) + -- Nothing -> case EG.newEClass (emptyVarInfo x) eg0 of + Nothing -> do + (xid, eg1) <- EG.addM (EG.Node (FreeVarF x)) eg0 + eg2 <- EG.rebuildM eg1 + return (xid, tmst{ts_facts=eg2, ts_reps=extendVarEnv idmp x xid}) + Just xid -> return (xid, tmst) + return (xid, MkNabla tyst' tmst') + +representIds :: [Id] -> Nabla -> MaybeT DsM ([ClassId], Nabla) +representIds xs = runStateT (mapM (StateT . representId) xs) + ===================================== compiler/GHC/HsToCore/Pmc/Solver/Types.hs ===================================== @@ -24,7 +24,6 @@ module GHC.HsToCore.Pmc.Solver.Types ( -- ** Looking up 'VarInfo' lookupVarInfo, lookupVarInfoNT, trvVarInfo, emptyVarInfo, - representId, representIds, representIdNablas, representIdsNablas, lookupMatchIdMap, -- ** Caching residual COMPLETE sets @@ -85,14 +84,12 @@ import GHC.Real (Ratio(..)) import qualified Data.Semigroup as Semi import Data.Functor.Compose -import Data.Equality.Analysis (Analysis(..)) import Data.Equality.Graph (EGraph, ClassId) import Data.Equality.Graph.Lens import qualified Data.Equality.Graph as EG import Data.IntSet (IntSet) import qualified Data.IntSet as IS (empty) import Data.Bifunctor (second) -import Control.Monad.Trans.State (runState, state, execState) -- import GHC.Driver.Ppr @@ -233,7 +230,9 @@ data PmAltConApp = PACA { paca_con :: !PmAltCon , paca_tvs :: ![TyVar] - , paca_ids :: ![ClassId] + , paca_ids :: ![ClassId] -- TODO(talk about merging things by congruence in + -- the e-graph) ... the merging is done automatically when the pms are + -- represented, but we keep these still for error reporting and what not... } -- | See 'vi_bot'. @@ -849,101 +848,9 @@ type TmEGraph = EGraph VarInfo CoreExprF instance Show VarInfo where show = showPprUnsafe . ppr --- | Represents a match-id in 'Nablas' -representIdNablas :: Id -> Nablas -> Nablas -representIdNablas x (MkNablas nbs) = MkNablas $ mapBag (snd . representId x) nbs - -representIdsNablas :: [Id] -> Nablas -> Nablas -representIdsNablas xs = execState (mapM (\x -> state (((),) . representIdNablas x)) xs) - --- Are these even used? don't we always use the ones above? --- | Like 'representId' but for a single Nabla -representId :: Id -> Nabla -> (ClassId, Nabla) -representId x (MkNabla tyst tmst at TmSt{ts_facts=eg0, ts_reps=idmp}) - = case lookupVarEnv idmp x of - -- The reason why we can't use an empty new class is that we don't account for the IdMap in the 'representCoreExprEgr' - -- In particular, if we represent "reverse @a xs" in the e-graph, the - -- node in which "xs" will be represented won't match the e-class id - -- representing "xs", because that class doesn't contain "VarF xs" - -- (but at least we can still mkMatchIds without storing the VarF for that one) - -- Nothing -> case EG.newEClass (emptyVarInfo x) eg0 of - Nothing -> case EG.add (EG.Node (FreeVarF x)) eg0 of - (xid, eg1) -> (xid, MkNabla tyst tmst{ts_facts=EG.rebuild eg1, ts_reps=extendVarEnv idmp x xid}) - Just xid -> (xid, MkNabla tyst tmst) - -representIds :: [Id] -> Nabla -> ([ClassId], Nabla) -representIds xs = runState (mapM (state . representId) xs) - -- | This instance is seriously wrong for general purpose, it's just required for instancing Analysis. -- There ought to be a better way. -- ROMES:TODO: instance Eq VarInfo where (==) a b = vi_id a == vi_id b -instance Analysis VarInfo CoreExprF where - {-# INLINE makeA #-} - {-# INLINE joinA #-} - - -- When an e-class is created for a variable, we create an VarInfo from it. - -- It doesn't matter if this variable is bound or free, since it's the first - -- variable in this e-class (and all others would have to be equivalent to - -- it) - -- - -- Also, the Eq instance for DeBruijn Vars will ensure that two free - -- variables with the same Id are equal and so they will be represented in - -- the same e-class - makeA (FreeVarF x) = emptyVarInfo x - makeA _ = emptyVarInfo unitDataConId - -- makeA _ = Nothing - -- Always start with Nothing, and add things as we go? - - -- romes: so currently, variables are joined in 'addVarCt' manually by getting the old value of $x$ and assuming the value of $y$ was chosen. - -- That's obviously bad now, it'd be much more clearer to do it here. It's just the nabla threading that's more trouble - -- Hacks hacks hacks - -- Do some "obvious" things in this merge, despite keeping all the nuanced - -- joining operations in addVarCt. Some part of them will be redundant, but - -- if we don't do the simple things here we might end up losing information - -- when merging things through the e-graph outside of 'addVarCt' - --- I think we really need effects, because the operation is only well-defined --- since it can fail when it is conflicting --- and that would allow us to do the merge procedure correcly here instead of in addVarCt --- we may be able to have Analysis (Effect VarInfo) (...) - -- joinA Nothing Nothing = Nothing - -- joinA Nothing (Just b) = Just b - -- joinA (Just a) Nothing = Just a - -- joinA (Just a) (Just b) - joinA a b - = b{ vi_id = if vi_id b == unitDataConId && vi_id a /= unitDataConId then vi_id a else vi_id b - , vi_pos = case (vi_pos a, vi_pos b) of - ([], []) -> [] - ([], x) -> x - (x, []) -> x - (_x, y) -> y -- keep right - , vi_neg = foldr (flip extendPmAltConSet) (vi_neg b) (pmAltConSetElems $ vi_neg a) - , vi_bot = case (vi_bot a, vi_bot b) of - (IsBot,IsBot) -> IsBot - (IsBot,IsNotBot) -> IsNotBot -- keep b, achhhhh - (IsBot,MaybeBot) -> IsBot - (IsNotBot,IsBot) -> IsBot -- keep b, achhhhh - (IsNotBot,IsNotBot) -> IsNotBot - (IsNotBot,MaybeBot) -> IsNotBot - (MaybeBot, IsBot) -> IsBot - (MaybeBot, IsNotBot) -> IsNotBot - (MaybeBot, MaybeBot) -> MaybeBot - , vi_rcm = case (vi_rcm a, vi_rcm b) of - (RCM Nothing Nothing,RCM a b) -> RCM a b - (RCM Nothing (Just a),RCM Nothing Nothing) -> RCM Nothing (Just a) - (RCM Nothing (Just _a),RCM Nothing (Just b)) -> RCM Nothing (Just b) -- keep right - (RCM Nothing (Just a),RCM (Just b) Nothing) -> RCM (Just b) (Just a) - (RCM Nothing (Just _a),RCM (Just b) (Just c)) -> RCM (Just b) (Just c) -- keep right - (RCM (Just a) Nothing,RCM Nothing Nothing) -> RCM (Just a) Nothing - (RCM (Just a) Nothing,RCM Nothing (Just b)) -> RCM (Just a) (Just b) - (RCM (Just _a) Nothing,RCM (Just b) Nothing) -> RCM (Just b) Nothing -- keep right - (RCM (Just _a) Nothing,RCM (Just b) (Just c)) -> RCM (Just b) (Just c) - (RCM (Just a) (Just b),RCM Nothing Nothing) -> RCM (Just a) (Just b) - (RCM (Just a) (Just _b),RCM Nothing (Just c)) -> RCM (Just a) (Just c) - (RCM (Just _a) (Just b),RCM (Just c) Nothing) -> RCM (Just c) (Just b) - (RCM (Just _a) (Just _b),RCM (Just c) (Just d)) -> RCM (Just c) (Just d) - -- we could also have _ _, (Just c) (Just d) -> (Just c, Just d) - } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/753bd0e5062261c3a2a1c14026f0ecc485ad0004...5ec798cbd6345825b728362cb6937a7aac1e6268 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/753bd0e5062261c3a2a1c14026f0ecc485ad0004...5ec798cbd6345825b728362cb6937a7aac1e6268 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 18:22:34 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 13 Oct 2023 14:22:34 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Fix restarts in .ghcid Message-ID: <65298aeab973c_24a445303fb38c403374@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5ad1de0b by Sebastian Graf at 2023-10-13T14:21:52-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - f85c0106 by Sebastian Graf at 2023-10-13T14:21:52-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - b82b20ee by Matthew Pickering at 2023-10-13T14:21:53-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - 19e8ed58 by Sylvain Henry at 2023-10-13T14:22:05-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - 6bf55adb by Sylvain Henry at 2023-10-13T14:22:05-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - ea56c981 by Sylvain Henry at 2023-10-13T14:22:05-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - d8fa5a8c by Ilias Tsitsimpis at 2023-10-13T14:22:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 7e4debb9 by John Ericson at 2023-10-13T14:22:07-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. - - - - - 4232b188 by John Ericson at 2023-10-13T14:22:07-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 22 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - configure.ac - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/cfg/system.config.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== configure.ac ===================================== @@ -1069,7 +1069,6 @@ AC_CONFIG_FILES( hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - docs/users_guide/ghc_config.py distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/cfg/system.config.in ===================================== @@ -34,6 +34,9 @@ python = @PythonCmd@ cc-llvm-backend = @CcLlvmBackend@ +llvm-min-version = @LlvmMinVersion@ +llvm-max-version = @LlvmMaxVersion@ + # Build options: #=============== ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -49,6 +49,8 @@ data Setting = CursesIncludeDir | GhcPatchLevel | GhcVersion | GhcSourcePath + | LlvmMinVersion + | LlvmMaxVersion | GmpIncludeDir | GmpLibDir | IconvIncludeDir @@ -103,6 +105,8 @@ setting key = lookupSystemConfig $ case key of GhcPatchLevel -> "ghc-patch-level" GhcVersion -> "ghc-version" GhcSourcePath -> "ghc-source-path" + LlvmMinVersion -> "llvm-min-version" + LlvmMaxVersion -> "llvm-max-version" GmpIncludeDir -> "gmp-include-dir" GmpLibDir -> "gmp-lib-dir" IconvIncludeDir -> "iconv-include-dir" ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -324,7 +324,12 @@ templateRules = do templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions templateRule "docs/index.html" $ packageVersions - templateRule "docs/users_guide/ghc_config.py" $ packageUnitIds Stage1 + templateRule "docs/users_guide/ghc_config.py" $ mconcat + [ projectVersion + , packageUnitIds Stage1 + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + ] -- Generators ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b60fa19354638c0321002a47a29b0c15598242e2...4232b1889ec1a9cd3d64ae35f309083714e3fbd5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b60fa19354638c0321002a47a29b0c15598242e2...4232b1889ec1a9cd3d64ae35f309083714e3fbd5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 21:03:56 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 13 Oct 2023 17:03:56 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Fix restarts in .ghcid Message-ID: <6529b0bce41b1_24a445340e5ae0454724@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8e181a29 by Sebastian Graf at 2023-10-13T17:02:46-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 76118156 by Sebastian Graf at 2023-10-13T17:02:46-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - c8e01f7b by Matthew Pickering at 2023-10-13T17:02:47-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - 112a6309 by Sylvain Henry at 2023-10-13T17:02:50-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - f191893d by Sylvain Henry at 2023-10-13T17:02:50-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - e2c44b03 by Sylvain Henry at 2023-10-13T17:02:50-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - c6d19a7e by Ilias Tsitsimpis at 2023-10-13T17:02:51-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 19e3f853 by John Ericson at 2023-10-13T17:02:52-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. - - - - - 87865796 by John Ericson at 2023-10-13T17:02:52-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 22 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - configure.ac - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/cfg/system.config.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== configure.ac ===================================== @@ -1069,7 +1069,6 @@ AC_CONFIG_FILES( hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - docs/users_guide/ghc_config.py distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/cfg/system.config.in ===================================== @@ -34,6 +34,9 @@ python = @PythonCmd@ cc-llvm-backend = @CcLlvmBackend@ +llvm-min-version = @LlvmMinVersion@ +llvm-max-version = @LlvmMaxVersion@ + # Build options: #=============== ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -49,6 +49,8 @@ data Setting = CursesIncludeDir | GhcPatchLevel | GhcVersion | GhcSourcePath + | LlvmMinVersion + | LlvmMaxVersion | GmpIncludeDir | GmpLibDir | IconvIncludeDir @@ -103,6 +105,8 @@ setting key = lookupSystemConfig $ case key of GhcPatchLevel -> "ghc-patch-level" GhcVersion -> "ghc-version" GhcSourcePath -> "ghc-source-path" + LlvmMinVersion -> "llvm-min-version" + LlvmMaxVersion -> "llvm-max-version" GmpIncludeDir -> "gmp-include-dir" GmpLibDir -> "gmp-lib-dir" IconvIncludeDir -> "iconv-include-dir" ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -324,7 +324,12 @@ templateRules = do templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions templateRule "docs/index.html" $ packageVersions - templateRule "docs/users_guide/ghc_config.py" $ packageUnitIds Stage1 + templateRule "docs/users_guide/ghc_config.py" $ mconcat + [ projectVersion + , packageUnitIds Stage1 + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + ] -- Generators ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4232b1889ec1a9cd3d64ae35f309083714e3fbd5...878657968995a8def25ac60569d07269840bf4fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4232b1889ec1a9cd3d64ae35f309083714e3fbd5...878657968995a8def25ac60569d07269840bf4fc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 21:40:39 2023 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Fri, 13 Oct 2023 17:40:39 -0400 Subject: [Git][ghc/ghc][wip/T22141] More robust checking for DataKinds Message-ID: <6529b957694c7_24a445350162bc45884f@gitlab.mail> Ryan Scott pushed to branch wip/T22141 at Glasgow Haskell Compiler / GHC Commits: ed5215cd by Ryan Scott at 2023-10-13T17:39:59-04:00 More robust checking for DataKinds As observed in #22141, GHC was not doing its due diligence in catching code that should require `DataKinds` in order to use. Most notably, it was allowing the use of arbitrary data types in kind contexts without `DataKinds`, e.g., ```hs data Vector :: Nat -> Type -> Type where ``` This patch revamps how GHC tracks `DataKinds`. The full specification is written out in the `DataKinds` section of the GHC User's Guide, and the implementation thereof is described in `Note [Checking for DataKinds]` in `GHC.Tc.Validity`. In brief: * We catch _type_-level `DataKinds` violations in the renamer. See `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in `GHC.Rename.Pat`. * We catch _kind_-level `DataKinds` violations in the typechecker, as this allows us to catch things that appear beneath type synonyms. (We do *not* want to do this in type-level contexts, as it is perfectly fine for a type synonym to mention something that requires DataKinds while still using the type synonym in a module that doesn't enable DataKinds.) See `checkValidType` in `GHC.Tc.Validity`. * There is now a single `TcRnDataKindsError` that classifies all manner of `DataKinds` violations, both in the renamer and the typechecker. The `NoDataKindsDC` error has been removed, as it has been subsumed by `TcRnDataKindsError`. * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit uses of data types at the kind level without `DataKinds`. Previously, `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`. Moreover, it thwarted the implementation of the `DataKinds` check in `checkValidType`, since we would expand `Constraint` (which was OK without `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and reject it. Now both are allowed. * I have added a flurry of additional test cases that test various corners of `DataKinds` checking. Fixes #22141. - - - - - 30 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Errors/Types/PromotionErr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Error/Codes.hs - docs/users_guide/9.10.1-notes.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/using-warnings.rst - testsuite/tests/polykinds/T7433.stderr - testsuite/tests/rename/should_fail/T22478e.hs - testsuite/tests/rename/should_fail/T22478e.stderr - + testsuite/tests/typecheck/should_compile/T22141a.hs - + testsuite/tests/typecheck/should_compile/T22141a.stderr - + testsuite/tests/typecheck/should_compile/T22141b.hs - + testsuite/tests/typecheck/should_compile/T22141b.stderr - + testsuite/tests/typecheck/should_compile/T22141c.hs - + testsuite/tests/typecheck/should_compile/T22141c.stderr - + testsuite/tests/typecheck/should_compile/T22141d.hs - + testsuite/tests/typecheck/should_compile/T22141d.stderr - + testsuite/tests/typecheck/should_compile/T22141e.hs - + testsuite/tests/typecheck/should_compile/T22141e.stderr - + testsuite/tests/typecheck/should_compile/T22141e_Aux.hs - + testsuite/tests/typecheck/should_compile/T22141f.hs - + testsuite/tests/typecheck/should_compile/T22141g.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed5215cd4cd2d3263e6c307c23d7d7dd9c2db6dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed5215cd4cd2d3263e6c307c23d7d7dd9c2db6dc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 23:32:58 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 13 Oct 2023 19:32:58 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/simpler-ghcversion.h Message-ID: <6529d3aaaf911_24a4453783327c4716bf@gitlab.mail> John Ericson pushed new branch wip/simpler-ghcversion.h at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/simpler-ghcversion.h You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 23:34:59 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 13 Oct 2023 19:34:59 -0400 Subject: [Git][ghc/ghc][wip/simpler-ghcversion.h] Generate `ghcversion.h` from a `.in` file Message-ID: <6529d4237fd90_24a44537a2e5cc473529@gitlab.mail> John Ericson pushed to branch wip/simpler-ghcversion.h at Glasgow Haskell Compiler / GHC Commits: 7a859daa by John Ericson at 2023-10-13T19:34:45-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. - - - - - 6 changed files: - configure.ac - rts/.gitignore - rts/configure.ac - rts/ghcversion.h.bottom → rts/ghcversion.h.in - − rts/ghcversion.h.top - rts/rts.cabal Changes: ===================================== configure.ac ===================================== @@ -68,21 +68,6 @@ FP_PROG_SORT dnl ---------------------------------------------------------- FP_SETUP_PROJECT_VERSION -dnl Don't use AC_DEFINE because it will make C-style comments invalid for -dnl Haskell. - -> rts/include/ghcversion.h - -cat rts/ghcversion.h.top >> rts/include/ghcversion.h - -echo "#define __GLASGOW_HASKELL__ ${ProjectVersionInt}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_FULL_VERSION__ \"${ProjectVersion}\"" >> rts/include/ghcversion.h -echo >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ ${ProjectPatchLevel1}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_PATCHLEVEL2__ ${ProjectPatchLevel2}" >> rts/include/ghcversion.h - -cat rts/ghcversion.h.bottom >> rts/include/ghcversion.h - # Hmmm, we fix the RPM release number to 1 here... Is this convenient? AC_SUBST([release], [1]) @@ -103,8 +88,12 @@ AC_PREREQ([2.69]) AC_CONFIG_HEADER(mk/config.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) -dnl manually outputted above, for reasons described there. -dnl AC_CONFIG_HEADER(rts/include/ghcversion.h) +dnl Don't use `AC_CONFIG_HEADER` because it will make C-style comments +dnl invalid for Haskell. +dnl +dnl RTS configure will copy resulting file into place, so `.in` file +dnl doesn't pollute the build. +AC_CONFIG_FILES(rts/ghcversion.h) # No, semi-sadly, we don't do `--srcdir'... if test x"$srcdir" != 'x.' ; then ===================================== rts/.gitignore ===================================== @@ -2,6 +2,7 @@ /dist/ /dist-*/ +/ghcversion.h /include/ghcversion.h /package.conf.inplace ===================================== rts/configure.ac ===================================== @@ -243,6 +243,16 @@ cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \ echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h ] +dnl ###################################################################### +dnl Generate ghcversion.h +dnl ###################################################################### + +[ +# Copy the file the top-level configure script created into place. We +# don't have the right version information to generate it ourselves. +cp $srcdir/ghcversion.h include/ghcversion.h +] + dnl ###################################################################### dnl Generate external symbol flags (-Wl,-u...) dnl ###################################################################### ===================================== rts/ghcversion.h.bottom → rts/ghcversion.h.in ===================================== @@ -1,3 +1,11 @@ +#if !defined(__GHCVERSION_H__) +#define __GHCVERSION_H__ + +#define __GLASGOW_HASKELL__ @ProjectVersionInt@ +#define __GLASGOW_HASKELL_FULL_VERSION__ "@ProjectVersion@" + +#define __GLASGOW_HASKELL_PATCHLEVEL1__ @ProjectPatchLevel1@ +#define __GLASGOW_HASKELL_PATCHLEVEL2__ @ProjectPatchLevel2@ #define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) ( \ ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \ ===================================== rts/ghcversion.h.top deleted ===================================== @@ -1,3 +0,0 @@ -#if !defined(__GHCVERSION_H__) -#define __GHCVERSION_H__ - ===================================== rts/rts.cabal ===================================== @@ -240,7 +240,7 @@ library include-dirs: include includes: Rts.h - autogen-includes: ghcautoconf.h + autogen-includes: ghcautoconf.h ghcversion.h install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h -- ^ from include View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a859daa2ec12ef3a3505a4d03789cd2810bfd01 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a859daa2ec12ef3a3505a4d03789cd2810bfd01 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 13 23:35:29 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 13 Oct 2023 19:35:29 -0400 Subject: [Git][ghc/ghc][wip/simpler-ghcversion.h] 2 commits: `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Message-ID: <6529d441442df_24a44537aed7c447382a@gitlab.mail> John Ericson pushed to branch wip/simpler-ghcversion.h at Glasgow Haskell Compiler / GHC Commits: 8fa5a02e by John Ericson at 2023-10-13T19:35:13-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 91171158 by John Ericson at 2023-10-13T19:35:23-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. - - - - - 6 changed files: - configure.ac - rts/.gitignore - rts/configure.ac - rts/ghcversion.h.bottom → rts/ghcversion.h.in - − rts/ghcversion.h.top - rts/rts.cabal Changes: ===================================== configure.ac ===================================== @@ -68,23 +68,6 @@ FP_PROG_SORT dnl ---------------------------------------------------------- FP_SETUP_PROJECT_VERSION -dnl Don't use AC_DEFINE because it will make C-style comments invalid for -dnl Haskell. - -> rts/include/ghcversion.h - -cat rts/ghcversion.h.top >> rts/include/ghcversion.h - -echo "#define __GLASGOW_HASKELL__ ${ProjectVersionInt}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_FULL_VERSION__ \"${ProjectVersion}\"" >> rts/include/ghcversion.h -echo >> rts/include/ghcversion.h -AS_IF([test x"${ProjectPatchLevel1}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ ${ProjectPatchLevel1}" >> rts/include/ghcversion.h]) -AS_IF([test x"${ProjectPatchLevel2}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL2__ ${ProjectPatchLevel2}" >> rts/include/ghcversion.h]) - -cat rts/ghcversion.h.bottom >> rts/include/ghcversion.h - # Hmmm, we fix the RPM release number to 1 here... Is this convenient? AC_SUBST([release], [1]) @@ -105,8 +88,12 @@ AC_PREREQ([2.69]) AC_CONFIG_HEADER(mk/config.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) -dnl manually outputted above, for reasons described there. -dnl AC_CONFIG_HEADER(rts/include/ghcversion.h) +dnl Don't use `AC_CONFIG_HEADER` because it will make C-style comments +dnl invalid for Haskell. +dnl +dnl RTS configure will copy resulting file into place, so `.in` file +dnl doesn't pollute the build. +AC_CONFIG_FILES(rts/ghcversion.h) # No, semi-sadly, we don't do `--srcdir'... if test x"$srcdir" != 'x.' ; then ===================================== rts/.gitignore ===================================== @@ -2,6 +2,7 @@ /dist/ /dist-*/ +/ghcversion.h /include/ghcversion.h /package.conf.inplace ===================================== rts/configure.ac ===================================== @@ -243,6 +243,16 @@ cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \ echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h ] +dnl ###################################################################### +dnl Generate ghcversion.h +dnl ###################################################################### + +[ +# Copy the file the top-level configure script created into place. We +# don't have the right version information to generate it ourselves. +cp $srcdir/ghcversion.h include/ghcversion.h +] + dnl ###################################################################### dnl Generate external symbol flags (-Wl,-u...) dnl ###################################################################### ===================================== rts/ghcversion.h.bottom → rts/ghcversion.h.in ===================================== @@ -1,3 +1,11 @@ +#if !defined(__GHCVERSION_H__) +#define __GHCVERSION_H__ + +#define __GLASGOW_HASKELL__ @ProjectVersionInt@ +#define __GLASGOW_HASKELL_FULL_VERSION__ "@ProjectVersion@" + +#define __GLASGOW_HASKELL_PATCHLEVEL1__ @ProjectPatchLevel1@ +#define __GLASGOW_HASKELL_PATCHLEVEL2__ @ProjectPatchLevel2@ #define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) ( \ ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \ ===================================== rts/ghcversion.h.top deleted ===================================== @@ -1,3 +0,0 @@ -#if !defined(__GHCVERSION_H__) -#define __GHCVERSION_H__ - ===================================== rts/rts.cabal ===================================== @@ -240,7 +240,7 @@ library include-dirs: include includes: Rts.h - autogen-includes: ghcautoconf.h + autogen-includes: ghcautoconf.h ghcversion.h install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h -- ^ from include View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a859daa2ec12ef3a3505a4d03789cd2810bfd01...91171158ecbd9429e803bb0af1760cad518f267d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a859daa2ec12ef3a3505a4d03789cd2810bfd01...91171158ecbd9429e803bb0af1760cad518f267d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 00:43:54 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 13 Oct 2023 20:43:54 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Fix restarts in .ghcid Message-ID: <6529e44a2fb04_24a445397769904895e2@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5d1e6264 by Sebastian Graf at 2023-10-13T20:43:13-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 5254a848 by Sebastian Graf at 2023-10-13T20:43:13-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 92eaafdc by Matthew Pickering at 2023-10-13T20:43:14-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - 487f4a69 by Sylvain Henry at 2023-10-13T20:43:17-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - 54287535 by Sylvain Henry at 2023-10-13T20:43:17-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - c84c0cfa by Sylvain Henry at 2023-10-13T20:43:17-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f5708507 by Ilias Tsitsimpis at 2023-10-13T20:43:18-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 77d4811d by John Ericson at 2023-10-13T20:43:19-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 18 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/878657968995a8def25ac60569d07269840bf4fc...77d4811d2b7bab7642c991a680a83c8aaf63fc7e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/878657968995a8def25ac60569d07269840bf4fc...77d4811d2b7bab7642c991a680a83c8aaf63fc7e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 04:04:30 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 00:04:30 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Fix restarts in .ghcid Message-ID: <652a134e67780_24a4453e10b2405083f5@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d767e1cb by Sebastian Graf at 2023-10-14T00:04:05-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 87ea042f by Sebastian Graf at 2023-10-14T00:04:05-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 82b0fa86 by Matthew Pickering at 2023-10-14T00:04:06-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - f684f438 by Sylvain Henry at 2023-10-14T00:04:09-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - b6a5979d by Sylvain Henry at 2023-10-14T00:04:09-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 1e240ebd by Sylvain Henry at 2023-10-14T00:04:09-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - 0d38af89 by Ilias Tsitsimpis at 2023-10-14T00:04:10-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 0eedf2d8 by John Ericson at 2023-10-14T00:04:11-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 18 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77d4811d2b7bab7642c991a680a83c8aaf63fc7e...0eedf2d82b04d63fa93fe75835d33daaf6244f73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77d4811d2b7bab7642c991a680a83c8aaf63fc7e...0eedf2d82b04d63fa93fe75835d33daaf6244f73 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 07:24:57 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 03:24:57 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Fix restarts in .ghcid Message-ID: <652a4249e2ee6_24a445431dedac530147@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e2585d80 by Sebastian Graf at 2023-10-14T03:24:30-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 0b533c10 by Sebastian Graf at 2023-10-14T03:24:31-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 68d5b533 by Matthew Pickering at 2023-10-14T03:24:31-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - 7465db16 by Sylvain Henry at 2023-10-14T03:24:34-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - 4c5a7da0 by Sylvain Henry at 2023-10-14T03:24:34-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - b3edb326 by Sylvain Henry at 2023-10-14T03:24:34-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - 4995949b by Ilias Tsitsimpis at 2023-10-14T03:24:36-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - c70ef3e0 by John Ericson at 2023-10-14T03:24:36-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 18 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0eedf2d82b04d63fa93fe75835d33daaf6244f73...c70ef3e00b255a374a0960dee233d77593a1b167 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0eedf2d82b04d63fa93fe75835d33daaf6244f73...c70ef3e00b255a374a0960dee233d77593a1b167 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 09:37:24 2023 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Sat, 14 Oct 2023 05:37:24 -0400 Subject: [Git][ghc/ghc][wip/or-pats] refactor Message-ID: <652a6154c8332_24a445464d17dc54355b@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 436f0454 by David Knothe at 2023-10-14T11:37:10+02:00 refactor - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -3113,11 +3113,9 @@ texp :: { ECP } mkHsViewPatPV (comb2 $1 $>) $1 $3 [mu AnnRarrow $2] } orpats :: { [LPat GhcPs] } --- : texp {% do : exp %shift {% do { pat1 <- (checkPattern <=< runPV) (unECP $1) ; return [pat1] }} --- | texp '|' orpats {% do | exp ';' orpats {% do { pat1 <- (checkPattern <=< runPV) (unECP $1) ; pat2 <- addTrailingSemiA pat1 (getLoc $2) @@ -3388,14 +3386,14 @@ pat_syn_pat :: { LPat GhcPs } pat_syn_pat : exp {% (checkPattern <=< runPV) (unECP $1) } pat :: { LPat GhcPs } -pat : pat_syn_pat { $1 } - | pat ';' orpats {% - do { let srcSpan = comb2 (getLocA $1) (getLocA $ last $3) - ; cs <- getCommentsFor srcSpan - ; pat1 <- addTrailingSemiA $1 (getLoc $2) - ; let orpat = sL (noAnnSrcSpan srcSpan) $ OrPat (EpAnn (spanAsAnchor srcSpan) [] cs) (pat1:$3) - ; _ <- hintOrPats orpat - ; return $ orpat }} +pat : orpats {% case $1 of + [pat] -> return pat + _ -> do { let srcSpan = getLocA $1 + ; cs <- getCommentsFor srcSpan + ; let orpat = sL (noAnnSrcSpan srcSpan) $ OrPat (EpAnn (spanAsAnchor srcSpan) [] cs) $1 + ; _ <- hintOrPats orpat + ; return orpat }} + -- 'pats1' does the same thing as 'pat', but returns it as a singleton -- list so that it can be used with a parameterized production rule View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/436f0454705c93ea0324056d69267a880029cf67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/436f0454705c93ea0324056d69267a880029cf67 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 11:36:24 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 07:36:24 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Fix restarts in .ghcid Message-ID: <652a7d38c85a3_24a44548e5ac2056867a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a071f3d9 by Sebastian Graf at 2023-10-14T07:35:00-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - c86d5ff2 by Sebastian Graf at 2023-10-14T07:35:00-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 190f1406 by Matthew Pickering at 2023-10-14T07:35:01-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - e148ad67 by Sylvain Henry at 2023-10-14T07:35:04-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - 06ae2eb3 by Sylvain Henry at 2023-10-14T07:35:04-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 6988e904 by Sylvain Henry at 2023-10-14T07:35:04-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - 104ceb58 by sheaf at 2023-10-14T07:35:12-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 4c50dad9 by Ilias Tsitsimpis at 2023-10-14T07:35:13-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - e6716ad4 by John Ericson at 2023-10-14T07:35:13-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 26 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/rename/should_compile/T24084.hs - + testsuite/tests/rename/should_compile/T24084_A.hs - + testsuite/tests/rename/should_compile/T24084_B.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -692,13 +692,14 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup | otherwise = do gre_env <- getGlobalRdrEnv let original_gres = lookupGRE gre_env (LookupChildren (rdrNameOcc rdr_name) how_lkup) - -- The remaining GREs are things that we *could* export here, note that - -- this includes things which have `NoParent`. Those are sorted in - -- `checkPatSynParent`. + picked_gres = pick_gres original_gres + -- The remaining GREs are things that we *could* export here. + -- Note that this includes things which have `NoParent`; + -- those are sorted in `checkPatSynParent`. traceRn "parent" (ppr parent) traceRn "lookupExportChild original_gres:" (ppr original_gres) - traceRn "lookupExportChild picked_gres:" (ppr (picked_gres original_gres) $$ ppr must_have_parent) - case picked_gres original_gres of + traceRn "lookupExportChild picked_gres:" (ppr picked_gres $$ ppr must_have_parent) + case picked_gres of NoOccurrence -> noMatchingParentErr original_gres UniqueOccurrence g -> @@ -745,34 +746,36 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup addNameClashErrRn rdr_name gres return (FoundChild (NE.head gres)) - picked_gres :: [GlobalRdrElt] -> DisambigInfo + pick_gres :: [GlobalRdrElt] -> DisambigInfo -- For Unqual, find GREs that are in scope qualified or unqualified -- For Qual, find GREs that are in scope with that qualification - picked_gres gres + pick_gres gres | isUnqual rdr_name = mconcat (map right_parent gres) | otherwise = mconcat (map right_parent (pickGREs rdr_name gres)) right_parent :: GlobalRdrElt -> DisambigInfo - right_parent p - = case greParent p of + right_parent gre + = case greParent gre of ParentIs cur_parent - | parent == cur_parent -> DisambiguatedOccurrence p + | parent == cur_parent -> DisambiguatedOccurrence gre | otherwise -> NoOccurrence - NoParent -> UniqueOccurrence p + NoParent -> UniqueOccurrence gre {-# INLINEABLE lookupSubBndrOcc_helper #-} --- This domain specific datatype is used to record why we decided it was +-- | This domain specific datatype is used to record why we decided it was -- possible that a GRE could be exported with a parent. data DisambigInfo = NoOccurrence - -- The GRE could never be exported. It has the wrong parent. + -- ^ The GRE could not be found, or it has the wrong parent. | UniqueOccurrence GlobalRdrElt - -- The GRE has no parent. It could be a pattern synonym. + -- ^ The GRE has no parent. It could be a pattern synonym. | DisambiguatedOccurrence GlobalRdrElt - -- The parent of the GRE is the correct parent + -- ^ The parent of the GRE is the correct parent. | AmbiguousOccurrence (NE.NonEmpty GlobalRdrElt) + -- ^ The GRE is ambiguous. + -- -- For example, two normal identifiers with the same name are in -- scope. They will both be resolved to "UniqueOccurrence" and the -- monoid will combine them to this failing case. @@ -784,7 +787,7 @@ instance Outputable DisambigInfo where ppr (AmbiguousOccurrence gres) = text "Ambiguous:" <+> ppr gres instance Semi.Semigroup DisambigInfo where - -- This is the key line: We prefer disambiguated occurrences to other + -- These are the key lines: we prefer disambiguated occurrences to other -- names. _ <> DisambiguatedOccurrence g' = DisambiguatedOccurrence g' DisambiguatedOccurrence g' <> _ = DisambiguatedOccurrence g' ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1068,13 +1068,17 @@ Notice that T appears *twice*, once as a child and once as a parent. From these two exports, respectively, during construction of the imp_occ_env, we begin by associating the following two elements with the key T: - T -> ImpOccItem { imp_item = T, imp_bundled = [C,T] , imp_is_parent = False } - T -> ImpOccItem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> ImpOccItem { imp_item = gre1, imp_bundled = [C,T] , imp_is_parent = False } + T -> ImpOccItem { imp_item = gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } -We combine these (in function 'combine' in 'mkImportOccEnv') by simply discarding -the first item, to get: +where `gre1`, `gre2` are two GlobalRdrElts with greName T. +We combine these (in function 'combine' in 'mkImportOccEnv') by discarding the +non-parent item, thusly: - T -> IE_ITem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> IE_ITem { imp_item = gre1 `plusGRE` gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } + +Note the `plusGRE`: this ensures we don't drop parent information; +see Note [Preserve parent information when combining import OccEnvs]. So the overall imp_occ_env is: @@ -1133,6 +1137,31 @@ Whereas in case (B) we reach the lookup_ie case for IEThingWith, which looks up 'S' and then finds the unique 'foo' amongst its children. See T16745 for a test of this. + +Note [Preserve parent information when combining import OccEnvs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When discarding one ImpOccItem in favour of another, as described in +Note [Dealing with imports], we must make sure to combine the GREs so that +we don't lose information. + +Consider for example #24084: + + module M1 where { class C a where { type T a } } + module M2 ( module M1 ) where { import M1 } + module M3 where { import M2 ( C, T ); instance C () where T () = () } + +When processing the import list of `M3`, we will have two `Avail`s attached +to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function +of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard +`C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** +discard the information want that `C` is the parent of `T`. Indeed, +losing track of this information can cause errors when importing, +as we could get an error of the form + + ‘T’ is not a (visible) associated type of class ‘C’ + +This explains why we use `plusGRE` when combining the two ImpOccItems, even +though we are discarding one in favour of the other. -} -- | All the 'GlobalRdrElt's associated with an 'AvailInfo'. @@ -1443,6 +1472,14 @@ data ImpOccItem -- ^ Is the import item a parent? See Note [Dealing with imports]. } +instance Outputable ImpOccItem where + ppr (ImpOccItem { imp_item = item, imp_bundled = bundled, imp_is_parent = is_par }) + = braces $ hsep + [ text "ImpOccItem" + , if is_par then text "[is_par]" else empty + , ppr (greName item) <+> ppr (greParent item) + , braces $ text "bundled:" <+> ppr (map greName bundled) ] + -- | Make an 'OccEnv' of all the imports. -- -- Complicated by the fact that associated data types and pattern synonyms @@ -1474,9 +1511,9 @@ mkImportOccEnv hsc_env decl_spec all_avails = -- See Note [Dealing with imports] -- 'combine' may be called for associated data types which appear - -- twice in the all_avails. In the example, we combine - -- T(T,T1,T2,T3) and C(C,T) to give (T, T(T,T1,T2,T3), Just C) - -- NB: the AvailTC can have fields as well as data constructors (#12127) + -- twice in the all_avails. In the example, we have two Avails for T, + -- namely T(T,T1,T2,T3) and C(C,T), and we combine them by dropping the + -- latter, in which T is not the parent. combine :: ImpOccItem -> ImpOccItem -> ImpOccItem combine item1@(ImpOccItem { imp_item = gre1, imp_is_parent = is_parent1 }) item2@(ImpOccItem { imp_item = gre2, imp_is_parent = is_parent2 }) @@ -1484,11 +1521,13 @@ mkImportOccEnv hsc_env decl_spec all_avails = , not (isRecFldGRE gre1 || isRecFldGRE gre2) -- NB: does not force GREInfo. , let name1 = greName gre1 name2 = greName gre2 + gre = gre1 `plusGRE` gre2 + -- See Note [Preserve parent information when combining import OccEnvs] = assertPpr (name1 == name2) (ppr name1 <+> ppr name2) $ if is_parent1 - then item1 - else item2 + then item1 { imp_item = gre } + else item2 { imp_item = gre } -- Discard C(C,T) in favour of T(T, T1, T2, T3). -- 'combine' may also be called for pattern synonyms which appear both ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -175,7 +175,7 @@ filterAvail keep ie rest = -- 'avails' may have several items with the same availName -- E.g import Ix( Ix(..), index ) -- will give Ix(Ix,index,range) and Ix(index) --- We want to combine these; addAvail does that +-- We want to combine these; plusAvail does that nubAvails :: [AvailInfo] -> [AvailInfo] nubAvails avails = eltsDNameEnv (foldl' add emptyDNameEnv avails) where ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -76,6 +76,7 @@ module GHC.Types.Name.Reader ( -- ** Global 'RdrName' mapping elements: 'GlobalRdrElt', 'Provenance', 'ImportSpec' GlobalRdrEltX(..), GlobalRdrElt, IfGlobalRdrElt, FieldGlobalRdrElt, greName, greNameSpace, greParent, greInfo, + plusGRE, insertGRE, forceGlobalRdrEnv, hydrateGlobalRdrEnv, isLocalGRE, isImportedGRE, isRecFldGRE, fieldGREInfo, @@ -1165,6 +1166,17 @@ data WhichGREs info where } -> WhichGREs GREInfo +instance Outputable (WhichGREs info) where + ppr SameNameSpace = text "SameNameSpace" + ppr (RelevantGREs { includeFieldSelectors = sel + , lookupVariablesForFields = vars + , lookupTyConsAsWell = tcs_too }) + = braces $ hsep + [ text "RelevantGREs" + , text (show sel) + , if vars then text "[vars]" else empty + , if tcs_too then text "[tcs]" else empty ] + -- | Look up as many possibly relevant 'GlobalRdrElt's as possible. pattern AllRelevantGREs :: WhichGREs GREInfo pattern AllRelevantGREs = @@ -1199,6 +1211,17 @@ data LookupChild -- See Note [childGREPriority]. } +instance Outputable LookupChild where + ppr (LookupChild { wantedParent = par + , lookupDataConFirst = dc + , prioritiseParent = prio_parent }) + = braces $ hsep + [ text "LookupChild" + , braces (text "parent:" <+> ppr par) + , if dc then text "[dc_first]" else empty + , if prio_parent then text "[prio_parent]" else empty + ] + -- | After looking up something with the given 'NameSpace', is the resulting -- 'GlobalRdrElt' we have obtained relevant, according to the 'RelevantGREs' -- specification of which 'NameSpace's are relevant? ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) ===================================== testsuite/tests/rename/should_compile/T24084.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084 where + +import T24084_B (Foo, Bar) + +data X + +instance Foo X where + type Bar X = X ===================================== testsuite/tests/rename/should_compile/T24084_A.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_A (Foo (..)) where + +class Foo a where + type Bar a ===================================== testsuite/tests/rename/should_compile/T24084_B.hs ===================================== @@ -0,0 +1,7 @@ + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_B (module T24084_A) where + +import T24084_A + ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -216,6 +216,7 @@ test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) test('T24037', normal, compile, ['']) +test('T24084', [extra_files(['T24084_A.hs', 'T24084_B.hs'])], multimod_compile, ['T24084', '-v0']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c70ef3e00b255a374a0960dee233d77593a1b167...e6716ad476a5232e08970e80ea655a0e24d56fc6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c70ef3e00b255a374a0960dee233d77593a1b167...e6716ad476a5232e08970e80ea655a0e24d56fc6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 14:46:46 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 10:46:46 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Fix restarts in .ghcid Message-ID: <652aa9d626d0f_24a4454d4aa4c8589511@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 63454886 by Sebastian Graf at 2023-10-14T10:46:00-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - b207f302 by Sebastian Graf at 2023-10-14T10:46:00-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - c8ee38bf by Matthew Pickering at 2023-10-14T10:46:01-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - a1d84483 by Sylvain Henry at 2023-10-14T10:46:04-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - 2ad44e00 by Sylvain Henry at 2023-10-14T10:46:04-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 4073919c by Sylvain Henry at 2023-10-14T10:46:04-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - 5a0b6d8f by sheaf at 2023-10-14T10:46:07-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 94404c11 by Ilias Tsitsimpis at 2023-10-14T10:46:08-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 8c8c9a2a by John Ericson at 2023-10-14T10:46:08-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 26 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/rename/should_compile/T24084.hs - + testsuite/tests/rename/should_compile/T24084_A.hs - + testsuite/tests/rename/should_compile/T24084_B.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -692,13 +692,14 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup | otherwise = do gre_env <- getGlobalRdrEnv let original_gres = lookupGRE gre_env (LookupChildren (rdrNameOcc rdr_name) how_lkup) - -- The remaining GREs are things that we *could* export here, note that - -- this includes things which have `NoParent`. Those are sorted in - -- `checkPatSynParent`. + picked_gres = pick_gres original_gres + -- The remaining GREs are things that we *could* export here. + -- Note that this includes things which have `NoParent`; + -- those are sorted in `checkPatSynParent`. traceRn "parent" (ppr parent) traceRn "lookupExportChild original_gres:" (ppr original_gres) - traceRn "lookupExportChild picked_gres:" (ppr (picked_gres original_gres) $$ ppr must_have_parent) - case picked_gres original_gres of + traceRn "lookupExportChild picked_gres:" (ppr picked_gres $$ ppr must_have_parent) + case picked_gres of NoOccurrence -> noMatchingParentErr original_gres UniqueOccurrence g -> @@ -745,34 +746,36 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup addNameClashErrRn rdr_name gres return (FoundChild (NE.head gres)) - picked_gres :: [GlobalRdrElt] -> DisambigInfo + pick_gres :: [GlobalRdrElt] -> DisambigInfo -- For Unqual, find GREs that are in scope qualified or unqualified -- For Qual, find GREs that are in scope with that qualification - picked_gres gres + pick_gres gres | isUnqual rdr_name = mconcat (map right_parent gres) | otherwise = mconcat (map right_parent (pickGREs rdr_name gres)) right_parent :: GlobalRdrElt -> DisambigInfo - right_parent p - = case greParent p of + right_parent gre + = case greParent gre of ParentIs cur_parent - | parent == cur_parent -> DisambiguatedOccurrence p + | parent == cur_parent -> DisambiguatedOccurrence gre | otherwise -> NoOccurrence - NoParent -> UniqueOccurrence p + NoParent -> UniqueOccurrence gre {-# INLINEABLE lookupSubBndrOcc_helper #-} --- This domain specific datatype is used to record why we decided it was +-- | This domain specific datatype is used to record why we decided it was -- possible that a GRE could be exported with a parent. data DisambigInfo = NoOccurrence - -- The GRE could never be exported. It has the wrong parent. + -- ^ The GRE could not be found, or it has the wrong parent. | UniqueOccurrence GlobalRdrElt - -- The GRE has no parent. It could be a pattern synonym. + -- ^ The GRE has no parent. It could be a pattern synonym. | DisambiguatedOccurrence GlobalRdrElt - -- The parent of the GRE is the correct parent + -- ^ The parent of the GRE is the correct parent. | AmbiguousOccurrence (NE.NonEmpty GlobalRdrElt) + -- ^ The GRE is ambiguous. + -- -- For example, two normal identifiers with the same name are in -- scope. They will both be resolved to "UniqueOccurrence" and the -- monoid will combine them to this failing case. @@ -784,7 +787,7 @@ instance Outputable DisambigInfo where ppr (AmbiguousOccurrence gres) = text "Ambiguous:" <+> ppr gres instance Semi.Semigroup DisambigInfo where - -- This is the key line: We prefer disambiguated occurrences to other + -- These are the key lines: we prefer disambiguated occurrences to other -- names. _ <> DisambiguatedOccurrence g' = DisambiguatedOccurrence g' DisambiguatedOccurrence g' <> _ = DisambiguatedOccurrence g' ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1068,13 +1068,17 @@ Notice that T appears *twice*, once as a child and once as a parent. From these two exports, respectively, during construction of the imp_occ_env, we begin by associating the following two elements with the key T: - T -> ImpOccItem { imp_item = T, imp_bundled = [C,T] , imp_is_parent = False } - T -> ImpOccItem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> ImpOccItem { imp_item = gre1, imp_bundled = [C,T] , imp_is_parent = False } + T -> ImpOccItem { imp_item = gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } -We combine these (in function 'combine' in 'mkImportOccEnv') by simply discarding -the first item, to get: +where `gre1`, `gre2` are two GlobalRdrElts with greName T. +We combine these (in function 'combine' in 'mkImportOccEnv') by discarding the +non-parent item, thusly: - T -> IE_ITem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> IE_ITem { imp_item = gre1 `plusGRE` gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } + +Note the `plusGRE`: this ensures we don't drop parent information; +see Note [Preserve parent information when combining import OccEnvs]. So the overall imp_occ_env is: @@ -1133,6 +1137,31 @@ Whereas in case (B) we reach the lookup_ie case for IEThingWith, which looks up 'S' and then finds the unique 'foo' amongst its children. See T16745 for a test of this. + +Note [Preserve parent information when combining import OccEnvs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When discarding one ImpOccItem in favour of another, as described in +Note [Dealing with imports], we must make sure to combine the GREs so that +we don't lose information. + +Consider for example #24084: + + module M1 where { class C a where { type T a } } + module M2 ( module M1 ) where { import M1 } + module M3 where { import M2 ( C, T ); instance C () where T () = () } + +When processing the import list of `M3`, we will have two `Avail`s attached +to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function +of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard +`C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** +discard the information want that `C` is the parent of `T`. Indeed, +losing track of this information can cause errors when importing, +as we could get an error of the form + + ‘T’ is not a (visible) associated type of class ‘C’ + +This explains why we use `plusGRE` when combining the two ImpOccItems, even +though we are discarding one in favour of the other. -} -- | All the 'GlobalRdrElt's associated with an 'AvailInfo'. @@ -1443,6 +1472,14 @@ data ImpOccItem -- ^ Is the import item a parent? See Note [Dealing with imports]. } +instance Outputable ImpOccItem where + ppr (ImpOccItem { imp_item = item, imp_bundled = bundled, imp_is_parent = is_par }) + = braces $ hsep + [ text "ImpOccItem" + , if is_par then text "[is_par]" else empty + , ppr (greName item) <+> ppr (greParent item) + , braces $ text "bundled:" <+> ppr (map greName bundled) ] + -- | Make an 'OccEnv' of all the imports. -- -- Complicated by the fact that associated data types and pattern synonyms @@ -1474,9 +1511,9 @@ mkImportOccEnv hsc_env decl_spec all_avails = -- See Note [Dealing with imports] -- 'combine' may be called for associated data types which appear - -- twice in the all_avails. In the example, we combine - -- T(T,T1,T2,T3) and C(C,T) to give (T, T(T,T1,T2,T3), Just C) - -- NB: the AvailTC can have fields as well as data constructors (#12127) + -- twice in the all_avails. In the example, we have two Avails for T, + -- namely T(T,T1,T2,T3) and C(C,T), and we combine them by dropping the + -- latter, in which T is not the parent. combine :: ImpOccItem -> ImpOccItem -> ImpOccItem combine item1@(ImpOccItem { imp_item = gre1, imp_is_parent = is_parent1 }) item2@(ImpOccItem { imp_item = gre2, imp_is_parent = is_parent2 }) @@ -1484,11 +1521,13 @@ mkImportOccEnv hsc_env decl_spec all_avails = , not (isRecFldGRE gre1 || isRecFldGRE gre2) -- NB: does not force GREInfo. , let name1 = greName gre1 name2 = greName gre2 + gre = gre1 `plusGRE` gre2 + -- See Note [Preserve parent information when combining import OccEnvs] = assertPpr (name1 == name2) (ppr name1 <+> ppr name2) $ if is_parent1 - then item1 - else item2 + then item1 { imp_item = gre } + else item2 { imp_item = gre } -- Discard C(C,T) in favour of T(T, T1, T2, T3). -- 'combine' may also be called for pattern synonyms which appear both ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -175,7 +175,7 @@ filterAvail keep ie rest = -- 'avails' may have several items with the same availName -- E.g import Ix( Ix(..), index ) -- will give Ix(Ix,index,range) and Ix(index) --- We want to combine these; addAvail does that +-- We want to combine these; plusAvail does that nubAvails :: [AvailInfo] -> [AvailInfo] nubAvails avails = eltsDNameEnv (foldl' add emptyDNameEnv avails) where ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -76,6 +76,7 @@ module GHC.Types.Name.Reader ( -- ** Global 'RdrName' mapping elements: 'GlobalRdrElt', 'Provenance', 'ImportSpec' GlobalRdrEltX(..), GlobalRdrElt, IfGlobalRdrElt, FieldGlobalRdrElt, greName, greNameSpace, greParent, greInfo, + plusGRE, insertGRE, forceGlobalRdrEnv, hydrateGlobalRdrEnv, isLocalGRE, isImportedGRE, isRecFldGRE, fieldGREInfo, @@ -1165,6 +1166,17 @@ data WhichGREs info where } -> WhichGREs GREInfo +instance Outputable (WhichGREs info) where + ppr SameNameSpace = text "SameNameSpace" + ppr (RelevantGREs { includeFieldSelectors = sel + , lookupVariablesForFields = vars + , lookupTyConsAsWell = tcs_too }) + = braces $ hsep + [ text "RelevantGREs" + , text (show sel) + , if vars then text "[vars]" else empty + , if tcs_too then text "[tcs]" else empty ] + -- | Look up as many possibly relevant 'GlobalRdrElt's as possible. pattern AllRelevantGREs :: WhichGREs GREInfo pattern AllRelevantGREs = @@ -1199,6 +1211,17 @@ data LookupChild -- See Note [childGREPriority]. } +instance Outputable LookupChild where + ppr (LookupChild { wantedParent = par + , lookupDataConFirst = dc + , prioritiseParent = prio_parent }) + = braces $ hsep + [ text "LookupChild" + , braces (text "parent:" <+> ppr par) + , if dc then text "[dc_first]" else empty + , if prio_parent then text "[prio_parent]" else empty + ] + -- | After looking up something with the given 'NameSpace', is the resulting -- 'GlobalRdrElt' we have obtained relevant, according to the 'RelevantGREs' -- specification of which 'NameSpace's are relevant? ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) ===================================== testsuite/tests/rename/should_compile/T24084.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084 where + +import T24084_B (Foo, Bar) + +data X + +instance Foo X where + type Bar X = X ===================================== testsuite/tests/rename/should_compile/T24084_A.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_A (Foo (..)) where + +class Foo a where + type Bar a ===================================== testsuite/tests/rename/should_compile/T24084_B.hs ===================================== @@ -0,0 +1,7 @@ + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_B (module T24084_A) where + +import T24084_A + ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -216,6 +216,7 @@ test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) test('T24037', normal, compile, ['']) +test('T24084', [extra_files(['T24084_A.hs', 'T24084_B.hs'])], multimod_compile, ['T24084', '-v0']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e6716ad476a5232e08970e80ea655a0e24d56fc6...8c8c9a2aceb2d75389a68397d9c2d4b5a80e42d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e6716ad476a5232e08970e80ea655a0e24d56fc6...8c8c9a2aceb2d75389a68397d9c2d4b5a80e42d9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 17:57:07 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 13:57:07 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Fix restarts in .ghcid Message-ID: <652ad673943ae_24a445517a15886161d8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 87e28423 by Sebastian Graf at 2023-10-14T13:56:29-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - b3e250f3 by Sebastian Graf at 2023-10-14T13:56:29-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - e3ac71ac by Matthew Pickering at 2023-10-14T13:56:29-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - 3dffd08d by Sylvain Henry at 2023-10-14T13:56:33-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - 85cadc06 by Sylvain Henry at 2023-10-14T13:56:33-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 7c96ee07 by Sylvain Henry at 2023-10-14T13:56:33-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - cf8171f8 by sheaf at 2023-10-14T13:56:35-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - bd3f5bcc by Ilias Tsitsimpis at 2023-10-14T13:56:37-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 39751402 by John Ericson at 2023-10-14T13:56:37-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 26 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/rename/should_compile/T24084.hs - + testsuite/tests/rename/should_compile/T24084_A.hs - + testsuite/tests/rename/should_compile/T24084_B.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -692,13 +692,14 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup | otherwise = do gre_env <- getGlobalRdrEnv let original_gres = lookupGRE gre_env (LookupChildren (rdrNameOcc rdr_name) how_lkup) - -- The remaining GREs are things that we *could* export here, note that - -- this includes things which have `NoParent`. Those are sorted in - -- `checkPatSynParent`. + picked_gres = pick_gres original_gres + -- The remaining GREs are things that we *could* export here. + -- Note that this includes things which have `NoParent`; + -- those are sorted in `checkPatSynParent`. traceRn "parent" (ppr parent) traceRn "lookupExportChild original_gres:" (ppr original_gres) - traceRn "lookupExportChild picked_gres:" (ppr (picked_gres original_gres) $$ ppr must_have_parent) - case picked_gres original_gres of + traceRn "lookupExportChild picked_gres:" (ppr picked_gres $$ ppr must_have_parent) + case picked_gres of NoOccurrence -> noMatchingParentErr original_gres UniqueOccurrence g -> @@ -745,34 +746,36 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup addNameClashErrRn rdr_name gres return (FoundChild (NE.head gres)) - picked_gres :: [GlobalRdrElt] -> DisambigInfo + pick_gres :: [GlobalRdrElt] -> DisambigInfo -- For Unqual, find GREs that are in scope qualified or unqualified -- For Qual, find GREs that are in scope with that qualification - picked_gres gres + pick_gres gres | isUnqual rdr_name = mconcat (map right_parent gres) | otherwise = mconcat (map right_parent (pickGREs rdr_name gres)) right_parent :: GlobalRdrElt -> DisambigInfo - right_parent p - = case greParent p of + right_parent gre + = case greParent gre of ParentIs cur_parent - | parent == cur_parent -> DisambiguatedOccurrence p + | parent == cur_parent -> DisambiguatedOccurrence gre | otherwise -> NoOccurrence - NoParent -> UniqueOccurrence p + NoParent -> UniqueOccurrence gre {-# INLINEABLE lookupSubBndrOcc_helper #-} --- This domain specific datatype is used to record why we decided it was +-- | This domain specific datatype is used to record why we decided it was -- possible that a GRE could be exported with a parent. data DisambigInfo = NoOccurrence - -- The GRE could never be exported. It has the wrong parent. + -- ^ The GRE could not be found, or it has the wrong parent. | UniqueOccurrence GlobalRdrElt - -- The GRE has no parent. It could be a pattern synonym. + -- ^ The GRE has no parent. It could be a pattern synonym. | DisambiguatedOccurrence GlobalRdrElt - -- The parent of the GRE is the correct parent + -- ^ The parent of the GRE is the correct parent. | AmbiguousOccurrence (NE.NonEmpty GlobalRdrElt) + -- ^ The GRE is ambiguous. + -- -- For example, two normal identifiers with the same name are in -- scope. They will both be resolved to "UniqueOccurrence" and the -- monoid will combine them to this failing case. @@ -784,7 +787,7 @@ instance Outputable DisambigInfo where ppr (AmbiguousOccurrence gres) = text "Ambiguous:" <+> ppr gres instance Semi.Semigroup DisambigInfo where - -- This is the key line: We prefer disambiguated occurrences to other + -- These are the key lines: we prefer disambiguated occurrences to other -- names. _ <> DisambiguatedOccurrence g' = DisambiguatedOccurrence g' DisambiguatedOccurrence g' <> _ = DisambiguatedOccurrence g' ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1068,13 +1068,17 @@ Notice that T appears *twice*, once as a child and once as a parent. From these two exports, respectively, during construction of the imp_occ_env, we begin by associating the following two elements with the key T: - T -> ImpOccItem { imp_item = T, imp_bundled = [C,T] , imp_is_parent = False } - T -> ImpOccItem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> ImpOccItem { imp_item = gre1, imp_bundled = [C,T] , imp_is_parent = False } + T -> ImpOccItem { imp_item = gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } -We combine these (in function 'combine' in 'mkImportOccEnv') by simply discarding -the first item, to get: +where `gre1`, `gre2` are two GlobalRdrElts with greName T. +We combine these (in function 'combine' in 'mkImportOccEnv') by discarding the +non-parent item, thusly: - T -> IE_ITem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> IE_ITem { imp_item = gre1 `plusGRE` gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } + +Note the `plusGRE`: this ensures we don't drop parent information; +see Note [Preserve parent information when combining import OccEnvs]. So the overall imp_occ_env is: @@ -1133,6 +1137,31 @@ Whereas in case (B) we reach the lookup_ie case for IEThingWith, which looks up 'S' and then finds the unique 'foo' amongst its children. See T16745 for a test of this. + +Note [Preserve parent information when combining import OccEnvs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When discarding one ImpOccItem in favour of another, as described in +Note [Dealing with imports], we must make sure to combine the GREs so that +we don't lose information. + +Consider for example #24084: + + module M1 where { class C a where { type T a } } + module M2 ( module M1 ) where { import M1 } + module M3 where { import M2 ( C, T ); instance C () where T () = () } + +When processing the import list of `M3`, we will have two `Avail`s attached +to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function +of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard +`C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** +discard the information want that `C` is the parent of `T`. Indeed, +losing track of this information can cause errors when importing, +as we could get an error of the form + + ‘T’ is not a (visible) associated type of class ‘C’ + +This explains why we use `plusGRE` when combining the two ImpOccItems, even +though we are discarding one in favour of the other. -} -- | All the 'GlobalRdrElt's associated with an 'AvailInfo'. @@ -1443,6 +1472,14 @@ data ImpOccItem -- ^ Is the import item a parent? See Note [Dealing with imports]. } +instance Outputable ImpOccItem where + ppr (ImpOccItem { imp_item = item, imp_bundled = bundled, imp_is_parent = is_par }) + = braces $ hsep + [ text "ImpOccItem" + , if is_par then text "[is_par]" else empty + , ppr (greName item) <+> ppr (greParent item) + , braces $ text "bundled:" <+> ppr (map greName bundled) ] + -- | Make an 'OccEnv' of all the imports. -- -- Complicated by the fact that associated data types and pattern synonyms @@ -1474,9 +1511,9 @@ mkImportOccEnv hsc_env decl_spec all_avails = -- See Note [Dealing with imports] -- 'combine' may be called for associated data types which appear - -- twice in the all_avails. In the example, we combine - -- T(T,T1,T2,T3) and C(C,T) to give (T, T(T,T1,T2,T3), Just C) - -- NB: the AvailTC can have fields as well as data constructors (#12127) + -- twice in the all_avails. In the example, we have two Avails for T, + -- namely T(T,T1,T2,T3) and C(C,T), and we combine them by dropping the + -- latter, in which T is not the parent. combine :: ImpOccItem -> ImpOccItem -> ImpOccItem combine item1@(ImpOccItem { imp_item = gre1, imp_is_parent = is_parent1 }) item2@(ImpOccItem { imp_item = gre2, imp_is_parent = is_parent2 }) @@ -1484,11 +1521,13 @@ mkImportOccEnv hsc_env decl_spec all_avails = , not (isRecFldGRE gre1 || isRecFldGRE gre2) -- NB: does not force GREInfo. , let name1 = greName gre1 name2 = greName gre2 + gre = gre1 `plusGRE` gre2 + -- See Note [Preserve parent information when combining import OccEnvs] = assertPpr (name1 == name2) (ppr name1 <+> ppr name2) $ if is_parent1 - then item1 - else item2 + then item1 { imp_item = gre } + else item2 { imp_item = gre } -- Discard C(C,T) in favour of T(T, T1, T2, T3). -- 'combine' may also be called for pattern synonyms which appear both ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -175,7 +175,7 @@ filterAvail keep ie rest = -- 'avails' may have several items with the same availName -- E.g import Ix( Ix(..), index ) -- will give Ix(Ix,index,range) and Ix(index) --- We want to combine these; addAvail does that +-- We want to combine these; plusAvail does that nubAvails :: [AvailInfo] -> [AvailInfo] nubAvails avails = eltsDNameEnv (foldl' add emptyDNameEnv avails) where ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -76,6 +76,7 @@ module GHC.Types.Name.Reader ( -- ** Global 'RdrName' mapping elements: 'GlobalRdrElt', 'Provenance', 'ImportSpec' GlobalRdrEltX(..), GlobalRdrElt, IfGlobalRdrElt, FieldGlobalRdrElt, greName, greNameSpace, greParent, greInfo, + plusGRE, insertGRE, forceGlobalRdrEnv, hydrateGlobalRdrEnv, isLocalGRE, isImportedGRE, isRecFldGRE, fieldGREInfo, @@ -1165,6 +1166,17 @@ data WhichGREs info where } -> WhichGREs GREInfo +instance Outputable (WhichGREs info) where + ppr SameNameSpace = text "SameNameSpace" + ppr (RelevantGREs { includeFieldSelectors = sel + , lookupVariablesForFields = vars + , lookupTyConsAsWell = tcs_too }) + = braces $ hsep + [ text "RelevantGREs" + , text (show sel) + , if vars then text "[vars]" else empty + , if tcs_too then text "[tcs]" else empty ] + -- | Look up as many possibly relevant 'GlobalRdrElt's as possible. pattern AllRelevantGREs :: WhichGREs GREInfo pattern AllRelevantGREs = @@ -1199,6 +1211,17 @@ data LookupChild -- See Note [childGREPriority]. } +instance Outputable LookupChild where + ppr (LookupChild { wantedParent = par + , lookupDataConFirst = dc + , prioritiseParent = prio_parent }) + = braces $ hsep + [ text "LookupChild" + , braces (text "parent:" <+> ppr par) + , if dc then text "[dc_first]" else empty + , if prio_parent then text "[prio_parent]" else empty + ] + -- | After looking up something with the given 'NameSpace', is the resulting -- 'GlobalRdrElt' we have obtained relevant, according to the 'RelevantGREs' -- specification of which 'NameSpace's are relevant? ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) ===================================== testsuite/tests/rename/should_compile/T24084.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084 where + +import T24084_B (Foo, Bar) + +data X + +instance Foo X where + type Bar X = X ===================================== testsuite/tests/rename/should_compile/T24084_A.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_A (Foo (..)) where + +class Foo a where + type Bar a ===================================== testsuite/tests/rename/should_compile/T24084_B.hs ===================================== @@ -0,0 +1,7 @@ + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_B (module T24084_A) where + +import T24084_A + ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -216,6 +216,7 @@ test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) test('T24037', normal, compile, ['']) +test('T24084', [extra_files(['T24084_A.hs', 'T24084_B.hs'])], multimod_compile, ['T24084', '-v0']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c8c9a2aceb2d75389a68397d9c2d4b5a80e42d9...39751402c6a48f3a4024e5c9748ec8b3604d55d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c8c9a2aceb2d75389a68397d9c2d4b5a80e42d9...39751402c6a48f3a4024e5c9748ec8b3604d55d5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 20:57:30 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 16:57:30 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Fix restarts in .ghcid Message-ID: <652b00ba9f89b_7336f27351209602f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 513861f9 by Sebastian Graf at 2023-10-14T16:57:01-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - 9882c7f1 by Sebastian Graf at 2023-10-14T16:57:01-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 4503c444 by Matthew Pickering at 2023-10-14T16:57:02-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - c219dfe7 by sheaf at 2023-10-14T16:57:04-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - b4a0deb6 by Ilias Tsitsimpis at 2023-10-14T16:57:06-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - cc5c6853 by John Ericson at 2023-10-14T16:57:06-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 17 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Packages.hs - + testsuite/tests/rename/should_compile/T24084.hs - + testsuite/tests/rename/should_compile/T24084_A.hs - + testsuite/tests/rename/should_compile/T24084_B.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -692,13 +692,14 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup | otherwise = do gre_env <- getGlobalRdrEnv let original_gres = lookupGRE gre_env (LookupChildren (rdrNameOcc rdr_name) how_lkup) - -- The remaining GREs are things that we *could* export here, note that - -- this includes things which have `NoParent`. Those are sorted in - -- `checkPatSynParent`. + picked_gres = pick_gres original_gres + -- The remaining GREs are things that we *could* export here. + -- Note that this includes things which have `NoParent`; + -- those are sorted in `checkPatSynParent`. traceRn "parent" (ppr parent) traceRn "lookupExportChild original_gres:" (ppr original_gres) - traceRn "lookupExportChild picked_gres:" (ppr (picked_gres original_gres) $$ ppr must_have_parent) - case picked_gres original_gres of + traceRn "lookupExportChild picked_gres:" (ppr picked_gres $$ ppr must_have_parent) + case picked_gres of NoOccurrence -> noMatchingParentErr original_gres UniqueOccurrence g -> @@ -745,34 +746,36 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup addNameClashErrRn rdr_name gres return (FoundChild (NE.head gres)) - picked_gres :: [GlobalRdrElt] -> DisambigInfo + pick_gres :: [GlobalRdrElt] -> DisambigInfo -- For Unqual, find GREs that are in scope qualified or unqualified -- For Qual, find GREs that are in scope with that qualification - picked_gres gres + pick_gres gres | isUnqual rdr_name = mconcat (map right_parent gres) | otherwise = mconcat (map right_parent (pickGREs rdr_name gres)) right_parent :: GlobalRdrElt -> DisambigInfo - right_parent p - = case greParent p of + right_parent gre + = case greParent gre of ParentIs cur_parent - | parent == cur_parent -> DisambiguatedOccurrence p + | parent == cur_parent -> DisambiguatedOccurrence gre | otherwise -> NoOccurrence - NoParent -> UniqueOccurrence p + NoParent -> UniqueOccurrence gre {-# INLINEABLE lookupSubBndrOcc_helper #-} --- This domain specific datatype is used to record why we decided it was +-- | This domain specific datatype is used to record why we decided it was -- possible that a GRE could be exported with a parent. data DisambigInfo = NoOccurrence - -- The GRE could never be exported. It has the wrong parent. + -- ^ The GRE could not be found, or it has the wrong parent. | UniqueOccurrence GlobalRdrElt - -- The GRE has no parent. It could be a pattern synonym. + -- ^ The GRE has no parent. It could be a pattern synonym. | DisambiguatedOccurrence GlobalRdrElt - -- The parent of the GRE is the correct parent + -- ^ The parent of the GRE is the correct parent. | AmbiguousOccurrence (NE.NonEmpty GlobalRdrElt) + -- ^ The GRE is ambiguous. + -- -- For example, two normal identifiers with the same name are in -- scope. They will both be resolved to "UniqueOccurrence" and the -- monoid will combine them to this failing case. @@ -784,7 +787,7 @@ instance Outputable DisambigInfo where ppr (AmbiguousOccurrence gres) = text "Ambiguous:" <+> ppr gres instance Semi.Semigroup DisambigInfo where - -- This is the key line: We prefer disambiguated occurrences to other + -- These are the key lines: we prefer disambiguated occurrences to other -- names. _ <> DisambiguatedOccurrence g' = DisambiguatedOccurrence g' DisambiguatedOccurrence g' <> _ = DisambiguatedOccurrence g' ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1068,13 +1068,17 @@ Notice that T appears *twice*, once as a child and once as a parent. From these two exports, respectively, during construction of the imp_occ_env, we begin by associating the following two elements with the key T: - T -> ImpOccItem { imp_item = T, imp_bundled = [C,T] , imp_is_parent = False } - T -> ImpOccItem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> ImpOccItem { imp_item = gre1, imp_bundled = [C,T] , imp_is_parent = False } + T -> ImpOccItem { imp_item = gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } -We combine these (in function 'combine' in 'mkImportOccEnv') by simply discarding -the first item, to get: +where `gre1`, `gre2` are two GlobalRdrElts with greName T. +We combine these (in function 'combine' in 'mkImportOccEnv') by discarding the +non-parent item, thusly: - T -> IE_ITem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> IE_ITem { imp_item = gre1 `plusGRE` gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } + +Note the `plusGRE`: this ensures we don't drop parent information; +see Note [Preserve parent information when combining import OccEnvs]. So the overall imp_occ_env is: @@ -1133,6 +1137,31 @@ Whereas in case (B) we reach the lookup_ie case for IEThingWith, which looks up 'S' and then finds the unique 'foo' amongst its children. See T16745 for a test of this. + +Note [Preserve parent information when combining import OccEnvs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When discarding one ImpOccItem in favour of another, as described in +Note [Dealing with imports], we must make sure to combine the GREs so that +we don't lose information. + +Consider for example #24084: + + module M1 where { class C a where { type T a } } + module M2 ( module M1 ) where { import M1 } + module M3 where { import M2 ( C, T ); instance C () where T () = () } + +When processing the import list of `M3`, we will have two `Avail`s attached +to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function +of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard +`C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** +discard the information want that `C` is the parent of `T`. Indeed, +losing track of this information can cause errors when importing, +as we could get an error of the form + + ‘T’ is not a (visible) associated type of class ‘C’ + +This explains why we use `plusGRE` when combining the two ImpOccItems, even +though we are discarding one in favour of the other. -} -- | All the 'GlobalRdrElt's associated with an 'AvailInfo'. @@ -1443,6 +1472,14 @@ data ImpOccItem -- ^ Is the import item a parent? See Note [Dealing with imports]. } +instance Outputable ImpOccItem where + ppr (ImpOccItem { imp_item = item, imp_bundled = bundled, imp_is_parent = is_par }) + = braces $ hsep + [ text "ImpOccItem" + , if is_par then text "[is_par]" else empty + , ppr (greName item) <+> ppr (greParent item) + , braces $ text "bundled:" <+> ppr (map greName bundled) ] + -- | Make an 'OccEnv' of all the imports. -- -- Complicated by the fact that associated data types and pattern synonyms @@ -1474,9 +1511,9 @@ mkImportOccEnv hsc_env decl_spec all_avails = -- See Note [Dealing with imports] -- 'combine' may be called for associated data types which appear - -- twice in the all_avails. In the example, we combine - -- T(T,T1,T2,T3) and C(C,T) to give (T, T(T,T1,T2,T3), Just C) - -- NB: the AvailTC can have fields as well as data constructors (#12127) + -- twice in the all_avails. In the example, we have two Avails for T, + -- namely T(T,T1,T2,T3) and C(C,T), and we combine them by dropping the + -- latter, in which T is not the parent. combine :: ImpOccItem -> ImpOccItem -> ImpOccItem combine item1@(ImpOccItem { imp_item = gre1, imp_is_parent = is_parent1 }) item2@(ImpOccItem { imp_item = gre2, imp_is_parent = is_parent2 }) @@ -1484,11 +1521,13 @@ mkImportOccEnv hsc_env decl_spec all_avails = , not (isRecFldGRE gre1 || isRecFldGRE gre2) -- NB: does not force GREInfo. , let name1 = greName gre1 name2 = greName gre2 + gre = gre1 `plusGRE` gre2 + -- See Note [Preserve parent information when combining import OccEnvs] = assertPpr (name1 == name2) (ppr name1 <+> ppr name2) $ if is_parent1 - then item1 - else item2 + then item1 { imp_item = gre } + else item2 { imp_item = gre } -- Discard C(C,T) in favour of T(T, T1, T2, T3). -- 'combine' may also be called for pattern synonyms which appear both ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -175,7 +175,7 @@ filterAvail keep ie rest = -- 'avails' may have several items with the same availName -- E.g import Ix( Ix(..), index ) -- will give Ix(Ix,index,range) and Ix(index) --- We want to combine these; addAvail does that +-- We want to combine these; plusAvail does that nubAvails :: [AvailInfo] -> [AvailInfo] nubAvails avails = eltsDNameEnv (foldl' add emptyDNameEnv avails) where ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -76,6 +76,7 @@ module GHC.Types.Name.Reader ( -- ** Global 'RdrName' mapping elements: 'GlobalRdrElt', 'Provenance', 'ImportSpec' GlobalRdrEltX(..), GlobalRdrElt, IfGlobalRdrElt, FieldGlobalRdrElt, greName, greNameSpace, greParent, greInfo, + plusGRE, insertGRE, forceGlobalRdrEnv, hydrateGlobalRdrEnv, isLocalGRE, isImportedGRE, isRecFldGRE, fieldGREInfo, @@ -1165,6 +1166,17 @@ data WhichGREs info where } -> WhichGREs GREInfo +instance Outputable (WhichGREs info) where + ppr SameNameSpace = text "SameNameSpace" + ppr (RelevantGREs { includeFieldSelectors = sel + , lookupVariablesForFields = vars + , lookupTyConsAsWell = tcs_too }) + = braces $ hsep + [ text "RelevantGREs" + , text (show sel) + , if vars then text "[vars]" else empty + , if tcs_too then text "[tcs]" else empty ] + -- | Look up as many possibly relevant 'GlobalRdrElt's as possible. pattern AllRelevantGREs :: WhichGREs GREInfo pattern AllRelevantGREs = @@ -1199,6 +1211,17 @@ data LookupChild -- See Note [childGREPriority]. } +instance Outputable LookupChild where + ppr (LookupChild { wantedParent = par + , lookupDataConFirst = dc + , prioritiseParent = prio_parent }) + = braces $ hsep + [ text "LookupChild" + , braces (text "parent:" <+> ppr par) + , if dc then text "[dc_first]" else empty + , if prio_parent then text "[prio_parent]" else empty + ] + -- | After looking up something with the given 'NameSpace', is the resulting -- 'GlobalRdrElt' we have obtained relevant, according to the 'RelevantGREs' -- specification of which 'NameSpace's are relevant? ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== testsuite/tests/rename/should_compile/T24084.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084 where + +import T24084_B (Foo, Bar) + +data X + +instance Foo X where + type Bar X = X ===================================== testsuite/tests/rename/should_compile/T24084_A.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_A (Foo (..)) where + +class Foo a where + type Bar a ===================================== testsuite/tests/rename/should_compile/T24084_B.hs ===================================== @@ -0,0 +1,7 @@ + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_B (module T24084_A) where + +import T24084_A + ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -216,6 +216,7 @@ test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) test('T24037', normal, compile, ['']) +test('T24084', [extra_files(['T24084_A.hs', 'T24084_B.hs'])], multimod_compile, ['T24084', '-v0']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39751402c6a48f3a4024e5c9748ec8b3604d55d5...cc5c6853fd3f322236cc1daa02ddcf3391965447 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39751402c6a48f3a4024e5c9748ec8b3604d55d5...cc5c6853fd3f322236cc1daa02ddcf3391965447 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 21:32:13 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sat, 14 Oct 2023 17:32:13 -0400 Subject: [Git][ghc/ghc][wip/expand-do] more MR review changes Message-ID: <652b08dd71d95_7336f2fcf09c105052@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: d92591a3 by Apoorv Ingle at 2023-10-14T16:31:44-05:00 more MR review changes - - - - - 5 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Types/Origin.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -466,14 +466,9 @@ isHsThingRnStmt _ = False isHsThingRnPat (OrigPat{}) = True isHsThingRnPat _ = False -type HsExpansionRn p - = HsExpansion -- See Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - HsThingRn -- Original source - (HsExpr p) -- Expanded expression in a p pass - data XXExprGhcRn - = ExpandedThingRn - {-# UNPACK #-} !(HsExpansionRn GhcRn) + = ExpandedThingRn { xrn_orig :: HsThingRn -- The original source thing + , xrn_expanded :: HsExpr GhcRn } -- The compiler generated expanded thing | PopErrCtxt -- A hint for typechecker to pop {-# UNPACK #-} !(LHsExpr GhcRn) -- the top of the error context stack @@ -497,7 +492,7 @@ mkExpandedExpr :: HsExpr GhcRn -- ^ source expression -> HsExpr GhcRn -- ^ expanded expression -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' -mkExpandedExpr oExpr eExpr = XExpr (ExpandedThingRn (HsExpanded (OrigExpr oExpr) eExpr)) +mkExpandedExpr oExpr eExpr = XExpr (ExpandedThingRn (OrigExpr oExpr) eExpr) -- | Build an expression using the extension constructor `XExpr`, -- and the two components of the expansion: original do stmt and @@ -506,13 +501,13 @@ mkExpandedStmt :: ExprLStmt GhcRn -- ^ source statement -> HsExpr GhcRn -- ^ expanded expression -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' -mkExpandedStmt oStmt eExpr = XExpr (ExpandedThingRn (HsExpanded (OrigStmt oStmt) eExpr)) +mkExpandedStmt oStmt eExpr = XExpr (ExpandedThingRn (OrigStmt oStmt) eExpr) mkExpandedPatRn :: LPat GhcRn -- ^ source pattern -> HsExpr GhcRn -- ^ expanded expression -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' -mkExpandedPatRn oPat eExpr = XExpr (ExpandedThingRn (HsExpanded (OrigPat oPat) eExpr)) +mkExpandedPatRn oPat eExpr = XExpr (ExpandedThingRn (OrigPat oPat) eExpr) -- | Build an expression using the extension constructor `XExpr`, -- and the two components of the expansion: original do stmt and @@ -539,7 +534,8 @@ data XXExprGhcTc | ExpandedThingTc -- See Note [Rebindable syntax and HsExpansion] -- See Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - {-# UNPACK #-} !(HsExpansionRn GhcTc) + { xtc_orig :: HsThingRn -- The original user written thing + , xtc_expanded :: HsExpr GhcTc } -- The expanded typechecked expression | ConLikeTc -- Result of typechecking a data-con -- See Note [Typechecking data constructors] in @@ -567,7 +563,7 @@ mkExpandedExprTc :: HsExpr GhcRn -- ^ source expression -> HsExpr GhcTc -- ^ expanded typechecked expression -> HsExpr GhcTc -- ^ suitably wrapped 'HsExpansion' -mkExpandedExprTc oExpr eExpr = XExpr (ExpandedThingTc (HsExpanded (OrigExpr oExpr) eExpr)) +mkExpandedExprTc oExpr eExpr = XExpr (ExpandedThingTc (OrigExpr oExpr) eExpr) -- | Build a 'HsExpansion' out of an extension constructor. -- The two components of the expansion are: original statement and @@ -576,7 +572,7 @@ mkExpandedStmtTc :: ExprLStmt GhcRn -- ^ source do statement -> HsExpr GhcTc -- ^ expanded typechecked expression -> HsExpr GhcTc -- ^ suitably wrapped 'HsExpansion' -mkExpandedStmtTc oStmt eExpr = XExpr (ExpandedThingTc (HsExpanded (OrigStmt oStmt) eExpr)) +mkExpandedStmtTc oStmt eExpr = XExpr (ExpandedThingTc (OrigStmt oStmt) eExpr) {- ********************************************************************* * * @@ -822,18 +818,19 @@ instance Outputable HsThingRn where where ppr_builder prefix x = ifPprDebug (braces (text prefix <+> parens (ppr x))) (ppr x) instance Outputable XXExprGhcRn where - ppr (ExpandedThingRn e) = ppr e - ppr (PopErrCtxt e) = ifPprDebug (braces (text " ppr e)) (ppr e) + ppr (ExpandedThingRn o e) = ifPprDebug (braces $ vcat [ppr o, ppr e]) (ppr o) + ppr (PopErrCtxt e) = ifPprDebug (braces (text "" <+> ppr e)) (ppr e) instance Outputable XXExprGhcTc where ppr (WrapExpr (HsWrap co_fn e)) = pprHsWrapper co_fn (\_parens -> pprExpr e) - ppr (ExpandedThingTc e) - = ppr e -- e is an HsExpansion, we print the original + ppr (ExpandedThingTc o e) + = ifPprDebug (braces $ vcat [ppr o, ppr e]) (ppr o) + -- e is the expanded expression, we print the original -- expression (HsExpr GhcRn), not the -- expanded typechecked one (HsExpr GhcTc), - -- unless we are in ppr's debug mode then both get printed + -- unless we are in ppr's debug mode printed both ppr (ConLikeTc con _ _) = pprPrefixOcc con -- Used in error messages generated by @@ -862,19 +859,19 @@ ppr_infix_expr (XExpr x) = case ghcPass @p of ppr_infix_expr _ = Nothing ppr_infix_expr_rn :: XXExprGhcRn -> Maybe SDoc -ppr_infix_expr_rn (ExpandedThingRn thing) = ppr_infix_hs_expansion thing +ppr_infix_expr_rn (ExpandedThingRn thing _) = ppr_infix_hs_expansion thing ppr_infix_expr_rn (PopErrCtxt (L _ a)) = ppr_infix_expr a ppr_infix_expr_tc :: XXExprGhcTc -> Maybe SDoc -ppr_infix_expr_tc (WrapExpr (HsWrap _ e)) = ppr_infix_expr e -ppr_infix_expr_tc (ExpandedThingTc thing) = ppr_infix_hs_expansion thing -ppr_infix_expr_tc (ConLikeTc {}) = Nothing -ppr_infix_expr_tc (HsTick {}) = Nothing -ppr_infix_expr_tc (HsBinTick {}) = Nothing +ppr_infix_expr_tc (WrapExpr (HsWrap _ e)) = ppr_infix_expr e +ppr_infix_expr_tc (ExpandedThingTc thing _) = ppr_infix_hs_expansion thing +ppr_infix_expr_tc (ConLikeTc {}) = Nothing +ppr_infix_expr_tc (HsTick {}) = Nothing +ppr_infix_expr_tc (HsBinTick {}) = Nothing -ppr_infix_hs_expansion :: HsExpansion HsThingRn b -> Maybe SDoc -ppr_infix_hs_expansion thing | OrigExpr e <- original thing = ppr_infix_expr e - | otherwise = Nothing +ppr_infix_hs_expansion :: HsThingRn -> Maybe SDoc +ppr_infix_hs_expansion (OrigExpr e) = ppr_infix_expr e +ppr_infix_hs_expansion _ = Nothing ppr_apps :: (OutputableBndrId p) => HsExpr (GhcPass p) @@ -967,18 +964,18 @@ hsExprNeedsParens prec = go go_x_tc :: XXExprGhcTc -> Bool go_x_tc (WrapExpr (HsWrap _ e)) = hsExprNeedsParens prec e - go_x_tc (ExpandedThingTc thing) = hsExpandedNeedsParens thing + go_x_tc (ExpandedThingTc thing _) = hsExpandedNeedsParens thing go_x_tc (ConLikeTc {}) = False go_x_tc (HsTick _ (L _ e)) = hsExprNeedsParens prec e go_x_tc (HsBinTick _ _ (L _ e)) = hsExprNeedsParens prec e go_x_rn :: XXExprGhcRn -> Bool - go_x_rn (ExpandedThingRn thing) = hsExpandedNeedsParens thing - go_x_rn (PopErrCtxt (L _ a)) = hsExprNeedsParens prec a + go_x_rn (ExpandedThingRn thing _) = hsExpandedNeedsParens thing + go_x_rn (PopErrCtxt (L _ a)) = hsExprNeedsParens prec a - hsExpandedNeedsParens :: HsExpansion HsThingRn a -> Bool - hsExpandedNeedsParens thing | OrigExpr e <- original thing = hsExprNeedsParens prec e - | otherwise = False + hsExpandedNeedsParens :: HsThingRn -> Bool + hsExpandedNeedsParens (OrigExpr e) = hsExprNeedsParens prec e + hsExpandedNeedsParens _ = False -- | Parenthesize an expression without token information gHsPar :: LHsExpr (GhcPass id) -> HsExpr (GhcPass id) @@ -1014,18 +1011,18 @@ isAtomicHsExpr (XExpr x) where go_x_tc :: XXExprGhcTc -> Bool go_x_tc (WrapExpr (HsWrap _ e)) = isAtomicHsExpr e - go_x_tc (ExpandedThingTc thing) = isAtomicHsExpanded thing + go_x_tc (ExpandedThingTc thing _) = isAtomicHsExpanded thing go_x_tc (ConLikeTc {}) = True go_x_tc (HsTick {}) = False go_x_tc (HsBinTick {}) = False go_x_rn :: XXExprGhcRn -> Bool - go_x_rn (ExpandedThingRn thing) = isAtomicHsExpanded thing - go_x_rn (PopErrCtxt (L _ a)) = isAtomicHsExpr a + go_x_rn (ExpandedThingRn thing _) = isAtomicHsExpanded thing + go_x_rn (PopErrCtxt (L _ a)) = isAtomicHsExpr a - isAtomicHsExpanded :: HsExpansion HsThingRn b -> Bool - isAtomicHsExpanded thing | OrigExpr e <- original thing = isAtomicHsExpr e - | otherwise = False + isAtomicHsExpanded :: HsThingRn -> Bool + isAtomicHsExpanded (OrigExpr e) = isAtomicHsExpr e + isAtomicHsExpanded _ = False isAtomicHsExpr _ = False ===================================== compiler/GHC/Hs/Syn/Type.hs ===================================== @@ -144,7 +144,7 @@ hsExprType (HsStatic (_, ty) _s) = ty hsExprType (HsPragE _ _ e) = lhsExprType e hsExprType (HsEmbTy x _ _) = dataConCantHappen x hsExprType (XExpr (WrapExpr (HsWrap wrap e))) = hsWrapperType wrap $ hsExprType e -hsExprType (XExpr (ExpandedThingTc thing)) = hsExprType $ expanded thing +hsExprType (XExpr (ExpandedThingTc _ e)) = hsExprType e hsExprType (XExpr (ConLikeTc con _ _)) = conLikeType con hsExprType (XExpr (HsTick _ e)) = lhsExprType e hsExprType (XExpr (HsBinTick _ _ e)) = lhsExprType e ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -87,6 +87,14 @@ import qualified Data.List.NonEmpty as NE {- Note [Handling overloaded and rebindable constructs] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Nomenclature +------------- +* Expansion (`HsExpr GhcRn -> HsExpr GhcRn`): expand between renaming and + typechecking, using the `HsExpansion` constructor of `HsExpr`. +* Desugaring (`HsExpr GhcTc -> Core.Expr`): convert the typechecked `HsSyn` to Core. This is done in GHC.HsToCore + + For overloaded constructs (overloaded literals, lists, strings), and rebindable constructs (e.g. if-then-else), our general plan is this, using overloaded labels #foo as an example: ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -17,7 +17,7 @@ -- | Expand @Do@ block statements into @(>>=)@, @(>>)@ and @let at s -- After renaming but right ebefore type checking -module GHC.Tc.Gen.Do where +module GHC.Tc.Gen.Do (expandDoStmts) where import GHC.Prelude @@ -66,18 +66,24 @@ expandDoStmts doFlav stmts = do expanded_expr <- expand_do_stmts doFlav stmts -- See Note [Expanding HsDo with HsExpansion] expand_do_stmts :: HsDoFlavour -> [ExprLStmt GhcRn] -> TcM (LHsExpr GhcRn) -expand_do_stmts ListComp _ = pprPanic "expand_do_stmts: impossible happened. ListComp" empty +expand_do_stmts ListComp _ = + pprPanic "expand_do_stmts: impossible happened. ListComp" empty + -- handeled by `GHC.Tc.Gen.Match.tcLcStmt` expand_do_stmts _ [] = pprPanic "expand_do_stmts: impossible happened. Empty stmts" empty expand_do_stmts _ (stmt@(L _ (TransStmt {})):_) = pprPanic "expand_do_stmts: TransStmt" $ ppr stmt + -- handeled by `GHC.Tc.Gen.Match.tcLcStmt` expand_do_stmts _ (stmt@(L _ (ParStmt {})):_) = pprPanic "expand_do_stmts: ParStmt" $ ppr stmt + -- handeled by `GHC.Tc.Gen.Match.tcLcStmt` expand_do_stmts _ (stmt@(L _ (ApplicativeStmt{})): _) = pprPanic "expand_do_stmts: Applicative Stmt" $ ppr stmt + -- Handeled by tcSyntaxOp see `GHC.Tc.Gen.Match.tcStmtsAndThen` + expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] -- last statement of a list comprehension, needs to explicitly return it @@ -108,7 +114,6 @@ expand_do_stmts do_or_lc (stmt@(L loc (BindStmt xbsrn pat e)): lstmts) | SyntaxExprRn bind_op <- xbsrn_bindOp xbsrn , fail_op <- xbsrn_failOp xbsrn -- the pattern binding pat can fail --- instead of making a new internal name, the fail block is just an anonymous lambda -- stmts ~~> stmt' f = \case pat -> stmts'; -- _ -> fail "Pattern match failure .." -- ------------------------------------------------------- @@ -124,7 +129,8 @@ expand_do_stmts do_or_lc (stmt@(L loc (BindStmt xbsrn pat e)): lstmts) = pprPanic "expand_do_stmts: The impossible happened, missing bind operator from renamer" (text "stmt" <+> ppr stmt) expand_do_stmts do_or_lc (stmt@(L loc (BodyStmt _ e (SyntaxExprRn then_op) _)) : lstmts) = --- See Note [BodyStmt] +-- See Note [BodyStmt] in Language.Haskell.Syntax.Expr +-- See Note [Expanding HsDo with HsExpansion] Equation (1) below -- stmts ~~> stmts' -- ---------------------------------------------- -- e ; stmts ~~> (>>) e stmts' @@ -145,7 +151,8 @@ expand_do_stmts do_or_lc -- at the end of expanded rec block })) : lstmts) = --- See Note [Typing a RecStmt] +-- See Note [Typing a RecStmt] in Language.Haskell.Syntax.Expr +-- See Note [Expanding HsDo with HsExpansion] Equation (4) below -- stmts ~~> stmts' -- ------------------------------------------------------------------------------------------- -- rec { later_ids, local_ids, rec_block } ; stmts @@ -227,20 +234,20 @@ mk_fail_block _ _ _ _ = pprPanic "mk_fail_block: impossible happened" empty {- Note [Expanding HsDo with HsExpansion] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We expand `do`-blocks before typechecking it, rather than type checking it and then -desugaring it by re-using the existing `HsExpansions` and `RebindableSyntax` machinery. +We expand `do`-blocks before typechecking it, by re-using the existing `HsExpansions` and `RebindableSyntax` machinery. This is very similar to: 1. Expansions done in `GHC.Rename.Expr.rnHsIf` for expanding `HsIf`; and 2. `desugarRecordUpd` in `GHC.Tc.Gen.Expr.tcExpr` for expanding `RecordUpd` +See Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr To disabmiguate desugaring (`HsExpr GhcTc -> Core.Expr`) we use the phrase expansion (`HsExpr GhcRn -> HsExpr GhcRn`) -See Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr - This expansion is done right before typechecking and after renaming See Part 2. of Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` +Historical note START +--------------------- In previous versions of GHC, the `do`-notation wasn't expanded before typechecking, instead the typechecker would operate directly on the original. Why? because it ensured that type error messages were explained in terms of @@ -262,8 +269,13 @@ what the programmer has written. In practice, however, this didn't work very wel the quantifiers impredicatively (#18324). Again, that happens automatically if you typecheck the expanded expression. -* Equationally speaking, we have the following schema for expanding `do`-statements. - They capture the essence of statement expansions as implemented in `expand_do_stmts` +Historical note END +------------------- + +Do Expansions Equationally +-------------------------- +We have the following schema for expanding `do`-statements. +They capture the essence of statement expansions as implemented in `expand_do_stmts` DO【 _ 】 maps a sequence of do statements and recursively converts them into expressions @@ -277,9 +289,21 @@ what the programmer has written. In practice, however, this didn't work very wel _ -> fail "pattern p failure")) (3) DO【 let x = e; ss 】 - = ‹ExpansionStmt (let x = e)› (let x = e in (‹PopErrCtxt›DO【 ss 】)) + = ‹ExpansionStmt (let x = e)› (let x = e in (‹PopErrCtxt›DO【 ss 】)) + + + (4) DO【 rec ss; sss 】 + = (>>=) e (\vars -> ‹PopErrCtxt›DO【 sss 】)) + where (vars, e) = RECDO【 ss 】 + + (5) DO【 s 】 = s + + RECDO【 _ 】 maps a sequence of recursively dependent monadic statements and converts it into an expression paired + with the variables that the rec finds a fix point of. + + (6) RECDO【 ss 】 = (vars, mfix (\~vars -> (>>=) (DO【 ss 】) (return vars))) + where vars are all the variables free in ss - (4) DO【 s 】 = s For a concrete example, consider a `do`-block written by the user @@ -297,8 +321,7 @@ The {l1} etc are location/source span information stored in the AST by the parse {g1} are compiler generated source spans. -The 3 main points to consider are: - +The 3 non-obvious points to consider are: 1. Wrap the expression with a `fail` block if the pattern match is not irrefutable. See Part 1. Below 2. Generate appropriate warnings for discarded results in a body statement @@ -307,10 +330,12 @@ The 3 main points to consider are: 3. Generating appropriate type error messages which blame the correct source spans See Part 3 Below -Part 1. Wrapping failable patterns with fail blocks ---------------------------------------------------- +Part 1. Expanding Patterns Bindings +----------------------------------- If `p` is a failable pattern---checked by `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`--- -we need to wrap it with a `fail`-block. For example, the expansion of the `do`-block +we need to wrap it with a `fail`-block. See Equation (2) above. + +The expansion of the `do`-block do { Just p <- e1; e2 } @@ -321,7 +346,7 @@ we need to wrap it with a `fail`-block. For example, the expansion of the `do`-b Just p -> e2 _ -> fail "failable pattern p at location") -The `fail`-block wrapping is done in `GHC.Tc.Gen.Do.mk_failable_expr`. +The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. * Note the explicit call to `fail`, in the monad of the `do`-block. Part of the specification of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash @@ -331,20 +356,19 @@ The `fail`-block wrapping is done in `GHC.Tc.Gen.Do.mk_failable_expr`. pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate a `MonadFail` constraint that isn't needed. -* Why an anonymous continuation lambda? - We need a lambda for the types to match: this expression is a second - argument to `(>>=)` so it needs to be of type `a -> m b`, a function. - It is anonymous because: - a. the name will be compiler generated and will never be seen by the user, and; - b. we are in the post renaming stage fresh naming will require non-trivial amount of plumbing for little gain. +* _Wrinkle 1_: For pattern synonyms, we always wrap it with a `fail`-block. + When the pattern is irrefutable, we do not add the fail block. + This is important because the occurrence of `fail` means that the typechecker + will generate a `MonadFail` constraint, and the language spec says that + we should not do that for irrefutable patterns. -* Wrinkle 1: For pattern synonyms, we always wrap it with a `fail`-block. - The irrefutable pattern checker returns false for pattern synonyms, but then after desugaring - we would get a pattern match checker's redundant pattern warnings. To avoid such - spurious warnings we filter out those type patterns that appear in a do expansion generated match - in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate + a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. + because after desugaring, it is marked as irrefutable! To avoid such + spurious warnings and type checker errors, we filter out those patterns that appear + in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) -* Wrinkle 2: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we +* _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we attach to that constraint? It should be a good one, because it'll show up in error messages when the `MonadFail` constraint can't be solved. Ideally, it should identify the pattern `p`. Hence, we wrap the `fail` alternative expression with a `ExpandedPat` @@ -358,14 +382,15 @@ the value when `-Wunused-binds` flag is turned on. (See testcase T3263-2.hs) For example the `do`-block - do { e1; e2 } + do { e1; e2 } -- where, e1 :: m Int expands to (>>) e1 e2 -* If `e1` returns a non-() value then we emit a value discarded warning. This check is done during desugaring - `HsToCore.dsExpr` in the `HsApp` with a call to `HsToCore.warnUnusedBindValue`. +* If `e1` returns a non-() value we want to emit a warning, telling the user that they + are discarding the value returned by e1. This is done by `HsToCore.dsExpr` in the `HsApp` + with a call to `HsToCore.warnUnusedBindValue`. * The decision to trigger the warning is: if the function is a compiler generated `(>>)`, and its first argument `e1` has a non-() type @@ -398,7 +423,7 @@ It stores the original statement (with location) and the expanded expression This is similar to vanilla `HsExpansion` and rebindable syntax See Note [Rebindable syntax and HsExpansion] in `GHC.Hs.Expr`. - * Recall, that when a source function arugment fails to typecheck, + * Recall, that when a source function argument fails to typecheck, we print an error message like "In the second argument of the function f..". However, `(>>)` is generated thus, we don't want to display that to the user; it would be confusing. But also, we do not want to completely ignore it as we do want to keep the error blame carets ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -740,9 +740,9 @@ exprCtOrigin (HsUntypedSplice {}) = Shouldn'tHappenOrigin "TH untyped splice" exprCtOrigin (HsProc {}) = Shouldn'tHappenOrigin "proc" exprCtOrigin (HsStatic {}) = Shouldn'tHappenOrigin "static expression" exprCtOrigin (HsEmbTy {}) = Shouldn'tHappenOrigin "type expression" -exprCtOrigin (XExpr (ExpandedThingRn thing)) | OrigExpr a <- original thing = exprCtOrigin a - | OrigStmt _ <- original thing = DoOrigin - | OrigPat p <- original thing = DoPatOrigin p +exprCtOrigin (XExpr (ExpandedThingRn thing _)) | OrigExpr a <- thing = exprCtOrigin a + | OrigStmt _ <- thing = DoOrigin + | OrigPat p <- thing = DoPatOrigin p exprCtOrigin (XExpr (PopErrCtxt {})) = Shouldn'tHappenOrigin "PopErrCtxt" -- | Extract a suitable CtOrigin from a MatchGroup View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d92591a33c0e63733b334b0b6d3d6891cee7bc73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d92591a33c0e63733b334b0b6d3d6891cee7bc73 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 22:02:28 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Sat, 14 Oct 2023 18:02:28 -0400 Subject: [Git][ghc/ghc][wip/expand-do] more MR review changes Message-ID: <652b0ff42a8e5_7336f3f871d810648e@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 69cff342 by Apoorv Ingle at 2023-10-14T17:02:08-05:00 more MR review changes - - - - - 13 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Zonk/Type.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -466,14 +466,9 @@ isHsThingRnStmt _ = False isHsThingRnPat (OrigPat{}) = True isHsThingRnPat _ = False -type HsExpansionRn p - = HsExpansion -- See Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - HsThingRn -- Original source - (HsExpr p) -- Expanded expression in a p pass - data XXExprGhcRn - = ExpandedThingRn - {-# UNPACK #-} !(HsExpansionRn GhcRn) + = ExpandedThingRn { xrn_orig :: HsThingRn -- The original source thing + , xrn_expanded :: HsExpr GhcRn } -- The compiler generated expanded thing | PopErrCtxt -- A hint for typechecker to pop {-# UNPACK #-} !(LHsExpr GhcRn) -- the top of the error context stack @@ -497,7 +492,7 @@ mkExpandedExpr :: HsExpr GhcRn -- ^ source expression -> HsExpr GhcRn -- ^ expanded expression -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' -mkExpandedExpr oExpr eExpr = XExpr (ExpandedThingRn (HsExpanded (OrigExpr oExpr) eExpr)) +mkExpandedExpr oExpr eExpr = XExpr (ExpandedThingRn (OrigExpr oExpr) eExpr) -- | Build an expression using the extension constructor `XExpr`, -- and the two components of the expansion: original do stmt and @@ -506,13 +501,13 @@ mkExpandedStmt :: ExprLStmt GhcRn -- ^ source statement -> HsExpr GhcRn -- ^ expanded expression -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' -mkExpandedStmt oStmt eExpr = XExpr (ExpandedThingRn (HsExpanded (OrigStmt oStmt) eExpr)) +mkExpandedStmt oStmt eExpr = XExpr (ExpandedThingRn (OrigStmt oStmt) eExpr) mkExpandedPatRn :: LPat GhcRn -- ^ source pattern -> HsExpr GhcRn -- ^ expanded expression -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' -mkExpandedPatRn oPat eExpr = XExpr (ExpandedThingRn (HsExpanded (OrigPat oPat) eExpr)) +mkExpandedPatRn oPat eExpr = XExpr (ExpandedThingRn (OrigPat oPat) eExpr) -- | Build an expression using the extension constructor `XExpr`, -- and the two components of the expansion: original do stmt and @@ -539,7 +534,8 @@ data XXExprGhcTc | ExpandedThingTc -- See Note [Rebindable syntax and HsExpansion] -- See Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - {-# UNPACK #-} !(HsExpansionRn GhcTc) + { xtc_orig :: HsThingRn -- The original user written thing + , xtc_expanded :: HsExpr GhcTc } -- The expanded typechecked expression | ConLikeTc -- Result of typechecking a data-con -- See Note [Typechecking data constructors] in @@ -567,7 +563,7 @@ mkExpandedExprTc :: HsExpr GhcRn -- ^ source expression -> HsExpr GhcTc -- ^ expanded typechecked expression -> HsExpr GhcTc -- ^ suitably wrapped 'HsExpansion' -mkExpandedExprTc oExpr eExpr = XExpr (ExpandedThingTc (HsExpanded (OrigExpr oExpr) eExpr)) +mkExpandedExprTc oExpr eExpr = XExpr (ExpandedThingTc (OrigExpr oExpr) eExpr) -- | Build a 'HsExpansion' out of an extension constructor. -- The two components of the expansion are: original statement and @@ -576,7 +572,7 @@ mkExpandedStmtTc :: ExprLStmt GhcRn -- ^ source do statement -> HsExpr GhcTc -- ^ expanded typechecked expression -> HsExpr GhcTc -- ^ suitably wrapped 'HsExpansion' -mkExpandedStmtTc oStmt eExpr = XExpr (ExpandedThingTc (HsExpanded (OrigStmt oStmt) eExpr)) +mkExpandedStmtTc oStmt eExpr = XExpr (ExpandedThingTc (OrigStmt oStmt) eExpr) {- ********************************************************************* * * @@ -822,18 +818,19 @@ instance Outputable HsThingRn where where ppr_builder prefix x = ifPprDebug (braces (text prefix <+> parens (ppr x))) (ppr x) instance Outputable XXExprGhcRn where - ppr (ExpandedThingRn e) = ppr e - ppr (PopErrCtxt e) = ifPprDebug (braces (text " ppr e)) (ppr e) + ppr (ExpandedThingRn o e) = ifPprDebug (braces $ vcat [ppr o, ppr e]) (ppr o) + ppr (PopErrCtxt e) = ifPprDebug (braces (text "" <+> ppr e)) (ppr e) instance Outputable XXExprGhcTc where ppr (WrapExpr (HsWrap co_fn e)) = pprHsWrapper co_fn (\_parens -> pprExpr e) - ppr (ExpandedThingTc e) - = ppr e -- e is an HsExpansion, we print the original + ppr (ExpandedThingTc o e) + = ifPprDebug (braces $ vcat [ppr o, ppr e]) (ppr o) + -- e is the expanded expression, we print the original -- expression (HsExpr GhcRn), not the -- expanded typechecked one (HsExpr GhcTc), - -- unless we are in ppr's debug mode then both get printed + -- unless we are in ppr's debug mode printed both ppr (ConLikeTc con _ _) = pprPrefixOcc con -- Used in error messages generated by @@ -862,19 +859,19 @@ ppr_infix_expr (XExpr x) = case ghcPass @p of ppr_infix_expr _ = Nothing ppr_infix_expr_rn :: XXExprGhcRn -> Maybe SDoc -ppr_infix_expr_rn (ExpandedThingRn thing) = ppr_infix_hs_expansion thing +ppr_infix_expr_rn (ExpandedThingRn thing _) = ppr_infix_hs_expansion thing ppr_infix_expr_rn (PopErrCtxt (L _ a)) = ppr_infix_expr a ppr_infix_expr_tc :: XXExprGhcTc -> Maybe SDoc -ppr_infix_expr_tc (WrapExpr (HsWrap _ e)) = ppr_infix_expr e -ppr_infix_expr_tc (ExpandedThingTc thing) = ppr_infix_hs_expansion thing -ppr_infix_expr_tc (ConLikeTc {}) = Nothing -ppr_infix_expr_tc (HsTick {}) = Nothing -ppr_infix_expr_tc (HsBinTick {}) = Nothing +ppr_infix_expr_tc (WrapExpr (HsWrap _ e)) = ppr_infix_expr e +ppr_infix_expr_tc (ExpandedThingTc thing _) = ppr_infix_hs_expansion thing +ppr_infix_expr_tc (ConLikeTc {}) = Nothing +ppr_infix_expr_tc (HsTick {}) = Nothing +ppr_infix_expr_tc (HsBinTick {}) = Nothing -ppr_infix_hs_expansion :: HsExpansion HsThingRn b -> Maybe SDoc -ppr_infix_hs_expansion thing | OrigExpr e <- original thing = ppr_infix_expr e - | otherwise = Nothing +ppr_infix_hs_expansion :: HsThingRn -> Maybe SDoc +ppr_infix_hs_expansion (OrigExpr e) = ppr_infix_expr e +ppr_infix_hs_expansion _ = Nothing ppr_apps :: (OutputableBndrId p) => HsExpr (GhcPass p) @@ -967,18 +964,18 @@ hsExprNeedsParens prec = go go_x_tc :: XXExprGhcTc -> Bool go_x_tc (WrapExpr (HsWrap _ e)) = hsExprNeedsParens prec e - go_x_tc (ExpandedThingTc thing) = hsExpandedNeedsParens thing + go_x_tc (ExpandedThingTc thing _) = hsExpandedNeedsParens thing go_x_tc (ConLikeTc {}) = False go_x_tc (HsTick _ (L _ e)) = hsExprNeedsParens prec e go_x_tc (HsBinTick _ _ (L _ e)) = hsExprNeedsParens prec e go_x_rn :: XXExprGhcRn -> Bool - go_x_rn (ExpandedThingRn thing) = hsExpandedNeedsParens thing - go_x_rn (PopErrCtxt (L _ a)) = hsExprNeedsParens prec a + go_x_rn (ExpandedThingRn thing _) = hsExpandedNeedsParens thing + go_x_rn (PopErrCtxt (L _ a)) = hsExprNeedsParens prec a - hsExpandedNeedsParens :: HsExpansion HsThingRn a -> Bool - hsExpandedNeedsParens thing | OrigExpr e <- original thing = hsExprNeedsParens prec e - | otherwise = False + hsExpandedNeedsParens :: HsThingRn -> Bool + hsExpandedNeedsParens (OrigExpr e) = hsExprNeedsParens prec e + hsExpandedNeedsParens _ = False -- | Parenthesize an expression without token information gHsPar :: LHsExpr (GhcPass id) -> HsExpr (GhcPass id) @@ -1014,18 +1011,18 @@ isAtomicHsExpr (XExpr x) where go_x_tc :: XXExprGhcTc -> Bool go_x_tc (WrapExpr (HsWrap _ e)) = isAtomicHsExpr e - go_x_tc (ExpandedThingTc thing) = isAtomicHsExpanded thing + go_x_tc (ExpandedThingTc thing _) = isAtomicHsExpanded thing go_x_tc (ConLikeTc {}) = True go_x_tc (HsTick {}) = False go_x_tc (HsBinTick {}) = False go_x_rn :: XXExprGhcRn -> Bool - go_x_rn (ExpandedThingRn thing) = isAtomicHsExpanded thing - go_x_rn (PopErrCtxt (L _ a)) = isAtomicHsExpr a + go_x_rn (ExpandedThingRn thing _) = isAtomicHsExpanded thing + go_x_rn (PopErrCtxt (L _ a)) = isAtomicHsExpr a - isAtomicHsExpanded :: HsExpansion HsThingRn b -> Bool - isAtomicHsExpanded thing | OrigExpr e <- original thing = isAtomicHsExpr e - | otherwise = False + isAtomicHsExpanded :: HsThingRn -> Bool + isAtomicHsExpanded (OrigExpr e) = isAtomicHsExpr e + isAtomicHsExpanded _ = False isAtomicHsExpr _ = False ===================================== compiler/GHC/Hs/Syn/Type.hs ===================================== @@ -144,7 +144,7 @@ hsExprType (HsStatic (_, ty) _s) = ty hsExprType (HsPragE _ _ e) = lhsExprType e hsExprType (HsEmbTy x _ _) = dataConCantHappen x hsExprType (XExpr (WrapExpr (HsWrap wrap e))) = hsWrapperType wrap $ hsExprType e -hsExprType (XExpr (ExpandedThingTc thing)) = hsExprType $ expanded thing +hsExprType (XExpr (ExpandedThingTc _ e)) = hsExprType e hsExprType (XExpr (ConLikeTc con _ _)) = conLikeType con hsExprType (XExpr (HsTick _ e)) = lhsExprType e hsExprType (XExpr (HsBinTick _ _ e)) = lhsExprType e ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -287,10 +287,10 @@ dsExpr (HsOverLit _ lit) dsExpr e@(XExpr ext_expr_tc) = case ext_expr_tc of - ExpandedThingTc thing - | OrigStmt (L loc _) <- original thing - -> putSrcSpanDsA loc $ dsExpr (expanded thing) - | otherwise -> dsExpr $ expanded thing + ExpandedThingTc o e + | OrigStmt (L loc _) <- o + -> putSrcSpanDsA loc $ dsExpr e + | otherwise -> dsExpr e WrapExpr {} -> dsHsWrapped e ConLikeTc con tvs tys -> dsConLike con tvs tys -- Hpc Support @@ -937,7 +937,7 @@ warnUnusedBindValue fun arg@(L loc _) arg_ty fish_var (L _ (HsAppType _ e _ _)) = fish_var e fish_var (L l (XExpr (WrapExpr (HsWrap _ e)))) = do (l, e') <- fish_var (L l e) return (l, e') - fish_var (L l (XExpr (ExpandedThingTc thing))) = fish_var (L l (expanded thing)) + fish_var (L l (XExpr (ExpandedThingTc _ e))) = fish_var (L l e) fish_var _ = Nothing warnUnusedBindValue _ _ _ = return () ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -1168,10 +1168,10 @@ viewLExprEq (e1,_) (e2,_) = lexp e1 e2 -- we have to compare the wrappers exp (XExpr (WrapExpr (HsWrap h e))) (XExpr (WrapExpr (HsWrap h' e'))) = wrap h h' && exp e e' - exp (XExpr (ExpandedThingTc thing)) (XExpr (ExpandedThingTc thing')) - | isHsThingRnExpr $ original thing - , isHsThingRnExpr $ original thing' - = exp (expanded thing) (expanded thing') + exp (XExpr (ExpandedThingTc o x)) (XExpr (ExpandedThingTc o' x')) + | isHsThingRnExpr o + , isHsThingRnExpr o' + = exp x x' exp (HsVar _ i) (HsVar _ i') = i == i' exp (XExpr (ConLikeTc c _ _)) (XExpr (ConLikeTc c' _ _)) = c == c' -- the instance for IPName derives using the id, so this works if the ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -1668,11 +1668,11 @@ repE (HsProjection _ xs) = repProjection (fmap (field_label . unLoc . dfoLabel . repE (HsEmbTy _ _ t) = do t1 <- repLTy (hswc_body t) rep2 typeEName [unC t1] -repE e@(XExpr (ExpandedThingRn thing)) - | OrigExpr e <- original thing +repE e@(XExpr (ExpandedThingRn o x)) + | OrigExpr e <- o = do { rebindable_on <- lift $ xoptM LangExt.RebindableSyntax ; if rebindable_on -- See Note [Quotation and rebindable syntax] - then repE $ expanded thing + then repE x else repE e } | otherwise = notHandled (ThExpressionForm e) ===================================== compiler/GHC/HsToCore/Ticks.hs ===================================== @@ -446,13 +446,13 @@ isCallSite :: HsExpr GhcTc -> Bool isCallSite HsApp{} = True isCallSite HsAppType{} = True isCallSite HsCase{} = True -isCallSite (XExpr (ExpandedThingTc thing)) - | OrigStmt (L _ BodyStmt{}) <- original thing +isCallSite (XExpr (ExpandedThingTc thing e)) + | OrigStmt (L _ BodyStmt{}) <- thing = False - | OrigStmt (L _ LastStmt{}) <- original thing + | OrigStmt (L _ LastStmt{}) <- thing = True | otherwise - = isCallSite $ expanded thing + = isCallSite e -- NB: OpApp, SectionL, SectionR are all expanded out isCallSite _ = False @@ -591,8 +591,8 @@ addTickHsExpr (HsProc x pat cmdtop) = addTickHsExpr (XExpr (WrapExpr (HsWrap w e))) = liftM (XExpr . WrapExpr . HsWrap w) $ (addTickHsExpr e) -- Explicitly no tick on inside -addTickHsExpr (XExpr (ExpandedThingTc (HsExpanded o e))) = - liftM (XExpr . ExpandedThingTc . HsExpanded o) $ +addTickHsExpr (XExpr (ExpandedThingTc o e)) = + liftM (XExpr . ExpandedThingTc o) $ addTickHsExpr e addTickHsExpr e@(XExpr (ConLikeTc {})) = return e @@ -658,8 +658,8 @@ addTickGRHSBody isOneOfMany isLambda isDoExp expr@(L pos e0) = do d <- getDensity case d of TickForBreakPoints - | XExpr (ExpandedThingTc thing) <- e0 - , OrigStmt (L _ LastStmt{}) <- original thing -> addTickLHsExprRHS expr + | XExpr (ExpandedThingTc thing _) <- e0 + , OrigStmt (L _ LastStmt{}) <- thing -> addTickLHsExprRHS expr | isDoExp -> addTickLHsExprNever expr TickForCoverage -> addTickLHsExprOptAlt isOneOfMany expr TickAllFunctions | isLambda -> ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -743,10 +743,10 @@ instance HiePass p => HasType (LocatedA (HsExpr (GhcPass p))) where RecordCon con_expr _ _ -> computeType con_expr ExprWithTySig _ e _ -> computeLType e HsPragE _ _ e -> computeLType e - XExpr (ExpandedThingTc thing) - | OrigExpr (HsGetField{}) <- original thing -- for record-dot-syntax - -> Just (hsExprType $ expanded thing) - | otherwise -> computeType (expanded thing) + XExpr (ExpandedThingTc thing e) + | OrigExpr (HsGetField{}) <- thing -- for record-dot-syntax + -> Just (hsExprType e) + | otherwise -> computeType e XExpr (HsTick _ e) -> computeLType e XExpr (HsBinTick _ _ e) -> computeLType e e -> Just (hsExprType e) @@ -1300,8 +1300,8 @@ instance HiePass p => ToHie (LocatedA (HsExpr (GhcPass p))) where WrapExpr (HsWrap w a) -> [ toHie $ L mspan a , toHie (L mspan w) ] - ExpandedThingTc thing - -> [ toHie (L mspan $ expanded thing) ] + ExpandedThingTc _ e + -> [ toHie (L mspan e) ] ConLikeTc con _ _ -> [ toHie $ C Use $ L mspan $ conLikeName con ] HsTick _ expr ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -87,6 +87,14 @@ import qualified Data.List.NonEmpty as NE {- Note [Handling overloaded and rebindable constructs] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Nomenclature +------------- +* Expansion (`HsExpr GhcRn -> HsExpr GhcRn`): expand between renaming and + typechecking, using the `HsExpansion` constructor of `HsExpr`. +* Desugaring (`HsExpr GhcTc -> Core.Expr`): convert the typechecked `HsSyn` to Core. This is done in GHC.HsToCore + + For overloaded constructs (overloaded literals, lists, strings), and rebindable constructs (e.g. if-then-else), our general plan is this, using overloaded labels #foo as an example: ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -17,7 +17,7 @@ -- | Expand @Do@ block statements into @(>>=)@, @(>>)@ and @let at s -- After renaming but right ebefore type checking -module GHC.Tc.Gen.Do where +module GHC.Tc.Gen.Do (expandDoStmts) where import GHC.Prelude @@ -66,22 +66,29 @@ expandDoStmts doFlav stmts = do expanded_expr <- expand_do_stmts doFlav stmts -- See Note [Expanding HsDo with HsExpansion] expand_do_stmts :: HsDoFlavour -> [ExprLStmt GhcRn] -> TcM (LHsExpr GhcRn) -expand_do_stmts ListComp _ = pprPanic "expand_do_stmts: impossible happened. ListComp" empty +expand_do_stmts ListComp _ = + pprPanic "expand_do_stmts: impossible happened. ListComp" empty + -- handeled by `GHC.Tc.Gen.Match.tcLcStmt` expand_do_stmts _ [] = pprPanic "expand_do_stmts: impossible happened. Empty stmts" empty expand_do_stmts _ (stmt@(L _ (TransStmt {})):_) = pprPanic "expand_do_stmts: TransStmt" $ ppr stmt + -- handeled by `GHC.Tc.Gen.Match.tcLcStmt` expand_do_stmts _ (stmt@(L _ (ParStmt {})):_) = pprPanic "expand_do_stmts: ParStmt" $ ppr stmt + -- handeled by `GHC.Tc.Gen.Match.tcLcStmt` expand_do_stmts _ (stmt@(L _ (ApplicativeStmt{})): _) = pprPanic "expand_do_stmts: Applicative Stmt" $ ppr stmt + -- Handeled by tcSyntaxOp see `GHC.Tc.Gen.Match.tcStmtsAndThen` + expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] - -- last statement of a list comprehension, needs to explicitly return it - -- See `checkLastStmt` and `Syntax.Expr.StmtLR.LastStmt` +-- See Note [Expanding HsDo with HsExpansion] Equation (5) below +-- last statement of a list comprehension, needs to explicitly return it +-- See `checkLastStmt` and `Syntax.Expr.StmtLR.LastStmt` | NoSyntaxExprRn <- ret_expr -- Last statement is just body if we are not in ListComp context. See Syntax.Expr.LastStmt = do traceTc "expand_do_stmts last" (ppr ret_expr) @@ -97,6 +104,7 @@ expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] return $ mkExpandedStmtPopAt loc stmt expansion expand_do_stmts do_or_lc (stmt@(L loc (LetStmt _ bs)) : lstmts) = +-- See Note [Expanding HsDo with HsExpansion] Equation (3) below -- stmts ~~> stmts' -- ------------------------------------------------ -- let x = e ; stmts ~~> let x = e in stmts' @@ -107,8 +115,8 @@ expand_do_stmts do_or_lc (stmt@(L loc (LetStmt _ bs)) : lstmts) = expand_do_stmts do_or_lc (stmt@(L loc (BindStmt xbsrn pat e)): lstmts) | SyntaxExprRn bind_op <- xbsrn_bindOp xbsrn , fail_op <- xbsrn_failOp xbsrn +-- See Note [Expanding HsDo with HsExpansion] Equation (2) below -- the pattern binding pat can fail --- instead of making a new internal name, the fail block is just an anonymous lambda -- stmts ~~> stmt' f = \case pat -> stmts'; -- _ -> fail "Pattern match failure .." -- ------------------------------------------------------- @@ -124,7 +132,8 @@ expand_do_stmts do_or_lc (stmt@(L loc (BindStmt xbsrn pat e)): lstmts) = pprPanic "expand_do_stmts: The impossible happened, missing bind operator from renamer" (text "stmt" <+> ppr stmt) expand_do_stmts do_or_lc (stmt@(L loc (BodyStmt _ e (SyntaxExprRn then_op) _)) : lstmts) = --- See Note [BodyStmt] +-- See Note [BodyStmt] in Language.Haskell.Syntax.Expr +-- See Note [Expanding HsDo with HsExpansion] Equation (1) below -- stmts ~~> stmts' -- ---------------------------------------------- -- e ; stmts ~~> (>>) e stmts' @@ -145,7 +154,8 @@ expand_do_stmts do_or_lc -- at the end of expanded rec block })) : lstmts) = --- See Note [Typing a RecStmt] +-- See Note [Typing a RecStmt] in Language.Haskell.Syntax.Expr +-- See Note [Expanding HsDo with HsExpansion] Equation (4) and (6) below -- stmts ~~> stmts' -- ------------------------------------------------------------------------------------------- -- rec { later_ids, local_ids, rec_block } ; stmts @@ -227,20 +237,20 @@ mk_fail_block _ _ _ _ = pprPanic "mk_fail_block: impossible happened" empty {- Note [Expanding HsDo with HsExpansion] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We expand `do`-blocks before typechecking it, rather than type checking it and then -desugaring it by re-using the existing `HsExpansions` and `RebindableSyntax` machinery. +We expand `do`-blocks before typechecking it, by re-using the existing `HsExpansions` and `RebindableSyntax` machinery. This is very similar to: 1. Expansions done in `GHC.Rename.Expr.rnHsIf` for expanding `HsIf`; and 2. `desugarRecordUpd` in `GHC.Tc.Gen.Expr.tcExpr` for expanding `RecordUpd` +See Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr To disabmiguate desugaring (`HsExpr GhcTc -> Core.Expr`) we use the phrase expansion (`HsExpr GhcRn -> HsExpr GhcRn`) -See Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr - This expansion is done right before typechecking and after renaming See Part 2. of Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` +Historical note START +--------------------- In previous versions of GHC, the `do`-notation wasn't expanded before typechecking, instead the typechecker would operate directly on the original. Why? because it ensured that type error messages were explained in terms of @@ -262,8 +272,13 @@ what the programmer has written. In practice, however, this didn't work very wel the quantifiers impredicatively (#18324). Again, that happens automatically if you typecheck the expanded expression. -* Equationally speaking, we have the following schema for expanding `do`-statements. - They capture the essence of statement expansions as implemented in `expand_do_stmts` +Historical note END +------------------- + +Do Expansions Equationally +-------------------------- +We have the following schema for expanding `do`-statements. +They capture the essence of statement expansions as implemented in `expand_do_stmts` DO【 _ 】 maps a sequence of do statements and recursively converts them into expressions @@ -277,9 +292,21 @@ what the programmer has written. In practice, however, this didn't work very wel _ -> fail "pattern p failure")) (3) DO【 let x = e; ss 】 - = ‹ExpansionStmt (let x = e)› (let x = e in (‹PopErrCtxt›DO【 ss 】)) + = ‹ExpansionStmt (let x = e)› (let x = e in (‹PopErrCtxt›DO【 ss 】)) + + + (4) DO【 rec ss; sss 】 + = (>>=) e (\vars -> ‹PopErrCtxt›DO【 sss 】)) + where (vars, e) = RECDO【 ss 】 + + (5) DO【 s 】 = s + + RECDO【 _ 】 maps a sequence of recursively dependent monadic statements and converts it into an expression paired + with the variables that the rec finds a fix point of. + + (6) RECDO【 ss 】 = (vars, mfix (\~vars -> (>>=) (DO【 ss 】) (return vars))) + where vars are all the variables free in ss - (4) DO【 s 】 = s For a concrete example, consider a `do`-block written by the user @@ -297,8 +324,7 @@ The {l1} etc are location/source span information stored in the AST by the parse {g1} are compiler generated source spans. -The 3 main points to consider are: - +The 3 non-obvious points to consider are: 1. Wrap the expression with a `fail` block if the pattern match is not irrefutable. See Part 1. Below 2. Generate appropriate warnings for discarded results in a body statement @@ -307,10 +333,12 @@ The 3 main points to consider are: 3. Generating appropriate type error messages which blame the correct source spans See Part 3 Below -Part 1. Wrapping failable patterns with fail blocks ---------------------------------------------------- +Part 1. Expanding Patterns Bindings +----------------------------------- If `p` is a failable pattern---checked by `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`--- -we need to wrap it with a `fail`-block. For example, the expansion of the `do`-block +we need to wrap it with a `fail`-block. See Equation (2) above. + +The expansion of the `do`-block do { Just p <- e1; e2 } @@ -321,7 +349,7 @@ we need to wrap it with a `fail`-block. For example, the expansion of the `do`-b Just p -> e2 _ -> fail "failable pattern p at location") -The `fail`-block wrapping is done in `GHC.Tc.Gen.Do.mk_failable_expr`. +The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`. * Note the explicit call to `fail`, in the monad of the `do`-block. Part of the specification of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash @@ -331,20 +359,19 @@ The `fail`-block wrapping is done in `GHC.Tc.Gen.Do.mk_failable_expr`. pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate a `MonadFail` constraint that isn't needed. -* Why an anonymous continuation lambda? - We need a lambda for the types to match: this expression is a second - argument to `(>>=)` so it needs to be of type `a -> m b`, a function. - It is anonymous because: - a. the name will be compiler generated and will never be seen by the user, and; - b. we are in the post renaming stage fresh naming will require non-trivial amount of plumbing for little gain. +* _Wrinkle 1_: For pattern synonyms, we always wrap it with a `fail`-block. + When the pattern is irrefutable, we do not add the fail block. + This is important because the occurrence of `fail` means that the typechecker + will generate a `MonadFail` constraint, and the language spec says that + we should not do that for irrefutable patterns. -* Wrinkle 1: For pattern synonyms, we always wrap it with a `fail`-block. - The irrefutable pattern checker returns false for pattern synonyms, but then after desugaring - we would get a pattern match checker's redundant pattern warnings. To avoid such - spurious warnings we filter out those type patterns that appear in a do expansion generated match - in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) + Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate + a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings. + because after desugaring, it is marked as irrefutable! To avoid such + spurious warnings and type checker errors, we filter out those patterns that appear + in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs) -* Wrinkle 2: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we +* _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we attach to that constraint? It should be a good one, because it'll show up in error messages when the `MonadFail` constraint can't be solved. Ideally, it should identify the pattern `p`. Hence, we wrap the `fail` alternative expression with a `ExpandedPat` @@ -358,14 +385,15 @@ the value when `-Wunused-binds` flag is turned on. (See testcase T3263-2.hs) For example the `do`-block - do { e1; e2 } + do { e1; e2 } -- where, e1 :: m Int expands to (>>) e1 e2 -* If `e1` returns a non-() value then we emit a value discarded warning. This check is done during desugaring - `HsToCore.dsExpr` in the `HsApp` with a call to `HsToCore.warnUnusedBindValue`. +* If `e1` returns a non-() value we want to emit a warning, telling the user that they + are discarding the value returned by e1. This is done by `HsToCore.dsExpr` in the `HsApp` + with a call to `HsToCore.warnUnusedBindValue`. * The decision to trigger the warning is: if the function is a compiler generated `(>>)`, and its first argument `e1` has a non-() type @@ -398,7 +426,7 @@ It stores the original statement (with location) and the expanded expression This is similar to vanilla `HsExpansion` and rebindable syntax See Note [Rebindable syntax and HsExpansion] in `GHC.Hs.Expr`. - * Recall, that when a source function arugment fails to typecheck, + * Recall, that when a source function argument fails to typecheck, we print an error message like "In the second argument of the function f..". However, `(>>)` is generated thus, we don't want to display that to the user; it would be confusing. But also, we do not want to completely ignore it as we do want to keep the error blame carets ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -658,9 +658,9 @@ tcXExpr (PopErrCtxt (L loc e)) res_ty setSrcSpanA loc $ tcExpr e res_ty -tcXExpr xe@(ExpandedThingRn thing) res_ty - | OrigStmt ls@(L loc s at LetStmt{}) <- original thing - , HsLet x tkLet binds tkIn e <- expanded thing +tcXExpr xe@(ExpandedThingRn o e) res_ty + | OrigStmt ls@(L loc s at LetStmt{}) <- o + , HsLet x tkLet binds tkIn e <- e = do { (binds', e') <- setSrcSpanA loc $ addStmtCtxt s $ tcLocalBinds binds $ @@ -668,15 +668,15 @@ tcXExpr xe@(ExpandedThingRn thing) res_ty -- a duplicate error context ; return $ mkExpandedStmtTc ls (HsLet x tkLet binds' tkIn e') } - | OrigStmt ls@(L loc s at LastStmt{}) <- original thing + | OrigStmt ls@(L loc s at LastStmt{}) <- o = setSrcSpanA loc $ addStmtCtxt s $ - mkExpandedStmtTc ls <$> tcExpr (expanded thing) res_ty + mkExpandedStmtTc ls <$> tcExpr e res_ty -- It is important that we call tcExpr (and not tcApp) here as -- `e` is just the last statement's body expression -- and not a HsApp of a generated (>>) or (>>=) -- This improves error messages e.g. T18324b.hs - | OrigStmt ls@(L loc _) <- original thing + | OrigStmt ls@(L loc _) <- o = setSrcSpanA loc $ mkExpandedStmtTc ls <$> tcApp (XExpr xe) res_ty ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -295,8 +295,8 @@ splitHsApps e = go e (top_ctxt 0 e) [] top_ctxt n (HsPragE _ _ fun) = top_lctxt n fun top_ctxt n (HsAppType _ fun _ _) = top_lctxt (n+1) fun top_ctxt n (HsApp _ fun _) = top_lctxt (n+1) fun - top_ctxt n (XExpr (ExpandedThingRn thing)) - | OrigExpr fun <- original thing = VACall fun n noSrcSpan + top_ctxt n (XExpr (ExpandedThingRn o _)) + | OrigExpr fun <- o = VACall fun n noSrcSpan top_ctxt n other_fun = VACall other_fun n noSrcSpan top_lctxt n (L _ fun) = top_ctxt n fun @@ -324,28 +324,26 @@ splitHsApps e = go e (top_ctxt 0 e) [] HsQuasiQuote _ _ (L l _) -> set l ctxt -- l :: SrcAnn NoEpAnns -- See Note [Looking through HsExpanded] - go (XExpr (ExpandedThingRn thing)) ctxt args - | let o = original thing - , isHsThingRnExpr o - = go (expanded thing) (VAExpansion o (appCtxtLoc ctxt) (appCtxtLoc ctxt)) + go (XExpr (ExpandedThingRn o e)) ctxt args + | isHsThingRnExpr o + = go e (VAExpansion o (appCtxtLoc ctxt) (appCtxtLoc ctxt)) (EWrap (EExpand o) : args) - | oStmt@(OrigStmt (L _ stmt)) <- original thing -- so that we set `(>>)` as generated - , BodyStmt{} <- stmt -- and get the right unused bind warnings - = go (expanded thing) (VAExpansion oStmt generatedSrcSpan generatedSrcSpan) - -- See Part 3. in Note [Expanding HsDo with HsExpansion] - (EWrap (EExpand oStmt) : args) -- in `GHC.Tc.Gen.Do` + | OrigStmt (L _ stmt) <- o -- so that we set `(>>)` as generated + , BodyStmt{} <- stmt -- and get the right unused bind warnings + = go e (VAExpansion o generatedSrcSpan generatedSrcSpan) + -- See Part 3. in Note [Expanding HsDo with HsExpansion] + (EWrap (EExpand o) : args) -- in `GHC.Tc.Gen.Do` - | oPat@(OrigPat (L loc _)) <- original thing -- so that we set the compiler generated fail context - = go (expanded thing) (VAExpansion oPat -- to be originating from a failable pattern - (locA loc) (locA loc)) -- See Part 1. Wrinkle 2. of - (EWrap (EExpand oPat) : args) -- Note [Expanding HsDo with HsExpansion] + | OrigPat (L loc _) <- o -- so that we set the compiler generated fail context + = go e (VAExpansion o (locA loc) (locA loc)) -- to be originating from a failable pattern + -- See Part 1. Wrinkle 2. of + (EWrap (EExpand o) : args) -- Note [Expanding HsDo with HsExpansion] -- in `GHC.Tc.Gen.Do` | otherwise - , let o = original thing - = go (expanded thing) (VAExpansion o (appCtxtLoc ctxt) (appCtxtLoc ctxt)) + = go e (VAExpansion o (appCtxtLoc ctxt) (appCtxtLoc ctxt)) (EWrap (EExpand o) : args) -- See Note [Desugar OpApp in the typechecker] ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -740,9 +740,9 @@ exprCtOrigin (HsUntypedSplice {}) = Shouldn'tHappenOrigin "TH untyped splice" exprCtOrigin (HsProc {}) = Shouldn'tHappenOrigin "proc" exprCtOrigin (HsStatic {}) = Shouldn'tHappenOrigin "static expression" exprCtOrigin (HsEmbTy {}) = Shouldn'tHappenOrigin "type expression" -exprCtOrigin (XExpr (ExpandedThingRn thing)) | OrigExpr a <- original thing = exprCtOrigin a - | OrigStmt _ <- original thing = DoOrigin - | OrigPat p <- original thing = DoPatOrigin p +exprCtOrigin (XExpr (ExpandedThingRn thing _)) | OrigExpr a <- thing = exprCtOrigin a + | OrigStmt _ <- thing = DoOrigin + | OrigPat p <- thing = DoPatOrigin p exprCtOrigin (XExpr (PopErrCtxt {})) = Shouldn'tHappenOrigin "PopErrCtxt" -- | Extract a suitable CtOrigin from a MatchGroup ===================================== compiler/GHC/Tc/Zonk/Type.hs ===================================== @@ -1066,9 +1066,10 @@ zonkExpr (XExpr (WrapExpr (HsWrap co_fn expr))) do new_expr <- zonkExpr expr return (XExpr (WrapExpr (HsWrap new_co_fn new_expr))) -zonkExpr (XExpr (ExpandedThingTc thing)) - = XExpr . ExpandedThingTc <$> (do e' <- zonkExpr $ expanded thing - return $ thing {expanded = e'}) +zonkExpr (XExpr (ExpandedThingTc thing e)) + = do e' <- zonkExpr e + return $ XExpr (ExpandedThingTc thing e') + zonkExpr (XExpr (ConLikeTc con tvs tys)) = XExpr . ConLikeTc con tvs <$> mapM zonk_scale tys View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69cff3423209149765a9080b1c6f3d257fce99dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69cff3423209149765a9080b1c6f3d257fce99dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 23:17:51 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 19:17:51 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Fix restarts in .ghcid Message-ID: <652b219f246fe_7336f5d180a8114735@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 3 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08fc27af4731a1cab4f82cfdedbf1dfb5f6fd563...fea9ecdbcdf68eb59449478075efd2df6aaea0a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/08fc27af4731a1cab4f82cfdedbf1dfb5f6fd563...fea9ecdbcdf68eb59449478075efd2df6aaea0a9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 23:18:20 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 19:18:20 -0400 Subject: [Git][ghc/ghc][master] hadrian: Move ghcBinDeps into ghcLibDeps Message-ID: <652b21bcd4e_7336f5d7e3bc1177d9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - 3 changed files: - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Program.hs Changes: ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32523713e044732ac37f2e2cdce2f6820f9c0997 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32523713e044732ac37f2e2cdce2f6820f9c0997 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 23:19:07 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 19:19:07 -0400 Subject: [Git][ghc/ghc][master] Combine GREs when combining in mkImportOccEnv Message-ID: <652b21eb515d3_7336f5d7b3741224c6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 8 changed files: - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - + testsuite/tests/rename/should_compile/T24084.hs - + testsuite/tests/rename/should_compile/T24084_A.hs - + testsuite/tests/rename/should_compile/T24084_B.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -692,13 +692,14 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup | otherwise = do gre_env <- getGlobalRdrEnv let original_gres = lookupGRE gre_env (LookupChildren (rdrNameOcc rdr_name) how_lkup) - -- The remaining GREs are things that we *could* export here, note that - -- this includes things which have `NoParent`. Those are sorted in - -- `checkPatSynParent`. + picked_gres = pick_gres original_gres + -- The remaining GREs are things that we *could* export here. + -- Note that this includes things which have `NoParent`; + -- those are sorted in `checkPatSynParent`. traceRn "parent" (ppr parent) traceRn "lookupExportChild original_gres:" (ppr original_gres) - traceRn "lookupExportChild picked_gres:" (ppr (picked_gres original_gres) $$ ppr must_have_parent) - case picked_gres original_gres of + traceRn "lookupExportChild picked_gres:" (ppr picked_gres $$ ppr must_have_parent) + case picked_gres of NoOccurrence -> noMatchingParentErr original_gres UniqueOccurrence g -> @@ -745,34 +746,36 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup addNameClashErrRn rdr_name gres return (FoundChild (NE.head gres)) - picked_gres :: [GlobalRdrElt] -> DisambigInfo + pick_gres :: [GlobalRdrElt] -> DisambigInfo -- For Unqual, find GREs that are in scope qualified or unqualified -- For Qual, find GREs that are in scope with that qualification - picked_gres gres + pick_gres gres | isUnqual rdr_name = mconcat (map right_parent gres) | otherwise = mconcat (map right_parent (pickGREs rdr_name gres)) right_parent :: GlobalRdrElt -> DisambigInfo - right_parent p - = case greParent p of + right_parent gre + = case greParent gre of ParentIs cur_parent - | parent == cur_parent -> DisambiguatedOccurrence p + | parent == cur_parent -> DisambiguatedOccurrence gre | otherwise -> NoOccurrence - NoParent -> UniqueOccurrence p + NoParent -> UniqueOccurrence gre {-# INLINEABLE lookupSubBndrOcc_helper #-} --- This domain specific datatype is used to record why we decided it was +-- | This domain specific datatype is used to record why we decided it was -- possible that a GRE could be exported with a parent. data DisambigInfo = NoOccurrence - -- The GRE could never be exported. It has the wrong parent. + -- ^ The GRE could not be found, or it has the wrong parent. | UniqueOccurrence GlobalRdrElt - -- The GRE has no parent. It could be a pattern synonym. + -- ^ The GRE has no parent. It could be a pattern synonym. | DisambiguatedOccurrence GlobalRdrElt - -- The parent of the GRE is the correct parent + -- ^ The parent of the GRE is the correct parent. | AmbiguousOccurrence (NE.NonEmpty GlobalRdrElt) + -- ^ The GRE is ambiguous. + -- -- For example, two normal identifiers with the same name are in -- scope. They will both be resolved to "UniqueOccurrence" and the -- monoid will combine them to this failing case. @@ -784,7 +787,7 @@ instance Outputable DisambigInfo where ppr (AmbiguousOccurrence gres) = text "Ambiguous:" <+> ppr gres instance Semi.Semigroup DisambigInfo where - -- This is the key line: We prefer disambiguated occurrences to other + -- These are the key lines: we prefer disambiguated occurrences to other -- names. _ <> DisambiguatedOccurrence g' = DisambiguatedOccurrence g' DisambiguatedOccurrence g' <> _ = DisambiguatedOccurrence g' ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1068,13 +1068,17 @@ Notice that T appears *twice*, once as a child and once as a parent. From these two exports, respectively, during construction of the imp_occ_env, we begin by associating the following two elements with the key T: - T -> ImpOccItem { imp_item = T, imp_bundled = [C,T] , imp_is_parent = False } - T -> ImpOccItem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> ImpOccItem { imp_item = gre1, imp_bundled = [C,T] , imp_is_parent = False } + T -> ImpOccItem { imp_item = gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } -We combine these (in function 'combine' in 'mkImportOccEnv') by simply discarding -the first item, to get: +where `gre1`, `gre2` are two GlobalRdrElts with greName T. +We combine these (in function 'combine' in 'mkImportOccEnv') by discarding the +non-parent item, thusly: - T -> IE_ITem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> IE_ITem { imp_item = gre1 `plusGRE` gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } + +Note the `plusGRE`: this ensures we don't drop parent information; +see Note [Preserve parent information when combining import OccEnvs]. So the overall imp_occ_env is: @@ -1133,6 +1137,31 @@ Whereas in case (B) we reach the lookup_ie case for IEThingWith, which looks up 'S' and then finds the unique 'foo' amongst its children. See T16745 for a test of this. + +Note [Preserve parent information when combining import OccEnvs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When discarding one ImpOccItem in favour of another, as described in +Note [Dealing with imports], we must make sure to combine the GREs so that +we don't lose information. + +Consider for example #24084: + + module M1 where { class C a where { type T a } } + module M2 ( module M1 ) where { import M1 } + module M3 where { import M2 ( C, T ); instance C () where T () = () } + +When processing the import list of `M3`, we will have two `Avail`s attached +to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function +of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard +`C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** +discard the information want that `C` is the parent of `T`. Indeed, +losing track of this information can cause errors when importing, +as we could get an error of the form + + ‘T’ is not a (visible) associated type of class ‘C’ + +This explains why we use `plusGRE` when combining the two ImpOccItems, even +though we are discarding one in favour of the other. -} -- | All the 'GlobalRdrElt's associated with an 'AvailInfo'. @@ -1443,6 +1472,14 @@ data ImpOccItem -- ^ Is the import item a parent? See Note [Dealing with imports]. } +instance Outputable ImpOccItem where + ppr (ImpOccItem { imp_item = item, imp_bundled = bundled, imp_is_parent = is_par }) + = braces $ hsep + [ text "ImpOccItem" + , if is_par then text "[is_par]" else empty + , ppr (greName item) <+> ppr (greParent item) + , braces $ text "bundled:" <+> ppr (map greName bundled) ] + -- | Make an 'OccEnv' of all the imports. -- -- Complicated by the fact that associated data types and pattern synonyms @@ -1474,9 +1511,9 @@ mkImportOccEnv hsc_env decl_spec all_avails = -- See Note [Dealing with imports] -- 'combine' may be called for associated data types which appear - -- twice in the all_avails. In the example, we combine - -- T(T,T1,T2,T3) and C(C,T) to give (T, T(T,T1,T2,T3), Just C) - -- NB: the AvailTC can have fields as well as data constructors (#12127) + -- twice in the all_avails. In the example, we have two Avails for T, + -- namely T(T,T1,T2,T3) and C(C,T), and we combine them by dropping the + -- latter, in which T is not the parent. combine :: ImpOccItem -> ImpOccItem -> ImpOccItem combine item1@(ImpOccItem { imp_item = gre1, imp_is_parent = is_parent1 }) item2@(ImpOccItem { imp_item = gre2, imp_is_parent = is_parent2 }) @@ -1484,11 +1521,13 @@ mkImportOccEnv hsc_env decl_spec all_avails = , not (isRecFldGRE gre1 || isRecFldGRE gre2) -- NB: does not force GREInfo. , let name1 = greName gre1 name2 = greName gre2 + gre = gre1 `plusGRE` gre2 + -- See Note [Preserve parent information when combining import OccEnvs] = assertPpr (name1 == name2) (ppr name1 <+> ppr name2) $ if is_parent1 - then item1 - else item2 + then item1 { imp_item = gre } + else item2 { imp_item = gre } -- Discard C(C,T) in favour of T(T, T1, T2, T3). -- 'combine' may also be called for pattern synonyms which appear both ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -175,7 +175,7 @@ filterAvail keep ie rest = -- 'avails' may have several items with the same availName -- E.g import Ix( Ix(..), index ) -- will give Ix(Ix,index,range) and Ix(index) --- We want to combine these; addAvail does that +-- We want to combine these; plusAvail does that nubAvails :: [AvailInfo] -> [AvailInfo] nubAvails avails = eltsDNameEnv (foldl' add emptyDNameEnv avails) where ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -76,6 +76,7 @@ module GHC.Types.Name.Reader ( -- ** Global 'RdrName' mapping elements: 'GlobalRdrElt', 'Provenance', 'ImportSpec' GlobalRdrEltX(..), GlobalRdrElt, IfGlobalRdrElt, FieldGlobalRdrElt, greName, greNameSpace, greParent, greInfo, + plusGRE, insertGRE, forceGlobalRdrEnv, hydrateGlobalRdrEnv, isLocalGRE, isImportedGRE, isRecFldGRE, fieldGREInfo, @@ -1165,6 +1166,17 @@ data WhichGREs info where } -> WhichGREs GREInfo +instance Outputable (WhichGREs info) where + ppr SameNameSpace = text "SameNameSpace" + ppr (RelevantGREs { includeFieldSelectors = sel + , lookupVariablesForFields = vars + , lookupTyConsAsWell = tcs_too }) + = braces $ hsep + [ text "RelevantGREs" + , text (show sel) + , if vars then text "[vars]" else empty + , if tcs_too then text "[tcs]" else empty ] + -- | Look up as many possibly relevant 'GlobalRdrElt's as possible. pattern AllRelevantGREs :: WhichGREs GREInfo pattern AllRelevantGREs = @@ -1199,6 +1211,17 @@ data LookupChild -- See Note [childGREPriority]. } +instance Outputable LookupChild where + ppr (LookupChild { wantedParent = par + , lookupDataConFirst = dc + , prioritiseParent = prio_parent }) + = braces $ hsep + [ text "LookupChild" + , braces (text "parent:" <+> ppr par) + , if dc then text "[dc_first]" else empty + , if prio_parent then text "[prio_parent]" else empty + ] + -- | After looking up something with the given 'NameSpace', is the resulting -- 'GlobalRdrElt' we have obtained relevant, according to the 'RelevantGREs' -- specification of which 'NameSpace's are relevant? ===================================== testsuite/tests/rename/should_compile/T24084.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084 where + +import T24084_B (Foo, Bar) + +data X + +instance Foo X where + type Bar X = X ===================================== testsuite/tests/rename/should_compile/T24084_A.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_A (Foo (..)) where + +class Foo a where + type Bar a ===================================== testsuite/tests/rename/should_compile/T24084_B.hs ===================================== @@ -0,0 +1,7 @@ + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_B (module T24084_A) where + +import T24084_A + ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -216,6 +216,7 @@ test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) test('T24037', normal, compile, ['']) +test('T24084', [extra_files(['T24084_A.hs', 'T24084_B.hs'])], multimod_compile, ['T24084', '-v0']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec3c4488f456f6f9bdd28a09f0b1e87fd3782db9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec3c4488f456f6f9bdd28a09f0b1e87fd3782db9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 23:19:49 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 19:19:49 -0400 Subject: [Git][ghc/ghc][master] hadrian: Pass -DNOSMP to C compiler when needed Message-ID: <652b2215de05e_7336f59c68281257dd@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 1 changed file: - hadrian/src/Settings/Packages.hs Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/257c2807587624592813a42e06a05c5fc34cb38c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/257c2807587624592813a42e06a05c5fc34cb38c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 14 23:20:49 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 14 Oct 2023 19:20:49 -0400 Subject: [Git][ghc/ghc][master] Users Guide: Drop dead code for Haddock refs to `parallel` Message-ID: <652b22517e9c7_7336f5a153381306e7@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 2 changed files: - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in Changes: ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13d3c613c3c1e4942c698449bdf58a6a13b76695 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13d3c613c3c1e4942c698449bdf58a6a13b76695 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 15 14:38:08 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sun, 15 Oct 2023 10:38:08 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T15226-stg Message-ID: <652bf950aaba2_7336f1b3ab07c1546c5@gitlab.mail> Matthew Craven pushed new branch wip/T15226-stg at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T15226-stg You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 15 14:46:10 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sun, 15 Oct 2023 10:46:10 -0400 Subject: [Git][ghc/ghc][wip/T15226-stg] Teach tag-inference about SeqOp/seq# Message-ID: <652bfb32ffea_7336f1b4044d815661f@gitlab.mail> Matthew Craven pushed to branch wip/T15226-stg at Glasgow Haskell Compiler / GHC Commits: f4889f47 by Matthew Craven at 2023-10-15T10:45:15-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. - - - - - 10 changed files: - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Stg/InferTags.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Stg/InferTags/TagSig.hs - compiler/GHC/StgToCmm/Prim.hs - + testsuite/tests/simplStg/should_compile/T15226b.hs - + testsuite/tests/simplStg/should_compile/T15226b.stderr - testsuite/tests/simplStg/should_compile/all.T - + testsuite/tests/simplStg/should_compile/inferTags003.hs - + testsuite/tests/simplStg/should_compile/inferTags003.stderr Changes: ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2108,6 +2108,11 @@ Implementing seq#. The compiler has magic for SeqOp in - Simplify.addEvals records evaluated-ness for the result; see Note [Adding evaluatedness info to pattern-bound variables] in GHC.Core.Opt.Simplify.Iteration + +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a + properly-tagged pointer inside of its unboxed-tuple result. + (The TagTuple has only one component because the state token in the + result has already been unarised out of existence.) -} seqRule :: RuleM CoreExpr ===================================== compiler/GHC/Stg/InferTags.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) ) import GHC.Types.Unique.Supply (mkSplitUniqSupply) import GHC.Types.RepType (dataConRuntimeRepStrictness) import GHC.Core (AltCon(..)) +import GHC.Builtin.PrimOps ( PrimOp(..) ) import Data.List (mapAccumL) import GHC.Utils.Outputable import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull ) @@ -340,9 +341,12 @@ inferTagExpr env (StgTick tick body) (info, body') = inferTagExpr env body inferTagExpr _ (StgOpApp op args ty) - = -- Do any primops guarantee to return a properly tagged value? - -- I think not. Ditto foreign calls. - (TagDunno, StgOpApp op args ty) + | StgPrimOp SeqOp <- op -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold + = (TagTuple [TagProper], StgOpApp op args ty) + -- Do any other primops guarantee to return a properly tagged value? + -- Probably not, and that is the conservative assumption anyway. + -- (And foreign calls definitely need not make promises.) + | otherwise = (TagDunno, StgOpApp op args ty) inferTagExpr env (StgLet ext bind body) = (info, StgLet ext bind' body') ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -217,7 +217,7 @@ withLcl fv act = do When compiling bytecode we call myCoreToStg to get STG code first. myCoreToStg in turn calls out to stg2stg which runs the STG to STG passes followed by free variables analysis and the tag inference pass including -it's rewriting phase at the end. +its rewriting phase at the end. Running tag inference is important as it upholds Note [Strict Field Invariant]. While code executed by GHCi doesn't take advantage of the SFI it can call into compiled code which does. So it must still make sure that the SFI is upheld. @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr rewriteExpr (e at StgCase {}) = rewriteCase e rewriteExpr (e at StgLet {}) = rewriteLet e rewriteExpr (e at StgLetNoEscape {}) = rewriteLetNoEscape e -rewriteExpr (StgTick t e) = StgTick t <$!> rewriteExpr e +rewriteExpr (StgTick t e) = StgTick t <$!> rewriteExpr e rewriteExpr e@(StgConApp {}) = rewriteConApp e -rewriteExpr e@(StgApp {}) = rewriteApp e -rewriteExpr (StgLit lit) = return $! (StgLit lit) -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do - (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty) +rewriteExpr e@(StgOpApp {}) = rewriteOpApp e +rewriteExpr e@(StgApp {}) = rewriteApp e +rewriteExpr (StgLit lit) = return $! (StgLit lit) rewriteCase :: InferStgExpr -> RM TgStgExpr @@ -488,6 +486,17 @@ rewriteApp (StgApp f args) rewriteApp (StgApp f args) = return $ StgApp f args rewriteApp _ = panic "Impossible" +rewriteOpApp :: InferStgExpr -> RM TgStgExpr +rewriteOpApp (StgOpApp op args res_ty) = case op of + op@(StgPrimOp primOp) + | primOp == SeqOp || primOp == DataToTagOp + -- These primops evaluate an argument and can use a tag annotation + -- to elide that eval. Foreign calls and other primops make no + -- use of tag info, so we don't bother annotating them. + -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty + _ -> pure $! StgOpApp op args res_ty +rewriteOpApp _ = panic "Impossible" + -- `mkSeq` x x' e generates `case x of x' -> e` -- We could also substitute x' for x in e but that's so rarely beneficial -- that we don't bother. ===================================== compiler/GHC/Stg/InferTags/TagSig.hs ===================================== @@ -5,7 +5,7 @@ -- We export this type from this module instead of GHC.Stg.InferTags.Types -- because it's used by more than the analysis itself. For example in interface -- files where we record a tag signature for bindings. --- By putting the sig into it's own module we can avoid module loops. +-- By putting the sig into its own module we can avoid module loops. module GHC.Stg.InferTags.TagSig where @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> () seqTagInfo TagTagged = () seqTagInfo TagDunno = () seqTagInfo TagProper = () -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis \ No newline at end of file +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of -- -- In more complex cases, there is a foreign call (out of line) fallback. This -- might happen e.g. if there's enough static information, such as statically --- know arguments. +-- known arguments. emitPrimOp :: StgToCmmConfig -> PrimOp -- ^ The primop ===================================== testsuite/tests/simplStg/should_compile/T15226b.hs ===================================== @@ -0,0 +1,11 @@ +module T15226b where + +import Control.Exception + +data StrictPair a b = MkStrictPair !a !b + +testFun :: a -> b -> IO (StrictPair a b) +testFun x y = do + x' <- evaluate x + evaluate (MkStrictPair x' y) + -- tag inference should not insert an eval for x' in making the strict pair ===================================== testsuite/tests/simplStg/should_compile/T15226b.stderr ===================================== @@ -0,0 +1,48 @@ + +==================== Final STG: ==================== +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE] + :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] = + {} \r [conrep conrep1] + case conrep of conrep2 [Occ=Once1] { + __DEFAULT -> + case conrep1 of conrep3 [Occ=Once1] { + __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3]; + }; + }; + +T15226b.testFun1 + :: forall a b. + a + -> b + -> GHC.Prim.State# GHC.Prim.RealWorld + -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #) +[GblId, Arity=3, Str=, Unf=OtherCon []] = + {} \r [x y void] + case seq# [x GHC.Prim.void#] of { + Solo# ipv1 [Occ=Once1] -> + let { + sat [Occ=Once1] :: T15226b.StrictPair a b + [LclId] = + {ipv1, y} \u [] + case y of conrep [Occ=Once1] { + __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep]; + }; + } in seq# [sat GHC.Prim.void#]; + }; + +T15226b.testFun + :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b) +[GblId, Arity=3, Str=, Unf=OtherCon []] = + {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#; + +T15226b.MkStrictPair [InlPrag=CONLIKE] + :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] = + {} \r [eta eta] + case eta of eta { + __DEFAULT -> + case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; }; + }; + + ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -18,3 +18,7 @@ test('T22840', [extra_files( [ 'T22840A.hs' , 'T22840B.hs' ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks']) +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) +test('inferTags003', [ only_ways(['optasm']), + grep_errmsg('(call stg\_ap\_0)', [1]) + ], compile, ['-ddump-cmm -dno-typeable-binds -O']) ===================================== testsuite/tests/simplStg/should_compile/inferTags003.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module M where + +import GHC.Exts +import GHC.IO + +data T a = MkT !Bool !a + +fun :: T a -> IO a +{-# OPAQUE fun #-} +fun (MkT _ x) = IO $ \s -> noinline seq# x s +-- evaluate/seq# should not produce its own eval for x +-- since it is properly tagged (from a strict field) + +-- uses noinline to prevent caseRules from eliding the seq# in Core ===================================== testsuite/tests/simplStg/should_compile/inferTags003.stderr ===================================== @@ -0,0 +1,177 @@ + +==================== Output Cmm ==================== +[M.$WMkT_entry() { // [R3, R2] + { info_tbls: [(cEx, + label: block_cEx_info + rep: StackRep [False] + srt: Nothing), + (cEA, + label: M.$WMkT_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Nothing), + (cED, + label: block_cED_info + rep: StackRep [False] + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cEA: // global + if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH; // CmmCondBranch + cEG: // global + R1 = M.$WMkT_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cEH: // global + I64[Sp - 16] = cEx; // CmmStore + R1 = R2; // CmmAssign + P64[Sp - 8] = R3; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto cEx; else goto cEy; // CmmCondBranch + cEy: // global + call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8; // CmmCall + cEx: // global + // slowCall + I64[Sp] = cED; // CmmStore + _sEi::P64 = R1; // CmmAssign + R1 = P64[Sp + 8]; // CmmAssign + P64[Sp + 8] = _sEi::P64; // CmmStore + call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8; // CmmCall + cED: // global + // slow_call for _sEh::P64 with pat stg_ap_0 + Hp = Hp + 24; // CmmAssign + if (Hp > HpLim) (likely: False) goto cEL; else goto cEK; // CmmCondBranch + cEL: // global + HpAlloc = 24; // CmmAssign + call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8; // CmmCall + cEK: // global + // allocHeapClosure + I64[Hp - 16] = M.MkT_con_info; // CmmStore + P64[Hp - 8] = P64[Sp + 8]; // CmmStore + P64[Hp] = R1; // CmmStore + R1 = Hp - 15; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.$WMkT_closure" { + M.$WMkT_closure: + const M.$WMkT_info; + }] + + + +==================== Output Cmm ==================== +[M.fun_entry() { // [R2] + { info_tbls: [(cEV, + label: block_cEV_info + rep: StackRep [] + srt: Nothing), + (cEY, + label: M.fun_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cEY: // global + if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0; // CmmCondBranch + cEZ: // global + R1 = M.fun_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cF0: // global + I64[Sp - 8] = cEV; // CmmStore + R1 = R2; // CmmAssign + Sp = Sp - 8; // CmmAssign + if (R1 & 7 != 0) goto cEV; else goto cEW; // CmmCondBranch + cEW: // global + call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8; // CmmCall + cEV: // global + R1 = P64[R1 + 15]; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.fun_closure" { + M.fun_closure: + const M.fun_info; + }] + + + +==================== Output Cmm ==================== +[M.MkT_entry() { // [R3, R2] + { info_tbls: [(cFc, + label: block_cFc_info + rep: StackRep [False] + srt: Nothing), + (cFf, + label: M.MkT_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Nothing), + (cFi, + label: block_cFi_info + rep: StackRep [False] + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cFf: // global + if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm; // CmmCondBranch + cFl: // global + R1 = M.MkT_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cFm: // global + I64[Sp - 16] = cFc; // CmmStore + R1 = R2; // CmmAssign + P64[Sp - 8] = R3; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto cFc; else goto cFd; // CmmCondBranch + cFd: // global + call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8; // CmmCall + cFc: // global + // slowCall + I64[Sp] = cFi; // CmmStore + _tEq::P64 = R1; // CmmAssign + R1 = P64[Sp + 8]; // CmmAssign + P64[Sp + 8] = _tEq::P64; // CmmStore + call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8; // CmmCall + cFi: // global + // slow_call for _B1::P64 with pat stg_ap_0 + Hp = Hp + 24; // CmmAssign + if (Hp > HpLim) (likely: False) goto cFq; else goto cFp; // CmmCondBranch + cFq: // global + HpAlloc = 24; // CmmAssign + call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8; // CmmCall + cFp: // global + // allocHeapClosure + I64[Hp - 16] = M.MkT_con_info; // CmmStore + P64[Hp - 8] = P64[Sp + 8]; // CmmStore + P64[Hp] = R1; // CmmStore + R1 = Hp - 15; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.MkT_closure" { + M.MkT_closure: + const M.MkT_info; + }] + + + +==================== Output Cmm ==================== +[M.MkT_con_entry() { // [] + { info_tbls: [(cFw, + label: M.MkT_con_info + rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cFw: // global + R1 = R1 + 1; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }] + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f4889f473c3a4033f2ad270386346f18783c7f48 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f4889f473c3a4033f2ad270386346f18783c7f48 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 15 14:57:31 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Sun, 15 Oct 2023 10:57:31 -0400 Subject: [Git][ghc/ghc][wip/T15226-stg] Teach tag-inference about SeqOp/seq# Message-ID: <652bfddb917a7_7336f1bcb8a341568e0@gitlab.mail> Matthew Craven pushed to branch wip/T15226-stg at Glasgow Haskell Compiler / GHC Commits: 84b1ced3 by Matthew Craven at 2023-10-15T10:57:10-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. - - - - - 10 changed files: - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Stg/InferTags.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Stg/InferTags/TagSig.hs - compiler/GHC/StgToCmm/Prim.hs - + testsuite/tests/simplStg/should_compile/T15226b.hs - + testsuite/tests/simplStg/should_compile/T15226b.stderr - testsuite/tests/simplStg/should_compile/all.T - + testsuite/tests/simplStg/should_compile/inferTags003.hs - + testsuite/tests/simplStg/should_compile/inferTags003.stderr Changes: ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2108,6 +2108,11 @@ Implementing seq#. The compiler has magic for SeqOp in - Simplify.addEvals records evaluated-ness for the result; see Note [Adding evaluatedness info to pattern-bound variables] in GHC.Core.Opt.Simplify.Iteration + +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a + properly-tagged pointer inside of its unboxed-tuple result. + (The TagTuple has only one component because the state token in the + result has already been unarised out of existence.) -} seqRule :: RuleM CoreExpr ===================================== compiler/GHC/Stg/InferTags.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) ) import GHC.Types.Unique.Supply (mkSplitUniqSupply) import GHC.Types.RepType (dataConRuntimeRepStrictness) import GHC.Core (AltCon(..)) +import GHC.Builtin.PrimOps ( PrimOp(..) ) import Data.List (mapAccumL) import GHC.Utils.Outputable import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull ) @@ -340,9 +341,12 @@ inferTagExpr env (StgTick tick body) (info, body') = inferTagExpr env body inferTagExpr _ (StgOpApp op args ty) - = -- Do any primops guarantee to return a properly tagged value? - -- I think not. Ditto foreign calls. - (TagDunno, StgOpApp op args ty) + | StgPrimOp SeqOp <- op -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold + = (TagTuple [TagProper], StgOpApp op args ty) + -- Do any other primops guarantee to return a properly tagged value? + -- Probably not, and that is the conservative assumption anyway. + -- (And foreign calls definitely need not make promises.) + | otherwise = (TagDunno, StgOpApp op args ty) inferTagExpr env (StgLet ext bind body) = (info, StgLet ext bind' body') ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -217,7 +217,7 @@ withLcl fv act = do When compiling bytecode we call myCoreToStg to get STG code first. myCoreToStg in turn calls out to stg2stg which runs the STG to STG passes followed by free variables analysis and the tag inference pass including -it's rewriting phase at the end. +its rewriting phase at the end. Running tag inference is important as it upholds Note [Strict Field Invariant]. While code executed by GHCi doesn't take advantage of the SFI it can call into compiled code which does. So it must still make sure that the SFI is upheld. @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr rewriteExpr (e at StgCase {}) = rewriteCase e rewriteExpr (e at StgLet {}) = rewriteLet e rewriteExpr (e at StgLetNoEscape {}) = rewriteLetNoEscape e -rewriteExpr (StgTick t e) = StgTick t <$!> rewriteExpr e +rewriteExpr (StgTick t e) = StgTick t <$!> rewriteExpr e rewriteExpr e@(StgConApp {}) = rewriteConApp e -rewriteExpr e@(StgApp {}) = rewriteApp e -rewriteExpr (StgLit lit) = return $! (StgLit lit) -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do - (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty) +rewriteExpr e@(StgOpApp {}) = rewriteOpApp e +rewriteExpr e@(StgApp {}) = rewriteApp e +rewriteExpr (StgLit lit) = return $! (StgLit lit) rewriteCase :: InferStgExpr -> RM TgStgExpr @@ -488,6 +486,17 @@ rewriteApp (StgApp f args) rewriteApp (StgApp f args) = return $ StgApp f args rewriteApp _ = panic "Impossible" +rewriteOpApp :: InferStgExpr -> RM TgStgExpr +rewriteOpApp (StgOpApp op args res_ty) = case op of + op@(StgPrimOp primOp) + | primOp == SeqOp || primOp == DataToTagOp + -- These primops evaluate an argument and can use a tag annotation + -- to elide that eval. Foreign calls and other primops make no + -- use of tag info, so we don't bother annotating them. + -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty + _ -> pure $! StgOpApp op args res_ty +rewriteOpApp _ = panic "Impossible" + -- `mkSeq` x x' e generates `case x of x' -> e` -- We could also substitute x' for x in e but that's so rarely beneficial -- that we don't bother. ===================================== compiler/GHC/Stg/InferTags/TagSig.hs ===================================== @@ -5,7 +5,7 @@ -- We export this type from this module instead of GHC.Stg.InferTags.Types -- because it's used by more than the analysis itself. For example in interface -- files where we record a tag signature for bindings. --- By putting the sig into it's own module we can avoid module loops. +-- By putting the sig into its own module we can avoid module loops. module GHC.Stg.InferTags.TagSig where @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> () seqTagInfo TagTagged = () seqTagInfo TagDunno = () seqTagInfo TagProper = () -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis \ No newline at end of file +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of -- -- In more complex cases, there is a foreign call (out of line) fallback. This -- might happen e.g. if there's enough static information, such as statically --- know arguments. +-- known arguments. emitPrimOp :: StgToCmmConfig -> PrimOp -- ^ The primop ===================================== testsuite/tests/simplStg/should_compile/T15226b.hs ===================================== @@ -0,0 +1,11 @@ +module T15226b where + +import Control.Exception + +data StrictPair a b = MkStrictPair !a !b + +testFun :: a -> b -> IO (StrictPair a b) +testFun x y = do + x' <- evaluate x + evaluate (MkStrictPair x' y) + -- tag inference should not insert an eval for x' in making the strict pair ===================================== testsuite/tests/simplStg/should_compile/T15226b.stderr ===================================== @@ -0,0 +1,48 @@ + +==================== Final STG: ==================== +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE] + :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] = + {} \r [conrep conrep1] + case conrep of conrep2 [Occ=Once1] { + __DEFAULT -> + case conrep1 of conrep3 [Occ=Once1] { + __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3]; + }; + }; + +T15226b.testFun1 + :: forall a b. + a + -> b + -> GHC.Prim.State# GHC.Prim.RealWorld + -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #) +[GblId, Arity=3, Str=, Unf=OtherCon []] = + {} \r [x y void] + case seq# [x GHC.Prim.void#] of { + Solo# ipv1 [Occ=Once1] -> + let { + sat [Occ=Once1] :: T15226b.StrictPair a b + [LclId] = + {ipv1, y} \u [] + case y of conrep [Occ=Once1] { + __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep]; + }; + } in seq# [sat GHC.Prim.void#]; + }; + +T15226b.testFun + :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b) +[GblId, Arity=3, Str=, Unf=OtherCon []] = + {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#; + +T15226b.MkStrictPair [InlPrag=CONLIKE] + :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] = + {} \r [eta eta] + case eta of eta { + __DEFAULT -> + case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; }; + }; + + ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -18,3 +18,7 @@ test('T22840', [extra_files( [ 'T22840A.hs' , 'T22840B.hs' ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks']) +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) +test('inferTags003', [ only_ways(['optasm']), + grep_errmsg(r'(call stg\_ap\_0)', [1]) + ], compile, ['-ddump-cmm -dno-typeable-binds -O']) ===================================== testsuite/tests/simplStg/should_compile/inferTags003.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module M where + +import GHC.Exts +import GHC.IO + +data T a = MkT !Bool !a + +fun :: T a -> IO a +{-# OPAQUE fun #-} +fun (MkT _ x) = IO $ \s -> noinline seq# x s +-- evaluate/seq# should not produce its own eval for x +-- since it is properly tagged (from a strict field) + +-- uses noinline to prevent caseRules from eliding the seq# in Core ===================================== testsuite/tests/simplStg/should_compile/inferTags003.stderr ===================================== @@ -0,0 +1,177 @@ + +==================== Output Cmm ==================== +[M.$WMkT_entry() { // [R3, R2] + { info_tbls: [(cEx, + label: block_cEx_info + rep: StackRep [False] + srt: Nothing), + (cEA, + label: M.$WMkT_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Nothing), + (cED, + label: block_cED_info + rep: StackRep [False] + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cEA: // global + if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH; // CmmCondBranch + cEG: // global + R1 = M.$WMkT_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cEH: // global + I64[Sp - 16] = cEx; // CmmStore + R1 = R2; // CmmAssign + P64[Sp - 8] = R3; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto cEx; else goto cEy; // CmmCondBranch + cEy: // global + call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8; // CmmCall + cEx: // global + // slowCall + I64[Sp] = cED; // CmmStore + _sEi::P64 = R1; // CmmAssign + R1 = P64[Sp + 8]; // CmmAssign + P64[Sp + 8] = _sEi::P64; // CmmStore + call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8; // CmmCall + cED: // global + // slow_call for _sEh::P64 with pat stg_ap_0 + Hp = Hp + 24; // CmmAssign + if (Hp > HpLim) (likely: False) goto cEL; else goto cEK; // CmmCondBranch + cEL: // global + HpAlloc = 24; // CmmAssign + call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8; // CmmCall + cEK: // global + // allocHeapClosure + I64[Hp - 16] = M.MkT_con_info; // CmmStore + P64[Hp - 8] = P64[Sp + 8]; // CmmStore + P64[Hp] = R1; // CmmStore + R1 = Hp - 15; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.$WMkT_closure" { + M.$WMkT_closure: + const M.$WMkT_info; + }] + + + +==================== Output Cmm ==================== +[M.fun_entry() { // [R2] + { info_tbls: [(cEV, + label: block_cEV_info + rep: StackRep [] + srt: Nothing), + (cEY, + label: M.fun_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cEY: // global + if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0; // CmmCondBranch + cEZ: // global + R1 = M.fun_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cF0: // global + I64[Sp - 8] = cEV; // CmmStore + R1 = R2; // CmmAssign + Sp = Sp - 8; // CmmAssign + if (R1 & 7 != 0) goto cEV; else goto cEW; // CmmCondBranch + cEW: // global + call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8; // CmmCall + cEV: // global + R1 = P64[R1 + 15]; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.fun_closure" { + M.fun_closure: + const M.fun_info; + }] + + + +==================== Output Cmm ==================== +[M.MkT_entry() { // [R3, R2] + { info_tbls: [(cFc, + label: block_cFc_info + rep: StackRep [False] + srt: Nothing), + (cFf, + label: M.MkT_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Nothing), + (cFi, + label: block_cFi_info + rep: StackRep [False] + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cFf: // global + if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm; // CmmCondBranch + cFl: // global + R1 = M.MkT_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cFm: // global + I64[Sp - 16] = cFc; // CmmStore + R1 = R2; // CmmAssign + P64[Sp - 8] = R3; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto cFc; else goto cFd; // CmmCondBranch + cFd: // global + call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8; // CmmCall + cFc: // global + // slowCall + I64[Sp] = cFi; // CmmStore + _tEq::P64 = R1; // CmmAssign + R1 = P64[Sp + 8]; // CmmAssign + P64[Sp + 8] = _tEq::P64; // CmmStore + call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8; // CmmCall + cFi: // global + // slow_call for _B1::P64 with pat stg_ap_0 + Hp = Hp + 24; // CmmAssign + if (Hp > HpLim) (likely: False) goto cFq; else goto cFp; // CmmCondBranch + cFq: // global + HpAlloc = 24; // CmmAssign + call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8; // CmmCall + cFp: // global + // allocHeapClosure + I64[Hp - 16] = M.MkT_con_info; // CmmStore + P64[Hp - 8] = P64[Sp + 8]; // CmmStore + P64[Hp] = R1; // CmmStore + R1 = Hp - 15; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.MkT_closure" { + M.MkT_closure: + const M.MkT_info; + }] + + + +==================== Output Cmm ==================== +[M.MkT_con_entry() { // [] + { info_tbls: [(cFw, + label: M.MkT_con_info + rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cFw: // global + R1 = R1 + 1; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }] + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84b1ced3faa4ae93f204831c934f9911be7a5201 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84b1ced3faa4ae93f204831c934f9911be7a5201 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 15 18:07:50 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Sun, 15 Oct 2023 14:07:50 -0400 Subject: [Git][ghc/ghc][wip/rts-configure] 15 commits: hadrian: Decrease verbosity of cabal commands Message-ID: <652c2a76bd58f_7336f20244d3c1673a@gitlab.mail> John Ericson pushed to branch wip/rts-configure at Glasgow Haskell Compiler / GHC Commits: 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 99c23403 by John Ericson at 2023-10-15T14:07:39-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - ac8d145c by John Ericson at 2023-10-15T14:07:39-04:00 Move over a number of C-style checks to RTS configure - - - - - 1d33da2e by John Ericson at 2023-10-15T14:07:39-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - 28b1afb7 by John Ericson at 2023-10-15T14:07:39-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - 419cdb1e by John Ericson at 2023-10-15T14:07:39-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 9e3bda88 by John Ericson at 2023-10-15T14:07:39-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 9b46cd0a by John Ericson at 2023-10-15T14:07:39-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - 30 changed files: - .ghcid - .gitignore - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - configure.ac - distrib/cross-port - docs/coding-style.html - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Program.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-prim/ghc-prim.cabal.in → libraries/ghc-prim/ghc-prim.cabal - m4/fp_cc_supports__atomics.m4 - m4/fptools_set_haskell_platform_vars.m4 - m4/ghc_convert_os.m4 - rts/.gitignore - rts/configure.ac - + rts/ghcplatform.h.bottom The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47c3672018b1480178cbf81be64537d58cc68dc7...9b46cd0af009721c4846202662e3b83cb29e6a33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47c3672018b1480178cbf81be64537d58cc68dc7...9b46cd0af009721c4846202662e3b83cb29e6a33 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 15 18:19:37 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Sun, 15 Oct 2023 14:19:37 -0400 Subject: [Git][ghc/ghc][wip/hadrian-substitutes-doc-config] 7 commits: Fix restarts in .ghcid Message-ID: <652c2d3941255_7336f2082d1041681d3@gitlab.mail> John Ericson pushed to branch wip/hadrian-substitutes-doc-config at Glasgow Haskell Compiler / GHC Commits: a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - 68eeb362 by John Ericson at 2023-10-15T14:18:40-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - 22 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - configure.ac - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/cfg/system.config.in - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Packages.hs - + testsuite/tests/rename/should_compile/T24084.hs - + testsuite/tests/rename/should_compile/T24084_A.hs - + testsuite/tests/rename/should_compile/T24084_B.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -692,13 +692,14 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup | otherwise = do gre_env <- getGlobalRdrEnv let original_gres = lookupGRE gre_env (LookupChildren (rdrNameOcc rdr_name) how_lkup) - -- The remaining GREs are things that we *could* export here, note that - -- this includes things which have `NoParent`. Those are sorted in - -- `checkPatSynParent`. + picked_gres = pick_gres original_gres + -- The remaining GREs are things that we *could* export here. + -- Note that this includes things which have `NoParent`; + -- those are sorted in `checkPatSynParent`. traceRn "parent" (ppr parent) traceRn "lookupExportChild original_gres:" (ppr original_gres) - traceRn "lookupExportChild picked_gres:" (ppr (picked_gres original_gres) $$ ppr must_have_parent) - case picked_gres original_gres of + traceRn "lookupExportChild picked_gres:" (ppr picked_gres $$ ppr must_have_parent) + case picked_gres of NoOccurrence -> noMatchingParentErr original_gres UniqueOccurrence g -> @@ -745,34 +746,36 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup addNameClashErrRn rdr_name gres return (FoundChild (NE.head gres)) - picked_gres :: [GlobalRdrElt] -> DisambigInfo + pick_gres :: [GlobalRdrElt] -> DisambigInfo -- For Unqual, find GREs that are in scope qualified or unqualified -- For Qual, find GREs that are in scope with that qualification - picked_gres gres + pick_gres gres | isUnqual rdr_name = mconcat (map right_parent gres) | otherwise = mconcat (map right_parent (pickGREs rdr_name gres)) right_parent :: GlobalRdrElt -> DisambigInfo - right_parent p - = case greParent p of + right_parent gre + = case greParent gre of ParentIs cur_parent - | parent == cur_parent -> DisambiguatedOccurrence p + | parent == cur_parent -> DisambiguatedOccurrence gre | otherwise -> NoOccurrence - NoParent -> UniqueOccurrence p + NoParent -> UniqueOccurrence gre {-# INLINEABLE lookupSubBndrOcc_helper #-} --- This domain specific datatype is used to record why we decided it was +-- | This domain specific datatype is used to record why we decided it was -- possible that a GRE could be exported with a parent. data DisambigInfo = NoOccurrence - -- The GRE could never be exported. It has the wrong parent. + -- ^ The GRE could not be found, or it has the wrong parent. | UniqueOccurrence GlobalRdrElt - -- The GRE has no parent. It could be a pattern synonym. + -- ^ The GRE has no parent. It could be a pattern synonym. | DisambiguatedOccurrence GlobalRdrElt - -- The parent of the GRE is the correct parent + -- ^ The parent of the GRE is the correct parent. | AmbiguousOccurrence (NE.NonEmpty GlobalRdrElt) + -- ^ The GRE is ambiguous. + -- -- For example, two normal identifiers with the same name are in -- scope. They will both be resolved to "UniqueOccurrence" and the -- monoid will combine them to this failing case. @@ -784,7 +787,7 @@ instance Outputable DisambigInfo where ppr (AmbiguousOccurrence gres) = text "Ambiguous:" <+> ppr gres instance Semi.Semigroup DisambigInfo where - -- This is the key line: We prefer disambiguated occurrences to other + -- These are the key lines: we prefer disambiguated occurrences to other -- names. _ <> DisambiguatedOccurrence g' = DisambiguatedOccurrence g' DisambiguatedOccurrence g' <> _ = DisambiguatedOccurrence g' ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1068,13 +1068,17 @@ Notice that T appears *twice*, once as a child and once as a parent. From these two exports, respectively, during construction of the imp_occ_env, we begin by associating the following two elements with the key T: - T -> ImpOccItem { imp_item = T, imp_bundled = [C,T] , imp_is_parent = False } - T -> ImpOccItem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> ImpOccItem { imp_item = gre1, imp_bundled = [C,T] , imp_is_parent = False } + T -> ImpOccItem { imp_item = gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } -We combine these (in function 'combine' in 'mkImportOccEnv') by simply discarding -the first item, to get: +where `gre1`, `gre2` are two GlobalRdrElts with greName T. +We combine these (in function 'combine' in 'mkImportOccEnv') by discarding the +non-parent item, thusly: - T -> IE_ITem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> IE_ITem { imp_item = gre1 `plusGRE` gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } + +Note the `plusGRE`: this ensures we don't drop parent information; +see Note [Preserve parent information when combining import OccEnvs]. So the overall imp_occ_env is: @@ -1133,6 +1137,31 @@ Whereas in case (B) we reach the lookup_ie case for IEThingWith, which looks up 'S' and then finds the unique 'foo' amongst its children. See T16745 for a test of this. + +Note [Preserve parent information when combining import OccEnvs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When discarding one ImpOccItem in favour of another, as described in +Note [Dealing with imports], we must make sure to combine the GREs so that +we don't lose information. + +Consider for example #24084: + + module M1 where { class C a where { type T a } } + module M2 ( module M1 ) where { import M1 } + module M3 where { import M2 ( C, T ); instance C () where T () = () } + +When processing the import list of `M3`, we will have two `Avail`s attached +to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function +of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard +`C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** +discard the information want that `C` is the parent of `T`. Indeed, +losing track of this information can cause errors when importing, +as we could get an error of the form + + ‘T’ is not a (visible) associated type of class ‘C’ + +This explains why we use `plusGRE` when combining the two ImpOccItems, even +though we are discarding one in favour of the other. -} -- | All the 'GlobalRdrElt's associated with an 'AvailInfo'. @@ -1443,6 +1472,14 @@ data ImpOccItem -- ^ Is the import item a parent? See Note [Dealing with imports]. } +instance Outputable ImpOccItem where + ppr (ImpOccItem { imp_item = item, imp_bundled = bundled, imp_is_parent = is_par }) + = braces $ hsep + [ text "ImpOccItem" + , if is_par then text "[is_par]" else empty + , ppr (greName item) <+> ppr (greParent item) + , braces $ text "bundled:" <+> ppr (map greName bundled) ] + -- | Make an 'OccEnv' of all the imports. -- -- Complicated by the fact that associated data types and pattern synonyms @@ -1474,9 +1511,9 @@ mkImportOccEnv hsc_env decl_spec all_avails = -- See Note [Dealing with imports] -- 'combine' may be called for associated data types which appear - -- twice in the all_avails. In the example, we combine - -- T(T,T1,T2,T3) and C(C,T) to give (T, T(T,T1,T2,T3), Just C) - -- NB: the AvailTC can have fields as well as data constructors (#12127) + -- twice in the all_avails. In the example, we have two Avails for T, + -- namely T(T,T1,T2,T3) and C(C,T), and we combine them by dropping the + -- latter, in which T is not the parent. combine :: ImpOccItem -> ImpOccItem -> ImpOccItem combine item1@(ImpOccItem { imp_item = gre1, imp_is_parent = is_parent1 }) item2@(ImpOccItem { imp_item = gre2, imp_is_parent = is_parent2 }) @@ -1484,11 +1521,13 @@ mkImportOccEnv hsc_env decl_spec all_avails = , not (isRecFldGRE gre1 || isRecFldGRE gre2) -- NB: does not force GREInfo. , let name1 = greName gre1 name2 = greName gre2 + gre = gre1 `plusGRE` gre2 + -- See Note [Preserve parent information when combining import OccEnvs] = assertPpr (name1 == name2) (ppr name1 <+> ppr name2) $ if is_parent1 - then item1 - else item2 + then item1 { imp_item = gre } + else item2 { imp_item = gre } -- Discard C(C,T) in favour of T(T, T1, T2, T3). -- 'combine' may also be called for pattern synonyms which appear both ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -175,7 +175,7 @@ filterAvail keep ie rest = -- 'avails' may have several items with the same availName -- E.g import Ix( Ix(..), index ) -- will give Ix(Ix,index,range) and Ix(index) --- We want to combine these; addAvail does that +-- We want to combine these; plusAvail does that nubAvails :: [AvailInfo] -> [AvailInfo] nubAvails avails = eltsDNameEnv (foldl' add emptyDNameEnv avails) where ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -76,6 +76,7 @@ module GHC.Types.Name.Reader ( -- ** Global 'RdrName' mapping elements: 'GlobalRdrElt', 'Provenance', 'ImportSpec' GlobalRdrEltX(..), GlobalRdrElt, IfGlobalRdrElt, FieldGlobalRdrElt, greName, greNameSpace, greParent, greInfo, + plusGRE, insertGRE, forceGlobalRdrEnv, hydrateGlobalRdrEnv, isLocalGRE, isImportedGRE, isRecFldGRE, fieldGREInfo, @@ -1165,6 +1166,17 @@ data WhichGREs info where } -> WhichGREs GREInfo +instance Outputable (WhichGREs info) where + ppr SameNameSpace = text "SameNameSpace" + ppr (RelevantGREs { includeFieldSelectors = sel + , lookupVariablesForFields = vars + , lookupTyConsAsWell = tcs_too }) + = braces $ hsep + [ text "RelevantGREs" + , text (show sel) + , if vars then text "[vars]" else empty + , if tcs_too then text "[tcs]" else empty ] + -- | Look up as many possibly relevant 'GlobalRdrElt's as possible. pattern AllRelevantGREs :: WhichGREs GREInfo pattern AllRelevantGREs = @@ -1199,6 +1211,17 @@ data LookupChild -- See Note [childGREPriority]. } +instance Outputable LookupChild where + ppr (LookupChild { wantedParent = par + , lookupDataConFirst = dc + , prioritiseParent = prio_parent }) + = braces $ hsep + [ text "LookupChild" + , braces (text "parent:" <+> ppr par) + , if dc then text "[dc_first]" else empty + , if prio_parent then text "[prio_parent]" else empty + ] + -- | After looking up something with the given 'NameSpace', is the resulting -- 'GlobalRdrElt' we have obtained relevant, according to the 'RelevantGREs' -- specification of which 'NameSpace's are relevant? ===================================== configure.ac ===================================== @@ -1069,7 +1069,6 @@ AC_CONFIG_FILES( hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - docs/users_guide/ghc_config.py distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/cfg/system.config.in ===================================== @@ -34,6 +34,9 @@ python = @PythonCmd@ cc-llvm-backend = @CcLlvmBackend@ +llvm-min-version = @LlvmMinVersion@ +llvm-max-version = @LlvmMaxVersion@ + # Build options: #=============== ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -49,6 +49,8 @@ data Setting = CursesIncludeDir | GhcPatchLevel | GhcVersion | GhcSourcePath + | LlvmMinVersion + | LlvmMaxVersion | GmpIncludeDir | GmpLibDir | IconvIncludeDir @@ -103,6 +105,8 @@ setting key = lookupSystemConfig $ case key of GhcPatchLevel -> "ghc-patch-level" GhcVersion -> "ghc-version" GhcSourcePath -> "ghc-source-path" + LlvmMinVersion -> "llvm-min-version" + LlvmMaxVersion -> "llvm-max-version" GmpIncludeDir -> "gmp-include-dir" GmpLibDir -> "gmp-lib-dir" IconvIncludeDir -> "iconv-include-dir" ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -356,6 +356,9 @@ buildSphinxInfoGuide = do root <- buildRootRules let path = "GHCUsersGuide" root -/- infoRoot -/- path <.> "info" %> \ file -> do + + needDocDeps + withTempDir $ \dir -> do let rstFilesDir = pathPath path rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"] @@ -391,6 +394,8 @@ buildManPage = do root <- buildRootRules root -/- manPageBuildPath %> \file -> do need ["docs/users_guide/ghc.rst"] + needDocDeps + withTempDir $ \dir -> do build $ target docContext (Sphinx ManMode) ["docs/users_guide"] [dir] checkSphinxWarnings dir ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -324,7 +324,12 @@ templateRules = do templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions templateRule "docs/index.html" $ packageVersions - templateRule "docs/users_guide/ghc_config.py" $ packageUnitIds Stage1 + templateRule "docs/users_guide/ghc_config.py" $ mconcat + [ projectVersion + , packageUnitIds Stage1 + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + ] -- Generators ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== testsuite/tests/rename/should_compile/T24084.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084 where + +import T24084_B (Foo, Bar) + +data X + +instance Foo X where + type Bar X = X ===================================== testsuite/tests/rename/should_compile/T24084_A.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_A (Foo (..)) where + +class Foo a where + type Bar a ===================================== testsuite/tests/rename/should_compile/T24084_B.hs ===================================== @@ -0,0 +1,7 @@ + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_B (module T24084_A) where + +import T24084_A + ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -216,6 +216,7 @@ test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) test('T24037', normal, compile, ['']) +test('T24084', [extra_files(['T24084_A.hs', 'T24084_B.hs'])], multimod_compile, ['T24084', '-v0']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ae8e10a7bbe5524e9c71458523d7a8c93f3c3b1...68eeb362929562dc72bb3408dd964d664d81faf4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ae8e10a7bbe5524e9c71458523d7a8c93f3c3b1...68eeb362929562dc72bb3408dd964d664d81faf4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 16 15:16:59 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Mon, 16 Oct 2023 11:16:59 -0400 Subject: [Git][ghc/ghc][wip/expand-do] - kill HsExpanded and HsExpansion, its now XXExprGhcRn Message-ID: <652d53eb63893_7336f3cb622f422074a@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: e8bdbd78 by Apoorv Ingle at 2023-10-16T09:54:15-05:00 - kill HsExpanded and HsExpansion, its now XXExprGhcRn - - - - - 18 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Do.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Types/LclEnv.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Basic.hs - compiler/Language/Haskell/Syntax/Expr.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -440,21 +440,21 @@ tupArgPresent (Missing {}) = False type instance XXExpr GhcPs = DataConCantHappen type instance XXExpr GhcRn = XXExprGhcRn type instance XXExpr GhcTc = XXExprGhcTc --- HsExpansion: see Note [Rebindable syntax and HsExpansion] below +-- XXExprGhcRn: see Note [Rebindable syntax and XXExprGhcRn] below {- ********************************************************************* * * - Generating code for HsExpanded + Generating code for ExpandedThingRn See Note [Handling overloaded and rebindable constructs] * * ********************************************************************* -} -- | The different source constructs that we use to instantiate the "original" field --- in an `HsExpansion original expansion` +-- in an `XXExprGhcRn original expansion` data HsThingRn = OrigExpr (HsExpr GhcRn) - | OrigStmt (ExprLStmt GhcRn) -- TODO see if we can get rid of the L here - | OrigPat (LPat GhcRn) -- TODO see if we can get rid of the L here + | OrigStmt (ExprLStmt GhcRn) + | OrigPat (LPat GhcRn) isHsThingRnExpr, isHsThingRnStmt, isHsThingRnPat :: HsThingRn -> Bool isHsThingRnExpr (OrigExpr{}) = True @@ -467,13 +467,13 @@ isHsThingRnPat (OrigPat{}) = True isHsThingRnPat _ = False data XXExprGhcRn - = ExpandedThingRn { xrn_orig :: HsThingRn -- The original source thing + = ExpandedThingRn { xrn_orig :: HsThingRn -- The original source thing , xrn_expanded :: HsExpr GhcRn } -- The compiler generated expanded thing | PopErrCtxt -- A hint for typechecker to pop {-# UNPACK #-} !(LHsExpr GhcRn) -- the top of the error context stack -- Does not presist post renaming phase - -- See Part 3. of Note [Expanding HsDo with HsExpansion] + -- See Part 3. of Note [Expanding HsDo with XXExprGhcRn] -- in `GHC.Tc.Gen.Do` @@ -491,7 +491,7 @@ mkPopErrCtxtExprAt loc a = L loc $ mkPopErrCtxtExpr a mkExpandedExpr :: HsExpr GhcRn -- ^ source expression -> HsExpr GhcRn -- ^ expanded expression - -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' + -> HsExpr GhcRn -- ^ suitably wrapped 'XXExprGhcRn' mkExpandedExpr oExpr eExpr = XExpr (ExpandedThingRn (OrigExpr oExpr) eExpr) -- | Build an expression using the extension constructor `XExpr`, @@ -500,13 +500,13 @@ mkExpandedExpr oExpr eExpr = XExpr (ExpandedThingRn (OrigExpr oExpr) eExpr) mkExpandedStmt :: ExprLStmt GhcRn -- ^ source statement -> HsExpr GhcRn -- ^ expanded expression - -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' + -> HsExpr GhcRn -- ^ suitably wrapped 'XXExprGhcRn' mkExpandedStmt oStmt eExpr = XExpr (ExpandedThingRn (OrigStmt oStmt) eExpr) mkExpandedPatRn :: LPat GhcRn -- ^ source pattern -> HsExpr GhcRn -- ^ expanded expression - -> HsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' + -> HsExpr GhcRn -- ^ suitably wrapped 'XXExprGhcRn' mkExpandedPatRn oPat eExpr = XExpr (ExpandedThingRn (OrigPat oPat) eExpr) -- | Build an expression using the extension constructor `XExpr`, @@ -516,7 +516,7 @@ mkExpandedStmtAt :: SrcSpanAnnA -- ^ Location for the expansion expression -> ExprLStmt GhcRn -- ^ source statement -> HsExpr GhcRn -- ^ expanded expression - -> LHsExpr GhcRn -- ^ suitably wrapped located 'HsExpansion' + -> LHsExpr GhcRn -- ^ suitably wrapped located 'XXExprGhcRn' mkExpandedStmtAt loc oStmt eExpr = L loc $ mkExpandedStmt oStmt eExpr -- | Wrap the expanded version of the expression with a pop. @@ -524,7 +524,7 @@ mkExpandedStmtPopAt :: SrcSpanAnnA -- ^ Location for the expansion statement -> ExprLStmt GhcRn -- ^ source statement -> HsExpr GhcRn -- ^ expanded expression - -> LHsExpr GhcRn -- ^ suitably wrapped 'HsExpansion' + -> LHsExpr GhcRn -- ^ suitably wrapped 'XXExprGhcRn' mkExpandedStmtPopAt loc oStmt eExpr = mkPopErrCtxtExprAt loc $ mkExpandedStmtAt loc oStmt eExpr @@ -532,9 +532,9 @@ data XXExprGhcTc = WrapExpr -- Type and evidence application and abstractions {-# UNPACK #-} !(HsWrap HsExpr) - | ExpandedThingTc -- See Note [Rebindable syntax and HsExpansion] - -- See Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` - { xtc_orig :: HsThingRn -- The original user written thing + | ExpandedThingTc -- See Note [Rebindable syntax and XXExprGhcRn] + -- See Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do` + { xtc_orig :: HsThingRn -- The original user written thing , xtc_expanded :: HsExpr GhcTc } -- The expanded typechecked expression | ConLikeTc -- Result of typechecking a data-con @@ -556,22 +556,22 @@ data XXExprGhcTc Int -- module-local tick number for False (LHsExpr GhcTc) -- sub-expression --- | Build a 'HsExpansion' out of an extension constructor, +-- | Build a 'XXExprGhcRn' out of an extension constructor, -- and the two components of the expansion: original and -- expanded typechecked expressions. mkExpandedExprTc :: HsExpr GhcRn -- ^ source expression -> HsExpr GhcTc -- ^ expanded typechecked expression - -> HsExpr GhcTc -- ^ suitably wrapped 'HsExpansion' + -> HsExpr GhcTc -- ^ suitably wrapped 'XXExprGhcRn' mkExpandedExprTc oExpr eExpr = XExpr (ExpandedThingTc (OrigExpr oExpr) eExpr) --- | Build a 'HsExpansion' out of an extension constructor. +-- | Build a 'XXExprGhcRn' out of an extension constructor. -- The two components of the expansion are: original statement and -- expanded typechecked expression. mkExpandedStmtTc :: ExprLStmt GhcRn -- ^ source do statement -> HsExpr GhcTc -- ^ expanded typechecked expression - -> HsExpr GhcTc -- ^ suitably wrapped 'HsExpansion' + -> HsExpr GhcTc -- ^ suitably wrapped 'XXExprGhcRn' mkExpandedStmtTc oStmt eExpr = XExpr (ExpandedThingTc (OrigStmt oStmt) eExpr) {- ********************************************************************* @@ -1011,18 +1011,18 @@ isAtomicHsExpr (XExpr x) where go_x_tc :: XXExprGhcTc -> Bool go_x_tc (WrapExpr (HsWrap _ e)) = isAtomicHsExpr e - go_x_tc (ExpandedThingTc thing _) = isAtomicHsExpanded thing + go_x_tc (ExpandedThingTc thing _) = isAtomicExpandedThingRn thing go_x_tc (ConLikeTc {}) = True go_x_tc (HsTick {}) = False go_x_tc (HsBinTick {}) = False go_x_rn :: XXExprGhcRn -> Bool - go_x_rn (ExpandedThingRn thing _) = isAtomicHsExpanded thing + go_x_rn (ExpandedThingRn thing _) = isAtomicExpandedThingRn thing go_x_rn (PopErrCtxt (L _ a)) = isAtomicHsExpr a - isAtomicHsExpanded :: HsThingRn -> Bool - isAtomicHsExpanded (OrigExpr e) = isAtomicHsExpr e - isAtomicHsExpanded _ = False + isAtomicExpandedThingRn :: HsThingRn -> Bool + isAtomicExpandedThingRn (OrigExpr e) = isAtomicHsExpr e + isAtomicExpandedThingRn _ = False isAtomicHsExpr _ = False @@ -1036,11 +1036,11 @@ instance Outputable (HsPragE (GhcPass p)) where {- ********************************************************************* * * - HsExpansion and rebindable syntax + XXExprGhcRn and rebindable syntax * * ********************************************************************* -} -{- Note [Rebindable syntax and HsExpansion] +{- Note [Rebindable syntax and XXExprGhcRn] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We implement rebindable syntax (RS) support by performing a desugaring in the renamer. We transform GhcPs expressions and patterns affected by @@ -1074,12 +1074,12 @@ To remedy this, instead of transforming the original HsIf node into mere applications of 'ifThenElse', we keep the original 'if' expression around too, using the TTG XExpr extension point to allow GHC to construct an -'HsExpansion' value that will keep track of the original +'XXExprGhcRn' value that will keep track of the original expression in its first field, and the desugared one in the second field. The resulting renamed AST would look like: L locif (XExpr - (HsExpanded + (ExpandedThingRn (HsIf (L loca 'a') (L loctrue ()) (L locfalse True) @@ -1101,7 +1101,7 @@ second field. The resulting renamed AST would look like: When comes the time to typecheck the program, we end up calling tcMonoExpr on the AST above. If this expression gives rise to a type error, then it will appear in a context line and GHC -will pretty-print it using the 'Outputable (HsExpansion a b)' +will pretty-print it using the 'Outputable (XXExprGhcRn a b)' instance defined below, which *only prints the original expression*. This is the gist of the idea, but is not quite enough to recover the error messages that we had with the @@ -1152,12 +1152,12 @@ A general recipe to follow this approach for new constructs could go as follows: HsVar/HsApp nodes, above) is set to 'generatedSrcSpan' - take both the original node and that rebound-and-renamed result and wrap them into an expansion construct: - for expressions, XExpr (HsExpanded ) + for expressions, XExpr (ExpandedThingRn ) for patterns, XPat (HsPatExpanded ) - At typechecking-time: - remove any logic that was previously dealing with your rebindable construct, typically involving [tc]SyntaxOp, SyntaxExpr and friends. - - the XExpr (HsExpanded ... ...) case in tcExpr already makes sure that we + - the XExpr (ExpandedThingRn ... ...) case in tcExpr already makes sure that we typecheck the desugared expression while reporting the original one in errors -} @@ -1170,16 +1170,16 @@ syntax. The language extensions @OverloadedRecordDot@ and @OverloadedRecordUpdate@ (providing "record dot syntax") are implemented using the techniques of Note [Rebindable syntax and -HsExpansion]. +XXExprGhcRn]. When OverloadedRecordDot is enabled: - Field selection expressions - e.g. foo.bar.baz - Have abstract syntax HsGetField - - After renaming are XExpr (HsExpanded (HsGetField ...) (getField @"..."...)) expressions + - After renaming are XExpr (ExpandedThingRn (HsGetField ...) (getField @"..."...)) expressions - Field selector expressions e.g. (.x.y) - Have abstract syntax HsProjection - - After renaming are XExpr (HsExpanded (HsProjection ...) ((getField @"...") . (getField @"...") . ...) expressions + - After renaming are XExpr (ExpandedThingRn (HsProjection ...) ((getField @"...") . (getField @"...") . ...) expressions When OverloadedRecordUpdate is enabled: - Record update expressions @@ -1187,7 +1187,7 @@ When OverloadedRecordUpdate is enabled: - Have abstract syntax RecordUpd - With rupd_flds containting a Right - See Note [RecordDotSyntax field updates] (in Language.Haskell.Syntax.Expr) - - After renaming are XExpr (HsExpanded (RecordUpd ...) (setField@"..." ...) expressions + - After renaming are XExpr (ExpandedThingRn (RecordUpd ...) (setField@"..." ...) expressions - Note that this is true for all record updates even for those that do not involve '.' When OverloadedRecordDot is enabled and RebindableSyntax is not @@ -1203,18 +1203,6 @@ OverloadedRecordUpd is enabled and RebindableSyntax is enabled the names 'getField' and 'setField' are whatever in-scope names they are. -} --- See Note [Rebindable syntax and HsExpansion] just above. -data HsExpansion orig expanded - = HsExpanded { original :: orig -- The original source thing - , expanded :: expanded } -- The compiler generated expanded thing - deriving Data - --- | Just print the original expression (the @a@) with the expanded version (the @b@) -instance (Outputable a, Outputable b) => Outputable (HsExpansion a b) where - ppr (HsExpanded orig expanded) - = ifPprDebug (vcat [ppr orig, braces (text "Expansion:" <+> ppr expanded)]) - (ppr orig) - {- ************************************************************************ ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -163,10 +163,10 @@ type instance XEmbTyPat GhcTc = Type type instance XXPat GhcPs = DataConCantHappen type instance XXPat GhcRn = HsPatExpansion (Pat GhcRn) (Pat GhcRn) -- Original pattern and its desugaring/expansion. - -- See Note [Rebindable syntax and HsExpansion]. + -- See Note [Rebindable syntax and XXExprGhcRn]. type instance XXPat GhcTc = XXPatGhcTc - -- After typechecking, we add extra constructors: CoPat and HsExpansion. - -- HsExpansion allows us to handle RebindableSyntax in pattern position: + -- After typechecking, we add extra constructors: CoPat and XXExprGhcRn. + -- XXExprGhcRn allows us to handle RebindableSyntax in pattern position: -- see "XXExpr GhcTc" for the counterpart in expressions. type instance ConLikeP GhcPs = RdrName -- IdP GhcPs @@ -207,11 +207,11 @@ data XXPatGhcTc } -- | Pattern expansion: original pattern, and desugared pattern, -- for RebindableSyntax and other overloaded syntax such as OverloadedLists. - -- See Note [Rebindable syntax and HsExpansion]. + -- See Note [Rebindable syntax and XXExprGhcRn]. | ExpansionPat (Pat GhcRn) (Pat GhcTc) --- See Note [Rebindable syntax and HsExpansion]. +-- See Note [Rebindable syntax and XXExprGhcRn]. data HsPatExpansion a b = HsPatExpanded a b deriving Data @@ -286,7 +286,7 @@ instance (Outputable p, OutputableBndr p, Outputable arg) instance OutputableBndrId p => Outputable (Pat (GhcPass p)) where ppr = pprPat --- See Note [Rebindable syntax and HsExpansion]. +-- See Note [Rebindable syntax and XXExprGhcRn]. instance (Outputable a, Outputable b) => Outputable (HsPatExpansion a b) where ppr (HsPatExpanded a b) = ifPprDebug (vcat [ppr a, ppr b]) (ppr a) ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -931,7 +931,7 @@ warnUnusedBindValue fun arg@(L loc _) arg_ty -- Retrieve the location info and the head of the application -- It is important that we /do not/ look through HsApp to avoid -- generating duplicate warnings - -- See Part 2. of Note [Expanding HsDo with HsExpansion] + -- See Part 2. of Note [Expanding HsDo with XXExprGhcRn] fish_var :: LHsExpr GhcTc -> Maybe (SrcSpan , Id) fish_var (L l (HsVar _ id)) = return (locA l, unLoc id) fish_var (L _ (HsAppType _ e _ _)) = fish_var e ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -777,7 +777,7 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches' -- which have a do expansion origin -- They generate spurious overlapping warnings -- Due to pattern synonyms treated as refutable patterns - -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with HsExpansion] in GHC.Tc.Gen.Do + -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do else matches' ; new_vars <- case matches of [] -> newSysLocalsDs arg_tys ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -1703,7 +1703,7 @@ Then, concerning the TH quotation, a type error from the splice. We consult the module-wide RebindableSyntax flag here. We could instead record -the choice in HsExpanded, but it seems simpler to consult the flag (again). +the choice in ExpandedThingRn, but it seems simpler to consult the flag (again). -} ----------------------------------------------------------------------------- ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1129,7 +1129,7 @@ the typechecker: to ol_from_fun. * HsDo, where we give the SrcSpan of the entire do block to each ApplicativeStmt. - * HsExpanded ExplicitList{}, where we give the SrcSpan of the original + * Expanded (via ExpandedThingRn) ExplicitList{}, where we give the SrcSpan of the original list expression to the 'fromListN' call. In order for the implicit function calls to not be confused for actual ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -91,7 +91,7 @@ import qualified Data.List.NonEmpty as NE Nomenclature ------------- * Expansion (`HsExpr GhcRn -> HsExpr GhcRn`): expand between renaming and - typechecking, using the `HsExpansion` constructor of `HsExpr`. + typechecking, using the `XXExprGhcRn` constructor of `HsExpr`. * Desugaring (`HsExpr GhcTc -> Core.Expr`): convert the typechecked `HsSyn` to Core. This is done in GHC.HsToCore @@ -101,12 +101,12 @@ using overloaded labels #foo as an example: * In the RENAMER: transform HsOverLabel "foo" - ==> XExpr (HsExpansion (HsOverLabel #foo) - (fromLabel `HsAppType` "foo")) + ==> XExpr (ExpandedThingRn (HsOverLabel #foo) + (fromLabel `HsAppType` "foo")) We write this more compactly in concrete-syntax form like this #foo ==> fromLabel @"foo" - Recall that in (HsExpansion orig expanded), 'orig' is the original term + Recall that in (ExpandedThingRn orig expanded), 'orig' is the original term the user wrote, and 'expanded' is the expanded or desugared version to be typechecked. @@ -115,7 +115,7 @@ using overloaded labels #foo as an example: The typechecker (and desugarer) will never see HsOverLabel In effect, the renamer does a bit of desugaring. Recall GHC.Hs.Expr -Note [Rebindable syntax and HsExpansion], which describes the use of HsExpansion. +Note [Rebindable syntax and XXExprGhcRn], which describes the use of XXExprGhcRn. RebindableSyntax: If RebindableSyntax is off we use the built-in 'fromLabel', defined in @@ -155,8 +155,8 @@ but several have a little bit of special treatment: where `leftSection` and `rightSection` are representation-polymorphic wired-in Ids. See Note [Left and right sections] -* To understand why expansions for `OpApp` is done in `GHC.Tc.Gen.Head.splitHsApps` see - Part 0. of Note [Doing HsExpansion in the Renamer vs Typechecker] below. +* To understand why expansions for `OpApp` is done in `GHC.Tc.Gen.Head.splitHsApps` + see Note [Doing XXExprGhcRn in the Renamer vs Typechecker] below. * RecordUpd: we desugar record updates into case expressions, in GHC.Tc.Gen.Expr.tcExpr. @@ -179,7 +179,7 @@ but several have a little bit of special treatment: See Note [Record Updates] in GHC.Tc.Gen.Expr for more details. To understand Why is this done in the typechecker, and not in the renamer - see Part 1. of Note [Doing HsExpansion in the Renamer vs Typechecker] + see Note [Doing XXExprGhcRn in the Renamer vs Typechecker] * HsDo: We expand `HsDo` statements in `Ghc.Tc.Gen.Do`. @@ -193,9 +193,9 @@ but several have a little bit of special treatment: (\x -> ((>>) (g x) (return (f x)))) - See Note [Expanding HsDo with HsExpansion] in `Ghc.Tc.Gen.Do` for more details. - To understand why is this done in the typechecker and not in the renamer see - Part 2. of Note [Doing HsExpansion in the Renamer vs Typechecker] + See Note [Expanding HsDo with XXExprGhcRn] in `Ghc.Tc.Gen.Do` for more details. + To understand why is this done in the typechecker and not in the renamer. + See Note [Doing XXExprGhcRn in the Renamer vs Typechecker] Note [Overloaded labels] ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -216,7 +216,7 @@ type-applying to "foo", so we get And those inferred kind quantifiers will indeed be instantiated when we typecheck the renamed-syntax call (fromLabel @"foo"). -Note [Doing HsExpansion in the Renamer vs Typechecker] +Note [Doing XXExprGhcRn in the Renamer vs Typechecker] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We expand some `HsExpr GhcRn` code at various places, usually, on the fly, depending on when it is more convenient. It may be beneficial to have a @@ -225,18 +225,25 @@ in the future when we have enough cases to cater for. For the time being, this note documents which language feature is expanded at which phase, and the reasons for doing so. - Part 0. `OpApp` Expansions - ------------------------ - The typechecker turns `OpApp` into a use of `HsExpansion` + ** `HsIf` Expansions + -------------------- + `HsIf` expansions are expanded in the Renamer becuase it is more convinent + to do so there and then not worry about it in the later stage. + `-XRebindableSyntax` is used to decide whether we use the `HsIf` or user defined if + + + ** `OpApp` Expansions + --------------------- + The typechecker turns `OpApp` into a use of `XXExprGhcRn` on the fly, in `GHC.Tc.Gen.Head.splitHsApps`. The language extension `RebindableSyntax` does not affect this behaviour. - It's a bit painful to transform `OpApp e1 op e2` to a `HsExpansion` + It's a bit painful to transform `OpApp e1 op e2` to a `XXExprGhcRn` form, because the renamer does precedence rearrangement after name resolution. So the renamer leaves an `OpApp` as an `OpApp`. - Part 1. Record Update Syntax `RecordUpd` Expansions - --------------------------------------------------- + ** Record Update Syntax `RecordUpd` Expansions + ---------------------------------------------- This is done in the typechecker on the fly (`GHC.Tc.Expr.tcExpr`), and not the renamer, for two reasons: - (Until we implement GHC proposal #366) @@ -253,7 +260,7 @@ and the reasons for doing so. in which an updated field has a higher-rank type. See Wrinkle [Using IdSig] in Note [Record Updates] in GHC.Tc.Gen.Expr. - Part 2. `HsDo` Statement Expansions + ** `HsDo` Statement Expansions ----------------------------------- The expansion for do block statements is done on the fly right before typechecking in `GHC.Tc.Gen.Expr` using `GHC.Tc.Gen.Do.expandDoStmts`. There are 2 main reasons: @@ -261,7 +268,7 @@ and the reasons for doing so. - During the renaming phase, we may not have all the constructor details `HsConDetails` populated in the data structure. This would result in an inaccurate irrefutability analysis causing the continuation lambda body to be wrapped with `fail` alternatives when not needed. - See Part 1. of Note [Expanding HsDo with HsExpansion] (test pattern-fails.hs) + See Part 1. of Note [Expanding HsDo with XXExprGhcRn] (test pattern-fails.hs) - If the expansion is done on the fly during renaming, expressions that have explicit type applications using (-XTypeApplciations) will not work (cf. Let statements expansion) @@ -2749,7 +2756,7 @@ getMonadFailOp ctxt {- ********************************************************************* * * - Generating code for HsExpanded + Generating code for ExpandedThingRn See Note [Handling overloaded and rebindable constructs] * * ********************************************************************* -} ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -315,7 +315,7 @@ Note [Handling overloaded and rebindable patterns] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Overloaded paterns and rebindable patterns are desugared in the renamer using the HsPatExpansion mechanism detailed in: -Note [Rebindable syntax and HsExpansion] +Note [Rebindable syntax and XXExprGhcRn] The approach is similar to that of expressions, which is further detailed in Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr. @@ -343,7 +343,7 @@ If OverloadedLists is enabled, we desugar a list pattern to a view pattern: toList -> [p1, p2, p3] This happens directly in the renamer, using the HsPatExpansion mechanism -detailed in Note [Rebindable syntax and HsExpansion]. +detailed in Note [Rebindable syntax and XXExprGhcRn]. Note that we emit a special view pattern: we additionally keep track of an inverse to the pattern. ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -713,14 +713,14 @@ checkCTupSize tup_size {- ********************************************************************* * * - Generating code for HsExpanded + Generating code for ExpandedThingRn See Note [Handling overloaded and rebindable constructs] * * ********************************************************************* -} wrapGenSpan :: (NoAnn an) => a -> LocatedAn an a -- Wrap something in a "generatedSrcSpan" --- See Note [Rebindable syntax and HsExpansion] +-- See Note [Rebindable syntax and XXExprGhcRn] wrapGenSpan x = L (noAnnSrcSpan generatedSrcSpan) x genHsApps :: Name -> [LHsExpr GhcRn] -> HsExpr GhcRn ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -4933,7 +4933,7 @@ pprWithArising (ct:cts) {- Note ["Arising from" messages in generated code] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider code generated when we desugar code before typechecking; -see Note [Rebindable syntax and HsExpansion]. +see Note [Rebindable syntax and XXExprGhcRn]. In this code, constraints may be generated, but we don't want to say "arising from a call of foo" if 'foo' doesn't appear in the ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -775,7 +775,7 @@ addArgCtxt :: AppCtxt -> LHsExpr GhcRn -- (VAExpansion), just use the less-informative context -- "In the expression: arg" -- Unless the arg is also a generated thing, in which case do nothing. --- See Note [Rebindable syntax and HsExpansion] in GHC.Hs.Expr +-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr -- 3. We are in an expanded do block's non-bind statement -- we simply add the statement context -- "In the statement of the do block .." @@ -784,7 +784,7 @@ addArgCtxt :: AppCtxt -> LHsExpr GhcRn -- so we set the location to be that of the argument -- b. Or, we are typechecking the second argument which would likely be a generated lambda -- so we set the location to be whatever the location in the context is --- See Note [Expanding HsDo with HsExpansion] in GHC.Tc.Gen.Match +-- See Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do addArgCtxt ctxt (L arg_loc arg) thing_inside = do { in_generated_code <- inGeneratedCode ; case ctxt of ===================================== compiler/GHC/Tc/Gen/Do.hs ===================================== @@ -44,14 +44,14 @@ import Data.List ((\\)) {- ************************************************************************ * * -\subsection{HsExpansion for Do Statements} +\subsection{XXExprGhcRn for Do Statements} * * ************************************************************************ -} -- | Expand the `do`-statments into expressions right after renaming -- so that they can be typechecked. --- See Note [Expanding HsDo with HsExpansion] below for `HsDo` specific commentary +-- See Note [Expanding HsDo with XXExprGhcRn] below for `HsDo` specific commentary -- and Note [Handling overloaded and rebindable constructs] for high level commentary expandDoStmts :: HsDoFlavour -> [ExprLStmt GhcRn] -> TcM (LHsExpr GhcRn) expandDoStmts doFlav stmts = do expanded_expr <- expand_do_stmts doFlav stmts @@ -63,7 +63,7 @@ expandDoStmts doFlav stmts = do expanded_expr <- expand_do_stmts doFlav stmts _ -> return expanded_expr -- | The main work horse for expanding do block statements into applications of binds and thens --- See Note [Expanding HsDo with HsExpansion] +-- See Note [Expanding HsDo with XXExprGhcRn] expand_do_stmts :: HsDoFlavour -> [ExprLStmt GhcRn] -> TcM (LHsExpr GhcRn) expand_do_stmts ListComp _ = @@ -86,7 +86,7 @@ expand_do_stmts _ (stmt@(L _ (ApplicativeStmt{})): _) = expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] --- See Note [Expanding HsDo with HsExpansion] Equation (5) below +-- See Note [Expanding HsDo with XXExprGhcRn] Equation (5) below -- last statement of a list comprehension, needs to explicitly return it -- See `checkLastStmt` and `Syntax.Expr.StmtLR.LastStmt` | NoSyntaxExprRn <- ret_expr @@ -104,7 +104,7 @@ expand_do_stmts _ [stmt@(L loc (LastStmt _ (L body_loc body) _ ret_expr))] return $ mkExpandedStmtPopAt loc stmt expansion expand_do_stmts do_or_lc (stmt@(L loc (LetStmt _ bs)) : lstmts) = --- See Note [Expanding HsDo with HsExpansion] Equation (3) below +-- See Note [Expanding HsDo with XXExprGhcRn] Equation (3) below -- stmts ~~> stmts' -- ------------------------------------------------ -- let x = e ; stmts ~~> let x = e in stmts' @@ -115,7 +115,7 @@ expand_do_stmts do_or_lc (stmt@(L loc (LetStmt _ bs)) : lstmts) = expand_do_stmts do_or_lc (stmt@(L loc (BindStmt xbsrn pat e)): lstmts) | SyntaxExprRn bind_op <- xbsrn_bindOp xbsrn , fail_op <- xbsrn_failOp xbsrn --- See Note [Expanding HsDo with HsExpansion] Equation (2) below +-- See Note [Expanding HsDo with XXExprGhcRn] Equation (2) below -- the pattern binding pat can fail -- stmts ~~> stmt' f = \case pat -> stmts'; -- _ -> fail "Pattern match failure .." @@ -133,7 +133,7 @@ expand_do_stmts do_or_lc (stmt@(L loc (BindStmt xbsrn pat e)): lstmts) expand_do_stmts do_or_lc (stmt@(L loc (BodyStmt _ e (SyntaxExprRn then_op) _)) : lstmts) = -- See Note [BodyStmt] in Language.Haskell.Syntax.Expr --- See Note [Expanding HsDo with HsExpansion] Equation (1) below +-- See Note [Expanding HsDo with XXExprGhcRn] Equation (1) below -- stmts ~~> stmts' -- ---------------------------------------------- -- e ; stmts ~~> (>>) e stmts' @@ -155,7 +155,7 @@ expand_do_stmts do_or_lc })) : lstmts) = -- See Note [Typing a RecStmt] in Language.Haskell.Syntax.Expr --- See Note [Expanding HsDo with HsExpansion] Equation (4) and (6) below +-- See Note [Expanding HsDo with XXExprGhcRn] Equation (4) and (6) below -- stmts ~~> stmts' -- ------------------------------------------------------------------------------------------- -- rec { later_ids, local_ids, rec_block } ; stmts @@ -235,9 +235,9 @@ mk_fail_block doFlav pat@(L ploc _) e (Just (SyntaxExprRn fail_op)) = mk_fail_block _ _ _ _ = pprPanic "mk_fail_block: impossible happened" empty -{- Note [Expanding HsDo with HsExpansion] +{- Note [Expanding HsDo with XXExprGhcRn] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We expand `do`-blocks before typechecking it, by re-using the existing `HsExpansions` and `RebindableSyntax` machinery. +We expand `do`-blocks before typechecking it, by re-using the existing `XXExprGhcRns` and `RebindableSyntax` machinery. This is very similar to: 1. Expansions done in `GHC.Rename.Expr.rnHsIf` for expanding `HsIf`; and 2. `desugarRecordUpd` in `GHC.Tc.Gen.Expr.tcExpr` for expanding `RecordUpd` @@ -247,7 +247,7 @@ To disabmiguate desugaring (`HsExpr GhcTc -> Core.Expr`) we use the phrase expan (`HsExpr GhcRn -> HsExpr GhcRn`) This expansion is done right before typechecking and after renaming -See Part 2. of Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` +See Part 2. of Note [Doing XXExprGhcRn in the Renamer vs Typechecker] in `GHC.Rename.Expr` Historical note START --------------------- @@ -423,8 +423,8 @@ It stores the original statement (with location) and the expanded expression * Whenever the typechecker steps through an `ExpandedThingRn`, we push the original statement in the error context, set the error location to the location of the statement, and then typecheck the expanded expression. - This is similar to vanilla `HsExpansion` and rebindable syntax - See Note [Rebindable syntax and HsExpansion] in `GHC.Hs.Expr`. + This is similar to vanilla `XXExprGhcRn` and rebindable syntax + See Note [Rebindable syntax and XXExprGhcRn] in `GHC.Hs.Expr`. * Recall, that when a source function argument fails to typecheck, we print an error message like "In the second argument of the function f..". ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -195,7 +195,7 @@ tcExpr :: HsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) -- - HsAppType type applications -- - ExprWithTySig (e :: type) -- - HsRecSel overloaded record fields --- - HsExpanded renamer expansions +-- - ExpandedThingRn renamer/pre-typechecker expansions -- - HsOpApp operator applications -- - HsOverLit overloaded literals -- These constructors are the union of @@ -270,7 +270,7 @@ tcExpr e@(HsLam x lam_variant matches) res_ty where match_ctxt | Just f <- doExpansionFlavour (mg_ext matches) - -- See Part 3. B. of Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do`. Testcase: Typeable1 + -- See Part 3. B. of Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do`. Testcase: Typeable1 = MC { mc_what = StmtCtxt (HsDoStmt f) , mc_body = tcBodyNC -- NB: Do not add any error contexts -- It has already been done @@ -432,7 +432,7 @@ tcExpr hsDo@(HsDo _ do_or_lc@(DoExpr{}) ss@(L _ stmts)) res_ty -- In the case of vanilla do expression. -- We expand the statements into explicit application of binds, thens and lets -- This helps in infering the right types for bind expressions when impredicativity is turned on --- See Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` +-- See Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do` = do { isApplicativeDo <- xoptM LangExt.ApplicativeDo ; if isApplicativeDo then tcDoStmts do_or_lc ss res_ty -- Use tcSyntaxOp if ApplicativeDo is turned on @@ -654,7 +654,7 @@ tcExpr (SectionR {}) ty = pprPanic "tcExpr:SectionR" (ppr ty) tcXExpr :: XXExprGhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcXExpr (PopErrCtxt (L loc e)) res_ty - = popErrCtxt $ -- See Part 3 of Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` + = popErrCtxt $ -- See Part 3 of Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do` setSrcSpanA loc $ tcExpr e res_ty @@ -675,7 +675,7 @@ tcXExpr xe@(ExpandedThingRn o e) res_ty -- It is important that we call tcExpr (and not tcApp) here as -- `e` is just the last statement's body expression -- and not a HsApp of a generated (>>) or (>>=) - -- This improves error messages e.g. T18324b.hs + -- This improves error messages e.g. DoExpansion1, DoExpansion2, DoExpansion3 | OrigStmt ls@(L loc _) <- o = setSrcSpanA loc $ mkExpandedStmtTc ls <$> tcApp (XExpr xe) res_ty @@ -1042,7 +1042,7 @@ we take the following steps: (0) Perform a first typechecking pass on the record expression (`e` in the example above), to infer the type of the record being updated. (1) Disambiguate the record fields (potentially using the type obtained in (0)). - (2) Desugar the record update as described above, using an HsExpansion. + (2) Desugar the record update as described above, using an XXExprGhcRn. (a) Create a let-binding to share the record update right-hand sides. (b) Desugar the record update to a case expression updating all the relevant constructors (those that have all of the fields being updated). ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -155,7 +155,7 @@ takes apart either an HsApp, or an infix OpApp, returning * The "user head" or "error head" of the application, to be reported to the user in case of an error. Example: (`op` e) - expands (via HsExpanded) to + expands (via ExpandedThingRn) to (rightSection op e) but we don't want to see 'rightSection' in error messages. So we keep the innermost un-expanded head as the "error head". @@ -323,7 +323,7 @@ splitHsApps e = go e (top_ctxt 0 e) [] HsUntypedSpliceExpr _ (L l _) -> set l ctxt -- l :: SrcAnn AnnListItem HsQuasiQuote _ _ (L l _) -> set l ctxt -- l :: SrcAnn NoEpAnns - -- See Note [Looking through HsExpanded] + -- See Note [Looking through ExpandedThingRn] go (XExpr (ExpandedThingRn o e)) ctxt args | isHsThingRnExpr o = go e (VAExpansion o (appCtxtLoc ctxt) (appCtxtLoc ctxt)) @@ -332,14 +332,14 @@ splitHsApps e = go e (top_ctxt 0 e) [] | OrigStmt (L _ stmt) <- o -- so that we set `(>>)` as generated , BodyStmt{} <- stmt -- and get the right unused bind warnings = go e (VAExpansion o generatedSrcSpan generatedSrcSpan) - -- See Part 3. in Note [Expanding HsDo with HsExpansion] + -- See Part 3. in Note [Expanding HsDo with XXExprGhcRn] (EWrap (EExpand o) : args) -- in `GHC.Tc.Gen.Do` | OrigPat (L loc _) <- o -- so that we set the compiler generated fail context = go e (VAExpansion o (locA loc) (locA loc)) -- to be originating from a failable pattern -- See Part 1. Wrinkle 2. of - (EWrap (EExpand o) : args) -- Note [Expanding HsDo with HsExpansion] + (EWrap (EExpand o) : args) -- Note [Expanding HsDo with XXExprGhcRn] -- in `GHC.Tc.Gen.Do` | otherwise @@ -783,25 +783,25 @@ pprHsExprArgTc arg = ppr arg Operator sections are desugared in the renamer; see GHC.Rename.Expr Note [Handling overloaded and rebindable constructs]. But for reasons explained there, we rename OpApp to OpApp. Then, -here in the typechecker, we desugar it to a use of HsExpanded. +here in the typechecker, we desugar it to a use of ExpandedThingRn. That makes it possible to typecheck something like e1 `f` e2 where f :: forall a. t1 -> forall b. t2 -> t3 -Note [Looking through HsExpanded] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Looking through ExpandedThingRn] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When creating an application chain in splitHsApps, we must deal with - HsExpanded f1 (f `HsApp` e1) `HsApp` e2 `HsApp` e3 + ExpandedThingRn f1 (f `HsApp` e1) `HsApp` e2 `HsApp` e3 as a single application chain `f e1 e2 e3`. Otherwise stuff like overloaded labels (#19154) won't work. -It's easy to achieve this: `splitHsApps` unwraps `HsExpanded`. +It's easy to achieve this: `splitHsApps` unwraps `ExpandedThingRn`. In order to be able to more accurately reconstruct the original `SrcSpan`s from the renamer in `rebuildHsApps`, we also have to track the `SrcSpan` -of the current application in `VAExpansion` when unwrapping `HsExpanded` +of the current application in `VAExpansion` when unwrapping `ExpandedThingRn` in `splitHsApps`, just as we track it in a non-expanded expression. Previously, `rebuildHsApps` substituted the location of the original ===================================== compiler/GHC/Tc/Types/LclEnv.hs ===================================== @@ -90,7 +90,7 @@ data TcLclCtxt = TcLclCtxt { tcl_loc :: RealSrcSpan, -- Source span tcl_ctxt :: [ErrCtxt], -- Error context, innermost on top - tcl_in_gen_code :: Bool, -- See Note [Rebindable syntax and HsExpansion] + tcl_in_gen_code :: Bool, -- See Note [Rebindable syntax and XXExprGhcRn] tcl_tclvl :: TcLevel, tcl_bndrs :: TcBinderStack, -- Used for reporting relevant bindings, -- and for tidying type ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -1219,7 +1219,7 @@ Note [Error contexts in generated code] So typically it's better to do setSrcSpan /before/ addErrCtxt. -See Note [Rebindable syntax and HsExpansion] in GHC.Hs.Expr for +See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr for more discussion of this fancy footwork, as well as Note [Generated code and pattern-match checking] in GHC.Types.Basic for the relation with pattern-match checks. @@ -1263,7 +1263,7 @@ pushCtxt ctxt = updLclEnv (updCtxt ctxt) updCtxt :: ErrCtxt -> TcLclEnv -> TcLclEnv -- Do not update the context if we are in generated code --- See Note [Rebindable syntax and HsExpansion] in GHC.Hs.Expr +-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr updCtxt ctxt env | lclEnvInGeneratedCode env = env | otherwise = addLclEnvErrCtxt ctxt env ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -600,7 +600,7 @@ isGenerated FromSource = False -- | This metadata stores the information as to why was the piece of code generated -- It is useful for generating the right error context --- See Part 3 in Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` +-- See Part 3 in Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do` data GenReason = DoExpansion HsDoFlavour | OtherExpansion deriving (Eq, Data) @@ -613,11 +613,11 @@ doExpansionFlavour :: Origin -> Maybe HsDoFlavour doExpansionFlavour (Generated (DoExpansion f) _) = Just f doExpansionFlavour _ = Nothing --- See Part 3 in Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` +-- See Part 3 in Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do` isDoExpansionGenerated :: Origin -> Bool isDoExpansionGenerated = isJust . doExpansionFlavour --- See Part 3 in Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` +-- See Part 3 in Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do` doExpansionOrigin :: HsDoFlavour -> Origin doExpansionOrigin f = Generated (DoExpansion f) DoPmc -- It is important that we perfrom PMC @@ -652,7 +652,7 @@ requiresPMC _ = True ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Some parts of the compiler generate code that is then typechecked. For example: - - the HsExpansion mechanism described in Note [Rebindable syntax and HsExpansion] + - the XXExprGhcRn mechanism described in Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr, - the deriving mechanism. ===================================== compiler/Language/Haskell/Syntax/Expr.hs ===================================== @@ -240,7 +240,7 @@ this if both data types are declared in the same module. NB 2: The notation getField @"size" e is short for HsApp (HsAppType (HsVar "getField") (HsWC (HsTyLit (HsStrTy "size")) [])) e. -We track the original parsed syntax via HsExpanded. +We track the original parsed syntax via ExpandedThingRn. -} @@ -588,7 +588,7 @@ data HsExpr p | XExpr !(XXExpr p) -- Note [Trees That Grow] in Language.Haskell.Syntax.Extension for the - -- general idea, and Note [Rebindable syntax and HsExpansion] in GHC.Hs.Expr + -- general idea, and Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr -- for an example of how we use it. -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8bdbd78f102e72b33208a491c7d33c1b7f43397 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8bdbd78f102e72b33208a491c7d33c1b7f43397 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 16 17:54:39 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Mon, 16 Oct 2023 13:54:39 -0400 Subject: [Git][ghc/ghc][wip/simpler-ghcversion.h] 8 commits: Fix restarts in .ghcid Message-ID: <652d78df8e2de_7336f403c36482283fe@gitlab.mail> John Ericson pushed to branch wip/simpler-ghcversion.h at Glasgow Haskell Compiler / GHC Commits: a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - f6d7ee9f by John Ericson at 2023-10-16T12:59:07-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 7c3b966f by John Ericson at 2023-10-16T13:52:20-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 22 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - configure.ac - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Packages.hs - − rts/ghcversion.h.top - rts/ghcversion.h.bottom → rts/include/ghcversion.h.in - + testsuite/tests/rename/should_compile/T24084.hs - + testsuite/tests/rename/should_compile/T24084_A.hs - + testsuite/tests/rename/should_compile/T24084_B.hs - testsuite/tests/rename/should_compile/all.T Changes: ===================================== .ghcid ===================================== @@ -2,4 +2,4 @@ --reload compiler --reload ghc --reload includes ---restart hadrian/ +--restart hadrian/ghci ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -97,7 +98,8 @@ The goal of this pass is to prepare for code generation. (The code generator can't deal with anything else.) Type lambdas are ok, however, because the code gen discards them. -5. [Not any more; nuked Jun 2002] Do the seq/par munging. +5. ANF-isation results in additional bindings that can obscure values. + We float these out; see Note [Floating in CorePrep]. 6. Clone all local Ids. This means that all such Ids are unique, rather than the @@ -165,7 +167,7 @@ Here is the syntax of the Core produced by CorePrep: Expressions body ::= app | let(rec) x = rhs in body -- Boxed only - | case body of pat -> body + | case app of pat -> body | /\a. body | /\c. body | body |> co @@ -217,7 +219,7 @@ corePrepPgm logger cp_cfg pgm_cfg binds_out = initUs_ us $ do floats1 <- corePrepTopBinds initialCorePrepEnv binds floats2 <- corePrepTopBinds initialCorePrepEnv implicit_binds - return (deFloatTop (floats1 `appendFloats` floats2)) + return (deFloatTop (floats1 `zipFloats` floats2)) endPassIO logger (cpPgm_endPassConfig pgm_cfg) binds_out [] @@ -244,7 +246,7 @@ corePrepTopBinds initialCorePrepEnv binds -- Only join points get returned this way by -- cpeBind, and no join point may float to top floatss <- go env' binds - return (floats `appendFloats` floatss) + return (floats `zipFloats` floatss) mkDataConWorkers :: Bool -> ModLocation -> [TyCon] -> [CoreBind] -- See Note [Data constructor workers] @@ -268,7 +270,40 @@ mkDataConWorkers generate_debug_info mod_loc data_tycons LexicalFastString $ mkFastString $ renderWithContext defaultSDocContext $ ppr name span1 file = realSrcLocSpan $ mkRealSrcLoc (mkFastString file) 1 1 -{- +{- Note [Floating in CorePrep] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ANFisation risks producing a lot of nested lets that obscures values: + let v = (:) (f 14) [] in e + ==> { ANF in CorePrep } + let v = let sat = f 14 in (:) sat [] in e +Here, `v` is not a value anymore, and we'd allocate a thunk closure for `v` that +allocates a thunk for `sat` and then allocates the cons cell. +Hence we carry around a bunch of floated bindings with us so that we again +expose the values: + let v = let sat = f 14 in (:) sat [] in e + ==> { Float sat } + let sat = f 14 in + let v = (:) sat [] in e +(We will not do this transformation if `v` does not become a value afterwards; +see Note [wantFloatLocal].) +If `v` is bound at the top-level, we might even float `sat` to top-level; +see Note [Floating out of top level bindings]. +For nested let bindings, we have to keep in mind Note [Core letrec invariant] +and may exploit strict contexts; see Note [wantFloatLocal]. + +There are 3 main categories of floats, encoded in the `FloatingBind` type: + + * `Float`: A floated binding, as `sat` above. + These come in different flavours as described by their `FloatInfo` and + `BindInfo`, which captures how far the binding can be floated and whether or + not we want to case-bind. See Note [BindInfo and FloatInfo]. + * `UnsafeEqualityCase`: Used for floating around unsafeEqualityProof bindings; + see (U3) of Note [Implementing unsafeCoerce]. + It's exactly a `Float` that is `CaseBound` and `LazyContextFloatable` + (see `mkNonRecFloat`), but one that has a non-DEFAULT Case alternative to + bind the unsafe coercion field of the Refl constructor. + * `FloatTick`: A floated `Tick`. See Note [Floating Ticks in CorePrep]. + Note [Floating out of top level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NB: we do need to float out of top-level bindings @@ -557,9 +592,9 @@ cpeBind top_lvl env (NonRec bndr rhs) floats1 | triv_rhs, isInternalName (idName bndr) = floats | otherwise - = addFloat floats new_float + = snocFloat floats new_float - new_float = mkFloat env dmd is_unlifted bndr1 rhs1 + new_float = mkNonRecFloat env dmd is_unlifted bndr1 rhs1 ; return (env2, floats1, Nothing) } @@ -578,15 +613,21 @@ cpeBind top_lvl env (Rec pairs) ; stuff <- zipWithM (cpePair top_lvl Recursive topDmd False env') bndrs1 rhss - ; let (floats_s, rhss1) = unzip stuff - -- Glom all floats into the Rec, *except* FloatStrings which can - -- (and must, because unlifted!) float further. - (string_floats, all_pairs) = - foldrOL add_float (emptyFloats, bndrs1 `zip` rhss1) - (concatFloats floats_s) + ; let (zipManyFloats -> floats, rhss1) = unzip stuff + -- Glom all floats into the Rec, *except* FloatStrings; see + -- see Note [ANF-ising literal string arguments], Wrinkle (FS1) + is_lit (Float (NonRec _ rhs) CaseBound TopLvlFloatable) = exprIsTickedString rhs + is_lit _ = False + (string_floats, top) = partitionOL is_lit (fs_binds floats) + -- Strings will *always* be in `top_floats` (we made sure of + -- that in `snocOL`), so that's the only field we need to + -- partition. + floats' = floats { fs_binds = top } + all_pairs = foldrOL add_float (bndrs1 `zip` rhss1) (getFloats floats') -- use env below, so that we reset cpe_rec_ids ; return (extendCorePrepEnvList env (bndrs `zip` bndrs1), - string_floats `addFloat` FloatLet (Rec all_pairs), + snocFloat (emptyFloats { fs_binds = string_floats }) + (Float (Rec all_pairs) LetBound TopLvlFloatable), Nothing) } | otherwise -- See Note [Join points and floating] @@ -604,10 +645,11 @@ cpeBind top_lvl env (Rec pairs) -- Flatten all the floats, and the current -- group into a single giant Rec - add_float (FloatLet (NonRec b r)) (ss, prs2) = (ss, (b,r) : prs2) - add_float (FloatLet (Rec prs1)) (ss, prs2) = (ss, prs1 ++ prs2) - add_float s at FloatString{} (ss, prs2) = (addFloat ss s, prs2) - add_float b _ = pprPanic "cpeBind" (ppr b) + add_float (Float bind bound _) prs2 + | bound /= CaseBound = case bind of + NonRec x e -> (x,e) : prs2 + Rec prs1 -> prs1 ++ prs2 + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool @@ -620,7 +662,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs do { (floats1, rhs1) <- cpeRhsE env rhs -- See if we are allowed to float this stuff out of the RHS - ; (floats2, rhs2) <- float_from_rhs floats1 rhs1 + ; let dec = want_float_from_rhs floats1 rhs1 + ; (floats2, rhs2) <- executeFloatDecision dec floats1 rhs1 -- Make the arity match up ; (floats3, rhs3) @@ -629,8 +672,8 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 - ; return ( addFloat floats2 float + ; let float = mkNonRecFloat env topDmd False v rhs2 + ; return ( snocFloat floats2 float , cpeEtaExpand arity (Var v)) }) -- Wrap floating ticks @@ -640,35 +683,9 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs where arity = idArity bndr -- We must match this arity - --------------------- - float_from_rhs floats rhs - | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs - - --------------------- - float_nested floats rhs - | wantFloatNested is_rec dmd is_unlifted floats rhs - = return (floats, rhs) - | otherwise = dontFloat floats rhs - - --------------------- - float_top floats rhs - | allLazyTop floats - = return (floats, rhs) - - | otherwise - = dontFloat floats rhs - -dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) --- Non-empty floats, but do not want to float from rhs --- So wrap the rhs in the floats --- But: rhs1 might have lambdas, and we can't --- put them inside a wrapBinds -dontFloat floats1 rhs - = do { (floats2, body) <- rhsToBody rhs - ; return (emptyFloats, wrapBinds floats1 $ - wrapBinds floats2 body) } + want_float_from_rhs floats rhs + | isTopLevel top_lvl = wantFloatTop floats + | otherwise = wantFloatLocal is_rec dmd is_unlifted floats rhs {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -754,14 +771,14 @@ cpeRhsE env (Let bind body) ; (body_floats, body') <- cpeRhsE env' body ; let expr' = case maybe_bind' of Just bind' -> Let bind' body' Nothing -> body' - ; return (bind_floats `appendFloats` body_floats, expr') } + ; return (bind_floats `appFloats` body_floats, expr') } cpeRhsE env (Tick tickish expr) -- Pull out ticks if they are allowed to be floated. | tickishFloatable tickish = do { (floats, body) <- cpeRhsE env expr -- See [Floating Ticks in CorePrep] - ; return (unitFloat (FloatTick tickish) `appendFloats` floats, body) } + ; return (FloatTick tickish `consFloat` floats, body) } | otherwise = do { body <- cpeBodyNF env expr ; return (emptyFloats, mkTick tickish' body) } @@ -805,12 +822,12 @@ cpeRhsE env (Case scrut bndr _ alts@[Alt con bs _]) ; (floats_rhs, rhs) <- cpeBody env rhs -- ... but we want to float `floats_rhs` as in (U3) so that rhs' might -- become a value - ; let case_float = FloatCase scrut bndr con bs True - -- NB: True <=> ok-for-spec; it is OK to "evaluate" the proof eagerly. + ; let case_float = UnsafeEqualityCase scrut bndr con bs + -- NB: It is OK to "evaluate" the proof eagerly. -- Usually there's the danger that we float the unsafeCoerce out of -- a branching Case alt. Not so here, because the regular code path -- for `cpeRhsE Case{}` will not float out of alts. - floats = addFloat floats_scrut case_float `appendFloats` floats_rhs + floats = snocFloat floats_scrut case_float `appFloats` floats_rhs ; return (floats, rhs) } cpeRhsE env (Case scrut bndr ty alts) @@ -859,7 +876,7 @@ cpeBody :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeBody) cpeBody env expr = do { (floats1, rhs) <- cpeRhsE env expr ; (floats2, body) <- rhsToBody rhs - ; return (floats1 `appendFloats` floats2, body) } + ; return (floats1 `appFloats` floats2, body) } -------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) @@ -882,7 +899,7 @@ rhsToBody expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] | otherwise -- Some value lambdas = do { let rhs = cpeEtaExpand (exprArity expr) expr ; fn <- newVar (exprType rhs) - ; let float = FloatLet (NonRec fn rhs) + ; let float = Float (NonRec fn rhs) LetBound TopLvlFloatable ; return (unitFloat float, Var fn) } where (bndrs,_) = collectBinders expr @@ -1125,7 +1142,8 @@ cpeApp top_env expr :: CorePrepEnv -> [ArgInfo] -- The arguments (inner to outer) -> CpeApp -- The function - -> Floats + -> Floats -- INVARIANT: These floats don't bind anything that is in the CpeApp! + -- Just stuff floated out from the head of the application. -> [Demand] -> Maybe Arity -> UniqSM (CpeApp @@ -1170,7 +1188,7 @@ cpeApp top_env expr (ss1 : ss_rest, False) -> (ss1, ss_rest) ([], _) -> (topDmd, []) (fs, arg') <- cpeArg top_env ss1 arg - rebuild_app' env as (App fun' arg') (fs `appendFloats` floats) ss_rest rt_ticks (req_depth-1) + rebuild_app' env as (App fun' arg') (fs `zipFloats` floats) ss_rest rt_ticks (req_depth-1) CpeCast co -> rebuild_app' env as (Cast fun' co) floats ss rt_ticks req_depth @@ -1182,7 +1200,7 @@ cpeApp top_env expr rebuild_app' env as fun' floats ss (tickish:rt_ticks) req_depth | otherwise -- See [Floating Ticks in CorePrep] - -> rebuild_app' env as fun' (addFloat floats (FloatTick tickish)) ss rt_ticks req_depth + -> rebuild_app' env as fun' (snocFloat floats (FloatTick tickish)) ss rt_ticks req_depth isLazyExpr :: CoreExpr -> Bool -- See Note [lazyId magic] in GHC.Types.Id.Make @@ -1261,8 +1279,7 @@ Other relevant Notes: * Note [runRW arg] below, describing a non-obvious case where the late-inlining could go wrong. - - Note [runRW arg] +Note [runRW arg] ~~~~~~~~~~~~~~~~~~~ Consider the Core program (from #11291), @@ -1294,7 +1311,6 @@ the function and the arguments) will forgo binding it to a variable. By contrast, in the non-bottoming case of `hello` above the function will be deemed non-trivial and consequently will be case-bound. - Note [Simplification of runRW#] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider the program, @@ -1408,8 +1424,7 @@ But with -O0, there is no FloatOut, so CorePrep must do the ANFisation to foo = Foo s (String literals are the only kind of binding allowed at top-level and hence -their floats are `OkToSpec` like lifted bindings, whereas all other unlifted -floats are `IfUnboxedOk` so that they don't float to top-level.) +their `FloatInfo` is `TopLvlFloatable`.) This appears to lead to bad code if the arg is under a lambda, because CorePrep doesn't float out of RHSs, e.g., (T23270) @@ -1432,24 +1447,13 @@ But actually, it doesn't, because "turtle"# is already an HNF. Here is the Cmm: Wrinkles: -(FS1) It is crucial that we float out String literals out of RHSs that could - become values, e.g., - - let t = case "turtle"# of s { __DEFAULT -> MkT s } - in f t - - where `MkT :: Addr# -> T`. We want - - let s = "turtle"#; t = MkT s - in f t - - because the former allocates an extra thunk for `t`. - Normally, the `case turtle# of s ...` becomes a `FloatCase` and - we don't float `FloatCase` outside of (recursive) RHSs, so we get the - former program (this is the 'allLazyNested' test in 'wantFloatNested'). - That is what we use `FloatString` for: It is essentially a `FloatCase` - which is always ok-to-spec/can be regarded as a non-allocating value and - thus be floated aggressively to expose more value bindings. +(FS1) We detect string literals in `cpeBind Rec{}` and float them out anyway; + otherwise we'd try to bind a string literal in a letrec, violating + Note [Core letrec invariant]. Since we know that literals don't have + free variables, we float further. + Arguably, we could just as well relax the letrec invariant for + string literals, or anthing that is a value (lifted or not). + This is tracked in #24036. -} -- This is where we arrange that a non-trivial argument is let-bound @@ -1459,10 +1463,9 @@ cpeArg env dmd arg = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; let arg_ty = exprType arg1 is_unlifted = isUnliftedType arg_ty - want_float = wantFloatNested NonRecursive dmd is_unlifted - ; (floats2, arg2) <- if want_float floats1 arg1 - then return (floats1, arg1) - else dontFloat floats1 arg1 + dec = wantFloatLocal NonRecursive dmd is_unlifted + floats1 arg1 + ; (floats2, arg2) <- executeFloatDecision dec floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -1474,8 +1477,8 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (addFloat floats2 arg_float, varToCoreExpr v) } + arg_float = mkNonRecFloat env dmd is_unlifted v arg3 + ; return (snocFloat floats2 arg_float, varToCoreExpr v) } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1508,20 +1511,6 @@ See Note [Eta expansion for join points] in GHC.Core.Opt.Arity Eta expanding the join point would introduce crap that we can't generate code for -Note [Floating unlifted arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider C (let v* = expensive in v) - -where the "*" indicates "will be demanded". Usually v will have been -inlined by now, but let's suppose it hasn't (see #2756). Then we -do *not* want to get - - let v* = expensive in C v - -because that has different strictness. Hence the use of 'allLazy'. -(NB: the let v* turns into a FloatCase, in mkLocalNonRec.) - - ------------------------------------------------------------------------------ -- Building the saturated syntax -- --------------------------------------------------------------------------- @@ -1714,7 +1703,9 @@ Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the DmdSig of the callee, or - 2. ok-for-spec, according to 'exprOkForSpeculation' + 2. ok-for-spec, according to 'exprOkForSpeculation'. + This includes DFuns `$fEqList a`, for example. + (Could identify more in the future; see reference to !1866 below.) While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' @@ -1791,159 +1782,262 @@ of the very function whose termination properties we are exploiting. It is also similar to Note [Do not strictify a DFun's parameter dictionaries], where marking recursive DFuns (of undecidable *instances*) strict in dictionary *parameters* leads to quite the same change in termination as above. + +Note [BindInfo and FloatInfo] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The `BindInfo` of a `Float` describes whether it will be case-bound or +let-bound: + + * `LetBound`: A let binding `let x = rhs in ...`, can be Rec or NonRec. + * `CaseBound`: A case binding `case rhs of x -> { __DEFAULT -> .. }`. + (So always NonRec.) + Some case-bound things (string literals, lifted bindings) + can float to top-level (but not all), hence it is similar + to, but not the same as `StrictContextFloatable :: FloatInfo` + described below. + +This info is used in `wrapBinds` to pick the corresponding binding form. + +We want to case-bind iff the binding is (non-recursive, and) either + + * ok-for-spec-eval (and perhaps lifted, see Note [Speculative evaluation]), or + * unlifted, or + * strictly used + +The `FloatInfo` of a `Float` describes how far it can float without +(a) violating Core invariants and (b) changing semantics. + + * Any binding is at least `StrictContextFloatable`, meaning we may float it + out of a strict context such as `f <>` where `f` is strict. + + * A binding is `LazyContextFloatable` if we may float it out of a lazy context + such as `let x = <> in Just x`. + Counterexample: A strict or unlifted binding that isn't ok-for-spec-eval + such as `case divInt# x y of r -> { __DEFAULT -> I# r }`. + Here, we may not foat out the strict `r = divInt# x y`. + + * A binding is `TopLvlFloatable` if it is `LazyContextFloatable` and also can + be bound at the top level. + Counterexample: A strict or unlifted binding (ok-for-spec-eval or not) + such as `case x +# y of r -> { __DEFAULT -> I# r }`. + +This meaning of "at least" is encoded in `floatsAtLeastAsFarAs`. +Note that today, `LetBound` implies `TopLvlFloatable`, so we could make do with +the the following enum (check `mkNonRecFloat` for whether this is up to date): + + LetBoundTopLvlFloatable (lifted or boxed values) + CaseBoundTopLvlFloatable (strings, ok-for-spec-eval and lifted) + CaseBoundLazyContextFloatable (ok-for-spec-eval and unlifted) + CaseBoundStrictContextFloatable (not ok-for-spec-eval and unlifted) + +Although there is redundancy in the current encoding, SG thinks it is cleaner +conceptually. + +See also Note [Floats and FloatDecision] for how we maintain whole groups of +floats and how far they go. + +Note [Floats and FloatDecision] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We have a special datatype `Floats` for modelling a telescope of `FloatingBind` +and caching its "maximum" `FloatInfo`, according to `floatsAtLeastAsFarAs` +(see Note [BindInfo and FloatInfo] for the ordering). +There are several operations for creating and combining `Floats` that maintain +scoping and the cached `FloatInfo`. + +When deciding whether we want to float out a `Floats` out of a binding context +such as `let x = <> in e` (let), `f <>` (app), or `x = <>; ...` (top-level), +we consult the cached `FloatInfo` of the `Floats`: + + * If we want to float to the top-level (`x = <>; ...`), we check whether + we may float-at-least-as-far-as `TopLvlFloatable`, in which case we + respond with `FloatAll :: FloatDecision`; otherwise we say `FloatNone`. + * If we want to float locally (let or app), then the floating decision is + described in Note [wantFloatLocal]. + +`executeFloatDecision` is then used to act on the particular `FloatDecision`. -} +-- See Note [BindInfo and FloatInfo] +data BindInfo + = CaseBound -- ^ A strict binding + | LetBound -- ^ A lazy or value binding + deriving Eq + +-- See Note [BindInfo and FloatInfo] +data FloatInfo + = TopLvlFloatable + -- ^ Anything that can be bound at top-level, such as arbitrary lifted + -- bindings or anything that responds True to `exprIsHNF`, such as literals or + -- saturated DataCon apps where unlifted or strict args are values. + + | LazyContextFloatable + -- ^ Anything that can be floated out of a lazy context. + -- In addition to any 'TopLvlFloatable' things, this includes (unlifted) + -- bindings that are ok-for-spec that we intend to case-bind. + + | StrictContextFloatable + -- ^ Anything that can be floated out of a strict evaluation context. + -- That is possible for all bindings; this is the Top element of 'FloatInfo'. + + deriving Eq + +instance Outputable BindInfo where + ppr CaseBound = text "Case" + ppr LetBound = text "Let" + +instance Outputable FloatInfo where + ppr TopLvlFloatable = text "top-lvl" + ppr LazyContextFloatable = text "lzy-ctx" + ppr StrictContextFloatable = text "str-ctx" + +-- See Note [Floating in CorePrep] +-- and Note [BindInfo and FloatInfo] data FloatingBind - -- | Rhs of bindings are CpeRhss - -- They are always of lifted type; - -- unlifted ones are done with FloatCase - = FloatLet CoreBind - - -- | Float a literal string binding. - -- INVARIANT: The `CoreExpr` matches `Lit (LitString bs)`. - -- It's just more convenient to keep around the expr rather than - -- the wrapped `bs` and reallocate the expr. - -- This is a special case of `FloatCase` that is unconditionally ok-for-spec. - -- We want to float out strings quite aggressively out of RHSs if doing so - -- saves allocation of a thunk ('wantFloatNested'); see Wrinkle (FS1) - -- in Note [ANF-ising literal string arguments]. - | FloatString !CoreExpr !Id - - | FloatCase - CpeBody -- ^ Scrutinee - Id -- ^ Case binder - AltCon [Var] -- ^ Single alternative - Bool -- ^ Ok-for-speculation; False of a strict, - -- but lifted binding that is not OK for - -- Note [Speculative evaluation]. - - -- | See Note [Floating Ticks in CorePrep] + = Float !CoreBind !BindInfo !FloatInfo + | UnsafeEqualityCase !CoreExpr !CoreBndr !AltCon ![CoreBndr] | FloatTick CoreTickish -data Floats = Floats OkToSpec (OrdList FloatingBind) +-- See Note [Floats and FloatDecision] +data Floats + = Floats + { fs_info :: !FloatInfo + , fs_binds :: !(OrdList FloatingBind) + } instance Outputable FloatingBind where - ppr (FloatLet b) = ppr b - ppr (FloatString e b) = text "string" <> braces (ppr b <> char '=' <> ppr e) - ppr (FloatCase r b k bs ok) = text "case" <> braces (ppr ok) <+> ppr r + ppr (Float b bi fi) = ppr bi <+> ppr fi <+> ppr b + ppr (FloatTick t) = ppr t + ppr (UnsafeEqualityCase scrut b k bs) = text "case" <+> ppr scrut <+> text "of"<+> ppr b <> text "@" <> case bs of [] -> ppr k _ -> parens (ppr k <+> ppr bs) - ppr (FloatTick t) = ppr t instance Outputable Floats where - ppr (Floats flag fs) = text "Floats" <> brackets (ppr flag) <+> - braces (vcat (map ppr (fromOL fs))) - -instance Outputable OkToSpec where - ppr OkToSpec = text "OkToSpec" - ppr IfUnliftedOk = text "IfUnliftedOk" - ppr NotOkToSpec = text "NotOkToSpec" - --- Can we float these binds out of the rhs of a let? We cache this decision --- to avoid having to recompute it in a non-linear way when there are --- deeply nested lets. -data OkToSpec - = OkToSpec -- ^ Lazy bindings of lifted type. Float as you please - | IfUnliftedOk -- ^ A mixture of lazy lifted bindings and n - -- ok-to-speculate unlifted bindings. - -- Float out of lets, but not to top-level! - | NotOkToSpec -- ^ Some not-ok-to-speculate unlifted bindings - -mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind -mkFloat env dmd is_unlifted bndr rhs - | Lit LitString{} <- rhs = FloatString rhs bndr - - | is_strict || ok_for_spec - , not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec - -- See Note [Speculative evaluation] - -- Don't make a case for a HNF binding, even if it's strict - -- Otherwise we get case (\x -> e) of ...! - - | is_unlifted = FloatCase rhs bndr DEFAULT [] True - -- we used to assertPpr ok_for_spec (ppr rhs) here, but it is now disabled - -- because exprOkForSpeculation isn't stable under ANF-ing. See for - -- example #19489 where the following unlifted expression: - -- - -- GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] - -- (GHC.Types.: @a_ax0 a2_agq a3_agl) - -- - -- is ok-for-spec but is ANF-ised into: - -- - -- let sat = GHC.Types.: @a_ax0 a2_agq a3_agl - -- in GHC.Prim.(#|_#) @LiftedRep @LiftedRep @[a_ax0] @[a_ax0] sat - -- - -- which isn't ok-for-spec because of the let-expression. - - | is_hnf = FloatLet (NonRec bndr rhs) - | otherwise = FloatLet (NonRec (setIdDemandInfo bndr dmd) rhs) - -- See Note [Pin demand info on floats] - where - is_hnf = exprIsHNF rhs - is_strict = isStrUsedDmd dmd - ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs - is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + ppr (Floats info binds) = text "Floats" <> brackets (ppr info) <> braces (ppr binds) + +lubFloatInfo :: FloatInfo -> FloatInfo -> FloatInfo +lubFloatInfo StrictContextFloatable _ = StrictContextFloatable +lubFloatInfo _ StrictContextFloatable = StrictContextFloatable +lubFloatInfo LazyContextFloatable _ = LazyContextFloatable +lubFloatInfo _ LazyContextFloatable = LazyContextFloatable +lubFloatInfo TopLvlFloatable TopLvlFloatable = TopLvlFloatable + +floatsAtLeastAsFarAs :: FloatInfo -> FloatInfo -> Bool +-- See Note [Floats and FloatDecision] +floatsAtLeastAsFarAs l r = l `lubFloatInfo` r == r emptyFloats :: Floats -emptyFloats = Floats OkToSpec nilOL +emptyFloats = Floats TopLvlFloatable nilOL isEmptyFloats :: Floats -> Bool -isEmptyFloats (Floats _ bs) = isNilOL bs +isEmptyFloats (Floats _ b) = isNilOL b -wrapBinds :: Floats -> CpeBody -> CpeBody -wrapBinds (Floats _ binds) body - = foldrOL mk_bind body binds - where - mk_bind (FloatCase rhs bndr con bs _) body = Case rhs bndr (exprType body) [Alt con bs body] - mk_bind (FloatString rhs bndr) body = Case rhs bndr (exprType body) [Alt DEFAULT [] body] - mk_bind (FloatLet bind) body = Let bind body - mk_bind (FloatTick tickish) body = mkTick tickish body - -addFloat :: Floats -> FloatingBind -> Floats -addFloat (Floats ok_to_spec floats) new_float - = Floats (combine ok_to_spec (check new_float)) (floats `snocOL` new_float) - where - check FloatLet {} = OkToSpec - check FloatTick{} = OkToSpec - check FloatString{} = OkToSpec - check (FloatCase _ _ _ _ ok_for_spec) - | ok_for_spec = IfUnliftedOk - | otherwise = NotOkToSpec - -- The ok-for-speculation flag says that it's safe to - -- float this Case out of a let, and thereby do it more eagerly - -- We need the IfUnliftedOk flag because it's never ok to float - -- an unlifted binding to the top level. - -- There is one exception: String literals! But those will become - -- FloatString and thus OkToSpec. - -- See Note [ANF-ising literal string arguments] +getFloats :: Floats -> OrdList FloatingBind +getFloats = fs_binds unitFloat :: FloatingBind -> Floats -unitFloat = addFloat emptyFloats - -appendFloats :: Floats -> Floats -> Floats -appendFloats (Floats spec1 floats1) (Floats spec2 floats2) - = Floats (combine spec1 spec2) (floats1 `appOL` floats2) - -concatFloats :: [Floats] -> OrdList FloatingBind -concatFloats = foldr (\ (Floats _ bs1) bs2 -> appOL bs1 bs2) nilOL - -combine :: OkToSpec -> OkToSpec -> OkToSpec -combine NotOkToSpec _ = NotOkToSpec -combine _ NotOkToSpec = NotOkToSpec -combine IfUnliftedOk _ = IfUnliftedOk -combine _ IfUnliftedOk = IfUnliftedOk -combine _ _ = OkToSpec +unitFloat = snocFloat emptyFloats + +floatInfo :: FloatingBind -> FloatInfo +floatInfo (Float _ _ info) = info +floatInfo UnsafeEqualityCase{} = LazyContextFloatable -- See Note [Floating in CorePrep] +floatInfo FloatTick{} = TopLvlFloatable -- We filter these out in cpePair, + -- see Note [Floating Ticks in CorePrep] + +-- | Append a `FloatingBind` `b` to a `Floats` telescope `bs` that may reference any +-- binding of the 'Floats'. +snocFloat :: Floats -> FloatingBind -> Floats +snocFloat floats fb = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fs_binds floats `snocOL` fb } + +-- | Cons a `FloatingBind` `b` to a `Floats` telescope `bs` which scopes over +-- `b`. +consFloat :: FloatingBind -> Floats -> Floats +consFloat fb floats = + Floats { fs_info = lubFloatInfo (fs_info floats) (floatInfo fb) + , fs_binds = fb `consOL` fs_binds floats } + +-- | Append two telescopes, nesting the right inside the left. +appFloats :: Floats -> Floats -> Floats +appFloats outer inner = + Floats { fs_info = lubFloatInfo (fs_info outer) (fs_info inner) + , fs_binds = fs_binds outer `appOL` fs_binds inner } + +-- | Zip up two `Floats`, none of which scope over the other +zipFloats :: Floats -> Floats -> Floats +-- We may certainly just nest one telescope in the other, so appFloats is a +-- valid implementation strategy. +zipFloats = appFloats + +-- | `zipFloats` a bunch of independent telescopes. +zipManyFloats :: [Floats] -> Floats +zipManyFloats = foldr zipFloats emptyFloats + +mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind +mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $ + Float (NonRec bndr' rhs) bound info + where + bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] + (bound,info) + | is_lifted, is_hnf = (LetBound, TopLvlFloatable) + -- is_lifted: We currently don't allow unlifted values at the + -- top-level or inside letrecs + -- (but SG thinks that in principle, we should) + | is_data_con bndr = (LetBound, TopLvlFloatable) + -- We need this special case for unlifted DataCon workers/wrappers + -- until #17521 is fixed + | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) + -- String literals are unboxed (so must be case-bound) and float to + -- the top-level + | is_unlifted, ok_for_spec = (CaseBound, LazyContextFloatable) + | is_lifted, ok_for_spec = (CaseBound, TopLvlFloatable) + -- See Note [Speculative evaluation] + -- Ok-for-spec-eval things will be case-bound, lifted or not. + -- But when it's lifted we are ok with floating it to top-level + -- (where it is actually bound lazily). + | is_unlifted || is_strict = (CaseBound, StrictContextFloatable) + -- These will never be floated out of a lazy RHS context + | otherwise = assertPpr is_lifted (ppr rhs) $ + (LetBound, TopLvlFloatable) + -- And these float freely but can't be speculated, hence LetBound + + is_lifted = not is_unlifted + is_hnf = exprIsHNF rhs + is_strict = isStrUsedDmd dmd + ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs + is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + is_data_con = isJust . isDataConId_maybe +-- | Wrap floats around an expression +wrapBinds :: Floats -> CpeBody -> CpeBody +wrapBinds floats body + = -- pprTraceWith "wrapBinds" (\res -> ppr floats $$ ppr body $$ ppr res) $ + foldrOL mk_bind body (getFloats floats) + where + -- See Note [BindInfo and FloatInfo] on whether we pick Case or Let here + mk_bind f@(Float bind CaseBound _) body + | NonRec bndr rhs <- bind + = mkDefaultCase rhs bndr body + | otherwise + = pprPanic "wrapBinds" (ppr f) + mk_bind (Float bind _ _) body + = Let bind body + mk_bind (UnsafeEqualityCase scrut b con bs) body + = mkSingleAltCase scrut b con bs body + mk_bind (FloatTick tickish) body + = mkTick tickish body + +-- | Put floats at top-level deFloatTop :: Floats -> [CoreBind] --- For top level only; we don't expect any FloatCases -deFloatTop (Floats _ floats) - = foldrOL get [] floats +-- Precondition: No Strict or LazyContextFloatable 'FloatInfo', no ticks! +deFloatTop floats + = foldrOL get [] (getFloats floats) where - get (FloatLet b) bs = get_bind b : bs - get (FloatString body var) bs = get_bind (NonRec var body) : bs - get (FloatCase body var _ _ _) bs = get_bind (NonRec var body) : bs - get b _ = pprPanic "corePrepPgm" (ppr b) + get (Float b _ TopLvlFloatable) bs + = get_bind b : bs + get b _ = pprPanic "corePrepPgm" (ppr b) -- See Note [Dead code in CorePrep] get_bind (NonRec x e) = NonRec x (occurAnalyseExpr e) @@ -1951,25 +2045,113 @@ deFloatTop (Floats _ floats) --------------------------------------------------------------------------- -wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec dmd rhs_is_unlifted floats rhs - = isEmptyFloats floats - || isStrUsedDmd dmd - || rhs_is_unlifted - || (allLazyNested is_rec floats && exprIsHNF rhs) - -- Why the test for allLazyNested? - -- v = f (x `divInt#` y) - -- we don't want to float the case, even if f has arity 2, - -- because floating the case would make it evaluated too early - -allLazyTop :: Floats -> Bool -allLazyTop (Floats OkToSpec _) = True -allLazyTop _ = False - -allLazyNested :: RecFlag -> Floats -> Bool -allLazyNested _ (Floats OkToSpec _) = True -allLazyNested _ (Floats NotOkToSpec _) = False -allLazyNested is_rec (Floats IfUnliftedOk _) = isNonRec is_rec +{- Note [wantFloatLocal] +~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + let x = let y = e1 in e2 + in e +Similarly for `(\x. e) (let y = e1 in e2)`. +Do we want to float out `y` out of `x`? +(This is discussed in detail in the paper +"Let-floating: moving bindings to give faster programs".) + +`wantFloatLocal` is concerned with answering this question. +It considers the Demand on `x`, whether or not `e2` is unlifted and the +`FloatInfo` of the `y` binding (e.g., it might itself be unlifted, a value, +strict, or ok-for-spec). + +We float out if ... + 1. ... the binding context is strict anyway, so either `x` is used strictly + or has unlifted type. + Doing so is trivially sound and won`t increase allocations, so we + return `FloatAll`. + This might happen while ANF-ising `f (g (h 13))` where `f`,`g` are strict: + f (g (h 13)) + ==> { ANF } + case (case h 13 of r -> g r) of r2 -> f r2 + ==> { Float } + case h 13 of r -> case g r of r2 -> f r2 + The latter is easier to read and grows less stack. + 2. ... `e2` becomes a value in doing so, in which case we won't need to + allocate a thunk for `x`/the arg that closes over the FVs of `e1`. + In general, this is only sound if `y=e1` is `LazyContextFloatable`. + (See Note [BindInfo and FloatInfo].) + Nothing is won if `x` doesn't become a value + (i.e., `let x = let sat = f 14 in g sat in e`), + so we return `FloatNone` if there is any float that is + `StrictContextFloatable`, and return `FloatAll` otherwise. + +To elaborate on (2), consider the case when the floated binding is +`e1 = divInt# a b`, e.g., not `LazyContextFloatable`: + let x = I# (a `divInt#` b) + in e +this ANFises to + let x = case a `divInt#` b of r { __DEFAULT -> I# r } + in e +If `x` is used lazily, we may not float `r` further out. +A float binding `x +# y` is OK, though, and so every ok-for-spec-eval +binding is `LazyContextFloatable`. + +Wrinkles: + + (W1) When the outer binding is a letrec, i.e., + letrec x = case a +# b of r { __DEFAULT -> f y r } + y = [x] + in e + we don't want to float `LazyContextFloatable` bindings such as `r` either + and require `TopLvlFloatable` instead. + The reason is that we don't track FV of FloatBindings, so we would need + to park them in the letrec, + letrec r = a +# b -- NB: r`s RHS might scope over x and y + x = f y r + y = [x] + in e + and now we have violated Note [Core letrec invariant]. + So we preempt this case in `wantFloatLocal`, responding `FloatNone` unless + all floats are `TopLvlFloatable`. +-} + +data FloatDecision + = FloatNone + | FloatAll + +executeFloatDecision :: FloatDecision -> Floats -> CpeRhs -> UniqSM (Floats, CpeRhs) +executeFloatDecision dec floats rhs = do + let (float,stay) = case dec of + _ | isEmptyFloats floats -> (emptyFloats,emptyFloats) + FloatNone -> (emptyFloats, floats) + FloatAll -> (floats, emptyFloats) + -- Wrap `stay` around `rhs`. + -- NB: `rhs` might have lambdas, and we can't + -- put them inside a wrapBinds, which expects a `CpeBody`. + if isEmptyFloats stay -- Fast path where we don't need to call `rhsToBody` + then return (float, rhs) + else do + (floats', body) <- rhsToBody rhs + return (float, wrapBinds stay $ wrapBinds floats' body) + +wantFloatTop :: Floats -> FloatDecision +wantFloatTop fs + | fs_info fs `floatsAtLeastAsFarAs` TopLvlFloatable = FloatAll + | otherwise = FloatNone + +wantFloatLocal :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> FloatDecision +-- See Note [wantFloatLocal] +wantFloatLocal is_rec rhs_dmd rhs_is_unlifted floats rhs + | isEmptyFloats floats -- Well yeah... + || isStrUsedDmd rhs_dmd -- Case (1) of Note [wantFloatLocal] + || rhs_is_unlifted -- dito + || (fs_info floats `floatsAtLeastAsFarAs` max_float_info && exprIsHNF rhs) + -- Case (2) of Note [wantFloatLocal] + = FloatAll + + | otherwise + = FloatNone + where + max_float_info | isRec is_rec = TopLvlFloatable + | otherwise = LazyContextFloatable + -- See Note [wantFloatLocal], Wrinkle (W1) + -- for 'is_rec' {- ************************************************************************ @@ -2224,26 +2406,28 @@ newVar ty -- | Like wrapFloats, but only wraps tick floats wrapTicks :: Floats -> CoreExpr -> (Floats, CoreExpr) -wrapTicks (Floats flag floats0) expr = - (Floats flag (toOL $ reverse floats1), foldr mkTick expr (reverse ticks1)) - where (floats1, ticks1) = foldlOL go ([], []) $ floats0 +wrapTicks floats expr + | (floats1, ticks1) <- fold_fun go floats + = (floats1, foldrOL mkTick expr ticks1) + where fold_fun f floats = + let (binds, ticks) = foldlOL f (nilOL,nilOL) (fs_binds floats) + in (floats { fs_binds = binds }, ticks) -- Deeply nested constructors will produce long lists of -- redundant source note floats here. We need to eliminate -- those early, as relying on mkTick to spot it after the fact -- can yield O(n^3) complexity [#11095] - go (floats, ticks) (FloatTick t) + go (flt_binds, ticks) (FloatTick t) = assert (tickishPlace t == PlaceNonLam) - (floats, if any (flip tickishContains t) ticks - then ticks else t:ticks) - go (floats, ticks) f at FloatString{} - = (f:floats, ticks) -- don't need to wrap the tick around the string; nothing to execute. - go (floats, ticks) f - = (foldr wrap f (reverse ticks):floats, ticks) - - wrap t (FloatLet bind) = FloatLet (wrapBind t bind) - wrap t (FloatCase r b con bs ok) = FloatCase (mkTick t r) b con bs ok - wrap _ other = pprPanic "wrapTicks: unexpected float!" - (ppr other) + (flt_binds, if any (flip tickishContains t) ticks + then ticks else ticks `snocOL` t) + go (flt_binds, ticks) f at UnsafeEqualityCase{} + -- unsafe equality case will be erased; don't wrap anything! + = (flt_binds `snocOL` f, ticks) + go (flt_binds, ticks) f at Float{} + = (flt_binds `snocOL` foldrOL wrap f ticks, ticks) + + wrap t (Float bind bound info) = Float (wrapBind t bind) bound info + wrap _ f = pprPanic "Unexpected FloatingBind" (ppr f) wrapBind t (NonRec binder rhs) = NonRec binder (mkTick t rhs) wrapBind t (Rec pairs) = Rec (mapSnd (mkTick t) pairs) ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -16,8 +16,8 @@ module GHC.Data.OrdList ( OrdList, pattern NilOL, pattern ConsOL, pattern SnocOL, nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, headOL, - mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, reverseOL, fromOLReverse, - strictlyEqOL, strictlyOrdOL + mapOL, mapOL', fromOL, toOL, foldrOL, foldlOL, + partitionOL, reverseOL, fromOLReverse, strictlyEqOL, strictlyOrdOL ) where import GHC.Prelude @@ -220,6 +220,25 @@ foldlOL k z (Snoc xs x) = let !z' = (foldlOL k z xs) in k z' x foldlOL k z (Two b1 b2) = let !z' = (foldlOL k z b1) in foldlOL k z' b2 foldlOL k z (Many xs) = foldl' k z xs +partitionOL :: (a -> Bool) -> OrdList a -> (OrdList a, OrdList a) +partitionOL _ None = (None,None) +partitionOL f (One x) + | f x = (One x, None) + | otherwise = (None, One x) +partitionOL f (Two xs ys) = (Two ls1 ls2, Two rs1 rs2) + where !(!ls1,!rs1) = partitionOL f xs + !(!ls2,!rs2) = partitionOL f ys +partitionOL f (Cons x xs) + | f x = (Cons x ls, rs) + | otherwise = (ls, Cons x rs) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Snoc xs x) + | f x = (Snoc ls x, rs) + | otherwise = (ls, Snoc rs x) + where !(!ls,!rs) = partitionOL f xs +partitionOL f (Many xs) = (toOL ls, toOL rs) + where !(!ls,!rs) = NE.partition f xs + toOL :: [a] -> OrdList a toOL [] = None toOL [x] = One x ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -692,13 +692,14 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup | otherwise = do gre_env <- getGlobalRdrEnv let original_gres = lookupGRE gre_env (LookupChildren (rdrNameOcc rdr_name) how_lkup) - -- The remaining GREs are things that we *could* export here, note that - -- this includes things which have `NoParent`. Those are sorted in - -- `checkPatSynParent`. + picked_gres = pick_gres original_gres + -- The remaining GREs are things that we *could* export here. + -- Note that this includes things which have `NoParent`; + -- those are sorted in `checkPatSynParent`. traceRn "parent" (ppr parent) traceRn "lookupExportChild original_gres:" (ppr original_gres) - traceRn "lookupExportChild picked_gres:" (ppr (picked_gres original_gres) $$ ppr must_have_parent) - case picked_gres original_gres of + traceRn "lookupExportChild picked_gres:" (ppr picked_gres $$ ppr must_have_parent) + case picked_gres of NoOccurrence -> noMatchingParentErr original_gres UniqueOccurrence g -> @@ -745,34 +746,36 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name how_lkup addNameClashErrRn rdr_name gres return (FoundChild (NE.head gres)) - picked_gres :: [GlobalRdrElt] -> DisambigInfo + pick_gres :: [GlobalRdrElt] -> DisambigInfo -- For Unqual, find GREs that are in scope qualified or unqualified -- For Qual, find GREs that are in scope with that qualification - picked_gres gres + pick_gres gres | isUnqual rdr_name = mconcat (map right_parent gres) | otherwise = mconcat (map right_parent (pickGREs rdr_name gres)) right_parent :: GlobalRdrElt -> DisambigInfo - right_parent p - = case greParent p of + right_parent gre + = case greParent gre of ParentIs cur_parent - | parent == cur_parent -> DisambiguatedOccurrence p + | parent == cur_parent -> DisambiguatedOccurrence gre | otherwise -> NoOccurrence - NoParent -> UniqueOccurrence p + NoParent -> UniqueOccurrence gre {-# INLINEABLE lookupSubBndrOcc_helper #-} --- This domain specific datatype is used to record why we decided it was +-- | This domain specific datatype is used to record why we decided it was -- possible that a GRE could be exported with a parent. data DisambigInfo = NoOccurrence - -- The GRE could never be exported. It has the wrong parent. + -- ^ The GRE could not be found, or it has the wrong parent. | UniqueOccurrence GlobalRdrElt - -- The GRE has no parent. It could be a pattern synonym. + -- ^ The GRE has no parent. It could be a pattern synonym. | DisambiguatedOccurrence GlobalRdrElt - -- The parent of the GRE is the correct parent + -- ^ The parent of the GRE is the correct parent. | AmbiguousOccurrence (NE.NonEmpty GlobalRdrElt) + -- ^ The GRE is ambiguous. + -- -- For example, two normal identifiers with the same name are in -- scope. They will both be resolved to "UniqueOccurrence" and the -- monoid will combine them to this failing case. @@ -784,7 +787,7 @@ instance Outputable DisambigInfo where ppr (AmbiguousOccurrence gres) = text "Ambiguous:" <+> ppr gres instance Semi.Semigroup DisambigInfo where - -- This is the key line: We prefer disambiguated occurrences to other + -- These are the key lines: we prefer disambiguated occurrences to other -- names. _ <> DisambiguatedOccurrence g' = DisambiguatedOccurrence g' DisambiguatedOccurrence g' <> _ = DisambiguatedOccurrence g' ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1068,13 +1068,17 @@ Notice that T appears *twice*, once as a child and once as a parent. From these two exports, respectively, during construction of the imp_occ_env, we begin by associating the following two elements with the key T: - T -> ImpOccItem { imp_item = T, imp_bundled = [C,T] , imp_is_parent = False } - T -> ImpOccItem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> ImpOccItem { imp_item = gre1, imp_bundled = [C,T] , imp_is_parent = False } + T -> ImpOccItem { imp_item = gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } -We combine these (in function 'combine' in 'mkImportOccEnv') by simply discarding -the first item, to get: +where `gre1`, `gre2` are two GlobalRdrElts with greName T. +We combine these (in function 'combine' in 'mkImportOccEnv') by discarding the +non-parent item, thusly: - T -> IE_ITem { imp_item = T, imp_bundled = [T1,T2,T3], imp_is_parent = True } + T -> IE_ITem { imp_item = gre1 `plusGRE` gre2, imp_bundled = [T1,T2,T3], imp_is_parent = True } + +Note the `plusGRE`: this ensures we don't drop parent information; +see Note [Preserve parent information when combining import OccEnvs]. So the overall imp_occ_env is: @@ -1133,6 +1137,31 @@ Whereas in case (B) we reach the lookup_ie case for IEThingWith, which looks up 'S' and then finds the unique 'foo' amongst its children. See T16745 for a test of this. + +Note [Preserve parent information when combining import OccEnvs] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When discarding one ImpOccItem in favour of another, as described in +Note [Dealing with imports], we must make sure to combine the GREs so that +we don't lose information. + +Consider for example #24084: + + module M1 where { class C a where { type T a } } + module M2 ( module M1 ) where { import M1 } + module M3 where { import M2 ( C, T ); instance C () where T () = () } + +When processing the import list of `M3`, we will have two `Avail`s attached +to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function +of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard +`C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** +discard the information want that `C` is the parent of `T`. Indeed, +losing track of this information can cause errors when importing, +as we could get an error of the form + + ‘T’ is not a (visible) associated type of class ‘C’ + +This explains why we use `plusGRE` when combining the two ImpOccItems, even +though we are discarding one in favour of the other. -} -- | All the 'GlobalRdrElt's associated with an 'AvailInfo'. @@ -1443,6 +1472,14 @@ data ImpOccItem -- ^ Is the import item a parent? See Note [Dealing with imports]. } +instance Outputable ImpOccItem where + ppr (ImpOccItem { imp_item = item, imp_bundled = bundled, imp_is_parent = is_par }) + = braces $ hsep + [ text "ImpOccItem" + , if is_par then text "[is_par]" else empty + , ppr (greName item) <+> ppr (greParent item) + , braces $ text "bundled:" <+> ppr (map greName bundled) ] + -- | Make an 'OccEnv' of all the imports. -- -- Complicated by the fact that associated data types and pattern synonyms @@ -1474,9 +1511,9 @@ mkImportOccEnv hsc_env decl_spec all_avails = -- See Note [Dealing with imports] -- 'combine' may be called for associated data types which appear - -- twice in the all_avails. In the example, we combine - -- T(T,T1,T2,T3) and C(C,T) to give (T, T(T,T1,T2,T3), Just C) - -- NB: the AvailTC can have fields as well as data constructors (#12127) + -- twice in the all_avails. In the example, we have two Avails for T, + -- namely T(T,T1,T2,T3) and C(C,T), and we combine them by dropping the + -- latter, in which T is not the parent. combine :: ImpOccItem -> ImpOccItem -> ImpOccItem combine item1@(ImpOccItem { imp_item = gre1, imp_is_parent = is_parent1 }) item2@(ImpOccItem { imp_item = gre2, imp_is_parent = is_parent2 }) @@ -1484,11 +1521,13 @@ mkImportOccEnv hsc_env decl_spec all_avails = , not (isRecFldGRE gre1 || isRecFldGRE gre2) -- NB: does not force GREInfo. , let name1 = greName gre1 name2 = greName gre2 + gre = gre1 `plusGRE` gre2 + -- See Note [Preserve parent information when combining import OccEnvs] = assertPpr (name1 == name2) (ppr name1 <+> ppr name2) $ if is_parent1 - then item1 - else item2 + then item1 { imp_item = gre } + else item2 { imp_item = gre } -- Discard C(C,T) in favour of T(T, T1, T2, T3). -- 'combine' may also be called for pattern synonyms which appear both ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -175,7 +175,7 @@ filterAvail keep ie rest = -- 'avails' may have several items with the same availName -- E.g import Ix( Ix(..), index ) -- will give Ix(Ix,index,range) and Ix(index) --- We want to combine these; addAvail does that +-- We want to combine these; plusAvail does that nubAvails :: [AvailInfo] -> [AvailInfo] nubAvails avails = eltsDNameEnv (foldl' add emptyDNameEnv avails) where ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -76,6 +76,7 @@ module GHC.Types.Name.Reader ( -- ** Global 'RdrName' mapping elements: 'GlobalRdrElt', 'Provenance', 'ImportSpec' GlobalRdrEltX(..), GlobalRdrElt, IfGlobalRdrElt, FieldGlobalRdrElt, greName, greNameSpace, greParent, greInfo, + plusGRE, insertGRE, forceGlobalRdrEnv, hydrateGlobalRdrEnv, isLocalGRE, isImportedGRE, isRecFldGRE, fieldGREInfo, @@ -1165,6 +1166,17 @@ data WhichGREs info where } -> WhichGREs GREInfo +instance Outputable (WhichGREs info) where + ppr SameNameSpace = text "SameNameSpace" + ppr (RelevantGREs { includeFieldSelectors = sel + , lookupVariablesForFields = vars + , lookupTyConsAsWell = tcs_too }) + = braces $ hsep + [ text "RelevantGREs" + , text (show sel) + , if vars then text "[vars]" else empty + , if tcs_too then text "[tcs]" else empty ] + -- | Look up as many possibly relevant 'GlobalRdrElt's as possible. pattern AllRelevantGREs :: WhichGREs GREInfo pattern AllRelevantGREs = @@ -1199,6 +1211,17 @@ data LookupChild -- See Note [childGREPriority]. } +instance Outputable LookupChild where + ppr (LookupChild { wantedParent = par + , lookupDataConFirst = dc + , prioritiseParent = prio_parent }) + = braces $ hsep + [ text "LookupChild" + , braces (text "parent:" <+> ppr par) + , if dc then text "[dc_first]" else empty + , if prio_parent then text "[prio_parent]" else empty + ] + -- | After looking up something with the given 'NameSpace', is the resulting -- 'GlobalRdrElt' we have obtained relevant, according to the 'RelevantGREs' -- specification of which 'NameSpace's are relevant? ===================================== configure.ac ===================================== @@ -68,23 +68,6 @@ FP_PROG_SORT dnl ---------------------------------------------------------- FP_SETUP_PROJECT_VERSION -dnl Don't use AC_DEFINE because it will make C-style comments invalid for -dnl Haskell. - -> rts/include/ghcversion.h - -cat rts/ghcversion.h.top >> rts/include/ghcversion.h - -echo "#define __GLASGOW_HASKELL__ ${ProjectVersionInt}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_FULL_VERSION__ \"${ProjectVersion}\"" >> rts/include/ghcversion.h -echo >> rts/include/ghcversion.h -AS_IF([test x"${ProjectPatchLevel1}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ ${ProjectPatchLevel1}" >> rts/include/ghcversion.h]) -AS_IF([test x"${ProjectPatchLevel2}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL2__ ${ProjectPatchLevel2}" >> rts/include/ghcversion.h]) - -cat rts/ghcversion.h.bottom >> rts/include/ghcversion.h - # Hmmm, we fix the RPM release number to 1 here... Is this convenient? AC_SUBST([release], [1]) @@ -105,8 +88,6 @@ AC_PREREQ([2.69]) AC_CONFIG_HEADER(mk/config.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) -dnl manually outputted above, for reasons described there. -dnl AC_CONFIG_HEADER(rts/include/ghcversion.h) # No, semi-sadly, we don't do `--srcdir'... if test x"$srcdir" != 'x.' ; then ===================================== docs/users_guide/conf.py ===================================== @@ -277,7 +277,6 @@ def setup(app): app.add_role('cabal-ref', haddock_role('Cabal')) app.add_role('ghc-compact-ref', haddock_role('ghc-compact')) app.add_role('ghc-prim-ref', haddock_role('ghc-prim')) - app.add_role('parallel-ref', haddock_role('parallel')) app.add_role('array-ref', haddock_role('array')) app.add_object_type('rts-flag', 'rts-flag', ===================================== docs/users_guide/ghc_config.py.in ===================================== @@ -23,7 +23,6 @@ lib_versions = { 'template-haskell': '@LIBRARY_template_haskell_UNIT_ID@', 'ghc-compact': '@LIBRARY_ghc_compact_UNIT_ID@', 'ghc': '@LIBRARY_ghc_UNIT_ID@', - 'parallel': '@LIBRARY_parallel_UNIT_ID@', 'Cabal': '@LIBRARY_Cabal_UNIT_ID@', 'array': '@LIBRARY_array_UNIT_ID@', } ===================================== hadrian/src/Base.hs ===================================== @@ -32,7 +32,7 @@ module Base ( hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, buildTargetFile, hostTargetFile, targetTargetFile, - ghcBinDeps, ghcLibDeps, haddockDeps, + ghcLibDeps, haddockDeps, relativePackageDbPath, packageDbPath, packageDbStamp, mingwStamp, systemCxxStdLibConf, systemCxxStdLibConfPath , PackageDbLoc(..), Inplace(..) @@ -151,17 +151,12 @@ ghcLibDeps stage iplace = do , "llvm-passes" , "ghc-interp.js" , "settings" + , "ghc-usage.txt" + , "ghci-usage.txt" ] cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace) return (cxxStdLib : ps) --- | Files the GHC binary depends on. -ghcBinDeps :: Stage -> Action [FilePath] -ghcBinDeps stage = mapM (\f -> stageLibPath stage <&> (-/- f)) - [ "ghc-usage.txt" - , "ghci-usage.txt" - ] - -- | Files the `haddock` binary depends on haddockDeps :: Stage -> Action [FilePath] haddockDeps stage = do ===================================== hadrian/src/Builder.hs ===================================== @@ -238,17 +238,12 @@ instance H.Builder Builder where -- changes (#18001). _bootGhcVersion <- setting GhcVersion pure [] - Ghc _ stage -> do + Ghc {} -> do root <- buildRoot touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit - -- GHC from the previous stage is used to build artifacts in the - -- current stage. Need the previous stage's GHC deps. - ghcdeps <- ghcBinDeps (predStage stage) - return $ [ unlitPath ] - ++ ghcdeps ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -323,6 +323,12 @@ templateRules = do templateRule "utils/ghc-pkg/ghc-pkg.cabal" $ projectVersion templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions + templateRule "rts/include/ghcversion.h" $ mconcat + [ interpolateSetting "ProjectVersionInt" ProjectVersionInt + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1 + , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2 + ] templateRule "docs/index.html" $ packageVersions templateRule "docs/users_guide/ghc_config.py" $ packageUnitIds Stage1 ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -85,8 +85,6 @@ buildProgram bin ctx@(Context{..}) rs = do need [template] -- Custom dependencies: this should be modeled better in the -- Cabal file somehow. - when (package == ghc) $ do - need =<< ghcBinDeps stage when (package == haddock) $ do -- Haddock has a resource folder need =<< haddockDeps stage ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -166,9 +166,14 @@ configureStageArgs = do let cFlags = getStagedCCFlags linkFlags = prgFlags . ccLinkProgram . tgtCCompilerLink <$> getStagedTarget mconcat [ configureArgs cFlags linkFlags - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] +ghcVersionH :: Args +ghcVersionH = notStage0 ? do + let h = "rts/include/ghcversion.h" + expr $ need [h] + arg $ "--ghc-option=-ghcversion-file=" <> h configureArgs :: Args -> Args -> Args configureArgs cFlags' ldFlags' = do @@ -199,7 +204,7 @@ configureArgs cFlags' ldFlags' = do -- ROMES:TODO: how is the Host set to TargetPlatformFull? That would be the target , conf "--host" $ arg =<< getSetting TargetPlatformFull , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] bootPackageConstraints :: Args ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -302,13 +302,11 @@ rtsPackageArgs = package rts ? do let ghcArgs = mconcat [ arg "-Irts" , arg $ "-I" ++ path - , notM targetSupportsSMP ? arg "-DNOSMP" , way `elem` [debug, debugDynamic] ? pure [ "-DTICKY_TICKY" , "-optc-DTICKY_TICKY"] , Profiling `wayUnit` way ? arg "-DPROFILING" , Threaded `wayUnit` way ? arg "-DTHREADED_RTS" - , notM targetSupportsSMP ? pure [ "-DNOSMP" - , "-optc-DNOSMP" ] + , notM targetSupportsSMP ? arg "-optc-DNOSMP" ] let cArgs = mconcat @@ -326,6 +324,8 @@ rtsPackageArgs = package rts ? do , arg "-Irts" , arg $ "-I" ++ path + , notM targetSupportsSMP ? arg "-DNOSMP" + , Debug `wayUnit` way ? pure [ "-DDEBUG" , "-fno-omit-frame-pointer" , "-g3" ===================================== rts/ghcversion.h.top deleted ===================================== @@ -1,3 +0,0 @@ -#if !defined(__GHCVERSION_H__) -#define __GHCVERSION_H__ - ===================================== rts/ghcversion.h.bottom → rts/include/ghcversion.h.in ===================================== @@ -1,3 +1,11 @@ +#if !defined(__GHCVERSION_H__) +#define __GHCVERSION_H__ + +#define __GLASGOW_HASKELL__ @ProjectVersionInt@ +#define __GLASGOW_HASKELL_FULL_VERSION__ "@ProjectVersion@" + +#define __GLASGOW_HASKELL_PATCHLEVEL1__ @ProjectPatchLevel1@ +#define __GLASGOW_HASKELL_PATCHLEVEL2__ @ProjectPatchLevel2@ #define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) ( \ ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \ ===================================== testsuite/tests/rename/should_compile/T24084.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084 where + +import T24084_B (Foo, Bar) + +data X + +instance Foo X where + type Bar X = X ===================================== testsuite/tests/rename/should_compile/T24084_A.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_A (Foo (..)) where + +class Foo a where + type Bar a ===================================== testsuite/tests/rename/should_compile/T24084_B.hs ===================================== @@ -0,0 +1,7 @@ + +{-# LANGUAGE NoImplicitPrelude #-} + +module T24084_B (module T24084_A) where + +import T24084_A + ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -216,6 +216,7 @@ test('T23510b', normal, compile, ['']) test('T23512b', normal, compile, ['']) test('T23664', normal, compile, ['']) test('T24037', normal, compile, ['']) +test('T24084', [extra_files(['T24084_A.hs', 'T24084_B.hs'])], multimod_compile, ['T24084', '-v0']) test('ExportWarnings1', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings1', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings2', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs', 'ExportWarnings_aux2.hs']), multimod_compile, ['ExportWarnings2', '-v0 -Wno-duplicate-exports -Wx-custom']) test('ExportWarnings3', extra_files(['ExportWarnings_base.hs', 'ExportWarnings_aux.hs']), multimod_compile, ['ExportWarnings3', '-v0 -Wno-duplicate-exports -Wx-custom']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91171158ecbd9429e803bb0af1760cad518f267d...7c3b966ff67071988cfcd25e5632cfe01929f6f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91171158ecbd9429e803bb0af1760cad518f267d...7c3b966ff67071988cfcd25e5632cfe01929f6f0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 17 07:59:07 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 17 Oct 2023 03:59:07 -0400 Subject: [Git][ghc/ghc][wip/T20749] 4 commits: Make DataCon workers strict in strict fields (#20749) Message-ID: <652e3ecb8434_7336f534fdd5c251973@gitlab.mail> Sebastian Graf pushed to branch wip/T20749 at Glasgow Haskell Compiler / GHC Commits: b4f3c67d by Sebastian Graf at 2023-10-17T09:55:59+02:00 Make DataCon workers strict in strict fields (#20749) This patch tweaks `exprIsConApp_maybe`, `exprIsHNF` and friends, and Demand Analysis so that they exploit and maintain strictness of DataCon workers. See `Note [Strict fields in Core]` for details. Very little needed to change, and it puts field seq insertion done by Tag Inference into a new perspective: That of *implementing* strict field semantics. Before Tag Inference, DataCon workers are strict. Afterwards they are effectively lazy and field seqs happen around use sites. History has shown that there is no other way to guarantee taggedness and thus the STG Strict Field Invariant. Knock-on changes: * `exprIsHNF` previously used `exprOkForSpeculation` on unlifted arguments instead of recursing into `exprIsHNF`. That regressed the termination analysis in CPR analysis (which simply calls out to `exprIsHNF`), so I made it call `exprOkForSpeculation`, too. * There's a small regression in Demand Analysis, visible in the changed test output of T16859: Previously, a field seq on a variable would give that variable a "used exactly once" demand, now it's "used at least once", because `dmdTransformDataConSig` accounts for future uses of the field that actually all go through the case binder (and hence won't re-enter the potential thunk). The difference should hardly be observable. * The Simplifier's fast path for data constructors only applies to lazy data constructors now. I observed regressions involving Data.Binary.Put's `Pair` data type. * Unfortunately, T21392 does no longer reproduce after this patch, so I marked it as "not broken" in order to track whether we regress again in the future. Fixes #20749, the satisfying conclusion of an annoying saga (cf. the ideas in #21497 and #22475). - - - - - caaaacfa by Jaro Reinders at 2023-10-17T09:55:59+02:00 Try fixing allocation regressions - - - - - 3ec0eb55 by Sebastian Graf at 2023-10-17T09:55:59+02:00 CorePrep: Attach evaldUnfolding to floats to detect more values - - - - - 17e3307f by Sebastian Graf at 2023-10-17T09:55:59+02:00 Arity: Attach eval'd arity type of scrutinee to case binder Just a sensible thing to do; should be a straight win. - - - - - 24 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Stg/InferTags.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Tc/TyCl/Build.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Utils/Misc.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/simplStg/should_compile/inferTags002.stderr - testsuite/tests/stranal/sigs/T16859.stderr Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -636,6 +636,8 @@ pcDataConWithFixity' declared_infix dc_name wrk_key rri -- See Note [Constructor tag allocation] and #14657 data_con = mkDataCon dc_name declared_infix prom_info (map (const no_bang) arg_tys) + (map (const HsLazy) arg_tys) + (map (const NotMarkedStrict) arg_tys) [] -- No labelled fields tyvars ex_tyvars conc_tyvars ===================================== compiler/GHC/Core.hs ===================================== @@ -42,7 +42,7 @@ module GHC.Core ( foldBindersOfBindStrict, foldBindersOfBindsStrict, collectBinders, collectTyBinders, collectTyAndValBinders, collectNBinders, collectNValBinders_maybe, - collectArgs, stripNArgs, collectArgsTicks, flattenBinds, + collectArgs, collectValArgs, stripNArgs, collectArgsTicks, flattenBinds, collectFunSimple, exprToType, @@ -1005,6 +1005,60 @@ tail position: A cast changes the type, but the type must be the same. But operationally, casts are vacuous, so this is a bit unfortunate! See #14610 for ideas how to fix this. +Note [Strict fields in Core] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Evaluating a data constructor worker evaluates its strict fields. + +In other words, if `MkT` is strict in its first field and `xs` reduces to +`error "boom"`, then `MkT xs b` will throw that error. +Conversely, it is sound to seq the field before the call to the constructor, +e.g., with `case xs of xs' { __DEFAULT -> MkT xs' b }`. +Let's call this transformation "field seq insertion". + +Note in particular that the data constructor application `MkT xs b` above is +*not* a value, unless `xs` is! + +This has pervasive effect on the Core pipeline: + + * `exprIsHNF`/`exprIsConLike`/`exprOkForSpeculation` need to assert that the + strict arguments of a DataCon worker are values/ok-for-spec themselves. + + * `exprIsConApp_maybe` inserts field seqs in the `FloatBind`s it returns, so + that the Simplifier, Constant-folding, the pattern-match checker, etc. + all see the insert field seqs when they match on strict workers. Often this + is just to emphasise strict semantics, but for case-of-known constructor + and case-to-let field insertion is *vital*, otherwise these transformations + would lose field seqs. + + * The demand signature of a data constructor is strict in strict field + position, whereas is it's normally lazy. Likewise the demand *transformer* + of a DataCon worker can add stricten up demands on strict field args. + See Note [Demand transformer for data constructors]. + + * In the absence of `-fpedantic-bottoms`, it is still possible that some seqs + are ultimately dropped or delayed due to eta-expansion. + See Note [Dealing with bottom]. + +Strict field semantics is exploited in STG by Note [Tag Inference]: +It performs field seq insertion to statically guarantee *taggedness* of strict +fields, establishing the Note [STG Strict Field Invariant]. (Happily, most +of those seqs are immediately detected as redundant by tag inference and are +omitted.) From then on, DataCon worker semantics are actually lazy, hence it is +important that STG passes maintain the Strict Field Invariant. + + +Historical Note: +The delightfully simple description of strict field semantics is the result of +a long saga (#20749, the bits about strict data constructors in #21497, #22475), +where we tried a more lenient (but actually not) semantics first that would +allow both strict and lazy implementations of DataCon workers. This was favoured +because the "pervasive effect" throughout the compiler was deemed too large +(when it really turned out to be very modest). +Alas, this semantics would require us to implement `exprIsHNF` in *exactly* the +same way as above, otherwise the analysis would not be conservative wrt. the +lenient semantics (which includes the strict one). It is also much harder to +explain and maintain, as it turned out. + ************************************************************************ * * In/Out type synonyms @@ -2091,6 +2145,17 @@ collectArgs expr go (App f a) as = go f (a:as) go e as = (e, as) +-- | Takes a nested application expression and returns the function +-- being applied and the arguments to which it is applied +collectValArgs :: Expr b -> (Expr b, [Arg b]) +collectValArgs expr + = go expr [] + where + go (App f a) as + | isValArg a = go f (a:as) + | otherwise = go f as + go e as = (e, as) + -- | Takes a nested application expression and returns the function -- being applied. Looking through casts and ticks to find it. collectFunSimple :: Expr b -> Expr b ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -49,7 +49,8 @@ module GHC.Core.DataCon ( dataConIsInfix, dataConWorkId, dataConWrapId, dataConWrapId_maybe, dataConImplicitTyThings, - dataConRepStrictness, dataConImplBangs, dataConBoxer, + dataConRepStrictness, dataConRepStrictness_maybe, + dataConImplBangs, dataConBoxer, splitDataProductType_maybe, @@ -60,7 +61,7 @@ module GHC.Core.DataCon ( isVanillaDataCon, isNewDataCon, isTypeDataCon, classDataCon, dataConCannotMatch, dataConUserTyVarsNeedWrapper, checkDataConTyVars, - isBanged, isMarkedStrict, cbvFromStrictMark, eqHsBang, isSrcStrict, isSrcUnpacked, + isBanged, isUnpacked, isMarkedStrict, cbvFromStrictMark, eqHsBang, isSrcStrict, isSrcUnpacked, specialPromotedDc, -- ** Promotion related functions @@ -97,6 +98,7 @@ import GHC.Types.Unique.FM ( UniqFM ) import GHC.Types.Unique.Set import GHC.Builtin.Uniques( mkAlphaTyVarUnique ) import GHC.Data.Graph.UnVar -- UnVarSet and operations +import GHC.Data.Maybe (orElse) import {-# SOURCE #-} GHC.Tc.Utils.TcType ( ConcreteTyVars ) @@ -524,6 +526,18 @@ data DataCon -- Matches 1-1 with dcOrigArgTys -- Hence length = dataConSourceArity dataCon + dcImplBangs :: [HsImplBang], + -- The actual decisions made (including failures) + -- about the original arguments; 1-1 with orig_arg_tys + -- See Note [Bangs on data constructor arguments] + + dcStricts :: [StrictnessMark], + -- One mark for every field of the DataCon worker; + -- if it's empty, then all fields are lazy, + -- otherwise it has the same length as dataConRepArgTys. + -- See also Note [Strict fields in Core] in GHC.Core + -- for the effect on the strictness signature + dcFields :: [FieldLabel], -- Field labels for this constructor, in the -- same order as the dcOrigArgTys; @@ -826,13 +840,6 @@ data DataConRep -- after unboxing and flattening, -- and *including* all evidence args - , dcr_stricts :: [StrictnessMark] -- 1-1 with dcr_arg_tys - -- See also Note [Data-con worker strictness] - - , dcr_bangs :: [HsImplBang] -- The actual decisions made (including failures) - -- about the original arguments; 1-1 with orig_arg_tys - -- See Note [Bangs on data constructor arguments] - } type DataConEnv a = UniqFM DataCon a -- Keyed by DataCon @@ -901,43 +908,8 @@ eqSpecPreds spec = [ mkPrimEqPred (mkTyVarTy tv) ty instance Outputable EqSpec where ppr (EqSpec tv ty) = ppr (tv, ty) -{- Note [Data-con worker strictness] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Notice that we do *not* say the worker Id is strict even if the data -constructor is declared strict - e.g. data T = MkT ![Int] Bool -Even though most often the evals are done by the *wrapper* $WMkT, there are -situations in which tag inference will re-insert evals around the worker. -So for all intents and purposes the *worker* MkT is strict, too! - -Unfortunately, if we exposed accurate strictness of DataCon workers, we'd -see the following transformation: - - f xs = case xs of xs' { __DEFAULT -> ... case MkT xs b of x { __DEFAULT -> [x] } } -- DmdAnal: Strict in xs - ==> { drop-seq, binder swap on xs' } - f xs = case MkT xs b of x { __DEFAULT -> [x] } -- DmdAnal: Still strict in xs - ==> { case-to-let } - f xs = let x = MkT xs' b in [x] -- DmdAnal: No longer strict in xs! - -I.e., we are ironically losing strictness in `xs` by dropping the eval on `xs` -and then doing case-to-let. The issue is that `exprIsHNF` currently says that -every DataCon worker app is a value. The implicit assumption is that surrounding -evals will have evaluated strict fields like `xs` before! But now that we had -just dropped the eval on `xs`, that assumption is no longer valid. - -Long story short: By keeping the demand signature lazy, the Simplifier will not -drop the eval on `xs` and using `exprIsHNF` to decide case-to-let and others -remains sound. - -Similarly, during demand analysis in dmdTransformDataConSig, we bump up the -field demand with `C_01`, *not* `C_11`, because the latter exposes too much -strictness that will drop the eval on `xs` above. - -This issue is discussed at length in -"Failed idea: no wrappers for strict data constructors" in #21497 and #22475. - -Note [Bangs on data constructor arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Bangs on data constructor arguments] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider data T = MkT !Int {-# UNPACK #-} !Int Bool @@ -963,8 +935,8 @@ Terminology: the flag settings in the importing module. Also see Note [Bangs on imported data constructors] in GHC.Types.Id.Make -* The dcr_bangs field of the dcRep field records the [HsImplBang] - If T was defined in this module, Without -O the dcr_bangs might be +* The dcImplBangs field records the [HsImplBang] + If T was defined in this module, Without -O the dcImplBangs might be [HsStrict _, HsStrict _, HsLazy] With -O it might be [HsStrict _, HsUnpack _, HsLazy] @@ -973,6 +945,17 @@ Terminology: With -XStrictData it might be [HsStrict _, HsUnpack _, HsStrict _] +* Core passes will often need to know whether the DataCon worker or wrapper in + an application is strict in some (lifted) field or not. This is tracked in the + demand signature attached to a DataCon's worker resp. wrapper Id. + + So if you've got a DataCon dc, you can get the demand signature by + `idDmdSig (dataConWorkId dc)` and make out strict args by testing with + `isStrictDmd`. Similarly, `idDmdSig <$> dataConWrapId_maybe dc` gives + you the demand signature of the wrapper, if it exists. + + These demand signatures are set in GHC.Types.Id.Make. + Note [Detecting useless UNPACK pragmas] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want to issue a warning when there's an UNPACK pragma in the source code, @@ -1008,7 +991,6 @@ we consult HsImplBang: The boolean flag is used only for this warning. See #11270 for motivation. - ************************************************************************ * * \subsection{Instances} @@ -1110,6 +1092,11 @@ isBanged (HsUnpack {}) = True isBanged (HsStrict {}) = True isBanged HsLazy = False +isUnpacked :: HsImplBang -> Bool +isUnpacked (HsUnpack {}) = True +isUnpacked (HsStrict {}) = False +isUnpacked HsLazy = False + isSrcStrict :: SrcStrictness -> Bool isSrcStrict SrcStrict = True isSrcStrict _ = False @@ -1135,13 +1122,15 @@ cbvFromStrictMark MarkedStrict = MarkedCbv -- | Build a new data constructor mkDataCon :: Name - -> Bool -- ^ Is the constructor declared infix? - -> TyConRepName -- ^ TyConRepName for the promoted TyCon - -> [HsSrcBang] -- ^ Strictness/unpack annotations, from user - -> [FieldLabel] -- ^ Field labels for the constructor, - -- if it is a record, otherwise empty - -> [TyVar] -- ^ Universals. - -> [TyCoVar] -- ^ Existentials. + -> Bool -- ^ Is the constructor declared infix? + -> TyConRepName -- ^ TyConRepName for the promoted TyCon + -> [HsSrcBang] -- ^ Strictness/unpack annotations, from user + -> [HsImplBang] -- ^ Strictness/unpack annotations, as inferred by the compiler + -> [StrictnessMark] -- ^ Strictness marks for the DataCon worker's fields in Core + -> [FieldLabel] -- ^ Field labels for the constructor, + -- if it is a record, otherwise empty + -> [TyVar] -- ^ Universals. + -> [TyCoVar] -- ^ Existentials. -> ConcreteTyVars -- ^ TyVars which must be instantiated with -- concrete types @@ -1163,7 +1152,9 @@ mkDataCon :: Name -- Can get the tag from the TyCon mkDataCon name declared_infix prom_info - arg_stricts -- Must match orig_arg_tys 1-1 + arg_stricts -- Must match orig_arg_tys 1-1 + impl_bangs -- Must match orig_arg_tys 1-1 + str_marks -- Must be empty or match dataConRepArgTys 1-1 fields univ_tvs ex_tvs conc_tvs user_tvbs eq_spec theta @@ -1180,6 +1171,8 @@ mkDataCon name declared_infix prom_info = con where is_vanilla = null ex_tvs && null eq_spec && null theta + str_marks' | not $ any isMarkedStrict str_marks = [] + | otherwise = str_marks con = MkData {dcName = name, dcUnique = nameUnique name, dcVanilla = is_vanilla, dcInfix = declared_infix, @@ -1192,7 +1185,8 @@ mkDataCon name declared_infix prom_info dcStupidTheta = stupid_theta, dcOrigArgTys = orig_arg_tys, dcOrigResTy = orig_res_ty, dcRepTyCon = rep_tycon, - dcSrcBangs = arg_stricts, + dcSrcBangs = arg_stricts, dcImplBangs = impl_bangs, + dcStricts = str_marks', dcFields = fields, dcTag = tag, dcRepType = rep_ty, dcWorkId = work_id, dcRep = rep, @@ -1436,19 +1430,27 @@ isNullaryRepDataCon :: DataCon -> Bool isNullaryRepDataCon dc = dataConRepArity dc == 0 dataConRepStrictness :: DataCon -> [StrictnessMark] --- ^ Give the demands on the arguments of a --- Core constructor application (Con dc args) -dataConRepStrictness dc = case dcRep dc of - NoDataConRep -> [NotMarkedStrict | _ <- dataConRepArgTys dc] - DCR { dcr_stricts = strs } -> strs +-- ^ Give the demands on the runtime arguments of a Core DataCon worker +-- application. +-- The length of the list matches `dataConRepArgTys` (e.g., the number +-- of runtime arguments). +dataConRepStrictness dc + = dataConRepStrictness_maybe dc + `orElse` map (const NotMarkedStrict) (dataConRepArgTys dc) + +dataConRepStrictness_maybe :: DataCon -> Maybe [StrictnessMark] +-- ^ Give the demands on the runtime arguments of a Core DataCon worker +-- application or `Nothing` if all of them are lazy. +-- The length of the list matches `dataConRepArgTys` (e.g., the number +-- of runtime arguments). +dataConRepStrictness_maybe dc + | null (dcStricts dc) = Nothing + | otherwise = Just (dcStricts dc) dataConImplBangs :: DataCon -> [HsImplBang] -- The implementation decisions about the strictness/unpack of each -- source program argument to the data constructor -dataConImplBangs dc - = case dcRep dc of - NoDataConRep -> replicate (dcSourceArity dc) HsLazy - DCR { dcr_bangs = bangs } -> bangs +dataConImplBangs dc = dcImplBangs dc dataConBoxer :: DataCon -> Maybe DataConBoxer dataConBoxer (MkData { dcRep = DCR { dcr_boxer = boxer } }) = Just boxer ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -848,6 +848,10 @@ trimArityType max_arity at@(AT lams _) | lams `lengthAtMost` max_arity = at | otherwise = AT (take max_arity lams) topDiv +evalArityType :: ArityType -> ArityType +evalArityType (AT ((IsExpensive,os):is) div) = AT ((IsCheap,os):is) div +evalArityType at = at + data ArityOpts = ArityOpts { ao_ped_bot :: !Bool -- See Note [Dealing with bottom] , ao_dicts_cheap :: !Bool -- See Note [Eta expanding through dictionaries] @@ -1473,7 +1477,7 @@ myExprIsCheap (AE { am_opts = opts, am_sigs = sigs }) e mb_ty -- See Note [Eta expanding through dictionaries] -- See Note [Eta expanding through CallStacks] - cheap_fun e = exprIsCheapX (myIsCheapApp sigs) e + cheap_fun e = exprIsCheapX (myIsCheapApp sigs) False e -- | A version of 'isCheapApp' that considers results from arity analysis. -- See Note [Arity analysis] for what's in the signature environment and why @@ -1553,7 +1557,7 @@ arityType env (Case scrut bndr _ alts) | otherwise -- In the remaining cases we may not push = addWork alts_type -- evaluation of the scrutinee in where - env' = delInScope env bndr + env' = extendSigEnv env bndr (evalArityType (arityType env scrut)) arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs alts_type = foldr1 (andArityType env) (map arity_type_alt alts) ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -47,7 +47,7 @@ import GHC.Core import GHC.Core.Make import GHC.Core.SimpleOpt ( exprIsConApp_maybe, exprIsLiteral_maybe ) import GHC.Core.DataCon ( DataCon,dataConTagZ, dataConTyCon, dataConWrapId, dataConWorkId ) -import GHC.Core.Utils ( cheapEqExpr, exprIsHNF +import GHC.Core.Utils ( cheapEqExpr, exprOkForSpeculation , stripTicksTop, stripTicksTopT, mkTicks ) import GHC.Core.Multiplicity import GHC.Core.Rules.Config @@ -2101,7 +2101,7 @@ Things to note Implementing seq#. The compiler has magic for SeqOp in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) - GHC.StgToCmm.Expr.cgExpr, and cgCase: special case for seq# @@ -2113,7 +2113,7 @@ Implementing seq#. The compiler has magic for SeqOp in seqRule :: RuleM CoreExpr seqRule = do [Type _ty_a, Type _ty_s, a, s] <- getArgs - guard $ exprIsHNF a + guard $ exprOkForSpeculation a return $ mkCoreUnboxedTuple [s, a] -- spark# :: forall a s . a -> State# s -> (# State# s, a #) ===================================== compiler/GHC/Core/Opt/CprAnal.hs ===================================== @@ -296,9 +296,16 @@ data TermFlag -- Better than using a Bool -- See Note [Nested CPR] exprTerminates :: CoreExpr -> TermFlag +-- ^ A /very/ simple termination analysis. exprTerminates e - | exprIsHNF e = Terminates -- A /very/ simple termination analysis. - | otherwise = MightDiverge + | exprIsHNF e = Terminates + | exprOkForSpeculation e = Terminates + | otherwise = MightDiverge + -- Annyingly, we have to check both for HNF and ok-for-spec. + -- * `I# (x# *# 2#)` is ok-for-spec, but not in HNF. Still worth CPR'ing! + -- * `lvl` is an HNF if its unfolding is evaluated + -- (perhaps `lvl = I# 0#` at top-level). But, tiresomely, it is never + -- ok-for-spec due to Note [exprOkForSpeculation and evaluated variables]. cprAnalApp :: AnalEnv -> CoreExpr -> [(CprType, CoreArg)] -> (CprType, CoreExpr) -- Main function that takes care of /nested/ CPR. See Note [Nested CPR] ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -824,6 +824,10 @@ to the Divergence lattice, but in practice it turned out to be hard to untaint from 'topDiv' to 'conDiv', leading to bugs, performance regressions and complexity that didn't justify the single fixed testcase T13380c. +You might think that we should check for side-effects rather than just for +precise exceptions. Right you are! See Note [Side-effects and strictness] +for why we unfortunately do not. + Note [Demand analysis for recursive data constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ T11545 features a single-product, recursive data type ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -8,14 +8,13 @@ module GHC.Core.Opt.Simplify.Env ( -- * The simplifier mode - SimplMode(..), updMode, - smPedanticBottoms, smPlatform, + SimplMode(..), updMode, smPlatform, -- * Environments SimplEnv(..), pprSimplEnv, -- Temp not abstract seArityOpts, seCaseCase, seCaseFolding, seCaseMerge, seCastSwizzle, seDoEtaReduction, seEtaExpand, seFloatEnable, seInline, seNames, - seOptCoercionOpts, sePedanticBottoms, sePhase, sePlatform, sePreInline, + seOptCoercionOpts, sePhase, sePlatform, sePreInline, seRuleOpts, seRules, seUnfoldingOpts, mkSimplEnv, extendIdSubst, extendTvSubst, extendCvSubst, @@ -235,9 +234,6 @@ seNames env = sm_names (seMode env) seOptCoercionOpts :: SimplEnv -> OptCoercionOpts seOptCoercionOpts env = sm_co_opt_opts (seMode env) -sePedanticBottoms :: SimplEnv -> Bool -sePedanticBottoms env = smPedanticBottoms (seMode env) - sePhase :: SimplEnv -> CompilerPhase sePhase env = sm_phase (seMode env) @@ -292,9 +288,6 @@ instance Outputable SimplMode where where pp_flag f s = ppUnless f (text "no") <+> s -smPedanticBottoms :: SimplMode -> Bool -smPedanticBottoms opts = ao_ped_bot (sm_arity_opts opts) - smPlatform :: SimplMode -> Platform smPlatform opts = roPlatform (sm_rule_opts opts) ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -31,7 +31,7 @@ import GHC.Core.Reduction import GHC.Core.Coercion.Opt ( optCoercion ) import GHC.Core.FamInstEnv ( FamInstEnv, topNormaliseType_maybe ) import GHC.Core.DataCon - ( DataCon, dataConWorkId, dataConRepStrictness + ( DataCon, dataConWorkId, dataConRepStrictness, dataConRepStrictness_maybe , dataConRepArgTys, isUnboxedTupleDataCon , StrictnessMark (..) ) import GHC.Core.Opt.Stats ( Tick(..) ) @@ -2165,14 +2165,14 @@ zap the SubstEnv. This is VITAL. Consider We'll clone the inner \x, adding x->x' in the id_subst Then when we inline y, we must *not* replace x by x' in the inlined copy!! -Note [Fast path for data constructors] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Fast path for lazy data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For applications of a data constructor worker, the full glory of rebuildCall is a waste of effort; * They never inline, obviously * They have no rewrite rules -* They are not strict (see Note [Data-con worker strictness] - in GHC.Core.DataCon) +* Though they might be strict (see Note [Strict fields in Core] in GHC.Core), + we will exploit that strictness through their demand signature So it's fine to zoom straight to `rebuild` which just rebuilds the call in a very straightforward way. @@ -2196,7 +2196,8 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont - | isDataConWorkId var -- See Note [Fast path for data constructors] + | Just dc <- isDataConWorkId_maybe var -- See Note [Fast path for lazy data constructors] + , Nothing <- dataConRepStrictness_maybe dc = rebuild env (Var var) cont | otherwise = case substId env var of @@ -3383,7 +3384,7 @@ a case pattern. This is *important*. Consider We really must record that b is already evaluated so that we don't go and re-evaluate it when constructing the result. -See Note [Data-con worker strictness] in GHC.Core.DataCon +See Note [Strict fields in Core] in GHC.Core. NB: simplLamBndrs preserves this eval info ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1270,11 +1270,8 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr -- simplifier produces rhs[exp/a], changing semantics if exp is not ok-for-spec -- Good: returning (Mk#, [x]) with a float of case exp of x { DEFAULT -> [] } -- simplifier produces case exp of a { DEFAULT -> exp[x/a] } - = let arg' = subst_expr subst arg - bndr = uniqAway (subst_in_scope subst) (mkWildValBinder ManyTy arg_type) - float = FloatCase arg' bndr DEFAULT [] - subst' = subst_extend_in_scope subst bndr - in go subst' (float:floats) fun (CC (Var bndr : args) co) + , (subst', float, bndr) <- case_bind subst arg arg_type + = go subst' (float:floats) fun (CC (Var bndr : args) co) | otherwise = go subst floats fun (CC (subst_expr subst arg : args) co) @@ -1317,8 +1314,9 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr | Just con <- isDataConWorkId_maybe fun , count isValArg args == idArity fun - = succeedWith in_scope floats $ - pushCoDataCon con args co + , (in_scope', seq_floats, args') <- mkFieldSeqFloats in_scope con args + = succeedWith in_scope' (seq_floats ++ floats) $ + pushCoDataCon con args' co -- Look through data constructor wrappers: they inline late (See Note -- [Activation for data constructor wrappers]) but we want to do @@ -1404,6 +1402,36 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr extend (Left in_scope) v e = Right (extendSubst (mkEmptySubst in_scope) v e) extend (Right s) v e = Right (extendSubst s v e) + case_bind :: Either InScopeSet Subst -> CoreExpr -> Type -> (Either InScopeSet Subst, FloatBind, Id) + case_bind subst expr expr_ty = (subst', float, bndr) + where + bndr = setCaseBndrEvald MarkedStrict $ + uniqAway (subst_in_scope subst) $ + mkWildValBinder ManyTy expr_ty + subst' = subst_extend_in_scope subst bndr + expr' = subst_expr subst expr + float = FloatCase expr' bndr DEFAULT [] + + mkFieldSeqFloats :: InScopeSet -> DataCon -> [CoreExpr] -> (InScopeSet, [FloatBind], [CoreExpr]) + mkFieldSeqFloats in_scope dc args + | Nothing <- dataConRepStrictness_maybe dc + = (in_scope, [], args) + | otherwise + = (in_scope', floats', ty_args ++ val_args') + where + (ty_args, val_args) = splitAtList (dataConUnivAndExTyCoVars dc) args + (in_scope', floats', val_args') = foldr do_one (in_scope, [], []) $ zipEqual "mkFieldSeqFloats" str_marks val_args + str_marks = dataConRepStrictness dc + do_one (str, arg) (in_scope,floats,args) + | NotMarkedStrict <- str = no_seq + | exprIsHNF arg = no_seq + | otherwise = (in_scope', float:floats, Var bndr:args) + where + no_seq = (in_scope, floats, arg:args) + (in_scope', float, bndr) = + case case_bind (Left in_scope) arg (exprType arg) of + (Left in_scope', float, bndr) -> (in_scope', float, bndr) + (right, _, _) -> pprPanic "case_bind did not preserve Left" (ppr in_scope $$ ppr arg $$ ppr right) -- See Note [exprIsConApp_maybe on literal strings] dealWithStringLiteral :: Var -> BS.ByteString -> Coercion ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -55,7 +55,7 @@ module GHC.Core.Type ( splitForAllForAllTyBinders, splitForAllForAllTyBinder_maybe, splitForAllTyCoVar_maybe, splitForAllTyCoVar, splitForAllTyVar_maybe, splitForAllCoVar_maybe, - splitPiTy_maybe, splitPiTy, splitPiTys, + splitPiTy_maybe, splitPiTy, splitPiTys, collectPiTyBinders, getRuntimeArgTys, mkTyConBindersPreferAnon, mkPiTy, mkPiTys, @@ -292,6 +292,7 @@ import GHC.Data.FastString import Control.Monad ( guard ) import GHC.Data.Maybe ( orElse, isJust ) +import GHC.List (build) -- $type_classification -- #type_classification# @@ -2004,6 +2005,18 @@ splitPiTys ty = split ty ty [] split orig_ty ty bs | Just ty' <- coreView ty = split orig_ty ty' bs split orig_ty _ bs = (reverse bs, orig_ty) +collectPiTyBinders :: Type -> [PiTyBinder] +collectPiTyBinders ty = build $ \c n -> + let + split (ForAllTy b res) = Named b `c` split res + split (FunTy { ft_af = af, ft_mult = w, ft_arg = arg, ft_res = res }) + = Anon (Scaled w arg) af `c` split res + split ty | Just ty' <- coreView ty = split ty' + split _ = n + in + split ty +{-# INLINE collectPiTyBinders #-} + -- | Extracts a list of run-time arguments from a function type, -- looking through newtypes to the right of arrows. -- ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -1256,18 +1256,23 @@ in this (which it previously was): in \w. v True -} --------------------- -exprIsWorkFree :: CoreExpr -> Bool -- See Note [exprIsWorkFree] -exprIsWorkFree e = exprIsCheapX isWorkFreeApp e - -exprIsCheap :: CoreExpr -> Bool -exprIsCheap e = exprIsCheapX isCheapApp e +------------------------------------- +type CheapAppFun = Id -> Arity -> Bool + -- Is an application of this function to n *value* args + -- always cheap, assuming the arguments are cheap? + -- True mainly of data constructors, partial applications; + -- but with minor variations: + -- isWorkFreeApp + -- isCheapApp + -- isExpandableApp -exprIsCheapX :: CheapAppFun -> CoreExpr -> Bool +exprIsCheapX :: CheapAppFun -> Bool -> CoreExpr -> Bool {-# INLINE exprIsCheapX #-} --- allow specialization of exprIsCheap and exprIsWorkFree +-- allow specialization of exprIsCheap, exprIsWorkFree and exprIsExpandable -- instead of having an unknown call to ok_app -exprIsCheapX ok_app e +-- expandable: Only True for exprIsExpandable, where Case and Let are never +-- expandable. +exprIsCheapX ok_app expandable e = ok e where ok e = go 0 e @@ -1291,90 +1296,26 @@ exprIsCheapX ok_app e | otherwise = go n e go n (App f e) | isRuntimeArg e = go (n+1) f && ok e | otherwise = go n f - go n (Let (NonRec _ r) e) = go n e && ok r - go n (Let (Rec prs) e) = go n e && all (ok . snd) prs + go n (Let (NonRec _ r) e) = not expandable && go n e && ok r + go n (Let (Rec prs) e) = not expandable && go n e && all (ok . snd) prs -- Case: see Note [Case expressions are work-free] -- App, Let: see Note [Arguments and let-bindings exprIsCheapX] +-------------------- +exprIsWorkFree :: CoreExpr -> Bool +-- See Note [exprIsWorkFree] +exprIsWorkFree e = exprIsCheapX isWorkFreeApp False e -{- Note [exprIsExpandable] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -An expression is "expandable" if we are willing to duplicate it, if doing -so might make a RULE or case-of-constructor fire. Consider - let x = (a,b) - y = build g - in ....(case x of (p,q) -> rhs)....(foldr k z y).... - -We don't inline 'x' or 'y' (see Note [Lone variables] in GHC.Core.Unfold), -but we do want - - * the case-expression to simplify - (via exprIsConApp_maybe, exprIsLiteral_maybe) - - * the foldr/build RULE to fire - (by expanding the unfolding during rule matching) - -So we classify the unfolding of a let-binding as "expandable" (via the -uf_expandable field) if we want to do this kind of on-the-fly -expansion. Specifically: - -* True of constructor applications (K a b) - -* True of applications of a "CONLIKE" Id; see Note [CONLIKE pragma] in GHC.Types.Basic. - (NB: exprIsCheap might not be true of this) - -* False of case-expressions. If we have - let x = case ... in ...(case x of ...)... - we won't simplify. We have to inline x. See #14688. - -* False of let-expressions (same reason); and in any case we - float lets out of an RHS if doing so will reveal an expandable - application (see SimplEnv.doFloatFromRhs). - -* Take care: exprIsExpandable should /not/ be true of primops. I - found this in test T5623a: - let q = /\a. Ptr a (a +# b) - in case q @ Float of Ptr v -> ...q... - - q's inlining should not be expandable, else exprIsConApp_maybe will - say that (q @ Float) expands to (Ptr a (a +# b)), and that will - duplicate the (a +# b) primop, which we should not do lightly. - (It's quite hard to trigger this bug, but T13155 does so for GHC 8.0.) --} +-------------------- +exprIsCheap :: CoreExpr -> Bool +-- See Note [exprIsCheap] +exprIsCheap e = exprIsCheapX isCheapApp False e -------------------------------------- +-------------------- exprIsExpandable :: CoreExpr -> Bool -- See Note [exprIsExpandable] -exprIsExpandable e - = ok e - where - ok e = go 0 e - - -- n is the number of value arguments - go n (Var v) = isExpandableApp v n - go _ (Lit {}) = True - go _ (Type {}) = True - go _ (Coercion {}) = True - go n (Cast e _) = go n e - go n (Tick t e) | tickishCounts t = False - | otherwise = go n e - go n (Lam x e) | isRuntimeVar x = n==0 || go (n-1) e - | otherwise = go n e - go n (App f e) | isRuntimeArg e = go (n+1) f && ok e - | otherwise = go n f - go _ (Case {}) = False - go _ (Let {}) = False - - -------------------------------------- -type CheapAppFun = Id -> Arity -> Bool - -- Is an application of this function to n *value* args - -- always cheap, assuming the arguments are cheap? - -- True mainly of data constructors, partial applications; - -- but with minor variations: - -- isWorkFreeApp - -- isCheapApp +exprIsExpandable e = exprIsCheapX isExpandableApp True e isWorkFreeApp :: CheapAppFun isWorkFreeApp fn n_val_args @@ -1394,7 +1335,7 @@ isCheapApp fn n_val_args | isDeadEndId fn = True -- See Note [isCheapApp: bottoming functions] | otherwise = case idDetails fn of - DataConWorkId {} -> True -- Actually handled by isWorkFreeApp + -- DataConWorkId {} -> _ -- Handled by isWorkFreeApp RecSelId {} -> n_val_args == 1 -- See Note [Record selection] ClassOpId {} -> n_val_args == 1 PrimOpId op _ -> primOpIsCheap op @@ -1409,6 +1350,7 @@ isExpandableApp fn n_val_args | isWorkFreeApp fn n_val_args = True | otherwise = case idDetails fn of + -- DataConWorkId {} -> _ -- Handled by isWorkFreeApp RecSelId {} -> n_val_args == 1 -- See Note [Record selection] ClassOpId {} -> n_val_args == 1 PrimOpId {} -> False @@ -1440,6 +1382,50 @@ isExpandableApp fn n_val_args I'm not sure why we have a special case for bottoming functions in isCheapApp. Maybe we don't need it. +Note [exprIsExpandable] +~~~~~~~~~~~~~~~~~~~~~~~ +An expression is "expandable" if we are willing to duplicate it, if doing +so might make a RULE or case-of-constructor fire. Consider + let x = (a,b) + y = build g + in ....(case x of (p,q) -> rhs)....(foldr k z y).... + +We don't inline 'x' or 'y' (see Note [Lone variables] in GHC.Core.Unfold), +but we do want + + * the case-expression to simplify + (via exprIsConApp_maybe, exprIsLiteral_maybe) + + * the foldr/build RULE to fire + (by expanding the unfolding during rule matching) + +So we classify the unfolding of a let-binding as "expandable" (via the +uf_expandable field) if we want to do this kind of on-the-fly +expansion. Specifically: + +* True of constructor applications (K a b) + +* True of applications of a "CONLIKE" Id; see Note [CONLIKE pragma] in GHC.Types.Basic. + (NB: exprIsCheap might not be true of this) + +* False of case-expressions. If we have + let x = case ... in ...(case x of ...)... + we won't simplify. We have to inline x. See #14688. + +* False of let-expressions (same reason); and in any case we + float lets out of an RHS if doing so will reveal an expandable + application (see SimplEnv.doFloatFromRhs). + +* Take care: exprIsExpandable should /not/ be true of primops. I + found this in test T5623a: + let q = /\a. Ptr a (a +# b) + in case q @ Float of Ptr v -> ...q... + + q's inlining should not be expandable, else exprIsConApp_maybe will + say that (q @ Float) expands to (Ptr a (a +# b)), and that will + duplicate the (a +# b) primop, which we should not do lightly. + (It's quite hard to trigger this bug, but T13155 does so for GHC 8.0.) + Note [isExpandableApp: bottoming functions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's important that isExpandableApp does not respond True to bottoming @@ -1620,7 +1606,7 @@ expr_ok fun_ok primop_ok other_expr _ -> False ----------------------------- -app_ok :: (Id -> Bool) -> (PrimOp -> Bool) -> Id -> [CoreExpr] -> Bool +app_ok :: (Id -> Bool) -> (PrimOp -> Bool) -> Id -> [CoreArg] -> Bool app_ok fun_ok primop_ok fun args | not (fun_ok fun) = False -- This code path is only taken for Note [Speculative evaluation] @@ -1635,13 +1621,11 @@ app_ok fun_ok primop_ok fun args -- DFuns terminate, unless the dict is implemented -- with a newtype in which case they may not - DataConWorkId {} -> args_ok - -- The strictness of the constructor has already - -- been expressed by its "wrapper", so we don't need - -- to take the arguments into account - -- Well, we thought so. But it's definitely wrong! - -- See #20749 and Note [How untagged pointers can - -- end up in strict fields] in GHC.Stg.InferTags + DataConWorkId dc + | Just str_marks <- dataConRepStrictness_maybe dc + -> fields_ok str_marks + | otherwise + -> args_ok ClassOpId _ is_terminating_result | is_terminating_result -- See Note [exprOkForSpeculation and type classes] @@ -1691,7 +1675,7 @@ app_ok fun_ok primop_ok fun args -- Even if a function call itself is OK, any unlifted -- args are still evaluated eagerly and must be checked - args_ok = and (zipWith arg_ok arg_tys args) + args_ok = all2Prefix arg_ok arg_tys args arg_ok :: PiTyVarBinder -> CoreExpr -> Bool arg_ok (Named _) _ = True -- A type argument arg_ok (Anon ty _) arg -- A term argument @@ -1700,6 +1684,17 @@ app_ok fun_ok primop_ok fun args | otherwise = expr_ok fun_ok primop_ok arg + -- Used for DataCon worker arguments + fields_ok str_marks = all3Prefix field_ok str_marks arg_tys args + field_ok :: StrictnessMark -> PiTyVarBinder -> CoreExpr -> Bool + field_ok _ (Named _) _ = True + field_ok str (Anon ty _) arg + | NotMarkedStrict <- str -- iff it's a lazy field + , definitelyLiftedType (scaledThing ty) -- and its type is lifted + = True -- then the worker app does not eval + | otherwise + = expr_ok fun_ok primop_ok arg + ----------------------------- altsAreExhaustive :: [Alt b] -> Bool -- True <=> the case alternatives are definitely exhaustive @@ -1925,12 +1920,14 @@ exprIsConLike = exprIsHNFlike isConLikeId isConLikeUnfolding -- or PAPs. -- exprIsHNFlike :: HasDebugCallStack => (Var -> Bool) -> (Unfolding -> Bool) -> CoreExpr -> Bool -exprIsHNFlike is_con is_con_unf = is_hnf_like +exprIsHNFlike is_con is_con_unf e + = -- pprTraceWith "hnf" (\r -> ppr r <+> ppr e) $ + is_hnf_like e where is_hnf_like (Var v) -- NB: There are no value args at this point - = id_app_is_value v 0 -- Catches nullary constructors, - -- so that [] and () are values, for example - -- and (e.g.) primops that don't have unfoldings + = id_app_is_value v [] -- Catches nullary constructors, + -- so that [] and () are values, for example + -- and (e.g.) primops that don't have unfoldings || is_con_unf (idUnfolding v) -- Check the thing's unfolding; it might be bound to a value -- or to a guaranteed-evaluated variable (isEvaldUnfolding) @@ -1954,7 +1951,7 @@ exprIsHNFlike is_con is_con_unf = is_hnf_like -- See Note [exprIsHNF Tick] is_hnf_like (Cast e _) = is_hnf_like e is_hnf_like (App e a) - | isValArg a = app_is_value e 1 + | isValArg a = app_is_value e [a] | otherwise = is_hnf_like e is_hnf_like (Let _ e) = is_hnf_like e -- Lazy let(rec)s don't affect us is_hnf_like (Case e b _ as) @@ -1962,26 +1959,53 @@ exprIsHNFlike is_con is_con_unf = is_hnf_like = is_hnf_like rhs is_hnf_like _ = False - -- 'n' is the number of value args to which the expression is applied - -- And n>0: there is at least one value argument - app_is_value :: CoreExpr -> Int -> Bool - app_is_value (Var f) nva = id_app_is_value f nva - app_is_value (Tick _ f) nva = app_is_value f nva - app_is_value (Cast f _) nva = app_is_value f nva - app_is_value (App f a) nva - | isValArg a = - app_is_value f (nva + 1) && - not (needsCaseBinding (exprType a) a) - -- For example f (x /# y) where f has arity two, and the first - -- argument is unboxed. This is not a value! - -- But f 34# is a value. - -- NB: Check app_is_value first, the arity check is cheaper - | otherwise = app_is_value f nva - app_is_value _ _ = False - - id_app_is_value id n_val_args - = is_con id - || idArity id > n_val_args + -- Collect arguments through Casts and Ticks and call id_app_is_value + app_is_value :: CoreExpr -> [CoreArg] -> Bool + app_is_value (Var f) as = id_app_is_value f as + app_is_value (Tick _ f) as = app_is_value f as + app_is_value (Cast f _) as = app_is_value f as + app_is_value (App f a) as | isValArg a = app_is_value f (a:as) + | otherwise = app_is_value f as + app_is_value _ _ = False + + id_app_is_value id val_args + -- First handle saturated applications of DataCons with strict fields + | Just dc <- isDataConWorkId_maybe id -- DataCon + , Just str_marks <- dataConRepStrictness_maybe dc -- with strict fields + , assert (val_args `leLength` str_marks) True + , val_args `equalLength` str_marks -- in a saturated app + = all3Prefix check_field str_marks (mapMaybe anonPiTyBinderType_maybe (collectPiTyBinders (idType id))) val_args + + -- Now all applications except saturated DataCon apps with strict fields + | idArity id > length val_args + -- PAP: Check unlifted val_args + || is_con id && isNothing (isDataConWorkId_maybe id >>= dataConRepStrictness_maybe) + -- Either a lazy DataCon or a CONLIKE. + -- Hence we only need to check unlifted val_args here. + -- NB: We assume that CONLIKEs are lazy, which is their entire + -- point. + = all2Prefix check_arg (mapMaybe anonPiTyBinderType_maybe (collectPiTyBinders (idType id))) val_args + + | otherwise + = False + where + -- fun_ty = idType id + -- arg_tys = collectPiTyBinders fun_ty + -- val_arg_tys = mapMaybe anonPiTyBinderType_maybe arg_tys + -- val_arg_tys = map exprType val_args, but much less costly. + -- The obvious definition regresses T16577 by 30% so we don't do it. + + check_arg a_ty a = mightBeUnliftedType a_ty ==> is_hnf_like a + -- Check unliftedness; for example f (x /# 12#) where f has arity two, + -- and the first argument is unboxed. This is not a value! + -- But f 34# is a value, so check args for HNFs. + -- NB: We check arity (and CONLIKEness) first because it's cheaper + -- and we reject quickly on saturated apps. + check_field str a_ty a + = isMarkedStrict str || mightBeUnliftedType a_ty ==> is_hnf_like a + a ==> b = not a || b + infixr 1 ==> +{-# INLINE exprIsHNFlike #-} {- Note [exprIsHNF Tick] @@ -2543,7 +2567,7 @@ This means the seqs on x and y both become no-ops and compared to the first vers The downside is that the caller of $wfoo potentially has to evaluate `y` once if we can't prove it isn't already evaluated. But y coming out of a strict field is in WHNF so safe to evaluated. And most of the time it will be properly tagged+evaluated -already at the call site because of the Strict Field Invariant! See Note [Strict Field Invariant] for more in this. +already at the call site because of the Strict Field Invariant! See Note [STG Strict Field Invariant] for more in this. This makes GHC itself around 1% faster despite doing slightly more work! So this is generally quite good. We only apply this when we think there is a benefit in doing so however. There are a number of cases in which ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -677,9 +677,11 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 + ; let float@(Float (NonRec v' _) _ _) = + mkFloat env topDmd False v rhs2 + -- v' has demand info and possibly evaldUnfolding ; return ( snocFloat floats2 float - , cpeEtaExpand arity (Var v)) }) + , cpeEtaExpand arity (Var v')) }) -- Wrap floating ticks ; let (floats4, rhs4) = wrapTicks floats3 rhs3 @@ -1503,8 +1505,10 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (snocFloat floats2 arg_float, varToCoreExpr v) } + arg_float@(Float (NonRec v' _) _ _) = + mkFloat env dmd is_unlifted v arg3 + -- v' has demand info and possibly evaldUnfolding + ; return (snocFloat floats2 arg_float, varToCoreExpr v') } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1937,12 +1941,11 @@ instance Outputable Floats where mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ - Float (NonRec bndr' rhs) bound info + Float (NonRec bndr2 rhs) bound info where - bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] (bound,info) - | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) - -- is_lifted: We currently don't allow unlifted values at the + | is_hnf, is_boxed = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unboxed values at the -- top-level or inside letrecs -- (but SG thinks that in principle, we should) | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) @@ -1961,11 +1964,21 @@ mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ -- And these float freely but can't be speculated, hence LetBound is_lifted = not is_unlifted + is_boxed = isBoxedType (idType bndr) is_hnf = exprIsHNF rhs is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + bndr1 = bndr `setIdDemandInfo` dmd -- See Note [Pin demand info on floats] + bndr2 + | is_hnf + -- Otherwise, exprIsHNF must be conservative when bndr occurs as a strict + -- field arg. Result: More allocation in $walexGetByte. + = bndr1 `setIdUnfolding` evaldUnfolding + | otherwise + = bndr1 + emptyFloats :: Floats emptyFloats = Floats nilOL nilOL nilOL ===================================== compiler/GHC/Stg/InferTags.hs ===================================== @@ -64,8 +64,8 @@ With nofib being ~0.3% faster as well. See Note [Tag inference passes] for how we proceed to generate and use this information. -Note [Strict Field Invariant] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [STG Strict Field Invariant] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As part of tag inference we introduce the Strict Field Invariant. Which consists of us saying that: @@ -124,15 +124,33 @@ Note that there are similar constraints around Note [CBV Function Ids]. Note [How untagged pointers can end up in strict fields] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Since the resolution of #20749 where Core passes assume that DataCon workers +evaluate their strict fields, it is pretty simple to see how the Simplifier +might exploit that knowledge to drop evals. Example: + + data MkT a = MkT !a + f :: [Int] -> T [Int] + f xs = xs `seq` MkT xs + +in Core we will have + + f = \xs -> MkT @[Int] xs + +No eval left there. + Consider data Set a = Tip | Bin !a (Set a) (Set a) We make a wrapper for Bin that evaluates its arguments $WBin x a b = case x of xv -> Bin xv a b Here `xv` will always be evaluated and properly tagged, just as the -Strict Field Invariant requires. +Note [STG Strict Field Invariant] requires. + +But alas, the Simplifier can destroy the invariant: see #15696. +Indeed, as Note [Strict fields in Core] explains, Core passes +assume that Data constructor workers evaluate their strict fields, +so the Simplifier will drop seqs freely. -But alas the Simplifier can destroy the invariant: see #15696. We start with thk = f () g x = ...(case thk of xv -> Bin xv Tip Tip)... @@ -153,7 +171,7 @@ Now you can see that the argument of Bin, namely thk, points to the thunk, not to the value as it did before. In short, although it may be rare, the output of optimisation passes -cannot guarantee to obey the Strict Field Invariant. For this reason +cannot guarantee to obey the Note [STG Strict Field Invariant]. For this reason we run tag inference. See Note [Tag inference passes]. Note [Tag inference passes] @@ -163,7 +181,7 @@ Tag inference proceeds in two passes: The result is then attached to /binders/. This is implemented by `inferTagsAnal` in GHC.Stg.InferTags * The second pass walks over the AST checking if the Strict Field Invariant is upheld. - See Note [Strict Field Invariant]. + See Note [STG Strict Field Invariant]. If required this pass modifies the program to uphold this invariant. Tag information is also moved from /binders/ to /occurrences/ during this pass. This is done by `GHC.Stg.InferTags.Rewrite (rewriteTopBinds)`. ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -65,7 +65,7 @@ The work of this pass is simple: * For any strict field we check if the argument is known to be properly tagged. * If it's not known to be properly tagged, we wrap the whole thing in a case, which will force the argument before allocation. -This is described in detail in Note [Strict Field Invariant]. +This is described in detail in Note [STG Strict Field Invariant]. The only slight complication is that we have to make sure not to invalidate free variable analysis in the process. @@ -218,7 +218,7 @@ When compiling bytecode we call myCoreToStg to get STG code first. myCoreToStg in turn calls out to stg2stg which runs the STG to STG passes followed by free variables analysis and the tag inference pass including it's rewriting phase at the end. -Running tag inference is important as it upholds Note [Strict Field Invariant]. +Running tag inference is important as it upholds Note [STG Strict Field Invariant]. While code executed by GHCi doesn't take advantage of the SFI it can call into compiled code which does. So it must still make sure that the SFI is upheld. See also #21083 and #22042. ===================================== compiler/GHC/Tc/TyCl/Build.hs ===================================== @@ -183,14 +183,15 @@ buildDataCon fam_envs dc_bang_opts src_name declared_infix prom_info src_bangs tag = lookupNameEnv_NF tag_map src_name -- See Note [Constructor tag allocation], fixes #14657 data_con = mkDataCon src_name declared_infix prom_info - src_bangs field_lbls + src_bangs impl_bangs str_marks field_lbls univ_tvs ex_tvs noConcreteTyVars user_tvbs eq_spec ctxt arg_tys res_ty NoPromInfo rep_tycon tag stupid_ctxt dc_wrk dc_rep dc_wrk = mkDataConWorkId work_name data_con - dc_rep = initUs_ us (mkDataConRep dc_bang_opts fam_envs wrap_name data_con) + (dc_rep, impl_bangs, str_marks) = + initUs_ us (mkDataConRep dc_bang_opts fam_envs wrap_name data_con) ; traceIf (text "buildDataCon 2" <+> ppr src_name) ; return data_con } ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -1385,33 +1385,8 @@ arguments. That is the job of dmdTransformDataConSig. More precisely, * it returns the demands on the arguments; in the above example that is [SL, A] -Nasty wrinkle. Consider this code (#22475 has more realistic examples but -assume this is what the demand analyser sees) - - data T = MkT !Int Bool - get :: T -> Bool - get (MkT _ b) = b - - foo = let v::Int = I# 7 - t::T = MkT v True - in get t - -Now `v` is unused by `get`, /but/ we can't give `v` an Absent demand, -else we'll drop the binding and replace it with an error thunk. -Then the code generator (more specifically GHC.Stg.InferTags.Rewrite) -will add an extra eval of MkT's argument to give - foo = let v::Int = error "absent" - t::T = case v of v' -> MkT v' True - in get t - -Boo! Because of this extra eval (added in STG-land), the truth is that `MkT` -may (or may not) evaluate its arguments (as established in #21497). Hence the -use of `bump` in dmdTransformDataConSig, which adds in a `C_01` eval. The -`C_01` says "may or may not evaluate" which is absolutely faithful to what -InferTags.Rewrite does. - -In particular it is very important /not/ to make that a `C_11` eval, -see Note [Data-con worker strictness]. +When the data constructor worker has strict fields, they act as additional +seqs; hence we add an additional `C_11` eval. -} {- ********************************************************************* @@ -1611,6 +1586,29 @@ a bad fit because expression may not throw a precise exception (increasing precision of the analysis), but that's just a favourable guess. +Note [Side-effects and strictness] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Due to historic reasons and the continued effort not to cause performance +regressions downstream, Strictness Analysis is currently prone to discarding +observable side-effects (other than precise exceptions, see +Note [Precise exceptions and strictness analysis]) in some cases. For example, + f :: MVar () -> Int -> IO Int + f mv x = putMVar mv () >> (x `seq` return x) +The call to `putMVar` is an observable side-effect. Yet, Strictness Analysis +currently concludes that `f` is strict in `x` and uses call-by-value. +That means `f mv (error "boom")` will error out with the imprecise exception +rather performing the side-effect. + +This is a conscious violation of the semantics described in the paper +"a semantics for imprecise exceptions"; so it would be great if we could +identify the offending primops and extend the idea in +Note [Which scrutinees may throw precise exceptions] to general side-effects. + +Unfortunately, the existing has-side-effects classification for primops is +too conservative, listing `writeMutVar#` and even `readMutVar#` as +side-effecting. That is due to #3207. A possible way forward is described in +#17900, but no effort has been so far towards a resolution. + Note [Exceptions and strictness] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to smart about catching exceptions, but we aren't anymore. @@ -2327,7 +2325,7 @@ dmdTransformDataConSig str_marks sd = case viewProd arity body_sd of mk_body_ty n dmds = DmdType nopDmdEnv (zipWith (bump n) str_marks dmds) bump n str dmd | isMarkedStrict str = multDmd n (plusDmd str_field_dmd dmd) | otherwise = multDmd n dmd - str_field_dmd = C_01 :* seqSubDmd -- Why not C_11? See Note [Data-con worker strictness] + str_field_dmd = C_11 :* seqSubDmd -- See Note [Strict fields in Core] -- | A special 'DmdTransformer' for dictionary selectors that feeds the demand -- on the result into the indicated dictionary component (if saturated). ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -260,7 +260,7 @@ The invariants around the arguments of call by value function like Ids are then: * Any `WorkerLikeId` * Some `JoinId` bindings. -This works analogous to the Strict Field Invariant. See also Note [Strict Field Invariant]. +This works analogous to the Strict Field Invariant. See also Note [STG Strict Field Invariant]. To make this work what we do is: * During W/W and SpecConstr any worker/specialized binding we introduce ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Core.Coercion import GHC.Core.Reduction import GHC.Core.Make import GHC.Core.FVs ( mkRuleInfo ) -import GHC.Core.Utils ( exprType, mkCast, mkDefaultCase, coreAltsType ) +import GHC.Core.Utils ( exprType, mkCast, coreAltsType ) import GHC.Core.Unfold.Make import GHC.Core.SimpleOpt import GHC.Core.TyCon @@ -594,8 +594,12 @@ mkDataConWorkId wkr_name data_con = mkGlobalId (DataConWorkId data_con) wkr_name wkr_ty alg_wkr_info where - tycon = dataConTyCon data_con -- The representation TyCon - wkr_ty = dataConRepType data_con + tycon = dataConTyCon data_con -- The representation TyCon + wkr_ty = dataConRepType data_con + univ_tvs = dataConUnivTyVars data_con + ex_tcvs = dataConExTyCoVars data_con + arg_tys = dataConRepArgTys data_con -- Should be same as dataConOrigArgTys + str_marks = dataConRepStrictness data_con ----------- Workers for data types -------------- alg_wkr_info = noCafIdInfo @@ -603,12 +607,19 @@ mkDataConWorkId wkr_name data_con `setInlinePragInfo` wkr_inline_prag `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated, -- even if arity = 0 + `setDmdSigInfo` wkr_sig + -- Workers eval their strict fields + -- See Note [Strict fields in Core] `setLFInfo` wkr_lf_info - -- No strictness: see Note [Data-con worker strictness] in GHC.Core.DataCon wkr_inline_prag = defaultInlinePragma { inl_rule = ConLike } wkr_arity = dataConRepArity data_con + wkr_sig = mkClosedDmdSig wkr_dmds topDiv + wkr_dmds = map mk_dmd str_marks + mk_dmd MarkedStrict = evalDmd + mk_dmd NotMarkedStrict = topDmd + -- See Note [LFInfo of DataCon workers and wrappers] wkr_lf_info | wkr_arity == 0 = LFCon data_con @@ -616,9 +627,6 @@ mkDataConWorkId wkr_name data_con -- LFInfo stores post-unarisation arity ----------- Workers for newtypes -------------- - univ_tvs = dataConUnivTyVars data_con - ex_tcvs = dataConExTyCoVars data_con - arg_tys = dataConRepArgTys data_con -- Should be same as dataConOrigArgTys nt_work_info = noCafIdInfo -- The NoCaf-ness is set by noCafIdInfo `setArityInfo` 1 -- Arity 1 `setInlinePragInfo` dataConWrapperInlinePragma @@ -786,10 +794,10 @@ mkDataConRep :: DataConBangOpts -> FamInstEnvs -> Name -> DataCon - -> UniqSM DataConRep + -> UniqSM (DataConRep, [HsImplBang], [StrictnessMark]) mkDataConRep dc_bang_opts fam_envs wrap_name data_con | not wrapper_reqd - = return NoDataConRep + = return (NoDataConRep, arg_ibangs, rep_strs) | otherwise = do { wrap_args <- mapM (newLocal (fsLit "conrep")) wrap_arg_tys @@ -853,11 +861,8 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con ; return (DCR { dcr_wrap_id = wrap_id , dcr_boxer = mk_boxer boxers - , dcr_arg_tys = rep_tys - , dcr_stricts = rep_strs - -- For newtypes, dcr_bangs is always [HsLazy]. - -- See Note [HsImplBangs for newtypes]. - , dcr_bangs = arg_ibangs }) } + , dcr_arg_tys = rep_tys } + , arg_ibangs, rep_strs) } where (univ_tvs, ex_tvs, eq_spec, theta, orig_arg_tys, _orig_res_ty) @@ -907,8 +912,8 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con -- (Most) newtypes have only a worker, with the exception -- of some newtypes written with GADT syntax. -- See dataConUserTyVarsNeedWrapper below. - && (any isBanged (ev_ibangs ++ arg_ibangs))) - -- Some forcing/unboxing (includes eq_spec) + && (any isUnpacked (ev_ibangs ++ arg_ibangs))) + -- Some unboxing (includes eq_spec) || isFamInstTyCon tycon -- Cast result || (dataConUserTyVarsNeedWrapper data_con -- If the data type was written with GADT syntax and @@ -1185,7 +1190,7 @@ dataConArgRep arg_ty HsLazy = ([(arg_ty, NotMarkedStrict)], (unitUnboxer, unitBoxer)) dataConArgRep arg_ty (HsStrict _) - = ([(arg_ty, MarkedStrict)], (seqUnboxer, unitBoxer)) + = ([(arg_ty, MarkedStrict)], (unitUnboxer, unitBoxer)) -- Seqs are inserted in STG dataConArgRep arg_ty (HsUnpack Nothing) = dataConArgUnpack arg_ty @@ -1215,9 +1220,6 @@ wrapCo co rep_ty (unbox_rep, box_rep) -- co :: arg_ty ~ rep_ty ; return (rep_ids, rep_expr `Cast` mkSymCo sco) } ------------------------ -seqUnboxer :: Unboxer -seqUnboxer v = return ([v], mkDefaultCase (Var v) v) - unitUnboxer :: Unboxer unitUnboxer v = return ([v], \e -> e) ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -27,7 +27,7 @@ module GHC.Utils.Misc ( dropWhileEndLE, spanEnd, last2, lastMaybe, onJust, - List.foldl1', foldl2, count, countWhile, all2, + List.foldl1', foldl2, count, countWhile, all2, all2Prefix, all3Prefix, lengthExceeds, lengthIs, lengthIsNot, lengthAtLeast, lengthAtMost, lengthLessThan, @@ -663,6 +663,29 @@ all2 _ [] [] = True all2 p (x:xs) (y:ys) = p x y && all2 p xs ys all2 _ _ _ = False +all2Prefix :: (a -> b -> Bool) -> [a] -> [b] -> Bool +-- ^ `all2Prefix p xs ys` is a fused version of `and $ zipWith2 p xs ys`. +-- So if one list is shorter than the other, `p` is assumed to be `True` for the +-- suffix. +all2Prefix p = foldr (\x go ys' -> case ys' of (y:ys'') -> p x y && go ys''; _ -> True) (\_ -> True) +{-# INLINE all2Prefix #-} +-- all2Prefix p xs ys = go xs ys +-- where go (x:xs) (y:ys) = p x y && go xs ys +-- go _ _ = True +-- {-# INLINABLE all2Prefix #-} + +all3Prefix :: (a -> b -> c -> Bool) -> [a] -> [b] -> [c] -> Bool +-- ^ `all3Prefix p xs ys zs` is a fused version of `and $ zipWith3 p xs ys zs`. +-- So if one list is shorter than the others, `p` is assumed to be `True` for +-- the suffix. +all3Prefix p xs ys zs = foldr (\y go xs' zs' -> case (xs',zs') of (x:xs'',z:zs'') -> p x y z && go xs'' zs''; _ -> False) (\_ _ -> True) ys xs zs +{-# INLINE all3Prefix #-} +-- all3Prefix p xs ys zs = go xs ys zs +-- where +-- go (x:xs) (y:ys) (z:zs) = p x y z && go xs ys zs +-- go _ _ _ = True +-- {-# INLINABLE all3Prefix #-} + -- Count the number of times a predicate is true count :: (a -> Bool) -> [a] -> Int ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -167,9 +167,13 @@ test('T9872d', ], compile, ['']) +# By adjusting T12545.measure.sh, SG found out that this benchmark varies as +# much as 1.7% by -dunique-increment alone since major improvements +# in 4bf9fa0f216bb294c1bd3644363b008a8643a653. +# Hence the acceptance threshold is 4% now. test ('T8095', [ only_ways(['normal']), - collect_compiler_stats('bytes allocated',2) ], + collect_compiler_stats('bytes allocated',4) ], compile, ['-v0 -O']) test ('T13386', ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -417,7 +417,10 @@ test('T21391', normal, compile, ['-O -dcore-lint']) test('T22112', [ grep_errmsg('never matches') ], compile, ['-O -dsuppress-uniques -dno-typeable-binds -fexpose-all-unfoldings -ddump-simpl']) test('T21391a', normal, compile, ['-O -dcore-lint']) # We don't want to see a thunk allocation for the insertBy expression after CorePrep. -test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]'), expect_broken(21392) ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) +# Unfortunately, this test is no longer broken after we made workers strict in strict fields, +# so it is no longer a reproducer for T21392. Still, it doesn't hurt if we test that we don't +# regress again. +test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]') ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) test('T21689', [extra_files(['T21689a.hs'])], multimod_compile, ['T21689', '-v0 -O']) test('T21801', normal, compile, ['-O -dcore-lint']) test('T21848', [grep_errmsg(r'SPEC wombat') ], compile, ['-O -ddump-spec']) ===================================== testsuite/tests/simplStg/should_compile/inferTags002.stderr ===================================== @@ -1,88 +1,30 @@ -==================== Output Cmm ==================== -[M.$WMkT_entry() { // [R3, R2] - { info_tbls: [(cym, - label: block_cym_info - rep: StackRep [False] - srt: Nothing), - (cyp, - label: M.$WMkT_info - rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } - srt: Nothing), - (cys, - label: block_cys_info - rep: StackRep [False] - srt: Nothing)] - stack_info: arg_space: 8 - } - {offset - cyp: // global - if ((Sp + -16) < SpLim) (likely: False) goto cyv; else goto cyw; - cyv: // global - R1 = M.$WMkT_closure; - call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; - cyw: // global - I64[Sp - 16] = cym; - R1 = R2; - P64[Sp - 8] = R3; - Sp = Sp - 16; - if (R1 & 7 != 0) goto cym; else goto cyn; - cyn: // global - call (I64[R1])(R1) returns to cym, args: 8, res: 8, upd: 8; - cym: // global - I64[Sp] = cys; - _sy8::P64 = R1; - R1 = P64[Sp + 8]; - P64[Sp + 8] = _sy8::P64; - call stg_ap_0_fast(R1) returns to cys, args: 8, res: 8, upd: 8; - cys: // global - Hp = Hp + 24; - if (Hp > HpLim) (likely: False) goto cyA; else goto cyz; - cyA: // global - HpAlloc = 24; - call stg_gc_unpt_r1(R1) returns to cys, args: 8, res: 8, upd: 8; - cyz: // global - I64[Hp - 16] = M.MkT_con_info; - P64[Hp - 8] = P64[Sp + 8]; - P64[Hp] = R1; - R1 = Hp - 15; - Sp = Sp + 16; - call (P64[Sp])(R1) args: 8, res: 0, upd: 8; - } - }, - section ""data" . M.$WMkT_closure" { - M.$WMkT_closure: - const M.$WMkT_info; - }] - - - ==================== Output Cmm ==================== [M.f_entry() { // [R2] - { info_tbls: [(cyK, - label: block_cyK_info + { info_tbls: [(cAs, + label: block_info rep: StackRep [] srt: Nothing), - (cyN, + (cAv, label: M.f_info rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cyN: // global - if ((Sp + -8) < SpLim) (likely: False) goto cyO; else goto cyP; - cyO: // global + _lbl_: // global + if ((Sp + -8) < SpLim) (likely: False) goto cAw; else goto cAx; + _lbl_: // global R1 = M.f_closure; call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; - cyP: // global - I64[Sp - 8] = cyK; + _lbl_: // global + I64[Sp - 8] = cAs; R1 = R2; Sp = Sp - 8; - if (R1 & 7 != 0) goto cyK; else goto cyL; - cyL: // global - call (I64[R1])(R1) returns to cyK, args: 8, res: 8, upd: 8; - cyK: // global + if (R1 & 7 != 0) goto cAs; else goto cAt; + _lbl_: // global + call (I64[R1])(R1) returns to cAs, args: 8, res: 8, upd: 8; + _lbl_: // global R1 = P64[R1 + 15]; Sp = Sp + 8; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; @@ -97,47 +39,47 @@ ==================== Output Cmm ==================== [M.MkT_entry() { // [R3, R2] - { info_tbls: [(cz1, - label: block_cz1_info + { info_tbls: [(cAJ, + label: block_info rep: StackRep [False] srt: Nothing), - (cz4, + (cAM, label: M.MkT_info rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } srt: Nothing), - (cz7, - label: block_cz7_info + (cAP, + label: block_info rep: StackRep [False] srt: Nothing)] stack_info: arg_space: 8 } {offset - cz4: // global - if ((Sp + -16) < SpLim) (likely: False) goto cza; else goto czb; - cza: // global + _lbl_: // global + if ((Sp + -16) < SpLim) (likely: False) goto cAS; else goto cAT; + _lbl_: // global R1 = M.MkT_closure; call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; - czb: // global - I64[Sp - 16] = cz1; + _lbl_: // global + I64[Sp - 16] = cAJ; R1 = R2; P64[Sp - 8] = R3; Sp = Sp - 16; - if (R1 & 7 != 0) goto cz1; else goto cz2; - cz2: // global - call (I64[R1])(R1) returns to cz1, args: 8, res: 8, upd: 8; - cz1: // global - I64[Sp] = cz7; - _tyf::P64 = R1; + if (R1 & 7 != 0) goto cAJ; else goto cAK; + _lbl_: // global + call (I64[R1])(R1) returns to cAJ, args: 8, res: 8, upd: 8; + _lbl_: // global + I64[Sp] = cAP; + __locVar_::P64 = R1; R1 = P64[Sp + 8]; - P64[Sp + 8] = _tyf::P64; - call stg_ap_0_fast(R1) returns to cz7, args: 8, res: 8, upd: 8; - cz7: // global + P64[Sp + 8] = __locVar_::P64; + call stg_ap_0_fast(R1) returns to cAP, args: 8, res: 8, upd: 8; + _lbl_: // global Hp = Hp + 24; - if (Hp > HpLim) (likely: False) goto czf; else goto cze; - czf: // global + if (Hp > HpLim) (likely: False) goto cAX; else goto cAW; + _lbl_: // global HpAlloc = 24; - call stg_gc_unpt_r1(R1) returns to cz7, args: 8, res: 8, upd: 8; - cze: // global + call stg_gc_unpt_r1(R1) returns to cAP, args: 8, res: 8, upd: 8; + _lbl_: // global I64[Hp - 16] = M.MkT_con_info; P64[Hp - 8] = P64[Sp + 8]; P64[Hp] = R1; @@ -155,14 +97,14 @@ ==================== Output Cmm ==================== [M.MkT_con_entry() { // [] - { info_tbls: [(czl, + { info_tbls: [(cB3, label: M.MkT_con_info rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - czl: // global + _lbl_: // global R1 = R1 + 1; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } ===================================== testsuite/tests/stranal/sigs/T16859.stderr ===================================== @@ -4,7 +4,7 @@ T16859.bar: <1!A> T16859.baz: <1L><1!P(L)><1C(1,L)> T16859.buz: <1!P(L,L)> T16859.foo: <1L> -T16859.mkInternalName: <1!P(L)><1L><1L> +T16859.mkInternalName: <1!P(L)> T16859.n_loc: <1!P(A,A,A,1L)> T16859.n_occ: <1!P(A,1!P(L,L),A,A)> T16859.n_sort: <1!P(1L,A,A,A)> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a8b97fbf89f37eaba135a623ce9a79250cbc268...17e3307f5cfe6ef84f151a1500d56e93ca608604 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a8b97fbf89f37eaba135a623ce9a79250cbc268...17e3307f5cfe6ef84f151a1500d56e93ca608604 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 17 09:06:22 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 17 Oct 2023 05:06:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/mixed-uniqfm Message-ID: <652e4e8e7dfef_7336f55052e2c267060@gitlab.mail> Sebastian Graf pushed new branch wip/mixed-uniqfm at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mixed-uniqfm You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 17 09:34:33 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 17 Oct 2023 05:34:33 -0400 Subject: [Git][ghc/ghc][wip/T20749] 5 commits: Move comments into new `Note [Sensitivity to unique increment]`, add T8095 (#19414) Message-ID: <652e5529e8662_7336f55d55ac027136b@gitlab.mail> Sebastian Graf pushed to branch wip/T20749 at Glasgow Haskell Compiler / GHC Commits: 392596a2 by Sebastian Graf at 2023-10-17T10:21:12+02:00 Move comments into new `Note [Sensitivity to unique increment]`, add T8095 (#19414) - - - - - 3143021d by Sebastian Graf at 2023-10-17T10:21:12+02:00 Make DataCon workers strict in strict fields (#20749) This patch tweaks `exprIsConApp_maybe`, `exprIsHNF` and friends, and Demand Analysis so that they exploit and maintain strictness of DataCon workers. See `Note [Strict fields in Core]` for details. Very little needed to change, and it puts field seq insertion done by Tag Inference into a new perspective: That of *implementing* strict field semantics. Before Tag Inference, DataCon workers are strict. Afterwards they are effectively lazy and field seqs happen around use sites. History has shown that there is no other way to guarantee taggedness and thus the STG Strict Field Invariant. Knock-on changes: * `exprIsHNF` previously used `exprOkForSpeculation` on unlifted arguments instead of recursing into `exprIsHNF`. That regressed the termination analysis in CPR analysis (which simply calls out to `exprIsHNF`), so I made it call `exprOkForSpeculation`, too. * There's a small regression in Demand Analysis, visible in the changed test output of T16859: Previously, a field seq on a variable would give that variable a "used exactly once" demand, now it's "used at least once", because `dmdTransformDataConSig` accounts for future uses of the field that actually all go through the case binder (and hence won't re-enter the potential thunk). The difference should hardly be observable. * The Simplifier's fast path for data constructors only applies to lazy data constructors now. I observed regressions involving Data.Binary.Put's `Pair` data type. * Unfortunately, T21392 does no longer reproduce after this patch, so I marked it as "not broken" in order to track whether we regress again in the future. Fixes #20749, the satisfying conclusion of an annoying saga (cf. the ideas in #21497 and #22475). - - - - - 35a3202d by Jaro Reinders at 2023-10-17T10:21:12+02:00 Try fixing allocation regressions - - - - - c01c0436 by Sebastian Graf at 2023-10-17T10:21:12+02:00 CorePrep: Attach evaldUnfolding to floats to detect more values - - - - - 7febfe8f by Sebastian Graf at 2023-10-17T10:21:12+02:00 Arity: Attach eval'd arity type of scrutinee to case binder Just a sensible thing to do; should be a straight win. - - - - - 26 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Stg/InferTags.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Tc/TyCl/Build.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Utils/Misc.hs - testsuite/tests/perf/compiler/T12545.hs - testsuite/tests/perf/compiler/T8095.hs - testsuite/tests/perf/compiler/all.T - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/simplStg/should_compile/inferTags002.stderr - testsuite/tests/stranal/sigs/T16859.stderr Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -636,6 +636,8 @@ pcDataConWithFixity' declared_infix dc_name wrk_key rri -- See Note [Constructor tag allocation] and #14657 data_con = mkDataCon dc_name declared_infix prom_info (map (const no_bang) arg_tys) + (map (const HsLazy) arg_tys) + (map (const NotMarkedStrict) arg_tys) [] -- No labelled fields tyvars ex_tyvars conc_tyvars ===================================== compiler/GHC/Core.hs ===================================== @@ -42,7 +42,7 @@ module GHC.Core ( foldBindersOfBindStrict, foldBindersOfBindsStrict, collectBinders, collectTyBinders, collectTyAndValBinders, collectNBinders, collectNValBinders_maybe, - collectArgs, stripNArgs, collectArgsTicks, flattenBinds, + collectArgs, collectValArgs, stripNArgs, collectArgsTicks, flattenBinds, collectFunSimple, exprToType, @@ -1005,6 +1005,60 @@ tail position: A cast changes the type, but the type must be the same. But operationally, casts are vacuous, so this is a bit unfortunate! See #14610 for ideas how to fix this. +Note [Strict fields in Core] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Evaluating a data constructor worker evaluates its strict fields. + +In other words, if `MkT` is strict in its first field and `xs` reduces to +`error "boom"`, then `MkT xs b` will throw that error. +Conversely, it is sound to seq the field before the call to the constructor, +e.g., with `case xs of xs' { __DEFAULT -> MkT xs' b }`. +Let's call this transformation "field seq insertion". + +Note in particular that the data constructor application `MkT xs b` above is +*not* a value, unless `xs` is! + +This has pervasive effect on the Core pipeline: + + * `exprIsHNF`/`exprIsConLike`/`exprOkForSpeculation` need to assert that the + strict arguments of a DataCon worker are values/ok-for-spec themselves. + + * `exprIsConApp_maybe` inserts field seqs in the `FloatBind`s it returns, so + that the Simplifier, Constant-folding, the pattern-match checker, etc. + all see the insert field seqs when they match on strict workers. Often this + is just to emphasise strict semantics, but for case-of-known constructor + and case-to-let field insertion is *vital*, otherwise these transformations + would lose field seqs. + + * The demand signature of a data constructor is strict in strict field + position, whereas is it's normally lazy. Likewise the demand *transformer* + of a DataCon worker can add stricten up demands on strict field args. + See Note [Demand transformer for data constructors]. + + * In the absence of `-fpedantic-bottoms`, it is still possible that some seqs + are ultimately dropped or delayed due to eta-expansion. + See Note [Dealing with bottom]. + +Strict field semantics is exploited in STG by Note [Tag Inference]: +It performs field seq insertion to statically guarantee *taggedness* of strict +fields, establishing the Note [STG Strict Field Invariant]. (Happily, most +of those seqs are immediately detected as redundant by tag inference and are +omitted.) From then on, DataCon worker semantics are actually lazy, hence it is +important that STG passes maintain the Strict Field Invariant. + + +Historical Note: +The delightfully simple description of strict field semantics is the result of +a long saga (#20749, the bits about strict data constructors in #21497, #22475), +where we tried a more lenient (but actually not) semantics first that would +allow both strict and lazy implementations of DataCon workers. This was favoured +because the "pervasive effect" throughout the compiler was deemed too large +(when it really turned out to be very modest). +Alas, this semantics would require us to implement `exprIsHNF` in *exactly* the +same way as above, otherwise the analysis would not be conservative wrt. the +lenient semantics (which includes the strict one). It is also much harder to +explain and maintain, as it turned out. + ************************************************************************ * * In/Out type synonyms @@ -2091,6 +2145,17 @@ collectArgs expr go (App f a) as = go f (a:as) go e as = (e, as) +-- | Takes a nested application expression and returns the function +-- being applied and the arguments to which it is applied +collectValArgs :: Expr b -> (Expr b, [Arg b]) +collectValArgs expr + = go expr [] + where + go (App f a) as + | isValArg a = go f (a:as) + | otherwise = go f as + go e as = (e, as) + -- | Takes a nested application expression and returns the function -- being applied. Looking through casts and ticks to find it. collectFunSimple :: Expr b -> Expr b ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -49,7 +49,8 @@ module GHC.Core.DataCon ( dataConIsInfix, dataConWorkId, dataConWrapId, dataConWrapId_maybe, dataConImplicitTyThings, - dataConRepStrictness, dataConImplBangs, dataConBoxer, + dataConRepStrictness, dataConRepStrictness_maybe, + dataConImplBangs, dataConBoxer, splitDataProductType_maybe, @@ -60,7 +61,7 @@ module GHC.Core.DataCon ( isVanillaDataCon, isNewDataCon, isTypeDataCon, classDataCon, dataConCannotMatch, dataConUserTyVarsNeedWrapper, checkDataConTyVars, - isBanged, isMarkedStrict, cbvFromStrictMark, eqHsBang, isSrcStrict, isSrcUnpacked, + isBanged, isUnpacked, isMarkedStrict, cbvFromStrictMark, eqHsBang, isSrcStrict, isSrcUnpacked, specialPromotedDc, -- ** Promotion related functions @@ -97,6 +98,7 @@ import GHC.Types.Unique.FM ( UniqFM ) import GHC.Types.Unique.Set import GHC.Builtin.Uniques( mkAlphaTyVarUnique ) import GHC.Data.Graph.UnVar -- UnVarSet and operations +import GHC.Data.Maybe (orElse) import {-# SOURCE #-} GHC.Tc.Utils.TcType ( ConcreteTyVars ) @@ -524,6 +526,18 @@ data DataCon -- Matches 1-1 with dcOrigArgTys -- Hence length = dataConSourceArity dataCon + dcImplBangs :: [HsImplBang], + -- The actual decisions made (including failures) + -- about the original arguments; 1-1 with orig_arg_tys + -- See Note [Bangs on data constructor arguments] + + dcStricts :: [StrictnessMark], + -- One mark for every field of the DataCon worker; + -- if it's empty, then all fields are lazy, + -- otherwise it has the same length as dataConRepArgTys. + -- See also Note [Strict fields in Core] in GHC.Core + -- for the effect on the strictness signature + dcFields :: [FieldLabel], -- Field labels for this constructor, in the -- same order as the dcOrigArgTys; @@ -826,13 +840,6 @@ data DataConRep -- after unboxing and flattening, -- and *including* all evidence args - , dcr_stricts :: [StrictnessMark] -- 1-1 with dcr_arg_tys - -- See also Note [Data-con worker strictness] - - , dcr_bangs :: [HsImplBang] -- The actual decisions made (including failures) - -- about the original arguments; 1-1 with orig_arg_tys - -- See Note [Bangs on data constructor arguments] - } type DataConEnv a = UniqFM DataCon a -- Keyed by DataCon @@ -901,43 +908,8 @@ eqSpecPreds spec = [ mkPrimEqPred (mkTyVarTy tv) ty instance Outputable EqSpec where ppr (EqSpec tv ty) = ppr (tv, ty) -{- Note [Data-con worker strictness] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Notice that we do *not* say the worker Id is strict even if the data -constructor is declared strict - e.g. data T = MkT ![Int] Bool -Even though most often the evals are done by the *wrapper* $WMkT, there are -situations in which tag inference will re-insert evals around the worker. -So for all intents and purposes the *worker* MkT is strict, too! - -Unfortunately, if we exposed accurate strictness of DataCon workers, we'd -see the following transformation: - - f xs = case xs of xs' { __DEFAULT -> ... case MkT xs b of x { __DEFAULT -> [x] } } -- DmdAnal: Strict in xs - ==> { drop-seq, binder swap on xs' } - f xs = case MkT xs b of x { __DEFAULT -> [x] } -- DmdAnal: Still strict in xs - ==> { case-to-let } - f xs = let x = MkT xs' b in [x] -- DmdAnal: No longer strict in xs! - -I.e., we are ironically losing strictness in `xs` by dropping the eval on `xs` -and then doing case-to-let. The issue is that `exprIsHNF` currently says that -every DataCon worker app is a value. The implicit assumption is that surrounding -evals will have evaluated strict fields like `xs` before! But now that we had -just dropped the eval on `xs`, that assumption is no longer valid. - -Long story short: By keeping the demand signature lazy, the Simplifier will not -drop the eval on `xs` and using `exprIsHNF` to decide case-to-let and others -remains sound. - -Similarly, during demand analysis in dmdTransformDataConSig, we bump up the -field demand with `C_01`, *not* `C_11`, because the latter exposes too much -strictness that will drop the eval on `xs` above. - -This issue is discussed at length in -"Failed idea: no wrappers for strict data constructors" in #21497 and #22475. - -Note [Bangs on data constructor arguments] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Bangs on data constructor arguments] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider data T = MkT !Int {-# UNPACK #-} !Int Bool @@ -963,8 +935,8 @@ Terminology: the flag settings in the importing module. Also see Note [Bangs on imported data constructors] in GHC.Types.Id.Make -* The dcr_bangs field of the dcRep field records the [HsImplBang] - If T was defined in this module, Without -O the dcr_bangs might be +* The dcImplBangs field records the [HsImplBang] + If T was defined in this module, Without -O the dcImplBangs might be [HsStrict _, HsStrict _, HsLazy] With -O it might be [HsStrict _, HsUnpack _, HsLazy] @@ -973,6 +945,17 @@ Terminology: With -XStrictData it might be [HsStrict _, HsUnpack _, HsStrict _] +* Core passes will often need to know whether the DataCon worker or wrapper in + an application is strict in some (lifted) field or not. This is tracked in the + demand signature attached to a DataCon's worker resp. wrapper Id. + + So if you've got a DataCon dc, you can get the demand signature by + `idDmdSig (dataConWorkId dc)` and make out strict args by testing with + `isStrictDmd`. Similarly, `idDmdSig <$> dataConWrapId_maybe dc` gives + you the demand signature of the wrapper, if it exists. + + These demand signatures are set in GHC.Types.Id.Make. + Note [Detecting useless UNPACK pragmas] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want to issue a warning when there's an UNPACK pragma in the source code, @@ -1008,7 +991,6 @@ we consult HsImplBang: The boolean flag is used only for this warning. See #11270 for motivation. - ************************************************************************ * * \subsection{Instances} @@ -1110,6 +1092,11 @@ isBanged (HsUnpack {}) = True isBanged (HsStrict {}) = True isBanged HsLazy = False +isUnpacked :: HsImplBang -> Bool +isUnpacked (HsUnpack {}) = True +isUnpacked (HsStrict {}) = False +isUnpacked HsLazy = False + isSrcStrict :: SrcStrictness -> Bool isSrcStrict SrcStrict = True isSrcStrict _ = False @@ -1135,13 +1122,15 @@ cbvFromStrictMark MarkedStrict = MarkedCbv -- | Build a new data constructor mkDataCon :: Name - -> Bool -- ^ Is the constructor declared infix? - -> TyConRepName -- ^ TyConRepName for the promoted TyCon - -> [HsSrcBang] -- ^ Strictness/unpack annotations, from user - -> [FieldLabel] -- ^ Field labels for the constructor, - -- if it is a record, otherwise empty - -> [TyVar] -- ^ Universals. - -> [TyCoVar] -- ^ Existentials. + -> Bool -- ^ Is the constructor declared infix? + -> TyConRepName -- ^ TyConRepName for the promoted TyCon + -> [HsSrcBang] -- ^ Strictness/unpack annotations, from user + -> [HsImplBang] -- ^ Strictness/unpack annotations, as inferred by the compiler + -> [StrictnessMark] -- ^ Strictness marks for the DataCon worker's fields in Core + -> [FieldLabel] -- ^ Field labels for the constructor, + -- if it is a record, otherwise empty + -> [TyVar] -- ^ Universals. + -> [TyCoVar] -- ^ Existentials. -> ConcreteTyVars -- ^ TyVars which must be instantiated with -- concrete types @@ -1163,7 +1152,9 @@ mkDataCon :: Name -- Can get the tag from the TyCon mkDataCon name declared_infix prom_info - arg_stricts -- Must match orig_arg_tys 1-1 + arg_stricts -- Must match orig_arg_tys 1-1 + impl_bangs -- Must match orig_arg_tys 1-1 + str_marks -- Must be empty or match dataConRepArgTys 1-1 fields univ_tvs ex_tvs conc_tvs user_tvbs eq_spec theta @@ -1180,6 +1171,8 @@ mkDataCon name declared_infix prom_info = con where is_vanilla = null ex_tvs && null eq_spec && null theta + str_marks' | not $ any isMarkedStrict str_marks = [] + | otherwise = str_marks con = MkData {dcName = name, dcUnique = nameUnique name, dcVanilla = is_vanilla, dcInfix = declared_infix, @@ -1192,7 +1185,8 @@ mkDataCon name declared_infix prom_info dcStupidTheta = stupid_theta, dcOrigArgTys = orig_arg_tys, dcOrigResTy = orig_res_ty, dcRepTyCon = rep_tycon, - dcSrcBangs = arg_stricts, + dcSrcBangs = arg_stricts, dcImplBangs = impl_bangs, + dcStricts = str_marks', dcFields = fields, dcTag = tag, dcRepType = rep_ty, dcWorkId = work_id, dcRep = rep, @@ -1436,19 +1430,27 @@ isNullaryRepDataCon :: DataCon -> Bool isNullaryRepDataCon dc = dataConRepArity dc == 0 dataConRepStrictness :: DataCon -> [StrictnessMark] --- ^ Give the demands on the arguments of a --- Core constructor application (Con dc args) -dataConRepStrictness dc = case dcRep dc of - NoDataConRep -> [NotMarkedStrict | _ <- dataConRepArgTys dc] - DCR { dcr_stricts = strs } -> strs +-- ^ Give the demands on the runtime arguments of a Core DataCon worker +-- application. +-- The length of the list matches `dataConRepArgTys` (e.g., the number +-- of runtime arguments). +dataConRepStrictness dc + = dataConRepStrictness_maybe dc + `orElse` map (const NotMarkedStrict) (dataConRepArgTys dc) + +dataConRepStrictness_maybe :: DataCon -> Maybe [StrictnessMark] +-- ^ Give the demands on the runtime arguments of a Core DataCon worker +-- application or `Nothing` if all of them are lazy. +-- The length of the list matches `dataConRepArgTys` (e.g., the number +-- of runtime arguments). +dataConRepStrictness_maybe dc + | null (dcStricts dc) = Nothing + | otherwise = Just (dcStricts dc) dataConImplBangs :: DataCon -> [HsImplBang] -- The implementation decisions about the strictness/unpack of each -- source program argument to the data constructor -dataConImplBangs dc - = case dcRep dc of - NoDataConRep -> replicate (dcSourceArity dc) HsLazy - DCR { dcr_bangs = bangs } -> bangs +dataConImplBangs dc = dcImplBangs dc dataConBoxer :: DataCon -> Maybe DataConBoxer dataConBoxer (MkData { dcRep = DCR { dcr_boxer = boxer } }) = Just boxer ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -848,6 +848,10 @@ trimArityType max_arity at@(AT lams _) | lams `lengthAtMost` max_arity = at | otherwise = AT (take max_arity lams) topDiv +evalArityType :: ArityType -> ArityType +evalArityType (AT ((IsExpensive,os):is) div) = AT ((IsCheap,os):is) div +evalArityType at = at + data ArityOpts = ArityOpts { ao_ped_bot :: !Bool -- See Note [Dealing with bottom] , ao_dicts_cheap :: !Bool -- See Note [Eta expanding through dictionaries] @@ -1473,7 +1477,7 @@ myExprIsCheap (AE { am_opts = opts, am_sigs = sigs }) e mb_ty -- See Note [Eta expanding through dictionaries] -- See Note [Eta expanding through CallStacks] - cheap_fun e = exprIsCheapX (myIsCheapApp sigs) e + cheap_fun e = exprIsCheapX (myIsCheapApp sigs) False e -- | A version of 'isCheapApp' that considers results from arity analysis. -- See Note [Arity analysis] for what's in the signature environment and why @@ -1553,7 +1557,7 @@ arityType env (Case scrut bndr _ alts) | otherwise -- In the remaining cases we may not push = addWork alts_type -- evaluation of the scrutinee in where - env' = delInScope env bndr + env' = extendSigEnv env bndr (evalArityType (arityType env scrut)) arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs alts_type = foldr1 (andArityType env) (map arity_type_alt alts) ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -47,7 +47,7 @@ import GHC.Core import GHC.Core.Make import GHC.Core.SimpleOpt ( exprIsConApp_maybe, exprIsLiteral_maybe ) import GHC.Core.DataCon ( DataCon,dataConTagZ, dataConTyCon, dataConWrapId, dataConWorkId ) -import GHC.Core.Utils ( cheapEqExpr, exprIsHNF +import GHC.Core.Utils ( cheapEqExpr, exprOkForSpeculation , stripTicksTop, stripTicksTopT, mkTicks ) import GHC.Core.Multiplicity import GHC.Core.Rules.Config @@ -2101,7 +2101,7 @@ Things to note Implementing seq#. The compiler has magic for SeqOp in -- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) +- GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq# s) - GHC.StgToCmm.Expr.cgExpr, and cgCase: special case for seq# @@ -2113,7 +2113,7 @@ Implementing seq#. The compiler has magic for SeqOp in seqRule :: RuleM CoreExpr seqRule = do [Type _ty_a, Type _ty_s, a, s] <- getArgs - guard $ exprIsHNF a + guard $ exprOkForSpeculation a return $ mkCoreUnboxedTuple [s, a] -- spark# :: forall a s . a -> State# s -> (# State# s, a #) ===================================== compiler/GHC/Core/Opt/CprAnal.hs ===================================== @@ -296,9 +296,16 @@ data TermFlag -- Better than using a Bool -- See Note [Nested CPR] exprTerminates :: CoreExpr -> TermFlag +-- ^ A /very/ simple termination analysis. exprTerminates e - | exprIsHNF e = Terminates -- A /very/ simple termination analysis. - | otherwise = MightDiverge + | exprIsHNF e = Terminates + | exprOkForSpeculation e = Terminates + | otherwise = MightDiverge + -- Annyingly, we have to check both for HNF and ok-for-spec. + -- * `I# (x# *# 2#)` is ok-for-spec, but not in HNF. Still worth CPR'ing! + -- * `lvl` is an HNF if its unfolding is evaluated + -- (perhaps `lvl = I# 0#` at top-level). But, tiresomely, it is never + -- ok-for-spec due to Note [exprOkForSpeculation and evaluated variables]. cprAnalApp :: AnalEnv -> CoreExpr -> [(CprType, CoreArg)] -> (CprType, CoreExpr) -- Main function that takes care of /nested/ CPR. See Note [Nested CPR] ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -824,6 +824,10 @@ to the Divergence lattice, but in practice it turned out to be hard to untaint from 'topDiv' to 'conDiv', leading to bugs, performance regressions and complexity that didn't justify the single fixed testcase T13380c. +You might think that we should check for side-effects rather than just for +precise exceptions. Right you are! See Note [Side-effects and strictness] +for why we unfortunately do not. + Note [Demand analysis for recursive data constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ T11545 features a single-product, recursive data type ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -8,14 +8,13 @@ module GHC.Core.Opt.Simplify.Env ( -- * The simplifier mode - SimplMode(..), updMode, - smPedanticBottoms, smPlatform, + SimplMode(..), updMode, smPlatform, -- * Environments SimplEnv(..), pprSimplEnv, -- Temp not abstract seArityOpts, seCaseCase, seCaseFolding, seCaseMerge, seCastSwizzle, seDoEtaReduction, seEtaExpand, seFloatEnable, seInline, seNames, - seOptCoercionOpts, sePedanticBottoms, sePhase, sePlatform, sePreInline, + seOptCoercionOpts, sePhase, sePlatform, sePreInline, seRuleOpts, seRules, seUnfoldingOpts, mkSimplEnv, extendIdSubst, extendTvSubst, extendCvSubst, @@ -235,9 +234,6 @@ seNames env = sm_names (seMode env) seOptCoercionOpts :: SimplEnv -> OptCoercionOpts seOptCoercionOpts env = sm_co_opt_opts (seMode env) -sePedanticBottoms :: SimplEnv -> Bool -sePedanticBottoms env = smPedanticBottoms (seMode env) - sePhase :: SimplEnv -> CompilerPhase sePhase env = sm_phase (seMode env) @@ -292,9 +288,6 @@ instance Outputable SimplMode where where pp_flag f s = ppUnless f (text "no") <+> s -smPedanticBottoms :: SimplMode -> Bool -smPedanticBottoms opts = ao_ped_bot (sm_arity_opts opts) - smPlatform :: SimplMode -> Platform smPlatform opts = roPlatform (sm_rule_opts opts) ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -31,7 +31,7 @@ import GHC.Core.Reduction import GHC.Core.Coercion.Opt ( optCoercion ) import GHC.Core.FamInstEnv ( FamInstEnv, topNormaliseType_maybe ) import GHC.Core.DataCon - ( DataCon, dataConWorkId, dataConRepStrictness + ( DataCon, dataConWorkId, dataConRepStrictness, dataConRepStrictness_maybe , dataConRepArgTys, isUnboxedTupleDataCon , StrictnessMark (..) ) import GHC.Core.Opt.Stats ( Tick(..) ) @@ -2165,14 +2165,14 @@ zap the SubstEnv. This is VITAL. Consider We'll clone the inner \x, adding x->x' in the id_subst Then when we inline y, we must *not* replace x by x' in the inlined copy!! -Note [Fast path for data constructors] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Fast path for lazy data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For applications of a data constructor worker, the full glory of rebuildCall is a waste of effort; * They never inline, obviously * They have no rewrite rules -* They are not strict (see Note [Data-con worker strictness] - in GHC.Core.DataCon) +* Though they might be strict (see Note [Strict fields in Core] in GHC.Core), + we will exploit that strictness through their demand signature So it's fine to zoom straight to `rebuild` which just rebuilds the call in a very straightforward way. @@ -2196,7 +2196,8 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont - | isDataConWorkId var -- See Note [Fast path for data constructors] + | Just dc <- isDataConWorkId_maybe var -- See Note [Fast path for lazy data constructors] + , Nothing <- dataConRepStrictness_maybe dc = rebuild env (Var var) cont | otherwise = case substId env var of @@ -3383,7 +3384,7 @@ a case pattern. This is *important*. Consider We really must record that b is already evaluated so that we don't go and re-evaluate it when constructing the result. -See Note [Data-con worker strictness] in GHC.Core.DataCon +See Note [Strict fields in Core] in GHC.Core. NB: simplLamBndrs preserves this eval info ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1270,11 +1270,8 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr -- simplifier produces rhs[exp/a], changing semantics if exp is not ok-for-spec -- Good: returning (Mk#, [x]) with a float of case exp of x { DEFAULT -> [] } -- simplifier produces case exp of a { DEFAULT -> exp[x/a] } - = let arg' = subst_expr subst arg - bndr = uniqAway (subst_in_scope subst) (mkWildValBinder ManyTy arg_type) - float = FloatCase arg' bndr DEFAULT [] - subst' = subst_extend_in_scope subst bndr - in go subst' (float:floats) fun (CC (Var bndr : args) co) + , (subst', float, bndr) <- case_bind subst arg arg_type + = go subst' (float:floats) fun (CC (Var bndr : args) co) | otherwise = go subst floats fun (CC (subst_expr subst arg : args) co) @@ -1317,8 +1314,9 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr | Just con <- isDataConWorkId_maybe fun , count isValArg args == idArity fun - = succeedWith in_scope floats $ - pushCoDataCon con args co + , (in_scope', seq_floats, args') <- mkFieldSeqFloats in_scope con args + = succeedWith in_scope' (seq_floats ++ floats) $ + pushCoDataCon con args' co -- Look through data constructor wrappers: they inline late (See Note -- [Activation for data constructor wrappers]) but we want to do @@ -1404,6 +1402,36 @@ exprIsConApp_maybe ise@(ISE in_scope id_unf) expr extend (Left in_scope) v e = Right (extendSubst (mkEmptySubst in_scope) v e) extend (Right s) v e = Right (extendSubst s v e) + case_bind :: Either InScopeSet Subst -> CoreExpr -> Type -> (Either InScopeSet Subst, FloatBind, Id) + case_bind subst expr expr_ty = (subst', float, bndr) + where + bndr = setCaseBndrEvald MarkedStrict $ + uniqAway (subst_in_scope subst) $ + mkWildValBinder ManyTy expr_ty + subst' = subst_extend_in_scope subst bndr + expr' = subst_expr subst expr + float = FloatCase expr' bndr DEFAULT [] + + mkFieldSeqFloats :: InScopeSet -> DataCon -> [CoreExpr] -> (InScopeSet, [FloatBind], [CoreExpr]) + mkFieldSeqFloats in_scope dc args + | Nothing <- dataConRepStrictness_maybe dc + = (in_scope, [], args) + | otherwise + = (in_scope', floats', ty_args ++ val_args') + where + (ty_args, val_args) = splitAtList (dataConUnivAndExTyCoVars dc) args + (in_scope', floats', val_args') = foldr do_one (in_scope, [], []) $ zipEqual "mkFieldSeqFloats" str_marks val_args + str_marks = dataConRepStrictness dc + do_one (str, arg) (in_scope,floats,args) + | NotMarkedStrict <- str = no_seq + | exprIsHNF arg = no_seq + | otherwise = (in_scope', float:floats, Var bndr:args) + where + no_seq = (in_scope, floats, arg:args) + (in_scope', float, bndr) = + case case_bind (Left in_scope) arg (exprType arg) of + (Left in_scope', float, bndr) -> (in_scope', float, bndr) + (right, _, _) -> pprPanic "case_bind did not preserve Left" (ppr in_scope $$ ppr arg $$ ppr right) -- See Note [exprIsConApp_maybe on literal strings] dealWithStringLiteral :: Var -> BS.ByteString -> Coercion ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -55,7 +55,7 @@ module GHC.Core.Type ( splitForAllForAllTyBinders, splitForAllForAllTyBinder_maybe, splitForAllTyCoVar_maybe, splitForAllTyCoVar, splitForAllTyVar_maybe, splitForAllCoVar_maybe, - splitPiTy_maybe, splitPiTy, splitPiTys, + splitPiTy_maybe, splitPiTy, splitPiTys, collectPiTyBinders, getRuntimeArgTys, mkTyConBindersPreferAnon, mkPiTy, mkPiTys, @@ -292,6 +292,7 @@ import GHC.Data.FastString import Control.Monad ( guard ) import GHC.Data.Maybe ( orElse, isJust ) +import GHC.List (build) -- $type_classification -- #type_classification# @@ -2004,6 +2005,18 @@ splitPiTys ty = split ty ty [] split orig_ty ty bs | Just ty' <- coreView ty = split orig_ty ty' bs split orig_ty _ bs = (reverse bs, orig_ty) +collectPiTyBinders :: Type -> [PiTyBinder] +collectPiTyBinders ty = build $ \c n -> + let + split (ForAllTy b res) = Named b `c` split res + split (FunTy { ft_af = af, ft_mult = w, ft_arg = arg, ft_res = res }) + = Anon (Scaled w arg) af `c` split res + split ty | Just ty' <- coreView ty = split ty' + split _ = n + in + split ty +{-# INLINE collectPiTyBinders #-} + -- | Extracts a list of run-time arguments from a function type, -- looking through newtypes to the right of arrows. -- ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -1256,18 +1256,23 @@ in this (which it previously was): in \w. v True -} --------------------- -exprIsWorkFree :: CoreExpr -> Bool -- See Note [exprIsWorkFree] -exprIsWorkFree e = exprIsCheapX isWorkFreeApp e - -exprIsCheap :: CoreExpr -> Bool -exprIsCheap e = exprIsCheapX isCheapApp e +------------------------------------- +type CheapAppFun = Id -> Arity -> Bool + -- Is an application of this function to n *value* args + -- always cheap, assuming the arguments are cheap? + -- True mainly of data constructors, partial applications; + -- but with minor variations: + -- isWorkFreeApp + -- isCheapApp + -- isExpandableApp -exprIsCheapX :: CheapAppFun -> CoreExpr -> Bool +exprIsCheapX :: CheapAppFun -> Bool -> CoreExpr -> Bool {-# INLINE exprIsCheapX #-} --- allow specialization of exprIsCheap and exprIsWorkFree +-- allow specialization of exprIsCheap, exprIsWorkFree and exprIsExpandable -- instead of having an unknown call to ok_app -exprIsCheapX ok_app e +-- expandable: Only True for exprIsExpandable, where Case and Let are never +-- expandable. +exprIsCheapX ok_app expandable e = ok e where ok e = go 0 e @@ -1291,90 +1296,26 @@ exprIsCheapX ok_app e | otherwise = go n e go n (App f e) | isRuntimeArg e = go (n+1) f && ok e | otherwise = go n f - go n (Let (NonRec _ r) e) = go n e && ok r - go n (Let (Rec prs) e) = go n e && all (ok . snd) prs + go n (Let (NonRec _ r) e) = not expandable && go n e && ok r + go n (Let (Rec prs) e) = not expandable && go n e && all (ok . snd) prs -- Case: see Note [Case expressions are work-free] -- App, Let: see Note [Arguments and let-bindings exprIsCheapX] +-------------------- +exprIsWorkFree :: CoreExpr -> Bool +-- See Note [exprIsWorkFree] +exprIsWorkFree e = exprIsCheapX isWorkFreeApp False e -{- Note [exprIsExpandable] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -An expression is "expandable" if we are willing to duplicate it, if doing -so might make a RULE or case-of-constructor fire. Consider - let x = (a,b) - y = build g - in ....(case x of (p,q) -> rhs)....(foldr k z y).... - -We don't inline 'x' or 'y' (see Note [Lone variables] in GHC.Core.Unfold), -but we do want - - * the case-expression to simplify - (via exprIsConApp_maybe, exprIsLiteral_maybe) - - * the foldr/build RULE to fire - (by expanding the unfolding during rule matching) - -So we classify the unfolding of a let-binding as "expandable" (via the -uf_expandable field) if we want to do this kind of on-the-fly -expansion. Specifically: - -* True of constructor applications (K a b) - -* True of applications of a "CONLIKE" Id; see Note [CONLIKE pragma] in GHC.Types.Basic. - (NB: exprIsCheap might not be true of this) - -* False of case-expressions. If we have - let x = case ... in ...(case x of ...)... - we won't simplify. We have to inline x. See #14688. - -* False of let-expressions (same reason); and in any case we - float lets out of an RHS if doing so will reveal an expandable - application (see SimplEnv.doFloatFromRhs). - -* Take care: exprIsExpandable should /not/ be true of primops. I - found this in test T5623a: - let q = /\a. Ptr a (a +# b) - in case q @ Float of Ptr v -> ...q... - - q's inlining should not be expandable, else exprIsConApp_maybe will - say that (q @ Float) expands to (Ptr a (a +# b)), and that will - duplicate the (a +# b) primop, which we should not do lightly. - (It's quite hard to trigger this bug, but T13155 does so for GHC 8.0.) --} +-------------------- +exprIsCheap :: CoreExpr -> Bool +-- See Note [exprIsCheap] +exprIsCheap e = exprIsCheapX isCheapApp False e -------------------------------------- +-------------------- exprIsExpandable :: CoreExpr -> Bool -- See Note [exprIsExpandable] -exprIsExpandable e - = ok e - where - ok e = go 0 e - - -- n is the number of value arguments - go n (Var v) = isExpandableApp v n - go _ (Lit {}) = True - go _ (Type {}) = True - go _ (Coercion {}) = True - go n (Cast e _) = go n e - go n (Tick t e) | tickishCounts t = False - | otherwise = go n e - go n (Lam x e) | isRuntimeVar x = n==0 || go (n-1) e - | otherwise = go n e - go n (App f e) | isRuntimeArg e = go (n+1) f && ok e - | otherwise = go n f - go _ (Case {}) = False - go _ (Let {}) = False - - -------------------------------------- -type CheapAppFun = Id -> Arity -> Bool - -- Is an application of this function to n *value* args - -- always cheap, assuming the arguments are cheap? - -- True mainly of data constructors, partial applications; - -- but with minor variations: - -- isWorkFreeApp - -- isCheapApp +exprIsExpandable e = exprIsCheapX isExpandableApp True e isWorkFreeApp :: CheapAppFun isWorkFreeApp fn n_val_args @@ -1394,7 +1335,7 @@ isCheapApp fn n_val_args | isDeadEndId fn = True -- See Note [isCheapApp: bottoming functions] | otherwise = case idDetails fn of - DataConWorkId {} -> True -- Actually handled by isWorkFreeApp + -- DataConWorkId {} -> _ -- Handled by isWorkFreeApp RecSelId {} -> n_val_args == 1 -- See Note [Record selection] ClassOpId {} -> n_val_args == 1 PrimOpId op _ -> primOpIsCheap op @@ -1409,6 +1350,7 @@ isExpandableApp fn n_val_args | isWorkFreeApp fn n_val_args = True | otherwise = case idDetails fn of + -- DataConWorkId {} -> _ -- Handled by isWorkFreeApp RecSelId {} -> n_val_args == 1 -- See Note [Record selection] ClassOpId {} -> n_val_args == 1 PrimOpId {} -> False @@ -1440,6 +1382,50 @@ isExpandableApp fn n_val_args I'm not sure why we have a special case for bottoming functions in isCheapApp. Maybe we don't need it. +Note [exprIsExpandable] +~~~~~~~~~~~~~~~~~~~~~~~ +An expression is "expandable" if we are willing to duplicate it, if doing +so might make a RULE or case-of-constructor fire. Consider + let x = (a,b) + y = build g + in ....(case x of (p,q) -> rhs)....(foldr k z y).... + +We don't inline 'x' or 'y' (see Note [Lone variables] in GHC.Core.Unfold), +but we do want + + * the case-expression to simplify + (via exprIsConApp_maybe, exprIsLiteral_maybe) + + * the foldr/build RULE to fire + (by expanding the unfolding during rule matching) + +So we classify the unfolding of a let-binding as "expandable" (via the +uf_expandable field) if we want to do this kind of on-the-fly +expansion. Specifically: + +* True of constructor applications (K a b) + +* True of applications of a "CONLIKE" Id; see Note [CONLIKE pragma] in GHC.Types.Basic. + (NB: exprIsCheap might not be true of this) + +* False of case-expressions. If we have + let x = case ... in ...(case x of ...)... + we won't simplify. We have to inline x. See #14688. + +* False of let-expressions (same reason); and in any case we + float lets out of an RHS if doing so will reveal an expandable + application (see SimplEnv.doFloatFromRhs). + +* Take care: exprIsExpandable should /not/ be true of primops. I + found this in test T5623a: + let q = /\a. Ptr a (a +# b) + in case q @ Float of Ptr v -> ...q... + + q's inlining should not be expandable, else exprIsConApp_maybe will + say that (q @ Float) expands to (Ptr a (a +# b)), and that will + duplicate the (a +# b) primop, which we should not do lightly. + (It's quite hard to trigger this bug, but T13155 does so for GHC 8.0.) + Note [isExpandableApp: bottoming functions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's important that isExpandableApp does not respond True to bottoming @@ -1620,7 +1606,7 @@ expr_ok fun_ok primop_ok other_expr _ -> False ----------------------------- -app_ok :: (Id -> Bool) -> (PrimOp -> Bool) -> Id -> [CoreExpr] -> Bool +app_ok :: (Id -> Bool) -> (PrimOp -> Bool) -> Id -> [CoreArg] -> Bool app_ok fun_ok primop_ok fun args | not (fun_ok fun) = False -- This code path is only taken for Note [Speculative evaluation] @@ -1635,13 +1621,11 @@ app_ok fun_ok primop_ok fun args -- DFuns terminate, unless the dict is implemented -- with a newtype in which case they may not - DataConWorkId {} -> args_ok - -- The strictness of the constructor has already - -- been expressed by its "wrapper", so we don't need - -- to take the arguments into account - -- Well, we thought so. But it's definitely wrong! - -- See #20749 and Note [How untagged pointers can - -- end up in strict fields] in GHC.Stg.InferTags + DataConWorkId dc + | Just str_marks <- dataConRepStrictness_maybe dc + -> fields_ok str_marks + | otherwise + -> args_ok ClassOpId _ is_terminating_result | is_terminating_result -- See Note [exprOkForSpeculation and type classes] @@ -1691,7 +1675,7 @@ app_ok fun_ok primop_ok fun args -- Even if a function call itself is OK, any unlifted -- args are still evaluated eagerly and must be checked - args_ok = and (zipWith arg_ok arg_tys args) + args_ok = all2Prefix arg_ok arg_tys args arg_ok :: PiTyVarBinder -> CoreExpr -> Bool arg_ok (Named _) _ = True -- A type argument arg_ok (Anon ty _) arg -- A term argument @@ -1700,6 +1684,17 @@ app_ok fun_ok primop_ok fun args | otherwise = expr_ok fun_ok primop_ok arg + -- Used for DataCon worker arguments + fields_ok str_marks = all3Prefix field_ok str_marks arg_tys args + field_ok :: StrictnessMark -> PiTyVarBinder -> CoreExpr -> Bool + field_ok _ (Named _) _ = True + field_ok str (Anon ty _) arg + | NotMarkedStrict <- str -- iff it's a lazy field + , definitelyLiftedType (scaledThing ty) -- and its type is lifted + = True -- then the worker app does not eval + | otherwise + = expr_ok fun_ok primop_ok arg + ----------------------------- altsAreExhaustive :: [Alt b] -> Bool -- True <=> the case alternatives are definitely exhaustive @@ -1925,12 +1920,14 @@ exprIsConLike = exprIsHNFlike isConLikeId isConLikeUnfolding -- or PAPs. -- exprIsHNFlike :: HasDebugCallStack => (Var -> Bool) -> (Unfolding -> Bool) -> CoreExpr -> Bool -exprIsHNFlike is_con is_con_unf = is_hnf_like +exprIsHNFlike is_con is_con_unf e + = -- pprTraceWith "hnf" (\r -> ppr r <+> ppr e) $ + is_hnf_like e where is_hnf_like (Var v) -- NB: There are no value args at this point - = id_app_is_value v 0 -- Catches nullary constructors, - -- so that [] and () are values, for example - -- and (e.g.) primops that don't have unfoldings + = id_app_is_value v [] -- Catches nullary constructors, + -- so that [] and () are values, for example + -- and (e.g.) primops that don't have unfoldings || is_con_unf (idUnfolding v) -- Check the thing's unfolding; it might be bound to a value -- or to a guaranteed-evaluated variable (isEvaldUnfolding) @@ -1954,7 +1951,7 @@ exprIsHNFlike is_con is_con_unf = is_hnf_like -- See Note [exprIsHNF Tick] is_hnf_like (Cast e _) = is_hnf_like e is_hnf_like (App e a) - | isValArg a = app_is_value e 1 + | isValArg a = app_is_value e [a] | otherwise = is_hnf_like e is_hnf_like (Let _ e) = is_hnf_like e -- Lazy let(rec)s don't affect us is_hnf_like (Case e b _ as) @@ -1962,26 +1959,53 @@ exprIsHNFlike is_con is_con_unf = is_hnf_like = is_hnf_like rhs is_hnf_like _ = False - -- 'n' is the number of value args to which the expression is applied - -- And n>0: there is at least one value argument - app_is_value :: CoreExpr -> Int -> Bool - app_is_value (Var f) nva = id_app_is_value f nva - app_is_value (Tick _ f) nva = app_is_value f nva - app_is_value (Cast f _) nva = app_is_value f nva - app_is_value (App f a) nva - | isValArg a = - app_is_value f (nva + 1) && - not (needsCaseBinding (exprType a) a) - -- For example f (x /# y) where f has arity two, and the first - -- argument is unboxed. This is not a value! - -- But f 34# is a value. - -- NB: Check app_is_value first, the arity check is cheaper - | otherwise = app_is_value f nva - app_is_value _ _ = False - - id_app_is_value id n_val_args - = is_con id - || idArity id > n_val_args + -- Collect arguments through Casts and Ticks and call id_app_is_value + app_is_value :: CoreExpr -> [CoreArg] -> Bool + app_is_value (Var f) as = id_app_is_value f as + app_is_value (Tick _ f) as = app_is_value f as + app_is_value (Cast f _) as = app_is_value f as + app_is_value (App f a) as | isValArg a = app_is_value f (a:as) + | otherwise = app_is_value f as + app_is_value _ _ = False + + id_app_is_value id val_args + -- First handle saturated applications of DataCons with strict fields + | Just dc <- isDataConWorkId_maybe id -- DataCon + , Just str_marks <- dataConRepStrictness_maybe dc -- with strict fields + , assert (val_args `leLength` str_marks) True + , val_args `equalLength` str_marks -- in a saturated app + = all3Prefix check_field str_marks (mapMaybe anonPiTyBinderType_maybe (collectPiTyBinders (idType id))) val_args + + -- Now all applications except saturated DataCon apps with strict fields + | idArity id > length val_args + -- PAP: Check unlifted val_args + || is_con id && isNothing (isDataConWorkId_maybe id >>= dataConRepStrictness_maybe) + -- Either a lazy DataCon or a CONLIKE. + -- Hence we only need to check unlifted val_args here. + -- NB: We assume that CONLIKEs are lazy, which is their entire + -- point. + = all2Prefix check_arg (mapMaybe anonPiTyBinderType_maybe (collectPiTyBinders (idType id))) val_args + + | otherwise + = False + where + -- fun_ty = idType id + -- arg_tys = collectPiTyBinders fun_ty + -- val_arg_tys = mapMaybe anonPiTyBinderType_maybe arg_tys + -- val_arg_tys = map exprType val_args, but much less costly. + -- The obvious definition regresses T16577 by 30% so we don't do it. + + check_arg a_ty a = mightBeUnliftedType a_ty ==> is_hnf_like a + -- Check unliftedness; for example f (x /# 12#) where f has arity two, + -- and the first argument is unboxed. This is not a value! + -- But f 34# is a value, so check args for HNFs. + -- NB: We check arity (and CONLIKEness) first because it's cheaper + -- and we reject quickly on saturated apps. + check_field str a_ty a + = isMarkedStrict str || mightBeUnliftedType a_ty ==> is_hnf_like a + a ==> b = not a || b + infixr 1 ==> +{-# INLINE exprIsHNFlike #-} {- Note [exprIsHNF Tick] @@ -2543,7 +2567,7 @@ This means the seqs on x and y both become no-ops and compared to the first vers The downside is that the caller of $wfoo potentially has to evaluate `y` once if we can't prove it isn't already evaluated. But y coming out of a strict field is in WHNF so safe to evaluated. And most of the time it will be properly tagged+evaluated -already at the call site because of the Strict Field Invariant! See Note [Strict Field Invariant] for more in this. +already at the call site because of the Strict Field Invariant! See Note [STG Strict Field Invariant] for more in this. This makes GHC itself around 1% faster despite doing slightly more work! So this is generally quite good. We only apply this when we think there is a benefit in doing so however. There are a number of cases in which ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -677,9 +677,11 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $ -- Note [Silly extra arguments] (do { v <- newVar (idType bndr) - ; let float = mkFloat env topDmd False v rhs2 + ; let float@(Float (NonRec v' _) _ _) = + mkFloat env topDmd False v rhs2 + -- v' has demand info and possibly evaldUnfolding ; return ( snocFloat floats2 float - , cpeEtaExpand arity (Var v)) }) + , cpeEtaExpand arity (Var v')) }) -- Wrap floating ticks ; let (floats4, rhs4) = wrapTicks floats3 rhs3 @@ -1503,8 +1505,10 @@ cpeArg env dmd arg else do { v <- newVar arg_ty -- See Note [Eta expansion of arguments in CorePrep] ; let arg3 = cpeEtaExpandArg env arg2 - arg_float = mkFloat env dmd is_unlifted v arg3 - ; return (snocFloat floats2 arg_float, varToCoreExpr v) } + arg_float@(Float (NonRec v' _) _ _) = + mkFloat env dmd is_unlifted v arg3 + -- v' has demand info and possibly evaldUnfolding + ; return (snocFloat floats2 arg_float, varToCoreExpr v') } } cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg @@ -1937,12 +1941,11 @@ instance Outputable Floats where mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ - Float (NonRec bndr' rhs) bound info + Float (NonRec bndr2 rhs) bound info where - bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats] (bound,info) - | is_lifted, is_hnf = (BoundVal, TopLvlFloatable) - -- is_lifted: We currently don't allow unlifted values at the + | is_hnf, is_boxed = (BoundVal, TopLvlFloatable) + -- is_lifted: We currently don't allow unboxed values at the -- top-level or inside letrecs -- (but SG thinks that in principle, we should) | exprIsTickedString rhs = (CaseBound, TopLvlFloatable) @@ -1961,11 +1964,21 @@ mkFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkFloat" ppr $ -- And these float freely but can't be speculated, hence LetBound is_lifted = not is_unlifted + is_boxed = isBoxedType (idType bndr) is_hnf = exprIsHNF rhs is_strict = isStrUsedDmd dmd ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs is_rec_call = (`elemUnVarSet` cpe_rec_ids env) + bndr1 = bndr `setIdDemandInfo` dmd -- See Note [Pin demand info on floats] + bndr2 + | is_hnf + -- Otherwise, exprIsHNF must be conservative when bndr occurs as a strict + -- field arg. Result: More allocation in $walexGetByte. + = bndr1 `setIdUnfolding` evaldUnfolding + | otherwise + = bndr1 + emptyFloats :: Floats emptyFloats = Floats nilOL nilOL nilOL ===================================== compiler/GHC/Stg/InferTags.hs ===================================== @@ -64,8 +64,8 @@ With nofib being ~0.3% faster as well. See Note [Tag inference passes] for how we proceed to generate and use this information. -Note [Strict Field Invariant] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [STG Strict Field Invariant] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As part of tag inference we introduce the Strict Field Invariant. Which consists of us saying that: @@ -124,15 +124,33 @@ Note that there are similar constraints around Note [CBV Function Ids]. Note [How untagged pointers can end up in strict fields] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Since the resolution of #20749 where Core passes assume that DataCon workers +evaluate their strict fields, it is pretty simple to see how the Simplifier +might exploit that knowledge to drop evals. Example: + + data MkT a = MkT !a + f :: [Int] -> T [Int] + f xs = xs `seq` MkT xs + +in Core we will have + + f = \xs -> MkT @[Int] xs + +No eval left there. + Consider data Set a = Tip | Bin !a (Set a) (Set a) We make a wrapper for Bin that evaluates its arguments $WBin x a b = case x of xv -> Bin xv a b Here `xv` will always be evaluated and properly tagged, just as the -Strict Field Invariant requires. +Note [STG Strict Field Invariant] requires. + +But alas, the Simplifier can destroy the invariant: see #15696. +Indeed, as Note [Strict fields in Core] explains, Core passes +assume that Data constructor workers evaluate their strict fields, +so the Simplifier will drop seqs freely. -But alas the Simplifier can destroy the invariant: see #15696. We start with thk = f () g x = ...(case thk of xv -> Bin xv Tip Tip)... @@ -153,7 +171,7 @@ Now you can see that the argument of Bin, namely thk, points to the thunk, not to the value as it did before. In short, although it may be rare, the output of optimisation passes -cannot guarantee to obey the Strict Field Invariant. For this reason +cannot guarantee to obey the Note [STG Strict Field Invariant]. For this reason we run tag inference. See Note [Tag inference passes]. Note [Tag inference passes] @@ -163,7 +181,7 @@ Tag inference proceeds in two passes: The result is then attached to /binders/. This is implemented by `inferTagsAnal` in GHC.Stg.InferTags * The second pass walks over the AST checking if the Strict Field Invariant is upheld. - See Note [Strict Field Invariant]. + See Note [STG Strict Field Invariant]. If required this pass modifies the program to uphold this invariant. Tag information is also moved from /binders/ to /occurrences/ during this pass. This is done by `GHC.Stg.InferTags.Rewrite (rewriteTopBinds)`. ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -65,7 +65,7 @@ The work of this pass is simple: * For any strict field we check if the argument is known to be properly tagged. * If it's not known to be properly tagged, we wrap the whole thing in a case, which will force the argument before allocation. -This is described in detail in Note [Strict Field Invariant]. +This is described in detail in Note [STG Strict Field Invariant]. The only slight complication is that we have to make sure not to invalidate free variable analysis in the process. @@ -218,7 +218,7 @@ When compiling bytecode we call myCoreToStg to get STG code first. myCoreToStg in turn calls out to stg2stg which runs the STG to STG passes followed by free variables analysis and the tag inference pass including it's rewriting phase at the end. -Running tag inference is important as it upholds Note [Strict Field Invariant]. +Running tag inference is important as it upholds Note [STG Strict Field Invariant]. While code executed by GHCi doesn't take advantage of the SFI it can call into compiled code which does. So it must still make sure that the SFI is upheld. See also #21083 and #22042. ===================================== compiler/GHC/Tc/TyCl/Build.hs ===================================== @@ -183,14 +183,15 @@ buildDataCon fam_envs dc_bang_opts src_name declared_infix prom_info src_bangs tag = lookupNameEnv_NF tag_map src_name -- See Note [Constructor tag allocation], fixes #14657 data_con = mkDataCon src_name declared_infix prom_info - src_bangs field_lbls + src_bangs impl_bangs str_marks field_lbls univ_tvs ex_tvs noConcreteTyVars user_tvbs eq_spec ctxt arg_tys res_ty NoPromInfo rep_tycon tag stupid_ctxt dc_wrk dc_rep dc_wrk = mkDataConWorkId work_name data_con - dc_rep = initUs_ us (mkDataConRep dc_bang_opts fam_envs wrap_name data_con) + (dc_rep, impl_bangs, str_marks) = + initUs_ us (mkDataConRep dc_bang_opts fam_envs wrap_name data_con) ; traceIf (text "buildDataCon 2" <+> ppr src_name) ; return data_con } ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -1385,33 +1385,8 @@ arguments. That is the job of dmdTransformDataConSig. More precisely, * it returns the demands on the arguments; in the above example that is [SL, A] -Nasty wrinkle. Consider this code (#22475 has more realistic examples but -assume this is what the demand analyser sees) - - data T = MkT !Int Bool - get :: T -> Bool - get (MkT _ b) = b - - foo = let v::Int = I# 7 - t::T = MkT v True - in get t - -Now `v` is unused by `get`, /but/ we can't give `v` an Absent demand, -else we'll drop the binding and replace it with an error thunk. -Then the code generator (more specifically GHC.Stg.InferTags.Rewrite) -will add an extra eval of MkT's argument to give - foo = let v::Int = error "absent" - t::T = case v of v' -> MkT v' True - in get t - -Boo! Because of this extra eval (added in STG-land), the truth is that `MkT` -may (or may not) evaluate its arguments (as established in #21497). Hence the -use of `bump` in dmdTransformDataConSig, which adds in a `C_01` eval. The -`C_01` says "may or may not evaluate" which is absolutely faithful to what -InferTags.Rewrite does. - -In particular it is very important /not/ to make that a `C_11` eval, -see Note [Data-con worker strictness]. +When the data constructor worker has strict fields, they act as additional +seqs; hence we add an additional `C_11` eval. -} {- ********************************************************************* @@ -1611,6 +1586,29 @@ a bad fit because expression may not throw a precise exception (increasing precision of the analysis), but that's just a favourable guess. +Note [Side-effects and strictness] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Due to historic reasons and the continued effort not to cause performance +regressions downstream, Strictness Analysis is currently prone to discarding +observable side-effects (other than precise exceptions, see +Note [Precise exceptions and strictness analysis]) in some cases. For example, + f :: MVar () -> Int -> IO Int + f mv x = putMVar mv () >> (x `seq` return x) +The call to `putMVar` is an observable side-effect. Yet, Strictness Analysis +currently concludes that `f` is strict in `x` and uses call-by-value. +That means `f mv (error "boom")` will error out with the imprecise exception +rather performing the side-effect. + +This is a conscious violation of the semantics described in the paper +"a semantics for imprecise exceptions"; so it would be great if we could +identify the offending primops and extend the idea in +Note [Which scrutinees may throw precise exceptions] to general side-effects. + +Unfortunately, the existing has-side-effects classification for primops is +too conservative, listing `writeMutVar#` and even `readMutVar#` as +side-effecting. That is due to #3207. A possible way forward is described in +#17900, but no effort has been so far towards a resolution. + Note [Exceptions and strictness] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to smart about catching exceptions, but we aren't anymore. @@ -2327,7 +2325,7 @@ dmdTransformDataConSig str_marks sd = case viewProd arity body_sd of mk_body_ty n dmds = DmdType nopDmdEnv (zipWith (bump n) str_marks dmds) bump n str dmd | isMarkedStrict str = multDmd n (plusDmd str_field_dmd dmd) | otherwise = multDmd n dmd - str_field_dmd = C_01 :* seqSubDmd -- Why not C_11? See Note [Data-con worker strictness] + str_field_dmd = C_11 :* seqSubDmd -- See Note [Strict fields in Core] -- | A special 'DmdTransformer' for dictionary selectors that feeds the demand -- on the result into the indicated dictionary component (if saturated). ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -260,7 +260,7 @@ The invariants around the arguments of call by value function like Ids are then: * Any `WorkerLikeId` * Some `JoinId` bindings. -This works analogous to the Strict Field Invariant. See also Note [Strict Field Invariant]. +This works analogous to the Strict Field Invariant. See also Note [STG Strict Field Invariant]. To make this work what we do is: * During W/W and SpecConstr any worker/specialized binding we introduce ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -58,7 +58,7 @@ import GHC.Core.Coercion import GHC.Core.Reduction import GHC.Core.Make import GHC.Core.FVs ( mkRuleInfo ) -import GHC.Core.Utils ( exprType, mkCast, mkDefaultCase, coreAltsType ) +import GHC.Core.Utils ( exprType, mkCast, coreAltsType ) import GHC.Core.Unfold.Make import GHC.Core.SimpleOpt import GHC.Core.TyCon @@ -594,8 +594,12 @@ mkDataConWorkId wkr_name data_con = mkGlobalId (DataConWorkId data_con) wkr_name wkr_ty alg_wkr_info where - tycon = dataConTyCon data_con -- The representation TyCon - wkr_ty = dataConRepType data_con + tycon = dataConTyCon data_con -- The representation TyCon + wkr_ty = dataConRepType data_con + univ_tvs = dataConUnivTyVars data_con + ex_tcvs = dataConExTyCoVars data_con + arg_tys = dataConRepArgTys data_con -- Should be same as dataConOrigArgTys + str_marks = dataConRepStrictness data_con ----------- Workers for data types -------------- alg_wkr_info = noCafIdInfo @@ -603,12 +607,19 @@ mkDataConWorkId wkr_name data_con `setInlinePragInfo` wkr_inline_prag `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated, -- even if arity = 0 + `setDmdSigInfo` wkr_sig + -- Workers eval their strict fields + -- See Note [Strict fields in Core] `setLFInfo` wkr_lf_info - -- No strictness: see Note [Data-con worker strictness] in GHC.Core.DataCon wkr_inline_prag = defaultInlinePragma { inl_rule = ConLike } wkr_arity = dataConRepArity data_con + wkr_sig = mkClosedDmdSig wkr_dmds topDiv + wkr_dmds = map mk_dmd str_marks + mk_dmd MarkedStrict = evalDmd + mk_dmd NotMarkedStrict = topDmd + -- See Note [LFInfo of DataCon workers and wrappers] wkr_lf_info | wkr_arity == 0 = LFCon data_con @@ -616,9 +627,6 @@ mkDataConWorkId wkr_name data_con -- LFInfo stores post-unarisation arity ----------- Workers for newtypes -------------- - univ_tvs = dataConUnivTyVars data_con - ex_tcvs = dataConExTyCoVars data_con - arg_tys = dataConRepArgTys data_con -- Should be same as dataConOrigArgTys nt_work_info = noCafIdInfo -- The NoCaf-ness is set by noCafIdInfo `setArityInfo` 1 -- Arity 1 `setInlinePragInfo` dataConWrapperInlinePragma @@ -786,10 +794,10 @@ mkDataConRep :: DataConBangOpts -> FamInstEnvs -> Name -> DataCon - -> UniqSM DataConRep + -> UniqSM (DataConRep, [HsImplBang], [StrictnessMark]) mkDataConRep dc_bang_opts fam_envs wrap_name data_con | not wrapper_reqd - = return NoDataConRep + = return (NoDataConRep, arg_ibangs, rep_strs) | otherwise = do { wrap_args <- mapM (newLocal (fsLit "conrep")) wrap_arg_tys @@ -853,11 +861,8 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con ; return (DCR { dcr_wrap_id = wrap_id , dcr_boxer = mk_boxer boxers - , dcr_arg_tys = rep_tys - , dcr_stricts = rep_strs - -- For newtypes, dcr_bangs is always [HsLazy]. - -- See Note [HsImplBangs for newtypes]. - , dcr_bangs = arg_ibangs }) } + , dcr_arg_tys = rep_tys } + , arg_ibangs, rep_strs) } where (univ_tvs, ex_tvs, eq_spec, theta, orig_arg_tys, _orig_res_ty) @@ -907,8 +912,8 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con -- (Most) newtypes have only a worker, with the exception -- of some newtypes written with GADT syntax. -- See dataConUserTyVarsNeedWrapper below. - && (any isBanged (ev_ibangs ++ arg_ibangs))) - -- Some forcing/unboxing (includes eq_spec) + && (any isUnpacked (ev_ibangs ++ arg_ibangs))) + -- Some unboxing (includes eq_spec) || isFamInstTyCon tycon -- Cast result || (dataConUserTyVarsNeedWrapper data_con -- If the data type was written with GADT syntax and @@ -1185,7 +1190,7 @@ dataConArgRep arg_ty HsLazy = ([(arg_ty, NotMarkedStrict)], (unitUnboxer, unitBoxer)) dataConArgRep arg_ty (HsStrict _) - = ([(arg_ty, MarkedStrict)], (seqUnboxer, unitBoxer)) + = ([(arg_ty, MarkedStrict)], (unitUnboxer, unitBoxer)) -- Seqs are inserted in STG dataConArgRep arg_ty (HsUnpack Nothing) = dataConArgUnpack arg_ty @@ -1215,9 +1220,6 @@ wrapCo co rep_ty (unbox_rep, box_rep) -- co :: arg_ty ~ rep_ty ; return (rep_ids, rep_expr `Cast` mkSymCo sco) } ------------------------ -seqUnboxer :: Unboxer -seqUnboxer v = return ([v], mkDefaultCase (Var v) v) - unitUnboxer :: Unboxer unitUnboxer v = return ([v], \e -> e) ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -27,7 +27,7 @@ module GHC.Utils.Misc ( dropWhileEndLE, spanEnd, last2, lastMaybe, onJust, - List.foldl1', foldl2, count, countWhile, all2, + List.foldl1', foldl2, count, countWhile, all2, all2Prefix, all3Prefix, lengthExceeds, lengthIs, lengthIsNot, lengthAtLeast, lengthAtMost, lengthLessThan, @@ -663,6 +663,29 @@ all2 _ [] [] = True all2 p (x:xs) (y:ys) = p x y && all2 p xs ys all2 _ _ _ = False +all2Prefix :: (a -> b -> Bool) -> [a] -> [b] -> Bool +-- ^ `all2Prefix p xs ys` is a fused version of `and $ zipWith2 p xs ys`. +-- So if one list is shorter than the other, `p` is assumed to be `True` for the +-- suffix. +all2Prefix p = foldr (\x go ys' -> case ys' of (y:ys'') -> p x y && go ys''; _ -> True) (\_ -> True) +{-# INLINE all2Prefix #-} +-- all2Prefix p xs ys = go xs ys +-- where go (x:xs) (y:ys) = p x y && go xs ys +-- go _ _ = True +-- {-# INLINABLE all2Prefix #-} + +all3Prefix :: (a -> b -> c -> Bool) -> [a] -> [b] -> [c] -> Bool +-- ^ `all3Prefix p xs ys zs` is a fused version of `and $ zipWith3 p xs ys zs`. +-- So if one list is shorter than the others, `p` is assumed to be `True` for +-- the suffix. +all3Prefix p xs ys zs = foldr (\y go xs' zs' -> case (xs',zs') of (x:xs'',z:zs'') -> p x y z && go xs'' zs''; _ -> False) (\_ _ -> True) ys xs zs +{-# INLINE all3Prefix #-} +-- all3Prefix p xs ys zs = go xs ys zs +-- where +-- go (x:xs) (y:ys) (z:zs) = p x y z && go xs ys zs +-- go _ _ _ = True +-- {-# INLINABLE all3Prefix #-} + -- Count the number of times a predicate is true count :: (a -> Bool) -> [a] -> Int ===================================== testsuite/tests/perf/compiler/T12545.hs ===================================== @@ -15,6 +15,29 @@ type instance ElemsOf A = [ T1, T2, T3, T4, T5, T6, T7, T8 , T25, T26, T27, T28, T29, T30, T31, T32 ] +{- Note [Sensitivity to unique increment] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +T12545 is sensitive to -dunique-increments changes, see #19414. I've seen +variations of as much as 4.8% by playing with that parameter. + +The issue with this test is that it does too little so is very sensitive to +any small variations during initialisation and in particular populating the +initial environments with wired-in things. Therefore it has a very high change +threshold so we catch if it regresses a lot but don't worry if it regresses a little. + +You can measure the variance by running T12545.measure.sh. + +Whenever we identify such a test (T8095 being another example), we leave a link +to this Note in the source code of the test *and* in the corresponding all.T, +detailing the spread as measured by adjusting T12545.measure.sh. +For example, + +# See Note [Sensitivity to unique increment] in T12545.hs; spread was 4.8% + +and then double the spread to come up with a stable acceptance threshold (e.g., +10%). +-} + data T1; instance ElemOf A T1 where data T2; instance ElemOf A T2 where data T3; instance ElemOf A T3 where ===================================== testsuite/tests/perf/compiler/T8095.hs ===================================== @@ -1,5 +1,6 @@ {-# OPTIONS_GHC -freduction-depth=1000 #-} {-# LANGUAGE TypeOperators,DataKinds,KindSignatures,TypeFamilies,PolyKinds,UndecidableInstances #-} +-- Subject to Note [Sensitivity to unique increment] with spread of 1.7% import GHC.TypeLits data Nat1 = Zero | Succ Nat1 type family Replicate1 (n :: Nat1) (x::a) :: [a] @@ -16,4 +17,3 @@ instance (xs ~ Replicate1 ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ f X = Y f Y = X test1 = f (X :: Data ( Replicate1 ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Zero ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) () )) - ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -167,9 +167,12 @@ test('T9872d', ], compile, ['']) +# Since major improvements to T8095 in in +# 4bf9fa0f216bb294c1bd3644363b008a8643a653 it is subject to +# Note [Sensitivity to unique increment] in T12545.hs; spread was 1.7% test ('T8095', [ only_ways(['normal']), - collect_compiler_stats('bytes allocated',2) ], + collect_compiler_stats('bytes allocated',4) ], compile, ['-v0 -O']) test ('T13386', @@ -270,15 +273,7 @@ test('T12234', compile, ['']) -# T12545 is sensitive to -dunique-increments changes, see #19414. I've seen -# variations of as much as 4.8% by playing with that parameter, -# -# The issue with the test is that it does too little so is very sensitive to -# any small variations during initialisation and in particular populating the -# initial environments with wired-in things. Therefore it has a very high change -# threshold so we catch if it regresses a lot but don't worry if it regresses a little. -# -# You can measure the variance by running T12545.measure.sh. +# See Note [Sensitivity to unique increment] in T12545.hs; spread was 4.8% test('T12545', [ only_ways(['normal']), collect_compiler_stats('bytes allocated', 10), # ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -417,7 +417,10 @@ test('T21391', normal, compile, ['-O -dcore-lint']) test('T22112', [ grep_errmsg('never matches') ], compile, ['-O -dsuppress-uniques -dno-typeable-binds -fexpose-all-unfoldings -ddump-simpl']) test('T21391a', normal, compile, ['-O -dcore-lint']) # We don't want to see a thunk allocation for the insertBy expression after CorePrep. -test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]'), expect_broken(21392) ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) +# Unfortunately, this test is no longer broken after we made workers strict in strict fields, +# so it is no longer a reproducer for T21392. Still, it doesn't hurt if we test that we don't +# regress again. +test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]') ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) test('T21689', [extra_files(['T21689a.hs'])], multimod_compile, ['T21689', '-v0 -O']) test('T21801', normal, compile, ['-O -dcore-lint']) test('T21848', [grep_errmsg(r'SPEC wombat') ], compile, ['-O -ddump-spec']) ===================================== testsuite/tests/simplStg/should_compile/inferTags002.stderr ===================================== @@ -1,88 +1,30 @@ -==================== Output Cmm ==================== -[M.$WMkT_entry() { // [R3, R2] - { info_tbls: [(cym, - label: block_cym_info - rep: StackRep [False] - srt: Nothing), - (cyp, - label: M.$WMkT_info - rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } - srt: Nothing), - (cys, - label: block_cys_info - rep: StackRep [False] - srt: Nothing)] - stack_info: arg_space: 8 - } - {offset - cyp: // global - if ((Sp + -16) < SpLim) (likely: False) goto cyv; else goto cyw; - cyv: // global - R1 = M.$WMkT_closure; - call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; - cyw: // global - I64[Sp - 16] = cym; - R1 = R2; - P64[Sp - 8] = R3; - Sp = Sp - 16; - if (R1 & 7 != 0) goto cym; else goto cyn; - cyn: // global - call (I64[R1])(R1) returns to cym, args: 8, res: 8, upd: 8; - cym: // global - I64[Sp] = cys; - _sy8::P64 = R1; - R1 = P64[Sp + 8]; - P64[Sp + 8] = _sy8::P64; - call stg_ap_0_fast(R1) returns to cys, args: 8, res: 8, upd: 8; - cys: // global - Hp = Hp + 24; - if (Hp > HpLim) (likely: False) goto cyA; else goto cyz; - cyA: // global - HpAlloc = 24; - call stg_gc_unpt_r1(R1) returns to cys, args: 8, res: 8, upd: 8; - cyz: // global - I64[Hp - 16] = M.MkT_con_info; - P64[Hp - 8] = P64[Sp + 8]; - P64[Hp] = R1; - R1 = Hp - 15; - Sp = Sp + 16; - call (P64[Sp])(R1) args: 8, res: 0, upd: 8; - } - }, - section ""data" . M.$WMkT_closure" { - M.$WMkT_closure: - const M.$WMkT_info; - }] - - - ==================== Output Cmm ==================== [M.f_entry() { // [R2] - { info_tbls: [(cyK, - label: block_cyK_info + { info_tbls: [(cAs, + label: block_info rep: StackRep [] srt: Nothing), - (cyN, + (cAv, label: M.f_info rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } srt: Nothing)] stack_info: arg_space: 8 } {offset - cyN: // global - if ((Sp + -8) < SpLim) (likely: False) goto cyO; else goto cyP; - cyO: // global + _lbl_: // global + if ((Sp + -8) < SpLim) (likely: False) goto cAw; else goto cAx; + _lbl_: // global R1 = M.f_closure; call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; - cyP: // global - I64[Sp - 8] = cyK; + _lbl_: // global + I64[Sp - 8] = cAs; R1 = R2; Sp = Sp - 8; - if (R1 & 7 != 0) goto cyK; else goto cyL; - cyL: // global - call (I64[R1])(R1) returns to cyK, args: 8, res: 8, upd: 8; - cyK: // global + if (R1 & 7 != 0) goto cAs; else goto cAt; + _lbl_: // global + call (I64[R1])(R1) returns to cAs, args: 8, res: 8, upd: 8; + _lbl_: // global R1 = P64[R1 + 15]; Sp = Sp + 8; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; @@ -97,47 +39,47 @@ ==================== Output Cmm ==================== [M.MkT_entry() { // [R3, R2] - { info_tbls: [(cz1, - label: block_cz1_info + { info_tbls: [(cAJ, + label: block_info rep: StackRep [False] srt: Nothing), - (cz4, + (cAM, label: M.MkT_info rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } srt: Nothing), - (cz7, - label: block_cz7_info + (cAP, + label: block_info rep: StackRep [False] srt: Nothing)] stack_info: arg_space: 8 } {offset - cz4: // global - if ((Sp + -16) < SpLim) (likely: False) goto cza; else goto czb; - cza: // global + _lbl_: // global + if ((Sp + -16) < SpLim) (likely: False) goto cAS; else goto cAT; + _lbl_: // global R1 = M.MkT_closure; call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; - czb: // global - I64[Sp - 16] = cz1; + _lbl_: // global + I64[Sp - 16] = cAJ; R1 = R2; P64[Sp - 8] = R3; Sp = Sp - 16; - if (R1 & 7 != 0) goto cz1; else goto cz2; - cz2: // global - call (I64[R1])(R1) returns to cz1, args: 8, res: 8, upd: 8; - cz1: // global - I64[Sp] = cz7; - _tyf::P64 = R1; + if (R1 & 7 != 0) goto cAJ; else goto cAK; + _lbl_: // global + call (I64[R1])(R1) returns to cAJ, args: 8, res: 8, upd: 8; + _lbl_: // global + I64[Sp] = cAP; + __locVar_::P64 = R1; R1 = P64[Sp + 8]; - P64[Sp + 8] = _tyf::P64; - call stg_ap_0_fast(R1) returns to cz7, args: 8, res: 8, upd: 8; - cz7: // global + P64[Sp + 8] = __locVar_::P64; + call stg_ap_0_fast(R1) returns to cAP, args: 8, res: 8, upd: 8; + _lbl_: // global Hp = Hp + 24; - if (Hp > HpLim) (likely: False) goto czf; else goto cze; - czf: // global + if (Hp > HpLim) (likely: False) goto cAX; else goto cAW; + _lbl_: // global HpAlloc = 24; - call stg_gc_unpt_r1(R1) returns to cz7, args: 8, res: 8, upd: 8; - cze: // global + call stg_gc_unpt_r1(R1) returns to cAP, args: 8, res: 8, upd: 8; + _lbl_: // global I64[Hp - 16] = M.MkT_con_info; P64[Hp - 8] = P64[Sp + 8]; P64[Hp] = R1; @@ -155,14 +97,14 @@ ==================== Output Cmm ==================== [M.MkT_con_entry() { // [] - { info_tbls: [(czl, + { info_tbls: [(cB3, label: M.MkT_con_info rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} } srt: Nothing)] stack_info: arg_space: 8 } {offset - czl: // global + _lbl_: // global R1 = R1 + 1; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } ===================================== testsuite/tests/stranal/sigs/T16859.stderr ===================================== @@ -4,7 +4,7 @@ T16859.bar: <1!A> T16859.baz: <1L><1!P(L)><1C(1,L)> T16859.buz: <1!P(L,L)> T16859.foo: <1L> -T16859.mkInternalName: <1!P(L)><1L><1L> +T16859.mkInternalName: <1!P(L)> T16859.n_loc: <1!P(A,A,A,1L)> T16859.n_occ: <1!P(A,1!P(L,L),A,A)> T16859.n_sort: <1!P(1L,A,A,A)> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/17e3307f5cfe6ef84f151a1500d56e93ca608604...7febfe8f1790eb79e325529bc23763bd47d6a2a1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/17e3307f5cfe6ef84f151a1500d56e93ca608604...7febfe8f1790eb79e325529bc23763bd47d6a2a1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 17 11:41:39 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 17 Oct 2023 07:41:39 -0400 Subject: [Git][ghc/ghc][wip/T17910] Wibble spec_constr_inhibition Message-ID: <652e72f3ad0dd_7336f58982d50290494@gitlab.mail> Simon Peyton Jones pushed to branch wip/T17910 at Glasgow Haskell Compiler / GHC Commits: 9cd9e338 by Simon Peyton Jones at 2023-10-17T12:41:20+01:00 Wibble spec_constr_inhibition - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -46,7 +46,6 @@ import GHC.Prelude hiding (head, init, last, tail) import qualified GHC.Prelude as Partial (head) import GHC.Core -import GHC.Core.Predicate( isDictId ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Inline import GHC.Core.Opt.Stats ( Tick(..) ) @@ -1422,10 +1421,10 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env one_occ IAmDead = True -- Happens in ((\x.1) v) one_occ OneOcc{ occ_n_br = 1, occ_in_lam = in_lam, occ_int_cxt = int_cxt } - | is_value_lam rhs, IsInteresting <- int_cxt + | is_value_lam, IsInteresting <- int_cxt = True | NotInsideLam <- in_lam - , not (isDictId bndr) -- Solely for SpecConstr + , not spec_constr_inhibition -- , not (isTopLevel top_lvl) || not (exprIsExpandable rhs) -- Inline used-once things; except expandable things at top level -- These may arise from user code e.g. @@ -1438,9 +1437,21 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env = False one_occ _ = False - is_value_lam (Lam b e) = isRuntimeVar b || is_value_lam e - is_value_lam (Tick t e) = not (tickishIsCode t) && is_value_lam e - is_value_lam _ = False + spec_constr_inhibition + = sePhase env == FinalPhase && (is_dfun_app || is_value_lam) + + is_value_lam = go rhs + where + go (Lam b e) = isRuntimeVar b || go e + go (Tick t e) = not (tickishIsCode t) && go e + go _ = False + + is_dfun_app = go rhs + where + go (Var f) = isDFunId f + go (App f _) = go f + go (Tick t e) = not (tickishIsCode t) && go e + go _ = False {- one_occ OneOcc{ occ_n_br = 1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9cd9e338456eb59590018806e43d632638d915ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9cd9e338456eb59590018806e43d632638d915ec You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 17 14:39:22 2023 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 17 Oct 2023 10:39:22 -0400 Subject: [Git][ghc/ghc][wip/enable-late-ccs-release] 467 commits: nativeGen: Explicitly set flags of text sections on Windows Message-ID: <652e9c9aca9dd_7336f5d032bb0317016@gitlab.mail> Matthew Pickering pushed to branch wip/enable-late-ccs-release at Glasgow Haskell Compiler / GHC Commits: 3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. - - - - - db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Set explicit section types on all platforms - - - - - b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00 Insert documentation into parsed signature modules Causes haddock comments in signature modules to be properly inserted into the AST (just as they are for regular modules) if the `-haddock` flag is given. Also adds a test that compares `-ddump-parsed-ast` output for a signature module to prevent further regressions. Fixes #23315 - - - - - c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00 primops: Introduce unsafeThawByteArray# This addresses an odd asymmetry in the ByteArray# primops, which previously provided unsafeFreezeByteArray# but no corresponding thaw operation. Closes #22710 - - - - - 87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00 testsuite: Elaborate in interface stability README This discussion didn't make it into the original MR. - - - - - e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00 Allow users to override non-essential haddock options in a Flavour We now supply the non-essential options to haddock using the `extraArgs` field, which can be specified in a Flavour so that if an advanced user wants to change how documentation is generated then they can use something other than the `defaultHaddockExtraArgs`. This does have the potential to regress some packaging if a user has overridden `extraArgs` themselves, because now they also need to add the haddock options to extraArgs. This can easily be done by appending `defaultHaddockExtraArgs` to their extraArgs invocation but someone might not notice this behaviour has changed. In any case, I think passing the non-essential options in this manner is the right thing to do and matches what we do for the "ghc" builder, which by default doesn't pass any optmisation levels, and would likewise be very bad if someone didn't pass suitable `-O` levels for builds. Fixes #23625 - - - - - fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00 ghc-prim: Link against libatomic Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures. Unfortunately this made GHC to fail to build on armel, since armel needs libatomic to support atomic operations on 64-bit word sizes. Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic, the same way as we do in rts/rts.cabal. - - - - - 4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00 simplifier: Correct InScopeSet in rule matching The in-scope set passedto the `exprIsLambda_maybe` call lacked all the in-scope binders. @simonpj suggests this fix where we augment the in-scope set with the free variables of expression which fixes this failure mode in quite a direct way. Fixes #23630 - - - - - 5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00 Add a test for #23413 It was fixed by commit e1590ddc661d6: Add the SolverStage monad. - - - - - 7e05f6df by sheaf at 2023-07-21T23:26:56-04:00 Finish migration of diagnostics in GHC.Tc.Validity This patch finishes migrating the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It also refactors the error message datatypes for class and family instances, to common them up under a single datatype as much as possible. - - - - - 4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00 ci: Enable some more jobs to run in a marge batch In !10907 I made the majority of jobs not run on a validate pipeline but then forgot to renable a select few jobs on the marge batch MR. - - - - - 026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00 user_guide/flags.py: python-3.12 no longer includes distutils packaging.version seems able to handle this fine - - - - - b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00 ci: Mention ~full-ci label in MR template We mention that if you need a full validation pipeline then you can apply the ~full-ci label to your MR in order to test against the full validation pipeline (like we do for marge). - - - - - 42b05e9b by sheaf at 2023-07-22T12:36:00-04:00 RTS: declare setKeepCAFs symbol Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on the symbol setKeepCAFs in the RTS, which led to undefined symbol errors on Windows, as exhibited by the testcase frontend001. Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix. Fixes #22961 - - - - - a72015d6 by sheaf at 2023-07-22T12:36:01-04:00 Mark plugins-external as broken on Windows This test is broken on Windows, so we explicitly mark it as such now that we stop skipping plugin tests on Windows. - - - - - cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00 Stop marking plugin tests as fragile on Windows Now that b2bb3e62 has landed we are in a better situation with regards to plugins on Windows, allowing us to unmark many plugin tests as fragile. Fixes #16405 - - - - - a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00 Misc cleanup - Remove unused RDR names - Fix typos in comments - Deriving: simplify boxConTbl and remove unused litConTbl - chmod -x GHC/Exts.hs, this seems accidental - - - - - 33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00 Visible forall in types of terms: Part 1 (#22326) This patch implements part 1 of GHC Proposal #281, introducing explicit `type` patterns and `type` arguments. Summary of the changes: 1. New extension flag: RequiredTypeArguments 2. New user-facing syntax: `type p` patterns (represented by EmbTyPat) `type e` expressions (represented by HsEmbTy) 3. Functions with required type arguments (visible forall) can now be defined and applied: idv :: forall a -> a -> a -- signature (relevant change: checkVdqOK in GHC/Tc/Validity.hs) idv (type a) (x :: a) = x -- definition (relevant change: tcPats in GHC/Tc/Gen/Pat.hs) x = idv (type Int) 42 -- usage (relevant change: tcInstFun in GHC/Tc/Gen/App.hs) 4. template-haskell support: TH.TypeE corresponds to HsEmbTy TH.TypeP corresponds to EmbTyPat 5. Test cases and a new User's Guide section Changes *not* included here are the t2t (term-to-type) transformation and term variable capture; those belong to part 2. - - - - - 73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00 Add test for #22424 This is a simple Template Haskell test in which we refer to record selectors by their exact Names, in two different ways. Fixes #22424 - - - - - 83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00 ghc-toolchain: Initial commit - - - - - 31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 ghc-toolchain: Toolchain Selection This commit integrates ghc-toolchain, the brand new way of configuring toolchains for GHC, with the Hadrian build system, with configure, and extends and improves the first iteration of ghc-toolchain. The general overview is * We introduce a program invoked `ghc-toolchain --triple=...` which, when run, produces a file with a `Target`. A `GHC.Toolchain.Target.Target` describes the properties of a target and the toolchain (executables and configured flags) to produce code for that target * Hadrian was modified to read Target files, and will both * Invoke the toolchain configured in the Target file as needed * Produce a `settings` file for GHC based on the Target file for that stage * `./configure` will invoke ghc-toolchain to generate target files, but it will also generate target files based on the flags configure itself configured (through `.in` files that are substituted) * By default, the Targets generated by configure are still (for now) the ones used by Hadrian * But we additionally validate the Target files generated by ghc-toolchain against the ones generated by configure, to get a head start on catching configuration bugs before we transition completely. * When we make that transition, we will want to drop a lot of the toolchain configuration logic from configure, but keep it otherwise. * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine) * We just have a HOST target file, which we use as the target for stage0 * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling) * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST * (for more details on cross-compilation see discussion on !9263) See also * Note [How we configure the bundled windows toolchain] * Note [ghc-toolchain consistency checking] * Note [ghc-toolchain overview] Ticket: #19877 MR: !9263 - - - - - a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Add flag to enable/disable ghc-toolchain based configurations This flag is disabled by default, and we'll use the configure-generated-toolchains by default until we remove the toolchain configuration logic from configure. - - - - - 61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Split ghc-toolchain executable to new packge In light of #23690, we split the ghc-toolchain executable out of the library package to be able to ship it in the bindist using Hadrian. Ideally, we eventually revert this commit. - - - - - 38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Ship ghc-toolchain in the bindist Add the ghc-toolchain binary to the binary distribution we ship to users, and teach the bindist configure to use the existing ghc-toolchain. - - - - - 32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00 Kill off gen_bytearray_addr_access_ops.py The relevant primop descriptions are now generated directly by genprimopcode. This makes progress toward fixing #23490, but it is not a complete fix since there is more than one way in which cabal-reinstall (hadrian/build build-cabal) is broken. - - - - - 02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00 compiler: Remove unused `containers.h` include Fixes #23712 - - - - - 822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00 Fix pretty printing of WARNING pragmas There is still something quite unsavoury going on with WARNING pragma printing because the printing relies on the fact that for decl deprecations the SourceText of WarningTxt is empty. However, I let that lion sleep and just fixed things directly. Fixes #23465 - - - - - e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00 ci-images: Bump to commit which has 9.6 image The test-bootstrap job has been failing for 9.6 because we accidentally used a non-master commit. - - - - - bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00 Update bootstrap plans for 9.6.2 and 9.4.5 - - - - - 355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00 EPA: Simplify GHC/Parser.y comb4/comb5 Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with anything with a SrcSpan Also get rid of some more now unnecessary reLoc calls. - - - - - 9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00 compiler: make -ddump-asm work with wasm backend NCG Fixes #23503. Now the `-ddump-asm` flag is respected in the wasm backend NCG, so developers can directly view the generated ASM instead of needing to pass `-S` or `-keep-tmp-files` and manually find & open the assembly file. Ideally, we should be able to output the assembly files in smaller chunks like in other NCG backends. This would also make dumping assembly stats easier. However, this would require a large refactoring, so for short-term debugging purposes I think the current approach works fine. Signed-off-by: Gavin Zhao <git at gzgz.dev> - - - - - 79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00 llvm: Restore accidentally deleted code in 0fc5cb97 Fixes #23711 - - - - - 20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00 configure: Default missing options to False when preparing ghc-toolchain Targets This commit fixes building ghc with 9.2 as the boostrap compiler. The ghc-toolchain patch assumed all _STAGE0 options were available, and forgot to account for this missing information in 9.2. Ghc 9.2 does not have in settings whether ar supports -l, hence can't report it with --info (unliked 9.4 upwards). The fix is to default the missing information (we default "ar supports -l" and other missing options to False) - - - - - fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00 docs: Fix typo - - - - - 503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00 This MR is an implementation of the proposal #516. It adds a warning -Wincomplete-record-selectors for usages of a record field access function (either a record selector or getField @"rec"), while trying to silence the warning whenever it can be sure that a constructor without the record field would not be invoked (which would otherwise cause the program to fail). For example: data T = T1 | T2 {x :: Bool} f a = x a -- this would throw an error g T1 = True g a = x a -- this would not throw an error h :: HasField "x" r Bool => r -> Bool h = getField @"x" j :: T -> Bool j = h -- this would throw an error because of the `HasField` -- constraint being solved See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning. See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details - - - - - af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00 Fix user-facing label in MR template - - - - - 5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00 ci: Test bootstrapping configurations with full-ci and on marge batches There have been two incidents recently where bootstrapping has been broken by removing support for building with 9.2.*. The process for bumping the minimum required version starts with bumping the configure version and then other CI jobs such as the bootstrap jobs have to be updated. We must not silently bump the minimum required version. Now we are running a slimmed down validate pipeline it seems worthwile to test these bootstrap configurations in the full-ci pipeline. - - - - - 25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Remove ghc-9_2_* plans We are anticipating shortly making it necessary to use ghc-9.4 to boot the compiler. - - - - - 2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00 Update bootstrap plans for ghc-platform and ghc-toolchain dependencies Fixes #23735 - - - - - c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Disable -selftest flag from bootstrap plans This saves on building one dependency (QuickCheck) which is unecessary for bootstrapping. - - - - - a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00 Link reference paper and package from System.Mem.{StableName,Weak} - - - - - a5319358 by David Knothe at 2023-07-28T13:13:10-04:00 Update Match Datatype EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation. All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list. We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows: data EquationInfo = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo } | EqnDone { eqn_rhs = MatchResult CoreExpr } An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated. - - - - - 86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00 Improve documentation for Data.Fixed - - - - - f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00 ghc-prim: Use C11 atomics Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*` family of C builtins. Here we refactor these to rather use the appropriate C11 atomic equivalents, allowing us to be more explicit about the expected ordering semantics. - - - - - 0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00 Include -haddock in DynFlags fingerprint The -haddock flag determines whether or not the resulting .hi files contain haddock documentation strings. If the existing .hi files do not contain haddock documentation strings and the user requests them, we should recompile. - - - - - 40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00 Bump filepath submodule to 1.4.100.4 Resolves #23741 Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T12234 T12425 T13035 T13701 T13719 T16875 T18304 T18698a T18698b T21839c T9198 TcPlugin_RewritePerf hard_hole_fits Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183 - - - - - ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00 Add since pragmas to GHC.IO.Handle.FD - - - - - d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00 Make the occurrence analyser smarter about join points This MR addresses #22404. There is a big Note Note [Occurrence analysis for join points] that explains it all. Significant changes * New field occ_join_points in OccEnv * The NonRec case of occAnalBind splits into two cases: one for existing join points (which does the special magic for Note [Occurrence analysis for join points], and one for other bindings. * mkOneOcc adds in info from occ_join_points. * All "bring into scope" activity is centralised in the new function `addInScope`. * I made a local data type LocalOcc for use inside the occurrence analyser It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn makes computationns over it simpler and more efficient. * I found quite a bit of allocation in GHC.Core.Rules.getRules so I optimised it a bit. More minor changes * I found I was using (Maybe Arity) a lot, so I defined a new data type JoinPointHood and used it everwhere. This touches a lot of non-occ-anal files, but it makes everything more perspicuous. * Renamed data constructor WithUsageDetails to WUD, and WithTailUsageDetails to WTUD This also fixes #21128, on the way. --------- Compiler perf ----------- I spent quite a time on performance tuning, so even though it does more than before, the occurrence analyser runs slightly faster on average. Here are the compile-time allocation changes over 0.5% CoOpt_Read(normal) ghc/alloc 766,025,520 754,561,992 -1.5% CoOpt_Singletons(normal) ghc/alloc 759,436,840 762,925,512 +0.5% LargeRecord(normal) ghc/alloc 1,814,482,440 1,799,530,456 -0.8% PmSeriesT(normal) ghc/alloc 68,159,272 67,519,720 -0.9% T10858(normal) ghc/alloc 120,805,224 118,746,968 -1.7% T11374(normal) ghc/alloc 164,901,104 164,070,624 -0.5% T11545(normal) ghc/alloc 79,851,808 78,964,704 -1.1% T12150(optasm) ghc/alloc 73,903,664 71,237,544 -3.6% GOOD T12227(normal) ghc/alloc 333,663,200 331,625,864 -0.6% T12234(optasm) ghc/alloc 52,583,224 52,340,344 -0.5% T12425(optasm) ghc/alloc 81,943,216 81,566,720 -0.5% T13056(optasm) ghc/alloc 294,517,928 289,642,512 -1.7% T13253-spj(normal) ghc/alloc 118,271,264 59,859,040 -49.4% GOOD T15164(normal) ghc/alloc 1,102,630,352 1,091,841,296 -1.0% T15304(normal) ghc/alloc 1,196,084,000 1,166,733,000 -2.5% T15630(normal) ghc/alloc 148,729,632 147,261,064 -1.0% T15703(normal) ghc/alloc 379,366,664 377,600,008 -0.5% T16875(normal) ghc/alloc 32,907,120 32,670,976 -0.7% T17516(normal) ghc/alloc 1,658,001,888 1,627,863,848 -1.8% T17836(normal) ghc/alloc 395,329,400 393,080,248 -0.6% T18140(normal) ghc/alloc 71,968,824 73,243,040 +1.8% T18223(normal) ghc/alloc 456,852,568 453,059,088 -0.8% T18282(normal) ghc/alloc 129,105,576 131,397,064 +1.8% T18304(normal) ghc/alloc 71,311,712 70,722,720 -0.8% T18698a(normal) ghc/alloc 208,795,112 210,102,904 +0.6% T18698b(normal) ghc/alloc 230,320,736 232,697,976 +1.0% BAD T19695(normal) ghc/alloc 1,483,648,128 1,504,702,976 +1.4% T20049(normal) ghc/alloc 85,612,024 85,114,376 -0.6% T21839c(normal) ghc/alloc 415,080,992 410,906,216 -1.0% GOOD T4801(normal) ghc/alloc 247,590,920 250,726,272 +1.3% T6048(optasm) ghc/alloc 95,699,416 95,080,680 -0.6% T783(normal) ghc/alloc 335,323,384 332,988,120 -0.7% T9233(normal) ghc/alloc 709,641,224 685,947,008 -3.3% GOOD T9630(normal) ghc/alloc 965,635,712 948,356,120 -1.8% T9675(optasm) ghc/alloc 444,604,152 428,987,216 -3.5% GOOD T9961(normal) ghc/alloc 303,064,592 308,798,800 +1.9% BAD WWRec(normal) ghc/alloc 503,728,832 498,102,272 -1.1% geo. mean -1.0% minimum -49.4% maximum +1.9% In fact these figures seem to vary between platforms; generally worse on i386 for some reason. The Windows numbers vary by 1% espec in benchmarks where the total allocation is low. But the geom mean stays solidly negative, which is good. The "increase/decrease" list below covers all platforms. The big win on T13253-spj comes because it has a big nest of join points, each occurring twice in the next one. The new occ-anal takes only one iteration of the simplifier to do the inlining; the old one took four. Moreover, we get much smaller code with the new one: New: Result size of Tidy Core = {terms: 429, types: 84, coercions: 0, joins: 14/14} Old: Result size of Tidy Core = {terms: 2,437, types: 304, coercions: 0, joins: 10/10} --------- Runtime perf ----------- No significant changes in nofib results, except a 1% reduction in compiler allocation. Metric Decrease: CoOpt_Read T13253-spj T9233 T9630 T9675 T12150 T21839c LargeRecord MultiComponentModulesRecomp T10421 T13701 T10421 T13701 T12425 Metric Increase: T18140 T9961 T18282 T18698a T18698b T19695 - - - - - 42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00 Improve documentation around IOException and ioe_filename See: * https://github.com/haskell/core-libraries-committee/issues/189 * https://github.com/haskell/unix/pull/279 * https://github.com/haskell/unix/pull/289 - - - - - 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - cf481cf0 by Matthew Pickering at 2023-10-17T15:38:37+01:00 packaging: Enable late-ccs for perf (and hence release) flavours This enables late cost centres when building profiled libraries and subsequently greatly improves the resolution of cost centre stacks when profiling. Fixes #21732 - - - - - 4a301a1d by Matthew Pickering at 2023-10-17T15:38:58+01:00 late cost centre: Don't insert cost centre for exprIsWorkFree - - - - - 19 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - .gitlab/generate-ci/generate-job-metadata - .gitlab/generate-ci/generate-jobs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md - .gitlab/jobs.yaml - .gitlab/merge_request_templates/Default.md - .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py - .gitlab/rel_eng/upload.sh - .gitlab/rel_eng/upload_ghc_libs.py - .gitlab/test-metrics.sh - README.md - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df1e3d3731b45a0cc024b6fd4e815e774ebad4d0...4a301a1de2bf5bb65d330133028a32e8c5390b91 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df1e3d3731b45a0cc024b6fd4e815e774ebad4d0...4a301a1de2bf5bb65d330133028a32e8c5390b91 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 12:10:47 2023 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Wed, 18 Oct 2023 08:10:47 -0400 Subject: [Git][ghc/ghc][wip/jsbits-userguide] JS/userguide: wip explanation of writing jsbits Message-ID: <652fcb479273e_7336f7a4fd0c4371946@gitlab.mail> Josh Meredith pushed to branch wip/jsbits-userguide at Glasgow Haskell Compiler / GHC Commits: 6da72a0a by Josh Meredith at 2023-10-18T23:10:33+11:00 JS/userguide: wip explanation of writing jsbits - - - - - 1 changed file: - docs/users_guide/javascript.rst Changes: ===================================== docs/users_guide/javascript.rst ===================================== @@ -1,7 +1,7 @@ .. _ffi-javascript: FFI and the JavaScript Backend -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +============================== .. index:: single: FFI and the JavaScript Backend @@ -22,8 +22,46 @@ look like: foreign import javascript "((x,y) => { return x + y; })" js_add :: Int -> Int -> Int +.. _`JavaScript FFI Types`: + +JavaScript FFI Types +-------------------- + +Some types are able to be used directly in the type signatures of foreign +exports, without conversion to a ``JSVal``. We saw in the first example +that ``Int`` is one of these. + +There are a number of supported types that can be passed directly in this +way, and they act as primitives within GHC's JavaScript RTS. This is in +comparison to data structures that are implemented in Haskell, such as +``String`` - being a list, this doesn't have a primitive JavaScript implementation, +and isn't equivalent to a JavaScript string. + +The following types are supported in this way: + +* ``Int``, including ``Int32`` and other sized numerical values. +* ``Int64``, and other 64 bit numbers are passed as two variables to the function, + where the first includes the sign and the higher bits +* ``Bool`` +* ``Char`` +* ``Any`` +* ``ByteArray#`` +* ``Double`` and ``Float`` +* ``MVar#``, and other RTS objects +* Unboxed tuples (e.g. ``(# a, b #)``) can appear in the return type, and are + constructed in JavaScript using macros such as ``RETURN_UBX_TUP2(x, y)``. + +As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so +the following example would compile successfully - despite `5` not being a valid JavaScript value +for the Haskell `Bool` type: + +.. code-block:: haskell + + foreign import javascript "((x) => { return 5; })" + type_error :: Bool -> Bool + JSVal -~~~~~ +^^^^^ The JavaScript backend has a concept of an untyped 'plain' JavaScript value, under the guise of the type ``JSVal``. Values having this type @@ -46,36 +84,9 @@ It also contains functions for working with objects: * ``isUndefined :: JSVal -> Bool`` - test for the JavaScript ``undefined`` * ``getProp :: JSVal -> String -> JSVal`` - object field access -JavaScript FFI Types -~~~~~~~~~~~~~~~~~~~~ - -Some types are able to be used directly in the type signatures of foreign -exports, without conversion to a ``JSVal``. We saw in the first example -that ``Int`` is one of these. - -The supported types are those with primitive JavaScript representations -that match the Haskell type. This means types such as the Haskell ``String`` -type aren't supported directly, because they're lists - which don't have -a primitive JavaScript representation, and so are incompatible with each -other. - -The following types are supported in this way: - -* ``Int`` -* ``Bool`` -* ``Char`` - -As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so -the following example would compile successfully - despite `5` not being a valid JavaScript value -for the Haskell `Bool` type: - -.. code-block:: haskell - - foreign import javascript "((x) => { return 5; })" - type_error :: Bool -> Bool JavaScript Callbacks -~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^ The JavaScript execution model is based around callback functions, and GHC's JavaScript backend implements these as a type in order to support @@ -173,3 +184,239 @@ We have to make sure not to use ``releaseCallback`` on any functions that are to be available in HTML, because we want these functions to be in memory indefinitely. +Writing ``jsbits`` for Libraries with C FFI Functions +----------------------------------------------------- + +Many libraries make use of C FFI functions to accomplish low-level or +performance sensitive operations - known as ``cbits`` and often kept in +a folder with this name. For such a library to support the JavaScript +backend, the ``cbits`` must have replacement implementations. Similar to +the ``cbits``, JavaScript FFI files are known as the ``jsbits``. + +In principle, it is possible for the JavaScript backend to automatically +compile ``cbits`` using Emscripten, but this requires wrappers to convert +data between the JS backend's RTS data format, and the format expected by +Emscripten-compiled functions. Since C functions are often used where +performance is more critical, there's potential for the data conversions +to negate this purpose. + +Instead, it is more effective for a library to provide an alternate +implementation for functions using the C FFI - either by providing direct +one-to-one replacement JavaScript functions, or by using C preprocessor +directives to replace C FFI imports with some combination of JS FFI imports +and pure-Haskell implementation. + +Direct Implementation of C FFI Imports in JavaScript +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When the JavaScript backend generates code for a C FFI import, it will call +the function named in the import string, prepended by ``h$`` - so the imported +C function ``open`` will look for the JavaScript function ``h$open``. No verification +is done to ensure that these functions are actually implemented in the linked +JavaScript files, so there can be runtime errors when a missing JavaScript +function is called. + +Based on this, implementing a C function in JavaScript is a matter of providing +a function of the correct shape (based on the C FFI import type signature) in +any of the linked JavaScript sources. External JavaScript sources are linked +by either providing them as an argument to GHC, or listing them in the ``js-sources`` +field of the cabal file - in which case it would usually be inside a predicate to +detect the ``javascript`` architecture, such as: + +.. code-block:: cabal + + library + + if arch(javascript) + js-sources: + jsbits/example.js + +Note that ``js-sources`` requires Cabal 3.10 to be used with library targets, and +Cabal 3.12 to be used with executable targets. + +The shape required of the JavaScript function will depend on the particular +C types used: + +* primitives, such as ``CInt`` will map directly to a single JavaScript argument + using JavaScript primitives. In the case of ``CInt``, this will be a JavaScript + number. Note that in the case of return values, a JavaScript number will usually + need to be rounded or cast back to an integral value in cases where mathematical + operations are used + +* pointer values, including ``CString``, are passed as an unboxed ``(ptr, offset)`` + pair. For arguments, being unboxed will mean these are passed as two top-level + arguments to the function. For return values, unboxed values are returned using + a special C preprocessor macro, ``RETURN_UBX_TUP2(ptr, offset)`` + +* ``CString``, in addition to the above pointer handling, will need to be decoded + and encoded to convert them between character arrays and JavaScript strings. + +* other RTS primitive types are discussed previously in `JavaScript FFI Types`_. + +As an example, let's consider the implementation of ``getcwd``: + +.. code-block:: haskell + + -- unix:System.Posix.Directory + + foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar) + +.. code-block:: javascript + + // libraries/base/jsbits/base.js + + //#OPTIONS: CPP + + function h$getcwd(buf, off, buf_size) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + RETURN_UBX_TUP2(null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } + +Here, the C function ``getcwd`` maps to the JavaScript function ``h$getcwd``, which +exists in a ``.js`` file within ``base``'s ``jsbits`` subdirectory. ``h$getcwd`` +expects a ``CString`` (passed as the equivalent ``Ptr CChar``) and a +``CSize`` argument. This results in three arguments to the JavaScript function - two +for the string's pointer and offset, and one for the size, which will be passed as a +JavaScript number. + +Next, the JavaScript ``h$getcwd`` function demonstrates a several details: + +* In the try clause, the ``cwd`` value is first accessed using a NodeJS-provided method. + This value is immediately encoded using ``h$encodeUtf8``, which is provided by the + JavaScript backend. This function will only return the pointer for the encoded value, + and the offset will always be 0 + +* Next, we select one of several cases - based on the specification of the C function + that we're trying to immitate + +* In the first case where the given buffer size is too small, but not zero, the function + must set the ``ERANGE`` error code, which we do here with ``h$setErrno``, and return + ``null``. As we saw in the function arguments, pointers are passed as a ``(ptr, offset)`` + pair - meaning ``null`` is represented by returning the unboxed pair ``(null, 0)`` + +* In the second case where there is enough space in ``buf`` to successfully copy the + bytes, we do so using ``h$copyMutableByteArray`` - a function supplied by GHC's JavaScript + RTS + +* In the third case where ``buf_size`` is 0, this indicates in the C function's specification + that we can allocate a new buffer of the appropriate size to return. We already have + this in the form of the previously encoded ``cwd``, so we can just return it, along + with the 0 offset + +* In the last case where ``buf`` is null, and ``buf_size`` is large enough, we allocate a + new buffer, this time with ``buf_size`` bytes of space using ``h$newByteArray``, and + we again perform a mutable copy + +* To use C preprocessor macros in linked JavaScript files, the file must open with the + ``//#OPTIONS: CPP`` line, as is shown towards the start of this snippet + +* If an error occurs, the catch clause will pass it to ``h$setErrno`` and return the + ``(null, 0)`` pointer and offset pair - which is a behaviour expected by the C function + in the error case. + +Writing JavaScript Functions to be NodeJS and Browser Aware +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In the above example of implementing ``getcwd``, the function we use in the JavaScript +implementation is from NodeJS, and the behaviour doesn't make sense to implement in a +browser. Therefore, the actual implementation will include a C preprocessor condition +to check if we're compiling for the browser, in which case ``h$unsupported(-1)`` will +be called. There can be multiple non-browser JavaScript runtimes, so we'll also have +to check at runtime to make sure that NodeJS is in use. + +.. code-block:: javascript + + function h$getcwd(buf, off, buf_size) { + #ifndef GHCJS_BROWSER + if (h$isNode()) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + return (null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } else + #endif + h$unsupported(-1); + } + +Using the C Preprocessor to Replace C FFI Imports +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Instead of providing a direct JavaScript implementation for each C FFI import, we can +instead use the C preprocessor to conditionally remove these C imports (and possibly +use sites as well). Then, some combination of JavaScript FFI imports and Haskell +implementation can be added instead. As in the direct implementation section, any +linked JavaScript files should usually be in a ``if arch(javascript)`` condition in +the cabal file. + +As an example of a mixed Haskell and JavaScript implementation replacing a C +implementation, consider ``base:GHC.Clock``: + +.. code-block:: haskell + + #if defined(javascript_HOST_ARCH) + getMonotonicTimeNSec :: IO Word64 + getMonotonicTimeNSec = do + w <- getMonotonicTimeMSec + return (floor w * 1000000) + + foreign import javascript unsafe "performance.now" + getMonotonicTimeMSec :: IO Double + + #else + foreign import ccall unsafe "getMonotonicNSec" + getMonotonicTimeNSec :: IO Word64 + #endif + +Here, the ``getMonotonicTimeNSec`` C FFI import is replaced by the JavaScript FFI +import ``getMonotonicTimeMSec``, which imports the standard JavaScript function +``performance.now``. However, because this JavaScript implementation +returns the time as a ``Double`` of floating point milliseconds, it must be wrapped +by a Haskell function to extract the integral value that's expected. + +In this case, the choice of using a mixed Haskell and JavaScript replacement +implementation was caused by the limitation of clocks being system calls. In a lot +of cases, C functions are used for similar system-level functionality. In such +cases, it's recommended to import the required system functions from standard +JavaScript libraries (or NodeJS/browser, as was required for ``getcwd``), and +use Haskell wrapper functions to convert the imported functions to the appropriate +format. + +In other cases, C functions are used for performance. For these cases, pure-Haskell +implementations are the preferred first step for compatability with the JavaScript +backend since it would be more future-proof against changes to the RTS data format. +Depending on the use case, compiler-optimised JS code might be hard to complete with +using hand-written JavaScript. Generally, the most likely performance gains from +hand-written JavaScript come from functions with data that stays as JavaScript +primitive types for a long time, especially strings. For this, ``JSVal`` allows +values to be passed between ``Haskell`` and ``JavaScript`` without a marshalling +penalty. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6da72a0adcd0f9e4c0ee3efc7e8be869c5fe7753 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6da72a0adcd0f9e4c0ee3efc7e8be869c5fe7753 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 12:24:49 2023 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Wed, 18 Oct 2023 08:24:49 -0400 Subject: [Git][ghc/ghc][wip/jsbits-userguide] JS/userguide: wip explanation of writing jsbits Message-ID: <652fce9123828_7336f7b0cc7ec3742e1@gitlab.mail> Josh Meredith pushed to branch wip/jsbits-userguide at Glasgow Haskell Compiler / GHC Commits: b57871dc by Josh Meredith at 2023-10-18T23:24:37+11:00 JS/userguide: wip explanation of writing jsbits - - - - - 1 changed file: - docs/users_guide/javascript.rst Changes: ===================================== docs/users_guide/javascript.rst ===================================== @@ -1,7 +1,7 @@ .. _ffi-javascript: FFI and the JavaScript Backend -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +============================== .. index:: single: FFI and the JavaScript Backend @@ -22,8 +22,46 @@ look like: foreign import javascript "((x,y) => { return x + y; })" js_add :: Int -> Int -> Int +.. _`JavaScript FFI Types`: + +JavaScript FFI Types +-------------------- + +Some types are able to be used directly in the type signatures of foreign +exports, without conversion to a ``JSVal``. We saw in the first example +that ``Int`` is one of these. + +There are a number of supported types that can be passed directly in this +way, and they act as primitives within GHC's JavaScript RTS. This is in +comparison to data structures that are implemented in Haskell, such as +``String`` - being a list, this doesn't have a primitive JavaScript implementation, +and isn't equivalent to a JavaScript string. + +The following types are supported in this way: + +* ``Int``, including ``Int32`` and other sized numerical values. +* ``Int64``, and other 64 bit numbers are passed as two variables to the function, + where the first includes the sign and the higher bits +* ``Bool`` +* ``Char`` +* ``Any`` +* ``ByteArray#`` +* ``Double`` and ``Float`` +* ``MVar#``, and other RTS objects +* Unboxed tuples (e.g. ``(# a, b #)``) can appear in the return type, and are + constructed in JavaScript using macros such as ``RETURN_UBX_TUP2(x, y)``. + +As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so +the following example would compile successfully - despite `5` not being a valid JavaScript value +for the Haskell `Bool` type: + +.. code-block:: haskell + + foreign import javascript "((x) => { return 5; })" + type_error :: Bool -> Bool + JSVal -~~~~~ +^^^^^ The JavaScript backend has a concept of an untyped 'plain' JavaScript value, under the guise of the type ``JSVal``. Values having this type @@ -46,36 +84,9 @@ It also contains functions for working with objects: * ``isUndefined :: JSVal -> Bool`` - test for the JavaScript ``undefined`` * ``getProp :: JSVal -> String -> JSVal`` - object field access -JavaScript FFI Types -~~~~~~~~~~~~~~~~~~~~ - -Some types are able to be used directly in the type signatures of foreign -exports, without conversion to a ``JSVal``. We saw in the first example -that ``Int`` is one of these. - -The supported types are those with primitive JavaScript representations -that match the Haskell type. This means types such as the Haskell ``String`` -type aren't supported directly, because they're lists - which don't have -a primitive JavaScript representation, and so are incompatible with each -other. - -The following types are supported in this way: - -* ``Int`` -* ``Bool`` -* ``Char`` - -As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so -the following example would compile successfully - despite `5` not being a valid JavaScript value -for the Haskell `Bool` type: - -.. code-block:: haskell - - foreign import javascript "((x) => { return 5; })" - type_error :: Bool -> Bool JavaScript Callbacks -~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^ The JavaScript execution model is based around callback functions, and GHC's JavaScript backend implements these as a type in order to support @@ -173,3 +184,241 @@ We have to make sure not to use ``releaseCallback`` on any functions that are to be available in HTML, because we want these functions to be in memory indefinitely. +Writing ``jsbits`` for Libraries with C FFI Functions +----------------------------------------------------- + +Many libraries make use of C FFI functions to accomplish low-level or +performance sensitive operations - known as ``cbits`` and often kept in +a folder with this name. For such a library to support the JavaScript +backend, the ``cbits`` must have replacement implementations. Similar to +the ``cbits``, JavaScript FFI files are known as the ``jsbits``. + +In principle, it is possible for the JavaScript backend to automatically +compile ``cbits`` using Emscripten, but this requires wrappers to convert +data between the JS backend's RTS data format, and the format expected by +Emscripten-compiled functions. Since C functions are often used where +performance is more critical, there's potential for the data conversions +to negate this purpose. + +Instead, it is more effective for a library to provide an alternate +implementation for functions using the C FFI - either by providing direct +one-to-one replacement JavaScript functions, or by using C preprocessor +directives to replace C FFI imports with some combination of JS FFI imports +and pure-Haskell implementation. + +Direct Implementation of C FFI Imports in JavaScript +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When the JavaScript backend generates code for a C FFI import, it will call +the function named in the import string, prepended by ``h$`` - so the imported +C function ``open`` will look for the JavaScript function ``h$open``. No verification +is done to ensure that these functions are actually implemented in the linked +JavaScript files, so there can be runtime errors when a missing JavaScript +function is called. + +Based on this, implementing a C function in JavaScript is a matter of providing +a function of the correct shape (based on the C FFI import type signature) in +any of the linked JavaScript sources. External JavaScript sources are linked +by either providing them as an argument to GHC, or listing them in the ``js-sources`` +field of the cabal file - in which case it would usually be inside a predicate to +detect the ``javascript`` architecture, such as: + +.. code-block:: cabal + + library + + if arch(javascript) + js-sources: + jsbits/example.js + +Note that ``js-sources`` requires Cabal 3.10 to be used with library targets, and +Cabal 3.12 to be used with executable targets. + +The shape required of the JavaScript function will depend on the particular +C types used: + +* primitives, such as ``CInt`` will map directly to a single JavaScript argument + using JavaScript primitives. In the case of ``CInt``, this will be a JavaScript + number. Note that in the case of return values, a JavaScript number will usually + need to be rounded or cast back to an integral value in cases where mathematical + operations are used + +* pointer values, including ``CString``, are passed as an unboxed ``(ptr, offset)`` + pair. For arguments, being unboxed will mean these are passed as two top-level + arguments to the function. For return values, unboxed values should be returned + from JavaScript functions by using a special C preprocessor macro, + ``RETURN_UBX_TUP2(ptr, offset)`` + +* ``CString``, in addition to the above pointer handling, will need to be decoded + and encoded to convert them between character arrays and JavaScript strings. + +* other RTS primitive types are discussed previously in `JavaScript FFI Types`_. + +As an example, let's consider the implementation of ``getcwd``: + +.. code-block:: haskell + + -- unix:System.Posix.Directory + + foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar) + +.. code-block:: javascript + + // libraries/base/jsbits/base.js + + //#OPTIONS: CPP + + function h$getcwd(buf, off, buf_size) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + RETURN_UBX_TUP2(null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } + +Here, the C function ``getcwd`` maps to the JavaScript function ``h$getcwd``, which +exists in a ``.js`` file within ``base``'s ``jsbits`` subdirectory. ``h$getcwd`` +expects a ``CString`` (passed as the equivalent ``Ptr CChar``) and a +``CSize`` argument. This results in three arguments to the JavaScript function - two +for the string's pointer and offset, and one for the size, which will be passed as a +JavaScript number. + +Next, the JavaScript ``h$getcwd`` function demonstrates a several details: + +* In the try clause, the ``cwd`` value is first accessed using a NodeJS-provided method. + This value is immediately encoded using ``h$encodeUtf8``, which is provided by the + JavaScript backend. This function will only return the pointer for the encoded value, + and the offset will always be 0 + +* Next, we select one of several cases - based on the specification of the C function + that we're trying to immitate + +* In the first case where the given buffer size is too small, but not zero, the function + must set the ``ERANGE`` error code, which we do here with ``h$setErrno``, and return + ``null``. As we saw in the function arguments, pointers are passed as a ``(ptr, offset)`` + pair - meaning ``null`` is represented by returning the unboxed pair ``(null, 0)`` + +* In the second case where there is enough space in ``buf`` to successfully copy the + bytes, we do so using ``h$copyMutableByteArray`` - a function supplied by GHC's JavaScript + RTS + +* In the third case where ``buf_size`` is 0, this indicates in the C function's specification + that we can allocate a new buffer of the appropriate size to return. We already have + this in the form of the previously encoded ``cwd``, so we can just return it, along + with the 0 offset + +* In the last case where ``buf`` is null, and ``buf_size`` is large enough, we allocate a + new buffer, this time with ``buf_size`` bytes of space using ``h$newByteArray``, and + we again perform a mutable copy + +* To use C preprocessor macros in linked JavaScript files, the file must open with the + ``//#OPTIONS: CPP`` line, as is shown towards the start of this snippet + +* If an error occurs, the catch clause will pass it to ``h$setErrno`` and return the + ``(null, 0)`` pointer and offset pair - which is a behaviour expected by the C function + in the error case. + +Writing JavaScript Functions to be NodeJS and Browser Aware +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In the above example of implementing ``getcwd``, the function we use in the JavaScript +implementation is from NodeJS, and the behaviour doesn't make sense to implement in a +browser. Therefore, the actual implementation will include a C preprocessor condition +to check if we're compiling for the browser, in which case ``h$unsupported(-1)`` will +be called. There can be multiple non-browser JavaScript runtimes, so we'll also have +to check at runtime to make sure that NodeJS is in use. + +.. code-block:: javascript + + function h$getcwd(buf, off, buf_size) { + #ifndef GHCJS_BROWSER + if (h$isNode()) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + return (null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } else + #endif + h$unsupported(); + RETURN_UBX_TUP2(null, 0); + } + +Replacing C FFI Imports with Pure Haskell and JavaScript +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Instead of providing a direct JavaScript implementation for each C FFI import, we can +instead use the C preprocessor to conditionally remove these C imports (and possibly +use sites as well). Then, some combination of JavaScript FFI imports and Haskell +implementation can be added instead. As in the direct implementation section, any +linked JavaScript files should usually be in a ``if arch(javascript)`` condition in +the cabal file. + +As an example of a mixed Haskell and JavaScript implementation replacing a C +implementation, consider ``base:GHC.Clock``: + +.. code-block:: haskell + + #if defined(javascript_HOST_ARCH) + getMonotonicTimeNSec :: IO Word64 + getMonotonicTimeNSec = do + w <- getMonotonicTimeMSec + return (floor w * 1000000) + + foreign import javascript unsafe "performance.now" + getMonotonicTimeMSec :: IO Double + + #else + foreign import ccall unsafe "getMonotonicNSec" + getMonotonicTimeNSec :: IO Word64 + #endif + +Here, the ``getMonotonicTimeNSec`` C FFI import is replaced by the JavaScript FFI +import ``getMonotonicTimeMSec``, which imports the standard JavaScript function +``performance.now``. However, because this JavaScript implementation +returns the time as a ``Double`` of floating point milliseconds, it must be wrapped +by a Haskell function to extract the integral value that's expected. + +In this case, the choice of using a mixed Haskell and JavaScript replacement +implementation was caused by the limitation of clocks being system calls. In a lot +of cases, C functions are used for similar system-level functionality. In such +cases, it's recommended to import the required system functions from standard +JavaScript libraries (or from the runtime, as was required for ``getcwd``), and +use Haskell wrapper functions to convert the imported functions to the appropriate +format. + +In other cases, C functions are used for performance. For these cases, pure-Haskell +implementations are the preferred first step for compatability with the JavaScript +backend since it would be more future-proof against changes to the RTS data format. +Depending on the use case, compiler-optimised JS code might be hard to complete with +using hand-written JavaScript. Generally, the most likely performance gains from +hand-written JavaScript come from functions with data that stays as JavaScript +primitive types for a long time, especially strings. For this, ``JSVal`` allows +values to be passed between ``Haskell`` and ``JavaScript`` without a marshalling +penalty. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b57871dcb7b9cba3edcbbd80165cf092090fa4fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b57871dcb7b9cba3edcbbd80165cf092090fa4fa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 12:27:16 2023 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Wed, 18 Oct 2023 08:27:16 -0400 Subject: [Git][ghc/ghc][wip/jsbits-userguide] JS/userguide: wip explanation of writing jsbits Message-ID: <652fcf2467979_7336f7b0ae79c3748c0@gitlab.mail> Josh Meredith pushed to branch wip/jsbits-userguide at Glasgow Haskell Compiler / GHC Commits: 0d8f4e27 by Josh Meredith at 2023-10-18T23:27:06+11:00 JS/userguide: wip explanation of writing jsbits - - - - - 1 changed file: - docs/users_guide/javascript.rst Changes: ===================================== docs/users_guide/javascript.rst ===================================== @@ -1,7 +1,7 @@ .. _ffi-javascript: FFI and the JavaScript Backend -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +============================== .. index:: single: FFI and the JavaScript Backend @@ -22,8 +22,46 @@ look like: foreign import javascript "((x,y) => { return x + y; })" js_add :: Int -> Int -> Int +.. _`JavaScript FFI Types`: + +JavaScript FFI Types +-------------------- + +Some types are able to be used directly in the type signatures of foreign +exports, without conversion to a ``JSVal``. We saw in the first example +that ``Int`` is one of these. + +There are a number of supported types that can be passed directly in this +way, and they act as primitives within GHC's JavaScript RTS. This is in +comparison to data structures that are implemented in Haskell, such as +``String`` - being a list, this doesn't have a primitive JavaScript implementation, +and isn't equivalent to a JavaScript string. + +The following types are supported in this way: + +* ``Int``, including ``Int32`` and other sized numerical values. +* ``Int64``, and other 64 bit numbers are passed as two variables to the function, + where the first includes the sign and the higher bits +* ``Bool`` +* ``Char`` +* ``Any`` +* ``ByteArray#`` +* ``Double`` and ``Float`` +* ``MVar#``, and other RTS objects +* Unboxed tuples (e.g. ``(# a, b #)``) can appear in the return type, and are + constructed in JavaScript using macros such as ``RETURN_UBX_TUP2(x, y)``. + +As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so +the following example would compile successfully - despite `5` not being a valid JavaScript value +for the Haskell `Bool` type: + +.. code-block:: haskell + + foreign import javascript "((x) => { return 5; })" + type_error :: Bool -> Bool + JSVal -~~~~~ +^^^^^ The JavaScript backend has a concept of an untyped 'plain' JavaScript value, under the guise of the type ``JSVal``. Values having this type @@ -46,36 +84,9 @@ It also contains functions for working with objects: * ``isUndefined :: JSVal -> Bool`` - test for the JavaScript ``undefined`` * ``getProp :: JSVal -> String -> JSVal`` - object field access -JavaScript FFI Types -~~~~~~~~~~~~~~~~~~~~ - -Some types are able to be used directly in the type signatures of foreign -exports, without conversion to a ``JSVal``. We saw in the first example -that ``Int`` is one of these. - -The supported types are those with primitive JavaScript representations -that match the Haskell type. This means types such as the Haskell ``String`` -type aren't supported directly, because they're lists - which don't have -a primitive JavaScript representation, and so are incompatible with each -other. - -The following types are supported in this way: - -* ``Int`` -* ``Bool`` -* ``Char`` - -As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so -the following example would compile successfully - despite `5` not being a valid JavaScript value -for the Haskell `Bool` type: - -.. code-block:: haskell - - foreign import javascript "((x) => { return 5; })" - type_error :: Bool -> Bool JavaScript Callbacks -~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^ The JavaScript execution model is based around callback functions, and GHC's JavaScript backend implements these as a type in order to support @@ -173,3 +184,240 @@ We have to make sure not to use ``releaseCallback`` on any functions that are to be available in HTML, because we want these functions to be in memory indefinitely. +Writing ``jsbits`` for Libraries with C FFI Functions +----------------------------------------------------- + +Many libraries make use of C FFI functions to accomplish low-level or +performance sensitive operations - known as ``cbits`` and often kept in +a folder with this name. For such a library to support the JavaScript +backend, the ``cbits`` must have replacement implementations. + +In principle, it is possible for the JavaScript backend to automatically +compile ``cbits`` using Emscripten, but this requires wrappers to convert +data between the JS backend's RTS data format, and the format expected by +Emscripten-compiled functions. Since C functions are often used where +performance is more critical, there's potential for the data conversions +to negate this purpose. + +Instead, it is more effective for a library to provide an alternate +implementation for functions using the C FFI - either by providing direct +one-to-one replacement JavaScript functions, or by using C preprocessor +directives to replace C FFI imports with some combination of JS FFI imports +and pure-Haskell implementation. + +Direct Implementation of C FFI Imports in JavaScript +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When the JavaScript backend generates code for a C FFI import, it will call +the function named in the import string, prepended by ``h$`` - so the imported +C function ``open`` will look for the JavaScript function ``h$open``. No verification +is done to ensure that these functions are actually implemented in the linked +JavaScript files, so there can be runtime errors when a missing JavaScript +function is called. + +Based on this, implementing a C function in JavaScript is a matter of providing +a function of the correct shape (based on the C FFI import type signature) in +any of the linked JavaScript sources. External JavaScript sources are linked +by either providing them as an argument to GHC, or listing them in the ``js-sources`` +field of the cabal file - in which case it would usually be inside a predicate to +detect the ``javascript`` architecture, such as: + +.. code-block:: cabal + + library + + if arch(javascript) + js-sources: + jsbits/example.js + +Note that ``js-sources`` requires Cabal 3.10 to be used with library targets, and +Cabal 3.12 to be used with executable targets. + +The shape required of the JavaScript function will depend on the particular +C types used: + +* primitives, such as ``CInt`` will map directly to a single JavaScript argument + using JavaScript primitives. In the case of ``CInt``, this will be a JavaScript + number. Note that in the case of return values, a JavaScript number will usually + need to be rounded or cast back to an integral value in cases where mathematical + operations are used + +* pointer values, including ``CString``, are passed as an unboxed ``(ptr, offset)`` + pair. For arguments, being unboxed will mean these are passed as two top-level + arguments to the function. For return values, unboxed values should be returned + from JavaScript functions by using a special C preprocessor macro, + ``RETURN_UBX_TUP2(ptr, offset)`` + +* ``CString``, in addition to the above pointer handling, will need to be decoded + and encoded to convert them between character arrays and JavaScript strings. + +* other RTS primitive types are discussed previously in `JavaScript FFI Types`_. + +As an example, let's consider the implementation of ``getcwd``: + +.. code-block:: haskell + + -- unix:System.Posix.Directory + + foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar) + +.. code-block:: javascript + + // libraries/base/jsbits/base.js + + //#OPTIONS: CPP + + function h$getcwd(buf, off, buf_size) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + RETURN_UBX_TUP2(null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } + +Here, the C function ``getcwd`` maps to the JavaScript function ``h$getcwd``, which +exists in a ``.js`` file within ``base``'s ``jsbits`` subdirectory. ``h$getcwd`` +expects a ``CString`` (passed as the equivalent ``Ptr CChar``) and a +``CSize`` argument. This results in three arguments to the JavaScript function - two +for the string's pointer and offset, and one for the size, which will be passed as a +JavaScript number. + +Next, the JavaScript ``h$getcwd`` function demonstrates a several details: + +* In the try clause, the ``cwd`` value is first accessed using a NodeJS-provided method. + This value is immediately encoded using ``h$encodeUtf8``, which is provided by the + JavaScript backend. This function will only return the pointer for the encoded value, + and the offset will always be 0 + +* Next, we select one of several cases - based on the specification of the C function + that we're trying to immitate + +* In the first case where the given buffer size is too small, but not zero, the function + must set the ``ERANGE`` error code, which we do here with ``h$setErrno``, and return + ``null``. As we saw in the function arguments, pointers are passed as a ``(ptr, offset)`` + pair - meaning ``null`` is represented by returning the unboxed pair ``(null, 0)`` + +* In the second case where there is enough space in ``buf`` to successfully copy the + bytes, we do so using ``h$copyMutableByteArray`` - a function supplied by GHC's JavaScript + RTS + +* In the third case where ``buf_size`` is 0, this indicates in the C function's specification + that we can allocate a new buffer of the appropriate size to return. We already have + this in the form of the previously encoded ``cwd``, so we can just return it, along + with the 0 offset + +* In the last case where ``buf`` is null, and ``buf_size`` is large enough, we allocate a + new buffer, this time with ``buf_size`` bytes of space using ``h$newByteArray``, and + we again perform a mutable copy + +* To use C preprocessor macros in linked JavaScript files, the file must open with the + ``//#OPTIONS: CPP`` line, as is shown towards the start of this snippet + +* If an error occurs, the catch clause will pass it to ``h$setErrno`` and return the + ``(null, 0)`` pointer and offset pair - which is a behaviour expected by the C function + in the error case. + +Writing JavaScript Functions to be NodeJS and Browser Aware +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In the above example of implementing ``getcwd``, the function we use in the JavaScript +implementation is from NodeJS, and the behaviour doesn't make sense to implement in a +browser. Therefore, the actual implementation will include a C preprocessor condition +to check if we're compiling for the browser, in which case ``h$unsupported(-1)`` will +be called. There can be multiple non-browser JavaScript runtimes, so we'll also have +to check at runtime to make sure that NodeJS is in use. + +.. code-block:: javascript + + function h$getcwd(buf, off, buf_size) { + #ifndef GHCJS_BROWSER + if (h$isNode()) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + return (null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } else + #endif + h$unsupported(); + RETURN_UBX_TUP2(null, 0); + } + +Replacing C FFI Imports with Pure Haskell and JavaScript +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Instead of providing a direct JavaScript implementation for each C FFI import, we can +instead use the C preprocessor to conditionally remove these C imports (and possibly +use sites as well). Then, some combination of JavaScript FFI imports and Haskell +implementation can be added instead. As in the direct implementation section, any +linked JavaScript files should usually be in a ``if arch(javascript)`` condition in +the cabal file. + +As an example of a mixed Haskell and JavaScript implementation replacing a C +implementation, consider ``base:GHC.Clock``: + +.. code-block:: haskell + + #if defined(javascript_HOST_ARCH) + getMonotonicTimeNSec :: IO Word64 + getMonotonicTimeNSec = do + w <- getMonotonicTimeMSec + return (floor w * 1000000) + + foreign import javascript unsafe "performance.now" + getMonotonicTimeMSec :: IO Double + + #else + foreign import ccall unsafe "getMonotonicNSec" + getMonotonicTimeNSec :: IO Word64 + #endif + +Here, the ``getMonotonicTimeNSec`` C FFI import is replaced by the JavaScript FFI +import ``getMonotonicTimeMSec``, which imports the standard JavaScript function +``performance.now``. However, because this JavaScript implementation +returns the time as a ``Double`` of floating point milliseconds, it must be wrapped +by a Haskell function to extract the integral value that's expected. + +In this case, the choice of using a mixed Haskell and JavaScript replacement +implementation was caused by the limitation of clocks being system calls. In a lot +of cases, C functions are used for similar system-level functionality. In such +cases, it's recommended to import the required system functions from standard +JavaScript libraries (or from the runtime, as was required for ``getcwd``), and +use Haskell wrapper functions to convert the imported functions to the appropriate +format. + +In other cases, C functions are used for performance. For these cases, pure-Haskell +implementations are the preferred first step for compatability with the JavaScript +backend since it would be more future-proof against changes to the RTS data format. +Depending on the use case, compiler-optimised JS code might be hard to complete with +using hand-written JavaScript. Generally, the most likely performance gains from +hand-written JavaScript come from functions with data that stays as JavaScript +primitive types for a long time, especially strings. For this, ``JSVal`` allows +values to be passed between ``Haskell`` and ``JavaScript`` without a marshalling +penalty. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0d8f4e27d0baf15ec23ed1904245798482ace3e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0d8f4e27d0baf15ec23ed1904245798482ace3e3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 12:31:14 2023 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Wed, 18 Oct 2023 08:31:14 -0400 Subject: [Git][ghc/ghc][wip/jsbits-userguide] JS/userguide: wip explanation of writing jsbits Message-ID: <652fd01221e8d_7336f7b10a8583770b4@gitlab.mail> Josh Meredith pushed to branch wip/jsbits-userguide at Glasgow Haskell Compiler / GHC Commits: dde67bb1 by Josh Meredith at 2023-10-18T23:31:03+11:00 JS/userguide: wip explanation of writing jsbits - - - - - 1 changed file: - docs/users_guide/javascript.rst Changes: ===================================== docs/users_guide/javascript.rst ===================================== @@ -1,7 +1,7 @@ .. _ffi-javascript: FFI and the JavaScript Backend -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +============================== .. index:: single: FFI and the JavaScript Backend @@ -22,8 +22,46 @@ look like: foreign import javascript "((x,y) => { return x + y; })" js_add :: Int -> Int -> Int +.. _`JavaScript FFI Types`: + +JavaScript FFI Types +-------------------- + +Some types are able to be used directly in the type signatures of foreign +exports, without conversion to a ``JSVal``. We saw in the first example +that ``Int`` is one of these. + +There are a number of supported types that can be passed directly in this +way, and they act as primitives within GHC's JavaScript RTS. This is in +comparison to data structures that are implemented in Haskell, such as +``String`` - being a list, this doesn't have a primitive JavaScript implementation, +and isn't equivalent to a JavaScript string. + +The following types are supported in this way: + +* ``Int``, including ``Int32`` and other sized numerical values. +* ``Int64``, and other 64 bit numbers are passed as two variables to the function, + where the first includes the sign and the higher bits +* ``Bool`` +* ``Char`` +* ``Any`` +* ``ByteArray#`` +* ``Double`` and ``Float`` +* ``MVar#``, and other RTS objects +* Unboxed tuples (e.g. ``(# a, b #)``) can appear in the return type, and are + constructed in JavaScript using macros such as ``RETURN_UBX_TUP2(x, y)``. + +As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so +the following example would compile successfully - despite `5` not being a valid JavaScript value +for the Haskell `Bool` type: + +.. code-block:: haskell + + foreign import javascript "((x) => { return 5; })" + type_error :: Bool -> Bool + JSVal -~~~~~ +^^^^^ The JavaScript backend has a concept of an untyped 'plain' JavaScript value, under the guise of the type ``JSVal``. Values having this type @@ -46,36 +84,9 @@ It also contains functions for working with objects: * ``isUndefined :: JSVal -> Bool`` - test for the JavaScript ``undefined`` * ``getProp :: JSVal -> String -> JSVal`` - object field access -JavaScript FFI Types -~~~~~~~~~~~~~~~~~~~~ - -Some types are able to be used directly in the type signatures of foreign -exports, without conversion to a ``JSVal``. We saw in the first example -that ``Int`` is one of these. - -The supported types are those with primitive JavaScript representations -that match the Haskell type. This means types such as the Haskell ``String`` -type aren't supported directly, because they're lists - which don't have -a primitive JavaScript representation, and so are incompatible with each -other. - -The following types are supported in this way: - -* ``Int`` -* ``Bool`` -* ``Char`` - -As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so -the following example would compile successfully - despite `5` not being a valid JavaScript value -for the Haskell `Bool` type: - -.. code-block:: haskell - - foreign import javascript "((x) => { return 5; })" - type_error :: Bool -> Bool JavaScript Callbacks -~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^ The JavaScript execution model is based around callback functions, and GHC's JavaScript backend implements these as a type in order to support @@ -173,3 +184,240 @@ We have to make sure not to use ``releaseCallback`` on any functions that are to be available in HTML, because we want these functions to be in memory indefinitely. +Writing Replacement Implementations for Libraries with C FFI Functions +---------------------------------------------------------------------- + +Many libraries make use of C FFI functions to accomplish low-level or +performance sensitive operations - known as ``cbits`` and often kept in +a folder with this name. For such a library to support the JavaScript +backend, the ``cbits`` must have replacement implementations. + +In principle, it is possible for the JavaScript backend to automatically +compile ``cbits`` using Emscripten, but this requires wrappers to convert +data between the JS backend's RTS data format, and the format expected by +Emscripten-compiled functions. Since C functions are often used where +performance is more critical, there's potential for the data conversions +to negate this purpose. + +Instead, it is more effective for a library to provide an alternate +implementation for functions using the C FFI - either by providing direct +one-to-one replacement JavaScript functions, or by using C preprocessor +directives to replace C FFI imports with some combination of JS FFI imports +and pure-Haskell implementation. + +Direct Implementation of C FFI Imports in JavaScript +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When the JavaScript backend generates code for a C FFI import, it will call +the function named in the import string, prepended by ``h$`` - so the imported +C function ``open`` will look for the JavaScript function ``h$open``. No verification +is done to ensure that these functions are actually implemented in the linked +JavaScript files, so there can be runtime errors when a missing JavaScript +function is called. + +Based on this, implementing a C function in JavaScript is a matter of providing +a function of the correct shape (based on the C FFI import type signature) in +any of the linked JavaScript sources. External JavaScript sources are linked +by either providing them as an argument to GHC, or listing them in the ``js-sources`` +field of the cabal file - in which case it would usually be inside a predicate to +detect the ``javascript`` architecture, such as: + +.. code-block:: cabal + + library + + if arch(javascript) + js-sources: + jsbits/example.js + +Note that ``js-sources`` requires Cabal 3.10 to be used with library targets, and +Cabal 3.12 to be used with executable targets. + +The shape required of the JavaScript function will depend on the particular +C types used: + +* primitives, such as ``CInt`` will map directly to a single JavaScript argument + using JavaScript primitives. In the case of ``CInt``, this will be a JavaScript + number. Note that in the case of return values, a JavaScript number will usually + need to be rounded or cast back to an integral value in cases where mathematical + operations are used + +* pointer values, including ``CString``, are passed as an unboxed ``(ptr, offset)`` + pair. For arguments, being unboxed will mean these are passed as two top-level + arguments to the function. For return values, unboxed values should be returned + from JavaScript functions by using a special C preprocessor macro, + ``RETURN_UBX_TUP2(ptr, offset)`` + +* ``CString``, in addition to the above pointer handling, will need to be decoded + and encoded to convert them between character arrays and JavaScript strings. + +* other RTS primitive types are discussed previously in `JavaScript FFI Types`_. + +As an example, let's consider the implementation of ``getcwd``: + +.. code-block:: haskell + + -- unix:System.Posix.Directory + + foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar) + +.. code-block:: javascript + + // libraries/base/jsbits/base.js + + //#OPTIONS: CPP + + function h$getcwd(buf, off, buf_size) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + RETURN_UBX_TUP2(null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } + +Here, the C function ``getcwd`` maps to the JavaScript function ``h$getcwd``, which +exists in a ``.js`` file within ``base``'s ``jsbits`` subdirectory. ``h$getcwd`` +expects a ``CString`` (passed as the equivalent ``Ptr CChar``) and a +``CSize`` argument. This results in three arguments to the JavaScript function - two +for the string's pointer and offset, and one for the size, which will be passed as a +JavaScript number. + +Next, the JavaScript ``h$getcwd`` function demonstrates a several details: + +* In the try clause, the ``cwd`` value is first accessed using a NodeJS-provided method. + This value is immediately encoded using ``h$encodeUtf8``, which is provided by the + JavaScript backend. This function will only return the pointer for the encoded value, + and the offset will always be 0 + +* Next, we select one of several cases - based on the specification of the C function + that we're trying to immitate + +* In the first case where the given buffer size is too small, but not zero, the function + must set the ``ERANGE`` error code, which we do here with ``h$setErrno``, and return + ``null``. As we saw in the function arguments, pointers are passed as a ``(ptr, offset)`` + pair - meaning ``null`` is represented by returning the unboxed pair ``(null, 0)`` + +* In the second case where there is enough space in ``buf`` to successfully copy the + bytes, we do so using ``h$copyMutableByteArray`` - a function supplied by GHC's JavaScript + RTS + +* In the third case where ``buf_size`` is 0, this indicates in the C function's specification + that we can allocate a new buffer of the appropriate size to return. We already have + this in the form of the previously encoded ``cwd``, so we can just return it, along + with the 0 offset + +* In the last case where ``buf`` is null, and ``buf_size`` is large enough, we allocate a + new buffer, this time with ``buf_size`` bytes of space using ``h$newByteArray``, and + we again perform a mutable copy + +* To use C preprocessor macros in linked JavaScript files, the file must open with the + ``//#OPTIONS: CPP`` line, as is shown towards the start of this snippet + +* If an error occurs, the catch clause will pass it to ``h$setErrno`` and return the + ``(null, 0)`` pointer and offset pair - which is a behaviour expected by the C function + in the error case. + +Writing JavaScript Functions to be NodeJS and Browser Aware +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In the above example of implementing ``getcwd``, the function we use in the JavaScript +implementation is from NodeJS, and the behaviour doesn't make sense to implement in a +browser. Therefore, the actual implementation will include a C preprocessor condition +to check if we're compiling for the browser, in which case ``h$unsupported(-1)`` will +be called. There can be multiple non-browser JavaScript runtimes, so we'll also have +to check at runtime to make sure that NodeJS is in use. + +.. code-block:: javascript + + function h$getcwd(buf, off, buf_size) { + #ifndef GHCJS_BROWSER + if (h$isNode()) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + return (null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } else + #endif + h$unsupported(); + RETURN_UBX_TUP2(null, 0); + } + +Replacing C FFI Imports with Pure Haskell and JavaScript +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Instead of providing a direct JavaScript implementation for each C FFI import, we can +instead use the C preprocessor to conditionally remove these C imports (and possibly +use sites as well). Then, some combination of JavaScript FFI imports and Haskell +implementation can be added instead. As in the direct implementation section, any +linked JavaScript files should usually be in a ``if arch(javascript)`` condition in +the cabal file. + +As an example of a mixed Haskell and JavaScript implementation replacing a C +implementation, consider ``base:GHC.Clock``: + +.. code-block:: haskell + + #if defined(javascript_HOST_ARCH) + getMonotonicTimeNSec :: IO Word64 + getMonotonicTimeNSec = do + w <- getMonotonicTimeMSec + return (floor w * 1000000) + + foreign import javascript unsafe "performance.now" + getMonotonicTimeMSec :: IO Double + + #else + foreign import ccall unsafe "getMonotonicNSec" + getMonotonicTimeNSec :: IO Word64 + #endif + +Here, the ``getMonotonicTimeNSec`` C FFI import is replaced by the JavaScript FFI +import ``getMonotonicTimeMSec``, which imports the standard JavaScript function +``performance.now``. However, because this JavaScript implementation +returns the time as a ``Double`` of floating point milliseconds, it must be wrapped +by a Haskell function to extract the integral value that's expected. + +In this case, the choice of using a mixed Haskell and JavaScript replacement +implementation was caused by the limitation of clocks being system calls. In a lot +of cases, C functions are used for similar system-level functionality. In such +cases, it's recommended to import the required system functions from standard +JavaScript libraries (or from the runtime, as was required for ``getcwd``), and +use Haskell wrapper functions to convert the imported functions to the appropriate +format. + +In other cases, C functions are used for performance. For these cases, pure-Haskell +implementations are the preferred first step for compatability with the JavaScript +backend since it would be more future-proof against changes to the RTS data format. +Depending on the use case, compiler-optimised JS code might be hard to complete with +using hand-written JavaScript. Generally, the most likely performance gains from +hand-written JavaScript come from functions with data that stays as JavaScript +primitive types for a long time, especially strings. For this, ``JSVal`` allows +values to be passed between ``Haskell`` and ``JavaScript`` without a marshalling +penalty. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dde67bb177f1bf7da2d192ef6f9fd21e13082791 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dde67bb177f1bf7da2d192ef6f9fd21e13082791 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 12:32:13 2023 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Wed, 18 Oct 2023 08:32:13 -0400 Subject: [Git][ghc/ghc][wip/jsbits-userguide] JS/userguide: wip explanation of writing jsbits Message-ID: <652fd04dd0bb0_7336f7b52e9c03776d5@gitlab.mail> Josh Meredith pushed to branch wip/jsbits-userguide at Glasgow Haskell Compiler / GHC Commits: 137842f3 by Josh Meredith at 2023-10-18T23:32:00+11:00 JS/userguide: wip explanation of writing jsbits - - - - - 1 changed file: - docs/users_guide/javascript.rst Changes: ===================================== docs/users_guide/javascript.rst ===================================== @@ -1,7 +1,7 @@ .. _ffi-javascript: FFI and the JavaScript Backend -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +============================== .. index:: single: FFI and the JavaScript Backend @@ -22,8 +22,46 @@ look like: foreign import javascript "((x,y) => { return x + y; })" js_add :: Int -> Int -> Int +.. _`JavaScript FFI Types`: + +JavaScript FFI Types +-------------------- + +Some types are able to be used directly in the type signatures of foreign +exports, without conversion to a ``JSVal``. We saw in the first example +that ``Int`` is one of these. + +There are a number of supported types that can be passed directly in this +way, and they act as primitives within GHC's JavaScript RTS. This is in +comparison to data structures that are implemented in Haskell, such as +``String`` - being a list, this doesn't have a primitive JavaScript implementation, +and isn't equivalent to a JavaScript string. + +The following types are supported in this way: + +* ``Int``, including ``Int32`` and other sized numerical values. +* ``Int64``, and other 64 bit numbers are passed as two variables to the function, + where the first includes the sign and the higher bits +* ``Bool`` +* ``Char`` +* ``Any`` +* ``ByteArray#`` +* ``Double`` and ``Float`` +* ``MVar#``, and other RTS objects +* Unboxed tuples (e.g. ``(# a, b #)``) can appear in the return type, and are + constructed in JavaScript using macros such as ``RETURN_UBX_TUP2(x, y)``. + +As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so +the following example would compile successfully - despite `5` not being a valid JavaScript value +for the Haskell `Bool` type: + +.. code-block:: haskell + + foreign import javascript "((x) => { return 5; })" + type_error :: Bool -> Bool + JSVal -~~~~~ +^^^^^ The JavaScript backend has a concept of an untyped 'plain' JavaScript value, under the guise of the type ``JSVal``. Values having this type @@ -46,36 +84,9 @@ It also contains functions for working with objects: * ``isUndefined :: JSVal -> Bool`` - test for the JavaScript ``undefined`` * ``getProp :: JSVal -> String -> JSVal`` - object field access -JavaScript FFI Types -~~~~~~~~~~~~~~~~~~~~ - -Some types are able to be used directly in the type signatures of foreign -exports, without conversion to a ``JSVal``. We saw in the first example -that ``Int`` is one of these. - -The supported types are those with primitive JavaScript representations -that match the Haskell type. This means types such as the Haskell ``String`` -type aren't supported directly, because they're lists - which don't have -a primitive JavaScript representation, and so are incompatible with each -other. - -The following types are supported in this way: - -* ``Int`` -* ``Bool`` -* ``Char`` - -As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so -the following example would compile successfully - despite `5` not being a valid JavaScript value -for the Haskell `Bool` type: - -.. code-block:: haskell - - foreign import javascript "((x) => { return 5; })" - type_error :: Bool -> Bool JavaScript Callbacks -~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^ The JavaScript execution model is based around callback functions, and GHC's JavaScript backend implements these as a type in order to support @@ -173,3 +184,240 @@ We have to make sure not to use ``releaseCallback`` on any functions that are to be available in HTML, because we want these functions to be in memory indefinitely. +Writing Replacement Implementations for Libraries with C FFI Functions +---------------------------------------------------------------------- + +Many libraries make use of C FFI functions to accomplish low-level or +performance sensitive operations - known as ``cbits`` and often kept in +a folder with this name. For such a library to support the JavaScript +backend, the ``cbits`` must have replacement implementations. + +In principle, it is possible for the JavaScript backend to automatically +compile ``cbits`` using Emscripten, but this requires wrappers to convert +data between the JS backend's RTS data format, and the format expected by +Emscripten-compiled functions. Since C functions are often used where +performance is more critical, there's potential for the data conversions +to negate this purpose. + +Instead, it is more effective for a library to provide an alternate +implementation for functions using the C FFI - either by providing direct +one-to-one replacement JavaScript functions, or by using C preprocessor +directives to replace C FFI imports with some combination of JS FFI imports +and pure-Haskell implementation. + +Direct Implementation of C FFI Imports in JavaScript as ``jsbits`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When the JavaScript backend generates code for a C FFI import, it will call +the function named in the import string, prepended by ``h$`` - so the imported +C function ``open`` will look for the JavaScript function ``h$open``. No verification +is done to ensure that these functions are actually implemented in the linked +JavaScript files, so there can be runtime errors when a missing JavaScript +function is called. + +Based on this, implementing a C function in JavaScript is a matter of providing +a function of the correct shape (based on the C FFI import type signature) in +any of the linked JavaScript sources. External JavaScript sources are linked +by either providing them as an argument to GHC, or listing them in the ``js-sources`` +field of the cabal file - in which case it would usually be inside a predicate to +detect the ``javascript`` architecture, such as: + +.. code-block:: cabal + + library + + if arch(javascript) + js-sources: + jsbits/example.js + +Note that ``js-sources`` requires Cabal 3.10 to be used with library targets, and +Cabal 3.12 to be used with executable targets. + +The shape required of the JavaScript function will depend on the particular +C types used: + +* primitives, such as ``CInt`` will map directly to a single JavaScript argument + using JavaScript primitives. In the case of ``CInt``, this will be a JavaScript + number. Note that in the case of return values, a JavaScript number will usually + need to be rounded or cast back to an integral value in cases where mathematical + operations are used + +* pointer values, including ``CString``, are passed as an unboxed ``(ptr, offset)`` + pair. For arguments, being unboxed will mean these are passed as two top-level + arguments to the function. For return values, unboxed values should be returned + from JavaScript functions by using a special C preprocessor macro, + ``RETURN_UBX_TUP2(ptr, offset)`` + +* ``CString``, in addition to the above pointer handling, will need to be decoded + and encoded to convert them between character arrays and JavaScript strings. + +* other RTS primitive types are discussed previously in `JavaScript FFI Types`_. + +As an example, let's consider the implementation of ``getcwd``: + +.. code-block:: haskell + + -- unix:System.Posix.Directory + + foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar) + +.. code-block:: javascript + + // libraries/base/jsbits/base.js + + //#OPTIONS: CPP + + function h$getcwd(buf, off, buf_size) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + RETURN_UBX_TUP2(null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } + +Here, the C function ``getcwd`` maps to the JavaScript function ``h$getcwd``, which +exists in a ``.js`` file within ``base``'s ``jsbits`` subdirectory. ``h$getcwd`` +expects a ``CString`` (passed as the equivalent ``Ptr CChar``) and a +``CSize`` argument. This results in three arguments to the JavaScript function - two +for the string's pointer and offset, and one for the size, which will be passed as a +JavaScript number. + +Next, the JavaScript ``h$getcwd`` function demonstrates a several details: + +* In the try clause, the ``cwd`` value is first accessed using a NodeJS-provided method. + This value is immediately encoded using ``h$encodeUtf8``, which is provided by the + JavaScript backend. This function will only return the pointer for the encoded value, + and the offset will always be 0 + +* Next, we select one of several cases - based on the specification of the C function + that we're trying to immitate + +* In the first case where the given buffer size is too small, but not zero, the function + must set the ``ERANGE`` error code, which we do here with ``h$setErrno``, and return + ``null``. As we saw in the function arguments, pointers are passed as a ``(ptr, offset)`` + pair - meaning ``null`` is represented by returning the unboxed pair ``(null, 0)`` + +* In the second case where there is enough space in ``buf`` to successfully copy the + bytes, we do so using ``h$copyMutableByteArray`` - a function supplied by GHC's JavaScript + RTS + +* In the third case where ``buf_size`` is 0, this indicates in the C function's specification + that we can allocate a new buffer of the appropriate size to return. We already have + this in the form of the previously encoded ``cwd``, so we can just return it, along + with the 0 offset + +* In the last case where ``buf`` is null, and ``buf_size`` is large enough, we allocate a + new buffer, this time with ``buf_size`` bytes of space using ``h$newByteArray``, and + we again perform a mutable copy + +* To use C preprocessor macros in linked JavaScript files, the file must open with the + ``//#OPTIONS: CPP`` line, as is shown towards the start of this snippet + +* If an error occurs, the catch clause will pass it to ``h$setErrno`` and return the + ``(null, 0)`` pointer and offset pair - which is a behaviour expected by the C function + in the error case. + +Writing JavaScript Functions to be NodeJS and Browser Aware +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In the above example of implementing ``getcwd``, the function we use in the JavaScript +implementation is from NodeJS, and the behaviour doesn't make sense to implement in a +browser. Therefore, the actual implementation will include a C preprocessor condition +to check if we're compiling for the browser, in which case ``h$unsupported(-1)`` will +be called. There can be multiple non-browser JavaScript runtimes, so we'll also have +to check at runtime to make sure that NodeJS is in use. + +.. code-block:: javascript + + function h$getcwd(buf, off, buf_size) { + #ifndef GHCJS_BROWSER + if (h$isNode()) { + try { + var cwd = h$encodeUtf8(process.cwd()); + if (buf_size < cwd.len && buf_size !== 0) { + h$setErrno("ERANGE"); + return (null, 0); + } else if (buf !== null) { + h$copyMutableByteArray(cwd, 0, buf, off, cwd.len); + RETURN_UBX_TUP2(buf, off); + } else if (buf_size === 0) { + RETURN_UBX_TUP2(cwd, 0); + } else { + var out = h$newByteArray(buf_size); + h$copyMutableByteArray(cwd, 0, out, off, cwd.len); + } + } catch (e) { + h$setErrno(e); + RETURN_UBX_TUP2(null, 0); + } + } else + #endif + h$unsupported(); + RETURN_UBX_TUP2(null, 0); + } + +Replacing C FFI Imports with Pure Haskell and JavaScript +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Instead of providing a direct JavaScript implementation for each C FFI import, we can +instead use the C preprocessor to conditionally remove these C imports (and possibly +use sites as well). Then, some combination of JavaScript FFI imports and Haskell +implementation can be added instead. As in the direct implementation section, any +linked JavaScript files should usually be in a ``if arch(javascript)`` condition in +the cabal file. + +As an example of a mixed Haskell and JavaScript implementation replacing a C +implementation, consider ``base:GHC.Clock``: + +.. code-block:: haskell + + #if defined(javascript_HOST_ARCH) + getMonotonicTimeNSec :: IO Word64 + getMonotonicTimeNSec = do + w <- getMonotonicTimeMSec + return (floor w * 1000000) + + foreign import javascript unsafe "performance.now" + getMonotonicTimeMSec :: IO Double + + #else + foreign import ccall unsafe "getMonotonicNSec" + getMonotonicTimeNSec :: IO Word64 + #endif + +Here, the ``getMonotonicTimeNSec`` C FFI import is replaced by the JavaScript FFI +import ``getMonotonicTimeMSec``, which imports the standard JavaScript function +``performance.now``. However, because this JavaScript implementation +returns the time as a ``Double`` of floating point milliseconds, it must be wrapped +by a Haskell function to extract the integral value that's expected. + +In this case, the choice of using a mixed Haskell and JavaScript replacement +implementation was caused by the limitation of clocks being system calls. In a lot +of cases, C functions are used for similar system-level functionality. In such +cases, it's recommended to import the required system functions from standard +JavaScript libraries (or from the runtime, as was required for ``getcwd``), and +use Haskell wrapper functions to convert the imported functions to the appropriate +format. + +In other cases, C functions are used for performance. For these cases, pure-Haskell +implementations are the preferred first step for compatability with the JavaScript +backend since it would be more future-proof against changes to the RTS data format. +Depending on the use case, compiler-optimised JS code might be hard to complete with +using hand-written JavaScript. Generally, the most likely performance gains from +hand-written JavaScript come from functions with data that stays as JavaScript +primitive types for a long time, especially strings. For this, ``JSVal`` allows +values to be passed between ``Haskell`` and ``JavaScript`` without a marshalling +penalty. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/137842f3d1046d037c3fcc98378da937d6edf9ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/137842f3d1046d037c3fcc98378da937d6edf9ab You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 15:15:36 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 18 Oct 2023 11:15:36 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24101 Message-ID: <652ff69871e4_7336f7f0bb5883916c5@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/T24101 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24101 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 16:08:47 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 18 Oct 2023 12:08:47 -0400 Subject: [Git][ghc/ghc][wip/mixed-uniqfm] FMs use Word64 now Message-ID: <6530030fbf6a1_7336f8055944039679a@gitlab.mail> Sebastian Graf pushed to branch wip/mixed-uniqfm at Glasgow Haskell Compiler / GHC Commits: 66833704 by Sebastian Graf at 2023-10-18T18:08:41+02:00 FMs use Word64 now - - - - - 4 changed files: - compiler/GHC/Data/Graph/UnVar.hs - compiler/GHC/Types/Unique/DFM.hs - compiler/GHC/Types/Unique/FM.hs - compiler/GHC/Types/Var/Env.hs Changes: ===================================== compiler/GHC/Data/Graph/UnVar.hs ===================================== @@ -31,7 +31,7 @@ module GHC.Data.Graph.UnVar import GHC.Prelude -import GHC.Types.Unique.FM( UniqFM, ufmToSet_Directly ) +import GHC.Types.Unique.FM( UniqFM, ufmToSet_Directly, getMixedKey, getUnmixedUnique ) import GHC.Types.Var import GHC.Utils.Outputable import GHC.Types.Unique ===================================== compiler/GHC/Types/Unique/DFM.hs ===================================== @@ -71,7 +71,7 @@ module GHC.Types.Unique.DFM ( import GHC.Prelude -import GHC.Types.Unique ( Uniquable(..), Unique, getKey, mkUniqueGrimily ) +import GHC.Types.Unique ( Uniquable(..), Unique ) import GHC.Utils.Outputable import qualified GHC.Data.Word64Map.Strict as MS ===================================== compiler/GHC/Types/Unique/FM.hs ===================================== @@ -122,7 +122,7 @@ newtype UniqFM key ele = UFM (M.Word64Map ele) type role UniqFM representational representational -- Don't allow coerces over the key -- | https://gist.github.com/degski/6e2069d6035ae04d5d6f64981c995ec2 -mix :: Word -> Int -> Int +mix :: MS.Key -> MS.Key -> MS.Key {-# INLINE mix #-} mix k x = fromIntegral $ f $ g $ f $ g $ f $ fromIntegral x where @@ -130,26 +130,21 @@ mix k x = fromIntegral $ f $ g $ f $ g $ f $ fromIntegral x g z = z * k s = finiteBitSize k `shiftR` 1 -- 32 for 64 bit, 16 for 32 bit -kFORWARD, kBACKWARD :: Word +kFORWARD, kBACKWARD :: MS.Key -- These are like "encryption" and "decryption" keys to mix -#if UNIQUE_TAG_BITS == 8 kFORWARD = 0xD6E8FEB86659FD93 kBACKWARD = 0xCFEE444D8B59A89B -#else -kFORWARD = 0x45D9F3B -kBACKWARD = 0x119DE1F3 -#endif -enc, dec :: Int -> Int +enc, dec :: MS.Key -> MS.Key enc = mix kFORWARD dec = mix kBACKWARD {-# INLINE enc #-} {-# INLINE dec #-} -getMixedKey :: Unique -> Int +getMixedKey :: Unique -> MS.Key {-# NOINLINE getMixedKey #-} getMixedKey = enc . getKey -getUnmixedUnique :: Int -> Unique +getUnmixedUnique :: MS.Key -> Unique {-# NOINLINE getUnmixedUnique #-} getUnmixedUnique = mkUniqueGrimily . dec ===================================== compiler/GHC/Types/Var/Env.hs ===================================== @@ -227,11 +227,11 @@ uniqAway' in_scope var -- given 'InScopeSet'. This must be used very carefully since one can very easily -- introduce non-unique 'Unique's this way. See Note [Local uniques]. unsafeGetFreshLocalUnique :: InScopeSet -> Unique -unsafeGetFreshLocalUnique (InScope set) = go (getMixedKey (mkUniqueGrimily (sizeUniqSet set))) +unsafeGetFreshLocalUnique (InScope set) = go (getMixedKey (mkUniqueGrimily (fromIntegral (sizeUniqSet set)))) where go n | let uniq = mkLocalUnique n - , Nothing <- IntMap.lookup (getMixedKey $ uniq) (ufmToIntMap $ getUniqSet set) + , Nothing <- Word64Map.lookup (getMixedKey $ uniq) (ufmToIntMap $ getUniqSet set) = uniq | otherwise = go (getMixedKey $ mkUniqueGrimily (n+1)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/668337048d41d107865474939926620f83a0e6fd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/668337048d41d107865474939926620f83a0e6fd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 17:00:29 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 18 Oct 2023 13:00:29 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 13 commits: Fix restarts in .ghcid Message-ID: <65300f2db9db6_7336f81b1e3ac409013@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - af67de65 by Sylvain Henry at 2023-10-18T12:59:42-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - 21e0bb2f by Sylvain Henry at 2023-10-18T12:59:42-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - 9c80bcba by Sylvain Henry at 2023-10-18T12:59:42-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - d9eade5e by Sylvain Henry at 2023-10-18T12:59:42-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - 4324d093 by John Ericson at 2023-10-18T12:59:43-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - db91486c by John Ericson at 2023-10-18T12:59:43-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - e1dd16d2 by John Ericson at 2023-10-18T12:59:43-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 30 changed files: - .ghcid - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Reader.hs - configure.ac - docs/users_guide/conf.py - docs/users_guide/ghc_config.py.in - hadrian/cfg/system.config.in - hadrian/doc/flavours.md - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - − rts/ghcversion.h.top - rts/ghcversion.h.bottom → rts/include/ghcversion.h.in - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc5c6853fd3f322236cc1daa02ddcf3391965447...e1dd16d2e0458a3bbe79633595d876e929938cf1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc5c6853fd3f322236cc1daa02ddcf3391965447...e1dd16d2e0458a3bbe79633595d876e929938cf1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 17:25:00 2023 From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring)) Date: Wed, 18 Oct 2023 13:25:00 -0400 Subject: [Git][ghc/ghc][wip/T15226-stg] Teach tag-inference about SeqOp/seq# Message-ID: <653014ec2a788_7336f8283e780409254@gitlab.mail> Matthew Craven pushed to branch wip/T15226-stg at Glasgow Haskell Compiler / GHC Commits: 3c0528ed by Matthew Craven at 2023-10-18T13:24:14-04:00 Teach tag-inference about SeqOp/seq# Fixes the STG/tag-inference analogue of #15226. - - - - - 12 changed files: - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Stg/InferTags.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Stg/InferTags/TagSig.hs - compiler/GHC/StgToCmm/Prim.hs - + testsuite/tests/simplStg/should_compile/T15226b.hs - + testsuite/tests/simplStg/should_compile/T15226b.stderr - testsuite/tests/simplStg/should_compile/all.T - + testsuite/tests/simplStg/should_compile/inferTags003.hs - + testsuite/tests/simplStg/should_compile/inferTags003.stderr - + testsuite/tests/simplStg/should_compile/inferTags004.hs - + testsuite/tests/simplStg/should_compile/inferTags004.stderr Changes: ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2108,6 +2108,9 @@ Implementing seq#. The compiler has magic for SeqOp in - Simplify.addEvals records evaluated-ness for the result; see Note [Adding evaluatedness info to pattern-bound variables] in GHC.Core.Opt.Simplify.Iteration + +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a + properly-tagged pointer inside of its unboxed-tuple result. -} seqRule :: RuleM CoreExpr ===================================== compiler/GHC/Stg/InferTags.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) ) import GHC.Types.Unique.Supply (mkSplitUniqSupply) import GHC.Types.RepType (dataConRuntimeRepStrictness) import GHC.Core (AltCon(..)) +import GHC.Builtin.PrimOps ( PrimOp(..) ) import Data.List (mapAccumL) import GHC.Utils.Outputable import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull ) @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args) | otherwise = --pprTrace "inferAppUnknown" (ppr fun) $ TagDunno --- TODO: --- If we have something like: --- let x = thunk in --- f g = case g of g' -> (# x, g' #) --- then we *do* know that g' will be properly tagged, --- so we should return TagTagged [TagDunno,TagProper] but currently we infer --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr. --- Seems not to matter much but should be changed eventually. inferTagExpr env (StgConApp con cn args tys) = (inferConTag env con args, StgConApp con cn args tys) @@ -340,9 +333,15 @@ inferTagExpr env (StgTick tick body) (info, body') = inferTagExpr env body inferTagExpr _ (StgOpApp op args ty) - = -- Do any primops guarantee to return a properly tagged value? - -- I think not. Ditto foreign calls. - (TagDunno, StgOpApp op args ty) + | StgPrimOp SeqOp <- op + -- The inner result of seq# comes directly from evaluating its + -- argument, hence TagProper. (The State# token was unarised out of + -- existence.) See Note [seq# magic] in GHC.Core.Opt.ConstantFold + = (TagTuple [TagProper], StgOpApp op args ty) + -- Do any other primops guarantee to return a properly tagged value? + -- Probably not, and that is the conservative assumption anyway. + -- (And foreign calls definitely need not make promises.) + | otherwise = (TagDunno, StgOpApp op args ty) inferTagExpr env (StgLet ext bind body) = (info, StgLet ext bind' body') ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -217,7 +217,7 @@ withLcl fv act = do When compiling bytecode we call myCoreToStg to get STG code first. myCoreToStg in turn calls out to stg2stg which runs the STG to STG passes followed by free variables analysis and the tag inference pass including -it's rewriting phase at the end. +its rewriting phase at the end. Running tag inference is important as it upholds Note [Strict Field Invariant]. While code executed by GHCi doesn't take advantage of the SFI it can call into compiled code which does. So it must still make sure that the SFI is upheld. @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr rewriteExpr (e at StgCase {}) = rewriteCase e rewriteExpr (e at StgLet {}) = rewriteLet e rewriteExpr (e at StgLetNoEscape {}) = rewriteLetNoEscape e -rewriteExpr (StgTick t e) = StgTick t <$!> rewriteExpr e +rewriteExpr (StgTick t e) = StgTick t <$!> rewriteExpr e rewriteExpr e@(StgConApp {}) = rewriteConApp e -rewriteExpr e@(StgApp {}) = rewriteApp e -rewriteExpr (StgLit lit) = return $! (StgLit lit) -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do - (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty) +rewriteExpr e@(StgOpApp {}) = rewriteOpApp e +rewriteExpr e@(StgApp {}) = rewriteApp e +rewriteExpr (StgLit lit) = return $! (StgLit lit) rewriteCase :: InferStgExpr -> RM TgStgExpr @@ -488,6 +486,17 @@ rewriteApp (StgApp f args) rewriteApp (StgApp f args) = return $ StgApp f args rewriteApp _ = panic "Impossible" +rewriteOpApp :: InferStgExpr -> RM TgStgExpr +rewriteOpApp (StgOpApp op args res_ty) = case op of + op@(StgPrimOp primOp) + | primOp == SeqOp || primOp == DataToTagOp + -- These primops evaluate an argument and can use a tag annotation + -- to elide that eval. Foreign calls and other primops make no + -- use of tag info, so we don't bother annotating them. + -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty + _ -> pure $! StgOpApp op args res_ty +rewriteOpApp _ = panic "Impossible" + -- `mkSeq` x x' e generates `case x of x' -> e` -- We could also substitute x' for x in e but that's so rarely beneficial -- that we don't bother. ===================================== compiler/GHC/Stg/InferTags/TagSig.hs ===================================== @@ -5,7 +5,7 @@ -- We export this type from this module instead of GHC.Stg.InferTags.Types -- because it's used by more than the analysis itself. For example in interface -- files where we record a tag signature for bindings. --- By putting the sig into it's own module we can avoid module loops. +-- By putting the sig into its own module we can avoid module loops. module GHC.Stg.InferTags.TagSig where @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> () seqTagInfo TagTagged = () seqTagInfo TagDunno = () seqTagInfo TagProper = () -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis \ No newline at end of file +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of -- -- In more complex cases, there is a foreign call (out of line) fallback. This -- might happen e.g. if there's enough static information, such as statically --- know arguments. +-- known arguments. emitPrimOp :: StgToCmmConfig -> PrimOp -- ^ The primop ===================================== testsuite/tests/simplStg/should_compile/T15226b.hs ===================================== @@ -0,0 +1,11 @@ +module T15226b where + +import Control.Exception + +data StrictPair a b = MkStrictPair !a !b + +testFun :: a -> b -> IO (StrictPair a b) +testFun x y = do + x' <- evaluate x + evaluate (MkStrictPair x' y) + -- tag inference should not insert an eval for x' in making the strict pair ===================================== testsuite/tests/simplStg/should_compile/T15226b.stderr ===================================== @@ -0,0 +1,48 @@ + +==================== Final STG: ==================== +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE] + :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] = + {} \r [conrep conrep1] + case conrep of conrep2 [Occ=Once1] { + __DEFAULT -> + case conrep1 of conrep3 [Occ=Once1] { + __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3]; + }; + }; + +T15226b.testFun1 + :: forall a b. + a + -> b + -> GHC.Prim.State# GHC.Prim.RealWorld + -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #) +[GblId, Arity=3, Str=, Unf=OtherCon []] = + {} \r [x y void] + case seq# [x GHC.Prim.void#] of { + Solo# ipv1 [Occ=Once1] -> + let { + sat [Occ=Once1] :: T15226b.StrictPair a b + [LclId] = + {ipv1, y} \u [] + case y of conrep [Occ=Once1] { + __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep]; + }; + } in seq# [sat GHC.Prim.void#]; + }; + +T15226b.testFun + :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b) +[GblId, Arity=3, Str=, Unf=OtherCon []] = + {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#; + +T15226b.MkStrictPair [InlPrag=CONLIKE] + :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] = + {} \r [eta eta] + case eta of eta { + __DEFAULT -> + case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; }; + }; + + ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -18,3 +18,8 @@ test('T22840', [extra_files( [ 'T22840A.hs' , 'T22840B.hs' ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks']) +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) +test('inferTags003', [ only_ways(['optasm']), + grep_errmsg(r'(call stg\_ap\_0)', [1]) + ], compile, ['-ddump-cmm -dno-typeable-binds -O']) +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques']) ===================================== testsuite/tests/simplStg/should_compile/inferTags003.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE MagicHash #-} +module M where + +import GHC.Exts +import GHC.IO + +data T a = MkT !Bool !a + +fun :: T a -> IO a +{-# OPAQUE fun #-} +fun (MkT _ x) = IO $ \s -> noinline seq# x s +-- evaluate/seq# should not produce its own eval for x +-- since it is properly tagged (from a strict field) + +-- uses noinline to prevent caseRules from eliding the seq# in Core ===================================== testsuite/tests/simplStg/should_compile/inferTags003.stderr ===================================== @@ -0,0 +1,177 @@ + +==================== Output Cmm ==================== +[M.$WMkT_entry() { // [R3, R2] + { info_tbls: [(cEx, + label: block_cEx_info + rep: StackRep [False] + srt: Nothing), + (cEA, + label: M.$WMkT_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Nothing), + (cED, + label: block_cED_info + rep: StackRep [False] + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cEA: // global + if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH; // CmmCondBranch + cEG: // global + R1 = M.$WMkT_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cEH: // global + I64[Sp - 16] = cEx; // CmmStore + R1 = R2; // CmmAssign + P64[Sp - 8] = R3; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto cEx; else goto cEy; // CmmCondBranch + cEy: // global + call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8; // CmmCall + cEx: // global + // slowCall + I64[Sp] = cED; // CmmStore + _sEi::P64 = R1; // CmmAssign + R1 = P64[Sp + 8]; // CmmAssign + P64[Sp + 8] = _sEi::P64; // CmmStore + call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8; // CmmCall + cED: // global + // slow_call for _sEh::P64 with pat stg_ap_0 + Hp = Hp + 24; // CmmAssign + if (Hp > HpLim) (likely: False) goto cEL; else goto cEK; // CmmCondBranch + cEL: // global + HpAlloc = 24; // CmmAssign + call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8; // CmmCall + cEK: // global + // allocHeapClosure + I64[Hp - 16] = M.MkT_con_info; // CmmStore + P64[Hp - 8] = P64[Sp + 8]; // CmmStore + P64[Hp] = R1; // CmmStore + R1 = Hp - 15; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.$WMkT_closure" { + M.$WMkT_closure: + const M.$WMkT_info; + }] + + + +==================== Output Cmm ==================== +[M.fun_entry() { // [R2] + { info_tbls: [(cEV, + label: block_cEV_info + rep: StackRep [] + srt: Nothing), + (cEY, + label: M.fun_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cEY: // global + if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0; // CmmCondBranch + cEZ: // global + R1 = M.fun_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cF0: // global + I64[Sp - 8] = cEV; // CmmStore + R1 = R2; // CmmAssign + Sp = Sp - 8; // CmmAssign + if (R1 & 7 != 0) goto cEV; else goto cEW; // CmmCondBranch + cEW: // global + call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8; // CmmCall + cEV: // global + R1 = P64[R1 + 15]; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.fun_closure" { + M.fun_closure: + const M.fun_info; + }] + + + +==================== Output Cmm ==================== +[M.MkT_entry() { // [R3, R2] + { info_tbls: [(cFc, + label: block_cFc_info + rep: StackRep [False] + srt: Nothing), + (cFf, + label: M.MkT_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Nothing), + (cFi, + label: block_cFi_info + rep: StackRep [False] + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cFf: // global + if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm; // CmmCondBranch + cFl: // global + R1 = M.MkT_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + cFm: // global + I64[Sp - 16] = cFc; // CmmStore + R1 = R2; // CmmAssign + P64[Sp - 8] = R3; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto cFc; else goto cFd; // CmmCondBranch + cFd: // global + call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8; // CmmCall + cFc: // global + // slowCall + I64[Sp] = cFi; // CmmStore + _tEq::P64 = R1; // CmmAssign + R1 = P64[Sp + 8]; // CmmAssign + P64[Sp + 8] = _tEq::P64; // CmmStore + call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8; // CmmCall + cFi: // global + // slow_call for _B1::P64 with pat stg_ap_0 + Hp = Hp + 24; // CmmAssign + if (Hp > HpLim) (likely: False) goto cFq; else goto cFp; // CmmCondBranch + cFq: // global + HpAlloc = 24; // CmmAssign + call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8; // CmmCall + cFp: // global + // allocHeapClosure + I64[Hp - 16] = M.MkT_con_info; // CmmStore + P64[Hp - 8] = P64[Sp + 8]; // CmmStore + P64[Hp] = R1; // CmmStore + R1 = Hp - 15; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . M.MkT_closure" { + M.MkT_closure: + const M.MkT_info; + }] + + + +==================== Output Cmm ==================== +[M.MkT_con_entry() { // [] + { info_tbls: [(cFw, + label: M.MkT_con_info + rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cFw: // global + R1 = R1 + 1; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }] + + ===================================== testsuite/tests/simplStg/should_compile/inferTags004.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE BangPatterns, UnboxedTuples #-} +module InferTags004 where + +x :: Int +x = x + +f :: a -> (# Int, a #) +-- Adapted from a TODO in InferTags. +-- f's tag signature should indicate that the second component +-- of its result is properly tagged: TagTuple[TagDunno,TagProper] +f g = case g of !g' -> (# x, g' #) ===================================== testsuite/tests/simplStg/should_compile/inferTags004.stderr ===================================== @@ -0,0 +1,13 @@ + +==================== CodeGenAnal STG: ==================== +Rec { +(InferTags004.x, ) = {} \u [] InferTags004.x; +end Rec } + +(InferTags004.f, ) = + {} \r [(g, )] + case g of (g', ) { + __DEFAULT -> (#,#) [InferTags004.x g']; + }; + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c0528eda983de66fd2361baf7ed52640aea2b8f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c0528eda983de66fd2361baf7ed52640aea2b8f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 20:10:48 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 18 Oct 2023 16:10:48 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) Message-ID: <65303bc892121_7336f863595544416f8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e2dcb855 by Sylvain Henry at 2023-10-18T16:10:04-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - a2256b7f by Sylvain Henry at 2023-10-18T16:10:04-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - 7fe08dee by Sylvain Henry at 2023-10-18T16:10:04-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - b5d5fb24 by Sylvain Henry at 2023-10-18T16:10:04-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - 3d6a03e4 by John Ericson at 2023-10-18T16:10:05-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - 7df22c01 by John Ericson at 2023-10-18T16:10:05-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 6771670d by John Ericson at 2023-10-18T16:10:05-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 18 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/doc/flavours.md - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Flavours/Validate.hs - libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - − rts/ghcversion.h.top - rts/ghcversion.h.bottom → rts/include/ghcversion.h.in - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== configure.ac ===================================== @@ -68,23 +68,6 @@ FP_PROG_SORT dnl ---------------------------------------------------------- FP_SETUP_PROJECT_VERSION -dnl Don't use AC_DEFINE because it will make C-style comments invalid for -dnl Haskell. - -> rts/include/ghcversion.h - -cat rts/ghcversion.h.top >> rts/include/ghcversion.h - -echo "#define __GLASGOW_HASKELL__ ${ProjectVersionInt}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_FULL_VERSION__ \"${ProjectVersion}\"" >> rts/include/ghcversion.h -echo >> rts/include/ghcversion.h -AS_IF([test x"${ProjectPatchLevel1}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ ${ProjectPatchLevel1}" >> rts/include/ghcversion.h]) -AS_IF([test x"${ProjectPatchLevel2}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL2__ ${ProjectPatchLevel2}" >> rts/include/ghcversion.h]) - -cat rts/ghcversion.h.bottom >> rts/include/ghcversion.h - # Hmmm, we fix the RPM release number to 1 here... Is this convenient? AC_SUBST([release], [1]) @@ -105,8 +88,6 @@ AC_PREREQ([2.69]) AC_CONFIG_HEADER(mk/config.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) -dnl manually outputted above, for reasons described there. -dnl AC_CONFIG_HEADER(rts/include/ghcversion.h) # No, semi-sadly, we don't do `--srcdir'... if test x"$srcdir" != 'x.' ; then @@ -1069,7 +1050,6 @@ AC_CONFIG_FILES( hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - docs/users_guide/ghc_config.py distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ===================================== hadrian/cfg/system.config.in ===================================== @@ -34,6 +34,9 @@ python = @PythonCmd@ cc-llvm-backend = @CcLlvmBackend@ +llvm-min-version = @LlvmMinVersion@ +llvm-max-version = @LlvmMaxVersion@ + # Build options: #=============== ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -49,6 +49,8 @@ data Setting = CursesIncludeDir | GhcPatchLevel | GhcVersion | GhcSourcePath + | LlvmMinVersion + | LlvmMaxVersion | GmpIncludeDir | GmpLibDir | IconvIncludeDir @@ -103,6 +105,8 @@ setting key = lookupSystemConfig $ case key of GhcPatchLevel -> "ghc-patch-level" GhcVersion -> "ghc-version" GhcSourcePath -> "ghc-source-path" + LlvmMinVersion -> "llvm-min-version" + LlvmMaxVersion -> "llvm-max-version" GmpIncludeDir -> "gmp-include-dir" GmpLibDir -> "gmp-lib-dir" IconvIncludeDir -> "iconv-include-dir" ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -356,6 +356,9 @@ buildSphinxInfoGuide = do root <- buildRootRules let path = "GHCUsersGuide" root -/- infoRoot -/- path <.> "info" %> \ file -> do + + needDocDeps + withTempDir $ \dir -> do let rstFilesDir = pathPath path rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"] @@ -391,6 +394,8 @@ buildManPage = do root <- buildRootRules root -/- manPageBuildPath %> \file -> do need ["docs/users_guide/ghc.rst"] + needDocDeps + withTempDir $ \dir -> do build $ target docContext (Sphinx ManMode) ["docs/users_guide"] [dir] checkSphinxWarnings dir ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -323,8 +323,19 @@ templateRules = do templateRule "utils/ghc-pkg/ghc-pkg.cabal" $ projectVersion templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions + templateRule "rts/include/ghcversion.h" $ mconcat + [ interpolateSetting "ProjectVersionInt" ProjectVersionInt + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1 + , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2 + ] templateRule "docs/index.html" $ packageVersions - templateRule "docs/users_guide/ghc_config.py" $ packageUnitIds Stage1 + templateRule "docs/users_guide/ghc_config.py" $ mconcat + [ projectVersion + , packageUnitIds Stage1 + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + ] -- Generators ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -166,9 +166,14 @@ configureStageArgs = do let cFlags = getStagedCCFlags linkFlags = prgFlags . ccLinkProgram . tgtCCompilerLink <$> getStagedTarget mconcat [ configureArgs cFlags linkFlags - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] +ghcVersionH :: Args +ghcVersionH = notStage0 ? do + let h = "rts/include/ghcversion.h" + expr $ need [h] + arg $ "--ghc-option=-ghcversion-file=" <> h configureArgs :: Args -> Args -> Args configureArgs cFlags' ldFlags' = do @@ -199,7 +204,7 @@ configureArgs cFlags' ldFlags' = do -- ROMES:TODO: how is the Host set to TargetPlatformFull? That would be the target , conf "--host" $ arg =<< getSetting TargetPlatformFull , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] bootPackageConstraints :: Args ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs ===================================== @@ -295,15 +295,15 @@ bignat_shiftr_neg -> State# s -> State# s bignat_shiftr_neg mwa wa n s1 - -- initialize higher limb - = case mwaWrite# mwa (szA -# 1#) 0## s1 of - s2 -> case bignat_shiftr mwa wa n s2 of - s3 -> if nz_shifted_out - -- round if non-zero bits were shifted out - then mwaAddInplaceWord# mwa 0# 1## s3 - else s3 + -- initialize higher limb of mwa + = case mwaSize# mwa s1 of + (# s2, sz_mwa #) -> case mwaWrite# mwa (sz_mwa -# 1#) 0## s2 of + s3 -> case bignat_shiftr mwa wa n s3 of + s4 -> if nz_shifted_out + -- round if non-zero bits were shifted out + then mwaAddInplaceWord# mwa 0# 1## s4 + else s4 where - !szA = wordArraySize# wa !(# nw, nb #) = count_words_bits_int n -- non-zero bits are shifted out? ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/ghcversion.h.top deleted ===================================== @@ -1,3 +0,0 @@ -#if !defined(__GHCVERSION_H__) -#define __GHCVERSION_H__ - ===================================== rts/ghcversion.h.bottom → rts/include/ghcversion.h.in ===================================== @@ -1,3 +1,11 @@ +#if !defined(__GHCVERSION_H__) +#define __GHCVERSION_H__ + +#define __GLASGOW_HASKELL__ @ProjectVersionInt@ +#define __GLASGOW_HASKELL_FULL_VERSION__ "@ProjectVersion@" + +#define __GLASGOW_HASKELL_PATCHLEVEL1__ @ProjectPatchLevel1@ +#define __GLASGOW_HASKELL_PATCHLEVEL2__ @ProjectPatchLevel2@ #define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) ( \ ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \ ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1dd16d2e0458a3bbe79633595d876e929938cf1...6771670d48ff88910c53eea6c38dda469c672c9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e1dd16d2e0458a3bbe79633595d876e929938cf1...6771670d48ff88910c53eea6c38dda469c672c9a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 20:27:04 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 18 Oct 2023 16:27:04 -0400 Subject: [Git][ghc/ghc][wip/mixed-uniqfm] Fixfixfix Message-ID: <65303f97efb87_7336f86939924442032@gitlab.mail> Sebastian Graf pushed to branch wip/mixed-uniqfm at Glasgow Haskell Compiler / GHC Commits: 8e122c96 by Sebastian Graf at 2023-10-18T22:26:58+02:00 Fixfixfix - - - - - 3 changed files: - compiler/GHC/Types/Unique/DFM.hs - compiler/GHC/Types/Unique/FM.hs - compiler/GHC/Types/Var/Env.hs Changes: ===================================== compiler/GHC/Types/Unique/DFM.hs ===================================== @@ -398,7 +398,7 @@ listToUDFM_Directly = foldl' (\m (u, v) -> addToUDFM_Directly m u v) emptyUDFM -- | Apply a function to a particular element adjustUDFM :: Uniquable key => (elt -> elt) -> UniqDFM key elt -> key -> UniqDFM key elt -adjustUDFM f (UDFM m i) k = UDFM (M.adjust (fmap f) (getMixedKey $ getUnique k) m) i +adjustUDFM f m k = adjustUDFM_Directly f m (getUnique k) -- | Apply a function to a particular element adjustUDFM_Directly :: (elt -> elt) -> UniqDFM key elt -> Unique -> UniqDFM key elt ===================================== compiler/GHC/Types/Unique/FM.hs ===================================== @@ -27,6 +27,7 @@ of arguments of combining function. {-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -Wall #-} +{-# OPTIONS_GHC -ddump-simpl -ddump-asm -ddump-cmm -ddump-prep -ddump-to-file #-} module GHC.Types.Unique.FM ( -- * Unique-keyed mappings @@ -124,7 +125,7 @@ type role UniqFM representational representational -- Don't allow coerces over t -- | https://gist.github.com/degski/6e2069d6035ae04d5d6f64981c995ec2 mix :: MS.Key -> MS.Key -> MS.Key {-# INLINE mix #-} -mix k x = fromIntegral $ f $ g $ f $ g $ f $ fromIntegral x +mix k = fromIntegral . f . g . f . g . f . fromIntegral where f y = (y `shiftR` s) `xor` y g z = z * k @@ -137,15 +138,15 @@ kBACKWARD = 0xCFEE444D8B59A89B enc, dec :: MS.Key -> MS.Key enc = mix kFORWARD dec = mix kBACKWARD -{-# INLINE enc #-} -{-# INLINE dec #-} +{-# NOINLINE enc #-} +{-# NOINLINE dec #-} getMixedKey :: Unique -> MS.Key -{-# NOINLINE getMixedKey #-} +{-# INLINE getMixedKey #-} getMixedKey = enc . getKey getUnmixedUnique :: MS.Key -> Unique -{-# NOINLINE getUnmixedUnique #-} +{-# INLINE getUnmixedUnique #-} getUnmixedUnique = mkUniqueGrimily . dec emptyUFM :: UniqFM key elt @@ -239,7 +240,7 @@ addToUFM_L f k v (UFM m) = coerce $ M.insertLookupWithKey (\_ _n _o -> f k _o _n) - (getKey $ getUnique k) + (getMixedKey $ getUnique k) v m @@ -256,7 +257,7 @@ alterUFM_Directly -> UniqFM key elt -- ^ old -> Unique -- ^ new -> UniqFM key elt -- ^ result -alterUFM_Directly f (UFM m) k = UFM (M.alter f (getKey k) m) +alterUFM_Directly f (UFM m) k = UFM (M.alter f (getMixedKey k) m) -- | Add elements to the map, combining existing values with inserted ones using -- the given function. ===================================== compiler/GHC/Types/Var/Env.hs ===================================== @@ -78,7 +78,6 @@ module GHC.Types.Var.Env ( ) where import GHC.Prelude -import qualified GHC.Data.Word64Map.Strict as Word64Map -- TODO: Move this to UniqFM import GHC.Types.Name.Occurrence import GHC.Types.Name @@ -227,14 +226,14 @@ uniqAway' in_scope var -- given 'InScopeSet'. This must be used very carefully since one can very easily -- introduce non-unique 'Unique's this way. See Note [Local uniques]. unsafeGetFreshLocalUnique :: InScopeSet -> Unique -unsafeGetFreshLocalUnique (InScope set) = go (getMixedKey (mkUniqueGrimily (fromIntegral (sizeUniqSet set)))) +unsafeGetFreshLocalUnique (InScope set) = go (fromIntegral (sizeUniqSet set)) where go n | let uniq = mkLocalUnique n - , Nothing <- Word64Map.lookup (getMixedKey $ uniq) (ufmToIntMap $ getUniqSet set) + , Nothing <- lookupUFM_Directly (getUniqSet set) uniq = uniq | otherwise - = go (getMixedKey $ mkUniqueGrimily (n+1)) + = go (n+1) {- ************************************************************************ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e122c96e692ef7be3138b1be0afc478825265bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8e122c96e692ef7be3138b1be0afc478825265bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 23:41:00 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 18 Oct 2023 19:41:00 -0400 Subject: [Git][ghc/ghc][master] 4 commits: Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) Message-ID: <65306d0c8ac4c_7336f8b6d3568453854@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - 10 changed files: - hadrian/doc/flavours.md - hadrian/src/Settings/Flavours/Validate.hs - libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/RtsMessages.c - rts/RtsSymbols.c - rts/include/rts/Messages.h - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T Changes: ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs ===================================== @@ -295,15 +295,15 @@ bignat_shiftr_neg -> State# s -> State# s bignat_shiftr_neg mwa wa n s1 - -- initialize higher limb - = case mwaWrite# mwa (szA -# 1#) 0## s1 of - s2 -> case bignat_shiftr mwa wa n s2 of - s3 -> if nz_shifted_out - -- round if non-zero bits were shifted out - then mwaAddInplaceWord# mwa 0# 1## s3 - else s3 + -- initialize higher limb of mwa + = case mwaSize# mwa s1 of + (# s2, sz_mwa #) -> case mwaWrite# mwa (sz_mwa -# 1#) 0## s2 of + s3 -> case bignat_shiftr mwa wa n s3 of + s4 -> if nz_shifted_out + -- round if non-zero bits were shifted out + then mwaAddInplaceWord# mwa 0# 1## s4 + else s4 where - !szA = wordArraySize# wa !(# nw, nb #) = count_words_bits_int n -- non-zero bits are shifted out? ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/13d3c613c3c1e4942c698449bdf58a6a13b76695...72c7380cb780933825bc84924908e01ce0495dc4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/13d3c613c3c1e4942c698449bdf58a6a13b76695...72c7380cb780933825bc84924908e01ce0495dc4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 23:41:41 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 18 Oct 2023 19:41:41 -0400 Subject: [Git][ghc/ghc][master] Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Message-ID: <65306d352b98d_7336f8b624d104586c9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - 5 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs Changes: ===================================== configure.ac ===================================== @@ -1069,7 +1069,6 @@ AC_CONFIG_FILES( hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - docs/users_guide/ghc_config.py distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ===================================== hadrian/cfg/system.config.in ===================================== @@ -34,6 +34,9 @@ python = @PythonCmd@ cc-llvm-backend = @CcLlvmBackend@ +llvm-min-version = @LlvmMinVersion@ +llvm-max-version = @LlvmMaxVersion@ + # Build options: #=============== ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -49,6 +49,8 @@ data Setting = CursesIncludeDir | GhcPatchLevel | GhcVersion | GhcSourcePath + | LlvmMinVersion + | LlvmMaxVersion | GmpIncludeDir | GmpLibDir | IconvIncludeDir @@ -103,6 +105,8 @@ setting key = lookupSystemConfig $ case key of GhcPatchLevel -> "ghc-patch-level" GhcVersion -> "ghc-version" GhcSourcePath -> "ghc-source-path" + LlvmMinVersion -> "llvm-min-version" + LlvmMaxVersion -> "llvm-max-version" GmpIncludeDir -> "gmp-include-dir" GmpLibDir -> "gmp-lib-dir" IconvIncludeDir -> "iconv-include-dir" ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -356,6 +356,9 @@ buildSphinxInfoGuide = do root <- buildRootRules let path = "GHCUsersGuide" root -/- infoRoot -/- path <.> "info" %> \ file -> do + + needDocDeps + withTempDir $ \dir -> do let rstFilesDir = pathPath path rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"] @@ -391,6 +394,8 @@ buildManPage = do root <- buildRootRules root -/- manPageBuildPath %> \file -> do need ["docs/users_guide/ghc.rst"] + needDocDeps + withTempDir $ \dir -> do build $ target docContext (Sphinx ManMode) ["docs/users_guide"] [dir] checkSphinxWarnings dir ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -324,7 +324,12 @@ templateRules = do templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions templateRule "docs/index.html" $ packageVersions - templateRule "docs/users_guide/ghc_config.py" $ packageUnitIds Stage1 + templateRule "docs/users_guide/ghc_config.py" $ mconcat + [ projectVersion + , packageUnitIds Stage1 + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + ] -- Generators View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f9436990ac1304c8c13b4f1f3ec3e2c3206104e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f9436990ac1304c8c13b4f1f3ec3e2c3206104e3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 18 23:42:29 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 18 Oct 2023 19:42:29 -0400 Subject: [Git][ghc/ghc][master] 2 commits: `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Message-ID: <65306d65e6350_7336f8b6da6384621cd@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 5 changed files: - configure.ac - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Builders/Cabal.hs - − rts/ghcversion.h.top - rts/ghcversion.h.bottom → rts/include/ghcversion.h.in Changes: ===================================== configure.ac ===================================== @@ -68,23 +68,6 @@ FP_PROG_SORT dnl ---------------------------------------------------------- FP_SETUP_PROJECT_VERSION -dnl Don't use AC_DEFINE because it will make C-style comments invalid for -dnl Haskell. - -> rts/include/ghcversion.h - -cat rts/ghcversion.h.top >> rts/include/ghcversion.h - -echo "#define __GLASGOW_HASKELL__ ${ProjectVersionInt}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_FULL_VERSION__ \"${ProjectVersion}\"" >> rts/include/ghcversion.h -echo >> rts/include/ghcversion.h -AS_IF([test x"${ProjectPatchLevel1}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ ${ProjectPatchLevel1}" >> rts/include/ghcversion.h]) -AS_IF([test x"${ProjectPatchLevel2}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL2__ ${ProjectPatchLevel2}" >> rts/include/ghcversion.h]) - -cat rts/ghcversion.h.bottom >> rts/include/ghcversion.h - # Hmmm, we fix the RPM release number to 1 here... Is this convenient? AC_SUBST([release], [1]) @@ -105,8 +88,6 @@ AC_PREREQ([2.69]) AC_CONFIG_HEADER(mk/config.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) -dnl manually outputted above, for reasons described there. -dnl AC_CONFIG_HEADER(rts/include/ghcversion.h) # No, semi-sadly, we don't do `--srcdir'... if test x"$srcdir" != 'x.' ; then ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -323,6 +323,12 @@ templateRules = do templateRule "utils/ghc-pkg/ghc-pkg.cabal" $ projectVersion templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions + templateRule "rts/include/ghcversion.h" $ mconcat + [ interpolateSetting "ProjectVersionInt" ProjectVersionInt + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1 + , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2 + ] templateRule "docs/index.html" $ packageVersions templateRule "docs/users_guide/ghc_config.py" $ mconcat [ projectVersion ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -166,9 +166,14 @@ configureStageArgs = do let cFlags = getStagedCCFlags linkFlags = prgFlags . ccLinkProgram . tgtCCompilerLink <$> getStagedTarget mconcat [ configureArgs cFlags linkFlags - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] +ghcVersionH :: Args +ghcVersionH = notStage0 ? do + let h = "rts/include/ghcversion.h" + expr $ need [h] + arg $ "--ghc-option=-ghcversion-file=" <> h configureArgs :: Args -> Args -> Args configureArgs cFlags' ldFlags' = do @@ -199,7 +204,7 @@ configureArgs cFlags' ldFlags' = do -- ROMES:TODO: how is the Host set to TargetPlatformFull? That would be the target , conf "--host" $ arg =<< getSetting TargetPlatformFull , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] bootPackageConstraints :: Args ===================================== rts/ghcversion.h.top deleted ===================================== @@ -1,3 +0,0 @@ -#if !defined(__GHCVERSION_H__) -#define __GHCVERSION_H__ - ===================================== rts/ghcversion.h.bottom → rts/include/ghcversion.h.in ===================================== @@ -1,3 +1,11 @@ +#if !defined(__GHCVERSION_H__) +#define __GHCVERSION_H__ + +#define __GLASGOW_HASKELL__ @ProjectVersionInt@ +#define __GLASGOW_HASKELL_FULL_VERSION__ "@ProjectVersion@" + +#define __GLASGOW_HASKELL_PATCHLEVEL1__ @ProjectPatchLevel1@ +#define __GLASGOW_HASKELL_PATCHLEVEL2__ @ProjectPatchLevel2@ #define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) ( \ ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f9436990ac1304c8c13b4f1f3ec3e2c3206104e3...0295375a6a43284ed32e2fc39ee4d08c3ef0ab9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f9436990ac1304c8c13b4f1f3ec3e2c3206104e3...0295375a6a43284ed32e2fc39ee4d08c3ef0ab9a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 13:17:24 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 19 Oct 2023 09:17:24 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) Message-ID: <65312c64e2afb_7336f9ed671b4526739@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 8984c6da by Krzysztof Gogolewski at 2023-10-19T09:17:10-04:00 Add a regression test for #24064 - - - - - 61ef0112 by Hécate Moonlight at 2023-10-19T09:17:14-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 28 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/doc/flavours.md - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Flavours/Validate.hs - libraries/base/changelog.md - libraries/base/src/Data/List.hs - libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - libraries/ghc-prim/GHC/Types.hs - rts/RtsMessages.c - rts/RtsSymbols.c - − rts/ghcversion.h.top - rts/ghcversion.h.bottom → rts/include/ghcversion.h.in - rts/include/rts/Messages.h - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - + testsuite/tests/numeric/should_run/T24066.hs - + testsuite/tests/numeric/should_run/T24066.stdout - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/typecheck/should_fail/T24064.hs - + testsuite/tests/typecheck/should_fail/T24064.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== configure.ac ===================================== @@ -68,23 +68,6 @@ FP_PROG_SORT dnl ---------------------------------------------------------- FP_SETUP_PROJECT_VERSION -dnl Don't use AC_DEFINE because it will make C-style comments invalid for -dnl Haskell. - -> rts/include/ghcversion.h - -cat rts/ghcversion.h.top >> rts/include/ghcversion.h - -echo "#define __GLASGOW_HASKELL__ ${ProjectVersionInt}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_FULL_VERSION__ \"${ProjectVersion}\"" >> rts/include/ghcversion.h -echo >> rts/include/ghcversion.h -AS_IF([test x"${ProjectPatchLevel1}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ ${ProjectPatchLevel1}" >> rts/include/ghcversion.h]) -AS_IF([test x"${ProjectPatchLevel2}" != x], - [echo "#define __GLASGOW_HASKELL_PATCHLEVEL2__ ${ProjectPatchLevel2}" >> rts/include/ghcversion.h]) - -cat rts/ghcversion.h.bottom >> rts/include/ghcversion.h - # Hmmm, we fix the RPM release number to 1 here... Is this convenient? AC_SUBST([release], [1]) @@ -105,8 +88,6 @@ AC_PREREQ([2.69]) AC_CONFIG_HEADER(mk/config.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) -dnl manually outputted above, for reasons described there. -dnl AC_CONFIG_HEADER(rts/include/ghcversion.h) # No, semi-sadly, we don't do `--srcdir'... if test x"$srcdir" != 'x.' ; then @@ -1069,7 +1050,6 @@ AC_CONFIG_FILES( hadrian/ghci-cabal hadrian/ghci-multi-cabal hadrian/ghci-stack - docs/users_guide/ghc_config.py distrib/configure.ac hadrian/cfg/default.host.target hadrian/cfg/default.target ===================================== hadrian/cfg/system.config.in ===================================== @@ -34,6 +34,9 @@ python = @PythonCmd@ cc-llvm-backend = @CcLlvmBackend@ +llvm-min-version = @LlvmMinVersion@ +llvm-max-version = @LlvmMaxVersion@ + # Build options: #=============== ===================================== hadrian/doc/flavours.md ===================================== @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH validate -O0
    -H64m - -fllvm-fill-undef-with-garbage + -fllvm-fill-undef-with-garbage
    -fcheck-prim-bounds -O
    -dcore-lint
    -dno-debug-output -O2
    -DDEBUG ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -49,6 +49,8 @@ data Setting = CursesIncludeDir | GhcPatchLevel | GhcVersion | GhcSourcePath + | LlvmMinVersion + | LlvmMaxVersion | GmpIncludeDir | GmpLibDir | IconvIncludeDir @@ -103,6 +105,8 @@ setting key = lookupSystemConfig $ case key of GhcPatchLevel -> "ghc-patch-level" GhcVersion -> "ghc-version" GhcSourcePath -> "ghc-source-path" + LlvmMinVersion -> "llvm-min-version" + LlvmMaxVersion -> "llvm-max-version" GmpIncludeDir -> "gmp-include-dir" GmpLibDir -> "gmp-lib-dir" IconvIncludeDir -> "iconv-include-dir" ===================================== hadrian/src/Rules/Documentation.hs ===================================== @@ -356,6 +356,9 @@ buildSphinxInfoGuide = do root <- buildRootRules let path = "GHCUsersGuide" root -/- infoRoot -/- path <.> "info" %> \ file -> do + + needDocDeps + withTempDir $ \dir -> do let rstFilesDir = pathPath path rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"] @@ -391,6 +394,8 @@ buildManPage = do root <- buildRootRules root -/- manPageBuildPath %> \file -> do need ["docs/users_guide/ghc.rst"] + needDocDeps + withTempDir $ \dir -> do build $ target docContext (Sphinx ManMode) ["docs/users_guide"] [dir] checkSphinxWarnings dir ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -323,8 +323,19 @@ templateRules = do templateRule "utils/ghc-pkg/ghc-pkg.cabal" $ projectVersion templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions + templateRule "rts/include/ghcversion.h" $ mconcat + [ interpolateSetting "ProjectVersionInt" ProjectVersionInt + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1 + , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2 + ] templateRule "docs/index.html" $ packageVersions - templateRule "docs/users_guide/ghc_config.py" $ packageUnitIds Stage1 + templateRule "docs/users_guide/ghc_config.py" $ mconcat + [ projectVersion + , packageUnitIds Stage1 + , interpolateSetting "LlvmMinVersion" LlvmMinVersion + , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion + ] -- Generators ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -166,9 +166,14 @@ configureStageArgs = do let cFlags = getStagedCCFlags linkFlags = prgFlags . ccLinkProgram . tgtCCompilerLink <$> getStagedTarget mconcat [ configureArgs cFlags linkFlags - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] +ghcVersionH :: Args +ghcVersionH = notStage0 ? do + let h = "rts/include/ghcversion.h" + expr $ need [h] + arg $ "--ghc-option=-ghcversion-file=" <> h configureArgs :: Args -> Args -> Args configureArgs cFlags' ldFlags' = do @@ -199,7 +204,7 @@ configureArgs cFlags' ldFlags' = do -- ROMES:TODO: how is the Host set to TargetPlatformFull? That would be the target , conf "--host" $ arg =<< getSetting TargetPlatformFull , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] bootPackageConstraints :: Args ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -35,6 +35,7 @@ validateArgs = sourceArgs SourceArgs -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" + , notStage0 ? arg "-fcheck-prim-bounds" ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] ===================================== libraries/base/changelog.md ===================================== @@ -8,6 +8,7 @@ * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) + * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). ## 4.19.0.0 *TBA* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. ===================================== libraries/base/src/Data/List.hs ===================================== @@ -17,9 +17,10 @@ module Data.List ( + List -- * Basic functions - (++) + , (++) , head , last , tail @@ -222,6 +223,7 @@ import Data.OldList hiding ( all, and, any, concat, concatMap, elem, find, length, notElem, null, or, product, sum ) import GHC.Base ( Bool(..), Eq((==)), otherwise ) +import GHC.List (List) -- | The 'isSubsequenceOf' function takes two lists and returns 'True' if all -- the elements of the first list occur, in order, in the second. The ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs ===================================== @@ -295,15 +295,15 @@ bignat_shiftr_neg -> State# s -> State# s bignat_shiftr_neg mwa wa n s1 - -- initialize higher limb - = case mwaWrite# mwa (szA -# 1#) 0## s1 of - s2 -> case bignat_shiftr mwa wa n s2 of - s3 -> if nz_shifted_out - -- round if non-zero bits were shifted out - then mwaAddInplaceWord# mwa 0# 1## s3 - else s3 + -- initialize higher limb of mwa + = case mwaSize# mwa s1 of + (# s2, sz_mwa #) -> case mwaWrite# mwa (sz_mwa -# 1#) 0## s2 of + s3 -> case bignat_shiftr mwa wa n s3 of + s4 -> if nz_shifted_out + -- round if non-zero bits were shifted out + then mwaAddInplaceWord# mwa 0# 1## s4 + else s4 where - !szA = wordArraySize# wa !(# nw, nb #) = count_words_bits_int n -- non-zero bits are shifted out? ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -135,13 +135,8 @@ bigNatIsTwo# ba = bigNatIsPowerOf2# :: BigNat# -> (# (# #) | Word# #) bigNatIsPowerOf2# a | bigNatIsZero a = (# (# #) | #) - | True = case wordIsPowerOf2# msw of - (# (# #) | #) -> (# (# #) | #) - (# | c #) -> case checkAllZeroes (imax -# 1#) of - 0# -> (# (# #) | #) - _ -> (# | c `plusWord#` - (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) - where + | True = + let msw = bigNatIndex# a imax sz = bigNatSize# a imax = sz -# 1# @@ -150,6 +145,12 @@ bigNatIsPowerOf2# a | True = case bigNatIndex# a i of 0## -> checkAllZeroes (i -# 1#) _ -> 0# + in case wordIsPowerOf2# msw of + (# (# #) | #) -> (# (# #) | #) + (# | c #) -> case checkAllZeroes (imax -# 1#) of + 0# -> (# (# #) | #) + _ -> (# | c `plusWord#` + (int2Word# imax `uncheckedShiftL#` WORD_SIZE_BITS_SHIFT#) #) -- | Return the Word# at the given index bigNatIndex# :: BigNat# -> Int# -> Word# ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -168,15 +168,27 @@ type family Any :: k where { } * * ********************************************************************* -} --- | The builtin list type, usually written in its non-prefix form @[a]@. +-- | The builtin linked list type. -- -- In Haskell, lists are one of the most important data types as they are -- often used analogous to loops in imperative programming languages. --- These lists are singly linked, which makes it unsuited for operations --- that require \(\mathcal{O}(1)\) access. Instead, lists are intended to +-- These lists are singly linked, which makes them unsuited for operations +-- that require \(\mathcal{O}(1)\) access. Instead, they are intended to -- be traversed. -- --- Lists are constructed recursively using the right-associative cons-operator +-- You can use @List a@ or @[a]@ in type signatures: +-- +-- > length :: [a] -> Int +-- +-- or +-- +-- > length :: List a -> Int +-- +-- They are fully equivalent, and @List a@ will be normalised to @[a]@. +-- +-- ==== Usage +-- +-- Lists are constructed recursively using the right-associative constructor operator (or /cons/) -- @(:) :: a -> [a] -> [a]@, which prepends an element to a list, -- and the empty list @[]@. -- @@ -184,6 +196,16 @@ type family Any :: k where { } -- (1 : 2 : 3 : []) == (1 : (2 : (3 : []))) == [1, 2, 3] -- @ -- +-- Lists can also be constructed using list literals +-- of the form @[x_1, x_2, ..., x_n]@ +-- which are syntactic sugar and, unless @-XOverloadedLists@ is enabled, +-- are translated into uses of @(:)@ and @[]@ +-- +-- 'Data.String.String' literals, like @"I 💜 hs"@, are translated into +-- Lists of characters, @[\'I\', \' \', \'💜\', \' \', \'h\', \'s\']@. +-- +-- ==== __Implementation__ +-- -- Internally and in memory, all the above are represented like this, -- with arrows being pointers to locations in memory. -- @@ -193,14 +215,6 @@ type family Any :: k where { } -- > v v v -- > 1 2 3 -- --- As seen above, lists can also be constructed using list literals --- of the form @[x_1, x_2, ..., x_n]@ --- which are syntactic sugar and, unless @-XOverloadedLists@ is enabled, --- are translated into uses of @(:)@ and @[]@ --- --- Similarly, 'Data.String.String' literals of the form @"I 💜 hs"@ are translated into --- Lists of characters, @[\'I\', \' \', \'💜\', \' \', \'h\', \'s\']@. --- -- ==== __Examples__ -- -- @ ===================================== rts/RtsMessages.c ===================================== @@ -326,27 +326,18 @@ rtsDebugMsgFn(const char *s, va_list ap) } -// Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) STG_NORETURN; - void rtsBadAlignmentBarf(void) { barf("Encountered incorrectly aligned pointer. This can't be good."); } -// Used by code generator -void rtsOutOfBoundsAccess(void) STG_NORETURN; - void rtsOutOfBoundsAccess(void) { barf("Encountered out of bounds array access."); } -// Used by code generator -void rtsMemcpyRangeOverlap(void) STG_NORETURN; - void rtsMemcpyRangeOverlap(void) { ===================================== rts/RtsSymbols.c ===================================== @@ -947,6 +947,9 @@ extern char **environ; SymI_HasProto(arenaFree) \ SymI_HasProto(rts_clearMemory) \ SymI_HasProto(setKeepCAFs) \ + SymI_HasProto(rtsBadAlignmentBarf) \ + SymI_HasProto(rtsOutOfBoundsAccess) \ + SymI_HasProto(rtsMemcpyRangeOverlap) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/ghcversion.h.top deleted ===================================== @@ -1,3 +0,0 @@ -#if !defined(__GHCVERSION_H__) -#define __GHCVERSION_H__ - ===================================== rts/ghcversion.h.bottom → rts/include/ghcversion.h.in ===================================== @@ -1,3 +1,11 @@ +#if !defined(__GHCVERSION_H__) +#define __GHCVERSION_H__ + +#define __GLASGOW_HASKELL__ @ProjectVersionInt@ +#define __GLASGOW_HASKELL_FULL_VERSION__ "@ProjectVersion@" + +#define __GLASGOW_HASKELL_PATCHLEVEL1__ @ProjectPatchLevel1@ +#define __GLASGOW_HASKELL_PATCHLEVEL2__ @ProjectPatchLevel2@ #define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) ( \ ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \ ===================================== rts/include/rts/Messages.h ===================================== @@ -78,7 +78,6 @@ void debugBelch(const char *s, ...) int vdebugBelch(const char *s, va_list ap); - /* Hooks for redirecting message generation: */ typedef void RtsMsgFunction(const char *, va_list); @@ -94,3 +93,8 @@ extern RtsMsgFunction rtsFatalInternalErrorFn; extern RtsMsgFunctionRetLen rtsDebugMsgFn; extern RtsMsgFunction rtsErrorMsgFn; extern RtsMsgFunction rtsSysErrorMsgFn; + +/* Used by code generator */ +void rtsBadAlignmentBarf(void) STG_NORETURN; +void rtsOutOfBoundsAccess(void) STG_NORETURN; +void rtsMemcpyRangeOverlap(void) STG_NORETURN; ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/numeric/should_run/T24066.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +module Main where + +import GHC.Num.BigNat +import GHC.Exts + +-- just to ensure that (future) rewrite rules don't mess with the test +{-# NOINLINE foo #-} +foo (# #) = bigNatZero# (# #) + +main = do + case bigNatIsPowerOf2# (foo (# #)) of + (# _ | #) -> putStrLn "Zero isn't a power of two" + (# | w #) -> putStrLn $ "Zero is 2^" ++ show (W# w) ===================================== testsuite/tests/numeric/should_run/T24066.stdout ===================================== @@ -0,0 +1 @@ +Zero isn't a power of two ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -81,3 +81,4 @@ test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) test('T22671', normal, compile_and_run, ['']) test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers']) +test('T24066', normal, compile_and_run, ['']) ===================================== testsuite/tests/typecheck/should_fail/T24064.hs ===================================== @@ -0,0 +1,48 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} + +module T24064 where + +class C1 b where + type F1 b + +class C2 (m :: * -> *) where + type F2 m + +class C3 r where + type F3 r + +class G t m where + g :: m a -> t m a + +data Y + +data X e a + +data H a + +data S a + +fun1 :: X e () +fun1 = undefined + +fun2 :: S () +fun2 = undefined + +fun3 :: H () +fun3 = undefined + +fun4 :: (F3 r ~ F1 (F2 m)) => r -> m () +fun4 = undefined + +test :: (C2 m, F2 m ~ Y) => m () +test = do + fun1 + fun2 + g fun3 + fun4 undefined + +main :: IO () +main = pure () ===================================== testsuite/tests/typecheck/should_fail/T24064.stderr ===================================== @@ -0,0 +1,26 @@ + +T24064.hs:42:3: error: [GHC-25897] + • Could not deduce ‘m ~ X e0’ + from the context: (C2 m, F2 m ~ Y) + bound by the type signature for: + test :: forall (m :: * -> *). (C2 m, F2 m ~ Y) => m () + at T24064.hs:40:1-32 + Expected: m () + Actual: X e0 () + ‘m’ is a rigid type variable bound by + the type signature for: + test :: forall (m :: * -> *). (C2 m, F2 m ~ Y) => m () + at T24064.hs:40:1-32 + • In a stmt of a 'do' block: fun1 + In the expression: + do fun1 + fun2 + g fun3 + fun4 undefined + In an equation for ‘test’: + test + = do fun1 + fun2 + g fun3 + .... + • Relevant bindings include test :: m () (bound at T24064.hs:41:1) ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -704,3 +704,4 @@ test('T22478c', normal, compile_fail, ['']) test('T23776', normal, compile, ['']) # to become an error in GHC 9.12 test('T17940', normal, compile_fail, ['']) test('ErrorIndexLinks', normal, compile_fail, ['-fprint-error-index-links=always']) +test('T24064', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6771670d48ff88910c53eea6c38dda469c672c9a...61ef011200275ed2d3bf3e3fc02dde253f0e3fe2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6771670d48ff88910c53eea6c38dda469c672c9a...61ef011200275ed2d3bf3e3fc02dde253f0e3fe2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 14:12:41 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 19 Oct 2023 10:12:41 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T24106 Message-ID: <65313959be36e_7336fa047dba054569@gitlab.mail> Ben Gamari pushed new branch wip/T24106 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24106 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 14:18:05 2023 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 19 Oct 2023 10:18:05 -0400 Subject: [Git][ghc/ghc][wip/T24106] 1599 commits: Bump GHC version to 9.7 Message-ID: <65313a9dabc0b_7336fa046695054728f@gitlab.mail> Ben Gamari pushed to branch wip/T24106 at Glasgow Haskell Compiler / GHC Commits: fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00 Bump GHC version to 9.7 - - - - - 914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05:00 Don't consider large byte arrays/compact regions pinned. Workaround for #22255 which showed how treating large/compact regions as pinned could cause segfaults. - - - - - 32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00 hadrian bindist: Install manpages to share/man/man1/ghc.1 When the installation makefile was copied over the manpages were no longer installed in the correct place. Now we install it into share/man/man1/ghc.1 as the make build system did. Fixes #22371 - - - - - b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00 rts: Drop paths from configure from cabal file A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them. - - - - - b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00 Bump libffi-tarballs submodule We will now use libffi-3.4.4. - - - - - 3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00 EPA: Make EOF position part of AnnsModule Closes #20951 Closes #19697 - - - - - 99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00 JS: fix support for -outputdir (#22641) The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug. - - - - - 02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00 Refactor mkRuntimeError This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions. - - - - - 35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00 base: Fix event manager shutdown race on non-Linux platforms During shutdown it's possible that we will attempt to use a closed fd to wakeup another capability's event manager. On the Linux eventfd path we were careful to handle this. However on the non-Linux path we failed to do so. Fix this. - - - - - 317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00 Fix unifier bug: failing to decompose over-saturated type family This simple patch fixes #22647 - - - - - 14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00 rts/m32: Fix sanity checking Previously we would attempt to clear pages which were marked as read-only. Fix this. - - - - - 16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00 ci: Move wasm pipelines into nightly rather than master See #22664 for the changes which need to be made to bring one of these back to the validate pipeline. - - - - - 18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix segment list races - - - - - 602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - 9d63b160 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Eliminate race in bump_static_flag To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer. - - - - - 26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 8093264a by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix races in collector status tracking Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN. - - - - - 387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make segment state updates atomic - - - - - 543cae00 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy. - - - - - c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - 0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make bitmap accesses atomic This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN. - - - - - d3fe110a by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix benign race in update remembered set check Relaxed load is fine here since we will take the lock before looking at the list. - - - - - ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Fix race in shortcutting We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee. - - - - - 36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - aebef31c by doyougnu at 2022-12-23T19:10:09-05:00 add GHC.Utils.Binary.foldGet' and use for Iface A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang - - - - - 5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-05:00 compiler: Ensure that GHC toolchain is first in search path As noted in #22561, it is important that GHC's toolchain look first for its own headers and libraries to ensure that the system's are not found instead. If this happens things can break in surprising ways (e.g. see #22561). - - - - - cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00 head.hackage: Use slow-validate bindist for linting jobs This enables the SLOW_VALIDATE env var for the linting head.hackage jobs, namely the jobs enabled manually, by the label or on the nightly build now use the deb10-numa-slow-validate bindist which has assertions enabled. See #22623 for a ticket which was found by using this configuration already! The head.hackage jobs triggered by upstream CI are now thusly: hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build. Runs head.hackage with -dlint and a slow-validate bindist hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate head.hackage build with -dlint. nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config. nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled. release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist. - - - - - f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Don't run abi-test-nightly on release jobs The test is not configured to get the correct dependencies for the release pipelines (and indeed stops the release pipeline being run at all) - - - - - c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00 ci: Run head.hackage jobs on upstream-testing branch rather than master This change allows less priviledged users to trigger head.hackage jobs because less permissions are needed to trigger jobs on the upstream-testing branch, which is not protected. There is a CI job which updates upstream-testing each hour to the state of the master branch so it should always be relatively up-to-date. - - - - - 63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00 llvmGen: Fix relaxed ordering Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640 - - - - - f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00 gitlab-ci: Introduce aarch64-linux-llvm job This nightly job will ensure that we don't break the LLVM backend on AArch64/Linux by bootstrapping GHC. This would have caught #22640. - - - - - 6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00 Store RdrName rather than OccName in Holes In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130 - - - - - 3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d - - - - - 6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00 hadrian: Ensure that linker scripts are used when merging objects In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's implementation of the object merging rules: unlike the old `make` build system we utterly failed to pass the needed linker scripts. Fix this. - - - - - a5bd0eb8 by Andrew Lelechenko at 2022-12-24T21:10:34-05:00 Document infelicities of instance Ord Double and workarounds - - - - - 62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+00:00 Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Involves adding many new NFData instances. Without forcing Docs, references to the TcGblEnv for each module are retained by the Docs structure. Usually these are forced when the ModIface is serialised but not when we aren't writing the interface. - - - - - 21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00 Explain the auxiliary functions of permutations - - - - - 32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00:00 compiler: Add -f[no-]split-sections flags Here we add a `-fsplit-sections` flag which may some day replace `-split-sections`. This has the advantage of automatically providing a `-fno-split-sections` flag, which is useful for our packaging because we enable `-split-sections` by default but want to disable it in certain configurations. - - - - - e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - fec6638e by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Add no_split_sections tranformer This transformer reverts the effect of `split_sections`, which we intend to use for platforms which don't support split sections. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. - - - - - 3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00 check-exact: Fix build with -Werror - - - - - 53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+00:00 ci: Build all test dependencies with in-tree compiler This means that these executables will honour flavour transformers such as "werror". Fixes #22555 - - - - - 32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+00:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00 sphinx: Use modern syntax for extlinks This fixes the following build error: ``` Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273 ===> Command failed with error code: 2 Exception occurred: File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role title = caption % part ~~~~~~~~^~~~~~ TypeError: not all arguments converted during string formatting ``` I tested on Sphinx-5.1.1 and Sphinx-6.0.0 Thanks for sterni for providing instructions about how to test using sphinx-6.0.0. Fixes #22690 - - - - - 541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00 Misc cleanup - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well. - - - - - 22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00 EPA: Do not collect comments from end of file In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead. - - - - - 9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00 Revert "configure: Drop uses of AC_PROG_CC_C99" This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6. Centos7 using a very old version of the toolchain (autotools-2.69) where the behaviour of these macros has not yet changed. I am reverting this without haste as it is blocking the 9.6 branch. Fixes #22704 - - - - - 28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00 Add support for sized literals in the bytecode interpreter. The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945 - - - - - ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00 Only store Name in FunRhs rather than Id with knot-tied fields All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695 - - - - - c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00 darwin ci: Explicitly pass desired build triple to configure On the zw3rk machines for some reason the build machine was inferred to be arm64. Setting the build triple appropiately resolve this confusion and we produce x86 binaries. - - - - - 2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00 rts: MUT_VAR is not a StgMutArrPtrs There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs. - - - - - 6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00 Make FloatIn robust to shadowing This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4 - - - - - a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00 T10955: Set DYLD_LIBRARY_PATH for darwin The correct path to direct the dynamic linker on darwin is DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX using LD_LIBRARY_PATH seems to have stopped working. For more reading see: https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s - - - - - 73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00 Skip T18623 on darwin (to add to the long list of OSs) On recent versions of OSX, running `ulimit -v` results in ``` ulimit: setrlimit failed: invalid argument ``` Time is too short to work out what random stuff Apple has been doing with ulimit, so just skip the test like we do for other platforms. - - - - - 8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00 Pass -Wl,-no_fixup_chains to ld64 when appropiate Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default. This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on darwin. This results in a warning of the form: ld: warning: -undefined dynamic_lookup may not work with chained fixups The manual explains the incompatible nature of these two flags: -undefined treatment Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error. Note: dynamic_lookup that depends on lazy binding will not work with chained fixups. A relevant ticket is #22429 Here are also a few other links which are relevant to the issue: Official comment: https://developer.apple.com/forums/thread/719961 More relevant links: https://openradar.appspot.com/radar?id=5536824084660224 https://github.com/python/cpython/issues/97524 Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas e-notes - - - - - 365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00 Disable split sections on aarch64-deb10 build See #22722 Failure on this job: https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852 ``` Unexpected failures: /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T10828.run T10828 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T13123.run T13123 [exit code non-0] (ext-interp) /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test spaces/testsuite/tests/th/T20590.run T20590 [exit code non-0] (ext-interp) Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv ``` ``` Compile failed (exit code 1) errors were: data family D_0 a_1 :: * -> * data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool data E_3 where MkE_4 :: a_5 -> E_3 data Foo_6 a_7 b_8 where MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12 newtype Bar_13 :: * -> GHC.Types.Bool -> * where MkBar_14 :: a_15 -> Bar_13 a_15 b_16 data T10828.T (a_0 :: *) where T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1 T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2 GHC.Types.Int => {T10828.foo :: a_2, T10828.bar :: b_3} -> T10828.T GHC.Types.Int T10828.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: (do TyConI dec <- runQ $ reify (mkName "T") runIO $ putStrLn (pprint dec) >> hFlush stdout d <- runQ $ [d| data T' a :: Type where MkT' :: a -> a -> T' a MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |] runIO $ putStrLn (pprint d) >> hFlush stdout ....) *** unexpected failure for T10828(ext-interp) =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] =====> 7000 of 9215 [0, 1, 0] Compile failed (exit code 1) errors were: T13123.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data GADT where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |]) *** unexpected failure for T13123(ext-interp) =====> 7100 of 9215 [0, 2, 0] =====> 7100 of 9215 [0, 2, 0] =====> 7200 of 9215 [0, 2, 0] Compile failed (exit code 1) errors were: T20590.hs:1:1: error: [GHC-87897] Exception when trying to run compile-time code: ghc-iserv terminated (-4) Code: ([d| data T where MkT :: forall a. a -> T |]) *** unexpected failure for T20590(ext-interp) ``` Looks fairly worrying to me. - - - - - 965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00 EPA: exact print HsDocTy To match ghc-exactprint https://github.com/alanz/ghc-exactprint/pull/121 - - - - - 5d65773e by John Ericson at 2023-01-09T20:39:27-05:00 Remove RTS hack for configuring See the brand new Note [Undefined symbols in the RTS] for additional details. - - - - - e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00 Handle shadowing in DmdAnal (#22718) Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite - - - - - d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00 Add safe list indexing operator: !? With Joachim's amendments. Implements https://github.com/haskell/core-libraries-committee/issues/110 - - - - - cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00 rts, tests: limit thread name length to 15 bytes On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796 - - - - - 64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00 Store bootstrap_llvm_target and use it to set LlvmTarget in bindists This mirrors some existing logic for the bootstrap_target which influences how TargetPlatform is set. As described on #21970 not storing this led to `LlvmTarget` being set incorrectly and hence the wrong `--target` flag being passed to the C compiler. Towards #21970 - - - - - 4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00 Check for FP_LD_NO_FIXUP_CHAINS in installation configure script Otherwise, when installing from a bindist the C flag isn't passed to the C compiler. This completes the fix for #22429 - - - - - 2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00 Fix outdated link to Happy section on sequences - - - - - 146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00 Revert "NCG(x86): Compile add+shift as lea if possible." This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777 - - - - - 6e6adbe3 by Jade Lovelace at 2023-01-11T00:55:30-05:00 Fix tcPluginRewrite example - - - - - faa57138 by Jade Lovelace at 2023-01-11T00:55:31-05:00 fix missing haddock pipe - - - - - 0470ea7c by Florian Weimer at 2023-01-11T00:56:10-05:00 m4/fp_leading_underscore.m4: Avoid implicit exit function declaration And switch to a new-style function definition. Fixes build issues with compilers that do not accept implicit function declarations. - - - - - b2857df4 by HaskellMouse at 2023-01-11T00:56:52-05:00 Added a new warning about compatibility with RequiredTypeArguments This commit introduces a new warning that indicates code incompatible with future extension: RequiredTypeArguments. Enabling this extension may break some code and the warning will help to make it compatible in advance. - - - - - 5f17e21a by Ben Gamari at 2023-01-11T00:57:27-05:00 testsuite: Drop testheapalloced.c As noted in #22414, this file (which appears to be a benchmark for characterising the one-step allocator's MBlock cache) is currently unreferenced. Remove it. Closes #22414. - - - - - bc125775 by Vladislav Zavialov at 2023-01-11T00:58:03-05:00 Introduce the TypeAbstractions language flag GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 083f7015 by Krzysztof Gogolewski at 2023-01-11T00:58:38-05:00 Misc cleanup - Remove unused mkWildEvBinder - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault - - - - - aed1974e by Richard Eisenberg at 2023-01-11T08:30:42+00:00 Refactor the treatment of loopy superclass dicts This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666 and #19690 The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. * Treat the head of a Wanted quantified constraint in the same way as the superclass of an instance decl; this is what fixes #19690. See GHC.Tc.Solver.Canonical Note [Solving a Wanted forall-constraint] (Thanks to Matthew Craven for this insight.) This entailed refactoring the GivenSc constructor of CtOrigin a bit, to say whether it comes from an instance decl or quantified constraint. * Some refactoring way in which redundant constraints are reported; we don't want to complain about the extra, apparently-redundant constraints that we must add to an instance decl because of the loopy-superclass thing. I moved some work from GHC.Tc.Errors to GHC.Tc.Solver. * Add a new section to the user manual to describe the loopy superclass issue and what rules it follows. - - - - - 300bcc15 by HaskellMouse at 2023-01-11T13:43:36-05:00 Parse qualified terms in type signatures This commit allows qualified terms in type signatures to pass the parser and to be cathced by renamer with more informative error message. Adds a few tests. Fixes #21605 - - - - - 964284fc by Simon Peyton Jones at 2023-01-11T13:44:12-05:00 Fix void-arg-adding mechanism for worker/wrapper As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo. - - - - - f7ceafc9 by Krzysztof Gogolewski at 2023-01-11T22:36:59-05:00 Add 'docWithStyle' to improve codegen This new combinator docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc let us remove the need for code to be polymorphic in HDoc when not used in code style. Metric Decrease: ManyConstructors T13035 T1969 - - - - - b3be0d18 by Simon Peyton Jones at 2023-01-11T22:37:35-05:00 Fix finaliseArgBoxities for OPAQUE function We never do worker wrapper for OPAQUE functions, so we must zap the unboxing info during strictness analysis. This patch fixes #22502 - - - - - db11f358 by Ben Gamari at 2023-01-12T07:49:04-05:00 Revert "rts: Drop racy assertion" The logic here was inverted. Reverting the commit to avoid confusion when examining the commit history. This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1. - - - - - 3242139f by Ben Gamari at 2023-01-12T07:49:04-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - 9ffd5d57 by Ben Gamari at 2023-01-12T07:49:41-05:00 configure: Fix escaping of `$tooldir` In !9547 I introduced `$tooldir` directories into GHC's default link and compilation flags to ensure that our C toolchain finds its own headers and libraries before others on the system. However, the patch was subtly wrong in the escaping of `$tooldir`. Fix this. Fixes #22561. - - - - - 905d0b6e by Sebastian Graf at 2023-01-12T15:51:47-05:00 Fix contification with stable unfoldings (#22428) Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with a `JoinArity` that reflects the number of join point binders around the body for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`. I adjusted `Note [Join points and unfoldings/rules]` and `Note [Adjusting right-hand sides]` to account for the new machinery. I also wrote a new `Note [Join arity prediction based on joinRhsArity]` and refer to it when we combine `TailUsageDetails` for a recursive RHS. I also renamed * `occAnalLam` to `occAnalLamTail` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed `NodeDetails` called `SimpleNodeDetails`. Fixes #22428. The refactoring seems to have quite beneficial effect on ghc/alloc performance: ``` CoOpt_Read(normal) ghc/alloc 784,778,420 768,091,176 -2.1% GOOD T12150(optasm) ghc/alloc 77,762,270 75,986,720 -2.3% GOOD T12425(optasm) ghc/alloc 85,740,186 84,641,712 -1.3% GOOD T13056(optasm) ghc/alloc 306,104,656 299,811,632 -2.1% GOOD T13253(normal) ghc/alloc 350,233,952 346,004,008 -1.2% T14683(normal) ghc/alloc 2,800,514,792 2,754,651,360 -1.6% T15304(normal) ghc/alloc 1,230,883,318 1,215,978,336 -1.2% T15630(normal) ghc/alloc 153,379,590 151,796,488 -1.0% T16577(normal) ghc/alloc 7,356,797,056 7,244,194,416 -1.5% T17516(normal) ghc/alloc 1,718,941,448 1,692,157,288 -1.6% T19695(normal) ghc/alloc 1,485,794,632 1,458,022,112 -1.9% T21839c(normal) ghc/alloc 437,562,314 431,295,896 -1.4% GOOD T21839r(normal) ghc/alloc 446,927,580 440,615,776 -1.4% GOOD geo. mean -0.6% minimum -2.4% maximum -0.0% ``` Metric Decrease: CoOpt_Read T10421 T12150 T12425 T13056 T18698a T18698b T21839c T21839r T9961 - - - - - a1491c87 by Andreas Klebinger at 2023-01-12T15:52:23-05:00 Only gc sparks locally when we can ensure marking is done. When performing GC without work stealing there was no guarantee that spark pruning was happening after marking of the sparks. This could cause us to GC live sparks under certain circumstances. Fixes #22528. - - - - - 8acfe930 by Cheng Shao at 2023-01-12T15:53:00-05:00 Change MSYSTEM to CLANG64 uniformly - - - - - 73bc162b by M Farkas-Dyck at 2023-01-12T15:53:42-05:00 Make `GHC.Tc.Errors.Reporter` take `NonEmpty ErrorItem` rather than `[ErrorItem]`, which lets us drop some panics. Also use the `BasicMismatch` constructor rather than `mkBasicMismatchMsg`, which lets us drop the "-Wno-incomplete-record-updates" flag. - - - - - 1b812b69 by Oleg Grenrus at 2023-01-12T15:54:21-05:00 Fix #22728: Not all diagnostics in safe check are fatal Also add tests for the issue and -Winferred-safe-imports in general - - - - - c79b2b65 by Matthew Pickering at 2023-01-12T15:54:58-05:00 Don't run hadrian-multi on fast-ci label Fixes #22667 - - - - - 9a3d6add by Andrew Lelechenko at 2023-01-13T00:46:36-05:00 Bump submodule bytestring to 0.11.4.0 Metric Decrease: T21839c T21839r - - - - - df33c13c by Ben Gamari at 2023-01-13T00:47:12-05:00 gitlab-ci: Bump Darwin bootstrap toolchain This updates the bootstrap compiler on Darwin from 8.10.7 to 9.2.5, ensuring that we have the fix for #21964. - - - - - 756a66ec by Ben Gamari at 2023-01-13T00:47:12-05:00 gitlab-ci: Pass -w to cabal update Due to cabal#8447, cabal-install 3.8.1.0 requires a compiler to run `cabal update`. - - - - - 1142f858 by Cheng Shao at 2023-01-13T11:04:00+00:00 Bump hsc2hs submodule - - - - - d4686729 by Cheng Shao at 2023-01-13T11:04:00+00:00 Bump process submodule - - - - - 84ae6573 by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: Bump DOCKER_REV - - - - - d53598c5 by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: enable xz parallel compression for x64 jobs - - - - - d31fcbca by Cheng Shao at 2023-01-13T11:06:58+00:00 ci: use in-image emsdk for js jobs - - - - - 93b9bbc1 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: improve nix-shell for gen_ci.hs and fix some ghc/hlint warnings - Add a ghc environment including prebuilt dependencies to the nix-shell. Get rid of the ad hoc cabal cache and all dependencies are now downloaded from the nixos binary cache. - Make gen_ci.hs a cabal package with HLS integration, to make future hacking of gen_ci.hs easier. - Fix some ghc/hlint warnings after I got HLS to work. - For the lint-ci-config job, do a shallow clone to save a few minutes of unnecessary git checkout time. - - - - - 8acc56c7 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: source the toolchain env file in wasm jobs - - - - - 87194df0 by Cheng Shao at 2023-01-13T11:47:17+00:00 ci: add wasm ci jobs via gen_ci.hs - There is one regular wasm job run in validate pipelines - Additionally, int-native/unreg wasm jobs run in nightly/release pipelines Also, remove the legacy handwritten wasm ci jobs in .gitlab-ci.yml. - - - - - b6eb9bcc by Matthew Pickering at 2023-01-13T11:52:16+00:00 wasm ci: Remove wasm release jobs This removes the wasm release jobs, as we do not yet intend to distribute these binaries. - - - - - 496607fd by Simon Peyton Jones at 2023-01-13T16:52:07-05:00 Add a missing checkEscapingKind Ticket #22743 pointed out that there is a missing check, for type-inferred bindings, that the inferred type doesn't have an escaping kind. The fix is easy. - - - - - 7a9a1042 by Andreas Klebinger at 2023-01-16T20:48:19-05:00 Separate core inlining logic from `Unfolding` type. This seems like a good idea either way, but is mostly motivated by a patch where this avoids a module loop. - - - - - 33b58f77 by sheaf at 2023-01-16T20:48:57-05:00 Hadrian: generalise &%> to avoid warnings This patch introduces a more general version of &%> that works with general traversable shapes, instead of lists. This allows us to pass along the information that the length of the list of filepaths passed to the function exactly matches the length of the input list of filepath patterns, avoiding pattern match warnings. Fixes #22430 - - - - - 8c7a991c by Andreas Klebinger at 2023-01-16T20:49:34-05:00 Add regression test for #22611. A case were a function used to fail to specialize, but now does. - - - - - 6abea760 by Andreas Klebinger at 2023-01-16T20:50:10-05:00 Mark maximumBy/minimumBy as INLINE. The RHS was too large to inline which often prevented the overhead of the Maybe from being optimized away. By marking it as INLINE we can eliminate the overhead of both the maybe and are able to unpack the accumulator when possible. Fixes #22609 - - - - - 99d151bb by Matthew Pickering at 2023-01-16T20:50:50-05:00 ci: Bump CACHE_REV so that ghc-9.6 branch and HEAD have different caches Having the same CACHE_REV on both branches leads to issues where the darwin toolchain is different on ghc-9.6 and HEAD which leads to long darwin build times. In general we should ensure that each branch has a different CACHE_REV. - - - - - 6a5845fb by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Change owner of files in source-tarball job This fixes errors of the form: ``` fatal: detected dubious ownership in repository at '/builds/ghc/ghc' To add an exception for this directory, call: git config --global --add safe.directory /builds/ghc/ghc inferred 9.7.20230113 checking for GHC Git commit id... fatal: detected dubious ownership in repository at '/builds/ghc/ghc' To add an exception for this directory, call: git config --global --add safe.directory /builds/ghc/ghc ``` - - - - - 4afb952c by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Don't build aarch64-deb10-llvm job on release pipelines Closes #22721 - - - - - 8039feb9 by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Change owner of files in test-bootstrap job - - - - - 0b358d0c by Matthew Pickering at 2023-01-16T20:51:25-05:00 rel_eng: Add release engineering scripts into ghc tree It is better to keep these scripts in the tree as they depend on the CI configuration and so on. By keeping them in tree we can keep them up-to-date as the CI config changes and also makes it easier to backport changes to the release script between release branches in future. The final motivation is that it makes generating GHCUp metadata possible. - - - - - 28cb2ed0 by Matthew Pickering at 2023-01-16T20:51:25-05:00 ci: Don't use complicated image or clone in not-interruptible job This job exists only for the meta-reason of not allowing nightly pipelines to be cancelled. It was taking two minutes to run as in order to run "true" we would also clone the whole GHC repo. - - - - - eeea59bb by Matthew Pickering at 2023-01-16T20:51:26-05:00 Add scripts to generate ghcup metadata on nightly and release pipelines 1. A python script in .gitlab/rel_eng/mk-ghcup-metadata which generates suitable metadata for consumption by GHCUp for the relevant pipelines. - The script generates the metadata just as the ghcup maintainers want, without taking into account platform/library combinations. It is updated manually when the mapping changes. - The script downloads the bindists which ghcup wants to distribute, calculates the hash and generates the yaml in the correct structure. - The script is documented in the .gitlab/rel_eng/mk-ghcup-metadata/README.mk file 1a. The script requires us to understand the mapping from platform -> job. To choose the preferred bindist for each platform the .gitlab/gen_ci.hs script is modified to allow outputting a metadata file which answers the question about which job produces the bindist which we want to distribute to users for a specific platform. 2. Pipelines to run on nightly and release jobs to generate metadata - ghcup-metadata-nightly: Generates metadata which points directly to artifacts in the nightly job. - ghcup-metadata-release: Generates metadata suitable for inclusion directly in ghcup by pointing to the downloads folder where the bindist will be uploaded to. 2a. Trigger jobs which test the generated metadata in the downstream `ghccup-ci` repo. See that repo for documentation about what is tested and how but essentially we test in a variety of clean images that ghcup can download and install the bindists we say exist in our metadata. - - - - - 97bd4d8c by Andrew Lelechenko at 2023-01-16T20:52:04-05:00 Bump submodule parsec to 3.1.16.1 - - - - - 97ac8230 by Alan Zimmerman at 2023-01-16T20:52:39-05:00 EPA: Add annotation for 'type' in DataDecl Closes #22765 - - - - - dbbab95d by Ben Gamari at 2023-01-17T06:36:06-05:00 compiler: Small optimisation of assertM In #22739 @AndreasK noticed that assertM performed the action to compute the asserted predicate regardless of whether DEBUG is enabled. This is inconsistent with the other assertion operations and general convention. Fix this. Closes #22739. - - - - - fc02f3bb by Viktor Dukhovni at 2023-01-17T06:36:47-05:00 Avoid unnecessary printf warnings in EventLog.c Fixes #22778 - - - - - 003b6d44 by Simon Peyton Jones at 2023-01-17T16:33:05-05:00 Document the semantics of pattern bindings a bit better This MR is in response to the discussion on #22719 - - - - - f4d50baf by Vladislav Zavialov at 2023-01-17T16:33:41-05:00 Hadrian: fix warnings (#22783) This change fixes the following warnings when building Hadrian: src/Hadrian/Expression.hs:38:10: warning: [-Wredundant-constraints] src/Hadrian/Expression.hs:84:13: warning: [-Wtype-equality-requires-operators] src/Hadrian/Expression.hs:84:21: warning: [-Wtype-equality-requires-operators] src/Hadrian/Haskell/Cabal/Parse.hs:67:1: warning: [-Wunused-imports] - - - - - 06036d93 by Sylvain Henry at 2023-01-18T01:55:10-05:00 testsuite: req_smp --> req_target_smp, req_ghc_smp See #22630 and !9552 This commit: - splits req_smp into req_target_smp and req_ghc_smp - changes the testsuite driver to calculate req_ghc_smp - changes a handful of tests to use req_target_smp instead of req_smp - changes a handful of tests to use req_host_smp when needed The problem: - the problem this solves is the ambiguity surrounding req_smp - on master req_smp was used to express the constraint that the program being compiled supports smp _and_ that the host RTS (i.e., the RTS used to compile the program) supported smp. Normally that is fine, but in cross compilation this is not always the case as was discovered in #22630. The solution: - Differentiate the two constraints: - use req_target_smp to say the RTS the compiled program is linked with (and the platform) supports smp - use req_host_smp to say the RTS the host is linked with supports smp WIP: fix req_smp (target vs ghc) add flag to separate bootstrapper split req_smp -> req_target_smp and req_ghc_smp update tests smp flags cleanup and add some docstrings only set ghc_with_smp to bootstrapper on S1 or CC Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1 and cross compiling test the RTS in config/ghc not hadrian re-add ghc_with_smp fix and align req names fix T11760 to use req_host_smp test the rts directly, avoid python 3.5 limitation test the compiler in a try block align out of tree and in tree withSMP flags mark failing tests as host req smp testsuite: req_host_smp --> req_ghc_smp Fix ghc vs host, fix ghc_with_smp leftover - - - - - ee9b78aa by Krzysztof Gogolewski at 2023-01-18T01:55:45-05:00 Use -Wdefault when running Python testdriver (#22727) - - - - - e9c0537c by Vladislav Zavialov at 2023-01-18T01:56:22-05:00 Enable -Wstar-is-type by default (#22759) Following the plan in GHC Proposal #143 "Remove the * kind syntax", which states: In the next release (or 3 years in), enable -fwarn-star-is-type by default. The "next release" happens to be 9.6.1 I also moved the T21583 test case from should_fail to should_compile, because the only reason it was failing was -Werror=compat in our test suite configuration. - - - - - 4efee43d by Ryan Scott at 2023-01-18T01:56:59-05:00 Add missing parenthesizeHsType in cvtSigTypeKind We need to ensure that the output of `cvtSigTypeKind` is parenthesized (at precedence `sigPrec`) so that any type signatures with an outermost, explicit kind signature can parse correctly. Fixes #22784. - - - - - f891a442 by Ben Gamari at 2023-01-18T07:28:00-05:00 Bump ghc-tarballs to fix #22497 It turns out that gmp 6.2.1 uses the platform-reserved `x18` register on AArch64/Darwin. This was fixed in upstream changeset 18164:5f32dbc41afc, which was merged in 2020. Here I backport this patch although I do hope that a new release is forthcoming soon. Bumps gmp-tarballs submodule. Fixes #22497. - - - - - b13c6ea5 by Ben Gamari at 2023-01-18T07:28:00-05:00 Bump gmp-tarballs submodule This backports the upstream fix for CVE-2021-43618, fixing #22789. - - - - - c45a5fff by Cheng Shao at 2023-01-18T07:28:37-05:00 Fix typo in recent darwin tests fix Corrects a typo in !9647. Otherwise T18623 will still fail on darwin and stall other people's work. - - - - - b4c14c4b by Luite Stegeman at 2023-01-18T14:21:42-05:00 Add PrimCallConv support to GHCi This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051 - - - - - d0a63ef8 by Adam Gundry at 2023-01-18T14:22:26-05:00 Refactor warning flag parsing to add missing flags This adds `-Werror=<group>` and `-fwarn-<group>` flags for warning groups as well as individual warnings. Previously these were defined on an ad hoc basis so for example we had `-Werror=compat` but not `-Werror=unused-binds`, whereas we had `-fwarn-unused-binds` but not `-fwarn-compat`. Fixes #22182. - - - - - 7ed1b8ef by Adam Gundry at 2023-01-18T14:22:26-05:00 Minor corrections to comments - - - - - 5389681e by Adam Gundry at 2023-01-18T14:22:26-05:00 Revise warnings documentation in user's guide - - - - - ab0d5cda by Adam Gundry at 2023-01-18T14:22:26-05:00 Move documentation of deferred type error flags out of warnings section - - - - - eb5a6b91 by John Ericson at 2023-01-18T22:24:10-05:00 Give the RTS it's own configure script Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before. - - - - - 32ab07bf by Andrew Lelechenko at 2023-01-18T22:24:51-05:00 ghc package does not have to depend on terminfo - - - - - 981ff7c4 by Andrew Lelechenko at 2023-01-18T22:24:51-05:00 ghc-pkg does not have to depend on terminfo - - - - - f058e367 by Ben Gamari at 2023-01-18T22:25:27-05:00 nativeGen/X86: MFENCE is unnecessary for release semantics In #22764 a user noticed that a program implementing a simple atomic counter via an STRef regressed significantly due to the introduction of necessary atomic operations in the MutVar# primops (#22468). This regression was caused by a bug in the NCG, which emitted an unnecessary MFENCE instruction for a release-ordered atomic write. MFENCE is rather only needed to achieve sequentially consistent ordering. Fixes #22764. - - - - - 154889db by Ryan Scott at 2023-01-18T22:26:03-05:00 Add regression test for #22151 Issue #22151 was coincidentally fixed in commit aed1974e92366ab8e117734f308505684f70cddf (`Refactor the treatment of loopy superclass dicts`). This adds a regression test to ensure that the issue remains fixed. Fixes #22151. - - - - - 14b5982a by Andrei Borzenkov at 2023-01-18T22:26:43-05:00 Fix printing of promoted MkSolo datacon (#22785) Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo, and Solo was turned into a pattern synonym for backwards compatibility. Since pattern synonyms can not be promoted, the old code that pretty-printed promoted single-element tuples started producing ill-typed code: t :: Proxy ('Solo Int) This fails with "Pattern synonym ‘Solo’ used as a type" The solution is to track the distinction between type constructors and data constructors more carefully when printing single-element tuples. - - - - - 1fe806d3 by Cheng Shao at 2023-01-23T04:48:47-05:00 hadrian: add hi_core flavour transformer The hi_core flavour transformer enables -fwrite-if-simplified-core for stage1 libraries, which emit core into interface files to make it possible to restart code generation. Building boot libs with it makes it easier to use GHC API to prototype experimental backends that needs core/stg at link time. - - - - - 317cad26 by Cheng Shao at 2023-01-23T04:48:47-05:00 hadrian: add missing docs for recently added flavour transformers - - - - - 658f4446 by Ben Gamari at 2023-01-23T04:49:23-05:00 gitlab-ci: Add Rocky8 jobs Addresses #22268. - - - - - a83ec778 by Vladislav Zavialov at 2023-01-23T04:49:58-05:00 Set "since: 9.8" for TypeAbstractions and -Wterm-variable-capture These flags did not make it into the 9.6 release series, so the "since" annotations must be corrected. - - - - - fec7c2ea by Alan Zimmerman at 2023-01-23T04:50:33-05:00 EPA: Add SourceText to HsOverLabel To be able to capture string literals with possible escape codes as labels. Close #22771 - - - - - 3efd1e99 by Ben Gamari at 2023-01-23T04:51:08-05:00 template-haskell: Bump version to 2.20.0.0 Updates `text` and `exceptions` submodules for bounds bumps. Addresses #22767. - - - - - 0900b584 by Cheng Shao at 2023-01-23T04:51:45-05:00 hadrian: disable alloca for in-tree GMP on wasm32 When building in-tree GMP for wasm32, disable its alloca usage, since it may potentially cause stack overflow (e.g. #22602). - - - - - db0f1bfd by Cheng Shao at 2023-01-23T04:52:21-05:00 Bump process submodule Includes a critical fix for wasm32, see https://github.com/haskell/process/pull/272 for details. Also changes the existing cross test to include process stuff and avoid future regression here. - - - - - 9222b167 by Matthew Pickering at 2023-01-23T04:52:57-05:00 ghcup metadata: Fix subdir for windows bindist - - - - - 9a9bec57 by Matthew Pickering at 2023-01-23T04:52:57-05:00 ghcup metadata: Remove viPostRemove field from generated metadata This has been removed from the downstream metadata. - - - - - 82884ce0 by Simon Peyton Jones at 2023-01-23T04:53:32-05:00 Fix #22742 runtimeRepLevity_maybe was panicing unnecessarily; and the error printing code made use of the case when it should return Nothing rather than panicing. For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime peak-megagbytes-used, on a single architecture (alpine). See !9753 for commentary, but I'm going to accept it. Metric Increase: T21839r - - - - - 2c6deb18 by Bryan Richter at 2023-01-23T14:12:22+02:00 codeowners: Add Ben, Matt, and Bryan to CI - - - - - eee3bf05 by Matthew Craven at 2023-01-23T21:46:41-05:00 Do not collect compile-time metrics for T21839r ...the testsuite doesn't handle this properly since it also collects run-time metrics. Compile-time metrics for this test are already tracked via T21839c. Metric Decrease: T21839r - - - - - 1d1dd3fb by Matthew Pickering at 2023-01-24T05:37:52-05:00 Fix recompilation checking for multiple home units The key part of this change is to store a UnitId in the `UsageHomeModule` and `UsageHomeModuleInterface`. * Fine-grained dependency tracking is used if the dependency comes from any home unit. * We actually look up the right module when checking whether we need to recompile in the `UsageHomeModuleInterface` case. These scenarios are both checked by the new tests ( multipleHomeUnits_recomp and multipleHomeUnits_recomp_th ) Fixes #22675 - - - - - 7bfb30f9 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Augment target filepath by working directory when checking if module satisfies target This fixes a spurious warning in -Wmissing-home-modules. This is a simple oversight where when looking for the target in the first place we augment the search by the -working-directory flag but then fail to do so when checking this warning. Fixes #22676 - - - - - 69500dd4 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Use NodeKey rather than ModuleName in pruneCache The `pruneCache` function assumes that the list of `CachedInfo` all have unique `ModuleName`, this is not true: * In normal compilation, the same module name can appear for a file and it's boot file. * In multiple home unit compilation the same ModuleName can appear in different units The fix is to use a `NodeKey` as the actual key for the interfaces which includes `ModuleName`, `IsBoot` and `UnitId`. Fixes #22677 - - - - - 336b2b1c by Matthew Pickering at 2023-01-24T05:37:52-05:00 Recompilation checking: Don't try to find artefacts for Interactive & hs-boot combo In interactive mode we don't produce any linkables for hs-boot files. So we also need to not going looking for them when we check to see if we have all the right objects needed for recompilation. Ticket #22669 - - - - - 6469fea7 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Don't write o-boot files in Interactive mode We should not be producing object files when in interactive mode but we still produced the dummy o-boot files. These never made it into a `Linkable` but then confused the recompilation checker. Fixes #22669 - - - - - 06cc0a95 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Improve driver diagnostic messages by including UnitId in message Currently the driver diagnostics don't give any indication about which unit they correspond to. For example `-Wmissing-home-modules` can fire multiple times for each different home unit and gives no indication about which unit it's actually reporting about. Perhaps a longer term fix is to generalise the providence information away from a SrcSpan so that these kind of whole project errors can be reported with an accurate provenance. For now we can just include the `UnitId` in the error message. Fixes #22678 - - - - - 4fe9eaff by Matthew Pickering at 2023-01-24T05:37:52-05:00 Key ModSummary cache by UnitId as well as FilePath Multiple units can refer to the same files without any problem. Just another assumption which needs to be updated when we may have multiple home units. However, there is the invariant that within each unit each file only maps to one module, so as long as we also key the cache by UnitId then we are all good. This led to some confusing behaviour in GHCi when reloading, multipleHomeUnits_shared distils the essence of what can go wrong. Fixes #22679 - - - - - ada29f5c by Matthew Pickering at 2023-01-24T05:37:52-05:00 Finder: Look in current unit before looking in any home package dependencies In order to preserve existing behaviour it's important to look within the current component before consideirng a module might come from an external component. This already happened by accident in `downsweep`, (because roots are used to repopulated the cache) but in the `Finder` the logic was the wrong way around. Fixes #22680 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp -------------------------p - - - - - be701cc6 by Matthew Pickering at 2023-01-24T05:37:52-05:00 Debug: Print full NodeKey when pretty printing ModuleGraphNode This is helpful when debugging multiple component issues. - - - - - 34d2d463 by Krzysztof Gogolewski at 2023-01-24T05:38:32-05:00 Fix Lint check for duplicate external names Lint was checking for duplicate external names by calling removeDups, which needs a comparison function that is passed to Data.List.sortBy. But the comparison was not a valid ordering - it returned LT if one of the names was not external. For example, the previous implementation won't find a duplicate in [M.x, y, M.x]. Instead, we filter out non-external names before looking for duplicates. - - - - - 1c050ed2 by Matthew Pickering at 2023-01-24T05:39:08-05:00 Add test for T22671 This was fixed by b13c6ea5 Closes #22671 - - - - - 05e6a2d9 by Tom Ellis at 2023-01-24T12:10:52-05:00 Clarify where `f` is defined - - - - - d151546e by Cheng Shao at 2023-01-24T12:11:29-05:00 CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target We used to print the offset value to a platform word sized integer. This is incorrect when the offset is negative (e.g. output of cmm constant folding) and the register is 64-bit but on a 32-bit target, and may lead to incorrect runtime result (e.g. #22607). The fix is simple: just treat it as a proper MO_Add, with the correct width info inferred from the register itself. Metric Increase: T12707 T13379 T4801 T5321FD T5321Fun - - - - - e5383a29 by Wander Hillen at 2023-01-24T20:02:26-05:00 Allow waiting for timerfd to be interrupted during rts shutdown - - - - - 1957eda1 by Ryan Scott at 2023-01-24T20:03:01-05:00 Restore Compose's Read/Show behavior to match Read1/Show1 instances Fixes #22816. - - - - - 30972827 by Matthew Pickering at 2023-01-25T03:54:14-05:00 docs: Update INSTALL.md Removes references to make. Fixes #22480 - - - - - bc038c3b by Cheng Shao at 2023-01-25T03:54:50-05:00 compiler: fix handling of MO_F_Neg in wasm NCG In the wasm NCG, we used to compile MO_F_Neg to 0.0-x. It was an oversight, there actually exists f32.neg/f64.neg opcodes in the wasm spec and those should be used instead! The old behavior almost works, expect when GHC compiles the -0.0 literal, which will incorrectly become 0.0. - - - - - e987e345 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Hadrian: correctly detect AR at-file support Stage0's ar may not support at-files. Take it into account. Found while cross-compiling from Darwin to Windows. - - - - - 48131ee2 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Hadrian: fix Windows cross-compilation Decision to build either unix or Win32 package must be stage specific for cross-compilation to be supported. - - - - - 288fa017 by Sylvain Henry at 2023-01-25T14:47:41-05:00 Fix RTS build on Windows This change fixes a cross-compilation issue from ArchLinux to Windows because these symbols weren't found. - - - - - 2fdf22ae by Sylvain Henry at 2023-01-25T14:47:41-05:00 configure: support "windows" as an OS - - - - - 13a0566b by Simon Peyton Jones at 2023-01-25T14:48:16-05:00 Fix in-scope set in specImports Nothing deep here; I had failed to bring some floated dictionary binders into scope. Exposed by -fspecialise-aggressively Fixes #22715. - - - - - b7efdb24 by Matthew Pickering at 2023-01-25T14:48:51-05:00 ci: Disable HLint job due to excessive runtime The HLint jobs takes much longer to run (20 minutes) after "Give the RTS it's own configure script" eb5a6b91 Now the CI job will build the stage0 compiler before it generates the necessary RTS headers. We either need to: * Fix the linting rules so they take much less time * Revert the commit * Remove the linting of base from the hlint job * Remove the hlint job This is highest priority as it is affecting all CI pipelines. For now I am just disabling the job because there are many more pressing matters at hand. Ticket #22830 - - - - - 1bd32a35 by Sylvain Henry at 2023-01-26T12:34:21-05:00 Factorize hptModulesBelow Create and use moduleGraphModulesBelow in GHC.Unit.Module.Graph that doesn't need anything from the driver to be used. - - - - - 1262d3f8 by Matthew Pickering at 2023-01-26T12:34:56-05:00 Store dehydrated data structures in CgModBreaks This fixes a tricky leak in GHCi where we were retaining old copies of HscEnvs when reloading. If not all modules were recompiled then these hydrated fields in break points would retain a reference to the old HscEnv which could double memory usage. Fixes #22530 - - - - - e27eb80c by Matthew Pickering at 2023-01-26T12:34:56-05:00 Force more in NFData Name instance Doesn't force the lazy `OccName` field (#19619) which is already known as a really bad source of leaks. When we slam the hammer storing Names on disk (in interface files or the like), all this should be forced as otherwise a `Name` can easily retain an `Id` and hence the entire world. Fixes #22833 - - - - - 3d004d5a by Matthew Pickering at 2023-01-26T12:34:56-05:00 Force OccName in tidyTopName This occname has just been derived from an `Id`, so need to force it promptly so we can release the Id back to the world. Another symptom of the bug caused by #19619 - - - - - f2a0fea0 by Matthew Pickering at 2023-01-26T12:34:56-05:00 Strict fields in ModNodeKey (otherwise retains HomeModInfo) Towards #22530 - - - - - 5640cb1d by Sylvain Henry at 2023-01-26T12:35:36-05:00 Hadrian: fix doc generation Was missing dependencies on files generated by templates (e.g. ghc.cabal) - - - - - 3e827c3f by Richard Eisenberg at 2023-01-26T20:06:53-05:00 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. Close #22519. - - - - - b3ef5c89 by doyougnu at 2023-01-26T20:07:48-05:00 tryFillBuffer: strictify more speculative bangs - - - - - d0d7ba0f by Vladislav Zavialov at 2023-01-26T20:08:25-05:00 base: NoImplicitPrelude in Data.Void and Data.Kind This change removes an unnecessary dependency on Prelude from two modules in the base package. - - - - - fa1db923 by Matthew Pickering at 2023-01-26T20:09:00-05:00 ci: Add ubuntu18_04 nightly and release jobs This adds release jobs for ubuntu18_04 which uses glibc 2.27 which is older than the 2.28 which is used by Rocky8 bindists. Ticket #22268 - - - - - 807310a1 by Matthew Pickering at 2023-01-26T20:09:00-05:00 rel-eng: Add missing rocky8 bindist We intend to release rocky8 bindist so the fetching script needs to know about them. - - - - - c7116b10 by Ben Gamari at 2023-01-26T20:09:35-05:00 base: Make changelog proposal references more consistent Addresses #22773. - - - - - 6932cfc7 by Sylvain Henry at 2023-01-26T20:10:27-05:00 Fix spurious change from !9568 - - - - - e480fbc2 by Ben Gamari at 2023-01-27T05:01:24-05:00 rts: Use C11-compliant static assertion syntax Previously we used `static_assert` which is only available in C23. By contrast, C11 only provides `_Static_assert`. Fixes #22777 - - - - - 2648c09c by Andrei Borzenkov at 2023-01-27T05:02:07-05:00 Replace errors from badOrigBinding with new one (#22839) Problem: in 02279a9c the type-level [] syntax was changed from a built-in name to an alias for the GHC.Types.List constructor. badOrigBinding assumes that if a name is not built-in then it must have come from TH quotation, but this is not necessarily the case with []. The outdated assumption in badOrigBinding leads to incorrect error messages. This code: data [] Fails with "Cannot redefine a Name retrieved by a Template Haskell quote: []" Unfortunately, there is not enough information in RdrName to directly determine if the name was constructed via TH or by the parser, so this patch changes the error message instead. It unifies TcRnIllegalBindingOfBuiltIn and TcRnNameByTemplateHaskellQuote into a new error TcRnBindingOfExistingName and changes its wording to avoid guessing the origin of the name. - - - - - 545bf8cf by Matthew Pickering at 2023-01-27T14:58:53+00:00 Revert "base: NoImplicitPrelude in Data.Void and Data.Kind" Fixes CI errors of the form. ``` ===> Command failed with error code: 1 ghc: panic! (the 'impossible' happened) GHC version 9.7.20230127: lookupGlobal Failed to load interface for ‘GHC.Num.BigNat’ There are files missing in the ‘ghc-bignum’ package, try running 'ghc-pkg check'. Use -v (or `:set -v` in ghci) to see a list of the files searched for. Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic pprPanic, called at compiler/GHC/Tc/Utils/Env.hs:154:32 in ghc:GHC.Tc.Utils.Env CallStack (from HasCallStack): panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` This reverts commit d0d7ba0fb053ebe7f919a5932066fbc776301ccd. The module now lacks a dependency on GHC.Num.BigNat which it implicitly depends on. It is causing all CI jobs to fail so we revert without haste whilst the patch can be fixed. Fixes #22848 - - - - - 638277ba by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Detect family instance orphans correctly We were treating a type-family instance as a non-orphan if there was a type constructor on its /right-hand side/ that was local. Boo! Utterly wrong. With this patch, we correctly check the /left-hand side/ instead! Fixes #22717 - - - - - 46a53bb2 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Report family instance orphans correctly This fixes the fact that we were not reporting orphan family instances at all. The fix here is easy, but touches a bit of code. I refactored the code to be much more similar to the way that class instances are done: - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst - Make newFamInst initialise this field, just like newClsInst - And make newFamInst report a warning for an orphan, just like newClsInst - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate, just like newClsInst. - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv - TcRnOrphanInstance and SuggestFixOrphanInstance are now parametrised over class instances vs type/data family instances. Fixes #19773 - - - - - faa300fb by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Avoid orphans in STG This patch removes some orphan instances in the STG namespace by introducing the GHC.Stg.Lift.Types module, which allows various type family instances to be moved to GHC.Stg.Syntax, avoiding orphan instances. - - - - - 0f25a13b by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Avoid orphans in the parser This moves Anno instances for PatBuilder from GHC.Parser.PostProcess to GHC.Parser.Types to avoid orphans. - - - - - 15750d33 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00 Accept an orphan declaration (sadly) This accepts the orphan type family instance type instance DsForeignHook = ... in GHC.HsToCore.Types. See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks - - - - - c9967d13 by Zubin Duggal at 2023-01-27T23:55:31-05:00 bindist configure: Fail if find not found (#22691) - - - - - ad8cfed4 by John Ericson at 2023-01-27T23:56:06-05:00 Put hadrian bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. - - - - - d0ddc01b by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Introduce threaded2_sanity way Incredibly, we previously did not have a single way which would test the threaded RTS with multiple capabilities and the sanity-checker enabled. - - - - - 38ad8351 by Ben Gamari at 2023-01-27T23:56:42-05:00 rts: Relax Messages assertion `doneWithMsgThrowTo` was previously too strict in asserting that the `Message` is locked. Specifically, it failed to consider that the `Message` may not be locked if we are deleting all threads during RTS shutdown. - - - - - a9fe81af by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Fix race in UnliftedTVar2 Previously UnliftedTVar2 would fail when run with multiple capabilities (and possibly even with one capability) as it would assume that `killThread#` would immediately kill the "increment" thread. Also, refactor the the executable to now succeed with no output and fails with an exit code. - - - - - 8519af60 by Ben Gamari at 2023-01-27T23:56:42-05:00 testsuite: Make listThreads more robust Previously it was sensitive to the labels of threads which it did not create (e.g. the IO manager event loop threads). Fix this. - - - - - 55a81995 by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix non-atomic mutation of enabled_capabilities - - - - - b5c75f1d by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix C++ compilation issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - c261b62f by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Fix typo "tracingAddCapabilities" was mis-named - - - - - 77fdbd3f by Ben Gamari at 2023-01-27T23:56:43-05:00 rts: Drop long-dead fallback definitions for INFINITY & NAN These are no longer necessary since we now compile as C99. - - - - - 56c1bd98 by Ben Gamari at 2023-01-28T02:57:59-05:00 Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)" This reverts commit 99aca26b652603bc62953157a48e419f737d352d. - - - - - b3a3534b by nineonine at 2023-01-28T02:57:59-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043. - - - - - 082b7d43 by Oleg Grenrus at 2023-01-28T02:58:38-05:00 Add Foldable1 Solo instance - - - - - 50b1e2e8 by Andrei Borzenkov at 2023-01-28T02:59:18-05:00 Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115) I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind module. Instead, these TcRnMessage messages were introduced: TcRnMultipleFixityDecls TcRnIllegalPatternSynonymDecl TcRnIllegalClassBiding TcRnOrphanCompletePragma TcRnEmptyCase TcRnNonStdGuards TcRnDuplicateSigDecl TcRnMisplacedSigDecl TcRnUnexpectedDefaultSig TcRnBindInBootFile TcRnDuplicateMinimalSig - - - - - 3330b819 by Matthew Pickering at 2023-01-28T02:59:54-05:00 hadrian: Fix library-dirs, dynamic-library-dirs and static-library-dirs in inplace .conf files Previously we were just throwing away the contents of the library-dirs fields but really we have to do the same thing as for include-dirs, relativise the paths into the current working directory and maintain any extra libraries the user has specified. Now the relevant section of the rts.conf file looks like: ``` library-dirs: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib library-dirs-static: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib dynamic-library-dirs: ${pkgroot}/../rts/build ${pkgroot}/../../..//_build/stage1/rts/build /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib ``` Fixes #22209 - - - - - c9ad8852 by Andrew Lelechenko at 2023-01-28T03:00:33-05:00 Document differences between Data.{Monoid,Semigroup}.{First,Last} - - - - - 7e11c6dc by Cheng Shao at 2023-01-28T03:01:09-05:00 compiler: fix subword literal narrowing logic in the wasm NCG This patch fixes the W8/W16 literal narrowing logic in the wasm NCG, which used to lower it to something like i32.const -1, without properly zeroing-out the unused higher bits. Fixes #22608. - - - - - 6ea2aa02 by Cheng Shao at 2023-01-28T03:01:46-05:00 compiler: fix lowering of CmmBlock in the wasm NCG The CmmBlock datacon was not handled in lower_CmmLit, since I thought it would have been eliminated after proc-point splitting. Turns out it still occurs in very rare occasions, and this patch is needed to fix T9329 for wasm. - - - - - 2b62739d by Andrew Lelechenko at 2023-01-28T17:16:11-05:00 Assorted changes to avoid Data.List.{head,tail} - - - - - 78c07219 by Cheng Shao at 2023-01-28T17:16:48-05:00 compiler: properly handle ForeignHints in the wasm NCG Properly handle ForeignHints of ccall arguments/return value, insert sign extends and truncations when handling signed subwords. Fixes #22852. - - - - - 8bed166b by Ben Gamari at 2023-01-30T05:06:26-05:00 nativeGen: Disable asm-shortcutting on Darwin Asm-shortcutting may produce relative references to symbols defined in other compilation units. This is not something that MachO relocations support (see #21972). For this reason we disable the optimisation on Darwin. We do so without a warning since this flag is enabled by `-O2`. Another way to address this issue would be to rather implement a PLT-relocatable jump-table strategy. However, this would only benefit Darwin and does not seem worth the effort. Closes #21972. - - - - - da468391 by Cheng Shao at 2023-01-30T05:07:03-05:00 compiler: fix data section alignment in the wasm NCG Previously we tried to lower the alignment requirement as far as possible, based on the section kind inferred from the CLabel. For info tables, .p2align 1 was applied given the GC should only need the lowest bit to tag forwarding pointers. But this would lead to unaligned loads/stores, which has a performance penalty even if the wasm spec permits it. Furthermore, the test suite has shown memory corruption in a few cases when compacting gc is used. This patch takes a more conservative approach: all data sections except C strings align to word size. - - - - - 08ba8720 by Andreas Klebinger at 2023-01-30T21:18:45-05:00 ghc-the-library: Retain cafs in both static in dynamic builds. We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a __attribute__((constructor)) function. This broke for static builds where the linker discarded the object file since it was not reverenced from any exported code. We fix this by asserting that the flag is enabled using a function in the same module as the constructor. Which causes the object file to be retained by the linker, which in turn causes the constructor the be run in static builds. This changes nothing for dynamic builds using the ghc library. But causes static to also retain CAFs (as we expect them to). Fixes #22417. ------------------------- Metric Decrease: T21839r ------------------------- - - - - - 20598ef6 by Ryan Scott at 2023-01-30T21:19:20-05:00 Handle `type data` properly in tyThingParent_maybe Unlike most other data constructors, data constructors declared with `type data` are represented in `TyThing`s as `ATyCon` rather than `ADataCon`. The `ATyCon` case in `tyThingParent_maybe` previously did not consider the possibility of the underlying `TyCon` being a promoted data constructor, which led to the oddities observed in #22817. This patch adds a dedicated special case in `tyThingParent_maybe`'s `ATyCon` case for `type data` data constructors to fix these oddities. Fixes #22817. - - - - - 2f145052 by Ryan Scott at 2023-01-30T21:19:56-05:00 Fix two bugs in TypeData TH reification This patch fixes two issues in the way that `type data` declarations were reified with Template Haskell: * `type data` data constructors are now properly reified using `DataConI`. This is accomplished with a special case in `reifyTyCon`. Fixes #22818. * `type data` type constructors are now reified in `reifyTyCon` using `TypeDataD` instead of `DataD`. Fixes #22819. - - - - - d0f34f25 by Simon Peyton Jones at 2023-01-30T21:20:35-05:00 Take account of loop breakers in specLookupRule The key change is that in GHC.Core.Opt.Specialise.specLookupRule we were using realIdUnfolding, which ignores the loop-breaker flag. When given a loop breaker, rule matching therefore looped infinitely -- #22802. In fixing this I refactored a bit. * Define GHC.Core.InScopeEnv as a data type, and use it. (Previously it was a pair: hard to grep for.) * Put several functions returning an IdUnfoldingFun into GHC.Types.Id, namely idUnfolding alwaysActiveUnfoldingFun, whenActiveUnfoldingFun, noUnfoldingFun and use them. (The are all loop-breaker aware.) - - - - - de963cb6 by Matthew Pickering at 2023-01-30T21:21:11-05:00 ci: Remove FreeBSD job from release pipelines We no longer attempt to build or distribute this release - - - - - f26d27ec by Matthew Pickering at 2023-01-30T21:21:11-05:00 rel_eng: Add check to make sure that release jobs are downloaded by fetch-gitlab This check makes sure that if a job is a prefixed by "release-" then the script downloads it and understands how to map the job name to the platform. - - - - - 7619c0b4 by Matthew Pickering at 2023-01-30T21:21:11-05:00 rel_eng: Fix the name of the ubuntu-* jobs These were not uploaded for alpha1 Fixes #22844 - - - - - 68eb8877 by Matthew Pickering at 2023-01-30T21:21:11-05:00 gen_ci: Only consider release jobs for job metadata In particular we do not have a release job for FreeBSD so the generation of the platform mapping was failing. - - - - - b69461a0 by Jason Shipman at 2023-01-30T21:21:50-05:00 User's guide: Clarify overlapping instance candidate elimination This commit updates the user's guide section on overlapping instance candidate elimination to use "or" verbiage instead of "either/or" in regards to the current pair of candidates' being overlappable or overlapping. "Either IX is overlappable, or IY is overlapping" can cause confusion as it suggests "Either IX is overlappable, or IY is overlapping, but not both". This was initially discussed on this Discourse topic: https://discourse.haskell.org/t/clarification-on-overlapping-instance-candidate-elimination/5677 - - - - - 7cbdaad0 by Matthew Pickering at 2023-01-31T07:53:53-05:00 Fixes for cabal-reinstall CI job * Allow filepath to be reinstalled * Bump some version bounds to allow newer versions of libraries * Rework testing logic to avoid "install --lib" and package env files Fixes #22344 - - - - - fd8f32bf by Cheng Shao at 2023-01-31T07:54:29-05:00 rts: prevent potential divide-by-zero when tickInterval=0 This patch fixes a few places in RtsFlags.c that may result in divide-by-zero error when tickInterval=0, which is the default on wasm. Fixes #22603. - - - - - 085a6db6 by Joachim Breitner at 2023-01-31T07:55:05-05:00 Update note at beginning of GHC.Builtin.NAmes some things have been renamed since it was written, it seems. - - - - - 7716cbe6 by Cheng Shao at 2023-01-31T07:55:41-05:00 testsuite: use tgamma for cg007 gamma is a glibc-only deprecated function, use tgamma instead. It's required for fixing cg007 when testing the wasm unregisterised codegen. - - - - - 19c1fbcd by doyougnu at 2023-01-31T13:08:03-05:00 InfoTableProv: ShortText --> ShortByteString - - - - - 765fab98 by doyougnu at 2023-01-31T13:08:03-05:00 FastString: add fastStringToShorText - - - - - a83c810d by Simon Peyton Jones at 2023-01-31T13:08:38-05:00 Improve exprOkForSpeculation for classops This patch fixes #22745 and #15205, which are about GHC's failure to discard unnecessary superclass selections that yield coercions. See GHC.Core.Utils Note [exprOkForSpeculation and type classes] The main changes are: * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and refer to it * Define new function isTerminatingType, to identify those guaranteed-terminating dictionary types. * exprOkForSpeculation has a new (very simple) case for ClassOpId * ClassOpId has a new field that says if the return type is an unlifted type, or a terminating type. This was surprisingly tricky to get right. In particular note that unlifted types are not terminating types; you can write an expression of unlifted type, that diverges. Not so for dictionaries (or, more precisely, for the dictionaries that GHC constructs). Metric Decrease: LargeRecord - - - - - f83374f8 by Krzysztof Gogolewski at 2023-01-31T13:09:14-05:00 Support "unusable UNPACK pragma" warning with -O0 Fixes #11270 - - - - - a2d814dc by Ben Gamari at 2023-01-31T13:09:50-05:00 configure: Always create the VERSION file Teach the `configure` script to create the `VERSION` file. This will serve as the stable interface to allow the user to determine the version number of a working tree. Fixes #22322. - - - - - 5618fc21 by sheaf at 2023-01-31T15:51:06-05:00 Cmm: track the type of global registers This patch tracks the type of Cmm global registers. This is needed in order to lint uses of polymorphic registers, such as SIMD vector registers that can be used both for floating-point and integer values. This changes allows us to refactor VanillaReg to not store VGcPtr, as that information is instead stored in the type of the usage of the register. Fixes #22297 - - - - - 78b99430 by sheaf at 2023-01-31T15:51:06-05:00 Revert "Cmm Lint: relax SIMD register assignment check" This reverts commit 3be48877, which weakened a Cmm Lint check involving SIMD vectors. Now that we keep track of the type a global register is used at, we can restore the original stronger check. - - - - - be417a47 by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen/AArch64: Fix debugging output Previously various panics would rely on a half-written Show instance, leading to very unhelpful errors. Fix this. See #22798. - - - - - 30989d13 by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen: Teach graph-colouring allocator that x18 is unusable Previously trivColourable for AArch64 claimed that at 18 registers were trivially-colourable. This is incorrect as x18 is reserved by the platform on AArch64/Darwin. See #22798. - - - - - 7566fd9d by Ben Gamari at 2023-01-31T15:51:45-05:00 nativeGen/AArch64: Fix graph-colouring allocator Previously various `Instr` queries used by the graph-colouring allocator failed to handle a few pseudo-instructions. This manifested in compiler panicks while compiling `SHA`, which uses `-fregs-graph`. Fixes #22798. - - - - - 2cb500a5 by Ben Gamari at 2023-01-31T15:51:45-05:00 testsuite: Add regression test for #22798 - - - - - 03d693b2 by Ben Gamari at 2023-01-31T15:52:32-05:00 Revert "Hadrian: fix doc generation" This is too large of a hammer. This reverts commit 5640cb1d84d3cce4ce0a9e90d29b2b20d2b38c2f. - - - - - f838815c by Ben Gamari at 2023-01-31T15:52:32-05:00 hadrian: Sphinx docs require templated cabal files The package-version discovery logic in `doc/users_guide/package_versions.py` uses packages' cabal files to determine package versions. Teach Sphinx about these dependencies in cases where the cabal files are generated by templates. - - - - - 2e48c19a by Ben Gamari at 2023-01-31T15:52:32-05:00 hadrian: Refactor templating logic This refactors Hadrian's autoconf-style templating logic to be explicit about which interpolation variables should be substituted in which files. This clears the way to fix #22714 without incurring rule cycles. - - - - - 93f0e3c4 by Ben Gamari at 2023-01-31T15:52:33-05:00 hadrian: Substitute LIBRARY_*_VERSION variables This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables in `libraries/prologue.txt`, fixing #22714. Fixes #22714. - - - - - 22089f69 by Ben Gamari at 2023-01-31T20:46:27-05:00 Bump transformers submodule to 0.6.0.6 Fixes #22862. - - - - - f0eefa3c by Cheng Shao at 2023-01-31T20:47:03-05:00 compiler: properly handle non-word-sized CmmSwitch scrutinees in the wasm NCG Currently, the wasm NCG has an implicit assumption: all CmmSwitch scrutinees are 32-bit integers. This is not always true; #22864 is one counter-example with a 64-bit scrutinee. This patch fixes the logic by explicitly converting the scrutinee to a word that can be used as a br_table operand. Fixes #22871. Also includes a regression test. - - - - - 9f95db54 by Simon Peyton Jones at 2023-02-01T08:55:08+00:00 Improve treatment of type applications in patterns This patch fixes a subtle bug in the typechecking of type applications in patterns, e.g. f (MkT @Int @a x y) = ... See Note [Type applications in patterns] in GHC.Tc.Gen.Pat. This fixes #19847, #22383, #19577, #21501 - - - - - 955a99ea by Simon Peyton Jones at 2023-02-01T12:31:23-05:00 Treat existentials correctly in dubiousDataConInstArgTys Consider (#22849) data T a where MkT :: forall k (t::k->*) (ix::k). t ix -> T @k a Then dubiousDataConInstArgTys MkT [Type, Foo] should return [Foo (ix::Type)] NOT [Foo (ix::k)] A bit of an obscure case, but it's an outright bug, and the fix is easy. - - - - - 0cc16aaf by Matthew Pickering at 2023-02-01T12:31:58-05:00 Bump supported LLVM range from 10 through 15 to 11 through 16 LLVM 15 turns on the new pass manager by default, which we have yet to migrate to so for new we pass the `-enable-new-pm-0` flag in our llvm-passes flag. LLVM 11 was the first version to support the `-enable-new-pm` flag so we bump the lowest supported version to 11. Our CI jobs are using LLVM 12 so they should continue to work despite this bump to the lower bound. Fixes #21936 - - - - - f94f1450 by Matthew Pickering at 2023-02-01T12:31:58-05:00 Bump DOCKER_REV to use alpine image without LLVM installed alpine_3_12 only supports LLVM 10, which is now outside the supported version range. - - - - - 083e26ed by Matthew Pickering at 2023-02-01T17:43:21-05:00 Remove tracing OPTIONS_GHC These were accidentally left over from !9542 - - - - - 354aa47d by Teo Camarasu at 2023-02-01T17:44:00-05:00 doc: fix gcdetails_block_fragmentation_bytes since annotation - - - - - 61ce5bf6 by Jaro Reinders at 2023-02-02T00:15:30-05:00 compiler: Implement higher order patterns in the rule matcher This implements proposal 555 and closes ticket #22465. See the proposal and ticket for motivation. The core changes of this patch are in the GHC.Core.Rules.match function and they are explained in the Note [Matching higher order patterns]. - - - - - 394b91ce by doyougnu at 2023-02-02T00:16:10-05:00 CI: JavaScript backend runs testsuite This MR runs the testsuite for the JS backend. Note that this is a temporary solution until !9515 is merged. Key point: The CI runs hadrian on the built cross compiler _but not_ on the bindist. Other Highlights: - stm submodule gets a bump to mark tests as broken - several tests are marked as broken or are fixed by adding more - conditions to their test runner instance. List of working commit messages: CI: test cross target _and_ emulator CI: JS: Try run testsuite with hadrian JS.CI: cleanup and simplify hadrian invocation use single bracket, print info JS CI: remove call to test_compiler from hadrian don't build haddock JS: mark more tests as broken Tracked in https://gitlab.haskell.org/ghc/ghc/-/issues/22576 JS testsuite: don't skip sum_mod test Its expected to fail, yet we skipped it which automatically makes it succeed leading to an unexpected success, JS testsuite: don't mark T12035j as skip leads to an unexpected pass JS testsuite: remove broken on T14075 leads to unexpected pass JS testsuite: mark more tests as broken JS testsuite: mark T11760 in base as broken JS testsuite: mark ManyUnbSums broken submodules: bump process and hpc for JS tests Both submodules has needed tests skipped or marked broken for th JS backend. This commit now adds these changes to GHC. See: HPC: https://gitlab.haskell.org/hpc/hpc/-/merge_requests/21 Process: https://github.com/haskell/process/pull/268 remove js_broken on now passing tests separate wasm and js backend ci test: T11760: add threaded, non-moving only_ways test: T10296a add req_c T13894: skip for JS backend tests: jspace, T22333: mark as js_broken(22573) test: T22513i mark as req_th stm submodule: mark stm055, T16707 broken for JS tests: js_broken(22374) on unpack_sums_6, T12010 dont run diff on JS CI, cleanup fixup: More CI cleanup fix: align text to master fix: align exceptions submodule to master CI: Bump DOCKER_REV Bump to ci-images commit that has a deb11 build with node. Required for !9552 testsuite: mark T22669 as js_skip See #22669 This test tests that .o-boot files aren't created when run in using the interpreter backend. Thus this is not relevant for the JS backend. testsuite: mark T22671 as broken on JS See #22835 base.testsuite: mark Chan002 fragile for JS see #22836 revert: submodule process bump bump stm submodule New hash includes skips for the JS backend. testsuite: mark RnPatternSynonymFail broken on JS Requires TH: - see !9779 - and #22261 compiler: GHC.hs ifdef import Utils.Panic.Plain - - - - - 1ffe770c by Cheng Shao at 2023-02-02T09:40:38+00:00 docs: 9.6 release notes for wasm backend - - - - - 0ada4547 by Matthew Pickering at 2023-02-02T11:39:44-05:00 Disable unfolding sharing for interface files with core definitions Ticket #22807 pointed out that the RHS sharing was not compatible with -fignore-interface-pragmas because the flag would remove unfoldings from identifiers before the `extra-decls` field was populated. For the 9.6 timescale the only solution is to disable this sharing, which will make interface files bigger but this is acceptable for the first release of `-fwrite-if-simplified-core`. For 9.8 it would be good to fix this by implementing #20056 due to the large number of other bugs that would fix. I also improved the error message in tc_iface_binding to avoid the "no match in record selector" error but it should never happen now as the entire sharing logic is disabled. Also added the currently broken test for #22807 which could be fixed by !6080 Fixes #22807 - - - - - 7e2d3eb5 by lrzlin at 2023-02-03T05:23:27-05:00 Enable tables next to code for LoongArch64 - - - - - 2931712a by Wander Hillen at 2023-02-03T05:24:06-05:00 Move pthread and timerfd ticker implementations to separate files - - - - - 41c4baf8 by Ben Gamari at 2023-02-03T05:24:44-05:00 base: Fix Note references in GHC.IO.Handle.Types - - - - - 31358198 by Andrew Lelechenko at 2023-02-03T05:25:22-05:00 Bump submodule containers to 0.6.7 Metric Decrease: ManyConstructors T10421 T12425 T12707 T13035 T13379 T15164 T1969 T783 T9198 T9961 WWRec - - - - - 8feb9301 by Ben Gamari at 2023-02-03T05:25:59-05:00 gitlab-ci: Eliminate redundant ghc --info output Previously ci.sh would emit the output of `ghc --info` every time it ran when using the nix toolchain. This produced a significant amount of noise. See #22861. - - - - - de1d1512 by Ryan Scott at 2023-02-03T14:07:30-05:00 Windows: Remove mingwex dependency The clang based toolchain uses ucrt as its math library and so mingwex is no longer needed. In fact using mingwex will cause incompatibilities as the default routines in both have differing ULPs and string formatting modifiers. ``` $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe [1 of 2] Compiling Main ( Bug.hs, Bug.o ) ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info' ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above. <no location info>: error: GHC.ByteCode.Linker.lookupCE During interactive linking, GHCi couldn't find the following symbol: templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` - - - - - 48e39195 by Tamar Christina at 2023-02-03T14:07:30-05:00 linker: Fix BFD import libraries This commit fixes the BFD style import library support in the runtime linker. This was accidentally broken during the refactoring to clang and went unnoticed because clang itself is unable to generate the BFD style import libraries. With this change we can not link against both GCC or Clang produced libraries again and intermix code produced by both compilers. - - - - - b2bb3e62 by Ben Gamari at 2023-02-03T14:07:30-05:00 Bump Windows toolchain Updates to LLVM 14, hopefully fixing #21964. - - - - - bf3f88a1 by Andreas Klebinger at 2023-02-03T14:08:07-05:00 Fix CallerCC potentially shadowing other cost centres. Add a CallerCC cost centre flavour for cost centres added by the CallerCC pass. This avoids potential accidental shadowing between CCs added by user annotations and ones added by CallerCC. - - - - - faea4bcd by j at 2023-02-03T14:08:47-05:00 Disable several ignore-warning flags in genapply. - - - - - 25537dfd by Ben Gamari at 2023-02-04T04:12:57-05:00 Revert "Use fix-sized bit-fiddling primops for fixed size boxed types" This reverts commit 4512ad2d6a8e65ea43c86c816411cb13b822f674. This was never applied to master/9.6 originally. (cherry picked from commit a44bdc2720015c03d57f470b759ece7fab29a57a) - - - - - 7612dc71 by Krzysztof Gogolewski at 2023-02-04T04:13:34-05:00 Minor refactor * Introduce refactorDupsOn f = refactorDups (comparing f) * Make mkBigTupleCase and coreCaseTuple monadic. Every call to those functions was preceded by calling newUniqueSupply. * Use mkUserLocalOrCoVar, which is equivalent to combining mkLocalIdOrCoVar with mkInternalName. - - - - - 5a54ac0b by Andrew Lelechenko at 2023-02-04T18:48:32-05:00 Fix colors in emacs terminal - - - - - 3c0f0c6d by Andrew Lelechenko at 2023-02-04T18:49:11-05:00 base changelog: move entries which were not backported to ghc-9.6 to base-4.19 section - - - - - b18fbf52 by Josh Meredith at 2023-02-06T07:47:57+00:00 Update JavaScript fileStat to match Emscripten layout - - - - - 6636b670 by Sylvain Henry at 2023-02-06T09:43:21-05:00 JS: replace "js" architecture with "javascript" Despite Cabal supporting any architecture name, `cabal --check` only supports a few built-in ones. Sadly `cabal --check` is used by Hackage hence using any non built-in name in a package (e.g. `arch(js)`) is rejected and the package is prevented from being uploaded on Hackage. Luckily built-in support for the `javascript` architecture was added for GHCJS a while ago. In order to allow newer `base` to be uploaded on Hackage we make the switch from `js` to `javascript` architecture. Fixes #22740. Co-authored-by: Ben Gamari <ben at smart-cactus.org> - - - - - 77a8234c by Luite Stegeman at 2023-02-06T09:43:59-05:00 Fix marking async exceptions in the JS backend Async exceptions are posted as a pair of the exception and the thread object. This fixes the marking pass to correctly follow the two elements of the pair. Potentially fixes #22836 - - - - - 3e09cf82 by Jan Hrček at 2023-02-06T09:44:38-05:00 Remove extraneous word in Roles user guide - - - - - b17fb3d9 by sheaf at 2023-02-07T10:51:33-05:00 Don't allow . in overloaded labels This patch removes . from the list of allowed characters in a non-quoted overloaded label, as it was realised this steals syntax, e.g. (#.). Users who want this functionality will have to add quotes around the label, e.g. `#"17.28"`. Fixes #22821 - - - - - 5dce04ee by romes at 2023-02-07T10:52:10-05:00 Update kinds in comments in GHC.Core.TyCon Use `Type` instead of star kind (*) Fix comment with incorrect kind * to have kind `Constraint` - - - - - 92916194 by Ben Gamari at 2023-02-07T10:52:48-05:00 Revert "Use fix-sized equality primops for fixed size boxed types" This reverts commit 024020c38126f3ce326ff56906d53525bc71690c. This was never applied to master/9.6 originally. See #20405 for why using these primops is a bad idea. (cherry picked from commit b1d109ad542e4c37ae5af6ace71baf2cb509d865) - - - - - c1670c6b by Sylvain Henry at 2023-02-07T21:25:18-05:00 JS: avoid head/tail and unpackFS - - - - - a9912de7 by Krzysztof Gogolewski at 2023-02-07T21:25:53-05:00 testsuite: Fix Python warnings (#22856) - - - - - 9ee761bf by sheaf at 2023-02-08T14:40:40-05:00 Fix tyvar scoping within class SPECIALISE pragmas Type variables from class/instance headers scope over class/instance method type signatures, but DO NOT scope over the type signatures in SPECIALISE and SPECIALISE instance pragmas. The logic in GHC.Rename.Bind.rnMethodBinds correctly accounted for SPECIALISE inline pragmas, but forgot to apply the same treatment to method SPECIALISE pragmas, which lead to a Core Lint failure with an out-of-scope type variable. This patch makes sure we apply the same logic for both cases. Fixes #22913 - - - - - 7eac2468 by Matthew Pickering at 2023-02-08T14:41:17-05:00 Revert "Don't keep exit join points so much" This reverts commit caced75765472a1a94453f2e5a439dba0d04a265. It seems the patch "Don't keep exit join points so much" is causing wide-spread regressions in the bytestring library benchmarks. If I revert it then the 9.6 numbers are better on average than 9.4. See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T12150 T13386 T13719 T21839c T3294 parsing001 ------------------------- - - - - - 633f2799 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: remove config.use_threads This patch simplifies the testsuite driver by removing the use_threads config field. It's just a degenerate case of threads=1. - - - - - ca6673e3 by Cheng Shao at 2023-02-08T18:42:16-05:00 testsuite: use concurrent.futures.ThreadPoolExecutor in the driver The testsuite driver used to create one thread per test case, and explicitly use semaphore and locks for rate limiting and synchronization. This is a bad practice in any language, and occasionally may result in livelock conditions (e.g. #22889). This patch uses concurrent.futures.ThreadPoolExecutor for scheduling test case runs, which is simpler and more robust. - - - - - f22cce70 by Alan Zimmerman at 2023-02-08T18:42:51-05:00 EPA: Comment between module and where should be in header comments Do not apply the heuristic to associate a comment with a prior declaration for the first declaration in the file. Closes #22919 - - - - - d69ecac2 by Josh Meredith at 2023-02-09T03:24:05-05:00 JS generated refs: update testsuite conditions - - - - - 2ea1a6bc by sheaf at 2023-02-09T03:24:44-05:00 Bump transformers to 0.6.1.0 This allows us to avoid orphans for Foldable1 instances, fixing #22898. Updates transformers submodule. - - - - - d9d0c28d by konsumlamm at 2023-02-09T14:07:48-05:00 Update `Data.List.singleton` doc comment - - - - - fe9cd6ef by Ben Gamari at 2023-02-09T14:08:23-05:00 gitlab-template: Emphasize `user facing` label My sense is that the current mention of the ~"user facing" label is overlooked by many MR authors. Let's move this point up in the list to make it more likely that it is seen. Also rephrase some of the points. - - - - - e45eb828 by Simon Peyton Jones at 2023-02-10T06:51:28-05:00 Refactor the simplifier a bit to fix #22761 The core change in this commit, which fixes #22761, is that * In a Core rule, ru_rhs is always occ-analysed. This means adding a couple of calls to occurAnalyseExpr when building a Rule, in * GHC.Core.Rules.mkRule * GHC.Core.Opt.Simplify.Iteration.simplRules But diagosing the bug made me stare carefully at the code of the Simplifier, and I ended up doing some only-loosely-related refactoring. * I think that RULES could be lost because not every code path did addBndrRules * The code around lambdas was very convoluted It's mainly moving deck chairs around, but I like it more now. - - - - - 11e0cacb by Rebecca Turner at 2023-02-10T06:52:09-05:00 Detect the `mold` linker Enables support for the `mold` linker by rui314. - - - - - 59556235 by parsonsmatt at 2023-02-10T09:53:11-05:00 Add Lift instance for Fixed - - - - - c44e5f30 by Sylvain Henry at 2023-02-10T09:53:51-05:00 Testsuite: decrease length001 timeout for JS (#22921) - - - - - 133516af by Zubin Duggal at 2023-02-10T09:54:27-05:00 compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData` instances This is a minor refactor that makes it easy to add and remove fields from `ModIface_` and `ModIfaceBackend`. Also change the formatting to make it clear exactly which fields are fully forced with `rnf` - - - - - 1e9eac1c by Matthew Pickering at 2023-02-13T11:36:41+01:00 Refresh profiling docs I went through the whole of the profiling docs and tried to amend them to reflect current best practices and tooling. In particular I removed some old references to tools such as hp2any and replaced them with references to eventlog2html. - - - - - da208b9a by Matthew Pickering at 2023-02-13T11:36:41+01:00 docs: Add section about profiling and foreign calls Previously there was no documentation for how foreign calls interacted with the profiler. This can be quite confusing for users so getting it into the user guide is the first step to a potentially better solution. See the ticket for more insightful discussion. Fixes #21764 - - - - - 081640f1 by Andrew Lelechenko at 2023-02-13T12:51:52-05:00 Document that -fproc-alignment was introduced only in GHC 8.6 - - - - - 16adc349 by Sven Tennie at 2023-02-14T11:26:31-05:00 Add clangd flag to include generated header files This enables clangd to correctly check C files that import Rts.h. (The added include directory contains ghcautoconf.h et. al.) - - - - - c399ccd9 by amesgen at 2023-02-14T11:27:14-05:00 Mention new `Foreign.Marshal.Pool` implementation in User's Guide - - - - - b9282cf7 by Ben Gamari at 2023-02-14T11:27:50-05:00 upload_ghc_libs: More control over which packages to operate on Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to limit which packages to upload. This is often necessary when one package is not uploadable (e.g. see #22740). - - - - - aa3a262d by PHO at 2023-02-14T11:28:29-05:00 Assume platforms support rpaths if they use either ELF or Mach-O Not only Linux, Darwin, and FreeBSD support rpaths. Determine the usability of rpaths based on the object format, not on OS. - - - - - 47716024 by PHO at 2023-02-14T11:29:09-05:00 RTS linker: Improve compatibility with NetBSD 1. Hint address to NetBSD mmap(2) has a different semantics from that of Linux. When a hint address is provided, mmap(2) searches for a free region at or below the hint but *never* above it. This means we can't reliably search for free regions incrementally on the userland, especially when ASLR is enabled. Let the kernel do it for us if we don't care where the mapped address is going to be. 2. NetBSD not only hates to map pages as rwx, but also disallows to switch pages from rw- to r-x unless the intention is declared when pages are initially requested. This means we need a new MemoryAccess mode for pages that are going to be changed to r-x. - - - - - 11de324a by Li-yao Xia at 2023-02-14T11:29:49-05:00 base: Move changelog entry to its place - - - - - 75930424 by Ben Gamari at 2023-02-14T11:30:27-05:00 nativeGen/AArch64: Emit Atomic{Read,Write} inline Previously the AtomicRead and AtomicWrite operations were emitted as out-of-line calls. However, these tend to be very important for performance, especially the RELAXED case (which only exists for ThreadSanitizer checking). Fixes #22115. - - - - - d6411d6c by Andreas Klebinger at 2023-02-14T11:31:04-05:00 Fix some correctness issues around tag inference when targeting the bytecode generator. * Let binders are now always assumed untagged for bytecode. * Imported referenced are now always assumed to be untagged for bytecode. Fixes #22840 - - - - - 9fb4ca89 by sheaf at 2023-02-14T11:31:49-05:00 Introduce warning for loopy superclass solve Commit aed1974e completely re-engineered the treatment of loopy superclass dictionaries in instance declarations. Unfortunately, it has the potential to break (albeit in a rather minor way) user code. To alleviate migration concerns, this commit re-introduces the old behaviour. Any reliance on this old behaviour triggers a warning, controlled by `-Wloopy-superclass-solve`. The warning text explains that GHC might produce bottoming evidence, and provides a migration strategy. This allows us to provide a graceful migration period, alerting users when they are relying on this unsound behaviour. Fixes #22912 #22891 #20666 #22894 #22905 - - - - - 1928c7f3 by Cheng Shao at 2023-02-14T11:32:26-05:00 rts: make it possible to change mblock size on 32-bit targets The MBLOCK_SHIFT macro must be the single source of truth for defining the mblock size, and changing it should only affect performance, not correctness. This patch makes it truly possible to reconfigure mblock size, at least on 32-bit targets, by fixing places which implicitly relied on the previous MBLOCK_SHIFT constant. Fixes #22901. - - - - - 78aa3b39 by Simon Hengel at 2023-02-14T11:33:06-05:00 Update outdated references to notes - - - - - e8baecd2 by meooow25 at 2023-02-14T11:33:49-05:00 Documentation: Improve Foldable1 documentation * Explain foldrMap1, foldlMap1, foldlMap1', and foldrMap1' in greater detail, the text is mostly adapted from documentation of Foldable. * Describe foldr1, foldl1, foldl1' and foldr1' in terms of the above functions instead of redoing the full explanation. * Small updates to documentation of fold1, foldMap1 and toNonEmpty, again adapting from Foldable. * Update the foldMap1 example to lists instead of Sum since this is recommended for lazy right-associative folds. Fixes #22847 - - - - - 85a1a575 by romes at 2023-02-14T11:34:25-05:00 fix: Mark ghci Prelude import as implicit Fixes #22829 In GHCi, we were creating an import declaration for Prelude but we were not setting it as an implicit declaration. Therefore, ghci's import of Prelude triggered -Wmissing-import-lists. Adds regression test T22829 to testsuite - - - - - 3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05:00 compiler: fix generateCgIPEStub for no-tables-next-to-code builds generateCgIPEStub already correctly implements the CmmTick finding logic for when tables-next-to-code is on/off, but it used the wrong predicate to decide when to switch between the two. Previously it switches based on whether the codegen is unregisterised, but there do exist registerised builds that disable tables-next-to-code! This patch corrects that problem. Fixes #22896. - - - - - 08c0822c by doyougnu at 2023-02-15T00:16:39-05:00 docs: release notes, user guide: add js backend Follow up from #21078 - - - - - 79d8fd65 by Bryan Richter at 2023-02-15T00:17:15-05:00 Allow failure in nightly-x86_64-linux-deb10-no_tntc-validate See #22343 - - - - - 9ca51f9e by Cheng Shao at 2023-02-15T00:17:53-05:00 rts: add the rts_clearMemory function This patch adds the rts_clearMemory function that does its best to zero out unused RTS memory for a wasm backend use case. See the comment above rts_clearMemory() prototype declaration for more detailed explanation. Closes #22920. - - - - - 26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00 Add -single-threaded flag to force single threaded rts This is the small part of implementing https://github.com/ghc-proposals/ghc-proposals/pull/240 - - - - - 631c6c72 by Cheng Shao at 2023-02-16T06:43:09-05:00 docs: add a section for the wasm backend Fixes #22658 - - - - - 1878e0bd by Bryan Richter at 2023-02-16T06:43:47-05:00 tests: Mark T12903 fragile everywhere See #21184 - - - - - b9420eac by Bryan Richter at 2023-02-16T06:43:47-05:00 Mark all T5435 variants as fragile See #22970. - - - - - df3d94bd by Sylvain Henry at 2023-02-16T06:44:33-05:00 Testsuite: mark T13167 as fragile for JS (#22921) - - - - - 324e925b by Sylvain Henry at 2023-02-16T06:45:15-05:00 JS: disable debugging info for heap objects - - - - - 518af814 by Josh Meredith at 2023-02-16T10:16:32-05:00 Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name caching - - - - - 34cd308e by Ben Gamari at 2023-02-16T10:17:08-05:00 base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog Fixes #22883. - - - - - 12965aba by Simon Peyton Jones at 2023-02-16T10:17:46-05:00 Narrow the dont-decompose-newtype test Following #22924 this patch narrows the test that stops us decomposing newtypes. The key change is the use of noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp. We went to and fro on the solution, as you can see in #22924. The result is carefully documented in Note [Decomoposing newtype equalities] On the way I had revert most of commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90 Author: Richard Eisenberg <rae at cs.brynmawr.edu> Date: Mon Dec 5 10:14:02 2022 -0500 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. It turns out that (a) 3e827c3f makes GHC behave worse on some recursive newtypes (see one of the tests on this commit) (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders 3e827c3f unnecessary - - - - - 5b038888 by Andrew Lelechenko at 2023-02-16T10:18:24-05:00 Documentation: add an example of SPEC usage - - - - - 681e0e8c by sheaf at 2023-02-16T14:09:56-05:00 No default finalizer exception handler Commit cfc8e2e2 introduced a mechanism for handling of exceptions that occur during Handle finalization, and 372cf730 set the default handler to print out the error to stderr. However, #21680 pointed out we might not want to set this by default, as it might pollute users' terminals with unwanted information. So, for the time being, the default handler discards the exception. Fixes #21680 - - - - - b3ac17ad by Matthew Pickering at 2023-02-16T14:10:31-05:00 unicode: Don't inline bitmap in generalCategory generalCategory contains a huge literal string but is marked INLINE, this will duplicate the string into any use site of generalCategory. In particular generalCategory is used in functions like isSpace and the literal gets inlined into this function which makes it massive. https://github.com/haskell/core-libraries-committee/issues/130 Fixes #22949 ------------------------- Metric Decrease: T4029 T18304 ------------------------- - - - - - 8988eeef by sheaf at 2023-02-16T20:32:27-05:00 Expand synonyms in RoughMap We were failing to expand type synonyms in the function GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the RoughMap infrastructure crucially relies on type synonym expansion to work. This patch adds the missing type-synonym expansion. Fixes #22985 - - - - - 3dd50e2f by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Add test artifact Add the released testsuite tarball to the generated ghcup metadata. - - - - - c6a967d9 by Matthew Pickering at 2023-02-16T20:33:03-05:00 ghcup-metadata: Use Ubuntu and Rocky bindists Prefer to use the Ubuntu 20.04 and 18.04 binary distributions on Ubuntu and Linux Mint. Prefer to use the Rocky 8 binary distribution on unknown distributions. - - - - - be0b7209 by Matthew Pickering at 2023-02-17T09:37:16+00:00 Add INLINABLE pragmas to `generic*` functions in Data.OldList These functions are * recursive * overloaded So it's important to add an `INLINABLE` pragma to each so that they can be specialised at the use site when the specific numeric type is known. Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020) https://github.com/haskell/core-libraries-committee/issues/129 - - - - - a203ad85 by Sylvain Henry at 2023-02-17T15:59:16-05:00 Merge libiserv with ghci `libiserv` serves no purpose. As it depends on `ghci` and doesn't have more dependencies than the `ghci` package, its code could live in the `ghci` package too. This commit also moves most of the code from the `iserv` program into the `ghci` package as well so that it can be reused. This is especially useful for the implementation of TH for the JS backend (#22261, !9779). - - - - - 7080a93f by Simon Peyton Jones at 2023-02-20T12:06:32+01:00 Improve GHC.Tc.Gen.App.tcInstFun It wasn't behaving right when inst_final=False, and the function had no type variables f :: Foo => Int Rather a corner case, but we might as well do it right. Fixes #22908 Unexpectedly, three test cases (all using :type in GHCi) got slightly better output as a result: T17403, T14796, T12447 - - - - - 2592ab69 by Cheng Shao at 2023-02-20T10:35:30-05:00 compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping The wasm NCG used to map CCCS to a wasm global, based on the observation that CCCS is a transient register that's already handled by thread state load/store logic, so it doesn't need to be backed by the rCCCS field in the register table. Unfortunately, this is wrong, since even when Cmm execution hasn't yielded back to the scheduler, the Cmm code may call enterFunCCS, which does use rCCCS. This breaks cost centre profiling in a subtle way, resulting in inaccurate stack traces in some test cases. The fix is simple though: just remove the CCCS mapping. - - - - - 26243de1 by Alexis King at 2023-02-20T15:27:17-05:00 Handle top-level Addr# literals in the bytecode compiler Fixes #22376. - - - - - 0196cc2b by romes at 2023-02-20T15:27:52-05:00 fix: Explicitly flush stdout on plugin Because of #20791, the plugins tests often fail. This is a temporary fix to stop the tests from failing due to unflushed outputs on windows and the explicit flush should be removed when #20791 is fixed. - - - - - 4327d635 by Ryan Scott at 2023-02-20T20:44:34-05:00 Don't generate datacon wrappers for `type data` declarations Data constructor wrappers only make sense for _value_-level data constructors, but data constructors for `type data` declarations only exist at the _type_ level. This patch does the following: * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data constructor receives a wrapper now consider whether or not its parent data type was declared with `type data`, omitting a wrapper if this is the case. * Now that `type data` data constructors no longer receive wrappers, there is a spot of code in `refineDefaultAlt` that panics when it encounters a value headed by a `type data` type constructor. I've fixed this with a special case in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]` to explain why we do this. Fixes #22948. - - - - - 96dc58b9 by Ryan Scott at 2023-02-20T20:44:35-05:00 Treat type data declarations as empty when checking pattern-matching coverage The data constructors for a `type data` declaration don't exist at the value level, so we don't want GHC to warn users to match on them. Fixes #22964. - - - - - ff8e99f6 by Ryan Scott at 2023-02-20T20:44:35-05:00 Disallow `tagToEnum#` on `type data` types We don't want to allow users to conjure up values of a `type data` type using `tagToEnum#`, as these simply don't exist at the value level. - - - - - 8e765aff by Andrew Lelechenko at 2023-02-21T12:03:24-05:00 Bump submodule text to 2.0.2 - - - - - 172ff88f by Georgi Lyubenov at 2023-02-21T18:35:56-05:00 GHC proposal 496 - Nullary record wildcards This patch implements GHC proposal 496, which allows record wildcards to be used for nullary constructors, e.g. data A = MkA1 | MkA2 { fld1 :: Int } f :: A -> Int f (MkA1 {..}) = 0 f (MkA2 {..}) = fld1 To achieve this, we add arity information to the record field environment, so that we can accept a constructor which has no fields while continuing to reject non-record constructors with more than 1 field. See Note [Nullary constructors and empty record wildcards], as well as the more general overview in Note [Local constructor info in the renamer], both in the newly introduced GHC.Types.ConInfo module. Fixes #22161 - - - - - f70a0239 by sheaf at 2023-02-21T18:36:35-05:00 ghc-prim: levity-polymorphic array equality ops This patch changes the pointer-equality comparison operations in GHC.Prim.PtrEq to work with arrays of unlifted values, e.g. sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int# Fixes #22976 - - - - - 9296660b by Andreas Klebinger at 2023-02-21T23:58:05-05:00 base: Correct @since annotation for FP<->Integral bit cast operations. Fixes #22708 - - - - - f11d9c27 by romes at 2023-02-21T23:58:42-05:00 fix: Update documentation links Closes #23008 Additionally batches some fixes to pointers to the Note [Wired-in units], and a typo in said note. - - - - - fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00 Propagate failure if unable to push notes - - - - - 8e170f86 by Alexis King at 2023-02-23T16:59:22-05:00 rts: Fix `prompt#` when profiling is enabled This commit also adds a new -Dk RTS option to the debug RTS to assist debugging continuation captures. Currently, the printed information is quite minimal, but more can be added in the future if it proves to be useful when debugging future issues. fixes #23001 - - - - - e9e7a00d by sheaf at 2023-02-23T17:00:01-05:00 Explicit migration timeline for loopy SC solving This patch updates the warning message introduced in commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit migration timeline: GHC will no longer support this constraint solving mechanism starting from GHC 9.10. Fixes #22912 - - - - - 4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00 JS: make some arithmetic primops faster (#22835) Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org> - - - - - 92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump terminfo submodule to 0.4.1.6 - - - - - f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump unix submodule to 2.8.1.0 - - - - - 47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump deepseq submodule to 1.4.8.1 - - - - - d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump directory submodule to 1.3.8.1 - - - - - df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump process submodule to v1.6.17.0 - - - - - 4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump hsc2hs submodule to 0.68.8 - - - - - 81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump array submodule to 0.5.4.0 - - - - - 6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump Cabal submodule to 3.9 pre-release - - - - - 4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump filepath submodule to 1.4.100.1 - - - - - 2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00 Bump haskeline submodule to 0.8.2.1 - - - - - fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00 gitlab-ci: Run nix-build with -v0 This significantly cuts down on the amount of noise in the job log. Addresses #22861. - - - - - 69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00 Fix ParallelListComp out of scope suggestion This patch makes it so vars from one block of a parallel list comprehension are not in scope in a subsequent block during type checking. This was causing GHC to emit a faulty suggestion when an out of scope variable shared the occ name of a var from a different block. Fixes #22940 - - - - - ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-05:00 Fix shadowing bug in prepareAlts As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was using an OutType to construct an InAlt. When shadowing is in play, this is outright wrong. See Note [Shadowing in prepareAlts]. - - - - - 7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00 JS: Store CI perf results (fix #22923) - - - - - b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00 Don't specialise incoherent instance applications Using incoherent instances, there can be situations where two occurrences of the same overloaded function at the same type use two different instances (see #22448). For incoherently resolved instances, we must mark them with `nospec` to avoid the specialiser rewriting one to the other. This marking is done during the desugaring of the `WpEvApp` wrapper. Fixes #22448 Metric Increase: T15304 - - - - - d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00 Fix SCC grouping example - - - - - f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00 Mark setnumcapabilities001 fragile - - - - - 29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00 Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail See #22520 - - - - - 9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00 ghc-prim: fix hs_cmpxchg64 function prototype hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised builds, which go unnoticed at compile-time due to C implicit casting in .hc files. - - - - - 0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-05:00 Account for local rules in specImports As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were generating specialisations (a locally-define function) for imported functions; and then generating specialisations for those locally-defined functions. The RULE for the latter should be attached to the local Id, not put in the rules-for-imported-ids set. Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules - - - - - 8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-05:00 JS: fix for overlap with copyMutableByteArray# (#23033) The code wasn't taking into account some kind of overlap. cgrun070 has been extended to test the missing case. - - - - - 239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00 Testsuite: replace some js_skip with req_cmm req_cmm is more informative than js_skip - - - - - 7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-05:00 Take more care with unlifted bindings in the specialiser As #22998 showed, we were floating an unlifted binding to top level, which breaks a Core invariant. The fix is easy, albeit a little bit conservative. See Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise - - - - - bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-05:00 Account for TYPE vs CONSTRAINT in mkSelCo As #23018 showed, in mkRuntimeRepCo we need to account for coercions between TYPE and COERCION. See Note [mkRuntimeRepCo] in GHC.Core.Coercion. - - - - - 79ffa170 by Ben Gamari at 2023-03-01T04:17:20-05:00 hadrian: Add dependency from lib/settings to mk/config.mk In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253 by adding logic to the bindist Makefile to regenerate the `settings` file from information gleaned by the bindist `configure` script. However, this fix had no effect as `lib/settings` is shipped in the binary distribution (to allow in-place use of the binary distribution). As `lib/settings` already existed and its rule declared no dependencies, `make` would fail to use the added rule to regenerate it. Fix this by explicitly declaring a dependency from `lib/settings` on `mk/config.mk`. Fixes #22982. - - - - - a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-05:00 Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)" This reverts the bits affecting fusion of `drop` and `dropWhile` of commit 0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`. It also adds a new test for #23021 (which was the reason for reverting) as well as adds a clarifying comment to T18964. Fixes #23021, unfixes #18964. Metric Increase: T18964 Metric Decrease: T18964 - - - - - cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-05:00 Refine the test for naughty record selectors The test for naughtiness in record selectors is surprisingly subtle. See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils. Fixes #23038. - - - - - 86f240ca by romes at 2023-03-01T04:19:10-05:00 fix: Consider strictness annotation in rep_bind Fixes #23036 - - - - - 1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00 Don't suppress *all* Wanteds Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its rewriters have unfilled coercion holes; see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint. But if we thereby suppress *all* errors that's really confusing, and as #22707 shows, GHC goes on without even realising that the program is broken. Disaster. This MR arranges to un-suppress them all if they all get suppressed. Close #22707 - - - - - 8919f341 by Luite Stegeman at 2023-03-02T22:42:45-05:00 Check for platform support for JavaScript foreign imports GHC was accepting `foreign import javascript` declarations on non-JavaScript platforms. This adds a check so that these are only supported on an platform that supports the JavaScript calling convention. Fixes #22774 - - - - - db83f8bb by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Statically assert alignment of Capability In #22965 we noticed that changes in the size of `Capability` can result in unsound behavior due to the `align` pragma claiming an alignment which we don't in practice observe. Avoid this by statically asserting that the size is a multiple of the alignment. - - - - - 5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Introduce stgMallocAlignedBytes - - - - - 8a6f745d by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Correctly align Capability allocations Previously we failed to tell the C allocator that `Capability`s needed to be aligned, resulting in #22965. Fixes #22965. Fixes #22975. - - - - - 5464c73f by Ben Gamari at 2023-03-02T22:43:22-05:00 rts: Drop no-alignment special case for Windows For reasons that aren't clear, we were previously not giving Capability the same favorable alignment on Windows that we provided on other platforms. Fix this. - - - - - a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-05:00 constant folding: Correct type of decodeDouble_Int64 rule The first argument is Int64# unconditionally, so we better produce something of that type. This fixes a core lint error found in the ad package. Fixes #23019 - - - - - 68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-05:00 ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and didn't completly fix the compiler panics when compiling with `-fregs-graph`. Fixes #23002 - - - - - 2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00 Get the right in-scope set in etaBodyForJoinPoint Fixes #23026 - - - - - 45af8482 by David Feuer at 2023-03-03T11:40:47-05:00 Export getSolo from Data.Tuple Proposed in [CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113) and [approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191) - - - - - 0c694895 by David Feuer at 2023-03-03T11:40:47-05:00 Document getSolo - - - - - bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00 More fixes for `type data` declarations This MR fixes #23022 and #23023. Specifically * Beef up Note [Type data declarations] in GHC.Rename.Module, to make invariant (I1) explicit, and to name the several wrinkles. And add references to these specific wrinkles. * Add a Lint check for invariant (I1) above. See GHC.Core.Lint.checkTypeDataConOcc * Disable the `caseRules` for dataToTag# for `type data` values. See Wrinkle (W2c) in the Note above. Fixes #23023. * Refine the assertion in dataConRepArgTys, so that it does not complain about the absence of a wrapper for a `type data` constructor Fixes #23022. Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00 Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT These all type-level equality decision procedures. Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98 - - - - - bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00 Add test for T22793 - - - - - c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00 Fix typo in docs referring to threadLabel - - - - - 232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00 Add regression test for #22328 - - - - - 5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Enable response files for linker if supported - - - - - 1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Synchronize `configure.ac` and `distrib/configure.ac.in` - - - - - 70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix `hadrian/bindist/config.mk.in` … as suggested by @bgamari - - - - - b042b125 by sheaf at 2023-03-06T17:06:50-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Try to create somewhat portable `ld` command I cannot figure out a good way to generate an `ld` command that works on both Linux and macOS. Normally you'd use something like `AC_LINK_IFELSE` for this purpose (I think), but that won't let us test response file support. - - - - - 83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Quote variables … as suggested by @bgamari - - - - - 845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Fix configure failure on alpine linux - - - - - c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00 Small fixes to configure script - - - - - cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00 Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115) I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnIllegalInstanceHeadDecl TcRnUnexpectedStandaloneDerivingDecl TcRnUnusedVariableInRuleDecl TcRnUnexpectedStandaloneKindSig TcRnIllegalRuleLhs TcRnBadAssocRhs TcRnDuplicateRoleAnnot TcRnDuplicateKindSig TcRnIllegalDerivStrategy TcRnIllegalMultipleDerivClauses TcRnNoDerivStratSpecified TcRnStupidThetaInGadt TcRnBadImplicitSplice TcRnShadowedTyVarNameInFamResult TcRnIncorrectTyVarOnLhsOfInjCond TcRnUnknownTyVarsOnRhsOfInjCond Was introduced one helper type: RuleLhsErrReason - - - - - c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00 Constraint simplification loop now depends on `ExpansionFuel` instead of a boolean flag for `CDictCan.cc_pend_sc`. Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1. This helps pending given constraints to keep up with pending wanted constraints in case of `UndecidableSuperClasses` and superclass expansions while simplifying the infered type. Adds 3 dynamic flags for controlling the fuels for each type of constraints `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints Fixes #21909 Added Tests T21909, T21909b Added Note [Expanding Recursive Superclasses and ExpansionFuel] - - - - - a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00 Documentation: describe laziness of several function from Data.List - - - - - fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00 Add `Data.Functor.unzip` This function is currently present in `Data.List.NonEmpty`, but `Data.Functor` is a better home for it. This change was discussed and approved by the CLC at https://github.com/haskell/core-libraries-committee/issues/88. - - - - - 2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00 Fix documentation for traceWith and friends - - - - - f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00 Remove utils/hpc subdirectory and its contents - - - - - cf98e286 by David Binder at 2023-03-08T01:24:17-05:00 Add git submodule for utils/hpc - - - - - 605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 606793d4 by David Binder at 2023-03-08T01:24:18-05:00 Update commit for utils/hpc git submodule - - - - - 4158722a by Sylvain Henry at 2023-03-08T01:24:58-05:00 linker: fix linking with aligned sections (#23066) Take section alignment into account instead of assuming 16 bytes (which is wrong when the section requires 32 bytes, cf #23066). - - - - - 1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00 Change hostSupportsRPaths to report False on OpenBSD OpenBSD does support -rpath but ghc build process relies on some related features that don't work there. See ghc/ghc#23011 - - - - - bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00 bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args fixes #23068 - - - - - 321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Drop redundant prototype - - - - - abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix style - - - - - be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Deduplicate assertion - - - - - b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts: Use release ordering when storing thread labels Since this makes the ByteArray# visible from other cores. - - - - - 5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/BlockAlloc: Allow disabling of internal assertions These can be quite expensive and it is sometimes useful to compile a DEBUG RTS without them. - - - - - 6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - 9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - 0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00 Evac: Squash data race in eval_selector_chain - - - - - 7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Clarify comment - - - - - bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't push empty arrays to update remembered set Previously the write barrier of resizeSmallArray# incorrectly handled resizing of zero-sized arrays, pushing an invalid pointer to the update remembered set. Fixes #22931. - - - - - 92227b60 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. - - - - - ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 71b038a1 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Sanity check mutable list Assert that entries in the nonmoving generation's generational remembered set (a.k.a. mutable list) live in nonmoving generation. - - - - - 99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Fix tracking of FILLED_SWEEPING segments Previously we only updated the state of the segment at the head of each allocator's filled list. - - - - - 58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Assert state of swept segments - - - - - 2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive We must conservatively assume that new closures are reachable since we are not guaranteed to mark such blocks. - - - - - e4c3249f by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. Fixes #22927. - - - - - 1b069671 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. See the inline comments for details. Fixes #22930. - - - - - d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Post-sweep sanity checking - - - - - 0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00 nonmoving: Avoid n_caps race - - - - - 5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Be more paranoid in segment tracking Previously we left various segment link pointers dangling. None of this wrong per se, but it did make it harder than necessary to debug. - - - - - 7c817c0a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Sync-phase mark budgeting Here we significantly improve the bound on sync phase pause times by imposing a limit on the amount of work that we can perform during the sync. If we find that we have exceeded our marking budget then we allow the mutators to resume, return to concurrent marking, and try synchronizing again later. Fixes #22929. - - - - - ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Allow pinned gen0 objects to be WEAK keys - - - - - 78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Reenable assertion - - - - - b500867a by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move current segment array into Capability The current segments are conceptually owned by the mutator, not the collector. Consequently, it was quite tricky to prove that the mutator would not race with the collect due to this shared state. It turns out that such races are possible: when resizing the current segment array we may concurrently try to take a heap census. This will attempt to walk the current segment array, causing a data race. Fix this by moving the current segment array into `Capability`, where it belongs. Fixes #22926. - - - - - 56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix Note references Some references to Note [Deadlock detection under the non-moving collector] were missing an article. - - - - - 4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts/Sanity: Fix block count assertion with non-moving collector The nonmoving collector does not use `oldest_gen->blocks` to track its block list. However, it nevertheless updates `oldest_gen->n_blocks` to ensure that its size is accounted for by the storage manager. Consequently, we must not attempt to assert consistency between the two. - - - - - 96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Don't call prepareUnloadCheck When the nonmoving GC is in use we do not call `checkUnload` (since we don't unload code) and therefore should not call `prepareUnloadCheck`, lest we run into assertions. - - - - - 6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Encapsulate block allocator spinlock This makes it a bit easier to add instrumentation on this spinlock while debugging. - - - - - e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip some tests when sanity checking is enabled - - - - - 3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Fix unregisterised build - - - - - 4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Ensure that sanity checker accounts for saved_filled segments - - - - - f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00 hadrian: Add +boot_nonmoving_gc flavour transformer For using GHC bootstrapping to validate the non-moving GC. - - - - - 581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00 gitlab-ci: Add job bootstrapping with nonmoving GC - - - - - 487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Move allocator into new source file - - - - - 8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Split out nonmovingAllocateGC - - - - - 662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Only run T22795* in the normal way It doesn't make sense to run these in multiple ways as they merely test whether `-threaded`/`-single-threaded` flags. - - - - - 0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Rename clear_segment(_free_blocks)? To reflect the fact that these are to do with the nonmoving collector, now since they are exposed no longer static. - - - - - 7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Fix incorrect STATIC_INLINE This should be INLINE_HEADER lest we get unused declaration warnings. - - - - - f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Mark ffi023 as broken due to #23089 - - - - - a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00 testsuite: Skip T7160 in the nonmoving way Finalization order is different under the nonmoving collector. - - - - - f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00 rts: Capture GC configuration in a struct The number of distinct arguments passed to GarbageCollect was getting a bit out of hand. - - - - - ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00 nonmoving: Non-concurrent collection - - - - - 7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00 hadrian: Fix flavour compiler stage options off-by-one error !9193 pointed out that ghcDebugAssertions was supposed to be a predicate on the stage of the built compiler, but in practice it was a predicate on the stage of the compiler used to build. Unfortunately, while it fixed that issue for ghcDebugAssertions, it documented every other similar option as behaving the same way when in fact they all used the old behavior. The new behavior of ghcDebugAssertions seems more intuitive, so this commit changes the interpretation of every other option to match. It also improves the enableProfiledGhc and debugGhc flavour transformers by making them more selective about which stages in which they build additional library/RTS ways. - - - - - f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00 Delete created temporary subdirectories at end of session. This patch adds temporary subdirectories to the list of paths do clean up at the end of the GHC session. This fixes warnings about non-empty temporary directories. Fixes #22952 - - - - - 9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00 Fixes #19627. Previously the solver failed with an unhelpful "solver reached too may iterations" error. With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up. This commit adds: * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel] * Test `typecheck/should_fail/T19627.hs` for regression purposes - - - - - ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00 DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997) We should not panic in `add_demands` (now `set_lam_dmds`), because that code path is legimitely taken for OPAQUE PAP bindings, as in T22997. Fixes #22997. - - - - - 5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00 JS: remove dead code for old integer-gmp - - - - - bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00 JS: Fix implementation of MK_JSVAL - - - - - ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00 Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf. - - - - - 047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00 JS: fix implementation of forceBool to use JS backend syntax - - - - - 559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00 Simplifier: `countValArgs` should not count Type args (#23102) I observed miscompilations while working on !10088 caused by this. Fixes #23102. Metric Decrease: T10421 - - - - - 536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00 Bump Win32 to 2.13.4.0 Updates Win32 submodule - - - - - ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00 ghc-bignum: Drop redundant include-dirs field - - - - - c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00 Fix BCO creation setting caps when -j > -N * Remove calls to 'setNumCapabilities' in 'createBCOs' These calls exist to ensure that 'createBCOs' can benefit from parallelism. But this is not the right place to call `setNumCapabilities`. Furthermore the logic differs from that in the driver causing the capability count to be raised and lowered at each TH call if -j > -N. * Remove 'BCOOpts' No longer needed as it was only used to thread the job count down to `createBCOs` Resolves #23049 - - - - - 5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00 Add changelog entry for #23049 - - - - - 6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00 configure: Fix FIND_CXX_STD_LIB test on Darwin Annoyingly, Darwin's <cstddef> includes <version> and APFS is case-insensitive. Consequently, it will end up #including the `VERSION` file generated by the `configure` script on the second and subsequent runs of the `configure` script. See #23116. - - - - - 19d6d039 by sheaf at 2023-03-16T21:31:22+01:00 ghci: only keep the GlobalRdrEnv in ModInfo The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo, which includes a TypeEnv. This can easily cause space leaks as we have no way of forcing everything in a type environment. In GHC, we only use the GlobalRdrEnv, which we can force completely. So we only store that instead of a fully-fledged ModuleInfo. - - - - - 73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00 Add structured error messages for GHC.Tc.Utils.Backpack Tracking ticket: #20119 MR: !10127 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. One occurrence, when handing a nested error from the interface loading machinery, was omitted. It will be handled by a subsequent changeset that addresses interface errors. - - - - - a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00 Rename () into Unit, (,,...,,) into Tuple<n> (#21294) This patch implements a part of GHC Proposal #475. The key change is in GHC.Tuple.Prim: - data () = () - data (a,b) = (a,b) - data (a,b,c) = (a,b,c) ... + data Unit = () + data Tuple2 a b = (a,b) + data Tuple3 a b c = (a,b,c) ... And the rest of the patch makes sure that Unit and Tuple<n> are pretty-printed as () and (,,...,,) in various contexts. Updates the haddock submodule. Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com> - - - - - 23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: fix some wrongs in the eventlog format documentation - - - - - 90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: explain the BLOCK_MARKER event - - - - - ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add BlockedOnMVarRead thread status in eventlog encodings - - - - - 898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add TASK_DELETE event in eventlog encodings - - - - - bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00 docs: add WALL_CLOCK_TIME event in eventlog encodings - - - - - eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00 Add structured error messages for GHC.Tc.Utils.Env Tracking ticket: #20119 MR: !10129 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00 Document pdep / pext primops - - - - - e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00 Allow LLVM backend to use HDoc for faster file generation. Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement. Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045) - - - - - ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00 Compute LambdaFormInfo when using JavaScript backend. CmmCgInfos is needed to write interface files, but the JavaScript backend does not generate it, causing "Name without LFInfo" warnings. This patch adds a conservative but always correct CmmCgInfos when the JavaScript backend is used. Fixes #23053 - - - - - 926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00 Be more careful about quantification This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole - - - - - 0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00 Testsuite: use appropriate predicate for ManyUbxSums test (#22576) - - - - - 048c881e by romes at 2023-03-22T01:04:24-04:00 fix: Incorrect @since annotations in GHC.TypeError Fixes #23128 - - - - - a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T16318 (#22370) - - - - - ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00 Testsuite: use req_interp predicate for T20214 - - - - - e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00 Refactor the constraint solver pipeline The big change is to put the entire type-equality solver into GHC.Tc.Solver.Equality, rather than scattering it over Canonical and Interact. Other changes * EqCt becomes its own data type, a bit like QCInst. This is great because EqualCtList is then just [EqCt] * New module GHC.Tc.Solver.Dict has come of the class-contraint solver. In due course it will be all. One step at a time. This MR is intended to have zero change in behaviour: it is a pure refactor. It opens the way to subsequent tidying up, we believe. - - - - - cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00 Add structured error messages for GHC.Tc.Utils.TcMType Tracking ticket: #20119 MR: !10138 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00 Testsuite: use js_skip for T2615 (#22374) - - - - - 8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00 Optimized Foldable methods for Data.Functor.Compose Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose Implementation of https://github.com/haskell/core-libraries-committee/issues/57 - - - - - bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00 Additional optimized versions - - - - - 80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Simplify minimum/maximum in instance Foldable (Compose f g) - - - - - 8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00 Update changelog to mention changes to instance Foldable (Compose f g) - - - - - e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00 Add structured error messages for GHC.Tc.TyCl.PatSyn Tracking ticket: #20117 MR: !10158 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00 Allow WARNING pragmas to be controlled with custom categories Closes #17209. This implements GHC Proposal 541, allowing a WARNING pragma to be annotated with a category like so: {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-} The user can then enable, disable and set the severity of such warnings using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on. There is a new warning group `-Wextended-warnings` containing all these warnings. Warnings without a category are treated as if the category was `deprecations`, and are (still) controlled by the flags `-Wdeprecations` and `-Wwarnings-deprecations`. Updates Haddock submodule. - - - - - 0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00 Move mention of warning groups change to 9.8.1 release notes - - - - - b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00 nativeGen/AArch64: Fix bitmask immediate predicate Previously the predicate for determining whether a logical instruction operand could be encoded as a bitmask immediate was far too conservative. This meant that, e.g., pointer untagged required five instructions whereas it should only require one. Fixes #23030. - - - - - 46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00 User's guide: Improve docs for -Wall previously it would list the warnings _not_ enabled by -Wall. That’s unnecessary round-about and was out of date. So let's just name the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`). - - - - - 509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00 codeGen/tsan: Disable instrumentation of unaligned stores There is some disagreement regarding the prototype of `__tsan_unaligned_write` (specifically whether it takes just the written address, or the address and the value as an argument). Moreover, I have observed crashes which appear to be due to it. Disable instrumentation of unaligned stores as a temporary mitigation. Fixes #23096. - - - - - 6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00 base: Document GHC versions associated with past base versions in the changelog - - - - - 43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00 Add regression test for #17574 This test currently fails in the nonmoving way - - - - - f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00 fix: account for large and compact object stats with nonmoving gc Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap. We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap. Resolves #17574 - - - - - 7131b705 by David Feuer at 2023-03-25T00:04:04-04:00 Modify ThreadId documentation and comments For a long time, `GHC.Conc.Sync` has said ```haskell -- ToDo: data ThreadId = ThreadId (Weak ThreadId#) -- But since ThreadId# is unlifted, the Weak type must use open -- type variables. ``` We are now actually capable of using `Weak# ThreadId#`, but the world has moved on. To support the `Show` and `Ord` instances, we'd need to store the thread ID number in the `ThreadId`. And it seems very difficult to continue to support `threadStatus` in that regime, since it needs to be able to explain how threads died. In addition, garbage collection of weak references can be quite expensive, and it would be hard to evaluate the cost over he whole ecosystem. As discussed in [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125), it doesn't seem very likely that we'll actually switch to weak references here. - - - - - c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00 rts: Fix barriers of IND and IND_STATIC Previously IND and IND_STATIC lacked the acquire barriers enjoyed by BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers], this barrier is critical to ensure that the indirectee is visible to the entering core. Fixes #22872. - - - - - 62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00 Improve documentation of atomicModifyMutVar2# - - - - - b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00 rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023 This patch does a few things: - Add the missing RtsSymbols.c entry of performBlockingMajorGC - Make hs_perform_gc call performBlockingMajorGC, which restores previous behavior - Use hs_perform_gc in ffi023 - Remove rts_clearMemory() call in ffi023, it now works again in some test ways previously marked as broken. Fixes #23089 - - - - - d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00 testsuite: add the rts_clearMemory test case This patch adds a standalone test case for rts_clearMemory that mimics how it's typically used by wasm backend users and ensures this RTS API isn't broken by future RTS refactorings. Fixes #23901. - - - - - 80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00 Improve documentation for resizing of byte arrays - - - - - c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00 rts: Don't rely on EXTERN_INLINE for slop-zeroing logic Previously we relied on calling EXTERN_INLINE functions defined in ClosureMacros.h from Cmm to zero slop. However, as far as I can tell, this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted in each compilation unit. Fix this by explicitly declaring a new set of non-inline functions in ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h definitions as INLINE_HEADER. In the future we should try to eliminate EXTERN_INLINE. - - - - - c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00 rts: Fix capability-count check in zeroSlop Previously `zeroSlop` examined `RtsFlags` to determine whether the program was single-threaded. This is wrong; a program may be started with `+RTS -N1` yet the process may later increase the capability count with `setNumCapabilities`. This lead to quite subtle and rare crashes. Fixes #23088. - - - - - 656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00 Add Eq/Ord instances for SSymbol, SChar, and SNat This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148). - - - - - 4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00 Update and expand atomic modification Haddocks * The documentation for `atomicModifyIORef` and `atomicModifyIORef'` were incomplete, and the documentation for `atomicModifyIORef` was out of date. Update and expand. * Remove a useless lazy pattern match in the definition of `atomicModifyIORef`. The pair it claims to match lazily was already forced by `atomicModifyIORef2`. - - - - - e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00 Document the constructor name for lists Derived `Data` instances use raw infix constructor names when applicable. The `Data.Data [a]` instance, if derived, would have a constructor name of `":"`. However, it actually uses constructor name `"(:)"`. Document this peculiarity. See https://github.com/haskell/core-libraries-committee/issues/147 - - - - - c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00 Make exprIsConApp_maybe a bit cleverer Addresses #23159. See Note Note [Exploit occ-info in exprIsConApp_maybe] in GHC.Core.SimpleOpt. Compile times go down very slightly, but always go down, never up. Good! Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -1.8% T15703(normal) -1.2% GOOD geo. mean -0.1% minimum -1.8% maximum +0.0% Metric Decrease: CoOpt_Singletons T15703 - - - - - 76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00 Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat This implements [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149). - - - - - 3f374399 by sheaf at 2023-03-29T13:57:33+02:00 Handle records in the renamer This patch moves the field-based logic for disambiguating record updates to the renamer. The type-directed logic, scheduled for removal, remains in the typechecker. To do this properly (and fix the myriad of bugs surrounding the treatment of duplicate record fields), we took the following main steps: 1. Create GREInfo, a renamer-level equivalent to TyThing which stores information pertinent to the renamer. This allows us to uniformly treat imported and local Names in the renamer, as described in Note [GREInfo]. 2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which distinguished between normal names and field names, we now store simple Names in GlobalRdrElt, along with the new GREInfo information which allows us to recover the FieldLabel for record fields. 3. Add namespacing for record fields, within the OccNames themselves. This allows us to remove the mangling of duplicate field selectors. This change ensures we don't print mangled names to the user in error messages, and allows us to handle duplicate record fields in Template Haskell. 4. Move record disambiguation to the renamer, and operate on the level of data constructors instead, to handle #21443. The error message text for ambiguous record updates has also been changed to reflect that type-directed disambiguation is on the way out. (3) means that OccEnv is now a bit more complex: we first key on the textual name, which gives an inner map keyed on NameSpace: OccEnv a ~ FastStringEnv (UniqFM NameSpace a) Note that this change, along with (2), both increase the memory residency of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to regress somewhat in compile-time allocation. Even though (3) simplified a lot of code (in particular the treatment of field selectors within Template Haskell and in error messages), it came with one important wrinkle: in the situation of -- M.hs-boot module M where { data A; foo :: A -> Int } -- M.hs module M where { data A = MkA { foo :: Int } } we have that M.hs-boot exports a variable foo, which is supposed to match with the record field foo that M exports. To solve this issue, we add a new impedance-matching binding to M foo{var} = foo{fld} This mimics the logic that existed already for impedance-binding DFunIds, but getting it right was a bit tricky. See Note [Record field impedance matching] in GHC.Tc.Module. We also needed to be careful to avoid introducing space leaks in GHCi. So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in ModIface. This means stubbing out all the GREInfo fields, with the function forceGlobalRdrEnv. When we read it back in, we rehydrate with rehydrateGlobalRdrEnv. This robustly avoids any space leaks caused by retaining old type environments. Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063 Updates haddock submodule ------------------------- Metric Increase: MultiComponentModules MultiLayerModules MultiLayerModulesDefsGhci MultiLayerModulesNoCode T13701 T14697 hard_hole_fits ------------------------- - - - - - 4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00 Avoid repeatedly shadowing in shadowNames This commit refactors GHC.Type.Name.Reader.shadowNames to first accumulate all the shadowing arising from the introduction of a new set of GREs, and then applies all the shadowing to the old GlobalRdrEnv in one go. - - - - - d246049c by sheaf at 2023-03-29T13:57:34+02:00 igre_prompt_env: discard "only-qualified" names We were unnecessarily carrying around names only available qualified in igre_prompt_env, violating the icReaderEnv invariant. We now get rid of these, as they aren't needed for the shadowing computation that igre_prompt_env exists for. Fixes #23177 ------------------------- Metric Decrease: T14052 T14052Type ------------------------- - - - - - 41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00 hadrian: Fix path to HpcParser.y The source for this project has been moved into a src/ folder so we also need to update this path. Fixes #23187 - - - - - b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00 js: split JMacro into JS eDSL and JS syntax This commit: Splits JExpr and JStat into two nearly identical DSLs: - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a value cannot be unsaturated, or, a value of this DSL is a witness that a value of GHC.JS.Unsat has been saturated - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation. Then all binary and outputable instances are changed to use GHC.JS.Syntax. This moves us closer to closing out #22736 and #22352. See #22736 for roadmap. ------------------------- Metric Increase: CoOpt_Read LargeRecord ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T10858 T11195 T11374 T11822 T12227 T12707 T13035 T13253 T13253-spj T13379 T14683 T15164 T15703 T16577 T17096 T17516 T17836 T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T4801 T5321FD T5321Fun T5631 T5642 T783 T9198 T9233 T9630 TcPlugin_RewritePerf WWRec ------------------------- - - - - - f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. Also used the opportunity to reenable 64-bit Word/Int tests - - - - - a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00 testsuite: Fix racing prints in T21465 As noted in #23155, we previously failed to add flushes necessary to ensure predictable output. Fixes #23155. - - - - - 98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00 Revert "ghc-heap: remove wrong Addr# coercion (#23181)" This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02. This fails to build with GHC-9.2 as a boot compiler. See #23195 for tracking this issue. - - - - - 61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Add {-# WARNING #-} to Data.List.{head,tail} - - - - - 8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-} - - - - - 7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Bump submodules - - - - - d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00 Fix tests - - - - - 3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00 Proxies for head and tail: review suggestions - - - - - 930edcfd by sheaf at 2023-03-30T14:36:33-04:00 docs: move RecordUpd changelog entry to 9.8 This was accidentally included in the 9.6 changelog instead of the 9.6 changelog. - - - - - 6f885e65 by sheaf at 2023-03-30T14:37:09-04:00 Add LANGUAGE GADTs to GHC.Rename.Env We need to enable this extension for the file to compile with ghc 9.2, as we are pattern matching on a GADT and this required the GADT extension to be enabled until 9.4. - - - - - 6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: make lint-ci-config job fast again We don't pin our nixpkgs revision and tracks the default nixpkgs-unstable channel anyway. Instead of using haskell.packages.ghc924, we should be using haskell.packages.ghc92 to maximize the binary cache hit rate and make lint-ci-config job fast again. Also bumps the nix docker image to the latest revision. - - - - - ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: ensure that all non-i386 pipelines do parallel xz compression We can safely enable parallel xz compression for non-i386 pipelines. However, previously we didn't export XZ_OPT, so the xz process won't see it if XZ_OPT hasn't already been set in the current job. - - - - - 20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: unset CROSS_EMULATOR for js job - - - - - 4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: fix lint-testsuite job The list_broken make target will transitively depend on the calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It really should be TEST_HC since that's what get passed in the gitlab CI config. - - - - - cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00 ci: use alpine3_17-wasm image for wasm jobs Bump the ci-images dependency and use the new alpine3_17-wasm docker image for wasm jobs. - - - - - 79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Add basic support for testing cross-compilers - - - - - e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00 testsuite/driver: Normalize away differences in ghc executable name - - - - - ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00 hadrian: Pass CROSS_EMULATOR to runtests.py - - - - - 30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: don't add optllvm way for wasm32 - - - - - f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: normalize the .wasm extension - - - - - a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: strip the cross ghc prefix in output and error message - - - - - f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: handle target executable extension - - - - - 8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: mypy typing error fixes This patch fixes some mypy typing errors which weren't caught in previous linting jobs. - - - - - 0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: use context variable instead of thread-local variable This patch changes a thread-local variable to context variable instead, which works as intended when the testsuite transitions to use asyncio & coroutines instead of multi-threading to concurrently run test cases. Note that this also raises the minimum Python version to 3.7. - - - - - ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00 testsuite: asyncify the testsuite driver This patch refactors the testsuite driver, gets rid of multi-threading logic for running test cases concurrently, and uses asyncio & coroutines instead. This is not yak shaving for its own sake; the previous multi-threading logic is prone to livelock/deadlock conditions for some reason, even if the total number of threads is bounded to a thread pool's capacity. The asyncify change is an internal implementation detail of the testsuite driver and does not impact most GHC maintainers out there. The patch does not touch the .T files, test cases can be added/modified the exact same way as before. - - - - - 0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00 Add test for T23184 There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch: ``` commit 6656f0165a30fc2a22208532ba384fc8e2f11b46 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Jul 23 23:57:01 2021 +0100 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: ...lots of lines omitted... Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. ``` Note this "Fix a fairly longstanding outright bug". This is the specific fix ``` @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds -- let a = ...arg... -- in [...hole...] a -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable - do { let (dmd:_) = dmds -- Never fails - ; (floats1, cont') <- mkDupableContWithDmds env dmds cont + do { let (dmd:cont_dmds) = dmds -- Never fails + ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 ; (_, se', arg') <- simplArg env' dup se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ``` Ticket #23184 is a report of the bug that this diff fixes. - - - - - 62d25071 by mangoiv at 2023-04-01T04:20:01-04:00 [feat] make ($) representation polymorphic - this change was approved by the CLC in [1] following a CLC proposal [2] - make ($) representation polymorphic (adjust the type signature) - change ($) implementation to allow additional polymorphism - adjust the haddock of ($) to reflect these changes - add additional documentation to document these changes - add changelog entry - adjust tests (move now succeeding tests and adjust stdout of some tests) [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854 [2] https://github.com/haskell/core-libraries-committee/issues/132 - - - - - 77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00 User Guide: update copyright year: 2020->2023 - - - - - 3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00 driver: Unit State Data.Map -> GHC.Unique.UniqMap In pursuit of #22426. The driver and unit state are major contributors. This commit also bumps the haddock submodule to reflect the API changes in UniqMap. ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp T10421 T10547 T12150 T12234 T12425 T13035 T16875 T18140 T18304 T18698a T18698b T18923 T20049 T5837 T6048 T9198 ------------------------- - - - - - a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00 Add structured error messages for GHC.Tc.TyCl Tracking ticket: #20117 MR: !10183 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00 JS: Linker: use saturated JExpr Follow on to MR!10142 in pursuit of #22736 - - - - - 3da69346 by sheaf at 2023-04-01T18:28:37-04:00 Improve haddocks of template-haskell Con datatype This adds a bit more information, in particular about the lists of constructors in the GadtC and RecGadtC cases. - - - - - 3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00 TH: revert changes to GadtC & RecGadtC Commit 3f374399 included a breaking-change to the template-haskell library when it made the GadtC and RecGadtC constructors take non-empty lists of names. As this has the potential to break many users' packages, we decided to revert these changes for now. - - - - - f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00 Rework documentation for data Char - - - - - 43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00 cmm: implement parsing of MO_AtomicRMW from hand-written CMM files Fixes #23206 - - - - - ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00 ghc-heap: remove wrong Addr# coercion (#23181) Conversion from Addr# to I# isn't correct with the JS backend. - - - - - 2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00 hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1 Also fixes the ./generate_bootstrap_plans script which was recently broken We can hopefully drop the 9.2 plans soon but they still work so kept them around for now. - - - - - c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00 ci: Add job to test 9.6 bootstrapping - - - - - 53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00 hadrian: Improve option parsing Several options in Hadrian had their argument marked as optional (`OptArg`), but if the argument wasn't there they were just giving an error. It's more idiomatic to mark the argument as required instead; the code uses less Maybes, the parser can enforce that the argument is present, --help gives better output. - - - - - a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00 JS: fix issues with FD api support - Add missing implementations for fcntl_read/write/lock - Fix fdGetMode These were found while implementing TH in !9779. These functions must be used somehow by the external interpreter code. - - - - - 8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00 Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnDataKindsError TcRnUnusedQuantifiedTypeVar TcRnIllegalKindSignature TcRnUnexpectedPatSigType TcRnSectionPrecedenceError TcRnPrecedenceParsingError TcRnIllegalKind TcRnNegativeNumTypeLiteral TcRnUnexpectedKindVar TcRnBindMultipleVariables TcRnBindVarAlreadyInScope - - - - - 220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00 Fixes around unsafeCoerce# 1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul in 74ad75e87317, `unsafeCoerce#` is no longer defined there. I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module. 2. The documentation of `unsafeCoerce#` stated that you should not cast a function to an algebraic type, even if you later cast it back before applying it. But ghci was doing that type of cast, as can be seen with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any following the documentation. - - - - - 9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00 Add a few more memcpy-ish primops * copyMutableByteArrayNonOverlapping# * copyAddrToAddr# * copyAddrToAddrNonOverlapping# * setAddrRange# The implementations of copyBytes, moveBytes, and fillBytes in base:Foreign.Marshal.Utils now use these new primops, which can cause us to work a bit harder generating code for them, resulting in the metric increase in T21839c observed by CI on some architectures. But in exchange, we get better code! Metric Increase: T21839c - - - - - f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00 StgToCmm: Upgrade -fcheck-prim-bounds behavior Fixes #21054. Additionally, we can now check for range overlap when generating Cmm for primops that use memcpy internally. - - - - - cd00e321 by sheaf at 2023-04-04T01:04:50-04:00 Relax assertion in varToRecFieldOcc When using Template Haskell, it is possible to re-parent a field OccName belonging to one data constructor to another data constructor. The lsp-types package did this in order to "extend" a data constructor with additional fields. This ran into an assertion in 'varToRecFieldOcc'. This assertion can simply be relaxed, as the resulting splices are perfectly sound. Fixes #23220 - - - - - eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00 GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201) - - - - - 071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00 Make INLINE pragmas for pattern synonyms work with TH Previously, the code for converting `INLINE <name>` pragmas from TH splices used `vNameN`, which assumed that `<name>` must live in the variable namespace. Pattern synonyms, on the other hand, live in the constructor namespace. I've fixed the issue by switching to `vcNameN` instead, which works for both the variable and constructor namespaces. Fixes #23203. - - - - - 7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00 Fix unification with oversaturated type families unify_ty was incorrectly saying that F x y ~ T x are surely apart, where F x y is an oversaturated type family and T x is a tyconapp. As a result, the simplifier dropped a live case alternative (#23134). - - - - - c165f079 by sheaf at 2023-04-04T17:13:40-04:00 Add testcase for #23192 This issue around solving of constraints arising from superclass expansion using other constraints also borned from superclass expansion was the topic of commit aed1974e. That commit made sure we don't emit a "redundant constraint" warning in a situation in which removing the constraint would cause errors. Fixes #23192 - - - - - d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00 nonmoving: Disable slop-zeroing As noted in #23170, the nonmoving GC can race with a mutator zeroing the slop of an updated thunk (in much the same way that two mutators would race). Consequently, we must disable slop-zeroing when the nonmoving GC is in use. Closes #23170 - - - - - 04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00 Fix reverse flag for -Wunsupported-llvm-version - - - - - 0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00 Add release note for GHC.Unicode refactor in base-4.18. Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in base-4.18 and add proper release date. - - - - - cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00 Improve documentation for ($) (#22963) - - - - - 5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00 Remove trailing whitespace from ($) commentary - - - - - b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00 Adjust wording wrt representation polymorphism of ($) - - - - - 6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00 Add structured error messages for GHC.Tc.TyCl.Utils Tracking ticket: #20117 MR: !10251 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00 Renamer: don't call addUsedGRE on an exact Name When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc, we could end up calling addUsedGRE on an exact Name, which would then lead to a panic in the bestImport function: it would be incapable of processing a GRE which is not local but also not brought into scope by any imports (as it is referred to by its unique instead). Fixes #23240 - - - - - bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add support for -debug in the testsuite Confusingly, GhcDebugged referred to GhcDebugAssertions. - - - - - b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00 Add missing cases in -Di prettyprinter Fixes #23142 - - - - - 6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: make WasmCodeGenM an instance of MonadUnique - - - - - 05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00 compiler: apply cmm node-splitting for wasm backend This patch applies cmm node-splitting for wasm32 NCG, which is required when handling irreducible CFGs. Fixes #23237. - - - - - f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00 Set base 'maintainer' field to CLC - - - - - ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00 Clarify a couple of Notes about 'nospec' - - - - - ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00 Allow generation of TTH syntax with TH In other words allow generation of typed splices and brackets with Untyped Template Haskell. That is useful in cases where a library is build with TTH in mind, but we still want to generate some auxiliary declarations, where TTH cannot help us, but untyped TH can. Such example is e.g. `staged-sop` which works with TTH, but we would like to derive `Generic` declarations with TH. An alternative approach is to use `unsafeCodeCoerce`, but then the derived `Generic` instances would be type-checked only at use sites, i.e. much later. Also `-ddump-splices` output is quite ugly: user-written instances would use TTH brackets, not `unsafeCodeCoerce`. This commit doesn't allow generating of untyped template splices and brackets with untyped TH, as I don't know why one would want to do that (instead of merging the splices, e.g.) - - - - - 690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00 Add regression test for #23229 - - - - - 59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quotRem rules (#22152) case quotRemInt# x y of (# q, _ #) -> body ====> case quotInt# x y of q -> body case quotRemInt# x y of (# _, r #) -> body ====> case remInt# x y of r -> body - - - - - 4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Add quot folding rule (#22152) (x / l1) / l2 l1 and l2 /= 0 l1*l2 doesn't overflow ==> x / (l1 * l2) - - - - - 1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make Int64/Word64 division ok for speculation too. Only when the divisor is definitely non-zero. - - - - - 8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00 Make WordQuotRem2Op ok-for-speculation too - - - - - 27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00 Base/JS: GHC.JS.Foreign.Callback module (issue 23126) * Add the Callback module for "exporting" Haskell functions to be available to plain JavaScript code * Fix some primitives defined in GHC.JS.Prim * Add a JavaScript section to the user guide with instructions on how to use the JavaScript FFI, building up to using Callbacks to interact with the browser * Add tests for the JavaScript FFI and Callbacks - - - - - a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00 rts: improve memory ordering and add some comments in the StablePtr implementation - - - - - d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00 docs: Generate docs/index.html with version number * Generate docs/index.html to include the version of the ghc library * This also fixes the packageVersions interpolations which were - Missing an interpolation for `LIBRARY_ghc_VERSION` - Double quoting the version so that "9.7" was being inserted. Fixes #23121 - - - - - d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00 Stop if type constructors have kind errors Otherwise we get knock-on errors, such as #23252. This makes GHC fail a bit sooner, and I have not attempted to add recovery code, to add a fake TyCon place of the erroneous one, in an attempt to get more type errors in one pass. We could do that (perhaps) if there was a call for it. - - - - - 2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Major refactor in the handling of equality constraints This MR substantially refactors the way in which the constraint solver deals with equality constraints. The big thing is: * Intead of a pipeline in which we /first/ canonicalise and /then/ interact (the latter including performing unification) the two steps are more closely integreated into one. That avoids the current rather indirect communication between the two steps. The proximate cause for this refactoring is fixing #22194, which involve solving [W] alpha[2] ~ Maybe (F beta[4]) by doing this: alpha[2] := Maybe delta[2] [W] delta[2] ~ F beta[4] That is, we don't promote beta[4]! This is very like introducing a cycle breaker, and was very awkward to do before, but now it is all nice. See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and Note [Family applications in canonical constraints]. The big change is this: * Several canonicalisation checks (occurs-check, cycle-breaking, checking for concreteness) are combined into one new function: GHC.Tc.Utils.Unify.checkTyEqRhs This function is controlled by `TyEqFlags`, which says what to do for foralls, type families etc. * `canEqCanLHSFinish` now sees if unification is possible, and if so, actually does it: see `canEqCanLHSFinish_try_unification`. There are loads of smaller changes: * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a cheap-and-cheerful version of `checkTyEqRhs`, called `simpleUnifyCheck`. If `simpleUnifyCheck` succeeds, it can unify, otherwise it defers by emitting a constraint. This is simpler than before. * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`. Especially the nasty stuff involving `swap_for_occurs` and `canEqTyVarFunEq`. Much nicer now. See Note [Orienting TyVarLHS/TyFamLHS] Note [Orienting TyFamLHS/TyFamLHS] * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the problems that can be discovered by `checkTyEqRhs`. * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to to accept both cases in #22194 rather than rejecting both. Yet smaller: * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`) to reduce the need for synonym expansion when checking concreteness. Use it in `isConcreteType`. * Renamed `isConcrete` to `isConcreteType` * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient way to find if a particular type variable is used injectively than finding all the injective variables. It is called in `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a lot. * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the constraint solver. Fixes #22194, #23199 Compile times decrease by an average of 0.1%; but there is a 7.4% drop in compiler allocation on T15703. Metric Decrease: T15703 - - - - - 99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Add some documentation about redundant constraints - - - - - 3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Improve partial signatures This MR fixes #23223. The changes are in two places: * GHC.Tc.Bind.checkMonomorphismRestriction See the new `Note [When the MR applies]` We now no longer stupidly attempt to apply the MR when the user specifies a context, e.g. f :: Eq a => _ -> _ * GHC.Tc.Solver.decideQuantification See rewritten `Note [Constraints in partial type signatures]` Fixing this bug apparently breaks three tests: * partial-sigs/should_compile/T11192 * partial-sigs/should_fail/Defaulting1MROff * partial-sigs/should_fail/T11122 However they are all symptoms of #23232, so I'm marking them as expect_broken(23232). I feel happy about this MR. Nice. - - - - - 23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00 Make approximateWC a bit cleverer This MR fixes #23224: making approximateWC more clever See the long `Note [ApproximateWC]` in GHC.Tc.Solver All this is delicate and ad-hoc -- but it /has/ to be: we are talking about inferring a type for a binding in the presence of GADTs, type families and whatnot: known difficult territory. We just try as hard as we can. - - - - - 2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00 docs: Update template-haskell docs to use Code Q a rather than Q (TExp a) Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a rather than Q (TExp a). The documentation in the `template-haskell` library wasn't updated to reflect this change. Fixes #23148 - - - - - 0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00 Show an error when we cannot default a concrete tyvar Fixes #23153 - - - - - bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00 Handle ConcreteTvs in inferResultToType inferResultToType was discarding the ir_frr information, which meant some metavariables ended up being MetaTvs instead of ConcreteTvs. This function now creates new ConcreteTvs as necessary, instead of always creating MetaTvs. Fixes #23154 - - - - - 3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00 Transfer DFunId_ness onto specialised bindings Whether a binding is a DFunId or not has consequences for the `-fdicts-strict` flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does not apply because the constraint solver can create recursive groups of dictionaries. In #22549 this was fixed for the "normal" case, see Note [Do not strictify the argument dictionaries of a dfun]. However the loop still existed if the DFunId was being specialised. The problem was that the specialiser would specialise a DFunId and turn it into a VanillaId and so the demand analyser didn't know to apply special treatment to the binding anymore and the whole recursive group was optimised to bottom. The solution is to transfer over the DFunId-ness of the binding in the specialiser so that the demand analyser knows not to apply the `-fstrict-dicts`. Fixes #22549 - - - - - a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00 Add import lists to few GHC.Driver.Session imports Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261. There are a lot of GHC.Driver.Session which only use DynFlags, but not the parsing code. - - - - - 51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00 Account for special GHC.Prim import in warnUnusedPackages The GHC.Prim import is treated quite specially primarily because there isn't an interface file for GHC.Prim. Therefore we record separately in the ModSummary if it's imported or not so we don't go looking for it. This logic hasn't made it's way to `-Wunused-packages` so if you imported GHC.Prim then the warning would complain you didn't use `-package ghc-prim`. Fixes #23212 - - - - - 1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00 Add regression test for #23199 - - - - - 0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00 validDerivPred: Reject exotic constraints in IrredPreds This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely, we should reject `IrredPred`s that are inferred from `deriving` clauses whose arguments contain other type constructors, as described in `(VD2) Reject exotic constraints` of that Note. This has the nice property that `deriving` clauses whose inferred instance context mention `TypeError` will now emit the type error in the resulting error message, which better matches existing intuitions about how `TypeError` should work. While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]` was duplicated in a separate `Note [Exotic derived instance contexts]` in `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that there is a single authority on describing the conditions under which an inferred `deriving` constraint can be considered valid. This changes the behavior of `deriving` in a way that existing code might break, so I have made a mention of this in the GHC User's Guide. It seems very, very unlikely that much code is relying on this strange behavior, however, and even if there is, there is a clear, backwards-compatible migration path using `StandaloneDeriving`. Fixes #22696. - - - - - 10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00 Misc cleanup - Use dedicated list functions - Make cloneBndrs and cloneRecIdBndrs monadic - Fix invalid haddock comments in libraries/base - - - - - 5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00 Convert interface file loading errors into proper diagnostics This patch converts all the errors to do with loading interface files into proper structured diagnostics. * DriverMessage: Sometimes in the driver we attempt to load an interface file so we embed the IfaceMessage into the DriverMessage. * TcRnMessage: Most the time we are loading interface files during typechecking, so we embed the IfaceMessage This patch also removes the TcRnInterfaceLookupError constructor which is superceded by the IfaceMessage, which is now structured compared to just storing an SDoc before. - - - - - df1a5811 by sheaf at 2023-04-18T10:31:43-04:00 Don't panic in ltPatersonSize The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it encountered a type family on the RHS, as usually these are not allowed (type families are not allowed on the RHS of class instances or of quantified constraints). However, it is possible to still encounter type families on the RHS after doing a bit of constraint solving, as seen in test case T23171. This could trigger the panic in the call to ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which is involved in avoiding loopy superclass constraints. This patch simply changes ltPatersonSize to return "I don't know, because there's a type family involved" in these cases. Fixes #23171 - - - - - d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00 JS: fix thread-related primops - - - - - 7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00 CI: Disable abi-test-nightly See #23269 - - - - - ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00 Testsuite: don't use obsolescent egrep (#22351) Recent egrep displays the following message, breaking golden tests: egrep: warning: egrep is obsolescent; using grep -E Switch to using "grep -E" instead - - - - - f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00 hadrian: Pass haddock file arguments in a response file In !10119 CI was failing on windows because the command line was too long. We can mitigate this by passing the file arguments to haddock in a response file. We can't easily pass all the arguments in a response file because the `+RTS` arguments can't be placed in the response file. Fixes #23273 - - - - - 7012ec2f by tocic at 2023-04-20T11:01:42-04:00 Fix doc typo in GHC.Read.readList - - - - - 5c873124 by sheaf at 2023-04-20T18:33:34-04:00 Implement -jsem: parallelism controlled by semaphores See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a complete description for the motivation for this feature. The `-jsem` option allows a build tool to pass a semaphore to GHC which GHC can use in order to control how much parallelism it requests. GHC itself acts as a client in the GHC jobserver protocol. ``` GHC Jobserver Protocol ~~~~~~~~~~~~~~~~~~~~~~ This proposal introduces the GHC Jobserver Protocol. This protocol allows a server to dynamically invoke many instances of a client process, while restricting all of those instances to use no more than <n> capabilities. This is achieved by coordination over a system semaphore (either a POSIX semaphore [6]_ in the case of Linux and Darwin, or a Win32 semaphore [7]_ in the case of Windows platforms). There are two kinds of participants in the GHC Jobserver protocol: - The *jobserver* creates a system semaphore with a certain number of available tokens. Each time the jobserver wants to spawn a new jobclient subprocess, it **must** first acquire a single token from the semaphore, before spawning the subprocess. This token **must** be released once the subprocess terminates. Once work is finished, the jobserver **must** destroy the semaphore it created. - A *jobclient* is a subprocess spawned by the jobserver or another jobclient. Each jobclient starts with one available token (its *implicit token*, which was acquired by the parent which spawned it), and can request more tokens through the Jobserver Protocol by waiting on the semaphore. Each time a jobclient wants to spawn a new jobclient subprocess, it **must** pass on a single token to the child jobclient. This token can either be the jobclient's implicit token, or another token which the jobclient acquired from the semaphore. Each jobclient **must** release exactly as many tokens as it has acquired from the semaphore (this does not include the implicit tokens). ``` Build tools such as cabal act as jobservers in the protocol and are responsibile for correctly creating, cleaning up and managing the semaphore. Adds a new submodule (semaphore-compat) for managing and interacting with semaphores in a cross-platform way. Fixes #19349 - - - - - 52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00 rts: Initialize Array# header in listThreads# Previously the implementation of listThreads# failed to initialize the header of the created array, leading to various nastiness. Fixes #23071 - - - - - 1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00 testsuite: Add test for #23071 - - - - - dae514f9 by tocic at 2023-04-21T13:31:21-04:00 Fix doc typos in libraries/base/GHC - - - - - 113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00 Testsuite: replace some js_broken/js_skip predicates with req_c Using req_c is more precise. - - - - - 038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00 Minor doc fixes - Add docs/index.html to .gitignore. It is created by ./hadrian/build docs, and it was the only file in Hadrian's templateRules not present in .gitignore. - Mention that MultiWayIf supports non-boolean guards - Remove documentation of optdll - removed in 2007, 763daed95 - Fix markdown syntax - - - - - e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00 User's guide: DeepSubsumption is implied by Haskell{98,2010} - - - - - 499a1c20 by PHO at 2023-04-23T13:39:32-04:00 Implement executablePath for Solaris and make getBaseDir less platform-dependent Use base-4.17 executablePath when possible, and fall back on getExecutablePath when it's not available. The sole reason why getBaseDir had #ifdef's was apparently that getExecutablePath wasn't reliable, and we could reduce the number of CPP conditionals by making use of executablePath instead. Also export executablePath on js_HOST_ARCH. - - - - - 97a6f7bc by tocic at 2023-04-23T13:40:08-04:00 Fix doc typos in libraries/base - - - - - 787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00 testsuite/T20137: Avoid impl.-defined behavior Previously we would cast pointers to uint64_t. However, implementations are allowed to either zero- or sign-extend such casts. Instead cast to uintptr_t to avoid this. Fixes #23247. - - - - - 87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00 rts: always build 64-bit atomic ops This patch does a few things: - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit platforms - Remove legacy "64bit" cabal flag of rts package - Fix hs_xchg64 function prototype for 32-bit platforms - Fix AtomicFetch test for wasm32 - - - - - 2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00 compiler: don't install signal handlers when the host platform doesn't have signals Previously, large parts of GHC API will transitively invoke withSignalHandlers, which doesn't work on host platforms without signal functionality at all (e.g. wasm32-wasi). By making withSignalHandlers a no-op on those platforms, we can make more parts of GHC API work out of the box when signals aren't supported. - - - - - 1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00 hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC - - - - - 1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00 Add since pragma to Data.Functor.unzip - - - - - 0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00 More informative errors for bad imports (#21826) - - - - - ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00 JS/base: provide implementation for mkdir (issue 22374) - - - - - 8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00 JS: Fix h$base_access implementation (issue 22576) - - - - - 74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00 Give more guarntees about ImplicitParams (#23289) - Added new section in the GHC user's guide that legends behavior of nested implicit parameter bindings in these two cases: let ?f = 1 in let ?f = 2 in ?f and data T where MkT :: (?f :: Int) => T f :: T -> T -> Int f MkT MkT = ?f - Added new test case to examine this behavior. - - - - - c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00 DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208. - - - - - 77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00 Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364) Carry the actual type of an expression through the PreStgRhs and into GenStgRhs for use in later stages. Currently this is used in the JavaScript backend to fix some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2, T13822, T14749. - - - - - 052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00 EPA: Use ExplicitBraces only in HsModule !9018 brought in exact print annotations in LayoutInfo for open and close braces at the top level. But it retained them in the HsModule annotations too. Remove the originals, so exact printing uses LayoutInfo - - - - - d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: update ci.sh to actually run the entire testsuite for wasm backend For the time being, we still need to use in-tree mode and can't test the bindist yet. - - - - - 533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00 ci: additional wasm32 manual jobs in validate pipelines This patch enables bignum native & unregisterised wasm32 jobs as manual jobs in validate pipelines, which can be useful to prevent breakage when working on wasm32 related patches. - - - - - b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix cross prefix stripping This patch fixes cross prefix stripping in the testsuite driver. The normalization logic used to only handle prefixes of the triple form <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens in the prefix tuple, so the cross prefix stripping logic would work when ghc is configured with something like --target=wasm32-wasi. - - - - - 6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: include target exe extension in heap profile filenames This patch fixes hp2ps related framework failures when testing the wasm backend by including target exe extension in heap profile filenames. - - - - - e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: exclude ghci ways if no rts linker is present This patch implements logic to automatically exclude ghci ways when there is no rts linker. It's way better than having to annotate individual test cases. - - - - - 791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: fix permission bits in copy_files When the testsuite driver copy files instead of symlinking them, it should also copy the permission bits, otherwise there'll be permission denied errors. Also, enforce file copying when testing wasm32, since wasmtime doesn't handle host symlinks quite well (https://github.com/bytecodealliance/wasmtime/issues/6227). - - - - - aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_ghc_with_threaded_rts predicate This patch adds the req_ghc_with_threaded_rts predicate to the testsuite to assert the platform has threaded RTS, and mark some tests as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a config field instead of a global variable. - - - - - ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_process predicate This patch adds the req_process predicate to the testsuite to assert the platform has a process model, also marking tests that involve spawning processes as req_process. Also bumps hpc & process submodule. - - - - - cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add the req_host_target_ghc predicate This patch adds the req_host_target_ghc predicate to the testsuite to assert the ghc compiler being tested can compile both host/target code. When testing cross GHCs this is not supported yet, but it may change in the future. - - - - - b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: add missing annotations for some tests This patch adds missing annotations (req_th, req_dynamic_lib_support, req_rts_linker) to some tests. They were discovered when testing wasm32, though it's better to be explicit about what features they require, rather than simply adding when(arch('wasm32'), skip). - - - - - bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00 testsuite: wasm32-specific fixes This patch includes all wasm32-specific testsuite fixes. - - - - - 4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00 JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304) - - - - - 57277662 by sheaf at 2023-04-29T20:23:06+02:00 Add the Unsatisfiable class This commit implements GHC proposal #433, adding the Unsatisfiable class to the GHC.TypeError module. This provides an alternative to TypeError for which error reporting is more predictable: we report it when we are reporting unsolved Wanted constraints. Fixes #14983 #16249 #16906 #18310 #20835 - - - - - 00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00 Add structured error messages for GHC.Rename.Names Tracking ticket: #20115 MR: !10336 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00 Add sized primitive literal syntax Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining unboxed numeric literals such as `0xFF#Word8 :: Word8#`. Implements GHC proposal 0451: https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst Fixes #21422. Bumps haddock submodule. Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00 Document instances of Double - - - - - 1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00 Bump Cabal submodule (#22356) - - - - - 4eafb52a by sheaf at 2023-05-03T20:18:16-04:00 Don't forget to check the parent in an export list Commit 3f374399 introduced a bug which caused us to forget to include the parent of an export item of the form T(..) (that is, IEThingAll) when checking for duplicate exports. Fixes #23318 - - - - - 8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00 Fix unlit path in cross bindists - - - - - 8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00 hadrian: Flavour: Change args -> extraArgs Previously in a flavour definition you could override all the flags which were passed to GHC. This causes issues when needed to compute a package hash because we need to know what these extra arguments are going to be before computing the hash. The solution is to modify flavour so that the arguments you pass here are just extra ones rather than all the arguments that you need to compile something. This makes things work more like how cabal.project files work when you give extra arguments to a package and also means that flavour transformers correctly affect the hash. - - - - - 3fdb18f8 by romes at 2023-05-04T14:58:14-04:00 Hardwire a better unit-id for ghc Previously, the unit-id of ghc-the-library was fixed as `ghc`. This was done primarily because the compiler must know the unit-id of some packages (including ghc) a-priori to define wired-in names. However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed to `ghc` might result in subtle bugs when different ghc's interact. A good example of this is having GHC_A load a plugin compiled by GHC_B, where GHC_A and GHC_B are linked to ghc-libraries that are ABI incompatible. Without a distinction between the unit-id of the ghc library GHC_A is linked against and the ghc library the plugin it is loading was compiled against, we can't check compatibility. This patch gives a slightly better unit-id to ghc (ghc-version) by (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0) (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id. (2.1) `GHC.Settings.Config` is generated by Hadrian (2.2) and also by cabal through `compiler/Setup.hs` This unit-id definition is imported by `GHC.Unit.Types` and used to set the wired-in unit-id of "ghc", which was previously fixed to "ghc" The commits following this one will improve the unit-id with a cabal-style package hash and check compatibility when loading plugins. Note that we also ensure that ghc's unit key matches unit id both when hadrian or cabal builds ghc, and in this way we no longer need to add `ghc` to the WiringMap. - - - - - 6689c9c6 by romes at 2023-05-04T14:58:14-04:00 Validate compatibility of ghcs when loading plugins Ensure, when loading plugins, that the ghc the plugin depends on is the ghc loading the plugin -- otherwise fail to load the plugin. Progress towards #20742. - - - - - db4be339 by romes at 2023-05-04T14:58:14-04:00 Add hashes to unit-ids created by hadrian This commit adds support for computing an inputs hash for packages compiled by hadrian. The result is that ABI incompatible packages should be given different hashes and therefore be distinct in a cabal store. Hashing is enabled by the `--flag`, and is off by default as the hash contains a hash of the source files. We enable it when we produce release builds so that the artifacts we distribute have the right unit ids. - - - - - 944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00 Use hash-unit-ids in release jobs Includes fix upload_ghc_libs glob - - - - - 116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00 JS: fix bounds checking (Issue 23123) * For ByteArray-based bounds-checking, the JavaScript backend must use the `len` field, instead of the inbuild JavaScript `length` field. * Range-based operations must also check both the start and end of the range for bounds * All indicies are valid for ranges of size zero, since they are essentially no-ops * For cases of ByteArray accesses (e.g. read as Int), the end index is (i * sizeof(type) + sizeof(type) - 1), while the previous implementation uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3) * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike the previous point), but now check both start and end indicies * Byte array copies now check if the arrays are the same by identity and then if the ranges overlap. - - - - - 2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00 Fix remaining issues with bound checking (#23123) While fixing these I've also changed the way we store addresses into ByteArray#. Addr# are composed of two parts: a JavaScript array and an offset (32-bit number). Suppose we want to store an Addr# in a ByteArray# foo at offset i. Before this patch, we were storing both fields as a tuple in the "arr" array field: foo.arr[i] = [addr_arr, addr_offset]; Now we only store the array part in the "arr" field and the offset directly in the array: foo.dv.setInt32(i, addr_offset): foo.arr[i] = addr_arr; It avoids wasting space for the tuple. - - - - - 98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00 JavaScript: Correct arguments to h$appendToHsStringA fixes #23278 - - - - - ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00 base/encoding: add an allocations performance test (#22946) - - - - - e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00 linear types: Don't add external names to the usage env This has no observable effect, but avoids storing useless data. - - - - - b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00 Improved documentation for the Data.OldList.nub function There was recomentation to use map head . group . sort instead of nub function, but containers library has more suitable and efficient analogue - - - - - e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00 Fix type variable substitution in gen_Newtype_fam_insts Previously, `gen_Newtype_fam_insts` was substituting the type variable binders of a type family instance using `substTyVars`, which failed to take type variable dependencies into account. There is similar code in `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly, so this patch: 1. Factors out this code into a top-level `substATBndrs` function, and 2. Uses `substATBndrs` in `gen_Newtype_fam_insts`. Fixes #23329. - - - - - 275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00 Add structured error messages for GHC.Rename.Utils Tracking ticket: #20115 MR: !10350 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00 Use TemplateHaskellQuotes in TH.Syntax to construct Names - - - - - a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00 driver: Use hooks from plugin_hsc_env This fixes a bug in oneshot mode where hooks modified in a plugin wouldn't be used in oneshot mode because we neglected to use the right hsc_env. This was observed by @csabahruska. - - - - - 18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00 Rework plugin initialisation points In general this patch pushes plugin initialisation points to earlier in the pipeline. As plugins can modify the `HscEnv`, it's imperative that the plugins are initialised as soon as possible and used thereafter. For example, there are some new tests which modify hsc_logger and other hooks which failed to fire before (and now do) One consequence of this change is that the error for specifying the usage of a HPT plugin from the command line has changed, because it's now attempted to be loaded at initialisation rather than causing a cyclic module import. Closes #21279 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00 docs: Add Note [Timing of plugin initialization] - - - - - e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00 Incrementally update ghcup metadata in ghc/ghcup-metadata This job paves the way for distributing nightly builds * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the metadata on the "updates" branch. * Each night this metadata is downloaded and the nightly builds are appended to the end of the metadata. * The update job only runs on the scheduled nightly pipeline, not just when NIGHTLY=1. Things which are not done yet * Modify the retention policy for nightly jobs * Think about building release flavour compilers to distribute nightly. Fixes #23334 - - - - - 8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00 docs: Remove mentions of ArrayArray# from unlifted FFI section Fixes #23277 - - - - - 994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00 Add structured error messages for GHC.Rename.Module Tracking ticket: #20115 MR: !10361 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. Only addresses the single warning missing from the previous MR. - - - - - 3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00 rts: Fix data-race in hs_init_ghc As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic increment/decrement on the RTS's initialization count. This may go wrong in a multithreaded program which initializes the runtime multiple times. Closes #22756. - - - - - 78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00 Add structured error messages for GHC.IfaceToCore Tracking ticket: #20114 MR: !10390 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. - - - - - 0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00 Fix up rules for ghcup-metadata-nightly-push - - - - - b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00 testsuite: Add test for atomicSwapIORef - - - - - 81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00 compiler: Implement atomicSwapIORef with xchg As requested by @treeowl in CLC#139. - - - - - 6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00 Make atomicSwapMutVar# an inline primop - - - - - 64064cfe by doyougnu at 2023-05-09T18:40:01-04:00 JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt This MR changes some simple optimizations and is a first step in re-architecting the JS backend pipeline to add the optimizer. In particular it: - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module - adds module `GHC.JS.Optimizer` - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations - hooks the optimizer into code gen - adds FuncStat and ForStat constructors to the backend. Working Ticket: - #22736 Related MRs: - MR !10142 - MR !10000 ------------------------- Metric Decrease: CoOpt_Read ManyAlternatives PmSeriesS PmSeriesT PmSeriesV T10421 T12707 T13253 T13253-spj T15164 T17516 T18140 T18282 T18698a T18698b T18923 T1969 T19695 T20049 T3064 T5321FD T5321Fun T783 T9198 T9233 T9630 ------------------------- - - - - - 6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00 Add a regression test for #21050 - - - - - b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00 nonmoving: Account for mutator allocations in bytes_allocated Previously we failed to account direct mutator allocations into the nonmoving heap against the mutator's allocation limit and `cap->total_allocated`. This only manifests during CAF evaluation (since we allocate the CAF's blackhole directly into the nonmoving heap). Fixes #23312. - - - - - 0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00 Adjust AArch64 stackFrameHeaderSize The prologue of each stack frame are the saved LR and FP registers, 8 byte each. I.e. the size of the stack frame header is 2 * 8 byte. - - - - - 7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00 Make `(&)` representation polymorphic in the return type - - - - - b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00 ghc-prim: Generalize keepAlive#/touch# in state token type Closes #23163. - - - - - 1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00 Bump hsc2hs submodule Fixes #22981. - - - - - 0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00 base: Export GHC.Conc.Sync.fromThreadId Closes #22706. - - - - - 29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00 Build vanilla alpine bindists We currently attempt to build and distribute fully static alpine bindists (ones which could be used on any linux platform) but most people who use the alpine bindists want to use alpine to build their own static applications (for which a fully static bindist is not necessary). We should build and distribute these bindists for these users whilst the fully-static bindist is still unusable. Fixes #23349 - - - - - 40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00 Look both ways when looking for quantified equalities When looking up (t1 ~# t2) in the quantified constraints, check both orientations. Forgetting this led to #23333. - - - - - c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00 Move "target has RTS linker" out of settings We move the "target has RTS linker" information out of configure into a predicate in GHC, and remove this option from the settings file where it is unnecessary -- it's information statically known from the platform. Note that previously we would consider `powerpc`s and `s390x`s other than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker, but the RTS linker supports neither platform. Closes #23361 - - - - - bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00 Add a test for #17284 Since !10123 we now reject this program. - - - - - 630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00 Document unlawfulness of instance Num Fixed Fixes #22712 - - - - - 87eebf98 by sheaf at 2023-05-11T11:55:22-04:00 Add fused multiply-add instructions This patch adds eight new primops that fuse a multiplication and an addition or subtraction: - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#` fmadd x y z is x * y + z, computed with a single rounding step. This patch implements code generation for these primops in the following backends: - X86, AArch64 and PowerPC NCG, - LLVM - C WASM uses the C implementation. The primops are unsupported in the JavaScript backend. The following constant folding rules are also provided: - compute a * b + c when a, b, c are all literals, - x * y + 0 ==> x * y, - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x. NB: the constant folding rules incorrectly handle signed zero. This is a known limitation with GHC's floating-point constant folding rules (#21227), which we hope to resolve in the future. - - - - - ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00 Add a test for #21278 - - - - - 05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00 rts: Refine memory retention behaviour to account for pinned/compacted objects When using the copying collector there is still a lot of data which isn't copied (such as pinned, compacted, large objects etc). The logic to decide how much memory to retain didn't take into account that these wouldn't be copied. Therefore we pessimistically retained 2* the amount of memory for these blocks even though they wouldn't be copied by the collector. The solution is to split up the heap into two parts, the parts which will be copied and the parts which won't be copied. Then the appropiate factor is applied to each part individually (2 * for copying and 1.2 * for not copying). The T23221 test demonstrates this improvement with a program which first allocates many unpinned ByteArray# followed by many pinned ByteArray# and observes the difference in the ultimate memory baseline between the two. There are some charts on #23221. Fixes #23221 - - - - - 1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00 hadrian: fix no_dynamic_libs flavour transformer This patch fixes the no_dynamic_libs flavour transformer and make fully_static reuse it. Previously building with no_dynamic_libs fails since ghc program is still dynamic and transitively brings in dyn ways of rts which are produced by no rules. - - - - - 0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00 JS: refactor jsSaturate to return a saturated JStat (#23328) - - - - - a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00 Doc: Fix out-of-sync using-optimisation page - Make explicit that default flag values correspond to their -O0 value. - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction, -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper. - - - - - c176ad18 by sheaf at 2023-05-12T06:10:57-04:00 Don't panic in mkNewTyConRhs This function could come across invalid newtype constructors, as we only perform validity checking of newtypes once we are outside the knot-tied typechecking loop. This patch changes this function to fake up a stub type in the case of an invalid newtype, instead of panicking. This patch also changes "checkNewDataCon" so that it reports as many errors as possible at once. Fixes #23308 - - - - - ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00 Allow Core optimizations when interpreting bytecode Tracking ticket: #23056 MR: !10399 This adds the flag `-funoptimized-core-for-interpreter`, permitting use of the `-O` flag to enable optimizations when compiling with the interpreter backend, like in ghci. - - - - - c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00 hadrian: Fix mention of non-existent removeFiles function Previously Hadrian's bindist Makefile referred to a `removeFiles` function that was previously defined by the `make` build system. Since the `make` build system is no longer around, this function is now undefined. Naturally, make being make, this appears to be silently ignored instead of producing an error. Fix this by rewriting it to `rm -f`. Closes #23373. - - - - - eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00 Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog - - - - - aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Ensure non-moving gc is not running when pausing - - - - - 5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00 rts: Teach listAllBlocks about nonmoving heap List all blocks on the non-moving heap. Resolves #22627 - - - - - d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00 Fix coercion optimisation for SelCo (#23362) setNominalRole_maybe is supposed to output a nominal coercion. In the SelCo case, it was not updating the stored role to Nominal, causing #23362. - - - - - 59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00 hadrian: Fix linker script flag for MergeObjects builder This fixes what appears to have been a typo in !9530. The `-t` flag just enables tracing on all versions of `ld` I’ve looked at, while `-T` is used to specify a linker script. It seems that this worked anyway for some reason on some `ld` implementations (perhaps because they automatically detect linker scripts), but the missing `-T` argument causes `gold` to complain. - - - - - 4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00 Less coercion optimization for non-newtype axioms See Note [Push transitivity inside newtype axioms only] for an explanation of the change here. This change substantially improves the performance of coercion optimization for programs involving transitive type family reductions. ------------------------- Metric Decrease: CoOpt_Singletons LargeRecord T12227 T12545 T13386 T15703 T5030 T8095 ------------------------- - - - - - dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00 Move checkAxInstCo to GHC.Core.Lint A consequence of the previous change is that checkAxInstCo is no longer called during coercion optimization, so it can be moved back where it belongs. Also includes some edits to Note [Conflict checking with AxiomInstCo] as suggested by @simonpj. - - - - - 8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00 Use the eager unifier in the constraint solver This patch continues the refactoring of the constraint solver described in #23070. The Big Deal in this patch is to call the regular, eager unifier from the constraint solver, when we want to create new equalities. This replaces the existing, unifyWanted which amounted to yet-another-unifier, so it reduces duplication of a rather subtle piece of technology. See * Note [The eager unifier] in GHC.Tc.Utils.Unify * GHC.Tc.Solver.Monad.wrapUnifierTcS I did lots of other refactoring along the way * I simplified the treatment of right hand sides that contain CoercionHoles. Now, a constraint that contains a hetero-kind CoercionHole is non-canonical, and cannot be used for rewriting or unification alike. This required me to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in GHC.Tc.Solver.Equality. * I refactored the StopOrContinue type to add StartAgain, so that after a fundep improvement (for example) we can simply start the pipeline again. * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions. With Richard I concluded that they are never needed. * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities. Quite a few error messages change, I think always for the better. Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836 Metric Decrease: T17836 T18223 - - - - - 5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00 Cleanup of dynflags override in export renaming The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean. - - - - - d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00 Use a uniform return convention in bytecode for unary results fixes #22958 - - - - - 8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00 Add more instances for Compose: Enum, Bounded, Num, Real, Integral See https://github.com/haskell/core-libraries-committee/issues/160 for discussion - - - - - 902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00 Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the table, failing to unpack arguments that are perfectly unpackable. The fix is pretty easy; see Note [Recursive unboxing] - - - - - a5451438 by sheaf at 2023-05-13T14:59:13-04:00 Fix bad multiplicity role in tyConAppFunCo_maybe The function tyConAppFunCo_maybe produces a multiplicity coercion for the multiplicity argument of the function arrow, except that it could be at the wrong role if asked to produce a representational coercion. We fix this by using the 'funRole' function, which computes the right roles for arguments to the function arrow TyCon. Fixes #23386 - - - - - 5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00 Turn "ambiguous import" error into a panic This error should never occur, as a lookup of a type or data constructor should never be ambiguous. This is because a single module cannot export multiple Names with the same OccName, as per item (1) of Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export. This code path was intended to handle duplicate record fields, but the rest of the code had since been refactored to handle those in a different way. We also remove the AmbiguousImport constructor of IELookupError, as it is no longer used. Fixes #23302 - - - - - e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00 Unbreak some tests with latest GNU grep, which now warns about stray '\'. Confusingly, the testsuite mangled the error to say "stray /". We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex. Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default). - - - - - 5ae81842 by sheaf at 2023-05-15T14:49:17-04:00 Improve "ambiguous occurrence" error messages This error was sometimes a bit confusing, especially when data families were involved. This commit improves the general presentation of the "ambiguous occurrence" error, and adds a bit of extra context in the case of data families. Fixes #23301 - - - - - 2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00 Fix GHCJS OS platform (fix #23346) - - - - - 86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00 Split DynFlags structure into own module This will allow to make command line parsing to depend on diagnostic system (which depends on dynflags) - - - - - fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00 Replace the implementation of CodeBuffers with unboxed types - - - - - 21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00 Use unboxed codebuffers in base Metric Decrease: encodingAllocations - - - - - 18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Weak pointer cleanups Various stylistic cleanups. No functional changes. - - - - - c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't force debug output to stderr Previously `+RTS -Dw -l` would emit debug output to the eventlog while `+RTS -l -Dw` would emit it to stderr. This was because the parser for `-D` would unconditionally override the debug output target. Now we instead only do so if no it is currently `TRACE_NONE`. - - - - - a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Forcibly flush eventlog on barf Previously we would attempt to flush via `endEventLogging` which can easily deadlock, e.g., if `barf` fails during GC. Using `flushEventLog` directly may result in slightly less consistent eventlog output (since we don't take all capabilities before flushing) but avoids deadlocking. - - - - - 73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Assert that pointers aren't cleared by -DZ This turns many segmentation faults into much easier-to-debug assertion failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns produced by `+RTS -DZ` clearing as invalid pointers. This is a bit ad-hoc but this is the debug runtime. - - - - - 37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Introduce printGlobalThreads - - - - - 451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00 rts: Don't sanity-check StgTSO.global_link See Note [Avoid dangling global_link pointers]. Fixes #19146. - - - - - d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00 Split up tyThingToIfaceDecl from GHC.Iface.Make This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl from GHC.Iface.Make into GHC.Iface.Decl. This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl, transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad. - - - - - 4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00 Migrate errors to diagnostics in GHC.Tc.Module This commit migrates the errors in GHC.Tc.Module to use the new diagnostic infrastructure. It required a significant overhaul of the compatibility checks between an hs-boot or signature module and its implementation; we now use a Writer monad to accumulate errors; see the BootMismatch datatype in GHC.Tc.Errors.Types, with its panoply of subtypes. For the sake of readability, several local functions inside the 'checkBootTyCon' function were split off into top-level functions. We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file" datatype, as this mirrors the logic in several other places where we want to treat hs-boot and hsig files in a similar fashion. This commit also refactors the Backpack checks for type synonyms implementing abstract data, to correctly reject implementations that contain qualified or quantified types (this fixes #23342 and #23344). - - - - - d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00 configure: Drop unused AC_PROG_CPP In configure, we were calling `AC_PROG_CPP` but never making use of the $CPP variable it sets or reads. The issue is $CPP will show up in the --help output of configure, falsely advertising a configuration option that does nothing. The reason we don't use the $CPP variable is because HS_CPP_CMD is expected to be a single command (without flags), but AC_PROG_CPP, when CPP is unset, will set said variable to something like `/usr/bin/gcc -E`. Instead, we configure HS_CPP_CMD through $CC. - - - - - a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00 rts: fix --disable-large-address-space This patch moves ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from Storage.h to HeapAlloc.h. When --disable-large-address-space is passed to configure, the code in HeapAlloc.h makes use of these two macros. Fixes #23385. - - - - - bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00 Add -Wmissing-role-annotations Implements #22702 - - - - - 41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00 base: Export {get,set}ExceptionFinalizer from System.Mem.Weak As proposed in CLC Proposal #126 [1]. [1]: https://github.com/haskell/core-libraries-committee/issues/126 - - - - - 67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00 base: Introduce printToHandleFinalizerExceptionHandler - - - - - 5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00 JS: Implement h$clock_gettime in the JavaScript RTS (#23360) - - - - - 90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for SourceText SourceText is serialized along with INLINE pragmas into interface files. Many of these SourceTexts are identical, for example "{-# INLINE#". When deserialized, each such SourceText was previously expanded out into a [Char], which is highly wasteful of memory, and each such instance of the text would allocate an independent list with its contents as deserializing breaks any sharing that might have existed. Instead, we use a `FastString` to represent these, so that each instance unique text will be interned and stored in a memory efficient manner. - - - - - b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation/FastStrings for `SourceNote`s `SourceNote`s should not be stored as [Char] as this is highly wasteful and in certain scenarios can be highly duplicated. Metric Decrease: hard_hole_fits - - - - - 6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00 compiler: Use compact representation for UsageFile (#22744) Use FastString to store filepaths in interface files, as this data is highly redundant so we want to share all instances of filepaths in the compiler session. - - - - - 47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00 testsuite: add test for T22744 This test checks for #22744 by compiling 100 modules which each have a dependency on 1000 distinct external files. Previously, when loading these interfaces from disk, each individual instance of a filepath in the interface will would be allocated as an individual object on the heap, meaning we have heap objects for 100*1000 files, when there are only 1000 distinct files we care about. This test checks this by first compiling the module normally, then measuring the peak memory usage in a no-op recompile, as the recompilation checking will force the allocation of all these filepaths. - - - - - 0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00 users guide: Add glossary Currently this merely explains the meaning of "technology preview" in the context of released features. - - - - - 0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00 Update glossary.rst - - - - - 3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00 Use glossary directive - - - - - 2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00 JS: fix getpid (fix #23399) - - - - - 5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00 Use setSrcSpan rather than setLclEnv in solveForAll In subsequent MRs (#23409) we want to remove the TcLclEnv argument from a CtLoc. This MR prepares us for that by removing the one place where the entire TcLclEnv is used, by using it more precisely to just set the contexts source location. Fixes #23390 - - - - - 385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00 Update the users guide paragraph on -O in GHCi In relation to #23056 - - - - - 87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Add test for #13660 - - - - - 9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Move implementation of GHC.Foreign to GHC.Internal - - - - - 174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Introduce {new,with}CStringLen0 These are useful helpers for implementing the internal-NUL code unit check needed to fix #13660. - - - - - a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Clean up documentation - - - - - b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00 base: Ensure that FilePaths don't contain NULs POSIX filepaths may not contain the NUL octet but previously we did not reject such paths. This could be exploited by untrusted input to cause discrepancies between various `FilePath` queries and the opened filename. For instance, `readFile "hello.so\x00.txt"` would open the file `"hello.so"` yet `takeFileExtension` would return `".txt"`. The same argument applies to Windows FilePaths Fixes #13660. - - - - - 7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00 Allow the demand analyser to unpack tuple and equality dictionaries Addresses #23398. The demand analyser usually does not unpack class dictionaries: see Note [Do not unbox class dictionaries] in GHC.Core.Opt.DmdAnal. This patch makes an exception for tuple dictionaries and equality dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of the above Note. Compile times fall by 0.1% for some reason (max 0.7% on T18698b). - - - - - b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00 Use a simpler and more portable construct in ld.ldd check printf '%q\n' is a bash extension which led to incorrectly failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh - - - - - dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00 Update the warning about interpreter optimizations to reflect that they're not incompatible anymore, but guarded by a flag - - - - - 4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00 Remove stray dump flags in GHC.Rename.Names - - - - - 4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00 Make Warn = Located DriverMessage This change makes command line argument parsing use diagnostic framework for producing warnings. - - - - - 525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00 Type inference for data family newtype instances This patch addresses #23408, a tricky case with data family newtype instances. Consider type family TF a where TF Char = Bool data family DF a newtype instance DF Bool = MkDF Int and [W] Int ~R# DF (TF a), with a Given (a ~# Char). We must fully rewrite the Wanted so the tpye family can fire; that wasn't happening. - - - - - c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00 testsuite: fix predicate on rdynamic test Test rdynamic requires dynamic linking support, which is orthogonal to RTS linker support. Change the predicate accordingly. Fixes #23316 - - - - - 735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00 docs: Use ghc-ticket directive where appropiate in users guide Using the directive automatically formats and links the ticket appropiately. - - - - - b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00 NCG: remove useless .align directive (#20758) - - - - - 15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00 Add test for #23156 This program had exponential typechecking time in GHC 9.4 and 9.6 - - - - - 2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00 Revert "Change hostSupportsRPaths to report False on OpenBSD" This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2. - - - - - 882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00 Disable T17414 on OpenBSD Like on other systems it's not guaranteed that there's sufficient space in /tmp to write 2G out. - - - - - 9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00 Bring back getExecutablePath to getBaseDir on OpenBSD Fix #18173 - - - - - 9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00 Add an error origin for impedance matching (#23427) - - - - - 33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00 testsuite: Add tests for #23146 Both lifted and unlifted variants. - - - - - 76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Fix some Haddocks - - - - - 33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00 codeGen: Give proper LFInfo to datacon wrappers As noted in `Note [Conveying CAF-info and LFInfo between modules]`, when importing a binding from another module we must ensure that it gets the appropriate `LambdaFormInfo` if it is in WHNF to ensure that references to it are tagged correctly. However, the implementation responsible for doing this, `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and not wrappers. This lead to the crash of this program in #23146: module B where type NP :: [UnliftedType] -> UnliftedType data NP xs where UNil :: NP '[] module A where import B fieldsSam :: NP xs -> NP xs -> Bool fieldsSam UNil UNil = True x = fieldsSam UNil UNil Due to its GADT nature, `UNil` produces a trivial wrapper $WUNil :: NP '[] $WUNil = UNil @'[] @~(<co:1>) which is referenced in the RHS of `A.x`. Due to the above-mentioned bug in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were not tagged. This is problematic as `fieldsSam` expected its arguments to be tagged as they are unlifted. The fix is straightforward: extend the logic in `mkLFImported` to cover (nullary) datacon wrappers as well as workers. This is safe because we know that the wrapper of a nullary datacon will be in WHNF, even if it includes equalities evidence (since such equalities are not runtime relevant). Thanks to @MangoIV for the great ticket and @alt-romes for his minimization and help debugging. Fixes #23146. - - - - - 2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 codeGen: Fix LFInfo of imported datacon wrappers As noted in #23231 and in the previous commit, we were failing to give a an LFInfo of LFCon to a nullary datacon wrapper from another module, failing to properly tag pointers which ultimately led to the segmentation fault in #23146. On top of the previous commit which now considers wrappers where we previously only considered workers, we change the order of the guards so that we check for the arity of the binding before we check whether it is a constructor. This allows us to (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was nullary, which we previously would fail to do (2) Remove the `isNullaryRepDataCon` predicate: (a) which was previously wrong, since it considered wrappers whose workers had zero-width arguments to be non-nullary and would fail to give `LFCon` to them (b) is now unnecessary, since arity == 0 guarantees - that the worker takes no arguments at all - and the wrapper takes no arguments and its RHS must be an application of the worker to zero-width-args only. - we lint these two items with an assertion that the datacon `hasNoNonZeroWidthArgs` We also update `isTagged` to use the new logic in determining the LFInfos of imported Ids. The creation of LFInfos for imported Ids and this detail are explained in Note [The LFInfo of Imported Ids]. Note that before the patch to those issues we would already consider these nullary wrappers to have `LFCon` lambda form info; but failed to re-construct that information in `mkLFImported` Closes #23231, #23146 (I've additionally batched some fixes to documentation I found while investigating this issue) - - - - - 0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Make LFInfos for DataCons on construction As a result of the discussion in !10165, we decided to amend the previous commit which fixed the logic of `mkLFImported` with regard to datacon workers and wrappers. Instead of having the logic for the LFInfo of datacons be in `mkLFImported`, we now construct an LFInfo for all data constructors on GHC.Types.Id.Make and store it in the `lfInfo` field. See the new Note [LFInfo of DataCon workers and wrappers] and ammendments to Note [The LFInfo of Imported Ids] - - - - - 12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Update Note [Core letrec invariant] Authored by @simonpj - - - - - e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Rename mkLFImported to importedIdLFInfo The `mkLFImported` sounded too much like a constructor of sorts, when really it got the `LFInfo` of an imported Id from its `lf_info` field when this existed, and otherwise returned a conservative estimate of that imported Id's LFInfo. This in contrast to functions such as `mkLFReEntrant` which really are about constructing an `LFInfo`. - - - - - e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Enforce invariant on typePrimRepArgs in the types As part of the documentation effort in !10165 I came across this invariant on 'typePrimRepArgs' which is easily expressed at the type-level through a NonEmpty list. It allowed us to remove one panic. - - - - - b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00 Merge outdated Note [Data con representation] into Note [Data constructor representation] Introduce new Note [Constructor applications in STG] to better support the merge, and reference it from the relevant bits in the STG syntax. - - - - - e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Add the SolverStage monad This refactoring makes a substantial improvement in the structure of the type-checker's constraint solver: #23070. Specifically: * Introduced the SolverStage monad. See GHC.Tc.Solver.Monad Note [The SolverStage monad] * Make each solver pipeline (equalities, dictionaries, irreds etc) deal with updating the inert set, as a separate SolverStage. There is sometimes special stuff to do, and it means that each full pipeline can have type SolverStage Void, indicating that they never return anything. * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage. Much nicer. * Combined the remnants of GHC.Tc.Solver.Canonical and GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve. (Interact and Canonical are removed.) * Gave the same treatment to dictionary and irred constraints as I have already done for equality constraints: * New types (akin to EqCt): IrredCt and DictCt * Ct is now just a simple sum type data Ct = CDictCan DictCt | CIrredCan IrredCt | CEqCan EqCt | CQuantCan QCInst | CNonCanonical CtEvidence * inert_dicts can now have the better type DictMap DictCt, instead of DictMap Ct; and similarly inert_irreds. * Significantly simplified the treatment of implicit parameters. Previously we had a number of special cases * interactGivenIP, an entire function * special case in maybeKickOut * special case in findDict, when looking up dictionaries But actually it's simpler than that. When adding a new Given, implicit parameter constraint to the InertSet, we just need to kick out any existing inert constraints that mention that implicit parameter. The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with its auxiliary GHC.Core.Predicate.mentionsIP. See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict. * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit. See Note [Fast path for tcCheckHoleFit]. This is a big win in some cases: test hard_hole_fits gets nearly 40% faster (at compile time). * Add a new fast-path for solving /boxed/ equality constraints (t1 ~ t2). See Note [Solving equality classes] in GHC.Tc.Solver.Dict. This makes a big difference too: test T17836 compiles 40% faster. * Implement the PermissivePlan of #23413, which concerns what happens with insoluble Givens. Our previous treatment was wildly inconsistent as that ticket pointed out. A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply don't run the ambiguity check at all if -XAllowAmbiguousTypes is on. Smaller points: * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for insoluble /occurs/ checks, broaden in to all insouluble constraints. Just generally better. See Note [Insoluble mis-match] in that module. As noted above, compile time perf gets better. Here are the changes over 0.5% on Fedora. (The figures are slightly larger on Windows for some reason.) Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -0.9% MultiLayerModulesTH_OneShot(normal) +0.5% T11822(normal) -0.6% T12227(normal) -1.8% GOOD T12545(normal) -0.5% T13035(normal) -0.6% T15703(normal) -1.4% GOOD T16875(normal) -0.5% T17836(normal) -40.7% GOOD T17836b(normal) -12.3% GOOD T17977b(normal) -0.5% T5837(normal) -1.1% T8095(normal) -2.7% GOOD T9020(optasm) -1.1% hard_hole_fits(normal) -37.0% GOOD geo. mean -1.3% minimum -40.7% maximum +0.5% Metric Decrease: T12227 T15703 T17836 T17836b T8095 hard_hole_fits LargeRecord T9198 T13035 - - - - - 6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00 Avoid an assertion failure in abstractFloats The function GHC.Core.Opt.Simplify.Utils.abstractFloats was carelessly calling lookupIdSubst_maybe on a CoVar; but a precondition of the latter is being given an Id. In fact it's harmless to call it on a CoVar, but still, the precondition on lookupIdSubst_maybe makes sense, so I added a test for CoVars. This avoids a crash in a DEBUG compiler, but otherwise has no effect. Fixes #23426. - - - - - 838aaf4b by hainq at 2023-05-24T12:41:19-04:00 Migrate errors in GHC.Tc.Validity This patch migrates the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It adds the constructors: - TcRnSimplifiableConstraint - TcRnArityMismatch - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors and fundep coverage condition errors. - - - - - 8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00 linear lint: Add missing processing of DEFAULT In this correct program f :: a %1 -> a f x = case x of x { _DEFAULT -> x } after checking the alternative we weren't popping the case binder 'x' from the usage environment, which meant that the lambda-bound 'x' was counted twice: in the scrutinee and (incorrectly) in the alternative. In fact, we weren't checking the usage of 'x' at all. Now the code for handling _DEFAULT is similar to the one handling data constructors. Fixes #23025. - - - - - ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00 Remove outdated "Don't check hs-boot type family instances too early" note This note was introduced in 25b70a29f623 which delayed performing some consistency checks for type families. However, the change was reverted later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not removed. I found it confusing when reading to code to try and work out what special behaviour there was for hs-boot files (when in-fact there isn't any). - - - - - 44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: Define ticky macro stubs These macros have long been undefined which has meant we were missing reporting these allocations in ticky profiles. The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was missing all the RTS calls to allocate, this leads to a the overall ALLOC_RTS_tot number to be severaly underreported. Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot counters which are useful to tracking stack allocations. Fixes #23421 - - - - - b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00 rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes more sense to name it after that rather than the suffix NOCTR, whose meaning has been lost to the mists of time. - - - - - eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00 users guide: A few small mark-up fixes - - - - - a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00 configure: Fix support check for response files. In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument to printf, the writing of the arguments response file always failed. The fix is to pass the arguments after `--` so that they are treated positional arguments rather than flags to printf. Closes #23435 - - - - - f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00 [feat] add .direnv to the .gitignore file - - - - - 36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00 Add Data.List.unsnoc See https://github.com/haskell/core-libraries-committee/issues/165 for discussion - - - - - c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00 Fix crash in backpack signature merging with -ddump-rn-trace In some cases, backpack signature merging could crash in addUsedGRE when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause unavailable interfaces to be loaded. This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE when -ddump-rn-trace is enabled. Fixes #23424 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - 5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00 Add a regression test for #13981 The panic was fixed by 6998772043a7f0b. Fixes #13981. - - - - - 182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00 Add a test for #23355 It was fixed by !10061, so I'm adding it in the same group. - - - - - 1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00 Migrate errors in GHC.Rename.Splice GHC.Rename.Pat This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat to use the new diagnostic infrastructure. - - - - - 56abe494 by sheaf at 2023-05-25T12:09:55+02:00 Common up Template Haskell errors in TcRnMessage This commit commons up the various Template Haskell errors into a single constructor, TcRnTHError, of TcRnMessage. - - - - - a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00 Enable ghci tests for unboxed tuples The tests were originally skipped because ghci used not to support unboxed tuples/sums. - - - - - dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00 rts: Build ticky GHC with single-threaded RTS The threaded RTS allows you to use ticky profiling but only for the counters in the generated code. The counters used in the C portion of the RTS are disabled. Updating the counters is also racy using the threaded RTS which can lead to misleading or incorrect ticky results. Therefore we change the hadrian flavour to build using the single-threaded RTS (mainly in order to get accurate C code counter increments) Fixes #23430 - - - - - fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00 Propagate long-distance info in generated code When desugaring generated pattern matches, we skip pattern match checks. However, this ended up also discarding long-distance information, which might be needed for user-written sub-expressions. Example: ```haskell okay (GADT di) cd = let sr_field :: () sr_field = case getFooBar di of { Foo -> () } in case cd of { SomeRec _ -> SomeRec sr_field } ``` With sr_field a generated FunBind, we still want to propagate the outer long-distance information from the GADT pattern match into the checks for the user-written RHS of sr_field. Fixes #23445 - - - - - f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00 Introduce GHCiMessage to wrap GhcMessage By introducing a wrapped message type we can control how certain messages are printed in GHCi (to add extra information for example) - - - - - 58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00 Generalise UnknownDiagnostic to allow embedded diagnostics to access parent diagnostic options. * Split default diagnostic options from Diagnostic class into HasDefaultDiagnosticOpts class. * Generalise UnknownDiagnostic to allow embedded diagnostics to access options. The principle idea here is that when wrapping an error message (such as GHCMessage to make GHCiMessage) then we need to also be able to lift the configuration when overriding how messages are printed (see load' for an example). - - - - - b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00 Allow API users to wrap error messages created during 'load' This allows API users to configure how messages are rendered when they are emitted from the load function. For an example see how 'loadWithCache' is used in GHCi. - - - - - 2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00 Abstract cantFindError and turn Opt_BuildingCabal into a print-time option * cantFindError is abstracted so that the parts which mention specific things about ghc/ghci are parameters. The intention being that GHC/GHCi can specify the right values to put here but otherwise display the same error message. * The BuildingCabalPackage argument from GenericMissing is removed and turned into a print-time option. The reason for the error is not dependent on whether `-fbuilding-cabal-package` is passed, so we don't want to store that in the error message. - - - - - 34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00 error messages: Don't display ghci specific hints for missing packages Tickets like #22884 suggest that it is confusing that GHC used on the command line can suggest options which only work in GHCi. This ticket uses the error message infrastructure to override certain error messages which displayed GHCi specific information so that this information is only showed when using GHCi. The main annoyance is that we mostly want to display errors in the same way as before, but with some additional information. This means that the error rendering code has to be exported from the Iface/Errors/Ppr.hs module. I am unsure about whether the approach taken here is the best or most maintainable solution. Fixes #22884 - - - - - 05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't override existing metadata if version already exists. If a nightly pipeline runs twice for some reason for the same version then we really don't want to override an existing entry with new bindists. This could cause ABI compatability issues for users or break ghcup's caching logic. - - - - - fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Use proper API url for bindist download Previously we were using links from the web interface, but it's more robust and future-proof to use the documented links to the artifacts. https://docs.gitlab.com/ee/api/job_artifacts.html - - - - - 5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Set Nightly and LatestNightly tags The latest nightly release needs the LatestNightly tag, and all other nightly releases need the Nightly tag. Therefore when the metadata is updated we need to replace all LatestNightly with Nightly.` - - - - - 914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download nightly metadata for correct date The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata with one metadata file per year. When we update the metadata we download and update the right file for the current year. - - - - - 16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Download metadata and update for correct year something about pipeline date - - - - - 14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00 ghcup-metadata: Don't skip CI On a push we now have a CI job which updates gitlab pages with the metadata files. - - - - - 1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add --date flag to specify the release date The ghcup-metadata now has a viReleaseDay field which needs to be populated with the day of the release. - - - - - bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00 ghcup-metadata: Add dlOutput field ghcup now requires us to add this field which specifies where it should download the bindist to. See https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more discussion. - - - - - 2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00 JS: Convert rendering to use HLine instead of SDoc (#22455) - - - - - abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00 testsuite: add WasmControlFlow test This patch adds the WasmControlFlow test to test the wasm backend's relooper component. - - - - - 07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00 Factorize getLinkDeps Prepare reuse of getLinkDeps for TH implementation in the JS backend (cf #22261 and review of !9779). - - - - - fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00 Change GHC.Driver.Session import to .DynFlags Also move targetPlatform selector Plenty of GHC needs just DynFlags. Even more can be made to use .DynFlags if more selectors is migrated. This is a low hanging fruit. - - - - - 69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00 EPA: Better fix for #22919 The original fix for #22919 simply removed the ability to match up prior comments with the first declaration in the file. Restore it, but add a check that the comment is on a single line, by ensuring that it comes immediately prior to the next thing (comment or start of declaration), and that the token preceding it is not on the same line. closes #22919 - - - - - 0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00 Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214) - - - - - b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00 testsuite: Pass -kb16k -kc128k for performance tests Setting a larger stack chunk size gives a greater protection from stack thrashing (where the repeated overflow/underflow allocates a lot of stack chunks which sigificantly impact allocations). This stabilises some tests against differences cause by more things being pushed onto the stack. The performance tests are generally testing work done by the compiler, using allocation as a proxy, so removing/stabilising the allocations due to the stack gives us more stable tests which are also more sensitive to actual changes in compiler performance. The tests which increase are ones where we compile a lot of modules, and for each module we spawn a thread to compile the module in. Therefore increasing these numbers has a multiplying effect on these tests because there are many more stacks which we can increase in size. The most significant improvements though are cases such as T8095 which reduce significantly in allocations (30%). This isn't a performance improvement really but just helps stabilise the test against this threshold set by the defaults. Fixes #23439 ------------------------- Metric Decrease: InstanceMatching T14683 T8095 T9872b_defer T9872d T9961 hie002 T19695 T3064 Metric Increase: MultiLayerModules T13701 T14697 ------------------------- - - - - - 6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00 Move via-C flags into GHC These were previously hardcoded in configure (with no option for overriding them) and simply passed onto ghc through the settings file. Since configure already guarantees gcc supports those flags, we simply move them into GHC. - - - - - 981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Allow CPR on unrestricted constructors Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will allow CPR to handle `Ur`, in particular. - - - - - bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00 Push coercions across multiplicity boundaries Per the new `Note [Linting linearity]`, we want optimisations over trying to preserve linearity. This will avoid preventing inlinings and reductions and make linear programs more efficient. - - - - - d56dd695 by sheaf at 2023-05-31T11:37:12-04:00 Data.Bag: add INLINEABLE to polymorphic functions This commit allows polymorphic methods in GHC.Data.Bag to be specialised, avoiding having to pass explicit dictionaries when they are instantiated with e.g. a known monad. - - - - - 5366cd35 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcBinderStack into its own module This commit splits off TcBinderStack into its own module, to avoid module cycles: we might want to refer to it without also pulling in the TcM monad. - - - - - 09d4d307 by sheaf at 2023-05-31T11:37:12-04:00 Split off TcRef into its own module This helps avoid pull in the full TcM monad when we just want access to mutable references in the typechecker. This facilitates later patches which introduce a slimmed down TcM monad for zonking. - - - - - 88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00 Introduce Codensity monad The Codensity monad is useful to write state-passing computations in continuation-passing style, e.g. to implement a State monad as continuation-passing style over a Reader monad. - - - - - f62d8195 by sheaf at 2023-05-31T11:37:12-04:00 Restructure the zonker This commit splits up the zonker into a few separate components, described in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`. 1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`, which has enough information for zonking types. This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`, which guarantees we don't throw an error while reporting an error. 2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines two zonking monad transformers, `ZonkT` and `ZonkBndrT`. `ZonkT` is a reader monad transformer over `ZonkEnv`. `ZonkBndrT m` is the codensity monad over `ZonkT m`. `ZonkBndrT` is used for computations that accumulate binders in the `ZonkEnv`. 3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use in the typechecker. It uses the `ZonkM` monad. 4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`, which has been refactored to use `ZonkTcM = ZonkT TcM` and `ZonkBndrTcM = ZonkBndrT TcM`. Allocations slightly decrease on the whole due to using continuation-passing style instead of manual state passing of ZonkEnv in the final zonking to Type. ------------------------- Metric Decrease: T4029 T8095 T14766 T15304 hard_hole_fits RecordUpdPerf Metric Increase: T10421 ------------------------- - - - - - 70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00 Update rdt-theme to latest upstream version Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444 - - - - - f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Restructure IPE buffer layout Reference ticket #21766 This commit restructures IPE buffer list entries to not contain references to their corresponding info tables. IPE buffer list nodes now point to two lists of equal length, one holding the list of info table pointers and one holding the corresponding entries for each info table. This will allow the entry data to be compressed without losing the references to the info tables. - - - - - 5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE compression to configure Reference ticket #21766 Adds an `--enable-ipe-data-compreesion` flag to the configure script which will check for libzstd and set the appropriate flags to allow for IPE data compression in the compiler - - - - - b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00 IPE data compression Reference ticket #21766 When IPE data compression is enabled, compress the emitted IPE buffer entries and decompress them in the RTS. - - - - - 5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix libzstd detection in configure and RTS Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases and properly check that before IPE data decompression in the RTS. See ticket #21766. - - - - - 69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add note describing IPE data compression See ticket #21766 - - - - - 7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix byte order of IPE data, fix IPE tests Make sure byte order of written IPE buffer entries matches target. Make sure the IPE-related tests properly access the fields of IPE buffer entry nodes with the new IPE layout. This commit also introduces checks to avoid importing modules if IPE compression is not enabled. See ticket #21766. - - - - - 0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Fix IPE data decompression buffer allocation Capacity of buffers allocated for decompressed IPE data was incorrect due to a misuse of the `ZSTD_findFrameCompressedSize` function. Fix by always storing decompressed size of IPE data in IPE buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine the size of the compressed data. See ticket #21766 - - - - - a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add optional dependencies to ./configure output Changes the configure script to indicate whether libnuma, libzstd, or libdw are being used as dependencies due to their optional features being enabled. - - - - - 09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Add IPE-enabled builds to CI - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label - Introduces CI logic to enable IPE data compression - Enables uncompressed IPE data on debug CI job - Regenerates jobs.yaml MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the images repository is meant to ensure that the proper images have libzstd-dev installed. - - - - - 3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Update user's guide and release notes, small fixes Add mention of IPE data compression to user's guide and the release notes for 9.8.1. Also note the impact compression has on binary size in both places. Change IpeBufferListNode compression check so only the value `1` indicates compression. See ticket #21766 - - - - - 41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00 Remove IPE enabled builds from CI We don't need to explicitly specify the +ipe transformer to test IPE data since there are tests which manually enable IPE information. This commit does leave zstd IPE data compression enabled on the debian CI jobs. - - - - - 982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00 Fix build with 9.2 GHC.Tc.Zonk.Type uses an equality constraint. ghc.nix currently provides 9.2. - - - - - 1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00 Output Lint errors to stderr instead of stdout This is a continuation of 7b095b99, which fixed warnings but not errors. Refs #13342 - - - - - 8e81f140 by sheaf at 2023-06-01T10:56:51-04:00 Refactor lookupExactOrOrig & friends This refactors the panoply of renamer lookup functions relating to lookupExactOrOrig to more graciously handle Exact and Orig names. In particular, we avoid the situation in which we would add Exact/Orig GREs to the tcg_used_gres field, which could cause a panic in bestImport like in #23240. Fixes #23428 - - - - - 5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00 Use the one-shot trick for UM and RewriteM functors As described in Note [The one-shot state monad trick], we shouldn't use derived Functor instances for monads using one-shot. This was done for most of them, but UM and RewriteM were missed. - - - - - 2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00 Fix testsuite skipping Lint setTestOpts() is used to modify the test options for an entire .T file, rather than a single test. If there was a test using collect_compiler_stats, all of the tests in the same file had lint disabled. Fixes #21247 - - - - - 00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00 Add testcases for already fixed #16432 They were fixed by 40c7daed0. Fixes #16432 - - - - - f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00 cleanup: Remove unused field from SelfBoot It is no longer needed since Note [Extra dependencies from .hs-boot files] was deleted in 6998772043. I've also added tildes to Note headers, otherwise they're not detected by the linter. - - - - - 82eacab6 by sheaf at 2023-06-02T09:08:01-04:00 Delete GHC.Tc.Utils.Zonk This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType in commit f62d8195, but I forgot to delete the original module - - - - - 4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00 base: Add build-order import of GHC.Types in GHC.IO.Handle.Types For reasons similar to those described in Note [Depend on GHC.Num.Integer]. Fixes #23411. - - - - - f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00 JS: fix and enhance non-minimized code generation (#22455) Flag -ddisable-js-minimizer was producing invalid code. Fix that and also a few other things to generate nicer JS code for debugging. The added test checks that we don't regress when using the flag. - - - - - f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00 [hadrian] Fix multiline synopsis rendering - - - - - b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00 Elaborate on performance properties of Data.List.++ - - - - - 7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00 Big TcLclEnv and CtLoc refactoring The overall goal of this refactoring is to reduce the dependency footprint of the parser and syntax tree. Good reasons include: - Better module graph parallelisability - Make it easier to migrate error messages without introducing module loops - Philosophically, there's not reason for the AST to depend on half the compiler. One of the key edges which added this dependency was > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv) As this in turn depending on TcM which depends on HscEnv and so on. Therefore the goal of this patch is to move `TcLclEnv` out of `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without incurring a huge dependency chain. The changes in this patch are: * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv * Create new smaller modules for the types used in TcLclEnv New Modules: - GHC.Tc.Types.ErrCtxt - GHC.Tc.Types.BasicTypes - GHC.Tc.Types.TH - GHC.Tc.Types.LclEnv - GHC.Tc.Types.CtLocEnv - GHC.Tc.Errors.Types.PromotionErr Removed Boot File: - {-# SOURCE #-} GHC.Tc.Types * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't participate in restoreLclEnv. * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the location of the implication and constraint. By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no longer depend on the TcM monad and all that entails. Fixes #23389 #23409 - - - - - 3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session This removes the usage of DynFlags from Tc.Utils.TcType so that it no longer depends on GHC.Driver.Session. In general we don't want anything which is a dependency of Language.Haskell.Syntax to depend on GHC.Driver.Session and removing this edge gets us closer to that goal. - - - - - 18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00 Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes Language.Haskell.Syntax end up depending on GHC.Driver.Session. - - - - - 12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00 Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session - - - - - eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00 hole fit plugins: Split definition into own module The hole fit plugins are defined in terms of TcM, a type we want to avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own module we can remove this dependency. It also simplifies the necessary boot file. - - - - - 9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Move GHC.Core.Opt.CallerCC Types into separate module This allows `GHC.Driver.DynFlags` to depend on these types without depending on CoreM and hence the entire simplifier pipeline. We can also remove a hs-boot file with this change. - - - - - 52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00 Remove unecessary SOURCE import - - - - - 698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00 testsuite: Accept new output for CountDepsAst and CountDepsParser tests These are in a separate commit as the improvement to these tests is the cumulative effect of the previous set of patches rather than just the responsibility of the last one in the patchset. - - - - - 58ccf02e by sheaf at 2023-06-05T16:00:47-04:00 TTG: only allow VarBind at GhcTc The VarBind constructor of HsBind is only used at the GhcTc stage. This commit makes that explicit by setting the extension field of VarBind to be DataConCantHappen at all other stages. This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind, and remove some panics. - - - - - 54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00 Generate Addr# access ops programmatically The existing utils/genprimopcode/gen_bytearray_ops.py was relocated and extended for this purpose. Additionally, hadrian now knows about this script and uses it when generating primops.txt - - - - - ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00 ghcup-metadata: Only add Nightly tag when replacing LatestNightly Previously we were always adding the Nightly tag, but this led to all the previous builds getting an increasing number of nightly tags over time. Now we just add it once, when we remove the LatestNightly tag. - - - - - 4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00 Invisible binders in type declarations (#22560) This patch implements @k-binders introduced in GHC Proposal #425 and guarded behind the TypeAbstractions extension: type D :: forall k j. k -> j -> Type data D @k @j a b = ... ^^ ^^ To represent the new syntax, we modify LHsQTyVars as follows: - hsq_explicit :: [LHsTyVarBndr () pass] + hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass] HsBndrVis is a new data type that records the distinction between type variable binders written with and without the @ sign: data HsBndrVis pass = HsBndrRequired | HsBndrInvisible (LHsToken "@" pass) The rest of the patch updates GHC, template-haskell, and haddock to handle the new syntax. Parser: The PsErrUnexpectedTypeAppInDecl error message is removed. The syntax it used to reject is now permitted. Renamer: The @ sign does not affect the scope of a binder, so the changes to the renamer are minimal. See rnLHsTyVarBndrVisFlag. Type checker: There are three code paths that were updated to deal with the newly introduced invisible type variable binders: 1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl 2. checking CUSK: see kcCheckDeclHeader_cusk 3. inference: see kcInferDeclHeader, rejectInvisibleBinders Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv are generalized to work with HsBndrVis. Updates the haddock submodule. Metric Increase: MultiLayerModulesTH_OneShot Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00 JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481) - - - - - e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00 Update CODEOWNERS - - - - - 960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Remove IPE enabled builds from CI" This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951. - - - - - bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Update user's guide and release notes, small fixes" This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7. - - - - - 12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE-enabled builds to CI" This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f. - - - - - dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add optional dependencies to ./configure output" This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58. - - - - - 240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix IPE data decompression buffer allocation" This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a. - - - - - 9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix byte order of IPE data, fix IPE tests" This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327. - - - - - 3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add note describing IPE data compression" This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0. - - - - - fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Fix libzstd detection in configure and RTS" This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0. - - - - - 1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "IPE data compression" This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553. - - - - - fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Add IPE compression to configure" This reverts commit 5d1f2411f4becea8650d12d168e989241edee186. - - - - - 2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00 Revert "Restructure IPE buffer layout" This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91. - - - - - 2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00 Don't report redundant Givens from quantified constraints This fixes #23323 See (RC4) in Note [Tracking redundant constraints] - - - - - 567b32e1 by David Binder at 2023-06-08T18:41:29-04:00 Update the outdated instructions in HACKING.md on how to compile GHC - - - - - 2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00 Restore mingwex dependency on Windows This partially reverts some of the changes in !9475 to make `base` and `ghc-prim` depend on the `mingwex` library on Windows. It also restores the RTS's stubs for `mingwex`-specific symbols such as `_lock_file`. This is done because the C runtime provides `libmingwex` nowadays, and moreoever, not linking against `mingwex` requires downstream users to link against it explicitly in difficult-to-predict circumstances. Better to always link against `mingwex` and prevent users from having to do the guesswork themselves. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for the discussion that led to this. - - - - - 28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00 RtsSymbols.c: Remove mingwex symbol stubs As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows, which means that the RTS no longer needs to declare stubs for the `__mingw_*` family of symbols. Let's remove these stubs to avoid confusion. Fixes #23309. - - - - - 3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00 Consistently use validity checks for TH conversion of data constructors We were checking that TH-spliced data declarations do not look like this: ```hs data D :: Type = MkD Int ``` But we were only doing so for `data` declarations' data constructors, not for `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out the necessary validity checks into its own `cvtDataDefnCons` function and uses it in all of the places where it needs to be. Fixes #22559. - - - - - a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00 Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC pragma for files with module level scope. Instead of simple not deleting the files, we also need to remove them from the TmpFs so they are not deleted later on when all the other files are deleted. There are additional complications because you also need to remove the directory where these files live from the TmpFs so we don't try to delete those later either. I added two tests. 1. Tests simply that -keep-tmp-files works at all with a single module and --make mode. 2. The other tests that temporary files are deleted for other modules which don't enable -keep-tmp-files. Fixes #23339 - - - - - dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00 withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free. Ticket #23305 reports an error where we were attempting to use the logger which was created by withDeferredDiagnostics after its scope had ended. This problem would have been caught by this patch and a validate build: ``` +*** Exception: Use after free +CallStack (from HasCallStack): + error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make ``` This general issue is tracked by #20981 - - - - - 432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00 Don't return complete HscEnv from upsweep By returning a complete HscEnv from upsweep the logger (as introduced by withDeferredDiagnostics) was escaping the scope of withDeferredDiagnostics and hence we were losing error messages. This is reminiscent of #20981, which also talks about writing errors into messages after their scope has ended. See #23305 for details. - - - - - 26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00 Dump `SpecConstr` specialisations separately Introduce a `-ddump-spec-constr` flag which debugs specialisations from `SpecConstr`. These are no longer shown when you use `-ddump-spec`. - - - - - 4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00 Add role annotations to SNat, SSymbol and SChar Ticket #23454 explained it was possible to implement unsafeCoerce because SNat was lacking a role annotation. As these are supposed to be singleton types but backed by an efficient representation the correct annotation is nominal to ensure these kinds of coerces are forbidden. These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85 which was implemented in 532de36870ed9e880d5f146a478453701e9db25d. CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170 Fixes #23454 - - - - - 9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00 Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in This broke the sdist generation. Fixes #23489 - - - - - 273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00 Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver. - - - - - b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00 Fix -Wterm-variable-capture scope (#23434) -Wterm-variable-capture wasn't accordant with type variable scoping in associated types, in type classes. For example, this code produced the warning: k = 12 class C k a where type AT a :: k -> Type I solved this issue by reusing machinery of newTyVarNameRn function that is accordand with associated types: it does lookup for each free type variable when we are in the type class context. And in this patch I use result of this work to make sure that -Wterm-variable-capture warns only on implicitly quantified type variables. - - - - - 9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00 Remove redundant case statement in rts/js/mem.js. - - - - - a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00 Change WarningWithFlag to plural WarningWithFlags Resolves #22825 Now each diagnostic can name multiple different warning flags for its reason. There is currently one use case: missing signatures. Currently we need to check which warning flags are enabled when generating the diagnostic, which is against the declarative nature of the diagnostic framework. This patch allows a warning diagnostic to have multiple warning flags, which makes setup more declarative. The WarningWithFlag pattern synonym is added for backwards compatibility The 'msgEnvReason' field is added to MsgEnvelope to store the `ResolvedDiagnosticReason`, which accounts for the enabled flags, and then that is used for pretty printing the diagnostic. - - - - - ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00 Add a test Way for running ghci with Core optimizations Tracking ticket: #23059 This runs compile_and_run tests with optimised code with bytecode interpreter Changed submodules: hpc, process Co-authored-by: Torsten Schmits <git at tryp.io> - - - - - c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00 Configure -Qunused-arguments instead of hardcoding it When GHC invokes clang, it currently passes -Qunused-arguments to discard warnings resulting from GHC using multiple options that aren't used. In this commit, we configure -Qunused-arguments into the Cc options instead of checking if the compiler is clang at runtime and hardcoding the flag into GHC. This is part of the effort to centralise toolchain information in toolchain target files at configure time with the end goal of a runtime retargetable GHC. This also means we don't need to call getCompilerInfo ever, which improves performance considerably (see !10589). Metric Decrease: PmSeriesG T10421 T11303b T12150 T12227 T12234 T12425 T13035 T13253-spj T13386 T15703 T16875 T17836b T17977 T17977b T18140 T18282 T18304 T18698a T18698b T18923 T20049 T21839c T3064 T5030 T5321FD T5321Fun T5837 T6048 T9020 T9198 T9872d T9961 - - - - - 0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00 Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion between different precisions. - - - - - 95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00 Add regression test for #23143 !10541, the fix for #23323, also fixes #23143. Let's add a regression test to ensure that it stays fixed. Fixes #23143. - - - - - ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00 delete GHCi.UI.Tags module and remove remaining references Co-authored-by: Tilde Rose <t1lde at protonmail.com> - - - - - c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Add regression test for 17328 - - - - - de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00 Skip checking whether constructors are in scope when deriving newtype instances. Fixes #17328 - - - - - 5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00 Don't suggest `DeriveAnyClass` when instance can't be derived. Fixes #19692. Prototypical cases: class C1 a where x1 :: a -> Int data G1 = G1 deriving C1 class C2 a where x2 :: a -> Int x2 _ = 0 data G2 = G2 deriving C2 Both of these used to give this suggestion, but for C1 the suggestion would have failed (generated code with undefined methods, which compiles but warns). Now C2 still gives the suggestion but C1 doesn't. - - - - - 80a0b099 by David Binder at 2023-06-13T09:47:49-04:00 Add testcase for error GHC-00711 to testsuite - - - - - e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00 Add -Wmissing-poly-kind-signatures Implements #22826 This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types. - - - - - f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00 ci: special case in req_host_target_ghc for JS - - - - - b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00 When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions Fixes #23486 - - - - - c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00 Add a testcase for #20076 Remove 'recursive' in the error message, since the error can arise without recursion. - - - - - b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00 Use tcInferFRR to prevent bad generalisation Fixes #23176 - - - - - bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00 ci: Add dependenices on necessary aarch64 jobs for head.hackage ci These need to be added since we started testing aarch64 on head.hackage CI. The jobs will sometimes fail because they will start before the relevant aarch64 job has finished. Fixes #23511 - - - - - a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00 Add standalone kind signatures for Code and TExp CodeQ and TExpQ already had standalone kind signatures even before this change: type TExpQ :: TYPE r -> Kind.Type type CodeQ :: TYPE r -> Kind.Type Now Code and TExp have signatures too: type TExp :: TYPE r -> Kind.Type type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type This is a stylistic change. - - - - - e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeLits.Internal should not be used - - - - - 100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00 Warn that GHC.TypeNats.Internal should not be used - - - - - 078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add more flags for dumping core passes (#23491) - - - - - 1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00 Add tests for dumping flags (#23491) - - - - - 42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00 Provide a demand signature for atomicModifyMutVar.# (#23047) Fixes #23047 - - - - - 8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00 compiler: Cross-reference Note [StgToJS design] In particular, the numeric representations are quite useful context in a few places. - - - - - a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00 Implement the -Wimplicit-rhs-quantification warning (#23510) GHC Proposal #425 "Invisible binders in type declarations" forbids implicit quantification of type variables that occur free on the right-hand side of a type synonym but are not mentioned on the left-hand side. The users are expected to rewrite this using invisible binders: type T1 :: forall a . Maybe a type T1 = 'Nothing :: Maybe a -- old type T1 @a = 'Nothing :: Maybe a -- new Since the @k-binders are a new feature, we need to wait for three releases before we require the use of the new syntax. In the meantime, we ought to provide users with a new warning, -Wimplicit-rhs-quantification, that would detect when such implicit quantification takes place, and include it in -Wcompat. - - - - - 0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00 Minor refactorings to mkSpillInstr and mkLoadInstr Better error messages. And, use the existing `off` constant to reduce duplication. - - - - - 1792b57a by doyougnu at 2023-06-15T03:12:17-04:00 JS: merge util modules Merge Core and StgUtil modules for StgToJS pass. Closes: #23473 - - - - - 469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00 Check visibility of nested foralls in can_eq_nc (#18863) Prior to this change, `can_eq_nc` checked the visibility of the outermost layer of foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here Then it delegated the rest of the work to `can_eq_nc_forall`, which split off all foralls: forall a. forall b. forall c. phi1 forall x. forall y. forall z. phi2 ^^ up to here This meant that some visibility flags were completely ignored. We fix this oversight by moving the check to `can_eq_nc_forall`. - - - - - 59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: use regular mask for blocking IO Blocking IO used uninterruptibleMask which should make any thread blocked on IO unreachable by async exceptions (such as those from timeout). This changes it to a regular mask. It's important to note that the nodejs runtime does not actually interrupt the blocking IO when the Haskell thread receives an async exception, and that file positions may be updated and buffers may be written after the Haskell thread has already resumed. Any file descriptor affected by an async exception interruption should therefore be used with caution. - - - - - 907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: nodejs: do not set 'readable' handler on stdin at startup The Haskell runtime used to install a 'readable' handler on stdin at startup in nodejs. This would cause the nodejs system to start buffering the stream, causing data loss if the stdin file descriptor is passed to another process. This change delays installation of the 'readable' handler until the first read of stdin by Haskell code. - - - - - a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00 JS: reserve one more virtual (negative) file descriptor This is needed for upcoming support of the process package - - - - - 78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00 Report scoped kind variables at the type-checking phase (#16635) This patch modifies the renamer to respect ScopedTypeVariables in kind signatures. This means that kind variables bound by the outermost `forall` now scope over the type: type F = '[Right @a @() () :: forall a. Either a ()] -- ^^^^^^^^^^^^^^^ ^^^ -- in scope here bound here However, any use of such variables is a type error, because we don't have type-level lambdas to bind them in Core. This is described in the new Note [Type variable scoping errors during type check] in GHC.Tc.Types. - - - - - 4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00 JS: testsuite: use correct ticket number Replace #22356 with #22349 for these tests because #22356 has been fixed but now these tests fail because of #22349. - - - - - 15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: testsuite: update ticket numbers - - - - - 08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00 JS: more triage - - - - - e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00 Fix test T18522-deb-ppr Fixes #23509 - - - - - 62c56416 by Ben Price at 2023-06-16T05:52:39-04:00 Lint: more details on "Occurrence is GlobalId, but binding is LocalId" This is helpful when debugging a pass which accidentally shadowed a binder. - - - - - d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00 Clean a stray bit of text in user guide - - - - - 93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00 testsuite: Add forall visibility test cases The added tests ensure that the type checker does not confuse visible and invisible foralls. VisFlag1: kind-checking type applications and inferred type variable instantiations VisFlag1_ql: kind-checking Quick Look instantiations VisFlag2: kind-checking type family instances VisFlag3: checking kind annotations on type parameters of associated type families VisFlag4: checking kind annotations on type parameters in type declarations with SAKS VisFlag5: checking the result kind annotation of data family instances - - - - - a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00 JS: factorize SaneDouble into its own module Follow-up of b159e0e9 whose ticket is #22736 - - - - - 0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00 Add tests for #21973 - - - - - 640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation for `<**>` - - - - - 2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00 Update text - - - - - 1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00 Update examples - - - - - 7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00 Update documentation to actually display code correctly - - - - - 800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00 Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512) GHC Proposal #425 "Invisible binders in type declarations" restricts the scope of type and data family instances as follows: In type family and data family instances, require that every variable mentioned on the RHS must also occur on the LHS. For example, here are three equivalent type instance definitions accepted before this patch: type family F1 a :: k type instance F1 Int = Any :: j -> j type family F2 a :: k type instance F2 @(j -> j) Int = Any :: j -> j type family F3 a :: k type instance forall j. F3 Int = Any :: j -> j - In F1, j is implicitly quantified and it occurs only on the RHS; - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS; - In F3, j is explicitly quantified. Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted. - - - - - 9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: testsuite: use correct ticket numbers - - - - - c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00 JS: don't dump eventlog to stderr by default Fix T16707 Bump stm submodule - - - - - 89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00 Fix TH name lookup for symbolic tycons (#23525) - - - - - cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00 IPE data compression IPE data resulting from the `-finfo-table-map` flag may now be compressed by configuring the GHC build with the `--enable-ipe-data-compression` flag. This results in about a 20% reduction in the size of IPE-enabled build results. The compression library, zstd, may optionally be statically linked by configuring with the `--enabled-static-libzstd` flag (on non-darwin platforms) libzstd version 1.4.0 or greater is required. - - - - - 0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00 Add `IfaceWarnings` to represent the `ModIface`-storable parts of a `Warnings GhcRn`. Fixes #23516 - - - - - 3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00 Avoid desugaring non-recursive lets into recursive lets This prepares for having linear let expressions in the frontend. When desugaring lets, SPECIALISE statements create more copies of a let binding. Because of the rewrite rules attached to the bindings, there are dependencies between the generated binds. Before this commit, we simply wrapped all these in a mutually recursive let block, and left it to the simplified to sort it out. With this commit: we are careful to generate the bindings in dependency order, so that we can wrap them in consecutive lets (if the source is non-recursive). - - - - - 9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00 rts: Do not call exit() from SIGINT handler Previously `shutdown_handler` would call `stg_exit` if the scheduler was Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However, `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit` handlers). The only safe thing to do in this situation is to call `_exit`, which terminates with minimal cleanup. Fixes #23417. - - - - - 7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00 Bump Cabal submodule This requires changing the recomp007 test because now cabal passes `this-unit-id` to executable components, and that unit-id contains a hash which includes the ABI of the dependencies. Therefore changing the dependencies means that -this-unit-id changes and recompilation is triggered. The spririt of the test is to test GHC's recompilation logic assuming that `-this-unit-id` is constant, so we explicitly pass `-ipid` to `./configure` rather than letting `Cabal` work it out. - - - - - 1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00 [feat] add a hint to `HasField` error message - add a hint that indicates that the record that the record dot is used on might just be missing a field - as the intention of the programmer is not entirely clear, it is only shown if the type is known - This addresses in part issue #22382 - - - - - b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00 rts/ipe: Fix unused lock warning - - - - - 6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00 rts/ProfilerReportJson: Fix memory leak - - - - - 1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Various warnings fixes - - - - - 471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix printf format mismatch - - - - - 80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect #include <sys/poll.h> According to Alpine's warnings and poll(2), <poll.h> should be preferred. - - - - - ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00 nonmoving: Fix unused definition warrnings - - - - - 6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00 Disable futimens on Darwin. See #22938 - - - - - b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect CPP guard - - - - - 94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00 hadrian: Ensure that -Werror is passed when compiling the RTS. Previously the `+werror` transformer would only pass `-Werror` to GHC, which does not ensure that the same is passed to the C compiler when building the RTS. Arguably this is itself a bug but for now we will just work around this by passing `-optc-Werror` to GHC. I tried to enable `-Werror` in all C compilations but the boot libraries are something of a portability nightmare. - - - - - 5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Disable `#pragma GCC`s on clang compilers Otherwise the build fails due to warnings. See #23530. - - - - - cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix capitalization of prototype - - - - - 17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00 rts: Fix incorrect format specifier - - - - - 0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00 JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576) - - - - - 3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Memory usage fixes for Haddock - Do not include `mi_globals` in the `NoBackend` backend. It was only included for Haddock, but Haddock does not actually need it. This causes a 200MB reduction in max residency when generating haddocks on the Agda codebase (roughly 1GB to 800MB). - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to be written to interface files using `-fwrite-interface` Bumps haddock submodule. Metric Decrease: haddock.base - - - - - 8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00 Fix associated data family doc structure items Associated data families were being given their own export DocStructureItems, which resulted in them being documented separately from their classes in haddocks. This commit fixes it. - - - - - 4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: implement TH support - Add ghc-interp.js bootstrap script for the JS interpreter - Interactively link and execute iserv code from the ghci package - Incrementally load and run JS code for splices into the running iserv Co-authored-by: Luite Stegeman <stegeman at gmail.com> - - - - - 3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Don't use getKey - - - - - f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Stg: return imported FVs This is used to determine what to link when using the interpreter. For now it's only used by the JS interpreter but it could easily be used by the native interpreter too (instead of extracting names from compiled BCOs). - - - - - fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00 Fix some recompilation avoidance tests - - - - - a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00 TH_import_loop is now broken as expected - - - - - dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00 JS: always recompile when TH is enabled (cf #23013) - - - - - 711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00 Add support for deprecating exported items (proposal #134) This is an implementation of the deprecated exports proposal #134. The proposal introduces an ability to introduce warnings to exports. This allows for deprecating a name only when it is exported from a specific module, rather than always depreacting its usage. In this example: module A ({-# DEPRECATED "do not use" #-} x) where x = undefined --- module B where import A(x) `x` will emit a warning when it is explicitly imported. Like the declaration warnings, export warnings are first accumulated within the `Warnings` struct, then passed into the ModIface, from which they are then looked up and warned about in the importing module in the `lookup_ie` helpers of the `filterImports` function (for the explicitly imported names) and in the `addUsedGRE(s)` functions where they warn about regular usages of the imported name. In terms of the AST information, the custom warning is stored in the extension field of the variants of the `IE` type (see Trees that Grow for more information). The commit includes a bump to the haddock submodule added in MR #28 Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00 configure: Bump version to 9.8 Bumps Haddock submodule - - - - - 4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00 configure: Bump version to 9.9 Bumps haddock submodule. - - - - - 5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00 rts: Work around missing prototypes errors Darwin's toolchain inexpliciably claims that `write_barrier` and friends have declarations without prototypes, despite the fact that (a) they are definitions, and (b) the prototypes appear only a few lines above. Work around this by making the definitions proper prototypes. - - - - - 43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00 ghcup-metadata: Fix date modifier (M = minutes, m = month) Fixes #23552 - - - - - 564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00 Support large stack frames/offsets in GHCi bytecode interpreter Bytecode instructions like PUSH_L (push a local variable) contain an operand that refers to the stack slot. Before this patch, the operand type was SmallOp (Word16), limiting the maximum stack offset to 65535 words. This could cause compiler panics in some cases (See #22888). This patch changes the operand type for stack offsets from SmallOp to Op, removing the stack offset limit. Fixes #22888 - - - - - 8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00 JS: support levity-polymorphic datatypes (#22360,#22291) - thread knowledge about levity into PrimRep instead of panicking - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.) Doing this also fixes #22291 (test added). There is a small performance hit (~1% more allocations). Metric Increase: T18698a T18698b - - - - - 5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00 MR Review Template: Mention "Blocked on Review" label In order to improve our MR review processes we now have the label "Blocked on Review" which allows people to signal that a MR is waiting on a review to happen. See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html - - - - - 4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00 Move MR template to Default.md This makes it more obvious what you have to modify to affect the default template rather than looking in the project settings. - - - - - 522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00 Revert "Avoid desugaring non-recursive lets into recursive lets" This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef. Fixes #23550 - - - - - c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00 Propagate breakpoint information when inlining across modules Tracking ticket: #23394 MR: !10448 * Add constructor `IfaceBreakpoint` to `IfaceTickish` * Store breakpoint data in interface files * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's state * Allocate module name in `ModBreaks`, like `BreakArray` * Lookup breakpoint by module name in GHCi * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the linker when breakpoints are enabled, and panicking when `ModBreaks` is missing - - - - - 6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00 Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's - - - - - e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00 Remove arity inference in type declarations (#23514) Arity inference in type declarations was introduced as a workaround for the lack of @k-binders. They were added in 4aea0a72040, so I simplified all of this by simply removing arity inference altogether. This is part of GHC Proposal #425 "Invisible binders in type declarations". - - - - - 459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00 Relax defaulting of RuntimeRep/Levity when printing Fixes #16468 MR: !10702 Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall - - - - - 151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00 Remove duplicate link label in linear types docs - - - - - ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00 Stop configuring unused Ld command in `settings` GHC has no direct dependence on the linker. Rather, we depend upon the C compiler for linking and an object-merging program (which is typically `ld`) for production of GHCi objects and merging of C stubs into final object files. Despite this, for historical reasons we still recorded information about the linker into `settings`. Remove these entries from `settings`, `hadrian/cfg/system.config`, as well as the `configure` logic responsible for this information. Closes #23566. - - - - - bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00 Remove extraneous debug output - - - - - 7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00 Work with unset vars in -e mode - - - - - 49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00 Pass positional arguments in their positions By quoting $cmd, the default "bash -i" is a single argument to run, and no file named "bash -i" actually exists to be run. - - - - - 887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00 Handle unset value in -e context - - - - - 5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00 Configure CPP into settings There is a distinction to be made between the Haskell Preprocessor and the C preprocessor. The former is used to preprocess Haskell files, while the latter is used in C preprocessing such as Cmm files. In practice, they are both the same program (usually the C compiler) but invoked with different flags. Previously we would, at configure time, configure the haskell preprocessor and save the configuration in the settings file, but, instead of doing the same for CPP, we had hardcoded in GHC that the CPP program was either `cc -E` or `cpp`. This commit fixes that asymmetry by also configuring CPP at configure time, and tries to make more explicit the difference between HsCpp and Cpp (see Note [Preprocessing invocations]). Note that we don't use the standard CPP and CPPFLAGS to configure Cpp, but instead use the non-standard --with-cpp and --with-cpp-flags. The reason is that autoconf sets CPP to "$CC -E", whereas we expect the CPP command to be configured as a standalone executable rather than a command. These are symmetrical with --with-hs-cpp and --with-hs-cpp-flags. Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP to be C99 compatible through -optP, since we now configure that into settings. Closes #23422 - - - - - 5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00 hadrian: Always canonicalize topDirectory Hadrian's `topDirectory` is intended to provide an absolute path to the root of the GHC tree. However, if the tree is reached via a symlink this One question here is whether the `canonicalizePath` call is expensive enough to warrant caching. In a quick microbenchmark I observed that `canonicalizePath "."` takes around 10us per call; this seems sufficiently low not to worry. Alternatively, another approach here would have been to rather move the canonicalization into `m4/fp_find_root.m4`. This would have avoided repeated canonicalization but sadly path canonicalization is a hard problem in POSIX shell. Addresses #22451. - - - - - b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00 Optimise ELF linker (#23464) - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF` - cache shndx table in ObjectCode - run `checkProddableBlock` only with debug rts - - - - - 30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE - - - - - b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00 compiler: Drop MO_WriteBarrier rts: Drop write_barrier - - - - - 7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00 rts: Drop load_store_barrier() This is no longer used. - - - - - d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop last instances of prim_{write,read}_barrier - - - - - 965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Eliminate remaining uses of load_load_barrier - - - - - 0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00 compiler: Drop MO_ReadBarrier - - - - - 7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Drop load_load_barrier This is no longer used. - - - - - 9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00 Delete write_barrier function - - - - - bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00 rts: Make collectFreshWeakPtrs definition a prototype x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs needs to be a prototype. - - - - - ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00 Fix number of free double regs D1..D4 are defined for aarch64 and thus not free. - - - - - c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00 Fix typechecking of promoted empty lists The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of `'[]` (see the newly added `T23543` test case for an example), but the `'[]` case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type checker]`. There are some benign changes to test cases' expected output due to the new code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`. Fixes #23543. - - - - - fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00 Configure MergeObjs supports response files rather than Ld The previous configuration script to test whether Ld supported response files was * Incorrect (see #23542) * Used, in practice, to check if the *merge objects tool* supported response files. This commit modifies the macro to run the merge objects tool (rather than Ld), using a response file, and checking the result with $NM Fixes #23542 - - - - - 78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00 JS: fix JS stack printing (#23565) - - - - - 9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00 Add -fpolymorphic-specialisation flag (off by default at all optimisation levels) Polymorphic specialisation has led to a number of hard to diagnose incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so this commit introduces a flag `-fpolymorhphic-specialisation` which allows users to turn on this experimental optimisation if they are willing to buy into things going very wrong. Ticket #23469 - - - - - b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00 Rip out runtime linker/compiler checks We used to choose flags to pass to the toolchain at runtime based on the platform running GHC, and in this commit we drop all of those runtime linker checks Ultimately, this represents a change in policy: We no longer adapt at runtime to the toolchain being used, but rather make final decisions about the toolchain used at /configure time/ (we have deleted Note [Run-time linker info] altogether!). This works towards the goal of having all toolchain configuration logic living in the same place, which facilities the work towards a runtime-retargetable GHC (see #19877). As of this commit, the runtime linker/compiler logic was moved to autoconf, but soon it, and the rest of the existing toolchain configuration logic, will live in the standalone ghc-toolchain program (see !9263) In particular, what used to be done at runtime is now as follows: * The flags -Wl,--no-as-needed for needed shared libs are configured into settings * The flag -fstack-check is configured into settings * The check for broken tables-next-to-code was outdated * We use the configured c compiler by default as the assembler program * We drop `asmOpts` because we already configure -Qunused-arguments flag into settings (see !10589) Fixes #23562 Co-author: Rodrigo Mesquita (@alt-romes) - - - - - 8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00 Define FFI_GO_CLOSURES The libffi shipped with Apple's XCode toolchain does not contain a definition of the FFI_GO_CLOSURES macro, despite containing references to said macro. Work around this by defining the macro, following the model of a similar workaround in OpenJDK [1]. [1] https://github.com/openjdk/jdk17u-dev/pull/741/files - - - - - d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00 base: Fix incorrect CPP guard This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`. - - - - - 7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00 rts/Trace: Ensure that debugTrace arguments are used As debugTrace is a macro we must take care to ensure that the fact is clear to the compiler lest we see warnings. - - - - - cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00 rts: Various warnings fixes - - - - - dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00 hadrian: Ignore warnings in unix and semaphore-compat - - - - - d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00 hadrian: Fix dependencies of docs:* rule For the docs:* rule we need to actually build the package rather than just the haddocks for the dependent packages. Therefore we depend on the .conf files of the packages we are trying to build documentation for as well as the .haddock files. Fixes #23472 - - - - - cec90389 by sheaf at 2023-06-30T12:39:27-04:00 Add tests for #22106 Fixes #22106 - - - - - 083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00 Add -fbreak-points to control breakpoint insertion Rather than statically enabling breakpoints only for the interpreter, this adds a new flag. Tracking ticket: #23057 MR: !10466 - - - - - fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00 rts: Ensure that pinned allocations respect block size Previously, it was possible for pinned, aligned allocation requests to allocate beyond the end of the pinned accumulator block. Specifically, we failed to account for the padding needed to achieve the requested alignment in the "large object" check. With large alignment requests, this can result in the allocator using the capability's pinned object accumulator block to service a request which is larger than `PINNED_EMPTY_SIZE`. To fix this we reorganize `allocatePinned` to consistently account for the alignment padding in all large object checks. This is a bit subtle as we must handle the case of a small allocation request filling the accumulator block, as well as large requests. Fixes #23400. - - - - - 98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00 testsuite: Add test for #23400 - - - - - 4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00 ghc-heap: Support for BLOCKING_QUEUE closures - - - - - 03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00 Add some structured diagnostics in Tc/Validity.hs This addresses the work of ticket #20118 Created the following constructors for TcRnMessage - TcRnInaccessibleCoAxBranch - TcRnPatersonCondFailure - - - - - 6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Add failing test case for #23492 - - - - - 356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Use generated src span for catch-all case of record selector functions This fixes #23492. The problem was that we used the real source span of the field declaration for the generated catch-all case in the selector function, in particular in the generated call to `recSelError`, which meant it was included in the HIE output. Using `generatedSrcSpan` instead means that it is not included. - - - - - 3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils - - - - - dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00 Construct catch-all default case using helpers GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors - - - - - 0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00 Add regression test for #23549 - - - - - 32741743 by Alexis King at 2023-07-03T03:31:36-04:00 perf tests: Increase default stack size for MultiLayerModules An unhelpfully small stack size appears to have been the real culprit behind the metric fluctuations in #19293. Debugging metric decreases triggered by !10729 helped to finally identify the problem. Metric Decrease: MultiLayerModules MultiLayerModulesTH_Make T13701 T14697 - - - - - 82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00 Add missing void prototypes to rts functions See #23561. - - - - - 6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00 gitlab-ci: Refactor compilation of gen_ci Flakify and document it, making it far less sensitive to the build environment. - - - - - aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00 testsuite: Update documentation - - - - - 924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00 Better error for data deriving of type synonym/family. Closes #23522 - - - - - 4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00 Fix some broken links and typos - - - - - de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00 configure: Rip out Solaris dyld check Solaris 11 was released over a decade ago and, moreover, I doubt we have any Solaris users - - - - - 59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00 CI: add JS release and debug builds, regen CI jobs - - - - - 679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00 testsuite: Do not require CUSKs Numerous tests make use of CUSKs (complete user-supplied kinds), a legacy feature scheduled for deprecation. In order to proceed with the said deprecation, the tests have been updated to use SAKS instead (standalone kind signatures). This also allows us to remove the Haskell2010 language pragmas that were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021. - - - - - 945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00 gitlab: Drop backport-for-8.8 MR template Its usefulness has long passed. - - - - - 66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00 EPA: Simplify GHC/Parser.y comb2 Use the HasLoc instance from Ast.hs to allow comb2 to work with anything with a SrcSpan This gets rid of the custom comb2A, comb2Al, comb2N functions, and removes various reLoc calls. - - - - - 2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00 Fix deprecation warning when deprecated identifier is from another module A stray 'Just' was being printed in the deprecation message. Fixes #23573 - - - - - 46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00 rts: Don't rely on initializers for sigaction_t As noted in #23577, CentOS's ancient toolchain throws spurious missing-field-initializer warnings. - - - - - ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Don't treat -Winline warnings as fatal Such warnings are highly dependent upon the toolchain, platform, and build configuration. It's simply too fragile to rely on these. - - - - - 3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00 hadrian: Only pass -Wno-nonportable-include-path on Darwin This flag, which was introduced due to #17798, is only understood by Clang and consequently throws warnings on platforms using gcc. Sadly, there is no good way to treat such warnings as non-fatal with `-Werror` so for now we simply make this flag specific to platforms known to use Clang and case-insensitive filesystems (Darwin and Windows). See #23577. - - - - - 4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00 Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals - - - - - 2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00 compiler: Make OccSet opaque - - - - - cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00 Add Note about why we need forall in Code to be on the right - - - - - fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00 Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall. - - - - - 9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00 Improve the situation with the stimes cycle Currently the Semigroup stimes cycle is resolved in GHC.Base by importing stimes implementations from a hs-boot file. Resolve the cycle using hs-boot files for required classes (Num, Integral) instead. Now stimes can be defined directly in GHC.Base, making inlining and specialization possible. This leads to some new boot files for `GHC.Num` and `GHC.Real`, the methods for those are only used to implement `stimes` so it doesn't appear that these boot files will introduce any new performance traps. Metric Decrease: T13386 T8095 Metric Increase: T13253 T13386 T18698a T18698b T19695 T8095 - - - - - 9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00 Refactor Unique to be represented by Word64 In #22010 we established that Int was not always sufficient to store all the uniques we generate during compilation on 32-bit platforms. This commit addresses that problem by using Word64 instead of Int for uniques. The core of the change is in GHC.Core.Types.Unique and GHC.Core.Types.Unique.Supply. However, the representation of uniques is used in many other places, so those needed changes too. Additionally, the RTS has been extended with an atomic_inc64 operation. One major change from this commit is the introduction of the Word64Set and Word64Map data types. These are adapted versions of IntSet and IntMap from the containers package. These are planned to be upstreamed in the future. As a natural consequence of these changes, the compiler will be a bit slower and take more space on 32-bit platforms. Our CI tests indicate around a 5% residency increase. Metric Increase: CoOpt_Read CoOpt_Singletons LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot RecordUpdPerf T10421 T10547 T12150 T12227 T12234 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T13386 T13719 T14683 T14697 T14766 T15164 T15703 T16577 T16875 T17516 T18140 T18223 T18282 T18304 T18698a T18698b T18923 T1969 T19695 T20049 T21839c T3064 T3294 T4801 T5030 T5321FD T5321Fun T5631 T5642 T5837 T6048 T783 T8095 T9020 T9198 T9233 T9630 T9675 T9872a T9872b T9872b_defer T9872c T9872d T9961 TcPlugin_RewritePerf UniqLoop WWRec hard_hole_fits - - - - - 6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00 Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro - - - - - 40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00 Substitute free variables captured by breakpoints in SpecConstr Fixes #23267 - - - - - 2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00 Reinstate untouchable variable error messages This extra bit of information was accidentally being discarded after a refactoring of the way we reported problems when unifying a type variable with another type. This patch rectifies that. - - - - - 53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00 configure: Drop Clang command from settings Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the `runClang` function, and no longer need to configure into settings the Clang command. We used to determine options at runtime to pass clang when it was used as an assembler, but now that we configure at configure time we no longer need to. - - - - - 6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00 Filter out nontrivial substituted expressions in substTickish Fixes #23272 - - - - - 41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: testsuite: use req_c predicate instead of js_broken - - - - - 74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00 JS: implement some file primitives (lstat,rmdir) (#22374) - Implement lstat and rmdir. - Implement base_c_s_is* functions (testing a file type) - Enable passing tests - - - - - 7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: cleanup utils (#23314) - Removed unused code - Don't export unused functions - Move toTypeList to Closure module - - - - - f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: rename VarType/Vt into JSRep - - - - - 19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: remove custom PrimRep conversion (#23314) We use the usual conversion to PrimRep and then we convert these PrimReps to JSReps. - - - - - d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00 JS: don't use isRuntimeRepKindedTy in JS FFI - - - - - 8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file Fixes #23600 - - - - - e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00 ghcup-metadata: Use dynamically linked alpine bindists In theory these will work much better on alpine to allow people to build statically linked applications there. We don't need to distribute a statically linked application ourselves in order to allow that. Fixes #23602 - - - - - b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00 Drop circle-ci-job.sh - - - - - 9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00 testsuite: Allow preservation of unexpected output Here we introduce a new flag to the testsuite driver, --unexpected-output-dir=<dir>, which allows the user to ask the driver to preserve unexpected output from tests. The intent is for this to be used in CI to allow users to more easily fix unexpected platform-dependent output. - - - - - 48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00 gitlab-ci: Preserve unexpected output Here we enable use of the testsuite driver's `--unexpected-output-dir` flag by CI, preserving the result as an artifact for use by users. - - - - - 76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00 driver: Fix -S with .cmm files There was an oversight in the driver which assumed that you would always produce a `.o` file when compiling a .cmm file. Fixes #23610 - - - - - 6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00 Update Hadrian's stack.yaml - - - - - 1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00 compiler: Rework ShowSome Previously the field used to filter the sub-declarations to show was rather ad-hoc and was only able to show at most one sub-declaration. - - - - - 8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00 testsuite: Add test to catch changes in core libraries This adds testing infrastructure to ensure that changes in core libraries (e.g. `base` and `ghc-prim`) are caught in CI. - - - - - ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00 Deprecate Data.List.NonEmpty.unzip - - - - - 5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00 Drop latent mentions of -split-objs Closes #21134. - - - - - a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00 Add warn_and_run test kind This is a compile_and_run variant which also captures the GHC's stderr. The warn_and_run name is best I can come up with, as compile_and_run is taken. This is useful specifically for testing warnings. We want to test that when warning triggers, and it's not a false positive, i.e. that the runtime behaviour is indeed "incorrect". As an example a single test is altered to use warn_and_run - - - - - c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00 configure: Don't use ld.gold on i386 ld.gold appears to produce invalid static constructor tables on i386. While ideally we would add an autoconf check to check for this brokenness, sadly such a check isn't easy to compose. Instead to summarily reject such linkers on i386. Somewhat hackily closes #23579. - - - - - 054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00 Add since annotations for Data.Foldable1 - - - - - 550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00 JS: support -this-unit-id for programs in the linker (#23613) - - - - - d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00 Bump text submodule - - - - - 8e11630e by jade at 2023-07-10T16:58:40-04:00 Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007) As suggested in #20007 and implemented in !8895, trying to import type operators will suggest a fix to use the 'type' keyword, without considering whether ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled, alongside the suggestion of adding the 'type' keyword. - - - - - 61b1932e by sheaf at 2023-07-10T16:59:26-04:00 tyThingLocalGREs: include all DataCons for RecFlds The GREInfo for a record field should include the collection of all the data constructors of the parent TyCon that have this record field. This information was being incorrectly computed in the tyThingLocalGREs function for a DataCon, as we were not taking into account other DataCons with the same parent TyCon. Fixes #23546 - - - - - e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00 EPA: Simplify GHC/Parser.y comb3 A follow up to !10743 - - - - - ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00 Document that compareByteArrays# is available since ghc-prim-0.5.2.0 - - - - - 4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00 Revert "Bump text submodule" This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a. This commit requires that we bootstrap with ghc-9.4, which we do not require until #23195 has been completed. Subsequently this has broken nighty jobs such as the rocky8 job which in turn has broken nightly releases. - - - - - d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Fingerprint more code generation flags Previously our recompilation check was quite inconsistent in its coverage of non-optimisation code generation flags. Specifically, we failed to account for most flags that would affect the behavior of generated code in ways that might affect the result of a program's execution (e.g. `-feager-blackholing`, `-fstrict-dicts`) Closes #23369. - - - - - eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00 compiler: Record original thunk info tables on stack Here we introduce a new code generation option, `-forig-thunk-info`, which ensures that an `stg_orig_thunk_info` frame is pushed before every update frame. This can be invaluable when debugging thunk cycles and similar. See Note [Original thunk info table frames] for details. Closes #23255. - - - - - 4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00 Fix wrong MIN_VERSION_GLASGOW_HASKELL macros I forgot to change these after rebasing. - - - - - dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00 Hadrian: enable GHCi support on riscv64 - - - - - 09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00 JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628) - - - - - 29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00 Remove references to make build system in mk/build.mk Fixes #23636 - - - - - 630e3026 by sheaf at 2023-07-12T11:26:43-04:00 Valid hole fits: don't panic on a Given The function GHC.Tc.Errors.validHoleFits would end up panicking when encountering a Given constraint. To fix this, it suffices to filter out the Givens before continuing. Fixes #22684 - - - - - c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00 Use deb10 for i386 bindists deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10 Fixes #23585 - - - - - bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00 Fix #23567, a specializer bug Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834 The testcase isn't ideal because it doesn't detect the bug in master, unless doNotUnbox is removed as in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692. But I have confirmed that with that modification, it fails before and passes afterwards. - - - - - 84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 Comments - - - - - b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 updates to comments - - - - - 2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00 changes - - - - - 6143838a by sheaf at 2023-07-13T08:02:17-04:00 Fix deprecation of record fields Commit 3f374399 inadvertently broke the deprecation/warning mechanism for record fields due to its introduction of record field namespaces. This patch ensures that, when a top-level deprecation is applied to an identifier, it applies to all the record fields as well. This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of NameSpaces but to look up all NameSpaces and filter out the irrelevant ones. - - - - - 6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00 Introduce greInfo, greParent These are simple helper functions that wrap the internal field names gre_info, gre_par. - - - - - 7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00 Refactor lookupGRE_... functions This commit consolidates all the logic for looking up something in the Global Reader Environment into the single function lookupGRE. This allows us to declaratively specify all the different modes of looking up in the GlobalRdrEnv, and avoids manually passing around filtering functions as was the case in e.g. the function GHC.Rename.Env.lookupSubBndrOcc_helper. ------------------------- Metric Decrease: T8095 ------------------------- ------------------------- Metric Increase: T8095 ------------------------- - - - - - 5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00 configure: Drop DllWrap command We used to configure into settings a DllWrap command for windows builds and distributions, however, we no longer do, and dllwrap is effectively unused. This simplification is motivated in part by the larger toolchain-selection project (#19877, !9263) - - - - - e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00 base: fix haddock syntax in GHC.Profiling - - - - - 0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00 Revert "CI: add JS release and debug builds, regen CI jobs" This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af. This commit added two duplicate jobs on all validate pipelines, so we are reverting for now whilst we work out what the best way forward is. Ticket #23618 - - - - - 54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00 EPA: Simplify GHC/Parser.y sLL Follow up to !10743 - - - - - c8863828 by sheaf at 2023-07-15T03:24:06-04:00 Configure: canonicalise PythonCmd on Windows This change makes PythonCmd resolve to a canonical absolute path on Windows, which prevents HLS getting confused (now that we have a build-time dependency on python). fixes #23652 - - - - - ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00 Improve Note [Binder-swap during float-out] - - - - - cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00 Equality of forall-types is visibility aware This patch finally (I hope) nails the question of whether (forall a. ty) and (forall a -> ty) are `eqType`: they aren't! There is a long discussion in #22762, plus useful Notes: * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare * Note [Comparing visiblities] in GHC.Core.TyCo.Compare * Note [ForAllCo] in GHC.Core.TyCo.Rep It also establishes a helpful new invariant for ForAllCo, and ForAllTy, when the bound variable is a CoVar:in that case the visibility must be coreTyLamForAllTyFlag. All this is well documented in revised Notes. - - - - - 7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00 List and Tuple<n>: update documentation Add the missing changelog.md entries and @since-annotations. - - - - - 2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00 Type patterns (#22478, #18986) Improved name resolution and type checking of type patterns in constructors: 1. HsTyPat: a new dedicated data type that represents type patterns in HsConPatDetails instead of reusing HsPatSigType 2. rnHsTyPat: a new function that renames a type pattern and collects its binders into three groups: - explicitly bound type variables, excluding locally bound variables - implicitly bound type variables from kind signatures (only if ScopedTypeVariables are enabled) - named wildcards (only from kind signatures) 2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat 2b. rnImplcitTvBndrs: removed because no longer needed 3. collect_pat: updated to collect type variable binders from type patterns (this means that types and terms use the same infrastructure to detect conflicting bindings, unused variables and name shadowing) 3a. CollVarTyVarBinders: a new CollectFlag constructor that enables collection of type variables 4. tcHsTyPat: a new function that typechecks type patterns, capable of handling polymorphic kinds. See Note [Type patterns: binders and unifiers] Examples of code that is now accepted: f = \(P @a) -> \(P @a) -> ... -- triggers -Wname-shadowing g :: forall a. Proxy a -> ... g (P @a) = ... -- also triggers -Wname-shadowing h (P @($(TH.varT (TH.mkName "t")))) = ... -- t is bound at splice time j (P @(a :: (x,x))) = ... -- (x,x) is no longer rejected data T where MkT :: forall (f :: forall k. k -> Type). f Int -> f Maybe -> T k :: T -> () k (MkT @f (x :: f Int) (y :: f Maybe)) = () -- f :: forall k. k -> Type Examples of code that is rejected with better error messages: f (Left @a @a _) = ... -- new message: -- • Conflicting definitions for ‘a’ -- Bound at: Test.hs:1:11 -- Test.hs:1:14 Examples of code that is now rejected: {-# OPTIONS_GHC -Werror=unused-matches #-} f (P @a) = () -- Defined but not used: type variable ‘a’ - - - - - eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00 Don't use substTyUnchecked in newMetaTyVar There were some comments that explained that we needed to use an unchecked substitution function because of issue #12931, but that has since been fixed, so we should be able to use substTy instead now. - - - - - c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00 rnImports: var shouldn't import NoFldSelectors In an import declaration such as import M ( var ) the import of the variable "var" should **not** bring into scope record fields named "var" which are defined with NoFieldSelectors. Doing so can cause spurious "unused import" warnings, as reported in ticket #23557. Fixes #23557 - - - - - 1af2e773 by sheaf at 2023-07-17T02:48:19-04:00 Suggest similar names in imports This commit adds similar name suggestions when importing. For example module A where { spelling = 'o' } module B where { import B ( speling ) } will give rise to the error message: Module ‘A’ does not export ‘speling’. Suggested fix: Perhaps use ‘spelling’ This also provides hints when users try to import record fields defined with NoFieldSelectors. - - - - - 654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00 EPA: Store leading AnnSemi for decllist in al_rest This simplifies the markAnnListA implementation in ExactPrint - - - - - 22565506 by sheaf at 2023-07-17T21:12:59-04:00 base: add COMPLETE pragma to BufferCodec PatSyn This implements CLC proposal #178, rectifying an oversight in the implementation of CLC proposal #134 which could lead to spurious pattern match warnings. https://github.com/haskell/core-libraries-committee/issues/178 https://github.com/haskell/core-libraries-committee/issues/134 - - - - - 860f6269 by sheaf at 2023-07-17T21:13:00-04:00 exactprint: silence incomplete record update warnings - - - - - df706de3 by sheaf at 2023-07-17T21:13:00-04:00 Re-instate -Wincomplete-record-updates Commit e74fc066 refactored the handling of record updates to use the HsExpanded mechanism. This meant that the pattern matching inherent to a record update was considered to be "generated code", and thus we stopped emitting "incomplete record update" warnings entirely. This commit changes the "data Origin = Source | Generated" datatype, adding a field to the Generated constructor to indicate whether we still want to perform pattern-match checking. We also have to do a bit of plumbing with HsCase, to record that the HsCase arose from an HsExpansion of a RecUpd, so that the error message continues to mention record updates as opposed to a generic "incomplete pattern matches in case" error. Finally, this patch also changes the way we handle inaccessible code warnings. Commit e74fc066 was also a regression in this regard, as we were emitting "inaccessible code" warnings for case statements spuriously generated when desugaring a record update (remember: the desugaring mechanism happens before typechecking; it thus can't take into account e.g. GADT information in order to decide which constructors to include in the RHS of the desugaring of the record update). We fix this by changing the mechanism through which we disable inaccessible code warnings: we now check whether we are in generated code in GHC.Tc.Utils.TcMType.newImplication in order to determine whether to emit inaccessible code warnings. Fixes #23520 Updates haddock submodule, to avoid incomplete record update warnings - - - - - 1d05971e by sheaf at 2023-07-17T21:13:00-04:00 Propagate long-distance information in do-notation The preceding commit re-enabled pattern-match checking inside record updates. This revealed that #21360 was in fact NOT fixed by e74fc066. This commit makes sure we correctly propagate long-distance information in do blocks, e.g. in ```haskell data T = A { fld :: Int } | B f :: T -> Maybe T f r = do a at A{} <- Just r Just $ case a of { A _ -> A 9 } ``` we need to propagate the fact that "a" is headed by the constructor "A" to see that the case expression "case a of { A _ -> A 9 }" cannot fail. Fixes #21360 - - - - - bea0e323 by sheaf at 2023-07-17T21:13:00-04:00 Skip PMC for boring patterns Some patterns introduce no new information to the pattern-match checker (such as plain variable or wildcard patterns). We can thus skip doing any pattern-match checking on them when the sole purpose for doing so was introducing new long-distance information. See Note [Boring patterns] in GHC.Hs.Pat. Doing this avoids regressing in performance now that we do additional pattern-match checking inside do notation. - - - - - ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00 Split GHC.Platform.ArchOS from ghc-boot into ghc-platform Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package into this reinstallable standalone package which abides by the PVP, in part motivated by the ongoing work on `ghc-toolchain` towards runtime retargetability. - - - - - b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00 JS: better implementation for plusWord64 (#23597) - - - - - 889c2bbb by sheaf at 2023-07-18T06:37:32-04:00 Do primop rep-poly checks when instantiating This patch changes how we perform representation-polymorphism checking for primops (and other wired-in Ids such as coerce). When instantiating the primop, we check whether each type variable is required to instantiated to a concrete type, and if so we create a new concrete metavariable (a ConcreteTv) instead of a simple MetaTv. (A little subtlety is the need to apply the substitution obtained from instantiating to the ConcreteTvOrigins, see Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.) This allows us to prevent representation-polymorphism in non-argument position, as that is required for some of these primops. We can also remove the logic in tcRemainingValArgs, except for the part concerning representation-polymorphic unlifted newtypes. The function has been renamed rejectRepPolyNewtypes; all it does now is reject unsaturated occurrences of representation-polymorphic newtype constructors when the representation of its argument isn't a concrete RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check). The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head gives more explanation about a possible path to PHASE 2, which would be in line with the treatment for primops taken in this patch. We also update the Core Lint check to handle this new framework. This means Core Lint now checks representation-polymorphism in continuation position like needed for catch#. Fixes #21906 ------------------------- Metric Increase: LargeRecord ------------------------- - - - - - 00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00 Core Lint: distinguish let and letrec in locations Lint messages were saying "in the body of letrec" even for non-recursive let. I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no separate letrec. - - - - - 787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00 Use extended literals when deriving Show This implements GHC proposal https://github.com/ghc-proposals/ghc-proposals/pull/596 Also add support for Int64# and Word64#; see testcase ShowPrim. - - - - - 257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00 Add StgFromCore and StgCodeGen linting - - - - - 34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Strictness - - - - - c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00 Reg.Liveness: Don't repeatedly construct UniqSets - - - - - b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00 compiler/Types: Ensure that fromList-type operations can fuse In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing it to do so makes a considerable difference in allocations due to the backend. Metric Decrease: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 Codegen: Implement MO_S_MulMayOflo for W16 - - - - - 5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64 It's useful to see which value made the pattern match fail. (If it ever occurs.) - - - - - e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00 x86 CodeGen: Implement MO_S_MulMayOflo for W8 This case wasn't handled before. But, the test-primops test suite showed that it actually might appear. - - - - - a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00 Add test for %mulmayoflo primop The test expects a perfect implementation with no false positives. - - - - - 38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00 lint-ci-config: Generate jobs-metadata.json We also now save the jobs-metadata.json and jobs.yaml file as artifacts as: * It might be useful for someone who is modifying CI to copy jobs.yaml if they are having trouble regenerating locally. * jobs-metadata.json is very useful for downstream pipelines to work out the right job to download. Fixes #23654 - - - - - 1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00 Initialize 9.10.1-notes.rst Create new release notes for the next GHC release (GHC 9.10) - - - - - 3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00 Prioritise Parent when looking up class sub-binder When we look up children GlobalRdrElts of a given Parent, we sometimes would rather prioritise those GlobalRdrElts which have the right Parent, and sometimes prioritise those that have the right NameSpace: - in export lists, we should prioritise NameSpace - for class/instance binders, we should prioritise Parent See Note [childGREPriority] in GHC.Types.Name.Reader. fixes #23664 - - - - - 9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00 EPA: Improve annotation management in getMonoBind Ensure the LHsDecl for a FunBind has the correct leading comments and trailing annotations. See the added note for details. - - - - - ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00 Remove unused files in .gitlab These were left over after 6078b429 - - - - - 29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00 gen_ci: Add hie.yaml file This allows you to load `gen_ci.hs` into HLS, and now it is a huge module, that is quite useful. - - - - - 808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00 ci: Make "fast-ci" the default validate configuration We are trying out a lighter weight validation pipeline where by default we just test on 5 platforms: * x86_64-deb10-slow-validate * windows * x86_64-fedora33-release * aarch64-darwin * aarch64-linux-deb10 In order to enable the "full" validation pipeline you can apply the `full-ci` label which will enable all the validation pipelines. All the validation jobs are still run on a marge batch. The goal is to reduce the overall CI capacity so that pipelines start faster for MRs and marge bot batches are faster. Fixes #23694 - - - - - 0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00 EPA: Simplify GHC/Parser.y sL1 This is the next patch in a series simplifying location management in GHC/Parser.y This one simplifies sL1, to use the HasLoc instances introduced in !10743 (closed) - - - - - 3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Explicitly set flags of text sections on Windows The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. - - - - - db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00 nativeGen: Set explicit section types on all platforms - - - - - b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00 Insert documentation into parsed signature modules Causes haddock comments in signature modules to be properly inserted into the AST (just as they are for regular modules) if the `-haddock` flag is given. Also adds a test that compares `-ddump-parsed-ast` output for a signature module to prevent further regressions. Fixes #23315 - - - - - c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00 primops: Introduce unsafeThawByteArray# This addresses an odd asymmetry in the ByteArray# primops, which previously provided unsafeFreezeByteArray# but no corresponding thaw operation. Closes #22710 - - - - - 87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00 testsuite: Elaborate in interface stability README This discussion didn't make it into the original MR. - - - - - e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00 Allow users to override non-essential haddock options in a Flavour We now supply the non-essential options to haddock using the `extraArgs` field, which can be specified in a Flavour so that if an advanced user wants to change how documentation is generated then they can use something other than the `defaultHaddockExtraArgs`. This does have the potential to regress some packaging if a user has overridden `extraArgs` themselves, because now they also need to add the haddock options to extraArgs. This can easily be done by appending `defaultHaddockExtraArgs` to their extraArgs invocation but someone might not notice this behaviour has changed. In any case, I think passing the non-essential options in this manner is the right thing to do and matches what we do for the "ghc" builder, which by default doesn't pass any optmisation levels, and would likewise be very bad if someone didn't pass suitable `-O` levels for builds. Fixes #23625 - - - - - fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00 ghc-prim: Link against libatomic Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures. Unfortunately this made GHC to fail to build on armel, since armel needs libatomic to support atomic operations on 64-bit word sizes. Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic, the same way as we do in rts/rts.cabal. - - - - - 4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00 simplifier: Correct InScopeSet in rule matching The in-scope set passedto the `exprIsLambda_maybe` call lacked all the in-scope binders. @simonpj suggests this fix where we augment the in-scope set with the free variables of expression which fixes this failure mode in quite a direct way. Fixes #23630 - - - - - 5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00 Add a test for #23413 It was fixed by commit e1590ddc661d6: Add the SolverStage monad. - - - - - 7e05f6df by sheaf at 2023-07-21T23:26:56-04:00 Finish migration of diagnostics in GHC.Tc.Validity This patch finishes migrating the error messages in GHC.Tc.Validity to use the new diagnostic infrastructure. It also refactors the error message datatypes for class and family instances, to common them up under a single datatype as much as possible. - - - - - 4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00 ci: Enable some more jobs to run in a marge batch In !10907 I made the majority of jobs not run on a validate pipeline but then forgot to renable a select few jobs on the marge batch MR. - - - - - 026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00 user_guide/flags.py: python-3.12 no longer includes distutils packaging.version seems able to handle this fine - - - - - b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00 ci: Mention ~full-ci label in MR template We mention that if you need a full validation pipeline then you can apply the ~full-ci label to your MR in order to test against the full validation pipeline (like we do for marge). - - - - - 42b05e9b by sheaf at 2023-07-22T12:36:00-04:00 RTS: declare setKeepCAFs symbol Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on the symbol setKeepCAFs in the RTS, which led to undefined symbol errors on Windows, as exhibited by the testcase frontend001. Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix. Fixes #22961 - - - - - a72015d6 by sheaf at 2023-07-22T12:36:01-04:00 Mark plugins-external as broken on Windows This test is broken on Windows, so we explicitly mark it as such now that we stop skipping plugin tests on Windows. - - - - - cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00 Stop marking plugin tests as fragile on Windows Now that b2bb3e62 has landed we are in a better situation with regards to plugins on Windows, allowing us to unmark many plugin tests as fragile. Fixes #16405 - - - - - a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00 Misc cleanup - Remove unused RDR names - Fix typos in comments - Deriving: simplify boxConTbl and remove unused litConTbl - chmod -x GHC/Exts.hs, this seems accidental - - - - - 33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00 Visible forall in types of terms: Part 1 (#22326) This patch implements part 1 of GHC Proposal #281, introducing explicit `type` patterns and `type` arguments. Summary of the changes: 1. New extension flag: RequiredTypeArguments 2. New user-facing syntax: `type p` patterns (represented by EmbTyPat) `type e` expressions (represented by HsEmbTy) 3. Functions with required type arguments (visible forall) can now be defined and applied: idv :: forall a -> a -> a -- signature (relevant change: checkVdqOK in GHC/Tc/Validity.hs) idv (type a) (x :: a) = x -- definition (relevant change: tcPats in GHC/Tc/Gen/Pat.hs) x = idv (type Int) 42 -- usage (relevant change: tcInstFun in GHC/Tc/Gen/App.hs) 4. template-haskell support: TH.TypeE corresponds to HsEmbTy TH.TypeP corresponds to EmbTyPat 5. Test cases and a new User's Guide section Changes *not* included here are the t2t (term-to-type) transformation and term variable capture; those belong to part 2. - - - - - 73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00 Add test for #22424 This is a simple Template Haskell test in which we refer to record selectors by their exact Names, in two different ways. Fixes #22424 - - - - - 83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00 ghc-toolchain: Initial commit - - - - - 31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 ghc-toolchain: Toolchain Selection This commit integrates ghc-toolchain, the brand new way of configuring toolchains for GHC, with the Hadrian build system, with configure, and extends and improves the first iteration of ghc-toolchain. The general overview is * We introduce a program invoked `ghc-toolchain --triple=...` which, when run, produces a file with a `Target`. A `GHC.Toolchain.Target.Target` describes the properties of a target and the toolchain (executables and configured flags) to produce code for that target * Hadrian was modified to read Target files, and will both * Invoke the toolchain configured in the Target file as needed * Produce a `settings` file for GHC based on the Target file for that stage * `./configure` will invoke ghc-toolchain to generate target files, but it will also generate target files based on the flags configure itself configured (through `.in` files that are substituted) * By default, the Targets generated by configure are still (for now) the ones used by Hadrian * But we additionally validate the Target files generated by ghc-toolchain against the ones generated by configure, to get a head start on catching configuration bugs before we transition completely. * When we make that transition, we will want to drop a lot of the toolchain configuration logic from configure, but keep it otherwise. * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine) * We just have a HOST target file, which we use as the target for stage0 * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling) * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST * (for more details on cross-compilation see discussion on !9263) See also * Note [How we configure the bundled windows toolchain] * Note [ghc-toolchain consistency checking] * Note [ghc-toolchain overview] Ticket: #19877 MR: !9263 - - - - - a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Add flag to enable/disable ghc-toolchain based configurations This flag is disabled by default, and we'll use the configure-generated-toolchains by default until we remove the toolchain configuration logic from configure. - - - - - 61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Split ghc-toolchain executable to new packge In light of #23690, we split the ghc-toolchain executable out of the library package to be able to ship it in the bindist using Hadrian. Ideally, we eventually revert this commit. - - - - - 38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00 Ship ghc-toolchain in the bindist Add the ghc-toolchain binary to the binary distribution we ship to users, and teach the bindist configure to use the existing ghc-toolchain. - - - - - 32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00 Kill off gen_bytearray_addr_access_ops.py The relevant primop descriptions are now generated directly by genprimopcode. This makes progress toward fixing #23490, but it is not a complete fix since there is more than one way in which cabal-reinstall (hadrian/build build-cabal) is broken. - - - - - 02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00 compiler: Remove unused `containers.h` include Fixes #23712 - - - - - 822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00 Fix pretty printing of WARNING pragmas There is still something quite unsavoury going on with WARNING pragma printing because the printing relies on the fact that for decl deprecations the SourceText of WarningTxt is empty. However, I let that lion sleep and just fixed things directly. Fixes #23465 - - - - - e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00 ci-images: Bump to commit which has 9.6 image The test-bootstrap job has been failing for 9.6 because we accidentally used a non-master commit. - - - - - bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00 Update bootstrap plans for 9.6.2 and 9.4.5 - - - - - 355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00 EPA: Simplify GHC/Parser.y comb4/comb5 Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with anything with a SrcSpan Also get rid of some more now unnecessary reLoc calls. - - - - - 9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00 compiler: make -ddump-asm work with wasm backend NCG Fixes #23503. Now the `-ddump-asm` flag is respected in the wasm backend NCG, so developers can directly view the generated ASM instead of needing to pass `-S` or `-keep-tmp-files` and manually find & open the assembly file. Ideally, we should be able to output the assembly files in smaller chunks like in other NCG backends. This would also make dumping assembly stats easier. However, this would require a large refactoring, so for short-term debugging purposes I think the current approach works fine. Signed-off-by: Gavin Zhao <git at gzgz.dev> - - - - - 79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00 llvm: Restore accidentally deleted code in 0fc5cb97 Fixes #23711 - - - - - 20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00 configure: Default missing options to False when preparing ghc-toolchain Targets This commit fixes building ghc with 9.2 as the boostrap compiler. The ghc-toolchain patch assumed all _STAGE0 options were available, and forgot to account for this missing information in 9.2. Ghc 9.2 does not have in settings whether ar supports -l, hence can't report it with --info (unliked 9.4 upwards). The fix is to default the missing information (we default "ar supports -l" and other missing options to False) - - - - - fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00 docs: Fix typo - - - - - 503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00 This MR is an implementation of the proposal #516. It adds a warning -Wincomplete-record-selectors for usages of a record field access function (either a record selector or getField @"rec"), while trying to silence the warning whenever it can be sure that a constructor without the record field would not be invoked (which would otherwise cause the program to fail). For example: data T = T1 | T2 {x :: Bool} f a = x a -- this would throw an error g T1 = True g a = x a -- this would not throw an error h :: HasField "x" r Bool => r -> Bool h = getField @"x" j :: T -> Bool j = h -- this would throw an error because of the `HasField` -- constraint being solved See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning. See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details - - - - - af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00 Fix user-facing label in MR template - - - - - 5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00 ci: Test bootstrapping configurations with full-ci and on marge batches There have been two incidents recently where bootstrapping has been broken by removing support for building with 9.2.*. The process for bumping the minimum required version starts with bumping the configure version and then other CI jobs such as the bootstrap jobs have to be updated. We must not silently bump the minimum required version. Now we are running a slimmed down validate pipeline it seems worthwile to test these bootstrap configurations in the full-ci pipeline. - - - - - 25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Remove ghc-9_2_* plans We are anticipating shortly making it necessary to use ghc-9.4 to boot the compiler. - - - - - 2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00 Update bootstrap plans for ghc-platform and ghc-toolchain dependencies Fixes #23735 - - - - - c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00 bootstrap: Disable -selftest flag from bootstrap plans This saves on building one dependency (QuickCheck) which is unecessary for bootstrapping. - - - - - a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00 Link reference paper and package from System.Mem.{StableName,Weak} - - - - - a5319358 by David Knothe at 2023-07-28T13:13:10-04:00 Update Match Datatype EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation. All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list. We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows: data EquationInfo = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo } | EqnDone { eqn_rhs = MatchResult CoreExpr } An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated. - - - - - 86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00 Improve documentation for Data.Fixed - - - - - f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00 ghc-prim: Use C11 atomics Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*` family of C builtins. Here we refactor these to rather use the appropriate C11 atomic equivalents, allowing us to be more explicit about the expected ordering semantics. - - - - - 0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00 Include -haddock in DynFlags fingerprint The -haddock flag determines whether or not the resulting .hi files contain haddock documentation strings. If the existing .hi files do not contain haddock documentation strings and the user requests them, we should recompile. - - - - - 40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00 Bump filepath submodule to 1.4.100.4 Resolves #23741 Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp T10421 T12234 T12425 T13035 T13701 T13719 T16875 T18304 T18698a T18698b T21839c T9198 TcPlugin_RewritePerf hard_hole_fits Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183 - - - - - ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00 Add since pragmas to GHC.IO.Handle.FD - - - - - d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00 Make the occurrence analyser smarter about join points This MR addresses #22404. There is a big Note Note [Occurrence analysis for join points] that explains it all. Significant changes * New field occ_join_points in OccEnv * The NonRec case of occAnalBind splits into two cases: one for existing join points (which does the special magic for Note [Occurrence analysis for join points], and one for other bindings. * mkOneOcc adds in info from occ_join_points. * All "bring into scope" activity is centralised in the new function `addInScope`. * I made a local data type LocalOcc for use inside the occurrence analyser It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn makes computationns over it simpler and more efficient. * I found quite a bit of allocation in GHC.Core.Rules.getRules so I optimised it a bit. More minor changes * I found I was using (Maybe Arity) a lot, so I defined a new data type JoinPointHood and used it everwhere. This touches a lot of non-occ-anal files, but it makes everything more perspicuous. * Renamed data constructor WithUsageDetails to WUD, and WithTailUsageDetails to WTUD This also fixes #21128, on the way. --------- Compiler perf ----------- I spent quite a time on performance tuning, so even though it does more than before, the occurrence analyser runs slightly faster on average. Here are the compile-time allocation changes over 0.5% CoOpt_Read(normal) ghc/alloc 766,025,520 754,561,992 -1.5% CoOpt_Singletons(normal) ghc/alloc 759,436,840 762,925,512 +0.5% LargeRecord(normal) ghc/alloc 1,814,482,440 1,799,530,456 -0.8% PmSeriesT(normal) ghc/alloc 68,159,272 67,519,720 -0.9% T10858(normal) ghc/alloc 120,805,224 118,746,968 -1.7% T11374(normal) ghc/alloc 164,901,104 164,070,624 -0.5% T11545(normal) ghc/alloc 79,851,808 78,964,704 -1.1% T12150(optasm) ghc/alloc 73,903,664 71,237,544 -3.6% GOOD T12227(normal) ghc/alloc 333,663,200 331,625,864 -0.6% T12234(optasm) ghc/alloc 52,583,224 52,340,344 -0.5% T12425(optasm) ghc/alloc 81,943,216 81,566,720 -0.5% T13056(optasm) ghc/alloc 294,517,928 289,642,512 -1.7% T13253-spj(normal) ghc/alloc 118,271,264 59,859,040 -49.4% GOOD T15164(normal) ghc/alloc 1,102,630,352 1,091,841,296 -1.0% T15304(normal) ghc/alloc 1,196,084,000 1,166,733,000 -2.5% T15630(normal) ghc/alloc 148,729,632 147,261,064 -1.0% T15703(normal) ghc/alloc 379,366,664 377,600,008 -0.5% T16875(normal) ghc/alloc 32,907,120 32,670,976 -0.7% T17516(normal) ghc/alloc 1,658,001,888 1,627,863,848 -1.8% T17836(normal) ghc/alloc 395,329,400 393,080,248 -0.6% T18140(normal) ghc/alloc 71,968,824 73,243,040 +1.8% T18223(normal) ghc/alloc 456,852,568 453,059,088 -0.8% T18282(normal) ghc/alloc 129,105,576 131,397,064 +1.8% T18304(normal) ghc/alloc 71,311,712 70,722,720 -0.8% T18698a(normal) ghc/alloc 208,795,112 210,102,904 +0.6% T18698b(normal) ghc/alloc 230,320,736 232,697,976 +1.0% BAD T19695(normal) ghc/alloc 1,483,648,128 1,504,702,976 +1.4% T20049(normal) ghc/alloc 85,612,024 85,114,376 -0.6% T21839c(normal) ghc/alloc 415,080,992 410,906,216 -1.0% GOOD T4801(normal) ghc/alloc 247,590,920 250,726,272 +1.3% T6048(optasm) ghc/alloc 95,699,416 95,080,680 -0.6% T783(normal) ghc/alloc 335,323,384 332,988,120 -0.7% T9233(normal) ghc/alloc 709,641,224 685,947,008 -3.3% GOOD T9630(normal) ghc/alloc 965,635,712 948,356,120 -1.8% T9675(optasm) ghc/alloc 444,604,152 428,987,216 -3.5% GOOD T9961(normal) ghc/alloc 303,064,592 308,798,800 +1.9% BAD WWRec(normal) ghc/alloc 503,728,832 498,102,272 -1.1% geo. mean -1.0% minimum -49.4% maximum +1.9% In fact these figures seem to vary between platforms; generally worse on i386 for some reason. The Windows numbers vary by 1% espec in benchmarks where the total allocation is low. But the geom mean stays solidly negative, which is good. The "increase/decrease" list below covers all platforms. The big win on T13253-spj comes because it has a big nest of join points, each occurring twice in the next one. The new occ-anal takes only one iteration of the simplifier to do the inlining; the old one took four. Moreover, we get much smaller code with the new one: New: Result size of Tidy Core = {terms: 429, types: 84, coercions: 0, joins: 14/14} Old: Result size of Tidy Core = {terms: 2,437, types: 304, coercions: 0, joins: 10/10} --------- Runtime perf ----------- No significant changes in nofib results, except a 1% reduction in compiler allocation. Metric Decrease: CoOpt_Read T13253-spj T9233 T9630 T9675 T12150 T21839c LargeRecord MultiComponentModulesRecomp T10421 T13701 T10421 T13701 T12425 Metric Increase: T18140 T9961 T18282 T18698a T18698b T19695 - - - - - 42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00 Improve documentation around IOException and ioe_filename See: * https://github.com/haskell/core-libraries-committee/issues/189 * https://github.com/haskell/unix/pull/279 * https://github.com/haskell/unix/pull/289 - - - - - 33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00 JS: implement getMonotonicTime (fix #23687) - - - - - d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00 Implementation of the Deprecated Instances proposal #575 This commit implements the ability to deprecate certain instances, which causes the compiler to emit the desired deprecation message whenever they are instantiated. For example: module A where class C t where instance {-# DEPRECATED "dont use" #-} C Int where module B where import A f :: C t => t f = undefined g :: Int g = f -- "dont use" emitted here The implementation is as follows: - In the parser, we parse deprecations/warnings attached to instances: instance {-# DEPRECATED "msg" #-} Show X deriving instance {-# WARNING "msg2" #-} Eq Y (Note that non-standalone deriving instance declarations do not support this mechanism.) - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`). In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`), we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too). - Finally, when we solve a constraint using such an instance, in `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning that was stored in `ClsInst`. Note that we only emit a warning when the instance is used in a different module than it is defined, which keeps the behaviour in line with the deprecation of top-level identifiers. Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com> - - - - - d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00 compiler: Style fixes - - - - - 7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Fix implicit cast This ensures that Task.h can be built with a C++ compiler. - - - - - d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Fix warning in hs_try_putmvar001 - - - - - d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00 testsuite: Add AtomicModifyIORef test - - - - - f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce NO_WARN macro This allows fine-grained ignoring of warnings. - - - - - 497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Simplify atomicModifyMutVar2# implementation Previously we would perform a redundant load in the non-threaded RTS in atomicModifyMutVar2# implementation for the benefit of the non-moving GC's write barrier. Eliminate this. - - - - - 52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce more principled fence operations - - - - - cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Introduce SET_INFO_RELAXED - - - - - 6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00 rts: Style fixes - - - - - 4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00 codeGen/tsan: Rework handling of spilling - - - - - f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More debug information - - - - - df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00 Improve TSAN documentation - - - - - fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00 hadrian: More selective TSAN instrumentation - - - - - 465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00 EPA: Provide correct annotation span for ImportDecl Use the whole declaration, rather than just the span of the 'import' keyword. Metric Decrease: T9961 T5205 Metric Increase: T13035 - - - - - ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00 Add cases to T23279: HasField for deprecated record fields This commit adds additional tests from ticket #23279 to ensure that we don't regress on reporting deprecated record fields in conjunction with HasField, either when using overloaded record dot syntax or directly through `getField`. Fixes #23279 - - - - - 00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00 AArch NCG: Pure refactor Combine some alternatives. Add some line breaks for overly long lines - - - - - 8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - 74a882dc by MorrowM at 2023-08-02T06:00:03-04:00 Add a RULE to make lookup fuse See https://github.com/haskell/core-libraries-committee/issues/175 Metric Increase: T18282 - - - - - cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00 hadrian: Ensure that way-flags are passed to CC Previously the way-specific compilation flags (e.g. `-DDEBUG`, `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant that C dependency files would not correctly reflect dependencies predicated on the way, resulting in the rather painful #23554. Closes #23554. - - - - - 622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00 Native 32-bit Enum Int64/Word64 instances This commits adds more performant Enum Int64 and Enum Word64 instances for 32-bit platforms, replacing the Integer-based implementation. These instances are a copy of the Enum Int and Enum Word instances with minimal changes to manipulate Int64 and Word64 instead. On i386 this yields a 1.5x performance increase and for the JavaScript back end it even yields a 5.6x speedup. Metric Decrease: T18964 - - - - - c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00 JS: fix typos in constants (#23650) - - - - - b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00 JavaScript: update MK_TUP macros to use current tuple constructors (#23659) - - - - - 28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00 ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job Warnings when building Hadrian can end up cluttering the output of HLS, and we've had bug reports in the past about these warnings when building Hadrian. It would be nice to turn on -Werror on at least one build of Hadrian in CI to avoid a patch introducing warnings when building Hadrian. Fixes #23638 - - - - - aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that TSAN is aware of writeArray# write barriers By using a proper release store instead of a fence. - - - - - 453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00 codeGen: Ensure that array reads have necessary barriers This was the cause of #23541. - - - - - 93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Add test for #23550 - - - - - 6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00 Desugar non-recursive lets to non-recursive lets (take 2) This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And takes care of the case that I missed in my previous attempt. Namely the case of an AbsBinds with no type variables and no dictionary variable. Ironically, the comment explaining why non-recursive lets were desugared to recursive lets were pointing specifically at this case as the reason. I just failed to understand that it was until Simon PJ pointed it out to me. See #23550 for more discussion. - - - - - ff81d53f by jade at 2023-08-02T06:05:20-04:00 Expand documentation of List & Data.List This commit aims to improve the documentation and examples of symbols exported from Data.List - - - - - fa4e5913 by Jade at 2023-08-02T06:06:03-04:00 Improve documentation of Semigroup & Monoid This commit aims to improve the documentation of various symbols exported from Data.Semigroup and Data.Monoid - - - - - e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00 Desugar bindings in the context of their evidence Closes #23172 - - - - - 481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00 Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of incoherent instances Fixes #23287 - - - - - d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00 base: Improve String & IsString documentation - - - - - 01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00 rts/win32: Ensure reliability of IO manager shutdown When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an `IO_MANAGER_DIE` event to the IO manager thread using the `io_manager_event` event object. Finally, it will closes the event object, and invalidate `io_manager_event`. Previously, `readIOManagerEvent` would see that `io_manager_event` is invalid and return `0`, suggesting that everything is right with the world. This meant that if `ioManagerDie` invalidated the handle before the event manager was blocked on the event we would end up in a situation where the event manager would never realize it was asked to shut down. Fix this by ensuring that `readIOManagerEvent` instead returns `IO_MANAGER_DIE` when we detect that the event object has been invalidated by `ioManagerDie`. Fixes #23691. - - - - - fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00 Look through TH splices in splitHsApps This modifies `splitHsApps` (a key function used in typechecking function applications) to look through untyped TH splices and quasiquotes. Not doing so was the cause of #21077. This builds on !7821 by making `splitHsApps` match on `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as part of invoking the TH splice. See the new `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Along the way, I needed to make the type of `splitHsApps.set` slightly more general to accommodate the fact that the location attached to a quasiquote is a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`. Fixes #21077. - - - - - e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00 Bump deepseq submodule to 1.5. And bump bounds (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b) - - - - - cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00 configure: Bump minimal boot GHC version to 9.4 (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e) - - - - - 83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00 template-haskell: Bump version to 2.21.0.0 Bumps exceptions submodule. (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb) - - - - - 1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00 base: Bump version to 4.19 Updates all boot library submodules. (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143) - - - - - 3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Normalise versions more aggressively In backpack hashes can contain `+` characters. (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93) - - - - - d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Declare bkpcabal08 as fragile Due to spurious output changes described in #23648. (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b) - - - - - e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00 gitlab-ci: Only mark linker_unload_native as broken in static jobs This test passes on dynamically-linked Alpine. (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87) - - - - - 8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite: Update base-exports - - - - - 4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00 testsuite/interface-stability: normalise versions This eliminates spurious changes from version bumps. - - - - - 0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00 linker/PEi386: Don't sign-extend symbol section number Previously we incorrectly interpreted PE section numbers as signed values. However, this isn't the case; rather, it's an unsigned 16-bit number with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941 as the linker would conclude that the sections were invalid. Fixing this required quite a bit of refactoring. Closes #22941. - - - - - fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00 testsuite: Mark MulMayOflo_full as broken rather than skipping To ensure that we don't accidentally fix it. See #23742. - - - - - 824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00 nativeGen/AArch64: Fix sign extension in MulMayOflo Previously the 32-bit implementations of MulMayOflo would use the a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11 produces. Also similarly rework the 16- and 8-bit cases. This now passes the MulMayOflo tests in ghc/test-primops> in all four widths, including the precision tests. Fixes #23721. - - - - - 1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00 Fix haddock markup in code example for coerce - - - - - 46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00 Fix (~) and (@) infix operators in TH splices (#23748) 8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept the following infix operators: a ~ b = () a @ b = () But not if TH is used to generate those declarations: $([d| a ~ b = () a @ b = () |]) -- Test.hs:5:2: error: [GHC-55017] -- Illegal variable name: ‘~’ -- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.() This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme - - - - - a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00 [#23663] Show Flag Suggestions in GHCi Makes suggestions when using `:set` in GHCi with a misspelled flag. This mirrors how invalid flags are handled when passed to GHC directly. Logic for producing flag suggestions was moved to GHC.Driver.Sesssion so it can be shared. resolves #23663 - - - - - 03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00 Improve ghc-toolchain validation configure warning Fixes the layout of the ghc-toolchain validation warning produced by configure. - - - - - de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00 EPA make getLocA a synonym for getHasLoc This is basically a no-op change, but allows us to make future changes that can rely on the HasLoc instances And I presume this means we can use more precise functions based on class resolution, so the Windows CI build reports Metric Decrease: T12234 T13035 - - - - - 3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00 ghc-platform: Add upper bound on base Hackage upload requires this. - - - - - 8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00 Adjust and clarify handling of primop effects Fixes #17900; fixes #20195. The existing "can_fail" and "has_side_effects" primop attributes that previously governed this were used in inconsistent and confusingly-documented ways, especially with regard to raising exceptions. This patch replaces them with a single "effect" attribute, which has four possible values: NoEffect, CanFail, ThrowsException, and ReadWriteEffect. These are described in Note [Classifying primop effects]. A substantial amount of related documentation has been re-drafted for clarity and accuracy. In the process of making this attribute format change for literally every primop, several existing mis-classifications were detected and corrected. One of these mis-classifications was tagToEnum#, which is now considered CanFail; this particular fix is known to cause a regression in performance for derived Enum instances. (See #23782.) Fixing this is left as future work. New primop attributes "cheap" and "work_free" were also added, and used in the corresponding parts of GHC.Core.Utils. In view of their actual meaning and uses, `primOpOkForSideEffects` and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard` and `exprOkToDiscard`, respectively. Metric Increase: T21839c - - - - - 41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00 Update inert_solved_dicts for ImplicitParams When adding an implicit parameter dictionary to the inert set, we must make sure that it replaces any previous implicit parameter dictionaries that overlap, in order to get the appropriate shadowing behaviour, as in let ?x = 1 in let ?x = 2 in ?x We were already doing this for inert_cans, but we weren't doing the same thing for inert_solved_dicts, which lead to the bug reported in #23761. The fix is thus to make sure that, when handling an implicit parameter dictionary in updInertDicts, we update **both** inert_cans and inert_solved_dicts to ensure a new implicit parameter dictionary correctly shadows old ones. Fixes #23761 - - - - - 43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00 Bump bytestring submodule to 0.11.5.1 - - - - - 91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00 Initial commit of Note [Thunks, blackholes, and indirections] This Note attempts to summarize the treatment of thunks, thunk update, and indirections. This fell out of work on #23185. - - - - - 8d686854 by sheaf at 2023-08-05T01:06:54-04:00 Remove zonk in tcVTA This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its accompanying Note [Visible type application zonk]. Indeed, this zonk is no longer necessary, as we no longer maintain the invariant that types are well-kinded without zonking; only that typeKind does not crash; see Note [The Purely Kinded Type Invariant (PKTI)]. This commit removes this zonking step (as well as a secondary zonk), and replaces the aforementioned Note with the explanatory Note [Type application substitution], which justifies why the substitution performed in tc_inst_forall_arg remains valid without this zonking step. Fixes #23661 - - - - - 19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00 Bump nofib submodule Ensuring that nofib can be build using the same range of bootstrap compilers as GHC itself. - - - - - aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00 JS: Improve compatibility with recent emsdk The JavaScript code in libraries/base/jsbits/base.js had some hardcoded offsets for fields in structs, because we expected the layout of the data structures to remain unchanged. Emsdk 3.1.42 changed the layout of the stat struct, breaking this assumption, and causing code in .hsc files accessing the stat struct to fail. This patch improves compatibility with recent emsdk by removing the assumption that data layouts stay unchanged: 1. offsets of fields in structs used by JavaScript code are now computed by the configure script, so both the .js and .hsc files will automatically use the new layout if anything changes. 2. the distrib/configure script checks that the emsdk version on a user's system is the same version that a bindist was booted with, to avoid data layout inconsistencies See #23641 - - - - - b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00 JS: Fix missing local variable declarations This fixes some missing local variable declarations that were found by running the testsuite in strict mode. Fixes #23775 - - - - - 6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00 Update Haddock submodule to fix #23368 This submodule update adds the following three commits: bbf1c8ae - Check for puns 0550694e - Remove fake exports for (~), List, and Tuple<n> 5877bceb - Fix pretty-printing of Solo and MkSolo These commits fix the issues with Haddock HTML rendering reported in ticket #23368. Fixes #23368 - - - - - 5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00 Revert "Bump bytestring submodule to 0.11.5.1" This reverts commit 43578d60bfc478e7277dcd892463cec305400025. Fixes #23789 - - - - - 01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00 configure: Derive library version from ghc-prim.cabal.in Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon it. Closes #23726. - - - - - 3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00 tcExpr: Push expected types for untyped TH splices inwards In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much simpler case that simply delegates to `tcApp`. Although this passed the test suite at the time, this was actually an error, as the previous `tcExpr` case was critically pushing the expected type inwards. This actually matters for programs like the one in #23796, which GHC would not accept with type inference alone—we need full-blown type _checking_ to accept these. I have added back the previous `tcExpr` case for `HsUntypedSplice` and now explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and another in `splitHsApps`) in `Note [Looking through Template Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`. Fixes #23796. - - - - - 0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00 Compute all emitted diagnostic codes This commit introduces in GHC.Types.Error.Codes the function constructorCodes :: forall diag. (...) => Map DiagnosticCode String which computes a collection of all the diagnostic codes that correspond to a particular type. In particular, we can compute the collection of all diagnostic codes emitted by GHC using the invocation constructorCodes @GhcMessage We then make use of this functionality in the new "codes" test which checks consistency and coverage of GHC diagnostic codes. It performs three checks: - check 1: all non-outdated GhcDiagnosticCode equations are statically used. - check 2: all outdated GhcDiagnosticCode equations are statically unused. - check 3: all statically used diagnostic codes are covered by the testsuite (modulo accepted exceptions). - - - - - 4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00 numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int) Currently a negative exponent less than `minBound :: Int` results in Infinity, which is very surprising and obviously wrong. ``` λ> read "1e-9223372036854775808" :: Double 0.0 λ> read "1e-9223372036854775809" :: Double Infinity ``` There is a further edge case where the exponent can overflow when increased by the number of tens places in the integer part, or underflow when decreased by the number of leading zeros in the fractional part if the integer part is zero: ``` λ> read "10e9223372036854775807" :: Double 0.0 λ> read "0.01e-9223372036854775808" :: Double Infinity ``` To resolve both of these issues, perform all arithmetic and comparisons involving the exponent in type `Integer`. This approach also eliminates the need to explicitly check the exponent against `maxBound :: Int` and `minBound :: Int`, because the allowed range of the exponent (i.e. the result of `floatRange` for the target floating point type) is certainly within those bounds. This change implements CLC proposal 192: https://github.com/haskell/core-libraries-committee/issues/192 - - - - - 6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00 EPA: Remove Location from WarningTxt source This is not needed. - - - - - 1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00 Cleanup a TODO introduced in 1f94e0f7 The change must have slipped through review of !4412 - - - - - 2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00 More explicit strictness in GHC.Real - - - - - ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00 exprIsTrivial: Factor out shared implementation The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has been bugging me for a long time. This patch introduces an inlinable worker function `trivial_expr_fold` acting as the single, shared decision procedure of triviality. It "returns" a Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar code as before. (Better code, even, in the case of `getIdFromTrivialExpr` which presently allocates a `Just` constructor that cancels away after this patch.) - - - - - d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00 Simplify: Simplification of arguments in a single function The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`, which seems to be the main way to simplify args. Hence I consolidated the code path to call `simplArg`, too, renaming to `simplLazyArg`. - - - - - 8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Core.Ppr: Omit case binder for empty case alternatives A minor improvement to pretty-printing - - - - - d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend ... because those coerce between incompatible/unknown PrimReps. - - - - - f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Inlining literals into boring contexts is OK - - - - - 4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Clarify floating of unsafeEqualityProofs (#23754) - - - - - b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00 Kill SetLevel.notWorthFloating.is_triv (#23270) We have had it since b84ba676034, when it operated on annotated expressions. Nowadays it operates on vanilla `CoreExpr` though, so we should just call `exprIsTrivial`; thus handling empty cases and string literals correctly. - - - - - 7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00 ANFise string literal arguments (#23270) This instates the invariant that a trivial CoreExpr translates to an atomic StgExpr. Nice. Annoyingly, in -O0 we sometimes generate ``` foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat } ``` which makes it a bit harder to spot that we can emit a standard `stg_unpack_cstring` thunk. Fixes #23270. - - - - - 357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00 Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) - - - - - 59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. We do also give the same treatment to unsafeCoerce proofs and treat them as trivial iff their RHS is trivial. It is also both much simpler to describe than the previous mechanism of emitting an unsafe coercion and simpler to implement, removing quite a bit of commentary and `CorePrepProv`. In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier iteration due to #17910. E.g., FloatOut produces a binding ``` lvl_s6uK [Occ=Once1] :: GHC.Types.Int [LclId] lvl_s6uK = GHC.Types.I# 2# lvl_s6uL [Occ=Once1] :: GHC.Types.Any [LclId] lvl_s6uL = case Unsafe.Coerce.unsafeEqualityProof ... of { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...) } ``` That occurs once and hence is pre-inlined unconditionally in the next Simplifier pass. It's non-trivial to find a way around that, but not really harmful otherwise. Hence we accept a 1.2% increase on some architectures. Metric Increase: LargeRecord - - - - - 00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00 CorePrep: Eta expand arguments (#23083) Previously, we'd only eta expand let bindings and lambdas, now we'll also eta expand arguments such as in T23083: ```hs g f h = f (h `seq` (h $)) ``` Unless `-fpedantic-bottoms` is set, we'll now transform to ```hs g f h = f (\eta -> h eta) ``` in CorePrep. See the new `Note [Eta expansion of arguments in CorePrep]` for the details. We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions in T4801 and T5321FD. Fixes #23083. - - - - - bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00 Bump bytestring submodule to 0.11.5, again Fixes #23789. The bytestring commit used here is unreleased; a release can be made when necessary. - - - - - 7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00 Serialize CmmRetInfo in .rodata The handling of case was missing. - - - - - 0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Reference StgRetFun payload by its struct field address This is easier to grasp than relative pointer offsets. - - - - - f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better variable name: u -> frame The 'u' was likely introduced by copy'n'paste. - - - - - 0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00 Make checkSTACK() public Such that it can also be used in tests. - - - - - 7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00 Publish stack related fields in DerivedConstants.h These will be used in ghc-heap to decode these parts of the stack. - - - - - 907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00 ghc-heap: Decode StgStack and its stack frames Previously, ghc-heap could only decode heap closures. The approach is explained in detail in note [Decoding the stack]. - - - - - 6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00 Remove RetFunType from RetFun stack frame representation It's a technical detail. The single usage is replaced by a predicate. - - - - - 006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00 Better parameter name The call-site uses the term "offset", too. - - - - - d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00 Make closure boxing pure There seems to be no need to do something complicated. However, the strictness of the closure pointer matters, otherwise a thunk gets decoded. - - - - - 8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00 Document entertainGC in test It wasn't obvious why it's there and what its role is. Also, increase the "entertainment level" a bit. I checked in STG and Cmm dumps that this really generates closures (and is not e.g. constant folded away.) - - - - - cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -dipe-stats flag This is useful for seeing which info tables have information. - - - - - 261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00 Add -finfo-table-map-with-fallback -finfo-table-map-with-stack The -fno-info-table-map-with-stack flag omits STACK info tables from the info table map, and the -fno-info-table-map-with-fallback flag omits info tables with defaulted source locations from the map. In a test on the Agda codebase the build results were about 7% smaller when both of those types of tables were omitted. Adds a test that verifies that passing each combination of these flags results in the correct output for -dipe-stats, which is disabled for the js backend since profiling is not implemented. This commit also refactors a lot of the logic around extracting info tables from the Cmm results and building the info table map. This commit also fixes some issues in the users guide rst source to fix warnings that were noticed while debugging the documentation for these flags. Fixes #23702 - - - - - d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00 Add changelog entry for specialised Enum Int64/Word64 instances - - - - - 52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00 Fix -ddump-to-file and -ddump-timings interaction (#20316) - - - - - 1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00 Update release notes (#20316) - - - - - 8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00 base: Add changelog entry for CLC #188 This proposal modified the implementations of copyBytes, moveBytes and fillBytes (as detailed in the proposal) https://github.com/haskell/core-libraries-committee/issues/188 - - - - - 026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00 packaging: Build manpage in separate directory to other documentation We were installing two copies of the manpage: * One useless one in the `share/doc` folder, because we copy the doc/ folder into share/ * The one we deliberately installed into `share/man` etc The solution is to build the manpage into the `manpage` directory when building the bindist, and then just install it separately. Fixes #23707 - - - - - 524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00 Report deprecated fields bound by record wildcards when used This commit ensures that we emit the appropriate warnings when a deprecated record field bound by a record wildcard is used. For example: module A where data Foo = Foo {x :: Int, y :: Bool, z :: Char} {-# DEPRECATED x "Don't use x" #-} {-# WARNING y "Don't use y" #-} module B where import A foo (Foo {..}) = x This will cause us to emit a "Don't use x" warning, with location the location of the record wildcard. Note that we don't warn about `y`, because it is unused in the RHS of `foo`. Fixes #23382 - - - - - d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00 Add zstd suffix to jobs which rely on zstd This was causing some confusion as the job was named simply "x86_64-linux-deb10-validate", which implies a standard configuration rather than any dependency on libzstd. - - - - - e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Always run project-version job This is needed for the downstream test-primops pipeline to workout what the version of a bindist produced by a pipeline is. - - - - - f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rework how jobs-metadata.json is generated * We now represent a job group a triple of Maybes, which makes it easier to work out when jobs are enabled/disabled on certain pipelines. ``` data JobGroup a = StandardTriple { v :: Maybe (NamedJob a) , n :: Maybe (NamedJob a) , r :: Maybe (NamedJob a) } ``` * `jobs-metadata.json` generation is reworked using the following algorithm. - For each pipeline type, find all the platforms we are doing builds for. - Select one build per platform - Zip together the results This way we can choose different pipelines for validate/nightly/release which makes the metadata also useful for validate pipelines. This feature is used by the test-primops downstream CI in order to select the right bindist for testing validate pipelines. This makes it easier to inspect which jobs are going to be enabled on a particular pipeline. - - - - - f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00 gen_ci: Rules rework In particular we now distinguish between whether we are dealing with a Nightly/Release pipeline (which labels don't matter for) and a validate pipeline where labels do matter. The overall goal here is to allow a disjunction of labels for validate pipelines, for example, > Run a job if we have the full-ci label or test-primops label Therefore the "ValidateOnly" rules are treated as a set of disjunctions rather than conjunctions like before. What this means in particular is that if we want to ONLY run a job if a label is set, for example, "FreeBSD" label then we have to override the whole label set. Fixes #23772 - - - - - d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: set -e for lint-ci-config scripts - - - - - 994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00 ci: Fix job metadata generation - - - - - e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00 users-guide: Note that GHC2021 doesn't include ExplicitNamespaces As noted in #23801. - - - - - d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Support both distutils and packaging As noted in #23818, some old distributions (e.g. Debian 9) only include `distutils` while newer distributions only include `packaging`. Fixes #23818. - - - - - 1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00 users-guide: Ensure extlinks is compatible with Sphinx <4 The semantics of the `extlinks` attribute annoyingly changed in Sphinx 4. Reflect this in our configuration. See #22690. Fixes #23807. - - - - - 173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00 ci: Run full-ci on master and release branches Fixes #23737 - - - - - bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00 Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp - - - - - 662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Match CPP args with configure script At the moment we need ghc-toolchain to precisely match the output as provided by the normal configure script. The normal configure script (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc so we match that logic exactly in ghc-toolchain. The old implementation (which checks if certain flags are supported) is better but for now we have to match to catch any potential errors in the configuration. Ticket: #23720 - - - - - 09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Fix `-Wl,--no-as-needed` check The check was failing because the args supplied by $$1 were quoted which failed because then the C compiler thought they were an input file. Fixes #23720 - - - - - 2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00 configure: Add flag which turns ghc-toolchain check into error We want to catch these errors in CI, but first we need to a flag which turns this check into an error. - - - - - 6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs This will cause any CI job to fail if we have a mismatch between what ghc-toolchain reports and what ./configure natively reports. Fixing these kinds of issues is highest priority for 9.10 release. - - - - - 12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Pass user-specified options to ghc-toolchain The current user interface to configuring target toolchains is `./configure`. In !9263 we added a new tool to configure target toolchains called `ghc-toolchain`, but the blessed way of creating these toolchains is still through configure. However, we were not passing the user-specified options given with the `./configure` invocation to the ghc-toolchain tool. This commit remedies that by storing the user options and environment variables in USER_* variables, which then get passed to GHC-toolchain. The exception to the rule is the windows bundled toolchain, which overrides the USER_* variables with whatever flags the windows bundled toolchain requires to work. We consider the bundled toolchain to be effectively the user specifying options, since the actual user delegated that configuration work. Closes #23678 - - - - - f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Parse javascript and ghcjs as a Arch and OS - - - - - 8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 ghc-toolchain: Fix ranlib option - - - - - 31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00 Check Link Works with -Werror - - - - - bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Only check for no_compact_unwind support on darwin While writing ghc-toolchain we noticed that the FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as -n o_compact_unwind, which is a valid argument. Fixes #23676 - - - - - 0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add some javascript special cases to ghc-toolchain On javascript there isn't a choice of toolchain but some of the configure checks were not accurately providing the correct answer. 1. The linker was reported as gnu LD because the --version output mentioned gnu LD. 2. The --target flag makes no sense on javascript but it was just ignored by the linker, so we add a special case to stop ghc-toolchain thinking that emcc supports --target when used as a linker. - - - - - a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00 check for emcc in gnu_LD check - - - - - 50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00 Add ldOverrideWhitelist to only default to ldOverride on windows/linux On some platforms - ie darwin, javascript etc we really do not want to allow the user to use any linker other than the default one as this leads to all kinds of bugs. Therefore it is a bit more prudant to add a whitelist which specifies on which platforms it might be possible to use a different linker. - - - - - a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00 Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS A normal triple may look like x86_64-unknown-linux but when cross-compiling you get $target set to a quad such as.. aarch64-unknown-linux-gnu Which should also match this check. - - - - - c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00 ghc-toolchain: Pass ld-override onto ghc-toolchain - - - - - 039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00 ld override: Make whitelist override user given option - - - - - d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Add format mode to normalise differences before diffing. The "format" mode takes an "--input" and "--ouput" target file and formats it. This is intended to be useful on windows where the configure/ghc-toolchain target files can't be diffed very easily because the path separators are different. - - - - - f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta We needed to remove -Wno-unused-command-line-argument from the arguments passed in order for the configure check to report correctly. See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335 - - - - - 92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: MergeObjsCmd - distinguish between empty string and unset variable If `MergeObjsCmd` is explicitly set to the empty string then we should assume that MergeObjs is just not supported. This is especially important for windows where we set MergeObjsCmd to "" in m4/fp_setup_windows_toolchain.m4. - - - - - 3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00 configure: Add proper check to see if object merging works - - - - - 08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00 ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing If the user explicitly chooses to not set a MergeObjsCmd then it is correct to use Nothing for tgtMergeObjs field in the Target file. - - - - - c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00 HsCppArgs: Augment the HsCppOptions This is important when we pass -I when setting up the windows toolchain. - - - - - 294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00 Set USER_CPP_ARGS when setting up windows toolchain - - - - - bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 Improve handling of Cc as a fallback - - - - - f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00 ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags In ghc-toolchain, we were only /not/ configuring required flags when the user specified any flags at all for the of the HsCpp and Cpp tools. Otherwise, the linker takes into consideration the user specified flags to determine whether to search for a better linker implementation, but already configured the remaining GHC and platform-specific flags regardless of the user options. Other Tools consider the user options as a baseline for further configuration (see `findProgram`), so #23689 is not applicable. Closes #23689 - - - - - bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00 CPP_ARGS: Put new options after user specified options This matches up with the behaviour of ghc-toolchain, so that the output of both matches. - - - - - a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00 If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting Fixes #23821. - - - - - e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00 JS: implement openat(AT_FDCWD...) (#23697) Use `openSync` to implement `openat(AT_FDCWD...)`. - - - - - a975c663 by sheaf at 2023-08-17T07:54:47-04:00 Use unsatisfiable for missing methods w/ defaults When a class instance has an Unsatisfiable constraint in its context and the user has not explicitly provided an implementation of a method, we now always provide a RHS of the form `unsatisfiable @msg`, even if the method has a default definition available. This ensures that, when deferring type errors, users get the appropriate error message instead of a possible runtime loop, if class default methods were defined recursively. Fixes #23816 - - - - - 45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-internal: Initial commit of the skeleton - - - - - 88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00 ghc-experimental: Initial commit - - - - - 664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite/cloneStackLib: Fix incorrect format specifiers - - - - - eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00 rts/ipe: Fix const-correctness of IpeBufferListNode Both info tables and the string table should be `const` - - - - - 78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Drop dead debugging utilities These are largely superceded by support in the ghc-utils GDB extension. - - - - - 3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00 nonmoving: Refactor management of mark thread Here we refactor that treatment of the worker thread used by the nonmoving GC for concurrent marking, avoiding creating a new thread with every major GC cycle. As well, the new scheme is considerably easier to reason about, consolidating all state in one place, accessed via a small set of accessors with clear semantics. - - - - - 88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00 testsuite: Skip T23221 in nonmoving GC ways This test is very dependent upon GC behavior. - - - - - 381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00 ghc-heap: Don't expose stack dirty and marking fields These are GC metadata and are not relevant to the end-user. Moreover, they are unstable which makes ghc-heap harder to test than necessary. - - - - - 16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00 bump process submodule to include macOS fix and JS support - - - - - b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00 ci: Add support for triggering test-primops pipelines This commit adds 4 ways to trigger testing with test-primops. 1. Applying the ~test-primops label to a validate pipeline. 2. A manually triggered job on a validate pipeline 3. A nightly pipeline job 4. A release pipeline job Fixes #23695 - - - - - 32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00 Add test-primops label support The test-primops CI job requires some additional builds in the validation pipeline, so we make sure to enable these jobs when test-primops label is set. - - - - - 73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch ncg: Optimize immediate use for address calculations" This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631. See #23793 - - - - - 5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "AArch NCG: Pure refactor" This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d. See #23793 - - - - - 02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00 Revert "Aarch64 NCG: Use encoded immediates for literals." This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c. See #23793 ------------------------- Metric Increase: T4801 T5321FD T5321Fun ------------------------- - - - - - 7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00 ci: Remove manually triggered test-ci job This doesn't work on slimmed down pipelines as the needed jobs don't exist. If you want to run test-primops then apply the label. - - - - - 76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00 Remove Ptr example from roles docs - - - - - 069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00 Guard against duplicate pipelines in forks - - - - - f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00 dump-decls: fix "Ambiguous module name"-error Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package. ``` dump-decls: <no location info>: error: Ambiguous module name `System.Console.ANSI.Types': it was found in multiple packages: ansi-terminal-0.11.4 ansi-terminal-types-0.11.5 ``` - - - - - edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00 Fix MultiWayIf linearity checking (#23814) Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io> - - - - - 4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00 Update `Control.Concurrent.*` documentation - - - - - 015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00 Support 128-bit SIMD on AArch64 via LLVM backend - - - - - 52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00 Testsuite cleanup - Remove misleading help text in perf_notes, ways are not metrics - Remove no_print_summary - this was used for Phabricator - In linters tests, run 'git ls-files' just once. Previously, it was called on each has_ls_files() - Add ghc-prim.cabal to gitignore, noticed in #23726 - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd - - - - - ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00 EPA: Use Introduce [DeclTag] in AnnSortKey The AnnSortKey is used to keep track of the order of declarations for printing when the container has split them apart. This applies to HsValBinds and ClassDecl, ClsInstDecl. When making modifications to the list of declarations, the new order must be captured for when it must be printed. For each list of declarations (binds and sigs for a HsValBind) we can just store the list in order. To recreate the list when printing, we must merge them, and this is what the AnnSortKey records. It used to be indexed by SrcSpan, we now simply index by a marker as to which list to take the next item from. - - - - - e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00 Don't attempt pattern synonym error recovery This commit gets rid of the pattern synonym error recovery mechanism (recoverPSB). The rationale is that the fake pattern synonym binding that the recovery mechanism introduced could lead to undesirable knock-on errors, and it isn't really feasible to conjure up a satisfactory binding as pattern synonyms can be used both in expressions and patterns. See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn. It isn't such a big deal to eagerly fail compilation on a pattern synonym that doesn't typecheck anyway. Fixes #23467 - - - - - 6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00 base: Don't use Data.ByteString.Internals.memcpy This function is now deprecated from `bytestring`. Use `Foreign.Marshal.Utils.copyBytes` instead. Fixes #23880. - - - - - 0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Uniformly pass buildOptions to all builders in runBuilder In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo. This leads to hard to diagnose bugs as any build options you pass with runBuilderWithCmdOptions are ignored for many builders. Solution: Uniformly pass buildOptions to the invocation of cmd. Fixes #23845 - - - - - 9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Abstract windows toolchain setup This commit splits up the windows toolchain setup logic into two functions. * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if it isn't already downloaded * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point to the correct place FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw toolchain and also the eventual location where we will install the toolchain in the installed bindist. This is the first step towards #23608 - - - - - 6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00 Generate build.mk for bindists The config.mk.in script was relying on some variables which were supposed to be set by build.mk but therefore never were when used to install a bindist. Specifically * BUILD_PROF_LIBS to determine whether we had profiled libraries or not * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or not Not only were these never set but also not really accurate because you could have shared libaries but still statically linked ghc executable. In addition variables like GhcLibWays were just never used, so those have been deleted from the script. Now instead we generate a build.mk file which just directly specifies which RtsWays we have supplied in the bindist and whether we have DYNAMIC_GHC_PROGRAMS. - - - - - fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add reloc-binary-dist-* targets This adds a command line option to build a "relocatable" bindist. The bindist is created by first creating a normal bindist and then installing it using the `RelocatableBuild=YES` option. This creates a bindist without any wrapper scripts pointing to the libdir. The motivation for this feature is that we want to ship relocatable bindists on windows and this method is more uniform than the ad-hoc method which lead to bugs such as #23608 and #23476 The relocatable bindist can be built with the "reloc-binary-dist" target and supports the same suffixes as the normal "binary-dist" command to specify the compression style. - - - - - 41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00 packaging: Fix installation scripts on windows/RelocatableBuild case This includes quite a lot of small fixes which fix the installation makefile to work on windows properly. This also required fixing the RelocatableBuild variable which seemed to have been broken for a long while. Sam helped me a lot writing this patch by providing a windows machine to test the changes. Without him it would have taken ages to tweak everything. Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - 03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00 ci: Build relocatable bindist on windows We now build the relocatable bindist target on windows, which means we test and distribute the new method of creating a relocatable bindist. - - - - - d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Add error when trying to build binary-dist target on windows The binary dist produced by `binary-dist` target doesn't work on windows because of the wrapper script the makefile installs. In order to not surprise any packagers we just give an error if someone tries to build the old binary-dist target rather than the reloc-binary-dist target. - - - - - 7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00 hadrian: Remove query' logic to use tooldir - - - - - 03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00 configure: Set WindresCmd directly and removed unused variables For some reason there was an indirection via the Windres variable before setting WindresCmd. That indirection led to #23855. I then also noticed that these other variables were just not used anywhere when trying to work out what the correct condition was for this bit of the configure script. - - - - - c82770f5 by sheaf at 2023-08-23T13:43:48-04:00 Apply shellcheck suggestion to SUBST_TOOLDIR - - - - - 896e35e5 by sheaf at 2023-08-23T13:44:34-04:00 Compute hints from TcSolverReportMsg This commit changes how hints are handled in conjunction with constraint solver report messages. Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor, we compute the hints depending on the underlying TcSolverReportMsg. This disentangles the logic and makes it easier to add new hints for certain errors. - - - - - a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00 users-guide: remove note about fatal Haddock parse failures - - - - - 4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Introduce Data.Enum - - - - - f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Integer - - - - - b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num - - - - - 6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Num.Natural - - - - - 2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Float - - - - - f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add export list to GHC.Real - - - - - 94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Eliminate module reexport in GHC.Exception The metric increase here isn't strictly due to this commit but it's a rather small, incidental change. Metric Increase: T8095 T13386 Metric Decrease: T8095 T13386 T18304 - - - - - be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00 base: Add disclaimers in internal modules To warn users that these modules are internal and their interfaces may change with little warning. As proposed in Core Libraries Committee #146 [CLC146]. [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146 - - - - - 0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00 Bump Cabal submodule We need to bump the Cabal submodule to include commit ec75950 which fixes an issue with a dodgy import Rep(..) which relied on GHC bug #23570 - - - - - 0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00 Fix typos in the documentation of Data.OldList.permutations - - - - - 1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00 Be more eager in TyCon boot validity checking This commit performs boot-file consistency checking for TyCons into checkValidTyCl. This ensures that we eagerly catch any mismatches, which prevents the compiler from seeing these inconsistencies and panicking as a result. See Note [TyCon boot consistency checking] in GHC.Tc.TyCl. Fixes #16127 - - - - - d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Refactor estimation of stack info table provenance This commit greatly refactors the way we compute estimated provenance for stack info tables. Previously, this process was done using an entirely separate traversal of the whole Cmm code stream to build the map from info tables to source locations. The separate traversal is now fused with the Cmm code generation pipeline in GHC.Driver.Main. This results in very significant code generation speed ups when -finfo-table-map is enabled. In testing, this patch reduces code generation times by almost 30% with -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 . Fixes #23103 - - - - - d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00 Add a test checking overhead of -finfo-table-map We want to make sure we don't end up with poor codegen performance resulting from -finfo-table-map again as in #23103. This test adds a performance test tracking total allocations while compiling ExactPrint with -finfo-table-map. - - - - - fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Add export list to GHC.Llvm.MetaData - - - - - 5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Allow LlvmLits in MetaExprs This omission appears to be an oversight. - - - - - 86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00 compiler: Move platform feature predicates to GHC.Driver.DynFlags These are useful in `GHC.Driver.Config.*`. - - - - - a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Introduce infrastructure for module flag metadata - - - - - e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00 llvmGen: Don't pass stack alignment via command line As of https://reviews.llvm.org/D103048 LLVM no longer supports the `-stack-alignment=...` flag. Instead this information is passed via a module flag metadata node. This requires dropping support for LLVM 11 and 12. Fixes #23870 - - - - - a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00 EPA: Keep track of "in" token for WarningTxt category A warning can now be written with a category, e.g. {-# WARNInG in "x-c" e "d" #-} Keep track of the location of the 'in' keyword and string, as well as the original SourceText of the label, in case it uses character escapes. - - - - - 3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00 Remove redundant import in InfoTableProv The copyBytes function is provided by the import of Foreign. Fixes #23889 - - - - - d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00 gitlab/issue-template: Mention report-a-bug - - - - - 50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30 Added StandaloneKindSignature examples to replace CUSKs ones - - - - - 2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00 Remove outdated CPP in compiler/* and template-haskell/* The boot compiler was bumped to 9.4 in cebb5819b43. There is no point supporting older GHC versions with CPP. - - - - - 5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30 testsuite: Add regression test for #23861 Simon says this was fixed by commit 8d68685468d0b6e922332a3ee8c7541efbe46137 Author: sheaf <sam.derbyshire at gmail.com> Date: Fri Aug 4 15:28:45 2023 +0200 Remove zonk in tcVTA - - - - - b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00 testsuite: Add regression test for #23864 Simon says this was fixed by commit 59202c800f2c97c16906120ab2561f6e1556e4af Author: Sebastian Graf <sebastian.graf at kit.edu> Date: Fri Mar 31 17:35:22 2023 +0200 CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now. The main reason is that it plays far better in conjunction with eta expansion (as we aim to do for arguments in CorePrep, #23083), because we can discard any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta` it's impossible to discard the argument. - - - - - 9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00 Remove ScopedTypeVariables => TypeAbstractions This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/) to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448) by removing the implication of language extensions ScopedTypeVariables => TypeAbstractions To limit breakage, we now allow type arguments in constructor patterns when both ScopedTypeVariables and TypeApplications are enabled, but we emit a warning notifying the user that this is deprecated behaviour that will go away starting in GHC 9.12. Fixes #23776 - - - - - fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00 .stderr: ScopedTypeVariables =/> TypeAbstractions This commit accepts testsuite changes for the changes in the previous commit, which mean that TypeAbstractions is no longer implied by ScopedTypeVariables. - - - - - 4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00 Repair `codes` test on OpenBSD by explicitly requesting extended RE - - - - - 6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23540 `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so `explainEv` has been moved to `TestUtils.hs`. - - - - - 257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Add test for #23120 - - - - - 4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00 Make some evidence uses reachable by toHie Resolves #23540, #23120 This adds spans to certain expressions in the typechecker and renamer, and lets 'toHie' make use of those spans. Therefore the relevant evidence uses for the following syntax will now show up under the expected nodes in 'HieAst's: - Overloaded literals ('IsString', 'Num', 'Fractional') - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the overloaded literals being matched on) - Arithmetic sequences ('Enum') - Monadic bind statements ('Monad') - Monadic body statements ('Monad', 'Alternative') - ApplicativeDo ('Applicative', 'Functor') - Overloaded lists ('IsList') Also see Note [Source locations for implicit function calls] In the process of handling overloaded lists I added an extra 'SrcSpan' field to 'VAExpansion' - this allows us to more accurately reconstruct the locations from the renamer in 'rebuildHsApps'. This also happens to fix #23120. See the additions to Note [Looking through HsExpanded] - - - - - fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00 ghc-heap: rename C file (fix #23898) - - - - - b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00 Misc cleanup - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples. Rename to ReturnsTuple. - Builtin.Utils: use SDoc for a panic message. The comment about <<details unavailable>> was obsoleted by e8d356773b56. - TagCheck: fix wrong logic. It was zipping a list 'args' with its version 'args_cmm' after filtering. - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types - hadrian: remove leftover debugging print - - - - - 3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00 Add a regression test for #23903 The bug has been fixed by commit bad2f8b8aa8424. - - - - - 21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00 README: Refer to ghc-hq repository for contributor and governance information - - - - - e542d590 by sheaf at 2023-08-29T19:52:40-04:00 Export setInertSet from GHC.Tc.Solver.Monad We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad. These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed the export of setInertSet, but that function is useful for the GHC API. - - - - - 694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00 Don't bundle children for non-parent Avails We used to bundle all children of the parent Avail with things that aren't the parent, e.g. with class C a where type T a meth :: .. we would bundle the whole Avail (C, T, meth) with all of C, T and meth, instead of only with C. Avoiding this fixes #23570 - - - - - d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00 Fix typos - - - - - d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00 JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806) - - - - - e2940272 by David Binder at 2023-08-30T19:43:08-04:00 Bump submodules of hpc and hpc-bin to version 0.7.0.0 hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify compatibility with newer versions of the directory package which dropped all SafeHaskell guarantees. - - - - - 5d56d05c by David Binder at 2023-08-30T19:43:08-04:00 Bump hpc bound in ghc.cabal.in - - - - - 99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 ghc classes documentation: rm redundant comment - - - - - fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00 prelude documentation: various nits - - - - - 48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 integer documentation: minor corrections - - - - - 20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00 real documentation: nits - - - - - dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00 Add a test for #21765 This issue (of reporting a constraint as being redundant even though removing it causes typechecking to fail) was fixed in aed1974e. This commit simply adds a regression test. Fixes #21765 - - - - - f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00 Export foldl' from Prelude and bump submodules See https://github.com/haskell/core-libraries-committee/issues/167 for discussion Metric Decrease: T8095 T13386 Metric Increase: T13386 T8095 T8095 ghc/alloc decreased on x86_64, but increased on aarch64. T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms. Neither has anything to do with `foldl'`, so I conclude that both are flaky. - - - - - 3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00 Allow cross-tyvar defaulting proposals from plugins Fixes #23832. - - - - - e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00 Clarify Note [GlobalId/LocalId] after CorePrep (#23797) Fixes #23797. - - - - - ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00 Fix warning with UNPACK on sum type (#23921) - - - - - 9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00 hadrian: track python dependencies in doc rules - - - - - 1578215f by sheaf at 2023-09-05T00:38:26-04:00 Bump Haddock to fix #23616 This commit updates the Haddock submodule to include the fix to #23616. Fixes #23616 - - - - - 5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00 Fix example in GHC user guide in SafeHaskell section The example given in the SafeHaskell section uses an implementation of Monad which no longer works. This MR removes the non-canonical return instance and adds the necessary instances of Functor and Applicative. - - - - - 291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00 driver: Check transitive closure of haskell package dependencies when deciding whether to relink We were previously just checking whether direct package dependencies had been modified. This caused issues when compiling without optimisations as we wouldn't relink the direct dependency if one of its dependenices changed. Fixes #23724 - - - - - 35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00 Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic Fixes #23930 - - - - - 3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00 Make STG rewriter produce updatable closures - - - - - 0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00 configure: update message to use hadrian (#22616) - - - - - b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00 EPA: Incorrect locations for UserTyVar with '@' In T13343.hs, the location for the @ is not within the span of the surrounding UserTyVar. type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v Widen it so it is captured. Closes #23887 - - - - - 8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00 Bump haddock submodule to fix #23920 Removes the fake export of `FUN` from Prelude. Fixes #23920. Bumps haddock submodule. - - - - - e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00 Fix wrong role in mkSelCo_maybe In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a, and call mkSelCo (SelTyCon 1 nominal) Refl. The function incorrectly returned Refl :: a ~R a. The returned role should be nominal, according to the SelCo rule: co : (T s1..sn) ~r0 (T t1..tn) r = tyConRole tc r0 i ---------------------------------- SelCo (SelTyCon i r) : si ~r ti In this test case, r is nominal while r0 is representational. - - - - - 1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00 If we have multiple defaulting plugins, then we should zonk in between them after any defaulting has taken place, to avoid a defaulting plugin seeing a metavariable that has already been filled. Fixes #23821. - - - - - eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00 Improvements to the documentation of defaulting plugins Based on @simonpj's draft and comments in !11117 - - - - - ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00 EPA: Incorrect span for LWarnDec GhcPs The code (from T23465.hs) {-# WARNInG in "x-c" e "d" #-} e = e gives an incorrect span for the LWarnDecl GhcPs Closes #23892 It also fixes the Test23465/Test23464 mixup - - - - - a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00 Valid hole fits: don't suggest unsafeCoerce (#17940) - - - - - 88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00 Add warning for badly staged types. Resolves #23829. The stage violation results in out-of-bound names in splices. Technically this is an error, but someone might rely on this!? Internal changes: - we now track stages for TyVars. - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does in fact rename its argument type, and it can contain variables. - - - - - 9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00 rts: Fix invalid symbol type I suspect this code is dead since we haven't observed this failing despite the obviously incorrect macro name. - - - - - 03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00 testsuite: Add simple test exercising C11 atomics in GHCi See #22012. - - - - - 1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00 rts/RtsSymbols: Add AArch64 outline atomic operations Fixes #22012 by adding the symbols described in https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic. Ultimately this would be better addressed by #22011, but this is a first step in the right direction and fixes the immediate symptom. Note that we dropped the `__arch64_cas16` operations as these provided by all platforms's compilers. Also, we don't link directly against the libgcc/compiler-rt definitions but rather provide our own wrappers to work around broken toolchains (e.g. https://bugs.gentoo.org/868018). Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733. - - - - - 8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00 ci: Build debian12 and fedora38 bindists This adds builds for the latest releases for fedora and debian We build these bindists in nightly and release pipelines. - - - - - a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00 Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods. - - - - - 98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00 docs: move -xn flag beside --nonmoving-gc It makes sense to have these beside each other as they are aliases. - - - - - f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00 nonmoving: introduce a family of dense allocators Supplement the existing power 2 sized nonmoving allocators with a family of dense allocators up to a configurable threshold. This should reduce waste from rounding up block sizes while keeping the amount of allocator sizes manageable. This patch: - Adds a new configuration option `--nonmoving-dense-allocator-count` to control the amount of these new dense allocators. - Adds some constants to `NonmovingAllocator` in order to keep marking fast with the new allocators. Resolves #23340 - - - - - 2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00 Add changelog entry for #23340 - - - - - f96fe681 by sheaf at 2023-09-12T04:31:44-04:00 Use printGhciException in run{Stmt, Decls} When evaluating statements in GHCi, we need to use printGhciException instead of the printException function that GHC provides in order to get the appropriate error messages that are customised for ghci use. - - - - - d09b932b by psilospore at 2023-09-12T04:31:44-04:00 T23686: Suggest how to enable Language Extension when in ghci Fixes #23686 - - - - - da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00 Unarise: Split Rubbish literals in function args Fixes #23914. Also adds a check to STG lint that these args are properly unary or nullary after unarisation - - - - - 261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00 darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13 This bumps the minumum supported version to 10.13 (High Sierra) which is 6 years old at this point. Fixes #22938 - - - - - f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00 Fix TH pretty-printing of nested GADTs, issue #23937 This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints GADTs declarations contained within data family instances. Fixes #23937 - - - - - d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00 Put hadrian non-bootstrap plans through `jq` This makes it possible to review changes with conventional diffing tools. This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left off. - - - - - ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00 JS: fix some tests - Tests using Setup programs need to pass --with-hc-pkg - Several other fixes See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage for the current status - - - - - fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00 Fix in-scope set assertion failure (#23918) Patch by Simon - - - - - 21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00 Add -Winconsistent-flags warning The warning fires when inconsistent command line flags are passed. For example: * -dynamic-too and -dynamic * -dynamic-too on windows * -O and --interactive * etc This is on by default and allows users to control whether the warning is displayed and whether it should be an error or not. Fixes #22572 - - - - - dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00 Avoid serializing BCOs with the internal interpreter Refs #23919 - - - - - 9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00 Fix numa auto configure - - - - - 98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Add -fno-cse to T15426 and T18964 This -fno-cse change is to avoid these performance tests depending on flukey CSE stuff. Each contains several independent tests, and we don't want them to interact. See #23925. By killing CSE we expect a 400% increase in T15426, and 100% in T18964. Metric Increase: T15426 T18964 - - - - - 236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00 Tiny refactor canEtaReduceToArity was only called internally, and always with two arguments equal to zero. This patch just specialises the function, and renames it to cantEtaReduceFun. No change in behaviour. - - - - - 56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00 spec-constr: Lift argument limit for SPEC-marked functions When the user adds a SPEC argument to a function, they are informing us that they expect the function to be specialised. However, previously this instruction could be preempted by the specialised-argument limit (sc_max_args). Fix this. This fixes #14003. - - - - - 6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00 Fix eta reduction Issue #23922 showed that GHC was bogusly eta-reducing a join point. We should never eta-reduce (\x -> j x) to j, if j is a join point. It is extremly difficult to trigger this bug. It took me 45 mins of trying to make a small tests case, here immortalised as T23922a. - - - - - e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00 Profiling: Properly escape characters when using `-pj`. There are some ways in which unusual characters like quotes or others can make it into cost centre names. So properly escape these. Fixes #23924 - - - - - ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00 Use clearer example variable names for bool eliminator - - - - - 5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00 Add missing int64/word64-to-double/float rules (#23907) CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203 - - - - - 566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00 Fix and test TH pretty-printing of type operator role declarations This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it correctly pretty-prints `type role` declarations for operator names. Fixes #23954 - - - - - 8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00 Use correct FunTyFlag in adjustJoinPointType As the Lint error in #23952 showed, the function adjustJoinPointType was failing to adjust the FunTyFlag when adjusting the type. I don't think this caused the seg-fault reported in the ticket, but it is definitely. This patch fixes it. It is tricky to come up a small test case; Krzysztof came up with this one, but it only triggers a failure in GHC 9.6. - - - - - 778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00 Update to Unicode 15.1.0 See: https://www.unicode.org/versions/Unicode15.1.0/ - - - - - f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00 EPA: track unicode version for unrestrictedFunTyCon Closes #23885 Updates haddock submodule - - - - - 9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00 Bump parsec submodule to allow text-2.1 and bytestring-0.12 - - - - - 7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00 base: Advertise linear time of readFloat As noted in #23538, `readFloat` has runtime that scales nonlinearly in the size of its input. Consequently, its use on untrusted input can be exploited as a denial-of-service vector. Point this out and suggest use of `read` instead. See #23538. - - - - - f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00 Remove dead code GHC.CoreToStg.Prep.canFloat This function never fires, so we can delete it: #23965. - - - - - ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00 base/changelog: Move fix for #23907 to 9.8.1 section Since the fix was backported to 9.8.1 - - - - - 51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64 alpine bindist This is dynamically linked and makes creating statically linked executables more straightforward. Fixes #23482 - - - - - 02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00 Add aarch64-deb11 bindist This adds a debian 11 release job for aarch64. Fixes #22005 - - - - - 8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00 Don’t store the async exception masking state in CATCH frames - - - - - 86d2971e by doyougnu at 2023-09-19T19:08:19-04:00 compiler,ghci: error codes link to HF error index closes: #23259 - adds -fprint-error-index-links={auto|always|never} flag - - - - - 5f826c18 by sheaf at 2023-09-19T19:09:03-04:00 Pass quantified tyvars in tcDefaultAssocDecl This commit passes the correct set of quantified type variables written by the user in associated type default declarations for validity checking. This ensures that validity checking of associated type defaults mirrors that of standalone type family instances. Fixes #23768 (see testcase T23734 in subsequent commit) - - - - - aba18424 by sheaf at 2023-09-19T19:09:03-04:00 Avoid panic in mkGADTVars This commit avoids panicking in mkGADTVars when we encounter a type variable as in #23784 that is bound by a user-written forall but not actually used. Fixes #23784 - - - - - a525a92a by sheaf at 2023-09-19T19:09:03-04:00 Adjust reporting of unused tyvars in data FamInsts This commit adjusts the validity checking of data family instances to improve the reporting of unused type variables. See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity. The problem was that, in a situation such as data family D :: Type data instance forall (d :: Type). D = MkD the RHS passed to 'checkFamPatBinders' would be the TyCon app R:D d which mentions the type variable 'd' quantified in the user-written forall. Thus, when computing the set of unused type variables in the RHS of the data family instance, we would find that 'd' is used, and report a strange error message that would say that 'd' is not bound on the LHS. To fix this, we special-case the data-family instance case, manually extracting all the type variables that appear in the arguments of all the data constructores of the data family instance. Fixes #23778 - - - - - 28dd52ee by sheaf at 2023-09-19T19:09:03-04:00 Unused tyvars in FamInst: only report user tyvars This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734 - - - - - 1eed645c by sheaf at 2023-09-19T19:09:03-04:00 Validity: refactor treatment of data families This commit refactors the reporting of unused type variables in type and data family instances to be more principled. This avoids ad-hoc logic in the treatment of data family instances. - - - - - 35bc506b by John Ericson at 2023-09-19T19:09:40-04:00 Remove `ghc-cabal` It is dead code since the Make build system was removed. I tried to go over every match of `git grep -i ghc-cabal` to find other stray bits. Some of those might be workarounds that can be further removed. - - - - - 665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00 Re-add unregisterised build support for sparc and sparc64 Closes #23959 - - - - - 142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00 Bump ci-images to use updated version of Alex Fixes #23977 - - - - - fa977034 by John Ericson at 2023-09-21T12:55:25-04:00 Use Cabal 3.10 for Hadrian We need the newer version for `CABAL_FLAG_*` env vars for #17191. - - - - - a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: `need` any `configure` script we will call When the script is changed, we should reconfigure. - - - - - db882b57 by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Make it easier to debug Cabal configure Right now, output is squashed. This make per-package configure scripts extremely hard to maintain, because we get vague "library is missing" errors when the actually probably is usually completely unrelated except for also involving the C/C++ toolchain. (I can always pass `-VVV` to Hadrian locally, but these errors are subtle and I often cannot reproduce them locally!) `--disable-option-checking` was added back in 75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill; if other flags are passed that are not recognized behind the two from Cabal mentioned in the former comment, we *do* want to know about it. - - - - - 7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00 hadrian: Increase verbosity of certain cabal commands This is a hack to get around the cabal function we're calling *decreasing* the verbosity it passes to another function, which is the stuff we often actually care about. Sigh. Keeping this a separate commit so if this makes things too verbose it is easy to revert. - - - - - a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00 rts: Move most external symbols logic to the configure script This is much more terse because we are programmatically handling the leading underscore. `findPtr` however is still handled in the Cabal file because we need a newer Cabal to pass flags to the configure script automatically. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump Cabal submodule to allow text-2.1 and bytestring-0.12 - - - - - 0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00 hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist - - - - - b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00 Bump hadrian's index-state to upgrade alex at least to 3.2.7.3 - - - - - 11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00 JS: correct file size and times Programs produced by the JavaScript backend were returning incorrect file sizes and modification times, causing cabal related tests to fail. This fixes the problem and adds an additional test that verifies basic file information operations. fixes #23980 - - - - - b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00 gitlab-ci: Drop libiserv from upload_ghc_libs libiserv has been merged into the ghci package. - - - - - 37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Fix Windows line endings - - - - - 5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00 testsuite: Use makefile_test - - - - - 15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00 system-cxx-std-lib: Add license and description - - - - - 0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00 gitlab/issue-templates: Rename bug.md -> default.md So that it is visible by default. - - - - - 23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00 Bump submodule text to 2.1 - - - - - b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00 Bump submodule unix to 2.8.2.1 - - - - - 54b2016e by John Ericson at 2023-09-23T11:40:41-04:00 Move lib{numa,dw} defines to RTS configure Clean up the m4 to handle the auto case always and be more consistent. Also simplify the CPP --- we should always have both headers if we are using libnuma. "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to better separate searching from actions taken based on search results. This might seem overkill now, but will make shuffling logic between configure scripts easier later. The macro comments are converted from `dnl` to `#` following the recomendation in https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html - - - - - d51b601b by John Ericson at 2023-09-23T11:40:50-04:00 Shuffle libzstd configuring between scripts Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS configure, `AC_SUBST` goes to the top-level configure script, and the documentation of the m4 macro is improved. - - - - - d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00 Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure It is just `AC_DEFINE` it belongs there instead. - - - - - 18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00 Move mmap in the runtime linker check to the RTS configure `AC_DEFINE` should go there instead. - - - - - 74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00 Elaborate comment on GHC_NO_UNICODE - - - - - de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00 gitlab-ci: Mark T22012 as broken on CentOS 7 Due to #23979. - - - - - 6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00 hadrian: better error for failing to find file's dependencies Resolves #24004 - - - - - d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers . map` This patch changes occurences of the idiom `partitionEithers (map f xs)` by the simpler form `partitionWith f xs` where `partitionWith` is the utility function defined in `GHC.Utils.Misc`. Resolves: #23953 - - - - - 8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Refactor uses of `partitionEithers <$> mapM f xs` This patch changes occurences of the idiom `partitionEithers <$> mapM f xs` by the simpler form `partitionWithM f xs` where `partitionWithM` is a utility function newly added to `GHC.Utils.Misc`. - - - - - 6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00 Mark `GHC.Utils.Misc.partitionWithM` as inlineable This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure that the right-hand side of the definition of this function remains available for specialisation at call sites. - - - - - f1e5245a by David Binder at 2023-09-27T01:19:00-04:00 Add RTS option to supress tix file - - - - - 1f43124f by David Binder at 2023-09-27T01:19:00-04:00 Add expected output to testsuite in test interface-stability/base-exports - - - - - b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00 Expose HpcFlags and getHpcFlags from GHC.RTS.Flags - - - - - 345675c6 by David Binder at 2023-09-27T01:19:00-04:00 Fix expected output of interface-stability test - - - - - 146e1c39 by David Binder at 2023-09-27T01:19:00-04:00 Implement getHpcFlags - - - - - 61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00 Add section in user guide - - - - - ea05f890 by David Binder at 2023-09-27T01:19:01-04:00 Rename --emit-tix-file to --write-tix-file - - - - - cabce2ce by David Binder at 2023-09-27T01:19:01-04:00 Update the golden files for interface stability - - - - - 1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00 Refactor: introduce stgArgRep The function 'stgArgType' returns the type in STG. But this violates the abstraction: in STG we're supposed to operate on PrimReps. This introduces stgArgRep ty = typePrimRep (stgArgType ty) stgArgRep1 ty = typePrimRep1 (stgArgType ty) stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty) stgArgType is still directly used for unboxed tuples (should be fixable), FFI and in ticky. - - - - - b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00 Fix TH pretty-printer's parenthesization This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed. Fixes #23962, #23968, #23971, and #23986 - - - - - 79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00 Add a testcase for #17564 The code in the ticket relied on the behaviour of Derived constraints. Derived constraints were removed in GHC 9.4 and now the code works as expected. - - - - - d7a80143 by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add new modes of operation This commit adds two new modes of operation to the lint-codes utility: list - list all statically used diagnostic codes outdated - list all outdated diagnostic codes The previous behaviour is now: test - test consistency and coverage of diagnostic codes - - - - - 477d223c by sheaf at 2023-09-28T03:25:53-04:00 lint codes: avoid using git-grep We manually traverse through the filesystem to find the diagnostic codes embedded in .stdout and .stderr files, to avoid any issues with old versions of grep. Fixes #23843 - - - - - a38ae69a by sheaf at 2023-09-28T03:25:53-04:00 lint-codes: add Hadrian targets This commit adds new Hadrian targets: codes, codes:used - list all used diagnostic codes codes:outdated - list outdated diagnostic codes This allows users to easily query GHC for used and outdated diagnostic codes, e.g. hadrian/build -j --flavour=<..> codes will list all used diagnostic codes in the command line by running the lint-codes utility in the "list codes" mode of operation. The diagnostic code consistency and coverage test is still run as usual, through the testsuite: hadrian/build test --only="codes" - - - - - 9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00 hadrian: Install LICENSE files in bindists Fixes #23548. - - - - - b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00 Fix visibility when eta-reducing a type lambda Fixes #24014. - - - - - d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00 Fix several mistakes around free variables in iface breakpoints Fixes #23612 , #23607, #23998 and #23666. MR: !11026 The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons: * IfaceBreakpoint created binders for free variables instead of expressions * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped - - - - - ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00 Refactor to combine HsLam and HsLamCase This MR is pure refactoring (#23916): * Combine `HsLam` and `HsLamCase` * Combine `HsCmdLam` and `HsCmdLamCase` This just arranges to treat uniformly \x -> e \case pi -> ei \cases pis -> ie In the exising code base the first is treated differently to the latter two. No change in behaviour. More specifics: * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering * Lambda * `\case` * `\cases` * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases. * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one. * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.) * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument. * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one. * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one. * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one. p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one. Phew! - - - - - b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 Arm: Make ppr methods easier to use by not requiring NCGConfig - - - - - 2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00 AArch64: Fix broken conditional jumps for offsets >= 1MB Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps to avoid overflowing the immediate. Fixes #23746 - - - - - 1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00 EPA: Replace Monoid with NoAnn We currently use the Monoid class as a constraint on Exact Print Annotation functions, so we can use mempty. But this leads to requiring Semigroup instances too, which do not always make sense. Instead, introduce a class NoAnn, with a function noAnn analogous to mempty. Closes #20372 Updates haddock submodule - - - - - c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00 users-guide: Refactor handling of :base-ref: et al. - - - - - bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00 Simplify and correct nasty case in coercion opt This fixes #21062. No test case, because triggering this code seems challenging. - - - - - 9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Bump bytestring submodule to 0.12.0.2 - - - - - 4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00 Inline bucket_match - - - - - f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00 configure: Fix #21712 again This is a bit of a shot in the dark to fix #24033, which appears to be another instance of #21712. For some reason the ld-override logic *still* appears to be active on Darwin targets (or at least one). Consequently, on misconfigured systems we may choose a non-`ld64` linker. It's a bit unclear exactly what happened in #24033 but ultimately the check added for #21712 was not quite right, checking for the `ghc_host_os` (the value of which depends upon the bootstrap compiler) instead of the target platform. Fix this. Fixes #24033. - - - - - 2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00 Add a regression test for #24029 - - - - - 8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00 Fix non-symbolic children lookup of fixity decl The fix for #23664 did not correctly account for non-symbolic names when looking up children of a given parent. This one-line fix changes that. Fixes #24037 - - - - - a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00 rts: fix incorrect ticket reference - - - - - e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00 users-guide: Fix discussion of -Wpartial-fields * fix a few typos * add a new example showing when the warning fires * clarify the existing example * point out -Wincomplete-record-selects Fixes #24049. - - - - - 8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00 Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)" This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2. `-optP` should pass options to the preprocessor, that might be a very different program to the C compiler, so passing the options to the C compiler is likely to result in `-optP` being useless. Fixes #17185 and #21291 - - - - - 8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00 rts/nonmoving: Fix on LLP64 platforms Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL` size suffix. However, this is wrong on LLP64 platforms like Windows, where `long` is 32-bits. Fixes #23003. Fixes #24042. - - - - - f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00 Fix isAArch64Bitmask for 32bit immediates. Fixes #23802 - - - - - 63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00 Work around perf note fetch failure Addresses #24055. - - - - - 242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00 Add a test for #21348 - - - - - 7d390bce by Rewbert at 2023-10-05T05:38:08-04:00 Fixes #24046 - - - - - 69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00 Ensure unconstrained instance dictionaries get IPE info In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up with an initial source span based on the span of the binder, which was causing instance dictionaries without dynamic superclass constraints to not have source locations in their IPE info. Now they do. Resolves #24005 - - - - - 390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00 rts: Split up rts/include/stg/MachRegs.h by arch - - - - - 3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00 Actually set hackage index state Or at least, use a version of the cabal command that *claims* to set the index state. Time will tell. - - - - - 46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00 Update hackage index state - - - - - d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00 Ensure hadrian uses CI's hackage index state - - - - - e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00 Do not use O_NONBLOCK on regular files or block devices CLC proposal https://github.com/haskell/core-libraries-committee/issues/166 - - - - - a06197c4 by David Binder at 2023-10-08T15:06:55-04:00 Update hpc-bin submodule to 0.69 - - - - - ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00 Update Hadrian with correct path to happy file for hpc-bin - - - - - 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - b3d91ff2 by Ben Gamari at 2023-10-19T10:17:47-04:00 rts/eventlog: Simplify cost-centre stack traversal Previously we would compute the depth with a somewhat tricky loop over the cost-centre stack, then bound the computed depth to 255, and then use the same tricky loop when writing the cost-centre stack to the event. This was technically correct but (a) rather subtle, and (b) inefficient as we would walk over the entire cost-centre stack, only to later truncate it. We now compute the depth more efficiently, applying the bound while traversing the stack. Then to write the stack to the event we simply traverse to the computed depth. (cherry picked from commit 0c54199d5c1c4502f1768f09ac5470fc7269a8b5) - - - - - c6a25dff by Ben Gamari at 2023-10-19T10:17:48-04:00 rts/eventlog: Record CCS allocations, entries, and ticks Here we introduce a family of three new eventlog events to record allocations, entries, and ticks from cost-centre stacks when time profiling. Fixes #24106. (cherry picked from commit 8feef4a9dba3a94486be1f6d6aab6abb96b61366) - - - - - 19 changed files: - .ghcid - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - − .gitlab/circle-ci-job.sh - .gitlab/darwin/nix/sources.json - .gitlab/darwin/toolchain.nix - + .gitlab/generate-ci/LICENSE - + .gitlab/generate-ci/README.mkd - + .gitlab/generate-ci/flake.lock - + .gitlab/generate-ci/flake.nix - .gitlab/gen_ci.hs → .gitlab/generate-ci/gen_ci.hs - + .gitlab/generate-ci/generate-ci.cabal - + .gitlab/generate-ci/generate-job-metadata - + .gitlab/generate-ci/generate-jobs - + .gitlab/generate-ci/hie.yaml - − .gitlab/generate_jobs - .gitlab/hello.hs - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8feef4a9dba3a94486be1f6d6aab6abb96b61366...c6a25dffdd87d70efef494b953e4f39af760e387 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8feef4a9dba3a94486be1f6d6aab6abb96b61366...c6a25dffdd87d70efef494b953e4f39af760e387 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 15:15:55 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 19 Oct 2023 11:15:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/sgraf812-master-patch-42518 Message-ID: <6531482bcfca2_7336fa1e203005589f5@gitlab.mail> Sebastian Graf pushed new branch wip/sgraf812-master-patch-42518 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/sgraf812-master-patch-42518 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 15:37:44 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 19 Oct 2023 11:37:44 -0400 Subject: [Git][ghc/ghc][master] Add a regression test for #24064 Message-ID: <65314d48854e1_7336fa27141c85650dc@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 3 changed files: - + testsuite/tests/typecheck/should_fail/T24064.hs - + testsuite/tests/typecheck/should_fail/T24064.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== testsuite/tests/typecheck/should_fail/T24064.hs ===================================== @@ -0,0 +1,48 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} + +module T24064 where + +class C1 b where + type F1 b + +class C2 (m :: * -> *) where + type F2 m + +class C3 r where + type F3 r + +class G t m where + g :: m a -> t m a + +data Y + +data X e a + +data H a + +data S a + +fun1 :: X e () +fun1 = undefined + +fun2 :: S () +fun2 = undefined + +fun3 :: H () +fun3 = undefined + +fun4 :: (F3 r ~ F1 (F2 m)) => r -> m () +fun4 = undefined + +test :: (C2 m, F2 m ~ Y) => m () +test = do + fun1 + fun2 + g fun3 + fun4 undefined + +main :: IO () +main = pure () ===================================== testsuite/tests/typecheck/should_fail/T24064.stderr ===================================== @@ -0,0 +1,26 @@ + +T24064.hs:42:3: error: [GHC-25897] + • Could not deduce ‘m ~ X e0’ + from the context: (C2 m, F2 m ~ Y) + bound by the type signature for: + test :: forall (m :: * -> *). (C2 m, F2 m ~ Y) => m () + at T24064.hs:40:1-32 + Expected: m () + Actual: X e0 () + ‘m’ is a rigid type variable bound by + the type signature for: + test :: forall (m :: * -> *). (C2 m, F2 m ~ Y) => m () + at T24064.hs:40:1-32 + • In a stmt of a 'do' block: fun1 + In the expression: + do fun1 + fun2 + g fun3 + fun4 undefined + In an equation for ‘test’: + test + = do fun1 + fun2 + g fun3 + .... + • Relevant bindings include test :: m () (bound at T24064.hs:41:1) ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -704,3 +704,4 @@ test('T22478c', normal, compile_fail, ['']) test('T23776', normal, compile, ['']) # to become an error in GHC 9.12 test('T17940', normal, compile_fail, ['']) test('ErrorIndexLinks', normal, compile_fail, ['-fprint-error-index-links=always']) +test('T24064', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/740a1b8563f8abe573f3d325ed29c185448e23ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/740a1b8563f8abe573f3d325ed29c185448e23ca You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 15:38:34 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 19 Oct 2023 11:38:34 -0400 Subject: [Git][ghc/ghc][master] CLC Proposal #182: Export List from Data.List Message-ID: <65314d7a894aa_7336fa2728984568936@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 7 changed files: - libraries/base/changelog.md - libraries/base/src/Data/List.hs - libraries/ghc-prim/GHC/Types.hs - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 Changes: ===================================== libraries/base/changelog.md ===================================== @@ -8,6 +8,7 @@ * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) + * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). ## 4.19.0.0 *TBA* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. ===================================== libraries/base/src/Data/List.hs ===================================== @@ -17,9 +17,10 @@ module Data.List ( + List -- * Basic functions - (++) + , (++) , head , last , tail @@ -222,6 +223,7 @@ import Data.OldList hiding ( all, and, any, concat, concatMap, elem, find, length, notElem, null, or, product, sum ) import GHC.Base ( Bool(..), Eq((==)), otherwise ) +import GHC.List (List) -- | The 'isSubsequenceOf' function takes two lists and returns 'True' if all -- the elements of the first list occur, in order, in the second. The ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -168,15 +168,27 @@ type family Any :: k where { } * * ********************************************************************* -} --- | The builtin list type, usually written in its non-prefix form @[a]@. +-- | The builtin linked list type. -- -- In Haskell, lists are one of the most important data types as they are -- often used analogous to loops in imperative programming languages. --- These lists are singly linked, which makes it unsuited for operations --- that require \(\mathcal{O}(1)\) access. Instead, lists are intended to +-- These lists are singly linked, which makes them unsuited for operations +-- that require \(\mathcal{O}(1)\) access. Instead, they are intended to -- be traversed. -- --- Lists are constructed recursively using the right-associative cons-operator +-- You can use @List a@ or @[a]@ in type signatures: +-- +-- > length :: [a] -> Int +-- +-- or +-- +-- > length :: List a -> Int +-- +-- They are fully equivalent, and @List a@ will be normalised to @[a]@. +-- +-- ==== Usage +-- +-- Lists are constructed recursively using the right-associative constructor operator (or /cons/) -- @(:) :: a -> [a] -> [a]@, which prepends an element to a list, -- and the empty list @[]@. -- @@ -184,6 +196,16 @@ type family Any :: k where { } -- (1 : 2 : 3 : []) == (1 : (2 : (3 : []))) == [1, 2, 3] -- @ -- +-- Lists can also be constructed using list literals +-- of the form @[x_1, x_2, ..., x_n]@ +-- which are syntactic sugar and, unless @-XOverloadedLists@ is enabled, +-- are translated into uses of @(:)@ and @[]@ +-- +-- 'Data.String.String' literals, like @"I 💜 hs"@, are translated into +-- Lists of characters, @[\'I\', \' \', \'💜\', \' \', \'h\', \'s\']@. +-- +-- ==== __Implementation__ +-- -- Internally and in memory, all the above are represented like this, -- with arrows being pointers to locations in memory. -- @@ -193,14 +215,6 @@ type family Any :: k where { } -- > v v v -- > 1 2 3 -- --- As seen above, lists can also be constructed using list literals --- of the form @[x_1, x_2, ..., x_n]@ --- which are syntactic sugar and, unless @-XOverloadedLists@ is enabled, --- are translated into uses of @(:)@ and @[]@ --- --- Similarly, 'Data.String.String' literals of the form @"I 💜 hs"@ are translated into --- Lists of characters, @[\'I\', \' \', \'💜\', \' \', \'h\', \'s\']@. --- -- ==== __Examples__ -- -- @ ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/921fbf2fb601ff90cd9cbc0fb8fe3b1768a8f1d5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/921fbf2fb601ff90cd9cbc0fb8fe3b1768a8f1d5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 16:09:45 2023 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 19 Oct 2023 12:09:45 -0400 Subject: [Git][ghc/ghc][wip/mixed-uniqfm] 2 commits: Fix for #24102 Message-ID: <653154c937870_7336fa3ac50285784a2@gitlab.mail> Sebastian Graf pushed to branch wip/mixed-uniqfm at Glasgow Haskell Compiler / GHC Commits: aef078bb by Sebastian Graf at 2023-10-19T18:08:51+02:00 Fix for #24102 - - - - - 064c9ef1 by Sebastian Graf at 2023-10-19T18:09:32+02:00 Consequently hide mixed unique sets behind a newtype - - - - - 5 changed files: - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Graph/UnVar.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Types/Unique/DFM.hs - compiler/GHC/Types/Unique/FM.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -643,13 +643,19 @@ cpeBind top_lvl env (Rec pairs) where (bndrs, rhss) = unzip pairs - -- Flatten all the floats, and the current - -- group into a single giant Rec + -- Flatten all the floats, and the current + -- group into a single giant Rec add_float (Float bind bound _) prs2 - | bound /= CaseBound = case bind of + | bound /= CaseBound + || all (definitelyLiftedType . idType) (bindersOf bind) + -- The latter check is hit in -O0 (i.e., flavours quick, devel2) + -- for dictionary args which haven't been floated out yet, #24102. + -- They are preferably CaseBound, but since they are lifted we may + -- just as well put them in the Rec, in contrast to lifted bindings. + = case bind of NonRec x e -> (x,e) : prs2 Rec prs1 -> prs1 ++ prs2 - add_float f _ = pprPanic "cpeBind" (ppr f) + add_float f _ = pprPanic "cpeBind" (ppr f) --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool ===================================== compiler/GHC/Data/Graph/UnVar.hs ===================================== @@ -31,7 +31,7 @@ module GHC.Data.Graph.UnVar import GHC.Prelude -import GHC.Types.Unique.FM( UniqFM, ufmToSet_Directly, getMixedKey, getUnmixedUnique ) +import GHC.Types.Unique.FM import GHC.Types.Var import GHC.Utils.Outputable import GHC.Types.Unique @@ -44,7 +44,10 @@ import qualified GHC.Data.Word64Set as S -- at hand, and we do not have that when we turn the domain of a VarEnv into a UnVarSet. -- Therefore, use a Word64Set directly (which is likely also a bit more efficient). --- Set of uniques, i.e. for adjacent nodes +-- Set of mixed unique keys, i.e. for adjacent nodes +-- This could very well be backed by a UniqFMKeySet! But that would require +-- moving a lot of functions to GHC.Types.Unique.FM, because we definitely +-- don't want to expose the newtype constructor of UniqFMKeySet. newtype UnVarSet = UnVarSet S.Word64Set deriving Eq @@ -52,7 +55,7 @@ k :: Var -> Word64 k v = getMixedKey (getUnique v) domUFMUnVarSet :: UniqFM key elt -> UnVarSet -domUFMUnVarSet ae = UnVarSet $ ufmToSet_Directly ae +domUFMUnVarSet ae = UnVarSet $ ufmksToMixedSet $ ufmToSet_Directly ae emptyUnVarSet :: UnVarSet emptyUnVarSet = UnVarSet S.empty ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -151,11 +151,9 @@ import GHC.Runtime.Loader import GHC.Rename.Names import GHC.Utils.Constants import GHC.Types.Unique.DFM (udfmRestrictKeysSet) -import GHC.Types.Unique +import GHC.Types.Unique.FM (UniqFMKeySet, emptyUniqFMKeySet, mkUniqFMKeySet, unionUniqFMKeySet) import GHC.Iface.Errors.Types -import qualified GHC.Data.Word64Set as W - -- ----------------------------------------------------------------------------- -- Loading the program @@ -2812,7 +2810,7 @@ Before a module is compiled, we use this set to restrict the HUG to the visible modules only, avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance, because a union occurs for -each edge in the module graph. To achieve this, the set is represented directly as an IntSet, +each edge in the module graph. To achieve this, the set is represented directly as a UniqFMKeySet, which provides suitable performance – even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. @@ -2821,12 +2819,11 @@ See test "jspace" for an example which used to trigger this problem. -} -- See Note [ModuleNameSet, efficiency and space leaks] -type ModuleNameSet = M.Map UnitId W.Word64Set +type ModuleNameSet = M.Map UnitId UniqFMKeySet addToModuleNameSet :: UnitId -> ModuleName -> ModuleNameSet -> ModuleNameSet addToModuleNameSet uid mn s = - let k = (getKey $ getUnique $ mn) - in M.insertWith (W.union) uid (W.singleton k) s + M.insertWith unionUniqFMKeySet uid (mkUniqFMKeySet [mn]) s -- | Wait for some dependencies to finish and then read from the given MVar. wait_deps_hug :: MVar HomeUnitGraph -> [BuildResult] -> ReaderT MakeEnv (MaybeT IO) (HomeUnitGraph, ModuleNameSet) @@ -2837,7 +2834,7 @@ wait_deps_hug hug_var deps = do let -- Restrict to things which are in the transitive closure to avoid retaining -- reference to loop modules which have already been compiled by other threads. -- See Note [ModuleNameSet, efficiency and space leaks] - !new = udfmRestrictKeysSet (homeUnitEnv_hpt hme) (fromMaybe W.empty $ M.lookup uid module_deps) + !new = udfmRestrictKeysSet (homeUnitEnv_hpt hme) (fromMaybe emptyUniqFMKeySet $ M.lookup uid module_deps) in hme { homeUnitEnv_hpt = new } return (unitEnv_mapWithKey pruneHomeUnitEnv hug, module_deps) @@ -2852,7 +2849,7 @@ wait_deps (x:xs) = do Nothing -> return (hmis, new_deps) Just hmi -> return (hmi:hmis, new_deps) where - unionModuleNameSet = M.unionWith W.union + unionModuleNameSet = M.unionWith unionUniqFMKeySet -- Executing the pipelines ===================================== compiler/GHC/Types/Unique/DFM.hs ===================================== @@ -80,9 +80,8 @@ import Data.Data import Data.Functor.Classes (Eq1 (..)) import Data.List (sortBy) import Data.Function (on) -import GHC.Types.Unique.FM (UniqFM, getMixedKey, getUnmixedUnique, nonDetUFMToList, ufmToIntMap, unsafeIntMapToUFM) +import GHC.Types.Unique.FM import Unsafe.Coerce -import qualified GHC.Data.Word64Set as W -- Note [Deterministic UniqFM] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -325,10 +324,9 @@ filterUDFM_Directly p (UDFM m i) = UDFM (M.filterWithKey p' m) i udfmRestrictKeys :: UniqDFM key elt -> UniqDFM key elt2 -> UniqDFM key elt udfmRestrictKeys (UDFM a i) (UDFM b _) = UDFM (M.restrictKeys a (M.keysSet b)) i -udfmRestrictKeysSet :: UniqDFM key elt -> W.Word64Set -> UniqDFM key elt +udfmRestrictKeysSet :: UniqDFM key elt -> UniqFMKeySet -> UniqDFM key elt udfmRestrictKeysSet (UDFM val_set i) set = - let key_set = set - in UDFM (M.restrictKeys val_set key_set) i + UDFM (M.restrictKeys val_set (ufmksToMixedSet set)) i -- | Converts `UniqDFM` to a list, with elements in deterministic order. -- It's O(n log n) while the corresponding function on `UniqFM` is O(n). @@ -353,7 +351,7 @@ intersectUDFM (UDFM x i) (UDFM y _j) = UDFM (M.intersection x y) i -- a subset of elements from the left set, so `i` is a good upper bound. udfmIntersectUFM :: UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1 -udfmIntersectUFM (UDFM x i) y = UDFM (M.intersection x (ufmToIntMap y)) i +udfmIntersectUFM (UDFM x i) y = UDFM (M.intersection x (ufmToMixedIntMap y)) i -- M.intersection is left biased, that means the result will only have -- a subset of elements from the left set, so `i` is a good upper bound. @@ -361,7 +359,7 @@ disjointUDFM :: UniqDFM key elt -> UniqDFM key elt -> Bool disjointUDFM (UDFM x _i) (UDFM y _j) = M.disjoint x y disjointUdfmUfm :: UniqDFM key elt -> UniqFM key elt2 -> Bool -disjointUdfmUfm (UDFM x _i) y = M.disjoint x (ufmToIntMap y) +disjointUdfmUfm (UDFM x _i) y = M.disjoint x (ufmToMixedIntMap y) minusUDFM :: UniqDFM key elt1 -> UniqDFM key elt2 -> UniqDFM key elt1 minusUDFM (UDFM x i) (UDFM y _j) = UDFM (M.difference x y) i @@ -369,12 +367,12 @@ minusUDFM (UDFM x i) (UDFM y _j) = UDFM (M.difference x y) i -- bound. udfmMinusUFM :: UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1 -udfmMinusUFM (UDFM x i) y = UDFM (M.difference x (ufmToIntMap y)) i +udfmMinusUFM (UDFM x i) y = UDFM (M.difference x (ufmToMixedIntMap y)) i -- M.difference returns a subset of a left set, so `i` is a good upper -- bound. ufmMinusUDFM :: UniqFM key elt1 -> UniqDFM key elt2 -> UniqFM key elt1 -ufmMinusUDFM x (UDFM y _i) = unsafeIntMapToUFM (M.difference (ufmToIntMap x) y) +ufmMinusUDFM x (UDFM y _i) = mixedIntMapToUFM (M.difference (ufmToMixedIntMap x) y) -- | Partition UniqDFM into two UniqDFMs according to the predicate partitionUDFM :: (elt -> Bool) -> UniqDFM key elt -> (UniqDFM key elt, UniqDFM key elt) @@ -388,7 +386,7 @@ delListFromUDFM = foldl' delFromUDFM -- | This allows for lossy conversion from UniqDFM to UniqFM udfmToUfm :: UniqDFM key elt -> UniqFM key elt -udfmToUfm (UDFM m _i) = unsafeIntMapToUFM (M.map taggedFst m) +udfmToUfm (UDFM m _i) = mixedIntMapToUFM (M.map taggedFst m) listToUDFM :: Uniquable key => [(key,elt)] -> UniqDFM key elt listToUDFM = foldl' (\m (k, v) -> addToUDFM m k v) emptyUDFM ===================================== compiler/GHC/Types/Unique/FM.hs ===================================== @@ -33,9 +33,13 @@ module GHC.Types.Unique.FM ( -- * Unique-keyed mappings UniqFM, -- abstract type NonDetUniqFM(..), -- wrapper for opting into nondeterminism + UniqFMKeySet, -- A Word64Set with keys that are mixed the same way as UniqFM's getMixedKey, getUnmixedUnique, + -- ** Manipulating UniqFMKeySets + emptyUniqFMKeySet, mkUniqFMKeySet, unionUniqFMKeySet, + -- ** Manipulating those mappings emptyUFM, unitUFM, @@ -83,8 +87,8 @@ module GHC.Types.Unique.FM ( lookupUFM, lookupUFM_Directly, lookupWithDefaultUFM, lookupWithDefaultUFM_Directly, nonDetEltsUFM, nonDetKeysUFM, - ufmToSet_Directly, - nonDetUFMToList, ufmToIntMap, unsafeIntMapToUFM, + ufmToSet_Directly, ufmksToMixedSet, + nonDetUFMToList, ufmToMixedIntMap, mixedIntMapToUFM, unsafeCastUFMKey, pprUniqFM, pprUFM, pprUFMWithKeys, pluralUFM ) where @@ -103,10 +107,6 @@ import Data.Functor.Classes (Eq1 (..)) import Data.Bits import Data.Coerce --- for UNIQUE_TAG_BITS. @mix@ will silently fail if this isn't included and --- you'll get panics. -#include "Unique.h" - -- | A finite map from @uniques@ of one type to -- elements in another type. -- @@ -122,6 +122,10 @@ newtype UniqFM key ele = UFM (M.Word64Map ele) -- See Note [Deterministic UniqFM] in GHC.Types.Unique.DFM to learn about determinism. type role UniqFM representational representational -- Don't allow coerces over the key +-- | The result of `ufmToSet_Directly`: A very dense `S.Word64Set` the keys of +-- which are mixed exactly like the keys of the `UniqFM` from whence it came. +newtype UniqFMKeySet = UFMKS S.Word64Set + -- | https://gist.github.com/degski/6e2069d6035ae04d5d6f64981c995ec2 mix :: MS.Key -> MS.Key -> MS.Key {-# INLINE mix #-} @@ -129,7 +133,7 @@ mix k = fromIntegral . f . g . f . g . f . fromIntegral where f y = (y `shiftR` s) `xor` y g z = z * k - s = finiteBitSize k `shiftR` 1 -- 32 for 64 bit, 16 for 32 bit + s = finiteBitSize k `shiftR` 1 kFORWARD, kBACKWARD :: MS.Key -- These are like "encryption" and "decryption" keys to mix @@ -149,6 +153,15 @@ getUnmixedUnique :: MS.Key -> Unique {-# INLINE getUnmixedUnique #-} getUnmixedUnique = mkUniqueGrimily . dec +emptyUniqFMKeySet :: UniqFMKeySet +emptyUniqFMKeySet = UFMKS S.empty + +mkUniqFMKeySet :: Uniquable k => [k] -> UniqFMKeySet +mkUniqFMKeySet us = UFMKS (S.fromList (map (getMixedKey . getUnique) us)) + +unionUniqFMKeySet :: UniqFMKeySet -> UniqFMKeySet -> UniqFMKeySet +unionUniqFMKeySet (UFMKS s1) (UFMKS s2) = UFMKS (S.union s1 s2) + emptyUFM :: UniqFM key elt emptyUFM = UFM M.empty @@ -374,7 +387,7 @@ plusUFMList :: [UniqFM key elt] -> UniqFM key elt plusUFMList = foldl' plusUFM emptyUFM plusUFMListWith :: (elt -> elt -> elt) -> [UniqFM key elt] -> UniqFM key elt -plusUFMListWith f xs = unsafeIntMapToUFM $ M.unionsWith f (map ufmToIntMap xs) +plusUFMListWith f xs = mixedIntMapToUFM $ M.unionsWith f (map ufmToMixedIntMap xs) sequenceUFMList :: forall key elt. [UniqFM key elt] -> UniqFM key [elt] sequenceUFMList = foldr (plusUFM_CD2 cons) emptyUFM @@ -471,8 +484,8 @@ lookupWithDefaultUFM_Directly :: UniqFM key elt -> elt -> Unique -> elt lookupWithDefaultUFM_Directly (UFM m) v u = M.findWithDefault v (getMixedKey u) m -- | NB: This provides a set of keys with with `getMixedKey`! -ufmToSet_Directly :: UniqFM key elt -> S.Word64Set -ufmToSet_Directly (UFM m) = M.keysSet m +ufmToSet_Directly :: UniqFM key elt -> UniqFMKeySet +ufmToSet_Directly (UFM m) = UFMKS (M.keysSet m) anyUFM :: (elt -> Bool) -> UniqFM key elt -> Bool anyUFM p (UFM m) = M.foldr ((||) . p) False m @@ -546,11 +559,20 @@ instance forall key. Foldable (NonDetUniqFM key) where instance forall key. Traversable (NonDetUniqFM key) where traverse f (NonDetUniqFM (UFM m)) = NonDetUniqFM . UFM <$> traverse f m -ufmToIntMap :: UniqFM key elt -> M.Word64Map elt -ufmToIntMap (UFM m) = m +-- | Interpret a `UniqFMKeySet` as a `Word64Set`, where the Unique keys can be +-- recovered by applying `getUnmixedUnique` to the keys. +ufmksToMixedSet :: UniqFMKeySet -> S.Word64Set +ufmksToMixedSet (UFMKS s) = s + +-- | Interpret a `UniqFM` as a `Word64Map`, where the Unique keys can be +-- recovered by applying `getUnmixedUnique` to the keys. +ufmToMixedIntMap :: UniqFM key elt -> M.Word64Map elt +ufmToMixedIntMap (UFM m) = m -unsafeIntMapToUFM :: M.Word64Map elt -> UniqFM key elt -unsafeIntMapToUFM = UFM +-- | Interpret a `Word64Map` as a `UniqFM`, where the Unique keys of the +-- `Word64Map` can be recovered by applying `getUnmixedUnique` to the keys. +mixedIntMapToUFM :: M.Word64Map elt -> UniqFM key elt +mixedIntMapToUFM = UFM -- | Cast the key domain of a UniqFM. -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8e122c96e692ef7be3138b1be0afc478825265bd...064c9ef12005314ebb6b3806f8c1fae9f98bbd13 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8e122c96e692ef7be3138b1be0afc478825265bd...064c9ef12005314ebb6b3806f8c1fae9f98bbd13 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 16:39:30 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 19 Oct 2023 12:39:30 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Add a regression test for #24064 Message-ID: <65315bc2e137b_7336fa443c458579297@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 3a1c229e by Sylvain Henry at 2023-10-19T12:39:13-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - fbae18d9 by Sylvain Henry at 2023-10-19T12:39:16-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - 12 changed files: - compiler/GHC/ByteCode/Asm.hs - libraries/base/changelog.md - libraries/base/src/Data/List.hs - libraries/ghc-prim/GHC/Types.hs - rts/Interpreter.c - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - + testsuite/tests/typecheck/should_fail/T24064.hs - + testsuite/tests/typecheck/should_fail/T24064.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -43,23 +43,19 @@ import GHC.Platform import GHC.Platform.Profile import Control.Monad -import Control.Monad.ST ( runST ) import Control.Monad.Trans.Class import Control.Monad.Trans.State.Strict -import Data.Array.MArray - import qualified Data.Array.Unboxed as Array import Data.Array.Base ( UArray(..) ) -import Data.Array.Unsafe( castSTUArray ) - import Foreign hiding (shiftL, shiftR) import Data.Char ( ord ) import Data.List ( genericLength ) import Data.Map.Strict (Map) import Data.Maybe (fromMaybe) import qualified Data.Map.Strict as Map +import GHC.Float (castFloatToWord32, castDoubleToWord64) -- ----------------------------------------------------------------------------- -- Unlinked BCOs @@ -416,7 +412,7 @@ assembleI platform i = case i of tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) - info <- int (fromIntegral $ + info <- word (fromIntegral $ mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] @@ -466,21 +462,21 @@ assembleI platform i = case i of emit bci_TESTLT_W [Op np, LabelOp l] TESTEQ_W w l -> do np <- word w emit bci_TESTEQ_W [Op np, LabelOp l] - TESTLT_I64 i l -> do np <- int64 i + TESTLT_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTLT_I64 [Op np, LabelOp l] - TESTEQ_I64 i l -> do np <- int64 i + TESTEQ_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTEQ_I64 [Op np, LabelOp l] - TESTLT_I32 i l -> do np <- int (fromIntegral i) + TESTLT_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I32 [Op np, LabelOp l] - TESTEQ_I32 i l -> do np <- int (fromIntegral i) + TESTEQ_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I32 [Op np, LabelOp l] - TESTLT_I16 i l -> do np <- int (fromIntegral i) + TESTLT_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I16 [Op np, LabelOp l] - TESTEQ_I16 i l -> do np <- int (fromIntegral i) + TESTEQ_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I16 [Op np, LabelOp l] - TESTLT_I8 i l -> do np <- int (fromIntegral i) + TESTLT_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I8 [Op np, LabelOp l] - TESTEQ_I8 i l -> do np <- int (fromIntegral i) + TESTEQ_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I8 [Op np, LabelOp l] TESTLT_W64 w l -> do np <- word64 w emit bci_TESTLT_W64 [Op np, LabelOp l] @@ -530,42 +526,80 @@ assembleI platform i = case i of -- On Windows, stdcall labels have a suffix indicating the no. of -- arg words, e.g. foo at 8. testcase: ffi012(ghci) literal (LitLabel fs _ _) = litlabel fs - literal LitNullAddr = int 0 + literal LitNullAddr = word 0 literal (LitFloat r) = float (fromRational r) literal (LitDouble r) = double (fromRational r) literal (LitChar c) = int (ord c) literal (LitString bs) = lit [BCONPtrStr bs] -- LitString requires a zero-terminator when emitted literal (LitNumber nt i) = case nt of - LitNumInt -> int (fromIntegral i) - LitNumWord -> int (fromIntegral i) - LitNumInt8 -> int8 (fromIntegral i) - LitNumWord8 -> int8 (fromIntegral i) - LitNumInt16 -> int16 (fromIntegral i) - LitNumWord16 -> int16 (fromIntegral i) - LitNumInt32 -> int32 (fromIntegral i) - LitNumWord32 -> int32 (fromIntegral i) - LitNumInt64 -> int64 (fromIntegral i) - LitNumWord64 -> int64 (fromIntegral i) + LitNumInt -> word (fromIntegral i) + LitNumWord -> word (fromIntegral i) + LitNumInt8 -> word8 (fromIntegral i) + LitNumWord8 -> word8 (fromIntegral i) + LitNumInt16 -> word16 (fromIntegral i) + LitNumWord16 -> word16 (fromIntegral i) + LitNumInt32 -> word32 (fromIntegral i) + LitNumWord32 -> word32 (fromIntegral i) + LitNumInt64 -> word64 (fromIntegral i) + LitNumWord64 -> word64 (fromIntegral i) LitNumBigNat -> panic "GHC.ByteCode.Asm.literal: LitNumBigNat" -- We can lower 'LitRubbish' to an arbitrary constant, but @NULL@ is most -- likely to elicit a crash (rather than corrupt memory) in case absence -- analysis messed up. - literal (LitRubbish {}) = int 0 + literal (LitRubbish {}) = word 0 litlabel fs = lit [BCONPtrLbl fs] addr (RemotePtr a) = words [fromIntegral a] - float = words . mkLitF platform - double = words . mkLitD platform - int = words . mkLitI - int8 = words . mkLitI64 platform - int16 = words . mkLitI64 platform - int32 = words . mkLitI64 platform - int64 = words . mkLitI64 platform - word64 = words . mkLitW64 platform words ws = lit (map BCONPtrWord ws) word w = words [w] + word_size = platformWordSize platform + word_size_bits = platformWordSizeInBits platform + + -- Make lists of host-sized words for literals, so that when the + -- words are placed in memory at increasing addresses, the + -- bit pattern is correct for the host's word size and endianness. + -- + -- Note that we only support host endianness == target endianness for now, + -- even with the external interpreter. This would need to be fixed to + -- support host endianness /= target endianness + int :: Int -> Assembler Word + int i = word (fromIntegral i) + + float :: Float -> Assembler Word + float f = word32 (castFloatToWord32 f) + + double :: Double -> Assembler Word + double d = word64 (castDoubleToWord64 d) + + word64 :: Word64 -> Assembler Word + word64 ww = case word_size of + PW4 -> + let !wl = fromIntegral ww + !wh = fromIntegral (ww `unsafeShiftR` 32) + in case platformByteOrder platform of + LittleEndian -> words [wl,wh] + BigEndian -> words [wh,wl] + PW8 -> word (fromIntegral ww) + + word8 :: Word8 -> Assembler Word + word8 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 8)) + + word16 :: Word16 -> Assembler Word + word16 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 16)) + + word32 :: Word32 -> Assembler Word + word32 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> case word_size of + PW4 -> word (fromIntegral x) + PW8 -> word (fromIntegral x `unsafeShiftL` 32) + isLargeW :: Word -> Bool isLargeW n = n > 65535 @@ -648,74 +682,5 @@ mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal mkNativeCallInfoLit platform call_info = mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info --- Make lists of host-sized words for literals, so that when the --- words are placed in memory at increasing addresses, the --- bit pattern is correct for the host's word size and endianness. -mkLitI :: Int -> [Word] -mkLitF :: Platform -> Float -> [Word] -mkLitD :: Platform -> Double -> [Word] -mkLitI64 :: Platform -> Int64 -> [Word] -mkLitW64 :: Platform -> Word64 -> [Word] - -mkLitF platform f = case platformWordSize platform of - PW4 -> runST $ do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 f - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - - PW8 -> runST $ do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 f - -- on 64-bit architectures we read two (32-bit) Float cells when we read - -- a (64-bit) Word: so we write a dummy value in the second cell to - -- avoid an out-of-bound read. - writeArray arr 1 0.0 - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - -mkLitD platform d = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word, w1] - ) - PW8 -> runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - return [w0 :: Word] - ) - -mkLitI64 platform ii = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 ii - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ii :: Word] - -mkLitW64 platform ww = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Word),1) - writeArray arr 0 ww - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ww :: Word] - -mkLitI i = [fromIntegral i :: Word] - iNTERP_STACK_CHECK_THRESH :: Int iNTERP_STACK_CHECK_THRESH = INTERP_STACK_CHECK_THRESH ===================================== libraries/base/changelog.md ===================================== @@ -8,6 +8,7 @@ * Fix `fdIsNonBlocking` to always be `0` for regular files and block devices on unix, regardless of `O_NONBLOCK` * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) + * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). ## 4.19.0.0 *TBA* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. ===================================== libraries/base/src/Data/List.hs ===================================== @@ -17,9 +17,10 @@ module Data.List ( + List -- * Basic functions - (++) + , (++) , head , last , tail @@ -222,6 +223,7 @@ import Data.OldList hiding ( all, and, any, concat, concatMap, elem, find, length, notElem, null, or, product, sum ) import GHC.Base ( Bool(..), Eq((==)), otherwise ) +import GHC.List (List) -- | The 'isSubsequenceOf' function takes two lists and returns 'True' if all -- the elements of the first list occur, in order, in the second. The ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -168,15 +168,27 @@ type family Any :: k where { } * * ********************************************************************* -} --- | The builtin list type, usually written in its non-prefix form @[a]@. +-- | The builtin linked list type. -- -- In Haskell, lists are one of the most important data types as they are -- often used analogous to loops in imperative programming languages. --- These lists are singly linked, which makes it unsuited for operations --- that require \(\mathcal{O}(1)\) access. Instead, lists are intended to +-- These lists are singly linked, which makes them unsuited for operations +-- that require \(\mathcal{O}(1)\) access. Instead, they are intended to -- be traversed. -- --- Lists are constructed recursively using the right-associative cons-operator +-- You can use @List a@ or @[a]@ in type signatures: +-- +-- > length :: [a] -> Int +-- +-- or +-- +-- > length :: List a -> Int +-- +-- They are fully equivalent, and @List a@ will be normalised to @[a]@. +-- +-- ==== Usage +-- +-- Lists are constructed recursively using the right-associative constructor operator (or /cons/) -- @(:) :: a -> [a] -> [a]@, which prepends an element to a list, -- and the empty list @[]@. -- @@ -184,6 +196,16 @@ type family Any :: k where { } -- (1 : 2 : 3 : []) == (1 : (2 : (3 : []))) == [1, 2, 3] -- @ -- +-- Lists can also be constructed using list literals +-- of the form @[x_1, x_2, ..., x_n]@ +-- which are syntactic sugar and, unless @-XOverloadedLists@ is enabled, +-- are translated into uses of @(:)@ and @[]@ +-- +-- 'Data.String.String' literals, like @"I 💜 hs"@, are translated into +-- Lists of characters, @[\'I\', \' \', \'💜\', \' \', \'h\', \'s\']@. +-- +-- ==== __Implementation__ +-- -- Internally and in memory, all the above are represented like this, -- with arrows being pointers to locations in memory. -- @@ -193,14 +215,6 @@ type family Any :: k where { } -- > v v v -- > 1 2 3 -- --- As seen above, lists can also be constructed using list literals --- of the form @[x_1, x_2, ..., x_n]@ --- which are syntactic sugar and, unless @-XOverloadedLists@ is enabled, --- are translated into uses of @(:)@ and @[]@ --- --- Similarly, 'Data.String.String' literals of the form @"I 💜 hs"@ are translated into --- Lists of characters, @[\'I\', \' \', \'💜\', \' \', \'h\', \'s\']@. --- -- ==== __Examples__ -- -- @ ===================================== rts/Interpreter.c ===================================== @@ -1275,21 +1275,21 @@ run_BCO: case bci_PUSH8_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); + *(StgWord8*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH16_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); + *(StgWord16*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH32_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); + *(StgWord32*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -1252,6 +1252,8 @@ module Data.List where (!!) :: forall a. GHC.Stack.Types.HasCallStack => [a] -> GHC.Types.Int -> a (!?) :: forall a. [a] -> GHC.Types.Int -> GHC.Maybe.Maybe a (++) :: forall a. [a] -> [a] -> [a] + type List :: * -> * + data List a = ... (\\) :: forall a. GHC.Classes.Eq a => [a] -> [a] -> [a] all :: forall (t :: * -> *) a. Data.Foldable.Foldable t => (a -> GHC.Types.Bool) -> t a -> GHC.Types.Bool and :: forall (t :: * -> *). Data.Foldable.Foldable t => t GHC.Types.Bool -> GHC.Types.Bool ===================================== testsuite/tests/typecheck/should_fail/T24064.hs ===================================== @@ -0,0 +1,48 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} + +module T24064 where + +class C1 b where + type F1 b + +class C2 (m :: * -> *) where + type F2 m + +class C3 r where + type F3 r + +class G t m where + g :: m a -> t m a + +data Y + +data X e a + +data H a + +data S a + +fun1 :: X e () +fun1 = undefined + +fun2 :: S () +fun2 = undefined + +fun3 :: H () +fun3 = undefined + +fun4 :: (F3 r ~ F1 (F2 m)) => r -> m () +fun4 = undefined + +test :: (C2 m, F2 m ~ Y) => m () +test = do + fun1 + fun2 + g fun3 + fun4 undefined + +main :: IO () +main = pure () ===================================== testsuite/tests/typecheck/should_fail/T24064.stderr ===================================== @@ -0,0 +1,26 @@ + +T24064.hs:42:3: error: [GHC-25897] + • Could not deduce ‘m ~ X e0’ + from the context: (C2 m, F2 m ~ Y) + bound by the type signature for: + test :: forall (m :: * -> *). (C2 m, F2 m ~ Y) => m () + at T24064.hs:40:1-32 + Expected: m () + Actual: X e0 () + ‘m’ is a rigid type variable bound by + the type signature for: + test :: forall (m :: * -> *). (C2 m, F2 m ~ Y) => m () + at T24064.hs:40:1-32 + • In a stmt of a 'do' block: fun1 + In the expression: + do fun1 + fun2 + g fun3 + fun4 undefined + In an equation for ‘test’: + test + = do fun1 + fun2 + g fun3 + .... + • Relevant bindings include test :: m () (bound at T24064.hs:41:1) ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -704,3 +704,4 @@ test('T22478c', normal, compile_fail, ['']) test('T23776', normal, compile, ['']) # to become an error in GHC 9.12 test('T17940', normal, compile_fail, ['']) test('ErrorIndexLinks', normal, compile_fail, ['-fprint-error-index-links=always']) +test('T24064', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/61ef011200275ed2d3bf3e3fc02dde253f0e3fe2...fbae18d9569c914d2fdd2825c39e7bdf7e8e42bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/61ef011200275ed2d3bf3e3fc02dde253f0e3fe2...fbae18d9569c914d2fdd2825c39e7bdf7e8e42bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 18:26:40 2023 From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani)) Date: Thu, 19 Oct 2023 14:26:40 -0400 Subject: [Git][ghc/ghc][wip/expand-do] 32 commits: Test that functions from `mingwex` are available Message-ID: <653174e0bf409_7336fa70a53c85875d9@gitlab.mail> Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC Commits: 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 21cdbe23 by Apoorv Ingle at 2023-10-19T13:25:46-05:00 Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. - A step towards killing `tcSyntaxOp` - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206 - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`: 1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`) 2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc` - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam` - Ensures warnings such as 1. Pattern mach checks 2. Failable patterns 3. non-() return in body statements are preserved - Expansions inside Template haskell also work without issues. - Testcases: * T18324 T20020 T23147 T22788 T15598 T22086 * T23147b (error message check), * DoubleMatch (match inside a match for pmc check) * pattern-fails (check pattern match with non-refutable pattern, eg. newtype) * Simple-rec (rec statements inside do statment) * T22788 (code snippet from #22788) * DoExpanion1 (Error messages for body statments) * DoExpansion2 (Error messages for bind statements) * DoExpansion3 (Error messages for let statements) - - - - - 26 changed files: - .ghcid - .gitignore - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/StgToCmm/CgUtils.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - + compiler/GHC/Tc/Gen/Do.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8bdbd78f102e72b33208a491c7d33c1b7f43397...21cdbe23764d15fe132d499a95817bdbdb942ad6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e8bdbd78f102e72b33208a491c7d33c1b7f43397...21cdbe23764d15fe132d499a95817bdbdb942ad6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 19 20:30:06 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 19 Oct 2023 16:30:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: rts: fix small argument passing on big-endian arch (fix #23387) Message-ID: <653191ce36ddd_7336fa9fa7dc4603764@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 31f95f01 by Sylvain Henry at 2023-10-19T16:29:51-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - e23f5272 by Sylvain Henry at 2023-10-19T16:29:54-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - 8fc371ce by Sylvain Henry at 2023-10-19T16:29:57-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - cf285d80 by Sebastian Graf at 2023-10-19T16:29:58-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 5 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/CoreToStg/Prep.hs - rts/Interpreter.c - testsuite/tests/driver/recomp011/all.T - testsuite/tests/driver/recomp015/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -43,23 +43,19 @@ import GHC.Platform import GHC.Platform.Profile import Control.Monad -import Control.Monad.ST ( runST ) import Control.Monad.Trans.Class import Control.Monad.Trans.State.Strict -import Data.Array.MArray - import qualified Data.Array.Unboxed as Array import Data.Array.Base ( UArray(..) ) -import Data.Array.Unsafe( castSTUArray ) - import Foreign hiding (shiftL, shiftR) import Data.Char ( ord ) import Data.List ( genericLength ) import Data.Map.Strict (Map) import Data.Maybe (fromMaybe) import qualified Data.Map.Strict as Map +import GHC.Float (castFloatToWord32, castDoubleToWord64) -- ----------------------------------------------------------------------------- -- Unlinked BCOs @@ -416,7 +412,7 @@ assembleI platform i = case i of tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) - info <- int (fromIntegral $ + info <- word (fromIntegral $ mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] @@ -466,21 +462,21 @@ assembleI platform i = case i of emit bci_TESTLT_W [Op np, LabelOp l] TESTEQ_W w l -> do np <- word w emit bci_TESTEQ_W [Op np, LabelOp l] - TESTLT_I64 i l -> do np <- int64 i + TESTLT_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTLT_I64 [Op np, LabelOp l] - TESTEQ_I64 i l -> do np <- int64 i + TESTEQ_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTEQ_I64 [Op np, LabelOp l] - TESTLT_I32 i l -> do np <- int (fromIntegral i) + TESTLT_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I32 [Op np, LabelOp l] - TESTEQ_I32 i l -> do np <- int (fromIntegral i) + TESTEQ_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I32 [Op np, LabelOp l] - TESTLT_I16 i l -> do np <- int (fromIntegral i) + TESTLT_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I16 [Op np, LabelOp l] - TESTEQ_I16 i l -> do np <- int (fromIntegral i) + TESTEQ_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I16 [Op np, LabelOp l] - TESTLT_I8 i l -> do np <- int (fromIntegral i) + TESTLT_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I8 [Op np, LabelOp l] - TESTEQ_I8 i l -> do np <- int (fromIntegral i) + TESTEQ_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I8 [Op np, LabelOp l] TESTLT_W64 w l -> do np <- word64 w emit bci_TESTLT_W64 [Op np, LabelOp l] @@ -530,42 +526,80 @@ assembleI platform i = case i of -- On Windows, stdcall labels have a suffix indicating the no. of -- arg words, e.g. foo at 8. testcase: ffi012(ghci) literal (LitLabel fs _ _) = litlabel fs - literal LitNullAddr = int 0 + literal LitNullAddr = word 0 literal (LitFloat r) = float (fromRational r) literal (LitDouble r) = double (fromRational r) literal (LitChar c) = int (ord c) literal (LitString bs) = lit [BCONPtrStr bs] -- LitString requires a zero-terminator when emitted literal (LitNumber nt i) = case nt of - LitNumInt -> int (fromIntegral i) - LitNumWord -> int (fromIntegral i) - LitNumInt8 -> int8 (fromIntegral i) - LitNumWord8 -> int8 (fromIntegral i) - LitNumInt16 -> int16 (fromIntegral i) - LitNumWord16 -> int16 (fromIntegral i) - LitNumInt32 -> int32 (fromIntegral i) - LitNumWord32 -> int32 (fromIntegral i) - LitNumInt64 -> int64 (fromIntegral i) - LitNumWord64 -> int64 (fromIntegral i) + LitNumInt -> word (fromIntegral i) + LitNumWord -> word (fromIntegral i) + LitNumInt8 -> word8 (fromIntegral i) + LitNumWord8 -> word8 (fromIntegral i) + LitNumInt16 -> word16 (fromIntegral i) + LitNumWord16 -> word16 (fromIntegral i) + LitNumInt32 -> word32 (fromIntegral i) + LitNumWord32 -> word32 (fromIntegral i) + LitNumInt64 -> word64 (fromIntegral i) + LitNumWord64 -> word64 (fromIntegral i) LitNumBigNat -> panic "GHC.ByteCode.Asm.literal: LitNumBigNat" -- We can lower 'LitRubbish' to an arbitrary constant, but @NULL@ is most -- likely to elicit a crash (rather than corrupt memory) in case absence -- analysis messed up. - literal (LitRubbish {}) = int 0 + literal (LitRubbish {}) = word 0 litlabel fs = lit [BCONPtrLbl fs] addr (RemotePtr a) = words [fromIntegral a] - float = words . mkLitF platform - double = words . mkLitD platform - int = words . mkLitI - int8 = words . mkLitI64 platform - int16 = words . mkLitI64 platform - int32 = words . mkLitI64 platform - int64 = words . mkLitI64 platform - word64 = words . mkLitW64 platform words ws = lit (map BCONPtrWord ws) word w = words [w] + word_size = platformWordSize platform + word_size_bits = platformWordSizeInBits platform + + -- Make lists of host-sized words for literals, so that when the + -- words are placed in memory at increasing addresses, the + -- bit pattern is correct for the host's word size and endianness. + -- + -- Note that we only support host endianness == target endianness for now, + -- even with the external interpreter. This would need to be fixed to + -- support host endianness /= target endianness + int :: Int -> Assembler Word + int i = word (fromIntegral i) + + float :: Float -> Assembler Word + float f = word32 (castFloatToWord32 f) + + double :: Double -> Assembler Word + double d = word64 (castDoubleToWord64 d) + + word64 :: Word64 -> Assembler Word + word64 ww = case word_size of + PW4 -> + let !wl = fromIntegral ww + !wh = fromIntegral (ww `unsafeShiftR` 32) + in case platformByteOrder platform of + LittleEndian -> words [wl,wh] + BigEndian -> words [wh,wl] + PW8 -> word (fromIntegral ww) + + word8 :: Word8 -> Assembler Word + word8 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 8)) + + word16 :: Word16 -> Assembler Word + word16 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 16)) + + word32 :: Word32 -> Assembler Word + word32 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> case word_size of + PW4 -> word (fromIntegral x) + PW8 -> word (fromIntegral x `unsafeShiftL` 32) + isLargeW :: Word -> Bool isLargeW n = n > 65535 @@ -648,74 +682,5 @@ mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal mkNativeCallInfoLit platform call_info = mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info --- Make lists of host-sized words for literals, so that when the --- words are placed in memory at increasing addresses, the --- bit pattern is correct for the host's word size and endianness. -mkLitI :: Int -> [Word] -mkLitF :: Platform -> Float -> [Word] -mkLitD :: Platform -> Double -> [Word] -mkLitI64 :: Platform -> Int64 -> [Word] -mkLitW64 :: Platform -> Word64 -> [Word] - -mkLitF platform f = case platformWordSize platform of - PW4 -> runST $ do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 f - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - - PW8 -> runST $ do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 f - -- on 64-bit architectures we read two (32-bit) Float cells when we read - -- a (64-bit) Word: so we write a dummy value in the second cell to - -- avoid an out-of-bound read. - writeArray arr 1 0.0 - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - -mkLitD platform d = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word, w1] - ) - PW8 -> runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - return [w0 :: Word] - ) - -mkLitI64 platform ii = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 ii - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ii :: Word] - -mkLitW64 platform ww = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Word),1) - writeArray arr 0 ww - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ww :: Word] - -mkLitI i = [fromIntegral i :: Word] - iNTERP_STACK_CHECK_THRESH :: Int iNTERP_STACK_CHECK_THRESH = INTERP_STACK_CHECK_THRESH ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -643,13 +643,20 @@ cpeBind top_lvl env (Rec pairs) where (bndrs, rhss) = unzip pairs - -- Flatten all the floats, and the current - -- group into a single giant Rec + -- Flatten all the floats, and the current + -- group into a single giant Rec add_float (Float bind bound _) prs2 - | bound /= CaseBound = case bind of + | bound /= CaseBound + || all (definitelyLiftedType . idType) (bindersOf bind) + -- The latter check is hit in -O0 (i.e., flavours quick, devel2) + -- for dictionary args which haven't been floated out yet, #24102. + -- They are preferably CaseBound, but since they are lifted we may + -- just as well put them in the Rec, in contrast to lifted bindings. + = case bind of NonRec x e -> (x,e) : prs2 Rec prs1 -> prs1 ++ prs2 - add_float f _ = pprPanic "cpeBind" (ppr f) + add_float f _ = pprPanic "cpeBind" (ppr f) + --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool ===================================== rts/Interpreter.c ===================================== @@ -1275,21 +1275,21 @@ run_BCO: case bci_PUSH8_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); + *(StgWord8*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH16_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); + *(StgWord16*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH32_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); + *(StgWord32*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } ===================================== testsuite/tests/driver/recomp011/all.T ===================================== @@ -2,7 +2,6 @@ test('recomp011', [ extra_files(['Main.hs']) - , when(arch('powerpc64'), expect_broken(11260)) , js_broken(22261) ], makefile_test, []) ===================================== testsuite/tests/driver/recomp015/all.T ===================================== @@ -5,7 +5,7 @@ test('recomp015', # See ticket:11022#comment:7 unless(opsys('linux') or opsys('solaris2') or opsys('openbsd'), skip), when(arch('arm'), skip), - js_skip, # JS backend doesn't support .s assembly files - when(arch('powerpc64'), expect_broken(11323))], + js_skip # JS backend doesn't support .s assembly files + ], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fbae18d9569c914d2fdd2825c39e7bdf7e8e42bd...cf285d806a45bf7057d31469c950959c7e3d6ead -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fbae18d9569c914d2fdd2825c39e7bdf7e8e42bd...cf285d806a45bf7057d31469c950959c7e3d6ead You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 00:20:50 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 19 Oct 2023 20:20:50 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: rts: fix small argument passing on big-endian arch (fix #23387) Message-ID: <6531c7e2511_7336faf28bd38627842@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 38eaed1f by Sylvain Henry at 2023-10-19T20:20:22-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - 8fcc059e by Sylvain Henry at 2023-10-19T20:20:25-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - 4aab2e4a by Sylvain Henry at 2023-10-19T20:20:28-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - a60ad05c by Sebastian Graf at 2023-10-19T20:20:29-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 5 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/CoreToStg/Prep.hs - rts/Interpreter.c - testsuite/tests/driver/recomp011/all.T - testsuite/tests/driver/recomp015/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -43,23 +43,19 @@ import GHC.Platform import GHC.Platform.Profile import Control.Monad -import Control.Monad.ST ( runST ) import Control.Monad.Trans.Class import Control.Monad.Trans.State.Strict -import Data.Array.MArray - import qualified Data.Array.Unboxed as Array import Data.Array.Base ( UArray(..) ) -import Data.Array.Unsafe( castSTUArray ) - import Foreign hiding (shiftL, shiftR) import Data.Char ( ord ) import Data.List ( genericLength ) import Data.Map.Strict (Map) import Data.Maybe (fromMaybe) import qualified Data.Map.Strict as Map +import GHC.Float (castFloatToWord32, castDoubleToWord64) -- ----------------------------------------------------------------------------- -- Unlinked BCOs @@ -416,7 +412,7 @@ assembleI platform i = case i of tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) - info <- int (fromIntegral $ + info <- word (fromIntegral $ mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] @@ -466,21 +462,21 @@ assembleI platform i = case i of emit bci_TESTLT_W [Op np, LabelOp l] TESTEQ_W w l -> do np <- word w emit bci_TESTEQ_W [Op np, LabelOp l] - TESTLT_I64 i l -> do np <- int64 i + TESTLT_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTLT_I64 [Op np, LabelOp l] - TESTEQ_I64 i l -> do np <- int64 i + TESTEQ_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTEQ_I64 [Op np, LabelOp l] - TESTLT_I32 i l -> do np <- int (fromIntegral i) + TESTLT_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I32 [Op np, LabelOp l] - TESTEQ_I32 i l -> do np <- int (fromIntegral i) + TESTEQ_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I32 [Op np, LabelOp l] - TESTLT_I16 i l -> do np <- int (fromIntegral i) + TESTLT_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I16 [Op np, LabelOp l] - TESTEQ_I16 i l -> do np <- int (fromIntegral i) + TESTEQ_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I16 [Op np, LabelOp l] - TESTLT_I8 i l -> do np <- int (fromIntegral i) + TESTLT_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I8 [Op np, LabelOp l] - TESTEQ_I8 i l -> do np <- int (fromIntegral i) + TESTEQ_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I8 [Op np, LabelOp l] TESTLT_W64 w l -> do np <- word64 w emit bci_TESTLT_W64 [Op np, LabelOp l] @@ -530,42 +526,80 @@ assembleI platform i = case i of -- On Windows, stdcall labels have a suffix indicating the no. of -- arg words, e.g. foo at 8. testcase: ffi012(ghci) literal (LitLabel fs _ _) = litlabel fs - literal LitNullAddr = int 0 + literal LitNullAddr = word 0 literal (LitFloat r) = float (fromRational r) literal (LitDouble r) = double (fromRational r) literal (LitChar c) = int (ord c) literal (LitString bs) = lit [BCONPtrStr bs] -- LitString requires a zero-terminator when emitted literal (LitNumber nt i) = case nt of - LitNumInt -> int (fromIntegral i) - LitNumWord -> int (fromIntegral i) - LitNumInt8 -> int8 (fromIntegral i) - LitNumWord8 -> int8 (fromIntegral i) - LitNumInt16 -> int16 (fromIntegral i) - LitNumWord16 -> int16 (fromIntegral i) - LitNumInt32 -> int32 (fromIntegral i) - LitNumWord32 -> int32 (fromIntegral i) - LitNumInt64 -> int64 (fromIntegral i) - LitNumWord64 -> int64 (fromIntegral i) + LitNumInt -> word (fromIntegral i) + LitNumWord -> word (fromIntegral i) + LitNumInt8 -> word8 (fromIntegral i) + LitNumWord8 -> word8 (fromIntegral i) + LitNumInt16 -> word16 (fromIntegral i) + LitNumWord16 -> word16 (fromIntegral i) + LitNumInt32 -> word32 (fromIntegral i) + LitNumWord32 -> word32 (fromIntegral i) + LitNumInt64 -> word64 (fromIntegral i) + LitNumWord64 -> word64 (fromIntegral i) LitNumBigNat -> panic "GHC.ByteCode.Asm.literal: LitNumBigNat" -- We can lower 'LitRubbish' to an arbitrary constant, but @NULL@ is most -- likely to elicit a crash (rather than corrupt memory) in case absence -- analysis messed up. - literal (LitRubbish {}) = int 0 + literal (LitRubbish {}) = word 0 litlabel fs = lit [BCONPtrLbl fs] addr (RemotePtr a) = words [fromIntegral a] - float = words . mkLitF platform - double = words . mkLitD platform - int = words . mkLitI - int8 = words . mkLitI64 platform - int16 = words . mkLitI64 platform - int32 = words . mkLitI64 platform - int64 = words . mkLitI64 platform - word64 = words . mkLitW64 platform words ws = lit (map BCONPtrWord ws) word w = words [w] + word_size = platformWordSize platform + word_size_bits = platformWordSizeInBits platform + + -- Make lists of host-sized words for literals, so that when the + -- words are placed in memory at increasing addresses, the + -- bit pattern is correct for the host's word size and endianness. + -- + -- Note that we only support host endianness == target endianness for now, + -- even with the external interpreter. This would need to be fixed to + -- support host endianness /= target endianness + int :: Int -> Assembler Word + int i = word (fromIntegral i) + + float :: Float -> Assembler Word + float f = word32 (castFloatToWord32 f) + + double :: Double -> Assembler Word + double d = word64 (castDoubleToWord64 d) + + word64 :: Word64 -> Assembler Word + word64 ww = case word_size of + PW4 -> + let !wl = fromIntegral ww + !wh = fromIntegral (ww `unsafeShiftR` 32) + in case platformByteOrder platform of + LittleEndian -> words [wl,wh] + BigEndian -> words [wh,wl] + PW8 -> word (fromIntegral ww) + + word8 :: Word8 -> Assembler Word + word8 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 8)) + + word16 :: Word16 -> Assembler Word + word16 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 16)) + + word32 :: Word32 -> Assembler Word + word32 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> case word_size of + PW4 -> word (fromIntegral x) + PW8 -> word (fromIntegral x `unsafeShiftL` 32) + isLargeW :: Word -> Bool isLargeW n = n > 65535 @@ -648,74 +682,5 @@ mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal mkNativeCallInfoLit platform call_info = mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info --- Make lists of host-sized words for literals, so that when the --- words are placed in memory at increasing addresses, the --- bit pattern is correct for the host's word size and endianness. -mkLitI :: Int -> [Word] -mkLitF :: Platform -> Float -> [Word] -mkLitD :: Platform -> Double -> [Word] -mkLitI64 :: Platform -> Int64 -> [Word] -mkLitW64 :: Platform -> Word64 -> [Word] - -mkLitF platform f = case platformWordSize platform of - PW4 -> runST $ do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 f - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - - PW8 -> runST $ do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 f - -- on 64-bit architectures we read two (32-bit) Float cells when we read - -- a (64-bit) Word: so we write a dummy value in the second cell to - -- avoid an out-of-bound read. - writeArray arr 1 0.0 - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - -mkLitD platform d = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word, w1] - ) - PW8 -> runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - return [w0 :: Word] - ) - -mkLitI64 platform ii = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 ii - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ii :: Word] - -mkLitW64 platform ww = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Word),1) - writeArray arr 0 ww - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ww :: Word] - -mkLitI i = [fromIntegral i :: Word] - iNTERP_STACK_CHECK_THRESH :: Int iNTERP_STACK_CHECK_THRESH = INTERP_STACK_CHECK_THRESH ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -643,13 +643,20 @@ cpeBind top_lvl env (Rec pairs) where (bndrs, rhss) = unzip pairs - -- Flatten all the floats, and the current - -- group into a single giant Rec + -- Flatten all the floats, and the current + -- group into a single giant Rec add_float (Float bind bound _) prs2 - | bound /= CaseBound = case bind of + | bound /= CaseBound + || all (definitelyLiftedType . idType) (bindersOf bind) + -- The latter check is hit in -O0 (i.e., flavours quick, devel2) + -- for dictionary args which haven't been floated out yet, #24102. + -- They are preferably CaseBound, but since they are lifted we may + -- just as well put them in the Rec, in contrast to lifted bindings. + = case bind of NonRec x e -> (x,e) : prs2 Rec prs1 -> prs1 ++ prs2 - add_float f _ = pprPanic "cpeBind" (ppr f) + add_float f _ = pprPanic "cpeBind" (ppr f) + --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool ===================================== rts/Interpreter.c ===================================== @@ -1275,21 +1275,21 @@ run_BCO: case bci_PUSH8_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); + *(StgWord8*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH16_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); + *(StgWord16*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH32_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); + *(StgWord32*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } ===================================== testsuite/tests/driver/recomp011/all.T ===================================== @@ -2,7 +2,6 @@ test('recomp011', [ extra_files(['Main.hs']) - , when(arch('powerpc64'), expect_broken(11260)) , js_broken(22261) ], makefile_test, []) ===================================== testsuite/tests/driver/recomp015/all.T ===================================== @@ -5,7 +5,7 @@ test('recomp015', # See ticket:11022#comment:7 unless(opsys('linux') or opsys('solaris2') or opsys('openbsd'), skip), when(arch('arm'), skip), - js_skip, # JS backend doesn't support .s assembly files - when(arch('powerpc64'), expect_broken(11323))], + js_skip # JS backend doesn't support .s assembly files + ], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cf285d806a45bf7057d31469c950959c7e3d6ead...a60ad05cae46b408a7ec813d27147b6724f75ca3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cf285d806a45bf7057d31469c950959c7e3d6ead...a60ad05cae46b408a7ec813d27147b6724f75ca3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 05:07:35 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 20 Oct 2023 01:07:35 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/simpler-ghcversion.h Message-ID: <65320b17ac236_7336fb61120cc644597@gitlab.mail> John Ericson deleted branch wip/simpler-ghcversion.h at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 05:08:30 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 20 Oct 2023 01:08:30 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/rts-configure-2 Message-ID: <65320b4e3e845_7336fb6109e0464474d@gitlab.mail> John Ericson deleted branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 05:08:32 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 20 Oct 2023 01:08:32 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/rts-configure-libdw-libnuma Message-ID: <65320b5050c4f_7336fb61183dc6449f@gitlab.mail> John Ericson deleted branch wip/rts-configure-libdw-libnuma at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 05:08:34 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Fri, 20 Oct 2023 01:08:34 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/rts-configure-mmap-runtime-linker Message-ID: <65320b5226363_7336fb61183dc6451b3@gitlab.mail> John Ericson deleted branch wip/rts-configure-mmap-runtime-linker at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 05:11:33 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 20 Oct 2023 01:11:33 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: rts: fix small argument passing on big-endian arch (fix #23387) Message-ID: <65320c0510484_7336fb6138420648124@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 15c288c0 by Sylvain Henry at 2023-10-20T01:11:14-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - 89872302 by Sylvain Henry at 2023-10-20T01:11:16-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - e08fe4a8 by Sylvain Henry at 2023-10-20T01:11:20-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - 5cce070d by Sebastian Graf at 2023-10-20T01:11:20-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 5 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/CoreToStg/Prep.hs - rts/Interpreter.c - testsuite/tests/driver/recomp011/all.T - testsuite/tests/driver/recomp015/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -43,23 +43,19 @@ import GHC.Platform import GHC.Platform.Profile import Control.Monad -import Control.Monad.ST ( runST ) import Control.Monad.Trans.Class import Control.Monad.Trans.State.Strict -import Data.Array.MArray - import qualified Data.Array.Unboxed as Array import Data.Array.Base ( UArray(..) ) -import Data.Array.Unsafe( castSTUArray ) - import Foreign hiding (shiftL, shiftR) import Data.Char ( ord ) import Data.List ( genericLength ) import Data.Map.Strict (Map) import Data.Maybe (fromMaybe) import qualified Data.Map.Strict as Map +import GHC.Float (castFloatToWord32, castDoubleToWord64) -- ----------------------------------------------------------------------------- -- Unlinked BCOs @@ -416,7 +412,7 @@ assembleI platform i = case i of tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) - info <- int (fromIntegral $ + info <- word (fromIntegral $ mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] @@ -466,21 +462,21 @@ assembleI platform i = case i of emit bci_TESTLT_W [Op np, LabelOp l] TESTEQ_W w l -> do np <- word w emit bci_TESTEQ_W [Op np, LabelOp l] - TESTLT_I64 i l -> do np <- int64 i + TESTLT_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTLT_I64 [Op np, LabelOp l] - TESTEQ_I64 i l -> do np <- int64 i + TESTEQ_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTEQ_I64 [Op np, LabelOp l] - TESTLT_I32 i l -> do np <- int (fromIntegral i) + TESTLT_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I32 [Op np, LabelOp l] - TESTEQ_I32 i l -> do np <- int (fromIntegral i) + TESTEQ_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I32 [Op np, LabelOp l] - TESTLT_I16 i l -> do np <- int (fromIntegral i) + TESTLT_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I16 [Op np, LabelOp l] - TESTEQ_I16 i l -> do np <- int (fromIntegral i) + TESTEQ_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I16 [Op np, LabelOp l] - TESTLT_I8 i l -> do np <- int (fromIntegral i) + TESTLT_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I8 [Op np, LabelOp l] - TESTEQ_I8 i l -> do np <- int (fromIntegral i) + TESTEQ_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I8 [Op np, LabelOp l] TESTLT_W64 w l -> do np <- word64 w emit bci_TESTLT_W64 [Op np, LabelOp l] @@ -530,42 +526,80 @@ assembleI platform i = case i of -- On Windows, stdcall labels have a suffix indicating the no. of -- arg words, e.g. foo at 8. testcase: ffi012(ghci) literal (LitLabel fs _ _) = litlabel fs - literal LitNullAddr = int 0 + literal LitNullAddr = word 0 literal (LitFloat r) = float (fromRational r) literal (LitDouble r) = double (fromRational r) literal (LitChar c) = int (ord c) literal (LitString bs) = lit [BCONPtrStr bs] -- LitString requires a zero-terminator when emitted literal (LitNumber nt i) = case nt of - LitNumInt -> int (fromIntegral i) - LitNumWord -> int (fromIntegral i) - LitNumInt8 -> int8 (fromIntegral i) - LitNumWord8 -> int8 (fromIntegral i) - LitNumInt16 -> int16 (fromIntegral i) - LitNumWord16 -> int16 (fromIntegral i) - LitNumInt32 -> int32 (fromIntegral i) - LitNumWord32 -> int32 (fromIntegral i) - LitNumInt64 -> int64 (fromIntegral i) - LitNumWord64 -> int64 (fromIntegral i) + LitNumInt -> word (fromIntegral i) + LitNumWord -> word (fromIntegral i) + LitNumInt8 -> word8 (fromIntegral i) + LitNumWord8 -> word8 (fromIntegral i) + LitNumInt16 -> word16 (fromIntegral i) + LitNumWord16 -> word16 (fromIntegral i) + LitNumInt32 -> word32 (fromIntegral i) + LitNumWord32 -> word32 (fromIntegral i) + LitNumInt64 -> word64 (fromIntegral i) + LitNumWord64 -> word64 (fromIntegral i) LitNumBigNat -> panic "GHC.ByteCode.Asm.literal: LitNumBigNat" -- We can lower 'LitRubbish' to an arbitrary constant, but @NULL@ is most -- likely to elicit a crash (rather than corrupt memory) in case absence -- analysis messed up. - literal (LitRubbish {}) = int 0 + literal (LitRubbish {}) = word 0 litlabel fs = lit [BCONPtrLbl fs] addr (RemotePtr a) = words [fromIntegral a] - float = words . mkLitF platform - double = words . mkLitD platform - int = words . mkLitI - int8 = words . mkLitI64 platform - int16 = words . mkLitI64 platform - int32 = words . mkLitI64 platform - int64 = words . mkLitI64 platform - word64 = words . mkLitW64 platform words ws = lit (map BCONPtrWord ws) word w = words [w] + word_size = platformWordSize platform + word_size_bits = platformWordSizeInBits platform + + -- Make lists of host-sized words for literals, so that when the + -- words are placed in memory at increasing addresses, the + -- bit pattern is correct for the host's word size and endianness. + -- + -- Note that we only support host endianness == target endianness for now, + -- even with the external interpreter. This would need to be fixed to + -- support host endianness /= target endianness + int :: Int -> Assembler Word + int i = word (fromIntegral i) + + float :: Float -> Assembler Word + float f = word32 (castFloatToWord32 f) + + double :: Double -> Assembler Word + double d = word64 (castDoubleToWord64 d) + + word64 :: Word64 -> Assembler Word + word64 ww = case word_size of + PW4 -> + let !wl = fromIntegral ww + !wh = fromIntegral (ww `unsafeShiftR` 32) + in case platformByteOrder platform of + LittleEndian -> words [wl,wh] + BigEndian -> words [wh,wl] + PW8 -> word (fromIntegral ww) + + word8 :: Word8 -> Assembler Word + word8 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 8)) + + word16 :: Word16 -> Assembler Word + word16 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 16)) + + word32 :: Word32 -> Assembler Word + word32 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> case word_size of + PW4 -> word (fromIntegral x) + PW8 -> word (fromIntegral x `unsafeShiftL` 32) + isLargeW :: Word -> Bool isLargeW n = n > 65535 @@ -648,74 +682,5 @@ mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal mkNativeCallInfoLit platform call_info = mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info --- Make lists of host-sized words for literals, so that when the --- words are placed in memory at increasing addresses, the --- bit pattern is correct for the host's word size and endianness. -mkLitI :: Int -> [Word] -mkLitF :: Platform -> Float -> [Word] -mkLitD :: Platform -> Double -> [Word] -mkLitI64 :: Platform -> Int64 -> [Word] -mkLitW64 :: Platform -> Word64 -> [Word] - -mkLitF platform f = case platformWordSize platform of - PW4 -> runST $ do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 f - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - - PW8 -> runST $ do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 f - -- on 64-bit architectures we read two (32-bit) Float cells when we read - -- a (64-bit) Word: so we write a dummy value in the second cell to - -- avoid an out-of-bound read. - writeArray arr 1 0.0 - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - -mkLitD platform d = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word, w1] - ) - PW8 -> runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - return [w0 :: Word] - ) - -mkLitI64 platform ii = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 ii - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ii :: Word] - -mkLitW64 platform ww = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Word),1) - writeArray arr 0 ww - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ww :: Word] - -mkLitI i = [fromIntegral i :: Word] - iNTERP_STACK_CHECK_THRESH :: Int iNTERP_STACK_CHECK_THRESH = INTERP_STACK_CHECK_THRESH ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -643,13 +643,20 @@ cpeBind top_lvl env (Rec pairs) where (bndrs, rhss) = unzip pairs - -- Flatten all the floats, and the current - -- group into a single giant Rec + -- Flatten all the floats, and the current + -- group into a single giant Rec add_float (Float bind bound _) prs2 - | bound /= CaseBound = case bind of + | bound /= CaseBound + || all (definitelyLiftedType . idType) (bindersOf bind) + -- The latter check is hit in -O0 (i.e., flavours quick, devel2) + -- for dictionary args which haven't been floated out yet, #24102. + -- They are preferably CaseBound, but since they are lifted we may + -- just as well put them in the Rec, in contrast to lifted bindings. + = case bind of NonRec x e -> (x,e) : prs2 Rec prs1 -> prs1 ++ prs2 - add_float f _ = pprPanic "cpeBind" (ppr f) + add_float f _ = pprPanic "cpeBind" (ppr f) + --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool ===================================== rts/Interpreter.c ===================================== @@ -1275,21 +1275,21 @@ run_BCO: case bci_PUSH8_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); + *(StgWord8*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH16_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); + *(StgWord16*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH32_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); + *(StgWord32*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } ===================================== testsuite/tests/driver/recomp011/all.T ===================================== @@ -2,7 +2,6 @@ test('recomp011', [ extra_files(['Main.hs']) - , when(arch('powerpc64'), expect_broken(11260)) , js_broken(22261) ], makefile_test, []) ===================================== testsuite/tests/driver/recomp015/all.T ===================================== @@ -5,7 +5,7 @@ test('recomp015', # See ticket:11022#comment:7 unless(opsys('linux') or opsys('solaris2') or opsys('openbsd'), skip), when(arch('arm'), skip), - js_skip, # JS backend doesn't support .s assembly files - when(arch('powerpc64'), expect_broken(11323))], + js_skip # JS backend doesn't support .s assembly files + ], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a60ad05cae46b408a7ec813d27147b6724f75ca3...5cce070d396e17283528a64cc63841330b9c5020 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a60ad05cae46b408a7ec813d27147b6724f75ca3...5cce070d396e17283528a64cc63841330b9c5020 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 07:26:13 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 20 Oct 2023 03:26:13 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/spj-unf-size Message-ID: <65322b95b936_7336fb945bc6c6641f2@gitlab.mail> Simon Peyton Jones pushed new branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/spj-unf-size You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 08:02:03 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 20 Oct 2023 04:02:03 -0400 Subject: [Git][ghc/ghc][master] rts: fix small argument passing on big-endian arch (fix #23387) Message-ID: <653233fbdfd3a_7336fba248bf46689ec@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - 1 changed file: - rts/Interpreter.c Changes: ===================================== rts/Interpreter.c ===================================== @@ -1275,21 +1275,21 @@ run_BCO: case bci_PUSH8_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); + *(StgWord8*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH16_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); + *(StgWord16*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH32_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); + *(StgWord32*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f02d3c1a7b707e609bb3aea1dc6324fa19a5c39 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f02d3c1a7b707e609bb3aea1dc6324fa19a5c39 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 08:02:45 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 20 Oct 2023 04:02:45 -0400 Subject: [Git][ghc/ghc][master] Interpreter: fix literal alignment on big-endian architectures (fix #19261) Message-ID: <65323425e705_7336fba25875c673661@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - 1 changed file: - compiler/GHC/ByteCode/Asm.hs Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -43,23 +43,19 @@ import GHC.Platform import GHC.Platform.Profile import Control.Monad -import Control.Monad.ST ( runST ) import Control.Monad.Trans.Class import Control.Monad.Trans.State.Strict -import Data.Array.MArray - import qualified Data.Array.Unboxed as Array import Data.Array.Base ( UArray(..) ) -import Data.Array.Unsafe( castSTUArray ) - import Foreign hiding (shiftL, shiftR) import Data.Char ( ord ) import Data.List ( genericLength ) import Data.Map.Strict (Map) import Data.Maybe (fromMaybe) import qualified Data.Map.Strict as Map +import GHC.Float (castFloatToWord32, castDoubleToWord64) -- ----------------------------------------------------------------------------- -- Unlinked BCOs @@ -416,7 +412,7 @@ assembleI platform i = case i of tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) - info <- int (fromIntegral $ + info <- word (fromIntegral $ mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] @@ -466,21 +462,21 @@ assembleI platform i = case i of emit bci_TESTLT_W [Op np, LabelOp l] TESTEQ_W w l -> do np <- word w emit bci_TESTEQ_W [Op np, LabelOp l] - TESTLT_I64 i l -> do np <- int64 i + TESTLT_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTLT_I64 [Op np, LabelOp l] - TESTEQ_I64 i l -> do np <- int64 i + TESTEQ_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTEQ_I64 [Op np, LabelOp l] - TESTLT_I32 i l -> do np <- int (fromIntegral i) + TESTLT_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I32 [Op np, LabelOp l] - TESTEQ_I32 i l -> do np <- int (fromIntegral i) + TESTEQ_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I32 [Op np, LabelOp l] - TESTLT_I16 i l -> do np <- int (fromIntegral i) + TESTLT_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I16 [Op np, LabelOp l] - TESTEQ_I16 i l -> do np <- int (fromIntegral i) + TESTEQ_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I16 [Op np, LabelOp l] - TESTLT_I8 i l -> do np <- int (fromIntegral i) + TESTLT_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I8 [Op np, LabelOp l] - TESTEQ_I8 i l -> do np <- int (fromIntegral i) + TESTEQ_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I8 [Op np, LabelOp l] TESTLT_W64 w l -> do np <- word64 w emit bci_TESTLT_W64 [Op np, LabelOp l] @@ -530,42 +526,80 @@ assembleI platform i = case i of -- On Windows, stdcall labels have a suffix indicating the no. of -- arg words, e.g. foo at 8. testcase: ffi012(ghci) literal (LitLabel fs _ _) = litlabel fs - literal LitNullAddr = int 0 + literal LitNullAddr = word 0 literal (LitFloat r) = float (fromRational r) literal (LitDouble r) = double (fromRational r) literal (LitChar c) = int (ord c) literal (LitString bs) = lit [BCONPtrStr bs] -- LitString requires a zero-terminator when emitted literal (LitNumber nt i) = case nt of - LitNumInt -> int (fromIntegral i) - LitNumWord -> int (fromIntegral i) - LitNumInt8 -> int8 (fromIntegral i) - LitNumWord8 -> int8 (fromIntegral i) - LitNumInt16 -> int16 (fromIntegral i) - LitNumWord16 -> int16 (fromIntegral i) - LitNumInt32 -> int32 (fromIntegral i) - LitNumWord32 -> int32 (fromIntegral i) - LitNumInt64 -> int64 (fromIntegral i) - LitNumWord64 -> int64 (fromIntegral i) + LitNumInt -> word (fromIntegral i) + LitNumWord -> word (fromIntegral i) + LitNumInt8 -> word8 (fromIntegral i) + LitNumWord8 -> word8 (fromIntegral i) + LitNumInt16 -> word16 (fromIntegral i) + LitNumWord16 -> word16 (fromIntegral i) + LitNumInt32 -> word32 (fromIntegral i) + LitNumWord32 -> word32 (fromIntegral i) + LitNumInt64 -> word64 (fromIntegral i) + LitNumWord64 -> word64 (fromIntegral i) LitNumBigNat -> panic "GHC.ByteCode.Asm.literal: LitNumBigNat" -- We can lower 'LitRubbish' to an arbitrary constant, but @NULL@ is most -- likely to elicit a crash (rather than corrupt memory) in case absence -- analysis messed up. - literal (LitRubbish {}) = int 0 + literal (LitRubbish {}) = word 0 litlabel fs = lit [BCONPtrLbl fs] addr (RemotePtr a) = words [fromIntegral a] - float = words . mkLitF platform - double = words . mkLitD platform - int = words . mkLitI - int8 = words . mkLitI64 platform - int16 = words . mkLitI64 platform - int32 = words . mkLitI64 platform - int64 = words . mkLitI64 platform - word64 = words . mkLitW64 platform words ws = lit (map BCONPtrWord ws) word w = words [w] + word_size = platformWordSize platform + word_size_bits = platformWordSizeInBits platform + + -- Make lists of host-sized words for literals, so that when the + -- words are placed in memory at increasing addresses, the + -- bit pattern is correct for the host's word size and endianness. + -- + -- Note that we only support host endianness == target endianness for now, + -- even with the external interpreter. This would need to be fixed to + -- support host endianness /= target endianness + int :: Int -> Assembler Word + int i = word (fromIntegral i) + + float :: Float -> Assembler Word + float f = word32 (castFloatToWord32 f) + + double :: Double -> Assembler Word + double d = word64 (castDoubleToWord64 d) + + word64 :: Word64 -> Assembler Word + word64 ww = case word_size of + PW4 -> + let !wl = fromIntegral ww + !wh = fromIntegral (ww `unsafeShiftR` 32) + in case platformByteOrder platform of + LittleEndian -> words [wl,wh] + BigEndian -> words [wh,wl] + PW8 -> word (fromIntegral ww) + + word8 :: Word8 -> Assembler Word + word8 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 8)) + + word16 :: Word16 -> Assembler Word + word16 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 16)) + + word32 :: Word32 -> Assembler Word + word32 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> case word_size of + PW4 -> word (fromIntegral x) + PW8 -> word (fromIntegral x `unsafeShiftL` 32) + isLargeW :: Word -> Bool isLargeW n = n > 65535 @@ -648,74 +682,5 @@ mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal mkNativeCallInfoLit platform call_info = mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info --- Make lists of host-sized words for literals, so that when the --- words are placed in memory at increasing addresses, the --- bit pattern is correct for the host's word size and endianness. -mkLitI :: Int -> [Word] -mkLitF :: Platform -> Float -> [Word] -mkLitD :: Platform -> Double -> [Word] -mkLitI64 :: Platform -> Int64 -> [Word] -mkLitW64 :: Platform -> Word64 -> [Word] - -mkLitF platform f = case platformWordSize platform of - PW4 -> runST $ do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 f - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - - PW8 -> runST $ do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 f - -- on 64-bit architectures we read two (32-bit) Float cells when we read - -- a (64-bit) Word: so we write a dummy value in the second cell to - -- avoid an out-of-bound read. - writeArray arr 1 0.0 - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - -mkLitD platform d = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word, w1] - ) - PW8 -> runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - return [w0 :: Word] - ) - -mkLitI64 platform ii = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 ii - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ii :: Word] - -mkLitW64 platform ww = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Word),1) - writeArray arr 0 ww - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ww :: Word] - -mkLitI i = [fromIntegral i :: Word] - iNTERP_STACK_CHECK_THRESH :: Int iNTERP_STACK_CHECK_THRESH = INTERP_STACK_CHECK_THRESH View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b86243b4766365aa6ae03c5f8d577fe1e2f65b1f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b86243b4766365aa6ae03c5f8d577fe1e2f65b1f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 08:03:25 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 20 Oct 2023 04:03:25 -0400 Subject: [Git][ghc/ghc][master] Testsuite: recomp011 and recomp015 are fixed on powerpc Message-ID: <6532344d769da_7336fba288614676533@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - 2 changed files: - testsuite/tests/driver/recomp011/all.T - testsuite/tests/driver/recomp015/all.T Changes: ===================================== testsuite/tests/driver/recomp011/all.T ===================================== @@ -2,7 +2,6 @@ test('recomp011', [ extra_files(['Main.hs']) - , when(arch('powerpc64'), expect_broken(11260)) , js_broken(22261) ], makefile_test, []) ===================================== testsuite/tests/driver/recomp015/all.T ===================================== @@ -5,7 +5,7 @@ test('recomp015', # See ticket:11022#comment:7 unless(opsys('linux') or opsys('solaris2') or opsys('openbsd'), skip), when(arch('arm'), skip), - js_skip, # JS backend doesn't support .s assembly files - when(arch('powerpc64'), expect_broken(11323))], + js_skip # JS backend doesn't support .s assembly files + ], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4b2ec4744d8ec4f8ba1e0ce40df2694ae90fa68 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a4b2ec4744d8ec4f8ba1e0ce40df2694ae90fa68 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 08:04:02 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 20 Oct 2023 04:04:02 -0400 Subject: [Git][ghc/ghc][master] CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) Message-ID: <6532347227542_7336fba288614679680@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 1 changed file: - compiler/GHC/CoreToStg/Prep.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -643,13 +643,20 @@ cpeBind top_lvl env (Rec pairs) where (bndrs, rhss) = unzip pairs - -- Flatten all the floats, and the current - -- group into a single giant Rec + -- Flatten all the floats, and the current + -- group into a single giant Rec add_float (Float bind bound _) prs2 - | bound /= CaseBound = case bind of + | bound /= CaseBound + || all (definitelyLiftedType . idType) (bindersOf bind) + -- The latter check is hit in -O0 (i.e., flavours quick, devel2) + -- for dictionary args which haven't been floated out yet, #24102. + -- They are preferably CaseBound, but since they are lifted we may + -- just as well put them in the Rec, in contrast to lifted bindings. + = case bind of NonRec x e -> (x,e) : prs2 Rec prs1 -> prs1 ++ prs2 - add_float f _ = pprPanic "cpeBind" (ppr f) + add_float f _ = pprPanic "cpeBind" (ppr f) + --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fded7dd4300df8e1657b710f4deed16aa1d35ebe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fded7dd4300df8e1657b710f4deed16aa1d35ebe You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 10:06:37 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 20 Oct 2023 06:06:37 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/romes/fixes-4 Message-ID: <6532512d3a4ae_7336fbdcd08e46927d7@gitlab.mail> Rodrigo Mesquita pushed new branch wip/romes/fixes-4 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/fixes-4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 10:09:39 2023 From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes)) Date: Fri, 20 Oct 2023 06:09:39 -0400 Subject: [Git][ghc/ghc][wip/romes/eqsat-pmc] More comments Message-ID: <653251e3db79e_7336fbddbb22c69784b@gitlab.mail> Rodrigo Mesquita pushed to branch wip/romes/eqsat-pmc at Glasgow Haskell Compiler / GHC Commits: e175adb7 by Rodrigo Mesquita at 2023-10-20T12:09:31+02:00 More comments - - - - - 2 changed files: - compiler/GHC/Core/Equality.hs - compiler/GHC/HsToCore/Pmc/Solver.hs Changes: ===================================== compiler/GHC/Core/Equality.hs ===================================== @@ -136,28 +136,30 @@ representCoreExprEgr expr egr = EGM.runEGraphMT egr (runReaderT (go expr) emptyC addE :: Analysis m a CoreExprF => CoreExprF ClassId -> ReaderT CmEnv (EGM.EGraphMT a CoreExprF m) ClassId addE e = lift $ EGM.addM $ Node e +{-# INLINEABLE representCoreExprEgr #-} type CoreExprF = ExprF type CoreAltF = AltF type CoreBindF = BindF -cmpDeBruijnTickish :: DeBruijn CoreTickish -> DeBruijn CoreTickish -> Ordering -cmpDeBruijnTickish (D env1 t1) (D env2 t2) = go t1 t2 where - go (Breakpoint lext lid lids _) (Breakpoint rext rid rids _) - = case compare lid rid of - LT -> LT - EQ -> case compare (D env1 lids) (D env2 rids) of - LT -> LT - EQ -> compare lext rext - GT -> GT - GT -> GT - go l r = compare l r +-- cmpDeBruijnTickish :: DeBruijn CoreTickish -> DeBruijn CoreTickish -> Ordering +-- cmpDeBruijnTickish (D env1 t1) (D env2 t2) = go t1 t2 where +-- go (Breakpoint lext lid lids _) (Breakpoint rext rid rids _) +-- = case compare lid rid of +-- LT -> LT +-- EQ -> case compare (D env1 lids) (D env2 rids) of +-- LT -> LT +-- EQ -> compare lext rext +-- GT -> GT +-- GT -> GT +-- go l r = compare l r cmpDeBruijnType :: DeBruijn Type -> DeBruijn Type -> Ordering cmpDeBruijnType d1@(D _ t1) d2@(D _ t2) = if eqDeBruijnType d1 d2 then EQ -- ROMES:TODO: This definitely does not look OK. + -- ROMES:TODO: This hurts performance a lot (50% of regression is basically this) else compare (showPprUnsafe t1) (showPprUnsafe t2) cmpDeBruijnCoercion :: DeBruijn Coercion -> DeBruijn Coercion -> Ordering ===================================== compiler/GHC/HsToCore/Pmc/Solver.hs ===================================== @@ -586,6 +586,18 @@ where you can find the solution in a perhaps more digestible format. -- | A high-level pattern-match constraint. Corresponds to φ from Figure 3 of -- the LYG paper. -- Additionally, we use class-ids instead of ids (note... TODO) +-- ROMES:TODO: +-- Actually, I now think that we should only use e-class Ids within this module? and PhiCt should used Ids. +-- The reasoning is that we only represent Ids and merge them to their RHS +-- That sounds like the cleanest design, and we might even be able to rid other +-- modules of thinking about e-class Ids and just use them for our +-- representation of normalised refinement types +-- Even though other modules are aware of Nablas, which means somehow they will +-- have to know a bit about ClassIds, but we could also just refactor what we +-- used to have (in terms of lookupId) to lookup the id through representing +-- it, which is probably not that expensive. Eventually, if it is in fact +-- expensive, we can try again talking about ClassIds more often. But I dislike +-- how that breaks the illusion now. data PhiCt = PhiTyCt !PredType -- ^ A type constraint "T ~ U". @@ -707,6 +719,7 @@ addPhiTmCt nabla (PhiNotConCt x con) = addNotConCt nabla x con addPhiTmCt nabla (PhiBotCt x) = addBotCt nabla x addPhiTmCt nabla (PhiNotBotCt x) = addNotBotCt nabla x +-- ROMES:TODO: For example this one would be trivial if we still had Ids at this level... filterUnliftedFields :: Nabla -> PmAltCon -> [ClassId] -> [ClassId] filterUnliftedFields nabla con args = [ arg_id | (arg_id, bang) <- zipEqual "addPhiCt" args (pmAltConImplBangs con) @@ -739,7 +752,7 @@ mergeBotCt vi at VI { vi_bot = bot } addNotBotCt :: Nabla -> ClassId -> MaybeT DsM Nabla addNotBotCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ts_facts=env} } x = do -- This means we only add not-bottom constraints to the true match-id of newtype constructors (ie skipping NT classes) - -- This is the only occurrence of lookupVarInfoNT. + -- This is the only occurrence of lookupVarInfoNT.(nope) let (yid, vi at VI { vi_bot = bot }) = lookupVarInfoNT ts x case bot of IsBot -> mzero -- There was x ~ ⊥. Contradiction! View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e175adb789ce41806083731b1d6cd7f4affa06a2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e175adb789ce41806083731b1d6cd7f4affa06a2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 16:00:44 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 20 Oct 2023 12:00:44 -0400 Subject: [Git][ghc/ghc][wip/simplifier-tweaks] 85 commits: EPA: Introduce HasAnnotation class Message-ID: <6532a42c44fe9_3c96633c813e4106717@gitlab.mail> Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC Commits: 94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00 EPA: Introduce HasAnnotation class The class is defined as class HasAnnotation e where noAnnSrcSpan :: SrcSpan -> e This generalises noAnnSrcSpan, and allows noLocA :: (HasAnnotation e) => a -> GenLocated e a noLocA = L (noAnnSrcSpan noSrcSpan) - - - - - 8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00 Bump unix submodule to v2.8.3.0 - - - - - e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00 Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around. The motivation for the flag is given in #21917. - - - - - 3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Add ghcToolchain to tool args list This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS. - - - - - 476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Normalise triple via config.sub We were not normalising the target triple anymore like we did with the old make build system. Fixes #23856 - - - - - 303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add missing vendor normalisation This is copied from m4/ghc_convert_vendor.m4 Towards #23868 - - - - - 838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add loongarch64 to parseArch Towards #23868 - - - - - 1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Add same LD hack to ghc-toolchain In the ./configure script, if you pass the `LD` variable then this has the effect of stopping use searching for a linker and hence passing `-fuse-ld=...`. We want to emulate this logic in ghc-toolchain, if a use explicilty specifies `LD` variable then don't add `-fuse-ld=..` with the goal of making ./configure and ghc-toolchain agree on which flags to use when using the C compiler as a linker. This is quite unsavoury as we don't bake the choice of LD into the configuration anywhere but what's important for now is making ghc-toolchain and ./configure agree as much as possible. See #23857 for more discussion - - - - - 42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check for C99 support with -std=c99 Previously we failed to try enabling C99 support with `-std=c99`, as `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which don't enable C99 by default. Fixes #23879. - - - - - da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro In very old toolchains the BYTE_ORDER macro is not set but thankfully the __BYTE_ORDER__ macro can be used instead. - - - - - d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: AC_PATH_TARGET_TOOL for LD We want to make sure that LD is set to an absolute path in order to be consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which might use a relative path. - - - - - 171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Check whether we need -std=gnu99 for CPP as well In ./configure the C99 flag is passed to the C compiler when used as a C preprocessor. So we also check the same thing in ghc-toolchain. - - - - - 89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00 Check for --target linker flag separately to C compiler There are situations where the C compiler doesn't accept `--target` but when used as a linker it does (but doesn't do anything most likely) In particular with old gcc toolchains, the C compiler doesn't support --target but when used as a linker it does. - - - - - 37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00 Use Cc to compile test file in nopie check We were attempting to use the C compiler, as a linker, to compile a file in the nopie check, but that won't work in general as the flags we pass to the linker might not be compatible with the ones we pass when using the C compiler. - - - - - 9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Error when ghc-toolchain fails to compile This is a small QOL change as if you are working on ghc-toolchain and it fails to compile then configure will continue and can give you outdated results. - - - - - 1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00 configure: Check whether -no-pie works when the C compiler is used as a linker `-no-pie` is a flag we pass when using the C compiler as a linker (see pieCCLDOpts in GHC.Driver.Session) so we should test whether the C compiler used as a linker supports the flag, rather than just the C compiler. - - - - - 62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00 ghc-toolchain: Remove javascript special case for --target detection emcc when used as a linker seems to ignore the --target flag, and for consistency with configure which now tests for --target, we remove this special case. - - - - - 0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00 toolchain: Don't pass --target to emscripten toolchain As noted in `Note [Don't pass --target to emscripten toolchain]`, emscripten's `emcc` is rather inconsistent with respect to its treatment of the `--target` flag. Avoid this by special-casing this toolchain in the `configure` script and `ghc-toolchain`. Fixes on aspect of #23744. - - - - - 6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00 hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure Stop passing -gcc-options which mixed together linker flags and non-linker flags. There's no guarantee the C compiler will accept both of these in each mode. - - - - - c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00 configure: Probe stage0 link flags For consistency with later stages and CC. - - - - - 1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00 Stricter Binary.get in GHC.Types.Unit (#23964) I noticed some thunking while looking at Core. This change has very modest, but throughout positive ghc/alloc effect: ``` hard_hole_fits(normal) ghc/alloc 283,057,664 281,620,872 -0.5% geo. mean -0.1% minimum -0.5% maximum +0.0% ``` Fixes #23964. - - - - - a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00 rel_eng/upload.sh cleanups - - - - - 80705335 by doyougnu at 2023-10-10T19:03:18-04:00 ci: add javascript label rule This adds a rule which triggers the javascript job when the "javascript" label is assigned to an MR. - - - - - a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00 Make 'wWarningFlagsDeps' include every WarningFlag Fixes #24071. - - - - - d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00 Fix pretty printing of overlap pragmas in TH splices (fixes #24074) - - - - - 0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch64 NCG: Use encoded immediates for literals. Try to generate instr x2, <imm> instead of mov x1, lit instr x2, x1 When possible. This get's rid if quite a few redundant mov instructions. I believe this causes a metric decrease for LargeRecords as we reduce register pressure. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00 AArch NCG: Refactor getRegister' Remove some special cases which can be handled just as well by the generic case. This increases code re-use while also fixing #23749. Since some of the special case wasn't upholding Note [Signed arithmetic on AArch64]. - - - - - 1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00 Aarch ncg: Optimize immediate use for address calculations When the offset doesn't fit into the immediate we now just reuse the general getRegister' code path which is well optimized to compute the offset into a register instead of a special case for CmmRegOff. This means we generate a lot less code under certain conditions which is why performance metrics for these improve. ------------------------- Metric Decrease: T4801 T5321FD T5321Fun ------------------------- - - - - - b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over mem management checks These are for heap allocation, a strictly RTS concern. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. The RTS configure one has a new ``` AC_CHECK_SIZEOF([void *]) ``` that the top-level configure version didn't have, so that `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter commits, that can go away. Progress towards #17191 - - - - - 41130a65 by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `__thread` check This used by (@bgamari thinks) the `GCThread` abstraction in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over misc function checks These are for general use in the RTS. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00 RTS configure: Move over `eventfd` check This check is for the RTS part of the event manager and has a corresponding part in `base`. All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - 58f3babf by John Ericson at 2023-10-11T16:02:48-04:00 Split `FP_CHECK_PTHREADS` and move part to RTS configure `NEED_PTHREAD_LIB` is unused since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system), and so is no longer defined. Progress towards #17191 - - - - - e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00 nativeGen: section flags for .text$foo only Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix #22834 in !9810. It does however add "xr" indiscriminatly to .text sections even if splitSections is disabled. This leads to the assembler saying: ghc_1.s:7849:0: error: Warning: Ignoring changed section attributes for .text | 7849 | .section .text,"xr" | ^ - - - - - f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00 Modularity: pass TempDir instead of DynFlags (#17957) - - - - - 34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00 Test that functions from `mingwex` are available Ryan wrote these two minimizations, but they never got added to the test suite. See #23309, #23378 Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com> Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00 Do not check for the `mingwex` library in `/configure` See the recent discussion in !10360 --- Cabal will itself check for the library for the packages that need it, and while the autoconf check additionally does some other things like define a `HAS_LIBMINGWEX` C Preprocessor macro, those other things are also unused and unneeded. Progress towards #17191, which aims to get rid of `/configure` entirely. - - - - - 43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00 base: Introduce move modules into src The only non-move changes here are whitespace changes to pass the `whitespace` test and a few testsuite adaptations. - - - - - df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00 [PEi386 linker] Bounds check and null-deref guard We should resonably be able to expect that we won't exceed the number of sections if we assume to be dealing with legal object files. We can however not guarantee that we get some negative values, and while we try to special case most, we should exclude negative indexing into the sections array. We also need to ensure that we do not try to derefences targetSection, if it is NULL, due to the switch statement. - - - - - c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00 Move apple compat check to RTS configure - - - - - c80778ea by John Ericson at 2023-10-12T10:31:13-04:00 Move clock/timer fun checks to RTS configure Actual library check (which will set the Cabal flag) is left in the top-level configure for now. Progress towards #17191 - - - - - 7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00 Move visibility and "musttail" annotation checks to the RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. Progress towards #17191 - - - - - ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00 Move leading underscore checks to RTS configure `CabalLeadingUnderscore` is done via Hadrian already, so we can stop `AC_SUBST`ing it completely. - - - - - 25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00 Move alloca, fork, const, and big endian checks to RTS configure All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it belongs in the RTS configure and should be safe to move without modification. - - - - - 5170f42a by John Ericson at 2023-10-12T10:31:13-04:00 Move libdl check to RTS configure - - - - - ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00 Adjust `FP_FIND_LIBFFI` Just set vars, and `AC_SUBST` in top-level configure. Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build system). - - - - - f399812c by John Ericson at 2023-10-12T10:31:13-04:00 Split BFD support to RTS configure The flag is still in the top-level configure, but the other checks (which define various macros --- important) are in the RTS configure. - - - - - f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00 Split libm check between top level and RTS - - - - - dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00 CgUtils.fixStgRegStmt respect register width This change ensure that the reg + offset computation is always of the same size. Before this we could end up with a 64bit register, and then add a 32bit offset (on 32bit platforms). This not only would fail type sanity checking, but also incorrectly truncate 64bit values into 32bit values silently on 32bit architectures. - - - - - 9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00 hadrian: Decrease verbosity of cabal commands In Normal, most tools do not produce output to stdout unless there are error conditions. Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217 - - - - - 08fc27af by John Ericson at 2023-10-12T20:35:36-04:00 Do not substitute `@...@` for stage-specific values in cabal files `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag defaults; instead manual choices are passed to configure in the usual way. The old way was fundamentally broken, because it meant we were baking these Cabal files for a specific stage. Now we only do stage-agnostic @...@ substitution in cabal files (the GHC version), and so all stage-specific configuration is properly confined to `_build` and the right stage dir. Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim` (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got rid of it. Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com> - - - - - a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00 Fix restarts in .ghcid Using the whole of `hadrian/` restarted in a loop for me. - - - - - fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00 CorePrep: Refactor FloatingBind (#23442) A drastically improved architecture for local floating in CorePrep that decouples the decision of whether a float is going to be let- or case-bound from how far it can float (out of strict contexts, out of lazy contexts, to top-level). There are a couple of new Notes describing the effort: * `Note [Floating in CorePrep]` for the overview * `Note [BindInfo and FloatInfo]` for the new classification of floats * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform floating decisions This is necessary ground work for proper treatment of Strict fields and unlifted values at top-level. Fixes #23442. NoFib results (omitted = 0.0%): ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- pretty 0.0% -1.6% scc 0.0% -1.7% -------------------------------------------------------------------------------- Min 0.0% -1.7% Max 0.0% -0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00 hadrian: Move ghcBinDeps into ghcLibDeps This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc` library so need to make sure they are present in the libdir even if we are not going to build `ghc-bin`. This also fixes things for cross compilers because the stage2 cross-compiler requires the ghc-usage.txt file, but we are using the stage2 lib folder but not building stage3:exe:ghc-bin so ghc-usage.txt was not being generated. - - - - - ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00 Combine GREs when combining in mkImportOccEnv In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import item in favour of another, as explained in Note [Dealing with imports] in `GHC.Rename.Names`. However, this can cause us to lose track of important parent information. Consider for example #24084: module M1 where { class C a where { type T a } } module M2 ( module M1 ) where { import M1 } module M3 where { import M2 ( C, T ); instance C () where T () = () } When processing the import list of `M3`, we start off (for reasons that are not relevant right now) with two `Avail`s attached to `T`, namely `C(C, T)` and `T(T)`. We combine them in the `combine` function of `mkImportOccEnv`; as described in Note [Dealing with imports] we discard `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not** discard the information want that `C` is the parent of `T`. Indeed, losing track of this information can cause errors when importing, as we could get an error of the form ‘T’ is not a (visible) associated type of class ‘C’ We fix this by combining the two GREs for `T` using `plusGRE`. Fixes #24084 - - - - - 257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00 hadrian: Pass -DNOSMP to C compiler when needed Hadrian passes the -DNOSMP flag to GHC when the target doesn't support SMP, but doesn't pass it to CC as well, leading to the following compilation error on mips64el: | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0 ===> Command failed with error code: 1 In file included from rts/include/Stg.h:348, from rts/include/Rts.h:38, from rts/hooks/FlagDefaults.c:8: rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture 416 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture 440 | #error memory barriers unimplemented on this architecture | ^~~~~ rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture 464 | #error memory barriers unimplemented on this architecture | ^~~~~ The old make system correctly passed this flag to both GHC and CC [1]. Fix this error by passing -DNOSMP to CC as well. [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407 Closes #24082 - - - - - 13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00 Users Guide: Drop dead code for Haddock refs to `parallel` I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was not substituted. It is dead code -- there is no `parallel-ref` usages and it doesn't look like there ever was (going back to 3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it. - - - - - fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066) bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a". - - - - - cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00 Bignum: fix right shift of negative BigNat with native backend - - - - - cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00 Rts: expose rtsOutOfBoundsAccess symbol - - - - - 72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00 Hadrian: enable `-fcheck-prim-bounds` in validate flavour This allows T24066 to fail when the bug is present. Otherwise the out-of-bound access isn't detected as it happens in ghc-bignum which wasn't compiled with the bounds check. - - - - - f9436990 by John Ericson at 2023-10-18T19:41:01-04:00 Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in` Fixes #24091 Progress on #23966 Issue #24091 reports that `@ProjectVersion@` is no longer being substituted in the GHC user's guide. I assume this is a recent issue, but I am not sure how it's worked since c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and configure are trying to substitute the same `.in` file! Now only Hadrian does. That is better anyways; already something that issue #23966 requested. It seems like we were missing some dependencies in Hadrian. (I really, really hate that this is possible!) Hopefully it is fixed now. - - - - - b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00 `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*` Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to be defined. (Guaranteed including a test in the testsuite.) - - - - - 0295375a by John Ericson at 2023-10-18T19:41:37-04:00 Generate `ghcversion.h` from a `.in` file Now that there are no conditional sections (see the previous commit), we can just a do simple substitution rather than pasting it together line by line. Progress on #23966 - - - - - 740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00 Add a regression test for #24064 - - - - - 921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00 CLC Proposal #182: Export List from Data.List Proposal link: https://github.com/haskell/core-libraries-committee/issues/182 - - - - - 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - d1b0cc6f by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 Several improvements to the handling of coercions * Make `mkSymCo` and `mkInstCo` smarter Fixes #23642 * Fix return role of `SelCo` in the coercion optimiser. Fixes #23617 * Make the coercion optimiser `opt_trans_rule` work better for newtypes Fixes #23619 - - - - - 62bc9035 by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 Simplifier improvements This MR started as: allow the simplifer to do more in one pass, arising from places I could see the simplifier taking two iterations where one would do. But it turned into a larger project, because these changes unexpectedly made inlining blow up, especially join points in deeply-nested cases. The net result is good: a 2% improvement in compile time. The table below shows changes over 1%. The main changes are: * The SimplEnv now has a seInlineDepth field, which says how deep in unfoldings we are. See Note [Inline depth] in Simplify.Env * Avoid repeatedly simplifying coercions. see Note [Avoid re-simplifying coercions] in Simplify.Iteration As you'll see from the Note, this makes use of the seInlineDepth. * Allow Simplify.Utils.postInlineUnconditionally to inline variables that are used exactly once. See Note [Post-inline for single-use things]. * Allow Simplify.Iteration.simplAuxBind to inline used-once things. This is another part of Note [Post-inline for single-use things], and is really good for reducing simplifier iterations in situations like case K e of { K x -> blah } wher x is used once in blah. * Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case elimination. Note [Case elim in exprIsConApp_maybe] * When making join points, don't do so if the join point is so small it will immediately be inlined. See Note [Duplicating alternatives] * Do not add an unfolding to a join point at birth. This is a tricky one and has a long Note [Do not add unfoldings to join points at birth] It shows up in two places - In `mkDupableAlt` do not add an inlining - (trickier) In `simplLetUnfolding` don't add an unfolding for a fresh join point I am not fully satisifed with this, but it works and is well documented. * Many new or rewritten Notes. E.g. Note [Avoiding simplifying repeatedly] I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very delicately balanced. It's a small, heavily used, overloaded function and it's important that it inlines. By a fluke it was before, but at various times in my journey it stopped doing so. So I added an INLINE pragma to it. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Singletons(normal) -4.3% GOOD LargeRecord(normal) -23.3% GOOD PmSeriesS(normal) -2.4% T11195(normal) -1.7% T12227(normal) -20.0% GOOD T12545(normal) -5.4% T13253-spj(normal) -50.7% GOOD T13386(normal) -5.1% GOOD T14766(normal) -2.4% GOOD T15164(normal) -1.7% T15304(normal) +1.0% T15630(normal) -7.7% T15630a(normal) NEW T15703(normal) -7.5% GOOD T16577(normal) -5.1% GOOD T17516(normal) -3.6% T18223(normal) -16.8% GOOD T18282(normal) -1.5% T18304(normal) +1.9% T21839c(normal) -3.5% GOOD T3064(normal) -1.5% T5030(normal) -16.2% GOOD T5321Fun(normal) -1.6% T6048(optasm) -2.1% GOOD T8095(normal) -6.1% GOOD T9630(normal) -5.1% GOOD WWRec(normal) -1.6% geo. mean -2.1% minimum -50.7% maximum +1.9% Metric Decrease: CoOpt_Singletons LargeRecord T12227 T13253-spj T13386 T14766 T15703 T16577 T18223 T21839c T5030 T6048 T8095 T9630 - - - - - 2e5b78c6 by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 Improve postInlineUnconditionally This commit adds two things to postInlineUnconditionally: 1. Do not postInlineUnconditionally join point, ever. Doing so does not reduce allocation, which is the main point, and with join points that are used a lot it can bloat code. See point (1) of Note [Duplicating join points] in GHC.Core.Opt.Simplify.Iteration. 2. Do not postInlineUnconditionally a strict (demanded) binding. It will not allocate a thunk (it'll turn into a case instead) so again the main point of inlining it doesn't hold. Better to check per-call-site. - - - - - 42950140 by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 Update testsuite output - - - - - c237da54 by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 Try effect of * making multi-branch cases not work free (fixes #22423) * use plan A for dataToTag and tagToEnum - - - - - 83306277 by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 More changes * No floating at all for join points * Never inline j x = I x Example: integerSignum !j = IS (integerSignum# j) We want this to inline and then cancel with an enclosing case. But it won't if we have changed it to integerSignum x = case x of IN a -> IS (...) IS b -> IS (...) IP c -> IS (...) This involved changing - UnfoldingGuidance to not say always-inline for j x = Ix - callSiteInline to inline join points only if there is a real benefit - ok_to_dup_alt in Simplify.Iteration * Row back (for now) on changes to GHC.Core.Utils.ExprIsCheap - - - - - fe109d1f by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 Wibble - - - - - 5cfc57c5 by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 Wibble - - - - - 9e512441 by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 Further wibbles - - - - - 6bcff167 by Simon Peyton Jones at 2023-10-20T16:01:11+01:00 One more wibble Don't float an unlifted join point - - - - - c0e517c8 by Simon Peyton Jones at 2023-10-20T16:01:12+01:00 Small wibbles The most significant change is to mkSelCo. - - - - - efc98bde by Simon Peyton Jones at 2023-10-20T16:01:12+01:00 Temporarily add -DDEBUG to Coercion.hs - - - - - 49960854 by Simon Peyton Jones at 2023-10-20T16:01:12+01:00 Fix a missing zonk in before mkSelCo - - - - - cf6e970f by Simon Peyton Jones at 2023-10-20T16:01:12+01:00 Wibbles - - - - - c559190d by Simon Peyton Jones at 2023-10-20T16:01:12+01:00 Tickish comment - - - - - 26 changed files: - .ghcid - .gitignore - .gitlab/generate-ci/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/rel_eng/upload.sh - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9bcb2f7a195805443c1a5493b2e5698c1acfe44...c559190dcf35edd3379e8b00b0e8bb913db2f339 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9bcb2f7a195805443c1a5493b2e5698c1acfe44...c559190dcf35edd3379e8b00b0e8bb913db2f339 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 16:02:56 2023 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Fri, 20 Oct 2023 12:02:56 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/typefam-prettyprint Message-ID: <6532a4b0a7067_3c966340382441078ec@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/typefam-prettyprint at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/typefam-prettyprint You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 20 16:53:45 2023 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 20 Oct 2023 12:53:45 -0400 Subject: [Git][ghc/ghc][wip/spj-unf-size] More Message-ID: <6532b0996da42_3c966353adfcc1101a4@gitlab.mail> Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC Commits: 84939df9 by Simon Peyton Jones at 2023-10-20T17:53:33+01:00 More - - - - - 6 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/Unfold.hs Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -1408,7 +1408,7 @@ data CaseTree -- nothing relies on non-empty-ness | ScrutOf Id Int -- If this Id is bound to a value, apply this discount -data AltTree = AT AltCon [Var] ExprTree +data AltTree = AltTree AltCon [Var] ExprTree {- Note [UnfoldingCache] ~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -21,6 +21,8 @@ import GHC.Prelude import GHC.Driver.Flags +import GHC.Core.Opt.Simplify.Env +import GHC.Core.Opt.Simplify.Utils import GHC.Core import GHC.Core.Unfold import GHC.Types.Id @@ -105,7 +107,7 @@ callSiteInline logger opts !case_depth id active_unfolding lone_variable arg_inf CoreUnfolding { uf_tmpl = unf_template , uf_cache = unf_cache , uf_guidance = guidance } - | active_unfolding -> tryUnfolding logger opts case_depth id lone_variable + | active_unf -> tryUnfolding logger opts case_depth id lone_variable arg_infos cont_info unf_template unf_cache guidance | otherwise -> traceInline logger opts id "Inactive unfolding:" (ppr id) Nothing @@ -113,6 +115,9 @@ callSiteInline logger opts !case_depth id active_unfolding lone_variable arg_inf BootUnfolding -> Nothing OtherCon {} -> Nothing DFunUnfolding {} -> Nothing -- Never unfold a DFun + where + active_unf = activeUnfolding (seMode env) var + -- | Report the inlining of an identifier's RHS to the user, if requested. traceInline :: Logger -> UnfoldingOpts -> Id -> String -> SDoc -> a -> a @@ -228,7 +233,8 @@ needed on a per-module basis. -} -tryUnfolding :: Logger -> UnfoldingOpts -> Int -> Id -> Bool -> [ArgSummary] -> CallCtxt +tryUnfolding :: Logger -> UnfoldingOpts -> Int + -> Id -> Bool -> [ArgSummary] -> CallCtxt -> CoreExpr -> UnfoldingCache -> UnfoldingGuidance -> Maybe CoreExpr tryUnfolding logger opts !case_depth id lone_variable arg_infos @@ -246,7 +252,7 @@ tryUnfolding logger opts !case_depth id lone_variable arg_infos some_benefit = calc_some_benefit uf_arity enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) - UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size } + UnfIfGoodArgs { ug_args = arg_bndrs, ug_tree = expr_tree } | unfoldingVeryAggressive opts -> traceInline logger opts id str (mk_doc some_benefit extra_doc True) (Just unf_template) | is_wf && some_benefit && small_enough @@ -260,9 +266,19 @@ tryUnfolding logger opts !case_depth id lone_variable arg_infos depth_scaling = unfoldingCaseScaling opts depth_penalty | case_depth <= depth_treshold = 0 | otherwise = (size * (case_depth - depth_treshold)) `div` depth_scaling - adjusted_size = size + depth_penalty - discount - small_enough = adjusted_size <= unfoldingUseThreshold opts - discount = computeDiscount arg_discounts res_discount arg_infos cont_info + + want_result + | LT <- arg_bndrs `compareLength` arg_infos + = True -- Over-saturated + | otherwise = case cont_info of + BoringCtxt -> False + _ -> True + + context = IC { ic_bound = mkVarEnv (arg_bnds `zip` arg_infos) + , ic_free = xx + , ic_want_res = want_result } + size = depth_penalty `addSizeN` exprTreeSize context expr_tree + small_enough = adjusted_size `leqSize` unfoldingUseThreshold opts extra_doc = vcat [ text "case depth =" <+> int case_depth , text "depth based penalty =" <+> int depth_penalty ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -48,7 +48,7 @@ import qualified GHC.Prelude as Partial (head) import GHC.Core import GHC.Types.Literal ( isLitRubbish ) import GHC.Core.Opt.Simplify.Env -import GHC.Core.Opt.Simplify.Inline +-- import GHC.Core.Opt.Simplify.Inline import GHC.Core.Opt.Stats ( Tick(..) ) import qualified GHC.Core.Subst import GHC.Core.Ppr @@ -577,9 +577,9 @@ contArgs cont go args (CastIt _ k) = go args k go args k = (False, reverse args, k) - is_interesting arg se = interestingArg se arg - -- Do *not* use short-cutting substitution here - -- because we want to get as much IdInfo as possible + is_interesting arg se = exprSummary se arg + -- Do *not* use short-cutting substitution here + -- because we want to get as much IdInfo as possible -- | Describes how the 'SimplCont' will evaluate the hole as a 'SubDemand'. -- This can be more insightful than the limited syntactic context that @@ -1002,23 +1002,23 @@ interestingArg env e = go env 0 e conlike_unfolding = isConLikeUnfolding (idUnfolding v) ------------------------------ -idScrutInfo :: Id -> ScrutInfo -idScrutInfo bndr +idSummary :: SimplEnv -> Id -> ArgSummary +idSummary env bndr = case idUnfolding bndr of OtherCon cs -> ScrutIsNot cs DFunUnfolding { df_bndrs = bndrs, df_con = con, df_args = args } | null bndrs - -> ScrutIsCon (DataAlt con) (map exprScrutInfo args) + -> ScrutIsCon (DataAlt con) (map exprSummary args) | otherwise -> ScrutNoInfo CoreUnfolding { uf_tmpl = e } - -> exprScrutInfo e + -> exprSummary e NoUnfolding -> ScrutNoInfo BootUnfolding -> ScrutNoInfo -exprScrutInfo :: CoreExpr -> ScrutInfo +exprSummary :: SimplEnv -> CoreExpr -> ArgSummary -- Very simple version of exprIsConApp_maybe -exprScrutInfo e = go e [] +exprSummary env e = go e [] where go (Cast e _) as = go e as go (Tick _ e) as = go e as @@ -1035,7 +1035,7 @@ exprScrutInfo e = go e [] go_var v as | Just con <- isDataConWorkId_maybe v - = ScrutIsCon (DataAlt con) (map exprScrutInfo as) + = ScrutIsCon (DataAlt con) (map (exprSummary env) as) | Just rhs <- expandUnfolding_maybe (idUnfolding v) = go rhs as | otherwise ===================================== compiler/GHC/Core/Ppr.hs ===================================== @@ -638,7 +638,7 @@ instance Outputable CaseTree where <+> brackets (sep (map ppr alts)) instance Outputable AltTree where - ppr (AT con bs rhs) = ppr con <+> ppr bs <+> text "->" <+> ppr rhs + ppr (AltTree con bs rhs) = ppr con <+> ppr bs <+> text "->" <+> ppr rhs instance Outputable Unfolding where ppr NoUnfolding = text "No unfolding" ===================================== compiler/GHC/Core/Seq.hs ===================================== @@ -135,5 +135,5 @@ seqCT (ScrutOf x i) = x `seq` i `seq` () seqCT (CaseOf x alts) = x `seq` seqList seqAT alts seqAT :: AltTree -> () -seqAT (AT con bs e) = con `seq` seqBndrs bs `seq` seqET e +seqAT (AltTree con bs e) = con `seq` seqBndrs bs `seq` seqET e ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -22,9 +22,8 @@ module GHC.Core.Unfold ( Unfolding, UnfoldingGuidance, -- Abstract types ExprTree, exprTree, exprTreeSize, - - ArgSummary(..), nonTriv, - CallCtxt(..), + ArgSummary(..), CallCtxt(..), + Size, leqSize, addSizeN, UnfoldingOpts (..), defaultUnfoldingOpts, updateCreationThreshold, updateUseThreshold, @@ -56,7 +55,6 @@ import GHC.Builtin.Names import GHC.Builtin.PrimOps import GHC.Utils.Misc -import GHC.Utils.Panic import GHC.Utils.Outputable import GHC.Data.Bag @@ -166,23 +164,15 @@ updateReportPrefix n opts = opts { unfoldingReportPrefix = n } ********************************************************************* -} data ArgSummary = ArgNoInfo - | ArgIsCon AltCon [ArgInfo] + | ArgIsCon AltCon [ArgSummary] | ArgIsNot [AltCon] | ArgIsLam -data ArgSummary = TrivArg -- Nothing interesting - | NonTrivArg -- Arg has structure - | ValueArg -- Arg is a con-app or PAP - -- ..or con-like. Note [Conlike is interesting] - instance Outputable ArgSummary where - ppr TrivArg = text "TrivArg" - ppr NonTrivArg = text "NonTrivArg" - ppr ValueArg = text "ValueArg" - -nonTriv :: ArgSummary -> Bool -nonTriv TrivArg = False -nonTriv _ = True + ppr ArgNoInfo = text "ArgNoInfo" + ppr ArgIsLam = text "ArgIsLam" + ppr (ArgIsCon c as) = ppr c <> ppr as + ppr (ArgIsNot cs) = text "ArgIsNot" <> ppr cs data CallCtxt = BoringCtxt @@ -543,7 +533,7 @@ exprTree opts !bOMB_OUT_SIZE svars expr where alt_alt_tree :: Alt Var -> AltTree alt_alt_tree (Alt con bs rhs) - = AT con bs (exprTree opts bOMB_OUT_SIZE svars' rhs) + = AltTree con bs (exprTree opts bOMB_OUT_SIZE svars' rhs) where svars' = svars `extendVarSetList` bs @@ -937,74 +927,82 @@ addSize :: Size -> Size -> Size addSize (SSize n1) (SSize n2) = SSize (n1+n2) addSize _ _ = STooBig +addSizeN :: Int -> Size -> Size +addSizeN n1 (SSize n2) = SSize (n1+n2) +addSizeN _ STooBig = STooBig + leqSize :: Size -> Int -> Bool leqSize STooBig _ = False leqSize (SSize n) m = n <= m ------------------------- -type UnfoldingInfo = IdEnv ArgInfo - -- Domain is the bound vars of the function RHS +data InlineContext + = IC { ic_free :: Id -> ArgSummary -- Current unfoldings for free variables + , ic_bound :: IdEnv ArgSummary -- Summaries for local variables + , ic_want_res :: Bool -- True <=> result is scrutinised/demanded + -- so apply result discount + } ------------------------- -exprTreeSize :: UnfoldingInfo -- Unfolding - -> Bool -- Apply result discount please - -> ExprTree -> Size -exprTreeSize _ _ TooBig = STooBig -exprTreeSize unf want_res (SizeIs { et_size = size - , et_cases = cases - , et_ret = ret_discount }) - = foldr (addSize . caseTreeSize unf False) +exprTreeSize :: InlineContext -> ExprTree -> Size +exprTreeSize _ TooBig = STooBig +exprTreeSize !ic (SizeIs { et_size = size + , et_cases = cases + , et_ret = ret_discount }) + = foldr (addSize . caseTreeSize (ic { ic_want_res = False })) (sizeN discounted_size) cases where - discounted_size | want_res = size - ret_discount - | otherwise = size + discounted_size | ic_want_res ic = size - ret_discount + | otherwise = size -caseTreeSize :: UnfoldingInfo -> Bool -> CaseTree -> Size -caseTreeSize unf _ (ScrutOf bndr disc) - = case lookupBndr unf bndr of +caseTreeSize :: InlineContext -> CaseTree -> Size +caseTreeSize ic (ScrutOf bndr disc) + = case lookupBndr ic bndr of ArgNoInfo -> sizeN 0 ArgIsNot {} -> sizeN 0 ArgIsLam -> sizeN (-disc) -- Apply discount ArgIsCon {} -> sizeN (-disc) -- Apply discount -caseTreeSize unf want_res (CaseOf bndr alts) - = case lookupBndr unf bndr of - ArgNoInfo -> keptCaseSize unf want_res alts - ArgIsLam -> keptCaseSize unf want_res alts - ArgIsNot cons -> keptCaseSize unf want_res (trim_alts cons alts) +caseTreeSize ic (CaseOf var alts) + = case lookupBndr ic var of + ArgNoInfo -> keptCaseSize ic alts + ArgIsLam -> keptCaseSize ic alts + ArgIsNot cons -> keptCaseSize ic (trim_alts cons alts) ArgIsCon con args - | Just (AT _ bs rhs) <- find_alt con alts - , let unf' = extendVarEnvList unf (bs `zip` args) -- In DEFAULT case, bs is empty - -> exprTreeSize unf' want_res rhs + | Just (AltTree _ bs rhs) <- find_alt con alts + , let ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` + (bs `zip` args) } + -- In DEFAULT case, bs is empty, so extend is a no-op + -> exprTreeSize ic' rhs | otherwise -- Happens for empty alternatives - -> keptCaseSize unf want_res alts + -> keptCaseSize ic alts find_alt :: AltCon -> [AltTree] -> Maybe AltTree find_alt _ [] = Nothing find_alt con (alt:alts) - | AT DEFAULT _ _ <- alt = go alts (Just alt) - | otherwise = go (alt:alts) Nothing + | AltTree DEFAULT _ _ <- alt = go alts (Just alt) + | otherwise = go (alt:alts) Nothing where go [] deflt = deflt go (alt:alts) deflt - | AT con' _ _ <- alt, con==con' = Just alt - | otherwise = go alts deflt + | AltTree con' _ _ <- alt, con==con' = Just alt + | otherwise = go alts deflt trim_alts :: [AltCon] -> [AltTree] -> [AltTree] trim_alts _ [] = [] trim_alts acs (alt:alts) - | AT con _ _ <- alt, con `elem` acs = trim_alts acs alts - | otherwise = alt : trim_alts acs alts + | AltTree con _ _ <- alt, con `elem` acs = trim_alts acs alts + | otherwise = alt : trim_alts acs alts -keptCaseSize :: UnfoldingInfo -> Bool -> [AltTree] -> Size +keptCaseSize :: InlineContext -> [AltTree] -> Size -- Size of a (retained) case expression -keptCaseSize unf want_res alts +keptCaseSize ic alts = foldr (addSize . size_alt) (sizeN 0) alts -- We make the case itself free, but charge for each alternative -- If there are no alternatives (case e of {}), we get just the size of the scrutinee where size_alt :: AltTree -> Size - size_alt (AT _ _ rhs) = sizeN 10 `addSize` exprTreeSize unf want_res rhs + size_alt (AltTree _ _ rhs) = sizeN 10 `addSize` exprTreeSize ic rhs -- Add 10 for each alternative -- Don't charge for args, so that wrappers look cheap -- (See comments about wrappers with Case) @@ -1013,8 +1011,8 @@ keptCaseSize unf want_res alts -- find that giant case nests are treated as practically free -- A good example is Foreign.C.Error.errnoToIOError -lookupBndr :: UnfoldingInfo -> Id -> ArgInfo -lookupBndr unf bndr - | Just info <- lookupVarEnv unf bndr = info - | otherwise = idArgInfo bndr +lookupBndr :: InlineContext -> Id -> ArgSummary +lookupBndr (IC { ic_bound = bound_env, ic_free = lookup_free }) var + | Just info <- lookupVarEnv bound_env var = info + | otherwise = lookup_free var View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84939df9c836075860dc1a5fae85082a14626833 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84939df9c836075860dc1a5fae85082a14626833 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 21 06:35:22 2023 From: gitlab at gitlab.haskell.org (Moritz Angermann (@angerman)) Date: Sat, 21 Oct 2023 02:35:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/win-linker-sym-type Message-ID: <6533712ae8023_3c966317f07e4c13593b@gitlab.mail> Moritz Angermann pushed new branch wip/angerman/win-linker-sym-type at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/win-linker-sym-type You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 22 00:48:08 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 21 Oct 2023 20:48:08 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: rts: fix small argument passing on big-endian arch (fix #23387) Message-ID: <65347148c54c0_ab41e1650e680818ac@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00 rts: fix small argument passing on big-endian arch (fix #23387) - - - - - b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00 Interpreter: fix literal alignment on big-endian architectures (fix #19261) Literals weren't correctly aligned on big-endian, despite what the comment said. - - - - - a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00 Testsuite: recomp011 and recomp015 are fixed on powerpc These tests have been fixed but not tested and re-enabled on big-endian powerpc (see comments in #11260 and #11323) - - - - - fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00 CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) - - - - - 8cf7500a by Cheng Shao at 2023-10-21T20:47:52-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - c3ca6215 by Andrew Lelechenko at 2023-10-21T20:47:56-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - 8 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/CoreToStg/Prep.hs - docs/rts/rts.tex - libraries/base/changelog.md - rts/Interpreter.c - rts/PrimOps.cmm - testsuite/tests/driver/recomp011/all.T - testsuite/tests/driver/recomp015/all.T Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -43,23 +43,19 @@ import GHC.Platform import GHC.Platform.Profile import Control.Monad -import Control.Monad.ST ( runST ) import Control.Monad.Trans.Class import Control.Monad.Trans.State.Strict -import Data.Array.MArray - import qualified Data.Array.Unboxed as Array import Data.Array.Base ( UArray(..) ) -import Data.Array.Unsafe( castSTUArray ) - import Foreign hiding (shiftL, shiftR) import Data.Char ( ord ) import Data.List ( genericLength ) import Data.Map.Strict (Map) import Data.Maybe (fromMaybe) import qualified Data.Map.Strict as Map +import GHC.Float (castFloatToWord32, castDoubleToWord64) -- ----------------------------------------------------------------------------- -- Unlinked BCOs @@ -416,7 +412,7 @@ assembleI platform i = case i of tuple_proto p <- ioptr (liftM BCOPtrBCO ul_bco) p_tup <- ioptr (liftM BCOPtrBCO ul_tuple_bco) - info <- int (fromIntegral $ + info <- word (fromIntegral $ mkNativeCallInfoSig platform call_info) emit bci_PUSH_ALTS_T [Op p, Op info, Op p_tup] @@ -466,21 +462,21 @@ assembleI platform i = case i of emit bci_TESTLT_W [Op np, LabelOp l] TESTEQ_W w l -> do np <- word w emit bci_TESTEQ_W [Op np, LabelOp l] - TESTLT_I64 i l -> do np <- int64 i + TESTLT_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTLT_I64 [Op np, LabelOp l] - TESTEQ_I64 i l -> do np <- int64 i + TESTEQ_I64 i l -> do np <- word64 (fromIntegral i) emit bci_TESTEQ_I64 [Op np, LabelOp l] - TESTLT_I32 i l -> do np <- int (fromIntegral i) + TESTLT_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I32 [Op np, LabelOp l] - TESTEQ_I32 i l -> do np <- int (fromIntegral i) + TESTEQ_I32 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I32 [Op np, LabelOp l] - TESTLT_I16 i l -> do np <- int (fromIntegral i) + TESTLT_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I16 [Op np, LabelOp l] - TESTEQ_I16 i l -> do np <- int (fromIntegral i) + TESTEQ_I16 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I16 [Op np, LabelOp l] - TESTLT_I8 i l -> do np <- int (fromIntegral i) + TESTLT_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTLT_I8 [Op np, LabelOp l] - TESTEQ_I8 i l -> do np <- int (fromIntegral i) + TESTEQ_I8 i l -> do np <- word (fromIntegral i) emit bci_TESTEQ_I8 [Op np, LabelOp l] TESTLT_W64 w l -> do np <- word64 w emit bci_TESTLT_W64 [Op np, LabelOp l] @@ -530,42 +526,80 @@ assembleI platform i = case i of -- On Windows, stdcall labels have a suffix indicating the no. of -- arg words, e.g. foo at 8. testcase: ffi012(ghci) literal (LitLabel fs _ _) = litlabel fs - literal LitNullAddr = int 0 + literal LitNullAddr = word 0 literal (LitFloat r) = float (fromRational r) literal (LitDouble r) = double (fromRational r) literal (LitChar c) = int (ord c) literal (LitString bs) = lit [BCONPtrStr bs] -- LitString requires a zero-terminator when emitted literal (LitNumber nt i) = case nt of - LitNumInt -> int (fromIntegral i) - LitNumWord -> int (fromIntegral i) - LitNumInt8 -> int8 (fromIntegral i) - LitNumWord8 -> int8 (fromIntegral i) - LitNumInt16 -> int16 (fromIntegral i) - LitNumWord16 -> int16 (fromIntegral i) - LitNumInt32 -> int32 (fromIntegral i) - LitNumWord32 -> int32 (fromIntegral i) - LitNumInt64 -> int64 (fromIntegral i) - LitNumWord64 -> int64 (fromIntegral i) + LitNumInt -> word (fromIntegral i) + LitNumWord -> word (fromIntegral i) + LitNumInt8 -> word8 (fromIntegral i) + LitNumWord8 -> word8 (fromIntegral i) + LitNumInt16 -> word16 (fromIntegral i) + LitNumWord16 -> word16 (fromIntegral i) + LitNumInt32 -> word32 (fromIntegral i) + LitNumWord32 -> word32 (fromIntegral i) + LitNumInt64 -> word64 (fromIntegral i) + LitNumWord64 -> word64 (fromIntegral i) LitNumBigNat -> panic "GHC.ByteCode.Asm.literal: LitNumBigNat" -- We can lower 'LitRubbish' to an arbitrary constant, but @NULL@ is most -- likely to elicit a crash (rather than corrupt memory) in case absence -- analysis messed up. - literal (LitRubbish {}) = int 0 + literal (LitRubbish {}) = word 0 litlabel fs = lit [BCONPtrLbl fs] addr (RemotePtr a) = words [fromIntegral a] - float = words . mkLitF platform - double = words . mkLitD platform - int = words . mkLitI - int8 = words . mkLitI64 platform - int16 = words . mkLitI64 platform - int32 = words . mkLitI64 platform - int64 = words . mkLitI64 platform - word64 = words . mkLitW64 platform words ws = lit (map BCONPtrWord ws) word w = words [w] + word_size = platformWordSize platform + word_size_bits = platformWordSizeInBits platform + + -- Make lists of host-sized words for literals, so that when the + -- words are placed in memory at increasing addresses, the + -- bit pattern is correct for the host's word size and endianness. + -- + -- Note that we only support host endianness == target endianness for now, + -- even with the external interpreter. This would need to be fixed to + -- support host endianness /= target endianness + int :: Int -> Assembler Word + int i = word (fromIntegral i) + + float :: Float -> Assembler Word + float f = word32 (castFloatToWord32 f) + + double :: Double -> Assembler Word + double d = word64 (castDoubleToWord64 d) + + word64 :: Word64 -> Assembler Word + word64 ww = case word_size of + PW4 -> + let !wl = fromIntegral ww + !wh = fromIntegral (ww `unsafeShiftR` 32) + in case platformByteOrder platform of + LittleEndian -> words [wl,wh] + BigEndian -> words [wh,wl] + PW8 -> word (fromIntegral ww) + + word8 :: Word8 -> Assembler Word + word8 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 8)) + + word16 :: Word16 -> Assembler Word + word16 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> word (fromIntegral x `unsafeShiftL` (word_size_bits - 16)) + + word32 :: Word32 -> Assembler Word + word32 x = case platformByteOrder platform of + LittleEndian -> word (fromIntegral x) + BigEndian -> case word_size of + PW4 -> word (fromIntegral x) + PW8 -> word (fromIntegral x `unsafeShiftL` 32) + isLargeW :: Word -> Bool isLargeW n = n > 65535 @@ -648,74 +682,5 @@ mkNativeCallInfoLit :: Platform -> NativeCallInfo -> Literal mkNativeCallInfoLit platform call_info = mkLitWord platform . fromIntegral $ mkNativeCallInfoSig platform call_info --- Make lists of host-sized words for literals, so that when the --- words are placed in memory at increasing addresses, the --- bit pattern is correct for the host's word size and endianness. -mkLitI :: Int -> [Word] -mkLitF :: Platform -> Float -> [Word] -mkLitD :: Platform -> Double -> [Word] -mkLitI64 :: Platform -> Int64 -> [Word] -mkLitW64 :: Platform -> Word64 -> [Word] - -mkLitF platform f = case platformWordSize platform of - PW4 -> runST $ do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 f - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - - PW8 -> runST $ do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 f - -- on 64-bit architectures we read two (32-bit) Float cells when we read - -- a (64-bit) Word: so we write a dummy value in the second cell to - -- avoid an out-of-bound read. - writeArray arr 1 0.0 - f_arr <- castSTUArray arr - w0 <- readArray f_arr 0 - return [w0 :: Word] - -mkLitD platform d = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word, w1] - ) - PW8 -> runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 d - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - return [w0 :: Word] - ) - -mkLitI64 platform ii = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Int),1) - writeArray arr 0 ii - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ii :: Word] - -mkLitW64 platform ww = case platformWordSize platform of - PW4 -> runST (do - arr <- newArray_ ((0::Word),1) - writeArray arr 0 ww - d_arr <- castSTUArray arr - w0 <- readArray d_arr 0 - w1 <- readArray d_arr 1 - return [w0 :: Word,w1] - ) - PW8 -> [fromIntegral ww :: Word] - -mkLitI i = [fromIntegral i :: Word] - iNTERP_STACK_CHECK_THRESH :: Int iNTERP_STACK_CHECK_THRESH = INTERP_STACK_CHECK_THRESH ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -643,13 +643,20 @@ cpeBind top_lvl env (Rec pairs) where (bndrs, rhss) = unzip pairs - -- Flatten all the floats, and the current - -- group into a single giant Rec + -- Flatten all the floats, and the current + -- group into a single giant Rec add_float (Float bind bound _) prs2 - | bound /= CaseBound = case bind of + | bound /= CaseBound + || all (definitelyLiftedType . idType) (bindersOf bind) + -- The latter check is hit in -O0 (i.e., flavours quick, devel2) + -- for dictionary args which haven't been floated out yet, #24102. + -- They are preferably CaseBound, but since they are lifted we may + -- just as well put them in the Rec, in contrast to lifted bindings. + = case bind of NonRec x e -> (x,e) : prs2 Rec prs1 -> prs1 ++ prs2 - add_float f _ = pprPanic "cpeBind" (ppr f) + add_float f _ = pprPanic "cpeBind" (ppr f) + --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool ===================================== docs/rts/rts.tex ===================================== @@ -1970,10 +1970,9 @@ Here the right-hand sides of @range@ and @ys@ are both thunks; the former is static while the latter is dynamic. The layout of a thunk is the same as that for a function closure. -However, thunks must have a payload of at least @MIN_UPD_SIZE@ -words to allow it to be overwritten with a black hole and an -indirection. The compiler may have to add extra non-pointer fields to -satisfy this constraint. +However, a thunk header always contains an extra padding word at the +end. This allows the thunk to be overwritten with an indirection, +where the padding word will be repurposed as the indirectee pointer. \begin{center} \begin{tabular}{|l|l|l|l|l|}\hline ===================================== libraries/base/changelog.md ===================================== @@ -9,14 +9,16 @@ * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`. ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166)) * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)). + * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) + * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) -## 4.19.0.0 *TBA* +## 4.19.0.0 *October 2023* * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`. Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it. ([CLC proposal #87](https://github.com/haskell/core-libraries-committee/issues/87) and [#114](https://github.com/haskell/core-libraries-committee/issues/114)) - * `GHC.Conc.Sync` now exports `fromThreadId :: ThreadId -> Word64`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117)) + * Add `fromThreadId :: ThreadId -> Word64` to `GHC.Conc.Sync`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117)) * Add `Data.List.!?` ([CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110)) - * `maximumBy`/`minimumBy` are now marked as `INLINE` improving performance for unpackable + * Mark `maximumBy`/`minimumBy` as `INLINE` improving performance for unpackable types significantly. * Add INLINABLE pragmas to `generic*` functions in Data.OldList ([CLC proposal #129](https://github.com/haskell/core-libraries-committee/issues/130)) * Export `getSolo` from `Data.Tuple`. @@ -34,20 +36,18 @@ * Add `COMPLETE` pragmas to the `TypeRep`, `SSymbol`, `SChar`, and `SNat` pattern synonyms. ([CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149)) * Make `($)` representation polymorphic ([CLC proposal #132](https://github.com/haskell/core-libraries-committee/issues/132)) - * Implemented [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst), + * Implement [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst), adding the class `Unsatisfiable :: ErrorMessage -> TypeError` to `GHC.TypeError`, which provides a mechanism for custom type errors that reports the errors in a more predictable behaviour than `TypeError`. * Add more instances for `Compose`: `Enum`, `Bounded`, `Num`, `Real`, `Integral` ([CLC proposal #160](https://github.com/haskell/core-libraries-committee/issues/160)) * Make `(&)` representation polymorphic in the return type ([CLC proposal #158](https://github.com/haskell/core-libraries-committee/issues/158)) * Implement `GHC.IORef.atomicSwapIORef` via a new dedicated primop `atomicSwapMutVar#` ([CLC proposal #139](https://github.com/haskell/core-libraries-committee/issues/139)) - * Change codebuffers to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134)) - * Add nominal role annotations to SNat/SSymbol/SChar ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170)) + * Change `BufferCodec` to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134)) + * Add nominal role annotations to `SNat` / `SSymbol` / `SChar` ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170)) * Make `Semigroup`'s `stimes` specializable. ([CLC proposal #8](https://github.com/haskell/core-libraries-committee/issues/8)) - * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86)) - * Fixed exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192)) * Implement `copyBytes`, `fillBytes`, `moveBytes` and `stimes` for `Data.Array.Byte.ByteArray` using primops ([CLC proposal #188](https://github.com/haskell/core-libraries-committee/issues/188)) - * Add rewrite rules for conversion between Int64/Word64 and Float/Double on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)). + * Add rewrite rules for conversion between `Int64` / `Word64` and `Float` / `Double` on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)). ## 4.18.0.0 *March 2023* * Shipped with GHC 9.6.1 ===================================== rts/Interpreter.c ===================================== @@ -1275,21 +1275,21 @@ run_BCO: case bci_PUSH8_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); + *(StgWord8*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH16_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); + *(StgWord16*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } case bci_PUSH32_W: { W_ off = BCO_GET_LARGE_ARG; - *(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); + *(StgWord32*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off)); Sp_subW(1); goto nextInsn; } ===================================== rts/PrimOps.cmm ===================================== @@ -740,25 +740,15 @@ stg_atomicModifyMutVar2zh ( gcptr mv, gcptr f ) obviously we can share (f x). - z = [stg_ap_2 f x] (max (HS + 2) MIN_UPD_SIZE) - y = [stg_sel_0 z] (max (HS + 1) MIN_UPD_SIZE) + z = [stg_ap_2 f x] (SIZEOF_StgThunkHeader + WDS(2)) + y = [stg_sel_0 z] (SIZEOF_StgThunkHeader + WDS(1)) */ -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 1 -#define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE)) -#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),WDS(MIN_UPD_SIZE-1)) -#else #define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(1)) #define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),0) -#endif -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2 -#define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE)) -#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2)) -#else #define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(2)) #define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),0) -#endif #define SIZE (THUNK_2_SIZE + THUNK_1_SIZE) @@ -815,13 +805,8 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f ) z = [stg_ap_2 f x] (max (HS + 2) MIN_UPD_SIZE) */ -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2 -#define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE)) -#define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2)) -#else #define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(2)) #define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),0) -#endif HP_CHK_GEN_TICKY(THUNK_SIZE); ===================================== testsuite/tests/driver/recomp011/all.T ===================================== @@ -2,7 +2,6 @@ test('recomp011', [ extra_files(['Main.hs']) - , when(arch('powerpc64'), expect_broken(11260)) , js_broken(22261) ], makefile_test, []) ===================================== testsuite/tests/driver/recomp015/all.T ===================================== @@ -5,7 +5,7 @@ test('recomp015', # See ticket:11022#comment:7 unless(opsys('linux') or opsys('solaris2') or opsys('openbsd'), skip), when(arch('arm'), skip), - js_skip, # JS backend doesn't support .s assembly files - when(arch('powerpc64'), expect_broken(11323))], + js_skip # JS backend doesn't support .s assembly files + ], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5cce070d396e17283528a64cc63841330b9c5020...c3ca62151a0c514e843e555cdb76ffa857a7e6fb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5cce070d396e17283528a64cc63841330b9c5020...c3ca62151a0c514e843e555cdb76ffa857a7e6fb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 22 01:08:25 2023 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Sat, 21 Oct 2023 21:08:25 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/hadrian-ghc-llvm-version Message-ID: <653476094ff50_ab41e16bd2e8088933@gitlab.mail> John Ericson pushed new branch wip/hadrian-ghc-llvm-version at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hadrian-ghc-llvm-version You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 22 04:09:01 2023 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 22 Oct 2023 00:09:01 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Move function checks to RTS configure Message-ID: <6534a05d2fdbe_ab41e1ab4d11499485@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c258eb96 by John Ericson at 2023-10-22T00:08:45-04:00 Move function checks to RTS configure Some of these functions are used in `base` too, but we can copy the checks over to its configure if that's an issue. - - - - - e10cc51a by John Ericson at 2023-10-22T00:08:45-04:00 Move over a number of C-style checks to RTS configure - - - - - ec72ff55 by John Ericson at 2023-10-22T00:08:46-04:00 Move/Copy more `AC_DEFINE` to RTS config Only exception is the LLVM version macros, which are used for GHC itself. - - - - - aac494b5 by John Ericson at 2023-10-22T00:08:46-04:00 Define `TABLES_NEXT_TO_CODE` in the RTS configure We create a new cabal flag to facilitate this. - - - - - ee75fec8 by John Ericson at 2023-10-22T00:08:46-04:00 Configure scripts: `checkOS`: Make a bit more robust `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This allows us to cope with configs/triples that we haven't normalized extra being what GNU `config.sub` does. - - - - - 06d12e7c by John Ericson at 2023-10-22T00:08:46-04:00 Generate `ghcplatform.h` from RTS configure We create a new cabal flag to facilitate this. - - - - - 4f790a53 by John Ericson at 2023-10-22T00:08:46-04:00 Get rid of all mention of `mk/config.h` The RTS configure script is now solely responsible for managing its headers; the top level configure script does not help. - - - - - 953ae4e9 by Cheng Shao at 2023-10-22T00:08:47-04:00 rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. - - - - - 96719ad7 by Andrew Lelechenko at 2023-10-22T00:08:49-04:00 base changelog: move non-backported entries from 4.19 section to 4.20 Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational) nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip) were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section. Also minor stylistic changes to other entries, bringing them to a uniform form. - - - - - 20 changed files: - .gitignore - compiler/GHC/Builtin/primops.txt.pp - configure.ac - distrib/cross-port - docs/coding-style.html - docs/rts/rts.tex - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Settings/Packages.hs - libraries/base/changelog.md - m4/fp_cc_supports__atomics.m4 - m4/fptools_set_haskell_platform_vars.m4 - m4/ghc_convert_os.m4 - rts/PrimOps.cmm - rts/configure.ac - + rts/ghcplatform.h.bottom - + rts/ghcplatform.h.top.in - rts/rts.cabal Changes: ===================================== .gitignore ===================================== @@ -184,8 +184,8 @@ _darcs/ /linter.log /mk/are-validating.mk /mk/build.mk -/mk/config.h -/mk/config.h.in +/mk/unused.h +/mk/unused.h.in /mk/config.mk /mk/config.mk.old /mk/system-cxx-std-lib-1.0.conf ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -229,7 +229,7 @@ section "The word size story." must contain at least 30 bits. GHC always implements 'Int' using the primitive type 'Int#', whose size equals the @MachDeps.h@ constant @WORD\_SIZE\_IN\_BITS at . - This is normally set based on the @config.h@ parameter + This is normally set based on the RTS @ghcautoconf.h@ parameter @SIZEOF\_HSWORD@, i.e., 32 bits on 32-bit machines, 64 bits on 64-bit machines. ===================================== configure.ac ===================================== @@ -32,8 +32,8 @@ AC_CONFIG_MACRO_DIRS([m4]) # checkout), then we ship a file 'VERSION' containing the full version # when the source distribution was created. -if test ! -f mk/config.h.in; then - echo "mk/config.h.in doesn't exist: perhaps you haven't run 'python3 boot'?" +if test ! -f rts/ghcautoconf.h.autoconf.in; then + echo "rts/ghcautoconf.h.autoconf.in doesn't exist: perhaps you haven't run 'python3 boot'?" exit 1 fi @@ -84,8 +84,11 @@ AC_PREREQ([2.69]) # Prepare to generate the following header files # -# This one is autogenerated by autoheader. -AC_CONFIG_HEADER(mk/config.h) +dnl so the next header, which is manually maintained, doesn't get +dnl overwritten by an autogenerated header. Once we have no more +dnl `AC_CONFIG_HEADER` calls (issue #23966) we can delete all mention +dnl of `mk/unused.h`. +AC_CONFIG_HEADER(mk/unused.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) @@ -138,27 +141,6 @@ if test "$EnableDistroToolchain" = "YES"; then TarballsAutodownload=NO fi -AC_ARG_ENABLE(asserts-all-ways, -[AS_HELP_STRING([--enable-asserts-all-ways], - [Usually ASSERTs are only compiled in the DEBUG way, - this will enable them in all ways.])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])], - [EnableAssertsAllWays=NO] -) -if test "$enable_asserts_all_ways" = "yes" ; then - AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.]) -fi - -AC_ARG_ENABLE(native-io-manager, -[AS_HELP_STRING([--enable-native-io-manager], - [Enable the native I/O manager by default.])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])], - [EnableNativeIOManager=NO] -) -if test "$EnableNativeIOManager" = "YES"; then - AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.]) -fi - AC_ARG_ENABLE(ghc-toolchain, [AS_HELP_STRING([--enable-ghc-toolchain], [Whether to use the newer ghc-toolchain tool to configure ghc targets])], @@ -319,9 +301,6 @@ dnl ** Do a build with tables next to code? dnl -------------------------------------------------------------- GHC_TABLES_NEXT_TO_CODE -if test x"$TablesNextToCode" = xYES; then - AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code]) -fi AC_SUBST(TablesNextToCode) # Requires FPTOOLS_SET_PLATFORMS_VARS to be run first. @@ -617,12 +596,15 @@ dnl unregisterised, Sparc, and PPC backends. Also determines whether dnl linking to libatomic is required for atomic operations, e.g. on dnl RISCV64 GCC. FP_CC_SUPPORTS__ATOMICS +if test "$need_latomic" = 1; then + AC_SUBST([NeedLibatomic],[YES]) +else + AC_SUBST([NeedLibatomic],[NO]) +fi dnl ** look to see if we have a C compiler using an llvm back end. dnl FP_CC_LLVM_BACKEND -AS_IF([test x"$CcLlvmBackend" = x"YES"], - [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])]) AC_SUBST(CcLlvmBackend) FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS]) @@ -845,88 +827,14 @@ dnl -------------------------------------------------- dnl ### program checking section ends here ### dnl -------------------------------------------------- -dnl -------------------------------------------------- -dnl * Platform header file and syscall feature tests -dnl ### checking the state of the local header files and syscalls ### - -dnl ** Enable large file support. NB. do this before testing the type of -dnl off_t, because it will affect the result of that test. -AC_SYS_LARGEFILE - -dnl ** check for specific header (.h) files that we are interested in -AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h]) - -dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708 -AC_CHECK_HEADERS([sys/cpuset.h], [], [], -[[#if HAVE_SYS_PARAM_H -# include -#endif -]]) - -dnl ** check whether a declaration for `environ` is provided by libc. -FP_CHECK_ENVIRON - -dnl ** do we have long longs? -AC_CHECK_TYPES([long long]) - -dnl ** what are the sizes of various types -FP_CHECK_SIZEOF_AND_ALIGNMENT(char) -FP_CHECK_SIZEOF_AND_ALIGNMENT(double) -FP_CHECK_SIZEOF_AND_ALIGNMENT(float) -FP_CHECK_SIZEOF_AND_ALIGNMENT(int) -FP_CHECK_SIZEOF_AND_ALIGNMENT(long) -if test "$ac_cv_type_long_long" = yes; then -FP_CHECK_SIZEOF_AND_ALIGNMENT(long long) -fi -FP_CHECK_SIZEOF_AND_ALIGNMENT(short) -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char) -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int) -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long) -if test "$ac_cv_type_long_long" = yes; then -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long) -fi -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short) -FP_CHECK_SIZEOF_AND_ALIGNMENT(void *) - -FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t) -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t) - - dnl for use in settings file +AC_CHECK_SIZEOF([void *]) TargetWordSize=$ac_cv_sizeof_void_p AC_SUBST(TargetWordSize) AC_C_BIGENDIAN([TargetWordBigEndian=YES],[TargetWordBigEndian=NO]) AC_SUBST(TargetWordBigEndian) -FP_CHECK_FUNC([WinExec], - [@%:@include ], [WinExec("",0)]) - -FP_CHECK_FUNC([GetModuleFileName], - [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)]) - -dnl ** check for more functions -dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too. -AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale]) - -dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if -dnl ** _POSIX_C_SOURCE is defined -AC_CHECK_DECLS([ctime_r], , , -[#define _POSIX_SOURCE 1 -#define _POSIX_C_SOURCE 199506L -#include ]) - -dnl On Linux we should have program_invocation_short_name -AC_CHECK_DECLS([program_invocation_short_name], , , -[#define _GNU_SOURCE 1 -#include ]) - dnl ** check for math library dnl Keep that check as early as possible. dnl as we need to know whether we need libm ===================================== distrib/cross-port ===================================== @@ -28,7 +28,7 @@ if [ ! -f b1-stamp ]; then # For cross-compilation, at this stage you may want to set up a source # tree on the target machine, run the configure script there, and bring - # the resulting mk/config.h file back into this tree before building + # the resulting rts/ghcautoconf.h.autoconf file back into this tree before building # the libraries. touch mk/build.mk @@ -38,7 +38,7 @@ if [ ! -f b1-stamp ]; then # We could optimise slightly by not building hslibs here. Also, building # the RTS is not necessary (and might not be desirable if we're using - # a config.h from the target system). + # a ghcautoconf.h from the target system). make stage1 cd .. ===================================== docs/coding-style.html ===================================== @@ -108,7 +108,7 @@ POSIX-compliant to explicitly say so by having #include

  • Some architectures have memory alignment constraints. Others don't have any constraints but go faster if you align things. These -macros (from config.h) tell you which alignment to use +macros (from ghcautoconf.h) tell you which alignment to use
       /* minimum alignment of unsigned int */
    
    
    =====================================
    docs/rts/rts.tex
    =====================================
    @@ -1970,10 +1970,9 @@ Here the right-hand sides of @range@ and @ys@ are both thunks; the former
     is static while the latter is dynamic.
     
     The layout of a thunk is the same as that for a function closure.
    -However, thunks must have a payload of at least @MIN_UPD_SIZE@
    -words to allow it to be overwritten with a black hole and an
    -indirection.  The compiler may have to add extra non-pointer fields to
    -satisfy this constraint.
    +However, a thunk header always contains an extra padding word at the
    +end. This allows the thunk to be overwritten with an indirection,
    +where the padding word will be repurposed as the indirectee pointer.
     
     \begin{center}
     \begin{tabular}{|l|l|l|l|l|}\hline
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -155,10 +155,10 @@ generatePackageCode context@(Context stage pkg _ _) = do
         when (pkg == rts) $ do
             root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file ->
                 build $ target context GenApply [] [file]
    -        let go gen file = generate file (semiEmptyTarget stage) gen
             root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ ->
                 need . pure =<< pkgSetupConfigFile context
    -        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH
    +        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ ->
    +            need . pure =<< pkgSetupConfigFile context
             root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context
             root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines"
             root -/- "**" -/- dir -/- "include/rts/EventTypes.h" %> genEventTypes "--event-types-array"
    @@ -357,62 +357,6 @@ ghcWrapper stage  = do
                                          else [])
                                    ++ [ "$@" ]
     
    --- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that
    --- the resulting 'String' is a valid C preprocessor identifier.
    -cppify :: String -> String
    -cppify = replaceEq '-' '_' . replaceEq '.' '_'
    -
    --- | Generate @ghcplatform.h@ header.
    --- ROMES:TODO: For the runtime-retargetable GHC, these will eventually have to
    --- be determined at runtime, and no longer hardcoded to a file (passed as -D
    --- flags to the preprocessor, probably)
    -generateGhcPlatformH :: Expr String
    -generateGhcPlatformH = do
    -    trackGenerateHs
    -    stage    <- getStage
    -    let chooseSetting x y = case stage of { Stage0 {} -> x; _ -> y }
    -    buildPlatform  <- chooseSetting (queryBuild targetPlatformTriple) (queryHost targetPlatformTriple)
    -    buildArch      <- chooseSetting (queryBuild queryArch)   (queryHost queryArch)
    -    buildOs        <- chooseSetting (queryBuild queryOS)     (queryHost queryOS)
    -    buildVendor    <- chooseSetting (queryBuild queryVendor) (queryHost queryVendor)
    -    hostPlatform   <- chooseSetting (queryHost targetPlatformTriple) (queryTarget targetPlatformTriple)
    -    hostArch       <- chooseSetting (queryHost queryArch)    (queryTarget queryArch)
    -    hostOs         <- chooseSetting (queryHost queryOS)      (queryTarget queryOS)
    -    hostVendor     <- chooseSetting (queryHost queryVendor)  (queryTarget queryVendor)
    -    ghcUnreg       <- queryTarget tgtUnregisterised
    -    return . unlines $
    -        [ "#if !defined(__GHCPLATFORM_H__)"
    -        , "#define __GHCPLATFORM_H__"
    -        , ""
    -        , "#define BuildPlatform_TYPE  " ++ cppify buildPlatform
    -        , "#define HostPlatform_TYPE   " ++ cppify hostPlatform
    -        , ""
    -        , "#define " ++ cppify buildPlatform   ++ "_BUILD 1"
    -        , "#define " ++ cppify hostPlatform ++ "_HOST 1"
    -        , ""
    -        , "#define " ++ buildArch   ++ "_BUILD_ARCH 1"
    -        , "#define " ++ hostArch ++ "_HOST_ARCH 1"
    -        , "#define BUILD_ARCH " ++ show buildArch
    -        , "#define HOST_ARCH "  ++ show hostArch
    -        , ""
    -        , "#define " ++ buildOs   ++ "_BUILD_OS 1"
    -        , "#define " ++ hostOs ++ "_HOST_OS 1"
    -        , "#define BUILD_OS " ++ show buildOs
    -        , "#define HOST_OS "  ++ show hostOs
    -        , ""
    -        , "#define " ++ buildVendor   ++ "_BUILD_VENDOR 1"
    -        , "#define " ++ hostVendor ++ "_HOST_VENDOR 1"
    -        , "#define BUILD_VENDOR " ++ show buildVendor
    -        , "#define HOST_VENDOR "  ++ show hostVendor
    -        , ""
    -        ]
    -        ++
    -        [ "#define UnregisterisedCompiler 1" | ghcUnreg ]
    -        ++
    -        [ ""
    -        , "#endif /* __GHCPLATFORM_H__ */"
    -        ]
    -
     generateSettings :: Expr String
     generateSettings = do
         ctx <- getContext
    
    
    =====================================
    hadrian/src/Rules/Lint.hs
    =====================================
    @@ -22,6 +22,8 @@ lintRules = do
           cmd_ (Cwd "libraries/base") "./configure"
       "rts" -/- "include" -/- "ghcautoconf.h" %> \_ ->
           cmd_ (Cwd "rts") "./configure"
    +  "rts" -/- "include" -/- "ghcplatform.h" %> \_ ->
    +      cmd_ (Cwd "rts") "./configure"
     
     lint :: Action () -> Action ()
     lint lintAction = do
    @@ -68,7 +70,6 @@ base = do
       let includeDirs =
             [ "rts/include"
             , "libraries/base/include"
    -        , stage1RtsInc
             ]
       runHLint includeDirs [] "libraries/base"
     
    
    
    =====================================
    hadrian/src/Rules/Register.hs
    =====================================
    @@ -51,12 +51,6 @@ configurePackageRules = do
               isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend
               when isGmp $
                 need [buildP -/- "include/ghc-gmp.h"]
    -        when (pkg == rts) $ do
    -          -- Rts.h is a header listed in the cabal file, and configuring
    -          -- therefore wants to ensure that the header "works" post-configure.
    -          -- But it (transitively) includes this, so we must ensure it exists
    -          -- for that check to work.
    -          need [buildP -/- "include/ghcplatform.h"]
             Cabal.configurePackage ctx
     
         root -/- "**/autogen/cabal_macros.h" %> \out -> do
    
    
    =====================================
    hadrian/src/Rules/SourceDist.hs
    =====================================
    @@ -156,7 +156,8 @@ prepareTree dest = do
           , pkgPath terminfo -/- "configure"
           , "configure"
           , "aclocal.m4"
    -      , "mk" -/- "config.h.in" ]
    +      , "mk" -/- "unused.h.in"
    +      ]
     
         copyAlexHappyFiles =
           forM_ alexHappyFiles $ \(stg, pkg, inp, out) -> do
    
    
    =====================================
    hadrian/src/Settings/Packages.hs
    =====================================
    @@ -281,8 +281,8 @@ rtsPackageArgs = package rts ? do
         targetArch     <- queryTarget queryArch
         targetOs       <- queryTarget queryOS
         targetVendor   <- queryTarget queryVendor
    -    ghcUnreg       <- yesNo <$> queryTarget tgtUnregisterised
    -    ghcEnableTNC   <- yesNo <$> queryTarget tgtTablesNextToCode
    +    ghcUnreg       <- queryTarget tgtUnregisterised
    +    ghcEnableTNC   <- queryTarget tgtTablesNextToCode
         rtsWays        <- getRtsWays
         way            <- getWay
         path           <- getBuildPath
    @@ -355,8 +355,8 @@ rtsPackageArgs = package rts ? do
                 , "-DTargetArch="                ++ show targetArch
                 , "-DTargetOS="                  ++ show targetOs
                 , "-DTargetVendor="              ++ show targetVendor
    -            , "-DGhcUnregisterised="         ++ show ghcUnreg
    -            , "-DTablesNextToCode="          ++ show ghcEnableTNC
    +            , "-DGhcUnregisterised="         ++ show (yesNo ghcUnreg)
    +            , "-DTablesNextToCode="          ++ show (yesNo ghcEnableTNC)
                 , "-DRtsWay=\"rts_" ++ show way ++ "\""
                 ]
     
    @@ -414,6 +414,8 @@ rtsPackageArgs = package rts ? do
               , flag UseLibzstd                 `cabalFlag` "libzstd"
               , flag StaticLibzstd              `cabalFlag` "static-libzstd"
               , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
    +          , ghcUnreg                        `cabalFlag` "unregisterised"
    +          , ghcEnableTNC                    `cabalFlag` "tables-next-to-code"
               , Debug `wayUnit` way             `cabalFlag` "find-ptr"
               ]
             , builder (Cabal Setup) ? mconcat
    
    
    =====================================
    libraries/base/changelog.md
    =====================================
    @@ -9,14 +9,16 @@
       * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`.
         ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166))
       * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)).
    +  * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86))
    +  * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192))
     
    -## 4.19.0.0 *TBA*
    +## 4.19.0.0 *October 2023*
       * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`.
         Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it.
         ([CLC proposal #87](https://github.com/haskell/core-libraries-committee/issues/87) and [#114](https://github.com/haskell/core-libraries-committee/issues/114))
    -  * `GHC.Conc.Sync` now exports `fromThreadId :: ThreadId -> Word64`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
    +  * Add `fromThreadId :: ThreadId -> Word64` to `GHC.Conc.Sync`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
       * Add `Data.List.!?` ([CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110))
    -  * `maximumBy`/`minimumBy` are now marked as `INLINE` improving performance for unpackable
    +  * Mark `maximumBy`/`minimumBy` as `INLINE` improving performance for unpackable
         types significantly.
       * Add INLINABLE pragmas to `generic*` functions in Data.OldList ([CLC proposal #129](https://github.com/haskell/core-libraries-committee/issues/130))
       * Export `getSolo` from `Data.Tuple`.
    @@ -34,20 +36,18 @@
       * Add `COMPLETE` pragmas to the `TypeRep`, `SSymbol`, `SChar`, and `SNat` pattern synonyms.
           ([CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149))
       * Make `($)` representation polymorphic ([CLC proposal #132](https://github.com/haskell/core-libraries-committee/issues/132))
    -  * Implemented [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst),
    +  * Implement [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst),
         adding the class `Unsatisfiable :: ErrorMessage -> TypeError` to `GHC.TypeError`,
         which provides a mechanism for custom type errors that reports the errors in
         a more predictable behaviour than `TypeError`.
       * Add more instances for `Compose`: `Enum`, `Bounded`, `Num`, `Real`, `Integral` ([CLC proposal #160](https://github.com/haskell/core-libraries-committee/issues/160))
       * Make `(&)` representation polymorphic in the return type ([CLC proposal #158](https://github.com/haskell/core-libraries-committee/issues/158))
       * Implement `GHC.IORef.atomicSwapIORef` via a new dedicated primop `atomicSwapMutVar#` ([CLC proposal #139](https://github.com/haskell/core-libraries-committee/issues/139))
    -  * Change codebuffers to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134))
    -  * Add nominal role annotations to SNat/SSymbol/SChar ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170))
    +  * Change `BufferCodec` to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134))
    +  * Add nominal role annotations to `SNat` / `SSymbol` / `SChar` ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170))
       * Make `Semigroup`'s `stimes` specializable. ([CLC proposal #8](https://github.com/haskell/core-libraries-committee/issues/8))
    -  * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86))
    -  * Fixed exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192))
       * Implement `copyBytes`, `fillBytes`, `moveBytes` and `stimes` for `Data.Array.Byte.ByteArray` using primops ([CLC proposal #188](https://github.com/haskell/core-libraries-committee/issues/188))
    -  * Add rewrite rules for conversion between Int64/Word64 and Float/Double on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)).
    +  * Add rewrite rules for conversion between `Int64` / `Word64` and `Float` / `Double` on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)).
     
     ## 4.18.0.0 *March 2023*
       * Shipped with GHC 9.6.1
    
    
    =====================================
    m4/fp_cc_supports__atomics.m4
    =====================================
    @@ -61,12 +61,4 @@ AC_DEFUN([FP_CC_SUPPORTS__ATOMICS],
             AC_MSG_RESULT(no)
             AC_MSG_ERROR([C compiler needs to support __atomic primitives.])
         ])
    -    AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    -    if test "$need_latomic" = 1; then
    -        AC_SUBST([NeedLibatomic],[YES])
    -    else
    -        AC_SUBST([NeedLibatomic],[NO])
    -    fi
    -    AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    -        [Define to 1 if we need -latomic.])
     ])
    
    
    =====================================
    m4/fptools_set_haskell_platform_vars.m4
    =====================================
    @@ -82,7 +82,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS],
             solaris2)
                 test -z "[$]2" || eval "[$]2=OSSolaris2"
                 ;;
    -        mingw32|windows)
    +        mingw32|mingw64|windows)
                 test -z "[$]2" || eval "[$]2=OSMinGW32"
                 ;;
             freebsd)
    @@ -162,8 +162,6 @@ AC_DEFUN([GHC_SUBSECTIONS_VIA_SYMBOLS],
                 TargetHasSubsectionsViaSymbols=NO
              else
                 TargetHasSubsectionsViaSymbols=YES
    -            AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    -                   [Define to 1 if Apple-style dead-stripping is supported.])
              fi
             ],
             [TargetHasSubsectionsViaSymbols=NO
    
    
    =====================================
    m4/ghc_convert_os.m4
    =====================================
    @@ -22,7 +22,7 @@ AC_DEFUN([GHC_CONVERT_OS],[
           openbsd*)
             $3="openbsd"
             ;;
    -      windows|mingw32)
    +      windows|mingw32|mingw64)
             $3="mingw32"
             ;;
           # As far as I'm aware, none of these have relevant variants
    
    
    =====================================
    rts/PrimOps.cmm
    =====================================
    @@ -740,25 +740,15 @@ stg_atomicModifyMutVar2zh ( gcptr mv, gcptr f )
     
             obviously we can share (f x).
     
    -         z = [stg_ap_2 f x]  (max (HS + 2) MIN_UPD_SIZE)
    -         y = [stg_sel_0 z]   (max (HS + 1) MIN_UPD_SIZE)
    +         z = [stg_ap_2 f x]  (SIZEOF_StgThunkHeader + WDS(2))
    +         y = [stg_sel_0 z]   (SIZEOF_StgThunkHeader + WDS(1))
         */
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 1
    -#define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),WDS(MIN_UPD_SIZE-1))
    -#else
     #define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(1))
     #define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),0)
    -#endif
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2
    -#define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
    -#else
     #define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(2))
     #define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),0)
    -#endif
     
     #define SIZE (THUNK_2_SIZE + THUNK_1_SIZE)
     
    @@ -815,13 +805,8 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f )
              z = [stg_ap_2 f x]  (max (HS + 2) MIN_UPD_SIZE)
         */
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2
    -#define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
    -#else
     #define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(2))
     #define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),0)
    -#endif
     
         HP_CHK_GEN_TICKY(THUNK_SIZE);
     
    
    
    =====================================
    rts/configure.ac
    =====================================
    @@ -22,17 +22,153 @@ dnl     #define SIZEOF_CHAR 0
     dnl   recently.
     AC_PREREQ([2.69])
     
    +AC_CONFIG_FILES([ghcplatform.h.top])
    +
     AC_CONFIG_HEADERS([ghcautoconf.h.autoconf])
     
    +AC_ARG_ENABLE(asserts-all-ways,
    +[AS_HELP_STRING([--enable-asserts-all-ways],
    +                [Usually ASSERTs are only compiled in the DEBUG way,
    +                 this will enable them in all ways.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    +  [EnableAssertsAllWays=NO]
    +)
    +if test "$enable_asserts_all_ways" = "yes" ; then
    +   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    +fi
    +
    +AC_ARG_ENABLE(native-io-manager,
    +[AS_HELP_STRING([--enable-native-io-manager],
    +                [Enable the native I/O manager by default.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    +  [EnableNativeIOManager=NO]
    +)
    +if test "$EnableNativeIOManager" = "YES"; then
    +  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    +fi
    +
     # We have to run these unconditionally, but we may discard their
     # results in the following code
     AC_CANONICAL_BUILD
     AC_CANONICAL_HOST
     
    +dnl ** Do a build with tables next to code?
    +dnl --------------------------------------------------------------
    +
    +AS_IF(
    +  [test "$CABAL_FLAG_tables_next_to_code" = 1],
    +  [AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])])
    +
    +dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set),
    +dnl later CC is copied to CC_STAGE{1,2,3}
    +AC_PROG_CC([cc gcc clang])
    +
    +dnl make extensions visible to allow feature-tests to detect them lateron
    +AC_USE_SYSTEM_EXTENSIONS
    +
    +dnl ** Used to determine how to compile ghc-prim's atomics.c, used by
    +dnl    unregisterised, Sparc, and PPC backends. Also determines whether
    +dnl    linking to libatomic is required for atomic operations, e.g. on
    +dnl    RISCV64 GCC.
    +FP_CC_SUPPORTS__ATOMICS
    +AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    +AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    +    [Define to 1 if we need -latomic for sub-word atomic operations.])
    +
    +dnl ** look to see if we have a C compiler using an llvm back end.
    +dnl
    +FP_CC_LLVM_BACKEND
    +AS_IF([test x"$CcLlvmBackend" = x"YES"],
    +  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
    +
    +GHC_CONVERT_PLATFORM_PARTS([build], [Build])
    +FPTOOLS_SET_PLATFORM_VARS([build],[Build])
    +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Build])
    +
     GHC_CONVERT_PLATFORM_PARTS([host], [Host])
     FPTOOLS_SET_PLATFORM_VARS([host], [Host])
     FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
     
    +GHC_SUBSECTIONS_VIA_SYMBOLS
    +AS_IF([test x"${TargetHasSubsectionsViaSymbols}" = x"YES"],
    +  [AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    +    [Define to 1 if Apple-style dead-stripping is supported.])])
    +
    +dnl --------------------------------------------------
    +dnl * Platform header file and syscall feature tests
    +dnl ### checking the state of the local header files and syscalls ###
    +
    +dnl ** Enable large file support.  NB. do this before testing the type of
    +dnl    off_t, because it will affect the result of that test.
    +AC_SYS_LARGEFILE
    +
    +dnl ** check for specific header (.h) files that we are interested in
    +AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    +
    +dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    +AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    +[[#if HAVE_SYS_PARAM_H
    +# include 
    +#endif
    +]])
    +
    +dnl ** check whether a declaration for `environ` is provided by libc.
    +FP_CHECK_ENVIRON
    +
    +dnl ** do we have long longs?
    +AC_CHECK_TYPES([long long])
    +
    +dnl ** what are the sizes of various types
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    +
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    +
    +
    +FP_CHECK_FUNC([WinExec],
    +  [@%:@include ], [WinExec("",0)])
    +
    +FP_CHECK_FUNC([GetModuleFileName],
    +  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    +
    +dnl ** check for more functions
    +dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    +AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    +
    +dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    +dnl ** _POSIX_C_SOURCE is defined
    +AC_CHECK_DECLS([ctime_r], , ,
    +[#define _POSIX_SOURCE 1
    +#define _POSIX_C_SOURCE 199506L
    +#include ])
    +
    +dnl On Linux we should have program_invocation_short_name
    +AC_CHECK_DECLS([program_invocation_short_name], , ,
    +[#define _GNU_SOURCE 1
    +#include ])
    +
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    @@ -140,7 +276,6 @@ AC_ARG_ENABLE(large-address-space,
     )
     
     use_large_address_space=no
    -AC_CHECK_SIZEOF([void *])
     if test "$ac_cv_sizeof_void_p" -eq 8 ; then
         if test "x$EnableLargeAddressSpace" = "xyes" ; then
             if test "$ghc_host_os" = "darwin" ; then
    @@ -223,19 +358,41 @@ dnl --------------------------------------------------------------
     AC_OUTPUT
     
     dnl ######################################################################
    -dnl Generate ghcautoconf.h
    +dnl Generate ghcplatform.h
     dnl ######################################################################
     
     [
     mkdir -p include
    +
    +touch include/ghcplatform.h
    +> include/ghcplatform.h
    +
    +cat ghcplatform.h.top                          >> include/ghcplatform.h
    +]
    +
    +dnl ** Do an unregisterised build?
    +dnl --------------------------------------------------------------
    +AS_IF(
    +  [test "$CABAL_FLAG_unregisterised" = 1],
    +  [echo "#define UnregisterisedCompiler 1"     >> include/ghcplatform.h])
    +
    +[
    +cat $srcdir/ghcplatform.h.bottom               >> include/ghcplatform.h
    +]
    +
    +dnl ######################################################################
    +dnl Generate ghcautoconf.h
    +dnl ######################################################################
    +
    +[
     touch include/ghcautoconf.h
     > include/ghcautoconf.h
     
     echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h
     echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h
    -# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO
    +# Copy the contents of ghcautoconf.h.autoconf, turning '#define PACKAGE_FOO
     # "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
    -cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \
    +cat ghcautoconf.h.autoconf | sed \
        -e 's,^\([	 ]*\)#[	 ]*define[	 ][	 ]*\(PACKAGE_[A-Z]*\)[	 ][ 	]*".*".*$,\1/* #undef \2 */,' \
        -e '/__GLASGOW_HASKELL/d' \
        -e '/REMOVE ME/d' \
    
    
    =====================================
    rts/ghcplatform.h.bottom
    =====================================
    @@ -0,0 +1,2 @@
    +
    +#endif /* __GHCPLATFORM_H__ */
    
    
    =====================================
    rts/ghcplatform.h.top.in
    =====================================
    @@ -0,0 +1,23 @@
    +#if !defined(__GHCPLATFORM_H__)
    +#define __GHCPLATFORM_H__
    +
    +#define BuildPlatform_TYPE  @BuildPlatform_CPP@
    +#define HostPlatform_TYPE   @HostPlatform_CPP@
    +
    +#define @BuildPlatform_CPP at _BUILD  1
    +#define @HostPlatform_CPP at _HOST  1
    +
    +#define @BuildArch_CPP at _BUILD_ARCH  1
    +#define @HostArch_CPP at _HOST_ARCH  1
    +#define BUILD_ARCH  "@BuildArch_CPP@"
    +#define HOST_ARCH  "@HostArch_CPP@"
    +
    +#define @BuildOS_CPP at _BUILD_OS  1
    +#define @HostOS_CPP at _HOST_OS  1
    +#define BUILD_OS  "@BuildOS_CPP@"
    +#define HOST_OS  "@HostOS_CPP@"
    +
    +#define @BuildVendor_CPP at _BUILD_VENDOR  1
    +#define @HostVendor_CPP at _HOST_VENDOR  1
    +#define BUILD_VENDOR  "@BuildVendor_CPP@"
    +#define HOST_VENDOR  "@HostVendor_CPP@"
    
    
    =====================================
    rts/rts.cabal
    =====================================
    @@ -54,6 +54,10 @@ flag static-libzstd
       default: False
     flag leading-underscore
       default: False
    +flag unregisterised
    +  default: False
    +flag tables-next-to-code
    +  default: False
     flag smp
       default: True
     flag find-ptr
    @@ -240,7 +244,7 @@ library
     
           include-dirs: include
           includes: Rts.h
    -      autogen-includes: ghcautoconf.h
    +      autogen-includes: ghcautoconf.h ghcplatform.h
           install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
                             ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
                             -- ^ from include
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c3ca62151a0c514e843e555cdb76ffa857a7e6fb...96719ad7617c4f55a3ead99c3e2811e2f3934928
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c3ca62151a0c514e843e555cdb76ffa857a7e6fb...96719ad7617c4f55a3ead99c3e2811e2f3934928
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 06:49:33 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Sun, 22 Oct 2023 02:49:33 -0400
    Subject: [Git][ghc/ghc][master] 7 commits: Move function checks to RTS
     configure
    Message-ID: <6534c5fd9b626_ab41e1e5d891411368a@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    
    
    17 changed files:
    
    - .gitignore
    - compiler/GHC/Builtin/primops.txt.pp
    - configure.ac
    - distrib/cross-port
    - docs/coding-style.html
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Rules/Lint.hs
    - hadrian/src/Rules/Register.hs
    - hadrian/src/Rules/SourceDist.hs
    - hadrian/src/Settings/Packages.hs
    - m4/fp_cc_supports__atomics.m4
    - m4/fptools_set_haskell_platform_vars.m4
    - m4/ghc_convert_os.m4
    - rts/configure.ac
    - + rts/ghcplatform.h.bottom
    - + rts/ghcplatform.h.top.in
    - rts/rts.cabal
    
    
    Changes:
    
    =====================================
    .gitignore
    =====================================
    @@ -184,8 +184,8 @@ _darcs/
     /linter.log
     /mk/are-validating.mk
     /mk/build.mk
    -/mk/config.h
    -/mk/config.h.in
    +/mk/unused.h
    +/mk/unused.h.in
     /mk/config.mk
     /mk/config.mk.old
     /mk/system-cxx-std-lib-1.0.conf
    
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -229,7 +229,7 @@ section "The word size story."
              must contain at least 30 bits. GHC always implements
              'Int' using the primitive type 'Int#', whose size equals
              the @MachDeps.h@ constant @WORD\_SIZE\_IN\_BITS at .
    -         This is normally set based on the @config.h@ parameter
    +         This is normally set based on the RTS @ghcautoconf.h@ parameter
              @SIZEOF\_HSWORD@, i.e., 32 bits on 32-bit machines, 64
              bits on 64-bit machines.
     
    
    
    =====================================
    configure.ac
    =====================================
    @@ -32,8 +32,8 @@ AC_CONFIG_MACRO_DIRS([m4])
     # checkout), then we ship a file 'VERSION' containing the full version
     # when the source distribution was created.
     
    -if test ! -f mk/config.h.in; then
    -   echo "mk/config.h.in doesn't exist: perhaps you haven't run 'python3 boot'?"
    +if test ! -f rts/ghcautoconf.h.autoconf.in; then
    +   echo "rts/ghcautoconf.h.autoconf.in doesn't exist: perhaps you haven't run 'python3 boot'?"
        exit 1
     fi
     
    @@ -84,8 +84,11 @@ AC_PREREQ([2.69])
     # Prepare to generate the following header files
     #
     
    -# This one is autogenerated by autoheader.
    -AC_CONFIG_HEADER(mk/config.h)
    +dnl so the next header, which is manually maintained, doesn't get
    +dnl overwritten by an autogenerated header. Once we have no more
    +dnl `AC_CONFIG_HEADER` calls (issue #23966) we can delete all mention
    +dnl of `mk/unused.h`.
    +AC_CONFIG_HEADER(mk/unused.h)
     # This one is manually maintained.
     AC_CONFIG_HEADER(compiler/ghc-llvm-version.h)
     
    @@ -138,27 +141,6 @@ if test "$EnableDistroToolchain" = "YES"; then
       TarballsAutodownload=NO
     fi
     
    -AC_ARG_ENABLE(asserts-all-ways,
    -[AS_HELP_STRING([--enable-asserts-all-ways],
    -                [Usually ASSERTs are only compiled in the DEBUG way,
    -                 this will enable them in all ways.])],
    -  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    -  [EnableAssertsAllWays=NO]
    -)
    -if test "$enable_asserts_all_ways" = "yes" ; then
    -   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    -fi
    -
    -AC_ARG_ENABLE(native-io-manager,
    -[AS_HELP_STRING([--enable-native-io-manager],
    -                [Enable the native I/O manager by default.])],
    -  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    -  [EnableNativeIOManager=NO]
    -)
    -if test "$EnableNativeIOManager" = "YES"; then
    -  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    -fi
    -
     AC_ARG_ENABLE(ghc-toolchain,
     [AS_HELP_STRING([--enable-ghc-toolchain],
                     [Whether to use the newer ghc-toolchain tool to configure ghc targets])],
    @@ -319,9 +301,6 @@ dnl ** Do a build with tables next to code?
     dnl --------------------------------------------------------------
     
     GHC_TABLES_NEXT_TO_CODE
    -if test x"$TablesNextToCode" = xYES; then
    -   AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])
    -fi
     AC_SUBST(TablesNextToCode)
     
     # Requires FPTOOLS_SET_PLATFORMS_VARS to be run first.
    @@ -617,12 +596,15 @@ dnl    unregisterised, Sparc, and PPC backends. Also determines whether
     dnl    linking to libatomic is required for atomic operations, e.g. on
     dnl    RISCV64 GCC.
     FP_CC_SUPPORTS__ATOMICS
    +if test "$need_latomic" = 1; then
    +    AC_SUBST([NeedLibatomic],[YES])
    +else
    +    AC_SUBST([NeedLibatomic],[NO])
    +fi
     
     dnl ** look to see if we have a C compiler using an llvm back end.
     dnl
     FP_CC_LLVM_BACKEND
    -AS_IF([test x"$CcLlvmBackend" = x"YES"],
    -  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
     AC_SUBST(CcLlvmBackend)
     
     FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
    @@ -845,88 +827,14 @@ dnl --------------------------------------------------
     dnl ### program checking section ends here ###
     dnl --------------------------------------------------
     
    -dnl --------------------------------------------------
    -dnl * Platform header file and syscall feature tests
    -dnl ### checking the state of the local header files and syscalls ###
    -
    -dnl ** Enable large file support.  NB. do this before testing the type of
    -dnl    off_t, because it will affect the result of that test.
    -AC_SYS_LARGEFILE
    -
    -dnl ** check for specific header (.h) files that we are interested in
    -AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    -
    -dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    -AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    -[[#if HAVE_SYS_PARAM_H
    -# include 
    -#endif
    -]])
    -
    -dnl ** check whether a declaration for `environ` is provided by libc.
    -FP_CHECK_ENVIRON
    -
    -dnl ** do we have long longs?
    -AC_CHECK_TYPES([long long])
    -
    -dnl ** what are the sizes of various types
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    -if test "$ac_cv_type_long_long" = yes; then
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    -fi
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    -if test "$ac_cv_type_long_long" = yes; then
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    -fi
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    -
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    -
    -
     dnl for use in settings file
    +AC_CHECK_SIZEOF([void *])
     TargetWordSize=$ac_cv_sizeof_void_p
     AC_SUBST(TargetWordSize)
     
     AC_C_BIGENDIAN([TargetWordBigEndian=YES],[TargetWordBigEndian=NO])
     AC_SUBST(TargetWordBigEndian)
     
    -FP_CHECK_FUNC([WinExec],
    -  [@%:@include ], [WinExec("",0)])
    -
    -FP_CHECK_FUNC([GetModuleFileName],
    -  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    -
    -dnl ** check for more functions
    -dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    -AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    -
    -dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    -dnl ** _POSIX_C_SOURCE is defined
    -AC_CHECK_DECLS([ctime_r], , ,
    -[#define _POSIX_SOURCE 1
    -#define _POSIX_C_SOURCE 199506L
    -#include ])
    -
    -dnl On Linux we should have program_invocation_short_name
    -AC_CHECK_DECLS([program_invocation_short_name], , ,
    -[#define _GNU_SOURCE 1
    -#include ])
    -
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    
    
    =====================================
    distrib/cross-port
    =====================================
    @@ -28,7 +28,7 @@ if [ ! -f b1-stamp ]; then
     
        # For cross-compilation, at this stage you may want to set up a source
        # tree on the target machine, run the configure script there, and bring
    -   # the resulting mk/config.h file back into this tree before building
    +   # the resulting rts/ghcautoconf.h.autoconf file back into this tree before building
        # the libraries.
     
        touch mk/build.mk
    @@ -38,7 +38,7 @@ if [ ! -f b1-stamp ]; then
     
        # We could optimise slightly by not building hslibs here.  Also, building
        # the RTS is not necessary (and might not be desirable if we're using
    -   # a config.h from the target system).
    +   # a ghcautoconf.h from the target system).
        make stage1
     
       cd ..
    
    
    =====================================
    docs/coding-style.html
    =====================================
    @@ -108,7 +108,7 @@ POSIX-compliant to explicitly say so by having #include
     
     

  • Some architectures have memory alignment constraints. Others don't have any constraints but go faster if you align things. These -macros (from config.h) tell you which alignment to use +macros (from ghcautoconf.h) tell you which alignment to use
       /* minimum alignment of unsigned int */
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -155,10 +155,10 @@ generatePackageCode context@(Context stage pkg _ _) = do
         when (pkg == rts) $ do
             root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file ->
                 build $ target context GenApply [] [file]
    -        let go gen file = generate file (semiEmptyTarget stage) gen
             root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ ->
                 need . pure =<< pkgSetupConfigFile context
    -        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH
    +        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ ->
    +            need . pure =<< pkgSetupConfigFile context
             root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context
             root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines"
             root -/- "**" -/- dir -/- "include/rts/EventTypes.h" %> genEventTypes "--event-types-array"
    @@ -357,62 +357,6 @@ ghcWrapper stage  = do
                                          else [])
                                    ++ [ "$@" ]
     
    --- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that
    --- the resulting 'String' is a valid C preprocessor identifier.
    -cppify :: String -> String
    -cppify = replaceEq '-' '_' . replaceEq '.' '_'
    -
    --- | Generate @ghcplatform.h@ header.
    --- ROMES:TODO: For the runtime-retargetable GHC, these will eventually have to
    --- be determined at runtime, and no longer hardcoded to a file (passed as -D
    --- flags to the preprocessor, probably)
    -generateGhcPlatformH :: Expr String
    -generateGhcPlatformH = do
    -    trackGenerateHs
    -    stage    <- getStage
    -    let chooseSetting x y = case stage of { Stage0 {} -> x; _ -> y }
    -    buildPlatform  <- chooseSetting (queryBuild targetPlatformTriple) (queryHost targetPlatformTriple)
    -    buildArch      <- chooseSetting (queryBuild queryArch)   (queryHost queryArch)
    -    buildOs        <- chooseSetting (queryBuild queryOS)     (queryHost queryOS)
    -    buildVendor    <- chooseSetting (queryBuild queryVendor) (queryHost queryVendor)
    -    hostPlatform   <- chooseSetting (queryHost targetPlatformTriple) (queryTarget targetPlatformTriple)
    -    hostArch       <- chooseSetting (queryHost queryArch)    (queryTarget queryArch)
    -    hostOs         <- chooseSetting (queryHost queryOS)      (queryTarget queryOS)
    -    hostVendor     <- chooseSetting (queryHost queryVendor)  (queryTarget queryVendor)
    -    ghcUnreg       <- queryTarget tgtUnregisterised
    -    return . unlines $
    -        [ "#if !defined(__GHCPLATFORM_H__)"
    -        , "#define __GHCPLATFORM_H__"
    -        , ""
    -        , "#define BuildPlatform_TYPE  " ++ cppify buildPlatform
    -        , "#define HostPlatform_TYPE   " ++ cppify hostPlatform
    -        , ""
    -        , "#define " ++ cppify buildPlatform   ++ "_BUILD 1"
    -        , "#define " ++ cppify hostPlatform ++ "_HOST 1"
    -        , ""
    -        , "#define " ++ buildArch   ++ "_BUILD_ARCH 1"
    -        , "#define " ++ hostArch ++ "_HOST_ARCH 1"
    -        , "#define BUILD_ARCH " ++ show buildArch
    -        , "#define HOST_ARCH "  ++ show hostArch
    -        , ""
    -        , "#define " ++ buildOs   ++ "_BUILD_OS 1"
    -        , "#define " ++ hostOs ++ "_HOST_OS 1"
    -        , "#define BUILD_OS " ++ show buildOs
    -        , "#define HOST_OS "  ++ show hostOs
    -        , ""
    -        , "#define " ++ buildVendor   ++ "_BUILD_VENDOR 1"
    -        , "#define " ++ hostVendor ++ "_HOST_VENDOR 1"
    -        , "#define BUILD_VENDOR " ++ show buildVendor
    -        , "#define HOST_VENDOR "  ++ show hostVendor
    -        , ""
    -        ]
    -        ++
    -        [ "#define UnregisterisedCompiler 1" | ghcUnreg ]
    -        ++
    -        [ ""
    -        , "#endif /* __GHCPLATFORM_H__ */"
    -        ]
    -
     generateSettings :: Expr String
     generateSettings = do
         ctx <- getContext
    
    
    =====================================
    hadrian/src/Rules/Lint.hs
    =====================================
    @@ -22,6 +22,8 @@ lintRules = do
           cmd_ (Cwd "libraries/base") "./configure"
       "rts" -/- "include" -/- "ghcautoconf.h" %> \_ ->
           cmd_ (Cwd "rts") "./configure"
    +  "rts" -/- "include" -/- "ghcplatform.h" %> \_ ->
    +      cmd_ (Cwd "rts") "./configure"
     
     lint :: Action () -> Action ()
     lint lintAction = do
    @@ -68,7 +70,6 @@ base = do
       let includeDirs =
             [ "rts/include"
             , "libraries/base/include"
    -        , stage1RtsInc
             ]
       runHLint includeDirs [] "libraries/base"
     
    
    
    =====================================
    hadrian/src/Rules/Register.hs
    =====================================
    @@ -51,12 +51,6 @@ configurePackageRules = do
               isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend
               when isGmp $
                 need [buildP -/- "include/ghc-gmp.h"]
    -        when (pkg == rts) $ do
    -          -- Rts.h is a header listed in the cabal file, and configuring
    -          -- therefore wants to ensure that the header "works" post-configure.
    -          -- But it (transitively) includes this, so we must ensure it exists
    -          -- for that check to work.
    -          need [buildP -/- "include/ghcplatform.h"]
             Cabal.configurePackage ctx
     
         root -/- "**/autogen/cabal_macros.h" %> \out -> do
    
    
    =====================================
    hadrian/src/Rules/SourceDist.hs
    =====================================
    @@ -156,7 +156,8 @@ prepareTree dest = do
           , pkgPath terminfo -/- "configure"
           , "configure"
           , "aclocal.m4"
    -      , "mk" -/- "config.h.in" ]
    +      , "mk" -/- "unused.h.in"
    +      ]
     
         copyAlexHappyFiles =
           forM_ alexHappyFiles $ \(stg, pkg, inp, out) -> do
    
    
    =====================================
    hadrian/src/Settings/Packages.hs
    =====================================
    @@ -281,8 +281,8 @@ rtsPackageArgs = package rts ? do
         targetArch     <- queryTarget queryArch
         targetOs       <- queryTarget queryOS
         targetVendor   <- queryTarget queryVendor
    -    ghcUnreg       <- yesNo <$> queryTarget tgtUnregisterised
    -    ghcEnableTNC   <- yesNo <$> queryTarget tgtTablesNextToCode
    +    ghcUnreg       <- queryTarget tgtUnregisterised
    +    ghcEnableTNC   <- queryTarget tgtTablesNextToCode
         rtsWays        <- getRtsWays
         way            <- getWay
         path           <- getBuildPath
    @@ -355,8 +355,8 @@ rtsPackageArgs = package rts ? do
                 , "-DTargetArch="                ++ show targetArch
                 , "-DTargetOS="                  ++ show targetOs
                 , "-DTargetVendor="              ++ show targetVendor
    -            , "-DGhcUnregisterised="         ++ show ghcUnreg
    -            , "-DTablesNextToCode="          ++ show ghcEnableTNC
    +            , "-DGhcUnregisterised="         ++ show (yesNo ghcUnreg)
    +            , "-DTablesNextToCode="          ++ show (yesNo ghcEnableTNC)
                 , "-DRtsWay=\"rts_" ++ show way ++ "\""
                 ]
     
    @@ -414,6 +414,8 @@ rtsPackageArgs = package rts ? do
               , flag UseLibzstd                 `cabalFlag` "libzstd"
               , flag StaticLibzstd              `cabalFlag` "static-libzstd"
               , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
    +          , ghcUnreg                        `cabalFlag` "unregisterised"
    +          , ghcEnableTNC                    `cabalFlag` "tables-next-to-code"
               , Debug `wayUnit` way             `cabalFlag` "find-ptr"
               ]
             , builder (Cabal Setup) ? mconcat
    
    
    =====================================
    m4/fp_cc_supports__atomics.m4
    =====================================
    @@ -61,12 +61,4 @@ AC_DEFUN([FP_CC_SUPPORTS__ATOMICS],
             AC_MSG_RESULT(no)
             AC_MSG_ERROR([C compiler needs to support __atomic primitives.])
         ])
    -    AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    -    if test "$need_latomic" = 1; then
    -        AC_SUBST([NeedLibatomic],[YES])
    -    else
    -        AC_SUBST([NeedLibatomic],[NO])
    -    fi
    -    AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    -        [Define to 1 if we need -latomic.])
     ])
    
    
    =====================================
    m4/fptools_set_haskell_platform_vars.m4
    =====================================
    @@ -82,7 +82,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS],
             solaris2)
                 test -z "[$]2" || eval "[$]2=OSSolaris2"
                 ;;
    -        mingw32|windows)
    +        mingw32|mingw64|windows)
                 test -z "[$]2" || eval "[$]2=OSMinGW32"
                 ;;
             freebsd)
    @@ -162,8 +162,6 @@ AC_DEFUN([GHC_SUBSECTIONS_VIA_SYMBOLS],
                 TargetHasSubsectionsViaSymbols=NO
              else
                 TargetHasSubsectionsViaSymbols=YES
    -            AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    -                   [Define to 1 if Apple-style dead-stripping is supported.])
              fi
             ],
             [TargetHasSubsectionsViaSymbols=NO
    
    
    =====================================
    m4/ghc_convert_os.m4
    =====================================
    @@ -22,7 +22,7 @@ AC_DEFUN([GHC_CONVERT_OS],[
           openbsd*)
             $3="openbsd"
             ;;
    -      windows|mingw32)
    +      windows|mingw32|mingw64)
             $3="mingw32"
             ;;
           # As far as I'm aware, none of these have relevant variants
    
    
    =====================================
    rts/configure.ac
    =====================================
    @@ -22,17 +22,153 @@ dnl     #define SIZEOF_CHAR 0
     dnl   recently.
     AC_PREREQ([2.69])
     
    +AC_CONFIG_FILES([ghcplatform.h.top])
    +
     AC_CONFIG_HEADERS([ghcautoconf.h.autoconf])
     
    +AC_ARG_ENABLE(asserts-all-ways,
    +[AS_HELP_STRING([--enable-asserts-all-ways],
    +                [Usually ASSERTs are only compiled in the DEBUG way,
    +                 this will enable them in all ways.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    +  [EnableAssertsAllWays=NO]
    +)
    +if test "$enable_asserts_all_ways" = "yes" ; then
    +   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    +fi
    +
    +AC_ARG_ENABLE(native-io-manager,
    +[AS_HELP_STRING([--enable-native-io-manager],
    +                [Enable the native I/O manager by default.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    +  [EnableNativeIOManager=NO]
    +)
    +if test "$EnableNativeIOManager" = "YES"; then
    +  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    +fi
    +
     # We have to run these unconditionally, but we may discard their
     # results in the following code
     AC_CANONICAL_BUILD
     AC_CANONICAL_HOST
     
    +dnl ** Do a build with tables next to code?
    +dnl --------------------------------------------------------------
    +
    +AS_IF(
    +  [test "$CABAL_FLAG_tables_next_to_code" = 1],
    +  [AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])])
    +
    +dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set),
    +dnl later CC is copied to CC_STAGE{1,2,3}
    +AC_PROG_CC([cc gcc clang])
    +
    +dnl make extensions visible to allow feature-tests to detect them lateron
    +AC_USE_SYSTEM_EXTENSIONS
    +
    +dnl ** Used to determine how to compile ghc-prim's atomics.c, used by
    +dnl    unregisterised, Sparc, and PPC backends. Also determines whether
    +dnl    linking to libatomic is required for atomic operations, e.g. on
    +dnl    RISCV64 GCC.
    +FP_CC_SUPPORTS__ATOMICS
    +AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    +AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    +    [Define to 1 if we need -latomic for sub-word atomic operations.])
    +
    +dnl ** look to see if we have a C compiler using an llvm back end.
    +dnl
    +FP_CC_LLVM_BACKEND
    +AS_IF([test x"$CcLlvmBackend" = x"YES"],
    +  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
    +
    +GHC_CONVERT_PLATFORM_PARTS([build], [Build])
    +FPTOOLS_SET_PLATFORM_VARS([build],[Build])
    +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Build])
    +
     GHC_CONVERT_PLATFORM_PARTS([host], [Host])
     FPTOOLS_SET_PLATFORM_VARS([host], [Host])
     FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
     
    +GHC_SUBSECTIONS_VIA_SYMBOLS
    +AS_IF([test x"${TargetHasSubsectionsViaSymbols}" = x"YES"],
    +  [AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    +    [Define to 1 if Apple-style dead-stripping is supported.])])
    +
    +dnl --------------------------------------------------
    +dnl * Platform header file and syscall feature tests
    +dnl ### checking the state of the local header files and syscalls ###
    +
    +dnl ** Enable large file support.  NB. do this before testing the type of
    +dnl    off_t, because it will affect the result of that test.
    +AC_SYS_LARGEFILE
    +
    +dnl ** check for specific header (.h) files that we are interested in
    +AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    +
    +dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    +AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    +[[#if HAVE_SYS_PARAM_H
    +# include 
    +#endif
    +]])
    +
    +dnl ** check whether a declaration for `environ` is provided by libc.
    +FP_CHECK_ENVIRON
    +
    +dnl ** do we have long longs?
    +AC_CHECK_TYPES([long long])
    +
    +dnl ** what are the sizes of various types
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    +
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    +
    +
    +FP_CHECK_FUNC([WinExec],
    +  [@%:@include ], [WinExec("",0)])
    +
    +FP_CHECK_FUNC([GetModuleFileName],
    +  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    +
    +dnl ** check for more functions
    +dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    +AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    +
    +dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    +dnl ** _POSIX_C_SOURCE is defined
    +AC_CHECK_DECLS([ctime_r], , ,
    +[#define _POSIX_SOURCE 1
    +#define _POSIX_C_SOURCE 199506L
    +#include ])
    +
    +dnl On Linux we should have program_invocation_short_name
    +AC_CHECK_DECLS([program_invocation_short_name], , ,
    +[#define _GNU_SOURCE 1
    +#include ])
    +
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    @@ -140,7 +276,6 @@ AC_ARG_ENABLE(large-address-space,
     )
     
     use_large_address_space=no
    -AC_CHECK_SIZEOF([void *])
     if test "$ac_cv_sizeof_void_p" -eq 8 ; then
         if test "x$EnableLargeAddressSpace" = "xyes" ; then
             if test "$ghc_host_os" = "darwin" ; then
    @@ -223,19 +358,41 @@ dnl --------------------------------------------------------------
     AC_OUTPUT
     
     dnl ######################################################################
    -dnl Generate ghcautoconf.h
    +dnl Generate ghcplatform.h
     dnl ######################################################################
     
     [
     mkdir -p include
    +
    +touch include/ghcplatform.h
    +> include/ghcplatform.h
    +
    +cat ghcplatform.h.top                          >> include/ghcplatform.h
    +]
    +
    +dnl ** Do an unregisterised build?
    +dnl --------------------------------------------------------------
    +AS_IF(
    +  [test "$CABAL_FLAG_unregisterised" = 1],
    +  [echo "#define UnregisterisedCompiler 1"     >> include/ghcplatform.h])
    +
    +[
    +cat $srcdir/ghcplatform.h.bottom               >> include/ghcplatform.h
    +]
    +
    +dnl ######################################################################
    +dnl Generate ghcautoconf.h
    +dnl ######################################################################
    +
    +[
     touch include/ghcautoconf.h
     > include/ghcautoconf.h
     
     echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h
     echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h
    -# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO
    +# Copy the contents of ghcautoconf.h.autoconf, turning '#define PACKAGE_FOO
     # "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
    -cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \
    +cat ghcautoconf.h.autoconf | sed \
        -e 's,^\([	 ]*\)#[	 ]*define[	 ][	 ]*\(PACKAGE_[A-Z]*\)[	 ][ 	]*".*".*$,\1/* #undef \2 */,' \
        -e '/__GLASGOW_HASKELL/d' \
        -e '/REMOVE ME/d' \
    
    
    =====================================
    rts/ghcplatform.h.bottom
    =====================================
    @@ -0,0 +1,2 @@
    +
    +#endif /* __GHCPLATFORM_H__ */
    
    
    =====================================
    rts/ghcplatform.h.top.in
    =====================================
    @@ -0,0 +1,23 @@
    +#if !defined(__GHCPLATFORM_H__)
    +#define __GHCPLATFORM_H__
    +
    +#define BuildPlatform_TYPE  @BuildPlatform_CPP@
    +#define HostPlatform_TYPE   @HostPlatform_CPP@
    +
    +#define @BuildPlatform_CPP at _BUILD  1
    +#define @HostPlatform_CPP at _HOST  1
    +
    +#define @BuildArch_CPP at _BUILD_ARCH  1
    +#define @HostArch_CPP at _HOST_ARCH  1
    +#define BUILD_ARCH  "@BuildArch_CPP@"
    +#define HOST_ARCH  "@HostArch_CPP@"
    +
    +#define @BuildOS_CPP at _BUILD_OS  1
    +#define @HostOS_CPP at _HOST_OS  1
    +#define BUILD_OS  "@BuildOS_CPP@"
    +#define HOST_OS  "@HostOS_CPP@"
    +
    +#define @BuildVendor_CPP at _BUILD_VENDOR  1
    +#define @HostVendor_CPP at _HOST_VENDOR  1
    +#define BUILD_VENDOR  "@BuildVendor_CPP@"
    +#define HOST_VENDOR  "@HostVendor_CPP@"
    
    
    =====================================
    rts/rts.cabal
    =====================================
    @@ -54,6 +54,10 @@ flag static-libzstd
       default: False
     flag leading-underscore
       default: False
    +flag unregisterised
    +  default: False
    +flag tables-next-to-code
    +  default: False
     flag smp
       default: True
     flag find-ptr
    @@ -240,7 +244,7 @@ library
     
           include-dirs: include
           includes: Rts.h
    -      autogen-includes: ghcautoconf.h
    +      autogen-includes: ghcautoconf.h ghcplatform.h
           install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
                             ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
                             -- ^ from include
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fded7dd4300df8e1657b710f4deed16aa1d35ebe...7dfcab2f4bcb7206174ea48857df1883d05e97a2
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fded7dd4300df8e1657b710f4deed16aa1d35ebe...7dfcab2f4bcb7206174ea48857df1883d05e97a2
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 06:50:03 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Sun, 22 Oct 2023 02:50:03 -0400
    Subject: [Git][ghc/ghc][master] rts: drop stale mentions of MIN_UPD_SIZE
    Message-ID: <6534c61bbb0b6_ab41e1e978f4c11699b@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    
    
    2 changed files:
    
    - docs/rts/rts.tex
    - rts/PrimOps.cmm
    
    
    Changes:
    
    =====================================
    docs/rts/rts.tex
    =====================================
    @@ -1970,10 +1970,9 @@ Here the right-hand sides of @range@ and @ys@ are both thunks; the former
     is static while the latter is dynamic.
     
     The layout of a thunk is the same as that for a function closure.
    -However, thunks must have a payload of at least @MIN_UPD_SIZE@
    -words to allow it to be overwritten with a black hole and an
    -indirection.  The compiler may have to add extra non-pointer fields to
    -satisfy this constraint.
    +However, a thunk header always contains an extra padding word at the
    +end. This allows the thunk to be overwritten with an indirection,
    +where the padding word will be repurposed as the indirectee pointer.
     
     \begin{center}
     \begin{tabular}{|l|l|l|l|l|}\hline
    
    
    =====================================
    rts/PrimOps.cmm
    =====================================
    @@ -740,25 +740,15 @@ stg_atomicModifyMutVar2zh ( gcptr mv, gcptr f )
     
             obviously we can share (f x).
     
    -         z = [stg_ap_2 f x]  (max (HS + 2) MIN_UPD_SIZE)
    -         y = [stg_sel_0 z]   (max (HS + 1) MIN_UPD_SIZE)
    +         z = [stg_ap_2 f x]  (SIZEOF_StgThunkHeader + WDS(2))
    +         y = [stg_sel_0 z]   (SIZEOF_StgThunkHeader + WDS(1))
         */
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 1
    -#define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),WDS(MIN_UPD_SIZE-1))
    -#else
     #define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(1))
     #define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),0)
    -#endif
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2
    -#define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
    -#else
     #define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(2))
     #define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),0)
    -#endif
     
     #define SIZE (THUNK_2_SIZE + THUNK_1_SIZE)
     
    @@ -815,13 +805,8 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f )
              z = [stg_ap_2 f x]  (max (HS + 2) MIN_UPD_SIZE)
         */
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2
    -#define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
    -#else
     #define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(2))
     #define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),0)
    -#endif
     
         HP_CHK_GEN_TICKY(THUNK_SIZE);
     
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1e3719cc59f20d32c917e066ae7cd5edb98a96d
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1e3719cc59f20d32c917e066ae7cd5edb98a96d
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 06:50:56 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Sun, 22 Oct 2023 02:50:56 -0400
    Subject: [Git][ghc/ghc][master] base changelog: move non-backported entries
     from 4.19 section to 4.20
    Message-ID: <6534c650a9f92_ab41e1e9720481202f@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    
    
    1 changed file:
    
    - libraries/base/changelog.md
    
    
    Changes:
    
    =====================================
    libraries/base/changelog.md
    =====================================
    @@ -9,14 +9,16 @@
       * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`.
         ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166))
       * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)).
    +  * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86))
    +  * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192))
     
    -## 4.19.0.0 *TBA*
    +## 4.19.0.0 *October 2023*
       * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`.
         Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it.
         ([CLC proposal #87](https://github.com/haskell/core-libraries-committee/issues/87) and [#114](https://github.com/haskell/core-libraries-committee/issues/114))
    -  * `GHC.Conc.Sync` now exports `fromThreadId :: ThreadId -> Word64`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
    +  * Add `fromThreadId :: ThreadId -> Word64` to `GHC.Conc.Sync`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
       * Add `Data.List.!?` ([CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110))
    -  * `maximumBy`/`minimumBy` are now marked as `INLINE` improving performance for unpackable
    +  * Mark `maximumBy`/`minimumBy` as `INLINE` improving performance for unpackable
         types significantly.
       * Add INLINABLE pragmas to `generic*` functions in Data.OldList ([CLC proposal #129](https://github.com/haskell/core-libraries-committee/issues/130))
       * Export `getSolo` from `Data.Tuple`.
    @@ -34,20 +36,18 @@
       * Add `COMPLETE` pragmas to the `TypeRep`, `SSymbol`, `SChar`, and `SNat` pattern synonyms.
           ([CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149))
       * Make `($)` representation polymorphic ([CLC proposal #132](https://github.com/haskell/core-libraries-committee/issues/132))
    -  * Implemented [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst),
    +  * Implement [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst),
         adding the class `Unsatisfiable :: ErrorMessage -> TypeError` to `GHC.TypeError`,
         which provides a mechanism for custom type errors that reports the errors in
         a more predictable behaviour than `TypeError`.
       * Add more instances for `Compose`: `Enum`, `Bounded`, `Num`, `Real`, `Integral` ([CLC proposal #160](https://github.com/haskell/core-libraries-committee/issues/160))
       * Make `(&)` representation polymorphic in the return type ([CLC proposal #158](https://github.com/haskell/core-libraries-committee/issues/158))
       * Implement `GHC.IORef.atomicSwapIORef` via a new dedicated primop `atomicSwapMutVar#` ([CLC proposal #139](https://github.com/haskell/core-libraries-committee/issues/139))
    -  * Change codebuffers to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134))
    -  * Add nominal role annotations to SNat/SSymbol/SChar ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170))
    +  * Change `BufferCodec` to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134))
    +  * Add nominal role annotations to `SNat` / `SSymbol` / `SChar` ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170))
       * Make `Semigroup`'s `stimes` specializable. ([CLC proposal #8](https://github.com/haskell/core-libraries-committee/issues/8))
    -  * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86))
    -  * Fixed exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192))
       * Implement `copyBytes`, `fillBytes`, `moveBytes` and `stimes` for `Data.Array.Byte.ByteArray` using primops ([CLC proposal #188](https://github.com/haskell/core-libraries-committee/issues/188))
    -  * Add rewrite rules for conversion between Int64/Word64 and Float/Double on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)).
    +  * Add rewrite rules for conversion between `Int64` / `Word64` and `Float` / `Double` on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)).
     
     ## 4.18.0.0 *March 2023*
       * Shipped with GHC 9.6.1
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d24b0d854c7a8f48a75e8b6b32595975220f33af
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d24b0d854c7a8f48a75e8b6b32595975220f33af
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 14:21:55 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Sun, 22 Oct 2023 10:21:55 -0400
    Subject: [Git][ghc/ghc][wip/hadrian-ghc-llvm-version] 10 commits: Move
     function checks to RTS configure
    Message-ID: <65353003476d_1f7b0d2eac4d01020fc@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/hadrian-ghc-llvm-version at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    d0d6af9b by John Ericson at 2023-10-22T10:20:16-04:00
    Generate `compiler/ghc-llvm-version.h.in` via Hadrian
    
    Per #23966, I want the top-level configure to only generate
    configuration data for Hadrian, not do any "real" tasks on its own.
    This is part of that effort --- one less file generated by it.
    
    (It is still done with a `.in` file, so in a future world non-Hadrian
    also can easily create this file.)
    
    This also means we can get rid of the silly `unused.h` introduced in
    !6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge.
    
    Part of #23966
    
    - - - - -
    
    
    21 changed files:
    
    - .gitignore
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/ghc-llvm-version.h.in
    - configure.ac
    - distrib/cross-port
    - docs/coding-style.html
    - docs/rts/rts.tex
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Rules/Lint.hs
    - hadrian/src/Rules/Register.hs
    - hadrian/src/Rules/SourceDist.hs
    - hadrian/src/Settings/Packages.hs
    - libraries/base/changelog.md
    - m4/fp_cc_supports__atomics.m4
    - m4/fptools_set_haskell_platform_vars.m4
    - m4/ghc_convert_os.m4
    - rts/PrimOps.cmm
    - rts/configure.ac
    - + rts/ghcplatform.h.bottom
    - + rts/ghcplatform.h.top.in
    - rts/rts.cabal
    
    
    Changes:
    
    =====================================
    .gitignore
    =====================================
    @@ -184,8 +184,6 @@ _darcs/
     /linter.log
     /mk/are-validating.mk
     /mk/build.mk
    -/mk/config.h
    -/mk/config.h.in
     /mk/config.mk
     /mk/config.mk.old
     /mk/system-cxx-std-lib-1.0.conf
    
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -229,7 +229,7 @@ section "The word size story."
              must contain at least 30 bits. GHC always implements
              'Int' using the primitive type 'Int#', whose size equals
              the @MachDeps.h@ constant @WORD\_SIZE\_IN\_BITS at .
    -         This is normally set based on the @config.h@ parameter
    +         This is normally set based on the RTS @ghcautoconf.h@ parameter
              @SIZEOF\_HSWORD@, i.e., 32 bits on 32-bit machines, 64
              bits on 64-bit machines.
     
    
    
    =====================================
    compiler/ghc-llvm-version.h.in
    =====================================
    @@ -2,9 +2,9 @@
     #define __GHC_LLVM_VERSION_H__
     
     /* The maximum supported LLVM version number */
    -#undef sUPPORTED_LLVM_VERSION_MAX
    +#define sUPPORTED_LLVM_VERSION_MAX (@LlvmMinVersion@)
     
     /* The minimum supported LLVM version number */
    -#undef sUPPORTED_LLVM_VERSION_MIN
    +#define sUPPORTED_LLVM_VERSION_MIN (@LlvmMaxVersion@)
     
     #endif /* __GHC_LLVM_VERSION_H__ */
    
    
    =====================================
    configure.ac
    =====================================
    @@ -32,8 +32,8 @@ AC_CONFIG_MACRO_DIRS([m4])
     # checkout), then we ship a file 'VERSION' containing the full version
     # when the source distribution was created.
     
    -if test ! -f mk/config.h.in; then
    -   echo "mk/config.h.in doesn't exist: perhaps you haven't run 'python3 boot'?"
    +if test ! -f rts/ghcautoconf.h.autoconf.in; then
    +   echo "rts/ghcautoconf.h.autoconf.in doesn't exist: perhaps you haven't run 'python3 boot'?"
        exit 1
     fi
     
    @@ -80,15 +80,6 @@ dnl     #define SIZEOF_CHAR 0
     dnl   recently.
     AC_PREREQ([2.69])
     
    -# -------------------------------------------------------------------------
    -# Prepare to generate the following header files
    -#
    -
    -# This one is autogenerated by autoheader.
    -AC_CONFIG_HEADER(mk/config.h)
    -# This one is manually maintained.
    -AC_CONFIG_HEADER(compiler/ghc-llvm-version.h)
    -
     # No, semi-sadly, we don't do `--srcdir'...
     if test x"$srcdir" != 'x.' ; then
         echo "This configuration does not support the \`--srcdir' option.."
    @@ -138,27 +129,6 @@ if test "$EnableDistroToolchain" = "YES"; then
       TarballsAutodownload=NO
     fi
     
    -AC_ARG_ENABLE(asserts-all-ways,
    -[AS_HELP_STRING([--enable-asserts-all-ways],
    -                [Usually ASSERTs are only compiled in the DEBUG way,
    -                 this will enable them in all ways.])],
    -  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    -  [EnableAssertsAllWays=NO]
    -)
    -if test "$enable_asserts_all_ways" = "yes" ; then
    -   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    -fi
    -
    -AC_ARG_ENABLE(native-io-manager,
    -[AS_HELP_STRING([--enable-native-io-manager],
    -                [Enable the native I/O manager by default.])],
    -  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    -  [EnableNativeIOManager=NO]
    -)
    -if test "$EnableNativeIOManager" = "YES"; then
    -  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    -fi
    -
     AC_ARG_ENABLE(ghc-toolchain,
     [AS_HELP_STRING([--enable-ghc-toolchain],
                     [Whether to use the newer ghc-toolchain tool to configure ghc targets])],
    @@ -319,9 +289,6 @@ dnl ** Do a build with tables next to code?
     dnl --------------------------------------------------------------
     
     GHC_TABLES_NEXT_TO_CODE
    -if test x"$TablesNextToCode" = xYES; then
    -   AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])
    -fi
     AC_SUBST(TablesNextToCode)
     
     # Requires FPTOOLS_SET_PLATFORMS_VARS to be run first.
    @@ -527,10 +494,6 @@ LlvmMinVersion=13  # inclusive
     LlvmMaxVersion=16 # not inclusive
     AC_SUBST([LlvmMinVersion])
     AC_SUBST([LlvmMaxVersion])
    -sUPPORTED_LLVM_VERSION_MIN=$(echo \($LlvmMinVersion\) | sed 's/\./,/')
    -sUPPORTED_LLVM_VERSION_MAX=$(echo \($LlvmMaxVersion\) | sed 's/\./,/')
    -AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION_MIN], ${sUPPORTED_LLVM_VERSION_MIN}, [The minimum supported LLVM version number])
    -AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION_MAX], ${sUPPORTED_LLVM_VERSION_MAX}, [The maximum supported LLVM version number])
     
     ConfiguredEmsdkVersion="${EmsdkVersion}"
     AC_SUBST([ConfiguredEmsdkVersion])
    @@ -617,12 +580,15 @@ dnl    unregisterised, Sparc, and PPC backends. Also determines whether
     dnl    linking to libatomic is required for atomic operations, e.g. on
     dnl    RISCV64 GCC.
     FP_CC_SUPPORTS__ATOMICS
    +if test "$need_latomic" = 1; then
    +    AC_SUBST([NeedLibatomic],[YES])
    +else
    +    AC_SUBST([NeedLibatomic],[NO])
    +fi
     
     dnl ** look to see if we have a C compiler using an llvm back end.
     dnl
     FP_CC_LLVM_BACKEND
    -AS_IF([test x"$CcLlvmBackend" = x"YES"],
    -  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
     AC_SUBST(CcLlvmBackend)
     
     FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
    @@ -845,88 +811,14 @@ dnl --------------------------------------------------
     dnl ### program checking section ends here ###
     dnl --------------------------------------------------
     
    -dnl --------------------------------------------------
    -dnl * Platform header file and syscall feature tests
    -dnl ### checking the state of the local header files and syscalls ###
    -
    -dnl ** Enable large file support.  NB. do this before testing the type of
    -dnl    off_t, because it will affect the result of that test.
    -AC_SYS_LARGEFILE
    -
    -dnl ** check for specific header (.h) files that we are interested in
    -AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    -
    -dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    -AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    -[[#if HAVE_SYS_PARAM_H
    -# include 
    -#endif
    -]])
    -
    -dnl ** check whether a declaration for `environ` is provided by libc.
    -FP_CHECK_ENVIRON
    -
    -dnl ** do we have long longs?
    -AC_CHECK_TYPES([long long])
    -
    -dnl ** what are the sizes of various types
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    -if test "$ac_cv_type_long_long" = yes; then
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    -fi
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    -if test "$ac_cv_type_long_long" = yes; then
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    -fi
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    -
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    -
    -
     dnl for use in settings file
    +AC_CHECK_SIZEOF([void *])
     TargetWordSize=$ac_cv_sizeof_void_p
     AC_SUBST(TargetWordSize)
     
     AC_C_BIGENDIAN([TargetWordBigEndian=YES],[TargetWordBigEndian=NO])
     AC_SUBST(TargetWordBigEndian)
     
    -FP_CHECK_FUNC([WinExec],
    -  [@%:@include ], [WinExec("",0)])
    -
    -FP_CHECK_FUNC([GetModuleFileName],
    -  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    -
    -dnl ** check for more functions
    -dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    -AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    -
    -dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    -dnl ** _POSIX_C_SOURCE is defined
    -AC_CHECK_DECLS([ctime_r], , ,
    -[#define _POSIX_SOURCE 1
    -#define _POSIX_C_SOURCE 199506L
    -#include ])
    -
    -dnl On Linux we should have program_invocation_short_name
    -AC_CHECK_DECLS([program_invocation_short_name], , ,
    -[#define _GNU_SOURCE 1
    -#include ])
    -
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    
    
    =====================================
    distrib/cross-port
    =====================================
    @@ -28,7 +28,7 @@ if [ ! -f b1-stamp ]; then
     
        # For cross-compilation, at this stage you may want to set up a source
        # tree on the target machine, run the configure script there, and bring
    -   # the resulting mk/config.h file back into this tree before building
    +   # the resulting rts/ghcautoconf.h.autoconf file back into this tree before building
        # the libraries.
     
        touch mk/build.mk
    @@ -38,7 +38,7 @@ if [ ! -f b1-stamp ]; then
     
        # We could optimise slightly by not building hslibs here.  Also, building
        # the RTS is not necessary (and might not be desirable if we're using
    -   # a config.h from the target system).
    +   # a ghcautoconf.h from the target system).
        make stage1
     
       cd ..
    
    
    =====================================
    docs/coding-style.html
    =====================================
    @@ -108,7 +108,7 @@ POSIX-compliant to explicitly say so by having #include
     
     

  • Some architectures have memory alignment constraints. Others don't have any constraints but go faster if you align things. These -macros (from config.h) tell you which alignment to use +macros (from ghcautoconf.h) tell you which alignment to use
       /* minimum alignment of unsigned int */
    
    
    =====================================
    docs/rts/rts.tex
    =====================================
    @@ -1970,10 +1970,9 @@ Here the right-hand sides of @range@ and @ys@ are both thunks; the former
     is static while the latter is dynamic.
     
     The layout of a thunk is the same as that for a function closure.
    -However, thunks must have a payload of at least @MIN_UPD_SIZE@
    -words to allow it to be overwritten with a black hole and an
    -indirection.  The compiler may have to add extra non-pointer fields to
    -satisfy this constraint.
    +However, a thunk header always contains an extra padding word at the
    +end. This allows the thunk to be overwritten with an indirection,
    +where the padding word will be repurposed as the indirectee pointer.
     
     \begin{center}
     \begin{tabular}{|l|l|l|l|l|}\hline
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -80,7 +80,7 @@ compilerDependencies :: Expr [FilePath]
     compilerDependencies = do
         stage   <- getStage
         ghcPath <- expr $ buildPath (vanillaContext stage compiler)
    -    pure $ (ghcPath -/-) <$>
    +    let buildSpecific = (ghcPath -/-) <$>
                       [ "primop-code-size.hs-incl"
                       , "primop-commutable.hs-incl"
                       , "primop-data-decl.hs-incl"
    @@ -101,6 +101,10 @@ compilerDependencies = do
                       , "GHC/Platform/Constants.hs"
                       , "GHC/Settings/Config.hs"
                       ]
    +    let fixed = ("compiler" -/-) <$>
    +                  [ "ghc-llvm-version.h"
    +                  ]
    +    pure $ fixed ++ buildSpecific
     
     generatedDependencies :: Expr [FilePath]
     generatedDependencies = do
    @@ -155,10 +159,10 @@ generatePackageCode context@(Context stage pkg _ _) = do
         when (pkg == rts) $ do
             root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file ->
                 build $ target context GenApply [] [file]
    -        let go gen file = generate file (semiEmptyTarget stage) gen
             root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ ->
                 need . pure =<< pkgSetupConfigFile context
    -        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH
    +        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ ->
    +            need . pure =<< pkgSetupConfigFile context
             root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context
             root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines"
             root -/- "**" -/- dir -/- "include/rts/EventTypes.h" %> genEventTypes "--event-types-array"
    @@ -336,6 +340,10 @@ templateRules = do
         , interpolateSetting "LlvmMinVersion" LlvmMinVersion
         , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion
         ]
    +  templateRule "compiler/ghc-llvm-version.h" $ mconcat
    +    [ interpolateVar "LlvmMinVersion" $ replaceEq '.' ',' <$> setting LlvmMinVersion
    +    , interpolateVar "LlvmMaxVersion" $ replaceEq '.' ',' <$> setting LlvmMaxVersion
    +    ]
     
     
     -- Generators
    @@ -357,62 +365,6 @@ ghcWrapper stage  = do
                                          else [])
                                    ++ [ "$@" ]
     
    --- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that
    --- the resulting 'String' is a valid C preprocessor identifier.
    -cppify :: String -> String
    -cppify = replaceEq '-' '_' . replaceEq '.' '_'
    -
    --- | Generate @ghcplatform.h@ header.
    --- ROMES:TODO: For the runtime-retargetable GHC, these will eventually have to
    --- be determined at runtime, and no longer hardcoded to a file (passed as -D
    --- flags to the preprocessor, probably)
    -generateGhcPlatformH :: Expr String
    -generateGhcPlatformH = do
    -    trackGenerateHs
    -    stage    <- getStage
    -    let chooseSetting x y = case stage of { Stage0 {} -> x; _ -> y }
    -    buildPlatform  <- chooseSetting (queryBuild targetPlatformTriple) (queryHost targetPlatformTriple)
    -    buildArch      <- chooseSetting (queryBuild queryArch)   (queryHost queryArch)
    -    buildOs        <- chooseSetting (queryBuild queryOS)     (queryHost queryOS)
    -    buildVendor    <- chooseSetting (queryBuild queryVendor) (queryHost queryVendor)
    -    hostPlatform   <- chooseSetting (queryHost targetPlatformTriple) (queryTarget targetPlatformTriple)
    -    hostArch       <- chooseSetting (queryHost queryArch)    (queryTarget queryArch)
    -    hostOs         <- chooseSetting (queryHost queryOS)      (queryTarget queryOS)
    -    hostVendor     <- chooseSetting (queryHost queryVendor)  (queryTarget queryVendor)
    -    ghcUnreg       <- queryTarget tgtUnregisterised
    -    return . unlines $
    -        [ "#if !defined(__GHCPLATFORM_H__)"
    -        , "#define __GHCPLATFORM_H__"
    -        , ""
    -        , "#define BuildPlatform_TYPE  " ++ cppify buildPlatform
    -        , "#define HostPlatform_TYPE   " ++ cppify hostPlatform
    -        , ""
    -        , "#define " ++ cppify buildPlatform   ++ "_BUILD 1"
    -        , "#define " ++ cppify hostPlatform ++ "_HOST 1"
    -        , ""
    -        , "#define " ++ buildArch   ++ "_BUILD_ARCH 1"
    -        , "#define " ++ hostArch ++ "_HOST_ARCH 1"
    -        , "#define BUILD_ARCH " ++ show buildArch
    -        , "#define HOST_ARCH "  ++ show hostArch
    -        , ""
    -        , "#define " ++ buildOs   ++ "_BUILD_OS 1"
    -        , "#define " ++ hostOs ++ "_HOST_OS 1"
    -        , "#define BUILD_OS " ++ show buildOs
    -        , "#define HOST_OS "  ++ show hostOs
    -        , ""
    -        , "#define " ++ buildVendor   ++ "_BUILD_VENDOR 1"
    -        , "#define " ++ hostVendor ++ "_HOST_VENDOR 1"
    -        , "#define BUILD_VENDOR " ++ show buildVendor
    -        , "#define HOST_VENDOR "  ++ show hostVendor
    -        , ""
    -        ]
    -        ++
    -        [ "#define UnregisterisedCompiler 1" | ghcUnreg ]
    -        ++
    -        [ ""
    -        , "#endif /* __GHCPLATFORM_H__ */"
    -        ]
    -
     generateSettings :: Expr String
     generateSettings = do
         ctx <- getContext
    
    
    =====================================
    hadrian/src/Rules/Lint.hs
    =====================================
    @@ -22,6 +22,8 @@ lintRules = do
           cmd_ (Cwd "libraries/base") "./configure"
       "rts" -/- "include" -/- "ghcautoconf.h" %> \_ ->
           cmd_ (Cwd "rts") "./configure"
    +  "rts" -/- "include" -/- "ghcplatform.h" %> \_ ->
    +      cmd_ (Cwd "rts") "./configure"
     
     lint :: Action () -> Action ()
     lint lintAction = do
    @@ -68,7 +70,6 @@ base = do
       let includeDirs =
             [ "rts/include"
             , "libraries/base/include"
    -        , stage1RtsInc
             ]
       runHLint includeDirs [] "libraries/base"
     
    @@ -91,7 +92,8 @@ compiler = do
       let compilerDir    = "compiler"
       let ghcautoconf    = stage1RtsInc  "ghcautoconf.h"
       let ghcplatform    = stage1RtsInc  "ghcplatform.h"
    -  need $ mconcat [[ghcautoconf, ghcplatform], hsIncls stage1Compiler, [machDeps]]
    +  let ghcLlvmVersion = compilerDir  "ghc-llvm-version.h"
    +  need $ mconcat [[ghcautoconf, ghcplatform, ghcLlvmVersion], hsIncls stage1Compiler, [machDeps]]
       let includeDirs =
             [ stage1RtsInc
             , compilerDir
    
    
    =====================================
    hadrian/src/Rules/Register.hs
    =====================================
    @@ -51,12 +51,6 @@ configurePackageRules = do
               isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend
               when isGmp $
                 need [buildP -/- "include/ghc-gmp.h"]
    -        when (pkg == rts) $ do
    -          -- Rts.h is a header listed in the cabal file, and configuring
    -          -- therefore wants to ensure that the header "works" post-configure.
    -          -- But it (transitively) includes this, so we must ensure it exists
    -          -- for that check to work.
    -          need [buildP -/- "include/ghcplatform.h"]
             Cabal.configurePackage ctx
     
         root -/- "**/autogen/cabal_macros.h" %> \out -> do
    
    
    =====================================
    hadrian/src/Rules/SourceDist.hs
    =====================================
    @@ -156,7 +156,7 @@ prepareTree dest = do
           , pkgPath terminfo -/- "configure"
           , "configure"
           , "aclocal.m4"
    -      , "mk" -/- "config.h.in" ]
    +      ]
     
         copyAlexHappyFiles =
           forM_ alexHappyFiles $ \(stg, pkg, inp, out) -> do
    
    
    =====================================
    hadrian/src/Settings/Packages.hs
    =====================================
    @@ -281,8 +281,8 @@ rtsPackageArgs = package rts ? do
         targetArch     <- queryTarget queryArch
         targetOs       <- queryTarget queryOS
         targetVendor   <- queryTarget queryVendor
    -    ghcUnreg       <- yesNo <$> queryTarget tgtUnregisterised
    -    ghcEnableTNC   <- yesNo <$> queryTarget tgtTablesNextToCode
    +    ghcUnreg       <- queryTarget tgtUnregisterised
    +    ghcEnableTNC   <- queryTarget tgtTablesNextToCode
         rtsWays        <- getRtsWays
         way            <- getWay
         path           <- getBuildPath
    @@ -355,8 +355,8 @@ rtsPackageArgs = package rts ? do
                 , "-DTargetArch="                ++ show targetArch
                 , "-DTargetOS="                  ++ show targetOs
                 , "-DTargetVendor="              ++ show targetVendor
    -            , "-DGhcUnregisterised="         ++ show ghcUnreg
    -            , "-DTablesNextToCode="          ++ show ghcEnableTNC
    +            , "-DGhcUnregisterised="         ++ show (yesNo ghcUnreg)
    +            , "-DTablesNextToCode="          ++ show (yesNo ghcEnableTNC)
                 , "-DRtsWay=\"rts_" ++ show way ++ "\""
                 ]
     
    @@ -414,6 +414,8 @@ rtsPackageArgs = package rts ? do
               , flag UseLibzstd                 `cabalFlag` "libzstd"
               , flag StaticLibzstd              `cabalFlag` "static-libzstd"
               , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
    +          , ghcUnreg                        `cabalFlag` "unregisterised"
    +          , ghcEnableTNC                    `cabalFlag` "tables-next-to-code"
               , Debug `wayUnit` way             `cabalFlag` "find-ptr"
               ]
             , builder (Cabal Setup) ? mconcat
    
    
    =====================================
    libraries/base/changelog.md
    =====================================
    @@ -9,14 +9,16 @@
       * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`.
         ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166))
       * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)).
    +  * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86))
    +  * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192))
     
    -## 4.19.0.0 *TBA*
    +## 4.19.0.0 *October 2023*
       * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`.
         Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it.
         ([CLC proposal #87](https://github.com/haskell/core-libraries-committee/issues/87) and [#114](https://github.com/haskell/core-libraries-committee/issues/114))
    -  * `GHC.Conc.Sync` now exports `fromThreadId :: ThreadId -> Word64`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
    +  * Add `fromThreadId :: ThreadId -> Word64` to `GHC.Conc.Sync`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
       * Add `Data.List.!?` ([CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110))
    -  * `maximumBy`/`minimumBy` are now marked as `INLINE` improving performance for unpackable
    +  * Mark `maximumBy`/`minimumBy` as `INLINE` improving performance for unpackable
         types significantly.
       * Add INLINABLE pragmas to `generic*` functions in Data.OldList ([CLC proposal #129](https://github.com/haskell/core-libraries-committee/issues/130))
       * Export `getSolo` from `Data.Tuple`.
    @@ -34,20 +36,18 @@
       * Add `COMPLETE` pragmas to the `TypeRep`, `SSymbol`, `SChar`, and `SNat` pattern synonyms.
           ([CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149))
       * Make `($)` representation polymorphic ([CLC proposal #132](https://github.com/haskell/core-libraries-committee/issues/132))
    -  * Implemented [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst),
    +  * Implement [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst),
         adding the class `Unsatisfiable :: ErrorMessage -> TypeError` to `GHC.TypeError`,
         which provides a mechanism for custom type errors that reports the errors in
         a more predictable behaviour than `TypeError`.
       * Add more instances for `Compose`: `Enum`, `Bounded`, `Num`, `Real`, `Integral` ([CLC proposal #160](https://github.com/haskell/core-libraries-committee/issues/160))
       * Make `(&)` representation polymorphic in the return type ([CLC proposal #158](https://github.com/haskell/core-libraries-committee/issues/158))
       * Implement `GHC.IORef.atomicSwapIORef` via a new dedicated primop `atomicSwapMutVar#` ([CLC proposal #139](https://github.com/haskell/core-libraries-committee/issues/139))
    -  * Change codebuffers to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134))
    -  * Add nominal role annotations to SNat/SSymbol/SChar ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170))
    +  * Change `BufferCodec` to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134))
    +  * Add nominal role annotations to `SNat` / `SSymbol` / `SChar` ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170))
       * Make `Semigroup`'s `stimes` specializable. ([CLC proposal #8](https://github.com/haskell/core-libraries-committee/issues/8))
    -  * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86))
    -  * Fixed exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192))
       * Implement `copyBytes`, `fillBytes`, `moveBytes` and `stimes` for `Data.Array.Byte.ByteArray` using primops ([CLC proposal #188](https://github.com/haskell/core-libraries-committee/issues/188))
    -  * Add rewrite rules for conversion between Int64/Word64 and Float/Double on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)).
    +  * Add rewrite rules for conversion between `Int64` / `Word64` and `Float` / `Double` on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)).
     
     ## 4.18.0.0 *March 2023*
       * Shipped with GHC 9.6.1
    
    
    =====================================
    m4/fp_cc_supports__atomics.m4
    =====================================
    @@ -61,12 +61,4 @@ AC_DEFUN([FP_CC_SUPPORTS__ATOMICS],
             AC_MSG_RESULT(no)
             AC_MSG_ERROR([C compiler needs to support __atomic primitives.])
         ])
    -    AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    -    if test "$need_latomic" = 1; then
    -        AC_SUBST([NeedLibatomic],[YES])
    -    else
    -        AC_SUBST([NeedLibatomic],[NO])
    -    fi
    -    AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    -        [Define to 1 if we need -latomic.])
     ])
    
    
    =====================================
    m4/fptools_set_haskell_platform_vars.m4
    =====================================
    @@ -82,7 +82,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS],
             solaris2)
                 test -z "[$]2" || eval "[$]2=OSSolaris2"
                 ;;
    -        mingw32|windows)
    +        mingw32|mingw64|windows)
                 test -z "[$]2" || eval "[$]2=OSMinGW32"
                 ;;
             freebsd)
    @@ -162,8 +162,6 @@ AC_DEFUN([GHC_SUBSECTIONS_VIA_SYMBOLS],
                 TargetHasSubsectionsViaSymbols=NO
              else
                 TargetHasSubsectionsViaSymbols=YES
    -            AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    -                   [Define to 1 if Apple-style dead-stripping is supported.])
              fi
             ],
             [TargetHasSubsectionsViaSymbols=NO
    
    
    =====================================
    m4/ghc_convert_os.m4
    =====================================
    @@ -22,7 +22,7 @@ AC_DEFUN([GHC_CONVERT_OS],[
           openbsd*)
             $3="openbsd"
             ;;
    -      windows|mingw32)
    +      windows|mingw32|mingw64)
             $3="mingw32"
             ;;
           # As far as I'm aware, none of these have relevant variants
    
    
    =====================================
    rts/PrimOps.cmm
    =====================================
    @@ -740,25 +740,15 @@ stg_atomicModifyMutVar2zh ( gcptr mv, gcptr f )
     
             obviously we can share (f x).
     
    -         z = [stg_ap_2 f x]  (max (HS + 2) MIN_UPD_SIZE)
    -         y = [stg_sel_0 z]   (max (HS + 1) MIN_UPD_SIZE)
    +         z = [stg_ap_2 f x]  (SIZEOF_StgThunkHeader + WDS(2))
    +         y = [stg_sel_0 z]   (SIZEOF_StgThunkHeader + WDS(1))
         */
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 1
    -#define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),WDS(MIN_UPD_SIZE-1))
    -#else
     #define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(1))
     #define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),0)
    -#endif
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2
    -#define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
    -#else
     #define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(2))
     #define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),0)
    -#endif
     
     #define SIZE (THUNK_2_SIZE + THUNK_1_SIZE)
     
    @@ -815,13 +805,8 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f )
              z = [stg_ap_2 f x]  (max (HS + 2) MIN_UPD_SIZE)
         */
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2
    -#define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
    -#else
     #define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(2))
     #define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),0)
    -#endif
     
         HP_CHK_GEN_TICKY(THUNK_SIZE);
     
    
    
    =====================================
    rts/configure.ac
    =====================================
    @@ -22,17 +22,153 @@ dnl     #define SIZEOF_CHAR 0
     dnl   recently.
     AC_PREREQ([2.69])
     
    +AC_CONFIG_FILES([ghcplatform.h.top])
    +
     AC_CONFIG_HEADERS([ghcautoconf.h.autoconf])
     
    +AC_ARG_ENABLE(asserts-all-ways,
    +[AS_HELP_STRING([--enable-asserts-all-ways],
    +                [Usually ASSERTs are only compiled in the DEBUG way,
    +                 this will enable them in all ways.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    +  [EnableAssertsAllWays=NO]
    +)
    +if test "$enable_asserts_all_ways" = "yes" ; then
    +   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    +fi
    +
    +AC_ARG_ENABLE(native-io-manager,
    +[AS_HELP_STRING([--enable-native-io-manager],
    +                [Enable the native I/O manager by default.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    +  [EnableNativeIOManager=NO]
    +)
    +if test "$EnableNativeIOManager" = "YES"; then
    +  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    +fi
    +
     # We have to run these unconditionally, but we may discard their
     # results in the following code
     AC_CANONICAL_BUILD
     AC_CANONICAL_HOST
     
    +dnl ** Do a build with tables next to code?
    +dnl --------------------------------------------------------------
    +
    +AS_IF(
    +  [test "$CABAL_FLAG_tables_next_to_code" = 1],
    +  [AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])])
    +
    +dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set),
    +dnl later CC is copied to CC_STAGE{1,2,3}
    +AC_PROG_CC([cc gcc clang])
    +
    +dnl make extensions visible to allow feature-tests to detect them lateron
    +AC_USE_SYSTEM_EXTENSIONS
    +
    +dnl ** Used to determine how to compile ghc-prim's atomics.c, used by
    +dnl    unregisterised, Sparc, and PPC backends. Also determines whether
    +dnl    linking to libatomic is required for atomic operations, e.g. on
    +dnl    RISCV64 GCC.
    +FP_CC_SUPPORTS__ATOMICS
    +AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    +AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    +    [Define to 1 if we need -latomic for sub-word atomic operations.])
    +
    +dnl ** look to see if we have a C compiler using an llvm back end.
    +dnl
    +FP_CC_LLVM_BACKEND
    +AS_IF([test x"$CcLlvmBackend" = x"YES"],
    +  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
    +
    +GHC_CONVERT_PLATFORM_PARTS([build], [Build])
    +FPTOOLS_SET_PLATFORM_VARS([build],[Build])
    +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Build])
    +
     GHC_CONVERT_PLATFORM_PARTS([host], [Host])
     FPTOOLS_SET_PLATFORM_VARS([host], [Host])
     FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
     
    +GHC_SUBSECTIONS_VIA_SYMBOLS
    +AS_IF([test x"${TargetHasSubsectionsViaSymbols}" = x"YES"],
    +  [AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    +    [Define to 1 if Apple-style dead-stripping is supported.])])
    +
    +dnl --------------------------------------------------
    +dnl * Platform header file and syscall feature tests
    +dnl ### checking the state of the local header files and syscalls ###
    +
    +dnl ** Enable large file support.  NB. do this before testing the type of
    +dnl    off_t, because it will affect the result of that test.
    +AC_SYS_LARGEFILE
    +
    +dnl ** check for specific header (.h) files that we are interested in
    +AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    +
    +dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    +AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    +[[#if HAVE_SYS_PARAM_H
    +# include 
    +#endif
    +]])
    +
    +dnl ** check whether a declaration for `environ` is provided by libc.
    +FP_CHECK_ENVIRON
    +
    +dnl ** do we have long longs?
    +AC_CHECK_TYPES([long long])
    +
    +dnl ** what are the sizes of various types
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    +
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    +
    +
    +FP_CHECK_FUNC([WinExec],
    +  [@%:@include ], [WinExec("",0)])
    +
    +FP_CHECK_FUNC([GetModuleFileName],
    +  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    +
    +dnl ** check for more functions
    +dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    +AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    +
    +dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    +dnl ** _POSIX_C_SOURCE is defined
    +AC_CHECK_DECLS([ctime_r], , ,
    +[#define _POSIX_SOURCE 1
    +#define _POSIX_C_SOURCE 199506L
    +#include ])
    +
    +dnl On Linux we should have program_invocation_short_name
    +AC_CHECK_DECLS([program_invocation_short_name], , ,
    +[#define _GNU_SOURCE 1
    +#include ])
    +
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    @@ -140,7 +276,6 @@ AC_ARG_ENABLE(large-address-space,
     )
     
     use_large_address_space=no
    -AC_CHECK_SIZEOF([void *])
     if test "$ac_cv_sizeof_void_p" -eq 8 ; then
         if test "x$EnableLargeAddressSpace" = "xyes" ; then
             if test "$ghc_host_os" = "darwin" ; then
    @@ -223,19 +358,41 @@ dnl --------------------------------------------------------------
     AC_OUTPUT
     
     dnl ######################################################################
    -dnl Generate ghcautoconf.h
    +dnl Generate ghcplatform.h
     dnl ######################################################################
     
     [
     mkdir -p include
    +
    +touch include/ghcplatform.h
    +> include/ghcplatform.h
    +
    +cat ghcplatform.h.top                          >> include/ghcplatform.h
    +]
    +
    +dnl ** Do an unregisterised build?
    +dnl --------------------------------------------------------------
    +AS_IF(
    +  [test "$CABAL_FLAG_unregisterised" = 1],
    +  [echo "#define UnregisterisedCompiler 1"     >> include/ghcplatform.h])
    +
    +[
    +cat $srcdir/ghcplatform.h.bottom               >> include/ghcplatform.h
    +]
    +
    +dnl ######################################################################
    +dnl Generate ghcautoconf.h
    +dnl ######################################################################
    +
    +[
     touch include/ghcautoconf.h
     > include/ghcautoconf.h
     
     echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h
     echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h
    -# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO
    +# Copy the contents of ghcautoconf.h.autoconf, turning '#define PACKAGE_FOO
     # "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
    -cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \
    +cat ghcautoconf.h.autoconf | sed \
        -e 's,^\([	 ]*\)#[	 ]*define[	 ][	 ]*\(PACKAGE_[A-Z]*\)[	 ][ 	]*".*".*$,\1/* #undef \2 */,' \
        -e '/__GLASGOW_HASKELL/d' \
        -e '/REMOVE ME/d' \
    
    
    =====================================
    rts/ghcplatform.h.bottom
    =====================================
    @@ -0,0 +1,2 @@
    +
    +#endif /* __GHCPLATFORM_H__ */
    
    
    =====================================
    rts/ghcplatform.h.top.in
    =====================================
    @@ -0,0 +1,23 @@
    +#if !defined(__GHCPLATFORM_H__)
    +#define __GHCPLATFORM_H__
    +
    +#define BuildPlatform_TYPE  @BuildPlatform_CPP@
    +#define HostPlatform_TYPE   @HostPlatform_CPP@
    +
    +#define @BuildPlatform_CPP at _BUILD  1
    +#define @HostPlatform_CPP at _HOST  1
    +
    +#define @BuildArch_CPP at _BUILD_ARCH  1
    +#define @HostArch_CPP at _HOST_ARCH  1
    +#define BUILD_ARCH  "@BuildArch_CPP@"
    +#define HOST_ARCH  "@HostArch_CPP@"
    +
    +#define @BuildOS_CPP at _BUILD_OS  1
    +#define @HostOS_CPP at _HOST_OS  1
    +#define BUILD_OS  "@BuildOS_CPP@"
    +#define HOST_OS  "@HostOS_CPP@"
    +
    +#define @BuildVendor_CPP at _BUILD_VENDOR  1
    +#define @HostVendor_CPP at _HOST_VENDOR  1
    +#define BUILD_VENDOR  "@BuildVendor_CPP@"
    +#define HOST_VENDOR  "@HostVendor_CPP@"
    
    
    =====================================
    rts/rts.cabal
    =====================================
    @@ -54,6 +54,10 @@ flag static-libzstd
       default: False
     flag leading-underscore
       default: False
    +flag unregisterised
    +  default: False
    +flag tables-next-to-code
    +  default: False
     flag smp
       default: True
     flag find-ptr
    @@ -240,7 +244,7 @@ library
     
           include-dirs: include
           includes: Rts.h
    -      autogen-includes: ghcautoconf.h
    +      autogen-includes: ghcautoconf.h ghcplatform.h
           install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
                             ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
                             -- ^ from include
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cef0cd654e43f90861f840a330d95549eb96b0e5...d0d6af9b9f11356a5e81410189cfb505ef8ec276
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cef0cd654e43f90861f840a330d95549eb96b0e5...d0d6af9b9f11356a5e81410189cfb505ef8ec276
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 14:33:03 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Sun, 22 Oct 2023 10:33:03 -0400
    Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] 37 commits: Fix restarts in
     .ghcid
    Message-ID: <6535329f5337f_1f7b0d316d6ec103588@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00
    Fix restarts in .ghcid
    
    Using the whole of `hadrian/` restarted in a loop for me.
    
    - - - - -
    fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    NoFib results (omitted = 0.0%):
    ```
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             pretty           0.0%     -1.6%
                scc           0.0%     -1.7%
    --------------------------------------------------------------------------------
                Min           0.0%     -1.7%
                Max           0.0%     -0.0%
     Geometric Mean          -0.0%     -0.0%
    ```
    
    - - - - -
    32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00
    hadrian: Move ghcBinDeps into ghcLibDeps
    
    This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the
    `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc`
    library so need to make sure they are present in the libdir even if we
    are not going to build `ghc-bin`.
    
    This also fixes things for cross compilers because the stage2
    cross-compiler requires the ghc-usage.txt file, but we are using
    the stage2 lib folder but not building stage3:exe:ghc-bin so
    ghc-usage.txt was not being generated.
    
    - - - - -
    ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00
    Combine GREs when combining in mkImportOccEnv
    
    In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import
    item in favour of another, as explained in Note [Dealing with imports]
    in `GHC.Rename.Names`. However, this can cause us to lose track of
    important parent information.
    
    Consider for example #24084:
    
      module M1 where { class C a where { type T a } }
      module M2 ( module M1 ) where { import M1 }
      module M3 where { import M2 ( C, T ); instance C () where T () = () }
    
    When processing the import list of `M3`, we start off (for reasons that
    are not relevant right now) with two `Avail`s attached to `T`, namely
    `C(C, T)` and `T(T)`. We combine them in the `combine` function of
    `mkImportOccEnv`; as described in Note [Dealing with imports] we discard
    `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not**
    discard the information want that `C` is the parent of `T`. Indeed,
    losing track of this information can cause errors when importing,
    as we could get an error of the form
    
      ‘T’ is not a (visible) associated type of class ‘C’
    
    We fix this by combining the two GREs for `T` using `plusGRE`.
    
    Fixes #24084
    
    - - - - -
    257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00
    hadrian: Pass -DNOSMP to C compiler when needed
    
    Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
    SMP, but doesn't pass it to CC as well, leading to the following
    compilation error on mips64el:
    
    | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
    Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
    ===> Command failed with error code: 1
    In file included from rts/include/Stg.h:348,
                     from rts/include/Rts.h:38,
                     from rts/hooks/FlagDefaults.c:8:
    rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
      416 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
      440 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
      464 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    
    The old make system correctly passed this flag to both GHC and CC [1].
    
    Fix this error by passing -DNOSMP to CC as well.
    
    [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
    
    Closes #24082
    
    - - - - -
    13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00
    Users Guide: Drop dead code for Haddock refs to `parallel`
    
    I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was
    not substituted. It is dead code -- there is no `parallel-ref` usages
    and it doesn't look like there ever was (going back to
    3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it.
    
    - - - - -
    fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)
    
    bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".
    
    - - - - -
    cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Bignum: fix right shift of negative BigNat with native backend
    
    - - - - -
    cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Rts: expose rtsOutOfBoundsAccess symbol
    
    - - - - -
    72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Hadrian: enable `-fcheck-prim-bounds` in validate flavour
    
    This allows T24066 to fail when the bug is present.
    
    Otherwise the out-of-bound access isn't detected as it happens in
    ghc-bignum which wasn't compiled with the bounds check.
    
    - - - - -
    f9436990 by John Ericson at 2023-10-18T19:41:01-04:00
    Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in`
    
    Fixes #24091
    Progress on #23966
    
    Issue #24091 reports that `@ProjectVersion@` is no longer being
    substituted in the GHC user's guide. I assume this is a recent issue,
    but I am not sure how it's worked since
    c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and
    configure are trying to substitute the same `.in` file!
    
    Now only Hadrian does. That is better anyways; already something that
    issue #23966 requested.
    
    It seems like we were missing some dependencies in Hadrian. (I really,
    really hate that this is possible!) Hopefully it is fixed now.
    
    - - - - -
    b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00
    `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`
    
    Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
    be defined. (Guaranteed including a test in the testsuite.)
    
    - - - - -
    0295375a by John Ericson at 2023-10-18T19:41:37-04:00
    Generate `ghcversion.h` from a `.in` file
    
    Now that there are no conditional sections (see the previous commit), we
    can just a do simple substitution rather than pasting it together line
    by line.
    
    Progress on #23966
    
    - - - - -
    740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00
    Add a regression test for #24064
    
    - - - - -
    921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00
    CLC Proposal #182: Export List from Data.List
    
    Proposal link: https://github.com/haskell/core-libraries-committee/issues/182
    
    - - - - -
    4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
    rts: fix small argument passing on big-endian arch (fix #23387)
    
    - - - - -
    b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
    Interpreter: fix literal alignment on big-endian architectures (fix #19261)
    
    Literals weren't correctly aligned on big-endian, despite what the
    comment said.
    
    - - - - -
    a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
    Testsuite: recomp011 and recomp015 are fixed on powerpc
    
    These tests have been fixed but not tested and re-enabled on big-endian
    powerpc (see comments in #11260 and #11323)
    
    - - - - -
    fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
    CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
    - - - - -
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    c9a4d38a by Matthew Pickering at 2023-10-22T10:26:06-04:00
    hadrian: Build all executables in bin/ folder
    
    In the end the bindist creation logic copies them all into the bin
    folder. There is no benefit to building a specific few binaries in the
    lib/bin folder anymore.
    
    This also removes the ad-hoc logic to copy the touchy and unlit
    executables from stage0 into stage1. It takes <1s to build so we might
    as well just build it.
    
    - - - - -
    945ce30c by Matthew Pickering at 2023-10-22T10:26:06-04:00
    fail when bindist configure fails
    
    - - - - -
    3fb3d6ac by Matthew Pickering at 2023-10-22T10:26:06-04:00
    Correctly propagate build/host/target to bindist
    
    fix host/target bindist
    t
    
    - - - - -
    6edd4ade by Matthew Pickering at 2023-10-22T10:26:06-04:00
    ci: Test cross bindists
    
    - - - - -
    80612181 by Matthew Pickering at 2023-10-22T10:26:06-04:00
    CROSS_STAGE variable
    
    - - - - -
    d54a6ad3 by Matthew Pickering at 2023-10-22T10:26:06-04:00
    Use explicit syntax rather than pure
    
    - - - - -
    37707760 by Matthew Pickering at 2023-10-22T10:26:06-04:00
    ci: Javascript don't set CROSS_EMULATOR
    
    There is no CROSS_EMULATOR needed to run javascript binaries, so we
    don't set the CROSS_EMULATOR to some dummy value.
    
    - - - - -
    95d654b7 by Matthew Pickering at 2023-10-22T10:26:06-04:00
    hadrian: Fill in more of the default.host toolchain file
    
    When you are building a cross compiler this file will be used to build
    stage1 and it's libraries, so we need enough information here to work
    accurately. There is still more work to be done (see for example, word
    size is still fixed).
    
    - - - - -
    2753bbbf by Matthew Pickering at 2023-10-22T10:32:33-04:00
    hadrian: Build stage 2 cross compilers
    
    * Most of hadrian is abstracted over the stage in order to remove the
      assumption that the target of all stages is the same platform. This
      allows the RTS to be built for two different targets for example.
    * Abstracts the bindist creation logic to allow building either normal
      or cross bindists. Normal bindists use stage 1 libraries and a stage 2
      compiler. Cross bindists use stage 2 libararies and a stage 2
      compiler.
    
    -------------------------
    Metric Decrease:
        T10421a
        T10858
        T11195
        T11276
        T11374
        T11822
        T15630
        T17096
        T18478
        T20261
    Metric Increase:
        parsing001
    -------------------------
    
    - - - - -
    
    
    30 changed files:
    
    - .ghcid
    - .gitignore
    - .gitlab/ci.sh
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/ByteCode/Asm.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Data/OrdList.hs
    - compiler/GHC/Rename/Env.hs
    - compiler/GHC/Rename/Names.hs
    - compiler/GHC/Settings/IO.hs
    - compiler/GHC/Types/Avail.hs
    - compiler/GHC/Types/Name/Reader.hs
    - configure.ac
    - distrib/configure.ac.in
    - distrib/cross-port
    - docs/coding-style.html
    - docs/rts/rts.tex
    - docs/users_guide/conf.py
    - docs/users_guide/ghc_config.py.in
    - hadrian/bindist/Makefile
    - hadrian/bindist/config.mk.in
    - hadrian/cfg/default.host.target.in
    - hadrian/cfg/system.config.in
    - hadrian/doc/flavours.md
    - hadrian/src/Base.hs
    - hadrian/src/Builder.hs
    - hadrian/src/Context.hs
    - hadrian/src/Expression.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc566a6dd92850f5da695400e43273ef73afe3c6...2753bbbff8205a2ce5d6237646530e27eb6cbd13
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc566a6dd92850f5da695400e43273ef73afe3c6...2753bbbff8205a2ce5d6237646530e27eb6cbd13
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 14:44:21 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Sun, 22 Oct 2023 10:44:21 -0400
    Subject: [Git][ghc/ghc][wip/hadrian-ghc-llvm-version] Revert "hadrian:
     Decrease verbosity of cabal commands"
    Message-ID: <6535354589505_1f7b0d37bc78c1077a7@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/hadrian-ghc-llvm-version at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    23e3c72a by John Ericson at 2023-10-22T10:44:10-04:00
    Revert "hadrian: Decrease verbosity of cabal commands"
    
    This reverts commit 9e6ef7ba5949b8900b3a7efb3a443c2004ebe184.
    
    - - - - -
    
    
    1 changed file:
    
    - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    
    
    Changes:
    
    =====================================
    hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    =====================================
    @@ -198,10 +198,9 @@ copyPackage context at Context {..} = do
     shakeVerbosityToCabalFlag :: Verbosity -> String
     shakeVerbosityToCabalFlag = \case
         Diagnostic -> "-v3"
    -    Verbose -> "-v2"
    -    -- Normal levels should not produce output to stdout
    +    Verbose -> "-v3"
         Silent -> "-v0"
    -    _ -> "-v1"
    +    _ -> "-v2"
     
     -- | What type of file is Main
     data MainSourceType = HsMain | CppMain | CMain
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23e3c72a01317414a89783f096ab8806ecd9297b
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23e3c72a01317414a89783f096ab8806ecd9297b
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 15:21:10 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Sun, 22 Oct 2023 11:21:10 -0400
    Subject: [Git][ghc/ghc][wip/hadrian-ghc-llvm-version] TEMP more verbose
    Message-ID: <65353de6924fc_1f7b0d47cbdbc1135e0@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/hadrian-ghc-llvm-version at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    365d7328 by John Ericson at 2023-10-22T11:20:47-04:00
    TEMP more verbose
    
    Include Revert "hadrian: Decrease verbosity of cabal commands"
    
    This reverts commit 9e6ef7ba5949b8900b3a7efb3a443c2004ebe184.
    
    - - - - -
    
    
    4 changed files:
    
    - .gitlab-ci.yml
    - hadrian/ghci-cabal.in
    - hadrian/ghci-multi-cabal.in
    - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    
    
    Changes:
    
    =====================================
    .gitlab-ci.yml
    =====================================
    @@ -400,7 +400,7 @@ hadrian-ghc-in-ghci:
         - "echo 'package hadrian'  > hadrian/cabal.project.local"
         - "echo '  ghc-options: -Werror'  >> hadrian/cabal.project.local"
         # Load ghc-in-ghci then immediately exit and check the modules loaded
    -    - echo ":q" | hadrian/ghci -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok,"
    +    - echo ":q" | hadrian/ghci -j`mk/detect-cpu-count.sh`
       after_script:
         - .gitlab/ci.sh save_cache
         - cat ci-timings
    @@ -452,7 +452,7 @@ hadrian-multi:
         # Now GHC means, use this GHC for hadrian
         - export GHC=$BOOT_HC
         # Load hadrian-multi then immediately exit and check the modules loaded
    -    - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok,"
    +    - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`
       after_script:
         - .gitlab/ci.sh save_cache
       cache:
    
    
    =====================================
    hadrian/ghci-cabal.in
    =====================================
    @@ -5,6 +5,6 @@
     set -e
     export TOOL_OUTPUT=.hadrian_ghci/ghci_args
     # Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
    -CABFLAGS="-v0 $CABFLAGS" "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
    +"hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
     GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')"
     @WithGhc@ --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -hidir=.hadrian_ghci/interface -O0 +RTS -A128m
    
    
    =====================================
    hadrian/ghci-multi-cabal.in
    =====================================
    @@ -8,6 +8,6 @@ if [[ $(printf "9.4.0\n%s\n" $($RUN_GHC --numeric-version) | sort -uV | head -n
     set -e
     export TOOL_OUTPUT=.hadrian_ghci_multi/ghci_args
     # Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
    -CABFLAGS=-v0 "hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS
    +"hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS
     GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')"
     $RUN_GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m
    
    
    =====================================
    hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    =====================================
    @@ -198,10 +198,9 @@ copyPackage context at Context {..} = do
     shakeVerbosityToCabalFlag :: Verbosity -> String
     shakeVerbosityToCabalFlag = \case
         Diagnostic -> "-v3"
    -    Verbose -> "-v2"
    -    -- Normal levels should not produce output to stdout
    +    Verbose -> "-v3"
         Silent -> "-v0"
    -    _ -> "-v1"
    +    _ -> "-v2"
     
     -- | What type of file is Main
     data MainSourceType = HsMain | CppMain | CMain
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/365d73281646deeabf83ee509f47accc84ac8b80
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/365d73281646deeabf83ee509f47accc84ac8b80
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 15:52:12 2023
    From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314))
    Date: Sun, 22 Oct 2023 11:52:12 -0400
    Subject: [Git][ghc/ghc][wip/hadrian-ghc-llvm-version] TEMP more verbose
    Message-ID: <6535452c94761_1f7b0d53bc0181141b9@gitlab.mail>
    
    
    
    John Ericson pushed to branch wip/hadrian-ghc-llvm-version at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    44d40a4f by John Ericson at 2023-10-22T11:52:07-04:00
    TEMP more verbose
    
    Include Revert "hadrian: Decrease verbosity of cabal commands"
    
    This reverts commit 9e6ef7ba5949b8900b3a7efb3a443c2004ebe184.
    
    - - - - -
    
    
    4 changed files:
    
    - .gitlab-ci.yml
    - hadrian/ghci-cabal.in
    - hadrian/ghci-multi-cabal.in
    - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    
    
    Changes:
    
    =====================================
    .gitlab-ci.yml
    =====================================
    @@ -400,7 +400,7 @@ hadrian-ghc-in-ghci:
         - "echo 'package hadrian'  > hadrian/cabal.project.local"
         - "echo '  ghc-options: -Werror'  >> hadrian/cabal.project.local"
         # Load ghc-in-ghci then immediately exit and check the modules loaded
    -    - echo ":q" | hadrian/ghci -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok,"
    +    - echo ":q" | hadrian/ghci -j`mk/detect-cpu-count.sh` -VVVV
       after_script:
         - .gitlab/ci.sh save_cache
         - cat ci-timings
    @@ -452,7 +452,7 @@ hadrian-multi:
         # Now GHC means, use this GHC for hadrian
         - export GHC=$BOOT_HC
         # Load hadrian-multi then immediately exit and check the modules loaded
    -    - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok,"
    +    - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh` -VVVV
       after_script:
         - .gitlab/ci.sh save_cache
       cache:
    
    
    =====================================
    hadrian/ghci-cabal.in
    =====================================
    @@ -5,6 +5,6 @@
     set -e
     export TOOL_OUTPUT=.hadrian_ghci/ghci_args
     # Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
    -CABFLAGS="-v0 $CABFLAGS" "hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
    +"hadrian/build-cabal" tool:compiler/GHC.hs --build-root=.hadrian_ghci --flavour=ghc-in-ghci $HADRIAN_ARGS
     GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')"
     @WithGhc@ --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -hidir=.hadrian_ghci/interface -O0 +RTS -A128m
    
    
    =====================================
    hadrian/ghci-multi-cabal.in
    =====================================
    @@ -8,6 +8,6 @@ if [[ $(printf "9.4.0\n%s\n" $($RUN_GHC --numeric-version) | sort -uV | head -n
     set -e
     export TOOL_OUTPUT=.hadrian_ghci_multi/ghci_args
     # Replace newlines with spaces, as these otherwise break the ghci invocation on windows.
    -CABFLAGS=-v0 "hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS
    +"hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS
     GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')"
     $RUN_GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m
    
    
    =====================================
    hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
    =====================================
    @@ -198,10 +198,9 @@ copyPackage context at Context {..} = do
     shakeVerbosityToCabalFlag :: Verbosity -> String
     shakeVerbosityToCabalFlag = \case
         Diagnostic -> "-v3"
    -    Verbose -> "-v2"
    -    -- Normal levels should not produce output to stdout
    +    Verbose -> "-v3"
         Silent -> "-v0"
    -    _ -> "-v1"
    +    _ -> "-v2"
     
     -- | What type of file is Main
     data MainSourceType = HsMain | CppMain | CMain
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44d40a4fc28a66008d9dbe3bd8100e00294bd09b
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44d40a4fc28a66008d9dbe3bd8100e00294bd09b
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 21:30:09 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Sun, 22 Oct 2023 17:30:09 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] More -- now it compiles
    Message-ID: <65359461c728f_1f7b0dcea57ac151883@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    97fac893 by Simon Peyton Jones at 2023-10-22T22:29:25+01:00
    More -- now it compiles
    
    - - - - -
    
    
    15 changed files:
    
    - compiler/GHC/Core.hs
    - compiler/GHC/Core/Opt/LiberateCase.hs
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/Core/Opt/Pipeline.hs
    - compiler/GHC/Core/Opt/Simplify/Env.hs
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Opt/Simplify/Iteration.hs
    - compiler/GHC/Core/Opt/Simplify/Utils.hs
    - compiler/GHC/Core/Opt/SpecConstr.hs
    - compiler/GHC/Core/Ppr.hs
    - compiler/GHC/Core/Seq.hs
    - compiler/GHC/Core/Unfold.hs
    - compiler/GHC/Core/Unfold/Make.hs
    - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs
    - compiler/GHC/Types/Id.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core.hs
    =====================================
    @@ -1390,6 +1390,8 @@ data UnfoldingGuidance
       | UnfIfGoodArgs {     -- Arose from a normal Id
           ug_args :: [Var],      -- Arguments
           ug_tree :: ExprTree    -- Abstraction of the body
    +      -- Invariant: free vars of ug_tree are the ug_args, plus variables
    +      --            in scope at the binding site of the function definition
         }
     
       | UnfNever        -- The RHS is big, so don't inline it
    @@ -1397,13 +1399,14 @@ data UnfoldingGuidance
     data ExprTree
       = TooBig
       | SizeIs { et_size  :: {-# UNPACK #-} !Int
    -           , et_cases :: Bag CaseTree
                , et_ret   :: {-# UNPACK #-} !Int
                     -- ^ Discount when result is scrutinised
    +           , et_cases :: Bag CaseTree
         }
     
     data CaseTree
       = CaseOf Id          -- Abstracts a case expression on this Id
    +           Id          -- Case binder
                [AltTree]   -- Always non-empty, but not worth making NonEmpty;
                            -- nothing relies on non-empty-ness
       | ScrutOf Id Int     -- If this Id is bound to a value, apply this discount
    
    
    =====================================
    compiler/GHC/Core/Opt/LiberateCase.hs
    =====================================
    @@ -14,7 +14,6 @@ import GHC.Prelude
     
     import GHC.Core
     import GHC.Core.Unfold
    -import GHC.Core.Opt.Simplify.Inline
     import GHC.Builtin.Types ( unitDataConId )
     import GHC.Types.Id
     import GHC.Types.Var.Env
    
    
    =====================================
    compiler/GHC/Core/Opt/OccurAnal.hs
    =====================================
    @@ -1919,20 +1919,17 @@ nodeScore !env new_bndr lb_deps
         -- is_lb: see Note [Loop breakers, node scoring, and stability]
         is_lb = isStrongLoopBreaker (idOccInfo old_bndr)
     
    -    old_unf = realIdUnfolding old_bndr
    +    old_unf    = realIdUnfolding old_bndr
         can_unfold = canUnfold old_unf
         rhs        = case old_unf of
                        CoreUnfolding { uf_src = src, uf_tmpl = unf_rhs }
                          | isStableSource src
                          -> unf_rhs
                        _ -> bind_rhs
    -       -- 'bind_rhs' is irrelevant for inlining things with a stable unfolding
    -    rhs_size = case old_unf of
    -                 CoreUnfolding { uf_guidance = guidance }
    -                    | UnfIfGoodArgs { ug_size = size } <- guidance
    -                    -> size
    -                 _  -> cheapExprSize rhs
    +        -- 'bind_rhs' is irrelevant for inlining things with a stable unfolding
     
    +    rhs_size = cheapExprSize rhs
    +        -- ToDo: could exploit pre-computed unfolding size?
     
             -- Checking for a constructor application
             -- Cheap and cheerful; the simplifier moves casts out of the way
    
    
    =====================================
    compiler/GHC/Core/Opt/Pipeline.hs
    =====================================
    @@ -76,7 +76,7 @@ core2core :: HscEnv -> ModGuts -> IO ModGuts
     core2core hsc_env guts@(ModGuts { mg_module  = mod
                                     , mg_loc     = loc
                                     , mg_rdr_env = rdr_env })
    -  = do { let builtin_passes = getCoreToDo dflags hpt_rule_base extra_vars
    +  = do { let builtin_passes = getCoreToDo dflags mod hpt_rule_base extra_vars
                  uniq_tag = 's'
     
            ; (guts2, stats) <- runCoreM hsc_env hpt_rule_base uniq_tag mod
    @@ -116,9 +116,9 @@ core2core hsc_env guts@(ModGuts { mg_module  = mod
     ************************************************************************
     -}
     
    -getCoreToDo :: DynFlags -> RuleBase -> [Var] -> [CoreToDo]
    +getCoreToDo :: DynFlags -> Module -> RuleBase -> [Var] -> [CoreToDo]
     -- This function builds the pipeline of optimisations
    -getCoreToDo dflags hpt_rule_base extra_vars
    +getCoreToDo dflags mod hpt_rule_base extra_vars
       = flatten_todos core_todo
       where
         phases        = simplPhases        dflags
    @@ -156,7 +156,7 @@ getCoreToDo dflags hpt_rule_base extra_vars
           = CoreDoPasses
           $   [ maybe_strictness_before phase
               , CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter
    -                             (initSimplMode dflags phase name) hpt_rule_base
    +                             (initSimplMode dflags mod phase name) hpt_rule_base
               , maybe_rule_check phase ]
     
         -- Run GHC's internal simplification phase, after all rules have run.
    @@ -167,7 +167,7 @@ getCoreToDo dflags hpt_rule_base extra_vars
         -- See Note [Inline in InitialPhase]
         -- See Note [RULEs enabled in InitialPhase]
         simpl_gently = CoreDoSimplify $ initSimplifyOpts dflags extra_vars max_iter
    -                                    (initGentleSimplMode dflags) hpt_rule_base
    +                                    (initGentleSimplMode dflags mod) hpt_rule_base
     
         dmd_cpr_ww = if ww_on then [CoreDoDemand True,CoreDoCpr,CoreDoWorkerWrapper]
                               else [CoreDoDemand False] -- NB: No CPR! See Note [Don't change boxity without worker/wrapper]
    
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Env.hs
    =====================================
    @@ -75,6 +75,8 @@ import GHC.Types.Id as Id
     import GHC.Types.Basic
     import GHC.Types.Unique.FM      ( pprUniqFM )
     
    +import GHC.Unit.Types( Module )
    +
     import GHC.Data.OrdList
     import GHC.Data.Graph.UnVar
     
    @@ -242,7 +244,8 @@ seUnfoldingOpts env = sm_uf_opts (seMode env)
     
     -- See Note [The environments of the Simplify pass]
     data SimplMode = SimplMode -- See comments in GHC.Core.Opt.Simplify.Monad
    -  { sm_phase        :: !CompilerPhase
    +  { sm_module       ::  !Module
    +  , sm_phase        :: !CompilerPhase
       , sm_names        :: ![String]      -- ^ Name(s) of the phase
       , sm_rules        :: !Bool          -- ^ Whether RULES are enabled
       , sm_inline       :: !Bool          -- ^ Whether inlining is enabled
    @@ -910,12 +913,12 @@ So we want to look up the inner X.g_34 in the substitution, where we'll
     find that it has been substituted by b.  (Or conceivably cloned.)
     -}
     
    -substId :: SimplEnv -> InId -> SimplSR
    +substId :: HasDebugCallStack => SimplEnv -> InId -> SimplSR
     -- Returns DoneEx only on a non-Var expression
    -substId (SimplEnv { seInScope = in_scope, seIdSubst = ids }) v
    +substId (SimplEnv { seMode = mode, seInScope = in_scope, seIdSubst = ids }) v
       = case lookupVarEnv ids v of  -- Note [Global Ids in the substitution]
    -        Nothing               -> DoneId (refineFromInScope in_scope v)
    -        Just (DoneId v)       -> DoneId (refineFromInScope in_scope v)
    +        Nothing               -> DoneId (refineFromInScope mode in_scope v)
    +        Just (DoneId v)       -> DoneId (refineFromInScope mode in_scope v)
             Just res              -> res    -- DoneEx non-var, or ContEx
     
             -- Get the most up-to-date thing from the in-scope set
    @@ -924,22 +927,24 @@ substId (SimplEnv { seInScope = in_scope, seIdSubst = ids }) v
             --
             -- See also Note [In-scope set as a substitution] in GHC.Core.Opt.Simplify.
     
    -refineFromInScope :: InScopeSet -> Var -> Var
    -refineFromInScope in_scope v
    +refineFromInScope :: HasDebugCallStack => SimplMode -> InScopeSet -> Var -> Var
    +refineFromInScope mode in_scope v
       | isLocalId v = case lookupInScope in_scope v of
                       Just v' -> v'
    -                  Nothing -> pprPanic "refineFromInScope" (ppr in_scope $$ ppr v)
    +                  Nothing -> -- pprPanic "refineFromInScope" (ppr in_scope $$ ppr v)
    +                             pprTrace "refineFromInScope"
    +                                 (ppr (sm_module mode) <+> ppr v) v
                                  -- c.f #19074 for a subtle place where this went wrong
       | otherwise = v
     
     lookupRecBndr :: SimplEnv -> InId -> OutId
     -- Look up an Id which has been put into the envt by simplRecBndrs,
     -- but where we have not yet done its RHS
    -lookupRecBndr (SimplEnv { seInScope = in_scope, seIdSubst = ids }) v
    +lookupRecBndr (SimplEnv { seMode = mode, seInScope = in_scope, seIdSubst = ids }) v
       = case lookupVarEnv ids v of
             Just (DoneId v) -> v
             Just _ -> pprPanic "lookupRecBndr" (ppr v)
    -        Nothing -> refineFromInScope in_scope v
    +        Nothing -> refineFromInScope mode in_scope v
     
     {-
     ************************************************************************
    
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -9,12 +9,10 @@ This module contains inlining logic used by the simplifier.
     {-# LANGUAGE BangPatterns #-}
     
     module GHC.Core.Opt.Simplify.Inline (
    -        -- * Cheap and cheerful inlining checks.
    -        couldBeSmallEnoughToInline,
    -        smallEnoughToInline,
    -
             -- * The smart inlining decisions are made by callSiteInline
             callSiteInline, CallCtxt(..),
    +
    +        exprSummary
         ) where
     
     import GHC.Prelude
    @@ -25,47 +23,20 @@ import GHC.Core.Opt.Simplify.Env
     import GHC.Core.Opt.Simplify.Utils
     import GHC.Core
     import GHC.Core.Unfold
    +
     import GHC.Types.Id
    +import GHC.Types.Literal ( isLitRubbish )
     import GHC.Types.Basic  ( Arity, RecFlag(..) )
    +import GHC.Types.Name
    +import GHC.Types.Var.Env
    +
     import GHC.Utils.Logger
     import GHC.Utils.Misc
     import GHC.Utils.Outputable
    -import GHC.Types.Name
    +import GHC.Utils.Panic
     
     import Data.List (isPrefixOf)
     
    -{-
    -************************************************************************
    -*                                                                      *
    -\subsection[considerUnfolding]{Given all the info, do (not) do the unfolding}
    -*                                                                      *
    -************************************************************************
    -
    -We use 'couldBeSmallEnoughToInline' to avoid exporting inlinings that
    -we ``couldn't possibly use'' on the other side.  Can be overridden w/
    -flaggery.  Just the same as smallEnoughToInline, except that it has no
    -actual arguments.
    --}
    -
    -couldBeSmallEnoughToInline :: UnfoldingOpts -> Int -> CoreExpr -> Bool
    -couldBeSmallEnoughToInline opts threshold rhs
    -  = case sizeExpr opts threshold [] body of
    -       TooBig -> False
    -       _      -> True
    -  where
    -    (_, body) = collectBinders rhs
    -
    -----------------
    -smallEnoughToInline :: UnfoldingOpts -> Unfolding -> Bool
    -smallEnoughToInline opts (CoreUnfolding {uf_guidance = guidance})
    -  = case guidance of
    -       UnfIfGoodArgs {ug_tree = et}
    -         -> exprTreeSize emptyVarEnv False et `ltSize` unfoldingUseThreshold opts
    -       UnfWhen {} -> True
    -       UnfNever   -> False
    -smallEnoughToInline _ _
    -  = False
    -
     {-
     ************************************************************************
     *                                                                      *
    @@ -90,44 +61,36 @@ them inlining is to give them a NOINLINE pragma, which we do in
     StrictAnal.addStrictnessInfoToTopId
     -}
     
    -callSiteInline :: Logger
    -               -> UnfoldingOpts
    -               -> Int                   -- Case depth
    -               -> Id                    -- The Id
    -               -> Bool                  -- True <=> unfolding is active
    -               -> Bool                  -- True if there are no arguments at all (incl type args)
    -               -> [ArgSummary]          -- One for each value arg; True if it is interesting
    -               -> CallCtxt              -- True <=> continuation is interesting
    +callSiteInline :: Logger -> SimplEnv
    +               -> Id -> SimplCont
                    -> Maybe CoreExpr        -- Unfolding, if any
    -callSiteInline logger opts !case_depth id active_unfolding lone_variable arg_infos cont_info
    -  = case idUnfolding id of
    +callSiteInline logger env fn cont
    +  = case idUnfolding fn of
           -- idUnfolding checks for loop-breakers, returning NoUnfolding
           -- Things with an INLINE pragma may have an unfolding *and*
           -- be a loop breaker  (maybe the knot is not yet untied)
             CoreUnfolding { uf_tmpl = unf_template
                           , uf_cache = unf_cache
                           , uf_guidance = guidance }
    -          | active_unf -> tryUnfolding logger opts case_depth id lone_variable
    -                                    arg_infos cont_info unf_template
    -                                    unf_cache guidance
    -          | otherwise -> traceInline logger opts id "Inactive unfolding:" (ppr id) Nothing
    +          | active_unf -> tryUnfolding logger env fn cont unf_template unf_cache guidance
    +          | otherwise  -> traceInline logger env fn "Inactive unfolding:" (ppr fn) Nothing
             NoUnfolding      -> Nothing
             BootUnfolding    -> Nothing
             OtherCon {}      -> Nothing
             DFunUnfolding {} -> Nothing     -- Never unfold a DFun
       where
    -    active_unf = activeUnfolding (seMode env) var
    -
    +    active_unf = activeUnfolding (seMode env) fn
     
     -- | Report the inlining of an identifier's RHS to the user, if requested.
    -traceInline :: Logger -> UnfoldingOpts -> Id -> String -> SDoc -> a -> a
    -traceInline logger opts inline_id str doc result
    +traceInline :: Logger -> SimplEnv -> Id -> String -> SDoc -> a -> a
    +traceInline logger env inline_id str doc result
       -- We take care to ensure that doc is used in only one branch, ensuring that
       -- the simplifier can push its allocation into the branch. See Note [INLINE
       -- conditional tracing utilities].
       | enable    = logTraceMsg logger str doc result
       | otherwise = result
       where
    +    opts = seUnfoldingOpts env
         enable
           | logHasDumpFlag logger Opt_D_dump_verbose_inlinings
           = True
    @@ -233,39 +196,32 @@ needed on a per-module basis.
     
     -}
     
    -tryUnfolding :: Logger -> UnfoldingOpts -> Int
    -             -> Id -> Bool -> [ArgSummary] -> CallCtxt
    +tryUnfolding :: Logger -> SimplEnv -> Id -> SimplCont
                  -> CoreExpr -> UnfoldingCache -> UnfoldingGuidance
                  -> Maybe CoreExpr
    -tryUnfolding logger opts !case_depth id lone_variable arg_infos
    -             cont_info unf_template unf_cache guidance
    +tryUnfolding logger env fn cont unf_template unf_cache guidance
      = case guidance of
    -     UnfNever -> traceInline logger opts id str (text "UnfNever") Nothing
    +     UnfNever -> traceInline logger env fn str (text "UnfNever") Nothing
     
          UnfWhen { ug_arity = uf_arity, ug_unsat_ok = unsat_ok, ug_boring_ok = boring_ok }
             | enough_args && (boring_ok || some_benefit || unfoldingVeryAggressive opts)
                     -- See Note [INLINE for small functions] (3)
    -        -> traceInline logger opts id str (mk_doc some_benefit empty True) (Just unf_template)
    +        -> traceInline logger env fn str (mk_doc some_benefit empty True) (Just unf_template)
             | otherwise
    -        -> traceInline logger opts id str (mk_doc some_benefit empty False) Nothing
    +        -> traceInline logger env fn str (mk_doc some_benefit empty False) Nothing
             where
               some_benefit = calc_some_benefit uf_arity
               enough_args  = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0)
     
          UnfIfGoodArgs { ug_args = arg_bndrs, ug_tree = expr_tree }
             | unfoldingVeryAggressive opts
    -        -> traceInline logger opts id str (mk_doc some_benefit extra_doc True) (Just unf_template)
    +        -> traceInline logger env fn str (mk_doc some_benefit extra_doc True) (Just unf_template)
             | is_wf && some_benefit && small_enough
    -        -> traceInline logger opts id str (mk_doc some_benefit extra_doc True) (Just unf_template)
    +        -> traceInline logger env fn str (mk_doc some_benefit extra_doc True) (Just unf_template)
             | otherwise
    -        -> traceInline logger opts id str (mk_doc some_benefit extra_doc False) Nothing
    +        -> traceInline logger env fn str (mk_doc some_benefit extra_doc False) Nothing
             where
    -          some_benefit = calc_some_benefit (length arg_discounts)
    -          -- See Note [Avoid inlining into deeply nested cases]
    -          depth_treshold = unfoldingCaseThreshold opts
    -          depth_scaling = unfoldingCaseScaling opts
    -          depth_penalty | case_depth <= depth_treshold = 0
    -                        | otherwise       = (size * (case_depth - depth_treshold)) `div` depth_scaling
    +          some_benefit = calc_some_benefit (length arg_bndrs)
     
               want_result
                  | LT <- arg_bndrs `compareLength` arg_infos
    @@ -274,16 +230,48 @@ tryUnfolding logger opts !case_depth id lone_variable arg_infos
                                   BoringCtxt -> False
                                   _          -> True
     
    -          context = IC { ic_bound = mkVarEnv (arg_bnds `zip` arg_infos)
    -                       , ic_free  = xx
    +          zapped_env = zapSubstEnv env
    +          context = IC { ic_bound    = mkVarEnv (arg_bndrs `zip` arg_infos)
    +                       , ic_free     = getFreeSummary zapped_env
                            , ic_want_res = want_result }
    -          size = depth_penalty `addSizeN` exprTreeSize context expr_tree
    -          small_enough = adjusted_size `leqSize` unfoldingUseThreshold opts
    +          size :: Size
    +          size = exprTreeSize context expr_tree
    +
    +          getFreeSummary :: SimplEnv -> Id -> ArgSummary
    +          -- Get the ArgSummary of a free variable
    +          getFreeSummary env x
    +            = case lookupInScope (seInScope env) x of
    +                Just x' | warnPprTrace (not (isId x')) "GFS" (vcat
    +                            [ ppr fn <+> equals <+> ppr unf_template
    +                            , text "expr_tree:" <+> ppr expr_tree
    +                            , ppr x <+> ppr x'
    +                           ]) True
    +                        , Just expr <- maybeUnfoldingTemplate (idUnfolding x')
    +                        -> exprSummary env expr
    +                _ -> ArgNoInfo
    +
    +
    +          -- Adjust by the depth scaling
    +          -- See Note [Avoid inlining into deeply nested cases]
    +          depth_threshold = unfoldingCaseThreshold opts
    +          depth_scaling   = unfoldingCaseScaling opts
    +
    +          add_depth_penalty size = size + (size * (case_depth - depth_threshold))
    +                                                  `div` depth_scaling
    +          final_size | case_depth <= depth_threshold = size
    +                     | otherwise = adjustSize add_depth_penalty size
     
    -          extra_doc = vcat [ text "case depth =" <+> int case_depth
    -                           , text "depth based penalty =" <+> int depth_penalty
    -                           , text "discounted size =" <+> int adjusted_size ]
    +          small_enough = final_size `leqSize` unfoldingUseThreshold opts
    +
    +          extra_doc = vcat [ text "size =" <+> ppr size
    +                           , text "case depth =" <+> int case_depth
    +                           , text "final_size =" <+> ppr final_size ]
       where
    +    (lone_variable, arg_infos, call_cont) = contArgs cont
    +    cont_info  = interestingCallContext env call_cont
    +    case_depth = seCaseDepth env
    +    opts       = seUnfoldingOpts env
    +
         -- Unpack the UnfoldingCache lazily because it may not be needed, and all
         -- its fields are strict; so evaluating unf_cache at all forces all the
         -- isWorkFree etc computations to take place.  That risks wasting effort for
    @@ -302,7 +290,7 @@ tryUnfolding logger opts !case_depth id lone_variable arg_infos
                  , text "ANSWER =" <+> if yes_or_no then text "YES" else text "NO"]
     
         ctx = log_default_dump_context (logFlags logger)
    -    str = "Considering inlining: " ++ showSDocOneLine ctx (ppr id)
    +    str = "Considering inlining: " ++ showSDocOneLine ctx (ppr fn)
         n_val_args = length arg_infos
     
                -- some_benefit is used when the RHS is small enough
    @@ -320,7 +308,7 @@ tryUnfolding logger opts !case_depth id lone_variable arg_infos
           where
             saturated      = n_val_args >= uf_arity
             over_saturated = n_val_args > uf_arity
    -        interesting_args = any nonTriv arg_infos
    +        interesting_args = any hasArgInfo arg_infos
                     -- NB: (any nonTriv arg_infos) looks at the
                     -- over-saturated args too which is "wrong";
                     -- but if over-saturated we inline anyway.
    @@ -338,7 +326,6 @@ tryUnfolding logger opts !case_depth id lone_variable arg_infos
                               -> uf_arity > 0  -- See Note [RHS of lets]
                   _other      -> False         -- See Note [Nested functions]
     
    -
     {- Note [RHS of lets]
     ~~~~~~~~~~~~~~~~~~~~~
     When the call is the argument of a function with a RULE, or the RHS of a let,
    @@ -527,6 +514,7 @@ which Roman did.
     
     -}
     
    +{-
     computeDiscount :: [Int] -> Int -> [ArgSummary] -> CallCtxt
                     -> Int
     computeDiscount arg_discounts res_discount arg_infos cont_info
    @@ -570,3 +558,111 @@ computeDiscount arg_discounts res_discount arg_infos cont_info
                     -- Otherwise we, rather arbitrarily, threshold it.  Yuk.
                     -- But we want to avoid inlining large functions that return
                     -- constructors into contexts that are simply "interesting"
    +-}
    +
    +{- Note [Interesting arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +An argument is interesting if it deserves a discount for unfoldings
    +with a discount in that argument position.  The idea is to avoid
    +unfolding a function that is applied only to variables that have no
    +unfolding (i.e. they are probably lambda bound): f x y z There is
    +little point in inlining f here.
    +
    +Generally, *values* (like (C a b) and (\x.e)) deserve discounts.  But
    +we must look through lets, eg (let x = e in C a b), because the let will
    +float, exposing the value, if we inline.  That makes it different to
    +exprIsHNF.
    +
    +Before 2009 we said it was interesting if the argument had *any* structure
    +at all; i.e. (hasSomeUnfolding v).  But does too much inlining; see #3016.
    +
    +But we don't regard (f x y) as interesting, unless f is unsaturated.
    +If it's saturated and f hasn't inlined, then it's probably not going
    +to now!
    +
    +Note [Conlike is interesting]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider
    +        f d = ...((*) d x y)...
    +        ... f (df d')...
    +where df is con-like. Then we'd really like to inline 'f' so that the
    +rule for (*) (df d) can fire.  To do this
    +  a) we give a discount for being an argument of a class-op (eg (*) d)
    +  b) we say that a con-like argument (eg (df d)) is interesting
    +-}
    +
    +-------------------
    +contArgs :: SimplCont -> (Bool, [ArgSummary], SimplCont)
    +-- Summarises value args, discards type args and coercions
    +-- The returned continuation of the call is only used to
    +-- answer questions like "are you interesting?"
    +contArgs cont
    +  | lone cont = (True, [], cont)
    +  | otherwise = go [] cont
    +  where
    +    lone (ApplyToTy  {}) = False  -- See Note [Lone variables] in GHC.Core.Unfold
    +    lone (ApplyToVal {}) = False  -- NB: even a type application or cast
    +    lone (CastIt {})     = False  --     stops it being "lone"
    +    lone _               = True
    +
    +    go args (ApplyToVal { sc_arg = arg, sc_env = se, sc_cont = k })
    +                                        = go (exprSummary se arg : args) k
    +    go args (ApplyToTy { sc_cont = k }) = go args k
    +    go args (CastIt _ k)                = go args k
    +    go args k                           = (False, reverse args, k)
    +
    +------------------------------
    +exprSummary :: SimplEnv -> CoreExpr -> ArgSummary
    +-- Very simple version of exprIsConApp_maybe
    +-- But /do/ take the SimplEnv into account.  We must:
    +-- (a) Apply the substitution.  E.g
    +--       (\x. ...(f x)...) (a,b)
    +---    We may have x:->(a,b) in the substitution, and we want to see that
    +--     (a,b) when we are deciding whether or not to inline f
    +-- (b) Refine using the in-scope set. E.g
    +--       \x. ....case x of { (a,b) -> ...f x... }....
    +--     We want to see that x is (a,b) at the call site of f
    +exprSummary env e = go env e []
    +  where
    +    go :: SimplEnv -> CoreExpr -> [CoreExpr] -> ArgSummary
    +    go env (Cast e _) as = go env e as
    +    go env (Tick _ e) as = go env e as
    +    go env (App f a)  as = go env f (a:as)
    +    go env (Let b e)  as = go env' e as
    +      where
    +        env' = env `addNewInScopeIds` bindersOf b
    +
    +    go env (Var v)    as
    +       = -- Simplify.Env.substId Looks up in substitution
    +         -- /and/ refines from the InScopeset
    +         case substId env v of
    +           DoneId v'            -> go_var env v' as
    +           DoneEx e _           -> go (zapSubstEnv env)             e as
    +           ContEx tvs cvs ids e -> go (setSubstEnv env tvs cvs ids) e as
    +
    +    go _ (Lit l) as
    +       | isLitRubbish l = ArgNoInfo -- Leads to unproductive inlining in WWRec, #20035
    +       | otherwise      = assertPpr (null as) (ppr as) $
    +                          ArgIsCon (LitAlt l) []
    +
    +    go env (Lam b e)  as
    +      | null as = if isRuntimeVar b
    +                  then ArgIsLam
    +                  else go env' e []
    +      where
    +        env' = modifyInScope env b  -- Tricky corner here
    +
    +    go _ _ _ = ArgNoInfo
    +
    +    go_var env f args
    +      | Just con <- isDataConWorkId_maybe f
    +      = ArgIsCon (DataAlt con) (map (exprSummary env) args)
    +
    +      | Just rhs <- expandUnfolding_maybe (idUnfolding f)
    +      = go (zapSubstEnv env) rhs args
    +
    +      | idArity f > valArgCount args
    +      = ArgIsLam
    +
    +      | otherwise
    +      = ArgNoInfo
    
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Iteration.hs
    =====================================
    @@ -2302,8 +2302,7 @@ rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) cont
     -----------------------------------
     tryInlining :: SimplEnv -> Logger -> OutId -> SimplCont -> SimplM (Maybe OutExpr)
     tryInlining env logger var cont
    -  | Just expr <- callSiteInline logger uf_opts case_depth var active_unf
    -                                lone_variable arg_infos interesting_cont
    +  | Just expr <- callSiteInline logger env var cont
       = do { dump_inline expr cont
            ; return (Just expr) }
     
    @@ -2311,12 +2310,6 @@ tryInlining env logger var cont
       = return Nothing
     
       where
    -    uf_opts    = seUnfoldingOpts env
    -    case_depth = seCaseDepth env
    -    (lone_variable, arg_infos, call_cont) = contArgs cont
    -    interesting_cont = interestingCallContext env call_cont
    -    active_unf       = activeUnfolding (seMode env) var
    -
         log_inlining doc
           = liftIO $ logDumpFile logger (mkDumpStyle alwaysQualify)
                Opt_D_dump_inlinings
    
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Utils.hs
    =====================================
    @@ -24,7 +24,7 @@ module GHC.Core.Opt.Simplify.Utils (
             SimplCont(..), DupFlag(..), FromWhat(..), StaticEnv,
             isSimplified, contIsStop,
             contIsDupable, contResultType, contHoleType, contHoleScaling,
    -        contIsTrivial, contArgs, contIsRhs,
    +        contIsTrivial, contIsRhs,
             countArgs,
             mkBoringStop, mkRhsStop, mkLazyArgStop,
             interestingCallContext,
    @@ -46,9 +46,7 @@ import GHC.Prelude hiding (head, init, last, tail)
     import qualified GHC.Prelude as Partial (head)
     
     import GHC.Core
    -import GHC.Types.Literal ( isLitRubbish )
     import GHC.Core.Opt.Simplify.Env
    --- import GHC.Core.Opt.Simplify.Inline
     import GHC.Core.Opt.Stats ( Tick(..) )
     import qualified GHC.Core.Subst
     import GHC.Core.Ppr
    @@ -558,29 +556,6 @@ countValArgs (CastIt _ cont)                 = countValArgs cont
     countValArgs _                               = 0
     
     -------------------
    -contArgs :: SimplCont -> (Bool, [ArgSummary], SimplCont)
    --- Summarises value args, discards type args and coercions
    --- The returned continuation of the call is only used to
    --- answer questions like "are you interesting?"
    -contArgs cont
    -  | lone cont = (True, [], cont)
    -  | otherwise = go [] cont
    -  where
    -    lone (ApplyToTy  {}) = False  -- See Note [Lone variables] in GHC.Core.Unfold
    -    lone (ApplyToVal {}) = False  -- NB: even a type application or cast
    -    lone (CastIt {})     = False  --     stops it being "lone"
    -    lone _               = True
    -
    -    go args (ApplyToVal { sc_arg = arg, sc_env = se, sc_cont = k })
    -                                        = go (is_interesting arg se : args) k
    -    go args (ApplyToTy { sc_cont = k }) = go args k
    -    go args (CastIt _ k)                = go args k
    -    go args k                           = (False, reverse args, k)
    -
    -    is_interesting arg se = exprSummary se arg
    -       -- Do *not* use short-cutting substitution here
    -       -- because we want to get as much IdInfo as possible
    -
     -- | Describes how the 'SimplCont' will evaluate the hole as a 'SubDemand'.
     -- This can be more insightful than the limited syntactic context that
     -- 'SimplCont' provides, because the 'Stop' constructor might carry a useful
    @@ -593,10 +568,10 @@ contArgs cont
     -- about what to do then and no call sites so far seem to care.
     contEvalContext :: SimplCont -> SubDemand
     contEvalContext k = case k of
    -  (Stop _ _ sd)              -> sd
    -  (TickIt _ k)               -> contEvalContext k
    -  (CastIt _ k)               -> contEvalContext k
    -  ApplyToTy{sc_cont=k}       -> contEvalContext k
    +  Stop _ _ sd          -> sd
    +  TickIt _ k           -> contEvalContext k
    +  CastIt _ k           -> contEvalContext k
    +  ApplyToTy{sc_cont=k} -> contEvalContext k
         --  ApplyToVal{sc_cont=k}      -> mkCalledOnceDmd $ contEvalContext k
         -- Not 100% sure that's correct, . Here's an example:
         --   f (e x) and f :: 
    @@ -638,9 +613,11 @@ mkArgInfo env rule_base fun cont
         vanilla_discounts, arg_discounts :: [Int]
         vanilla_discounts = repeat 0
         arg_discounts = case idUnfolding fun of
    -                        CoreUnfolding {uf_guidance = UnfIfGoodArgs {ug_args = discounts}}
    -                              -> discounts ++ vanilla_discounts
    +                        CoreUnfolding {uf_guidance = UnfIfGoodArgs {ug_args = _discounts}}
    +                              -> {- discounts ++ -} vanilla_discounts
                             _     -> vanilla_discounts
    +         -- ToDo: with the New Plan it's harder to know which arguments
    +         -- attract a discount.  For now, let's just drop this and see.
     
         vanilla_dmds, arg_dmds :: [Demand]
         vanilla_dmds  = repeat topDmd
    @@ -928,118 +905,6 @@ contHasRules cont
         go (StrictBind {})                 = False      -- ??
         go (Stop _ _ _)                    = False
     
    -{- Note [Interesting arguments]
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -An argument is interesting if it deserves a discount for unfoldings
    -with a discount in that argument position.  The idea is to avoid
    -unfolding a function that is applied only to variables that have no
    -unfolding (i.e. they are probably lambda bound): f x y z There is
    -little point in inlining f here.
    -
    -Generally, *values* (like (C a b) and (\x.e)) deserve discounts.  But
    -we must look through lets, eg (let x = e in C a b), because the let will
    -float, exposing the value, if we inline.  That makes it different to
    -exprIsHNF.
    -
    -Before 2009 we said it was interesting if the argument had *any* structure
    -at all; i.e. (hasSomeUnfolding v).  But does too much inlining; see #3016.
    -
    -But we don't regard (f x y) as interesting, unless f is unsaturated.
    -If it's saturated and f hasn't inlined, then it's probably not going
    -to now!
    -
    -Note [Conlike is interesting]
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -Consider
    -        f d = ...((*) d x y)...
    -        ... f (df d')...
    -where df is con-like. Then we'd really like to inline 'f' so that the
    -rule for (*) (df d) can fire.  To do this
    -  a) we give a discount for being an argument of a class-op (eg (*) d)
    -  b) we say that a con-like argument (eg (df d)) is interesting
    --}
    -
    -interestingArg :: SimplEnv -> CoreExpr -> ArgSummary
    --- See Note [Interesting arguments]
    -interestingArg env e = go env 0 e
    -  where
    -    -- n is # value args to which the expression is applied
    -    go env n (Var v)
    -       = case substId env v of
    -           DoneId v'            -> go_var n v'
    -           DoneEx e _           -> go (zapSubstEnv env)             n e
    -           ContEx tvs cvs ids e -> go (setSubstEnv env tvs cvs ids) n e
    -
    -    go _   _ (Lit l)
    -       | isLitRubbish l        = TrivArg -- Leads to unproductive inlining in WWRec, #20035
    -       | otherwise             = ValueArg
    -    go _   _ (Type _)          = TrivArg
    -    go _   _ (Coercion _)      = TrivArg
    -    go env n (App fn (Type _)) = go env n fn
    -    go env n (App fn _)        = go env (n+1) fn
    -    go env n (Tick _ a)        = go env n a
    -    go env n (Cast e _)        = go env n e
    -    go env n (Lam v e)
    -       | isTyVar v             = go env n e
    -       | n>0                   = NonTrivArg     -- (\x.b) e   is NonTriv
    -       | otherwise             = ValueArg
    -    go _ _ (Case {})           = NonTrivArg
    -    go env n (Let b e)         = case go env' n e of
    -                                   ValueArg -> ValueArg
    -                                   _        -> NonTrivArg
    -                               where
    -                                 env' = env `addNewInScopeIds` bindersOf b
    -
    -    go_var n v
    -       | isConLikeId v     = ValueArg   -- Experimenting with 'conlike' rather that
    -                                        --    data constructors here
    -       | idArity v > n     = ValueArg   -- Catches (eg) primops with arity but no unfolding
    -       | n > 0             = NonTrivArg -- Saturated or unknown call
    -       | conlike_unfolding = ValueArg   -- n==0; look for an interesting unfolding
    -                                        -- See Note [Conlike is interesting]
    -       | otherwise         = TrivArg    -- n==0, no useful unfolding
    -       where
    -         conlike_unfolding = isConLikeUnfolding (idUnfolding v)
    -
    -------------------------------
    -idSummary :: SimplEnv -> Id -> ArgSummary
    -idSummary env bndr
    -  = case idUnfolding bndr of
    -      OtherCon cs -> ScrutIsNot cs
    -      DFunUnfolding { df_bndrs = bndrs, df_con = con, df_args = args }
    -        | null bndrs
    -        -> ScrutIsCon (DataAlt con) (map exprSummary args)
    -        | otherwise
    -        -> ScrutNoInfo
    -      CoreUnfolding { uf_tmpl = e }
    -        -> exprSummary e
    -      NoUnfolding   -> ScrutNoInfo
    -      BootUnfolding -> ScrutNoInfo
    -
    -exprSummary :: SimplEnv -> CoreExpr -> ArgSummary
    --- Very simple version of exprIsConApp_maybe
    -exprSummary env e = go e []
    -  where
    -    go (Cast e _) as = go e as
    -    go (Tick _ e) as = go e as
    -    go (Let _ e)  as = go e as
    -    go (App f a)  as = go f (a:as)
    -    go (Lit l)    as = assertPpr (null as) (ppr as) $
    -                       ScrutIsCon (LitAlt l) []
    -    go (Var v)    as = go_var v as
    -    go (Lam b e)  as
    -      | null as = if isRuntimeVar b
    -                  then ScrutIsLam
    -                  else go e []
    -    go _ _ = ScrutNoInfo
    -
    -    go_var v as
    -      | Just con <- isDataConWorkId_maybe v
    -      = ScrutIsCon (DataAlt con) (map (exprSummary env) as)
    -      | Just rhs <- expandUnfolding_maybe (idUnfolding v)
    -      = go rhs as
    -      | otherwise
    -      = ScrutNoInfo
     
     {-
     ************************************************************************
    @@ -1590,7 +1455,7 @@ postInlineUnconditionally env bind_cxt bndr occ_info rhs
     
             -> n_br < 100  -- See Note [Suppress exponential blowup]
     
    -           && smallEnoughToInline uf_opts unfolding     -- Small enough to dup
    +           && smallEnoughToInline env unfolding     -- Small enough to dup
                             -- ToDo: consider discount on smallEnoughToInline if int_cxt is true
                             --
                             -- NB: Do NOT inline arbitrarily big things, even if occ_n_br=1
    @@ -1636,11 +1501,23 @@ postInlineUnconditionally env bind_cxt bndr occ_info rhs
     
       where
         unfolding = idUnfolding bndr
    -    uf_opts   = seUnfoldingOpts env
         phase     = sePhase env
         active    = isActive phase (idInlineActivation bndr)
             -- See Note [pre/postInlineUnconditionally in gentle mode]
     
    +smallEnoughToInline :: SimplEnv -> Unfolding -> Bool
    +smallEnoughToInline env unfolding
    +  | CoreUnfolding {uf_guidance = guidance} <- unfolding
    +  = case guidance of
    +       UnfIfGoodArgs {ug_tree = et} -> exprTreeWillInline limit et
    +       UnfWhen {}                   -> True
    +       UnfNever                     -> False
    +  | otherwise
    +  = False
    +  where
    +    uf_opts = seUnfoldingOpts env
    +    limit   = unfoldingUseThreshold uf_opts
    +
     {- Note [Inline small things to avoid creating a thunk]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     The point of examining occ_info here is that for *non-values* that
    
    
    =====================================
    compiler/GHC/Core/Opt/SpecConstr.hs
    =====================================
    @@ -32,7 +32,6 @@ import GHC.Core
     import GHC.Core.Subst
     import GHC.Core.Utils
     import GHC.Core.Unfold
    -import GHC.Core.Opt.Simplify.Inline
     import GHC.Core.FVs     ( exprsFreeVarsList, exprFreeVars )
     import GHC.Core.Opt.Monad
     import GHC.Core.Opt.WorkWrap.Utils
    
    
    =====================================
    compiler/GHC/Core/Ppr.hs
    =====================================
    @@ -634,11 +634,11 @@ instance Outputable ExprTree where
     
     instance Outputable CaseTree where
       ppr (ScrutOf x n)   = ppr x <> colon <> int n
    -  ppr (CaseOf x alts) = text "case" <+> ppr x
    -                        <+> brackets (sep (map ppr alts))
    +  ppr (CaseOf x b alts) = sep [ text "case" <+> ppr x <+> ppr b
    +                              , nest 2 $ braces $ sep $ map ppr alts ]
     
     instance Outputable AltTree where
    -  ppr (AltTree con bs rhs) = ppr con <+> ppr bs <+> text "->" <+> ppr rhs
    +  ppr (AltTree con bs rhs) = sep [ppr con <+> ppr bs <+> text "->", nest 2 (ppr rhs)]
     
     instance Outputable Unfolding where
       ppr NoUnfolding                = text "No unfolding"
    
    
    =====================================
    compiler/GHC/Core/Seq.hs
    =====================================
    @@ -132,7 +132,7 @@ seqET (SizeIs { et_size = size, et_cases = cases, et_ret = ret })
     
     seqCT :: CaseTree -> ()
     seqCT (ScrutOf x i) = x `seq` i `seq` ()
    -seqCT (CaseOf x alts) = x `seq` seqList seqAT alts
    +seqCT (CaseOf x y alts) = x `seq` y `seq` seqList seqAT alts
     
     seqAT :: AltTree -> ()
     seqAT (AltTree con bs e) = con `seq` seqBndrs bs `seq` seqET e
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -22,8 +22,10 @@ module GHC.Core.Unfold (
             Unfolding, UnfoldingGuidance,   -- Abstract types
     
             ExprTree, exprTree, exprTreeSize,
    -        ArgSummary(..), CallCtxt(..),
    -        Size, leqSize, addSizeN,
    +        exprTreeWillInline, couldBeSmallEnoughToInline,
    +        ArgSummary(..), CallCtxt(..), hasArgInfo,
    +        Size, leqSize, addSizeN, adjustSize,
    +        InlineContext(..),
     
             UnfoldingOpts (..), defaultUnfoldingOpts,
             updateCreationThreshold, updateUseThreshold,
    @@ -56,6 +58,7 @@ import GHC.Builtin.PrimOps
     
     import GHC.Utils.Misc
     import GHC.Utils.Outputable
    +import GHC.Utils.Panic
     
     import GHC.Data.Bag
     
    @@ -164,10 +167,14 @@ updateReportPrefix n opts = opts { unfoldingReportPrefix = n }
     ********************************************************************* -}
     
     data ArgSummary = ArgNoInfo
    -                | ArgIsCon AltCon [ArgSummary]
    +                | ArgIsCon AltCon [ArgSummary]  -- Includes type args
                     | ArgIsNot [AltCon]
                     | ArgIsLam
     
    +hasArgInfo :: ArgSummary -> Bool
    +hasArgInfo ArgNoInfo = False
    +hasArgInfo _         = True
    +
     instance Outputable ArgSummary where
       ppr ArgNoInfo       = text "ArgNoInfo"
       ppr ArgIsLam        = text "ArgIsLam"
    @@ -265,10 +272,11 @@ calcUnfoldingGuidance opts is_top_bottoming (Tick t expr)
       | not (tickishIsCode t)  -- non-code ticks don't matter for unfolding
       = calcUnfoldingGuidance opts is_top_bottoming expr
     calcUnfoldingGuidance opts is_top_bottoming expr
    -  = case exprTree opts bOMB_OUT_SIZE (mkVarSet val_bndrs) body of
    +  = case exprTree opts val_bndrs body of
           TooBig -> UnfNever
    -      et@(SizeIs { et_size = size })
    -        | uncondInline expr n_val_bndrs size
    +      et@(SizeIs { et_size = size, et_cases = cases })
    +        | not (any is_case cases)
    +        , uncondInline expr n_val_bndrs size
             -> UnfWhen { ug_unsat_ok  = unSaturatedOk
                        , ug_boring_ok =  boringCxtOk
                        , ug_arity     = n_val_bndrs }   -- Note [INLINE for small functions]
    @@ -281,11 +289,28 @@ calcUnfoldingGuidance opts is_top_bottoming expr
     
       where
         (bndrs, body) = collectBinders expr
    -    bOMB_OUT_SIZE = unfoldingCreationThreshold opts
    -           -- Bomb out if size gets bigger than this
         val_bndrs   = filter isId bndrs
         n_val_bndrs = length val_bndrs
     
    +    is_case (CaseOf {})  = True
    +    is_case (ScrutOf {}) = False
    +
    +{- We use 'couldBeSmallEnoughToInline' to avoid exporting inlinings that
    +   we ``couldn't possibly use'' on the other side.  Can be overridden w/
    +   flaggery.  Just the same as smallEnoughToInline, except that it has no
    +   actual arguments.
    +-}
    +
    +couldBeSmallEnoughToInline :: UnfoldingOpts -> Int -> CoreExpr -> Bool
    +couldBeSmallEnoughToInline opts threshold rhs
    +  = exprTreeWillInline threshold $
    +    exprTree opts [] body
    +  where
    +    (_, body) = collectBinders rhs
    +
    +----------------
    +
    +
     {- Note [Inline unsafeCoerce]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     We really want to inline unsafeCoerce, even when applied to boring
    @@ -439,56 +464,99 @@ uncondInline rhs arity size
     *                                                                      *
     ********************************************************************* -}
     
    -exprTree :: UnfoldingOpts
    -         -> Int             -- Bomb out if it gets bigger than this
    -         -> VarSet          -- Record scrutiny of these variables
    -         -> CoreExpr
    -         -> ExprTree
    +{- Note [Constructing an ExprTree]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +We maintain:
    +* avs: argument variables, or variables bound by a case on an
    +       argument variable.
    +
    +  We record a CaseOf or ScrutOf for the `avs`
    +
    +* lvs: variables bound by lambda and lets in the body; and by
    +       case expressions that scrutinise one of the `lvs`, or
    +       a non-variable.
    +
    +  We never record a CaseOf or ScrutOf for one of the `lvs`.
    +
    +* We record a CaseOf, but not ScrutOf, for other variables; that is,
    +  variables free in the entire function definition.  For example:
    +        let  f x = case y of
    +                     A -> True
    +                     B -> 
    +        in
    +        case y of
    +          A -> ....f 3....f 4....
    +          B -> blah
    +  At the calls site of `f` we know that the free var `y` is equal to A, so
    +  f should definitely inline.
    +
    +  But consider instead this example
    +        let f x = y x 3 
    +        in  ...(f 3)...
    +  There nothing we will learn about the free `y` that will make the inining of
    +  `f` more attractive.  Hence we don't record ScrutOf for y.
    +
    +  This is IMPORTANT, because even a call like (reverse xs) would otherwise record
    +  a ScrutOf for `reverse` which is very silly.
    +-}
    +
    +type ETVars = (VarSet,VarSet)  -- (avs, lvs)
    +              -- See Note [Constructing an ExprTree]
     
    +exprTree :: UnfoldingOpts -> [Var] -> CoreExpr -> ExprTree
     -- Note [Computing the size of an expression]
     
    --- Forcing bOMB_OUT_SIZE early prevents repeated
    --- unboxing of the Int argument.
    -exprTree opts !bOMB_OUT_SIZE svars expr
    -  = size_up expr
    +exprTree opts args expr
    +  = go (mkVarSet args, emptyVarSet) expr
       where
    +    !bOMB_OUT_SIZE = unfoldingCreationThreshold opts
    +       -- Bomb out if size gets bigger than this
    +       -- Forcing bOMB_OUT_SIZE early prevents repeated
    +       -- unboxing of the Int argument.
    +
         et_add     = etAdd bOMB_OUT_SIZE
         et_add_alt = etAddAlt bOMB_OUT_SIZE
     
    -    size_up :: CoreExpr -> ExprTree
    -    size_up (Cast e _)   = size_up e
    -    size_up (Tick _ e)   = size_up e
    -    size_up (Type _)     = exprTreeN 0
    -    size_up (Coercion _) = exprTreeN 0
    -    size_up (Lit lit)    = exprTreeN (litSize lit)
    +    go :: ETVars -> CoreExpr -> ExprTree
    +          -- (avs,lvs): see Note [Constructing an ExprTree]
    +    go vs (Cast e _)   = go vs e
    +    go vs (Tick _ e)   = go vs e
    +    go _  (Type _)     = exprTreeN 0
    +    go _  (Coercion _) = exprTreeN 0
    +    go _  (Lit lit)    = exprTreeN (litSize lit)
     
    -    size_up (Lam b e)
    -      | isId b, not (id_is_free b) = size_up e `et_add` lamSize opts
    -      | otherwise                  = size_up e
    +    go vs (Lam b e)
    +      | isId b, not (id_is_free b) = go vs' e `et_add` lamSize opts
    +      | otherwise                  = go vs' e
    +      where
    +        vs' = vs `add_lv` b
     
    -    size_up (Let (NonRec binder rhs) body)
    -      = size_up_bind (binder, rhs)  `et_add` size_up body
    +    go vs (Let (NonRec binder rhs) body)
    +      = go_bind vs (binder, rhs)  `et_add`
    +        go (vs `add_lv` binder) body
     
    -    size_up (Let (Rec pairs) body)
    -      = foldr (et_add . size_up_bind) (size_up body) pairs
    +    go vs (Let (Rec pairs) body)
    +      = foldr (et_add . go_bind vs') (go vs' body) pairs
    +      where
    +        vs' = vs `add_lvs` map fst pairs
     
    -    size_up e@(App {}) = size_up_app e []
    +    go vs e@(App {}) = go_app vs e []
     
    -    size_up (Var f) | id_is_free f = exprTreeN 0
    +    go vs (Var f) | id_is_free f = exprTreeN 0
                         -- Use calLSize to ensure we get constructor
                         -- discounts even on nullary constructors
    -                    | otherwise    = callTree opts svars f []
    +                    | otherwise  = callTree opts vs f []
     
    -    size_up (Case e _ _ alts) = size_up_case e alts
    +    go vs (Case e b _ alts) = go_case vs e b alts
     
         -----------------------------
    -    size_up_bind (bndr, rhs)
    +    go_bind vs (bndr, rhs)
           | JoinPoint join_arity <- idJoinPointHood bndr
    -      , (_bndrs, body) <- collectNBinders join_arity rhs
    +      , (bndrs, body) <- collectNBinders join_arity rhs
                               -- Skip arguments to join point
    -      = size_up body
    +      = go (vs `add_lvs` bndrs) body
           | otherwise
    -      = size_up_alloc bndr `etAddN` size_up rhs
    +      = size_up_alloc bndr `etAddN` go vs rhs
     
         -- Cost to allocate binding with given binder
         size_up_alloc bndr
    @@ -501,94 +569,109 @@ exprTree opts !bOMB_OUT_SIZE svars expr
     
         -----------------------------
         -- size_up_app is used when there's ONE OR MORE value args
    -    size_up_app :: CoreExpr -> [CoreExpr] -> ExprTree
    +    go_app :: ETVars -> CoreExpr -> [CoreExpr] -> ExprTree
                        -- args are the non-void value args
    -    size_up_app (App fun arg) args
    -                 | arg_is_free arg = size_up_app fun args
    -                 | otherwise       = size_up arg  `et_add`
    -                                     size_up_app fun (arg:args)
    -    size_up_app (Var fun)     args = callTree opts svars fun args
    -    size_up_app (Tick _ expr) args = size_up_app expr args
    -    size_up_app (Cast expr _) args = size_up_app expr args
    -    size_up_app other         args = vanillaCallSize (length args) `etAddN`
    -                                     size_up other
    +    go_app vs (App fun arg) args
    +               | arg_is_free arg = go_app vs fun args
    +               | otherwise       = go vs arg `et_add`
    +                                   go_app vs fun (arg:args)
    +    go_app vs (Var fun)     args = callTree opts vs fun args
    +    go_app vs (Tick _ expr) args = go_app vs expr args
    +    go_app vs (Cast expr _) args = go_app vs expr args
    +    go_app vs other         args = vanillaCallSize (length args) `etAddN`
    +                                   go vs other
            -- if the lhs is not an App or a Var, or an invisible thing like a
            -- Tick or Cast, then we should charge for a complete call plus the
            -- size of the lhs itself.
     
         -----------------------------
    -    size_up_case scrut [] = size_up scrut
    +    -- Empty case
    +    go_case vs scrut _ [] = go vs scrut
              -- case e of {} never returns, so take size of scrutinee
     
    -    size_up_case scrut alts                    -- Now alts is non-empty
    -        | Just v <- interesting_id svars scrut -- We are scrutinising an argument variable
    -        = size_up scrut `et_add`
    -          etZero { et_cases = unitBag (CaseOf v (map alt_alt_tree alts)) }
    +    -- Record a CaseOf
    +    go_case vs@(avs,lvs) scrut b alts                 -- Now alts is non-empty
    +      | Just v <- recordCaseOf vs scrut
    +      = -- pprTrace "recordCaseOf" (ppr v $$ ppr lvs $$ ppr scrut $$ ppr alts) $
    +        go vs scrut `et_add`
    +        etZero { et_cases = unitBag (CaseOf v b (map (alt_alt_tree v) alts)) }
    +      where
    +        alt_alt_tree :: Id -> Alt Var -> AltTree
    +        alt_alt_tree v (Alt con bs rhs)
    +          = AltTree con bs (10 `etAddN` go (add_alt_bndrs v bs) rhs)
    +
    +        add_alt_bndrs v bs
    +          | v `elemVarSet` avs = (avs `extendVarSetList` (b:bs), lvs)
    +                                 -- Don't forget to add the case binder, b
    +          | otherwise = vs
    +
    +    -- Don't record a CaseOf
    +    go_case vs scrut b alts    -- alts is non-empty
    +      = caseSize scrut alts `etAddN`   -- A bit odd that this is only in one branch
    +        go vs scrut         `et_add`
    +        foldr1 et_add_alt (map alt_expr_tree alts)
    +      where
    +        alt_expr_tree :: Alt Var -> ExprTree
    +        alt_expr_tree (Alt _con bs rhs)
    +          = 10 `etAddN` go (vs `add_lvs` (b:bs)) rhs
    +            -- Don't charge for bndrs, so that wrappers look cheap
    +            -- (See comments about wrappers with Case)
    +            -- Don't forget to add the case binder, b, to lvs.
    +            --
    +            -- IMPORTANT: *do* charge 10 for the alternative, else we
    +            -- find that giant case nests are treated as practically free
    +            -- A good example is Foreign.C.Error.errnoToIOError
    +
    +caseSize :: CoreExpr -> [CoreAlt] -> Int
    +caseSize scrut alts
    +  | is_inline_scrut scrut, lengthAtMost alts 1 = -10
    +  | otherwise                                  = 0
    +              -- Normally we don't charge for the case itself, but
    +              -- we charge one per alternative (see size_up_alt,
    +              -- below) to account for the cost of the info table
    +              -- and comparisons.
    +              --
    +              -- However, in certain cases (see is_inline_scrut
    +              -- below), no code is generated for the case unless
    +              -- there are multiple alts.  In these cases we
    +              -- subtract one, making the first alt free.
    +              -- e.g. case x# +# y# of _ -> ...   should cost 1
    +              --      case touch# x# of _ -> ...  should cost 0
    +              -- (see #4978)
    +              --
    +              -- I would like to not have the "lengthAtMost alts 1"
    +              -- condition above, but without that some programs got worse
    +              -- (spectral/hartel/event and spectral/para).  I don't fully
    +              -- understand why. (SDM 24/5/11)
     
    +              -- Unboxed variables, inline primops and unsafe foreign calls
    +              -- are all "inline" things:
    +  where
    +    is_inline_scrut (Var v) =
    +      isUnliftedType (idType v)
    +        -- isUnliftedType is OK here: scrutinees have a fixed RuntimeRep (search for FRRCase)
    +    is_inline_scrut scrut
    +        | (Var f, _) <- collectArgs scrut
    +          = case idDetails f of
    +              FCallId fc    -> not (isSafeForeignCall fc)
    +              PrimOpId op _ -> not (primOpOutOfLine op)
    +              _other        -> False
             | otherwise
    -        = case_size     `etAddN`   -- A bit odd that this is only in one branch
    -          size_up scrut `et_add`
    -          foldr1 et_add_alt (map alt_expr_tree alts)
    -
    -        where
    -          alt_alt_tree :: Alt Var -> AltTree
    -          alt_alt_tree (Alt con bs rhs)
    -            = AltTree con bs (exprTree opts bOMB_OUT_SIZE svars' rhs)
    -            where
    -              svars' = svars `extendVarSetList` bs
    -
    -          alt_expr_tree :: Alt Var -> ExprTree
    -          alt_expr_tree (Alt _con _bndrs rhs) = 10 `etAddN` size_up rhs
    -              -- Don't charge for bndrs, so that wrappers look cheap
    -              -- (See comments about wrappers with Case)
    -              --
    -              -- IMPORTANT: *do* charge 10 for the alternative, else we
    -              -- find that giant case nests are treated as practically free
    -              -- A good example is Foreign.C.Error.errnoToIOError
    -
    -          case_size
    -           | is_inline_scrut scrut, lengthAtMost alts 1 = -10
    -           | otherwise                                  = 0
    -                -- Normally we don't charge for the case itself, but
    -                -- we charge one per alternative (see size_up_alt,
    -                -- below) to account for the cost of the info table
    -                -- and comparisons.
    -                --
    -                -- However, in certain cases (see is_inline_scrut
    -                -- below), no code is generated for the case unless
    -                -- there are multiple alts.  In these cases we
    -                -- subtract one, making the first alt free.
    -                -- e.g. case x# +# y# of _ -> ...   should cost 1
    -                --      case touch# x# of _ -> ...  should cost 0
    -                -- (see #4978)
    -                --
    -                -- I would like to not have the "lengthAtMost alts 1"
    -                -- condition above, but without that some programs got worse
    -                -- (spectral/hartel/event and spectral/para).  I don't fully
    -                -- understand why. (SDM 24/5/11)
    -
    -                -- Unboxed variables, inline primops and unsafe foreign calls
    -                -- are all "inline" things:
    -
    -          is_inline_scrut (Var v) =
    -            isUnliftedType (idType v)
    -              -- isUnliftedType is OK here: scrutinees have a fixed RuntimeRep (search for FRRCase)
    -          is_inline_scrut scrut
    -              | (Var f, _) <- collectArgs scrut
    -                = case idDetails f of
    -                    FCallId fc    -> not (isSafeForeignCall fc)
    -                    PrimOpId op _ -> not (primOpOutOfLine op)
    -                    _other        -> False
    -              | otherwise
    -                = False
    -    ------------
    -
    -interesting_id :: VarSet -> CoreExpr -> Maybe Id
    -interesting_id svars (Var v)
    -  | v `elemVarSet` svars  = Just v
    -interesting_id svars (Tick _ e) = interesting_id svars e
    -interesting_id svars (Cast e _) = interesting_id svars e
    -interesting_id _     _          = Nothing
    +          = False
    +
    +add_lv :: ETVars -> Var -> ETVars
    +add_lv (avs,lvs) b = (avs, lvs `extendVarSet` b)
    +
    +add_lvs :: ETVars -> [Var] -> ETVars
    +add_lvs (avs,lvs) bs = (avs, lvs `extendVarSetList` bs)
    +
    +recordCaseOf :: ETVars -> CoreExpr -> Maybe Id
    +recordCaseOf (_,lvs) (Var v)
    +     | v `elemVarSet` lvs  = Nothing
    +     | otherwise           = Just v
    +recordCaseOf vs (Tick _ e) = recordCaseOf vs e
    +recordCaseOf vs (Cast e _) = recordCaseOf vs e
    +recordCaseOf _     _       = Nothing
     
     arg_is_free :: CoreExpr -> Bool
     -- "free" means we don't charge for this
    @@ -620,15 +703,15 @@ litSize _other = 0    -- Must match size of nullary constructors
                           --            (eg via case binding)
     
     ----------------------------
    -callTree :: UnfoldingOpts -> VarSet -> Id -> [CoreExpr] -> ExprTree
    -callTree opts svars fun val_args
    +callTree :: UnfoldingOpts -> ETVars -> Id -> [CoreExpr] -> ExprTree
    +callTree opts vs fun val_args
       = case idDetails fun of
           FCallId _        -> exprTreeN (vanillaCallSize n_val_args)
           JoinId {}        -> exprTreeN (jumpSize        n_val_args)
           PrimOpId op _    -> exprTreeN (primOpSize op   n_val_args)
           DataConWorkId dc -> conSize dc n_val_args
    -      ClassOpId {}     -> classOpSize opts svars val_args
    -      _                -> funSize opts svars fun n_val_args
    +      ClassOpId {}     -> classOpSize opts vs fun val_args
    +      _                -> funSize opts vs fun n_val_args
       where
         n_val_args = length val_args
     
    @@ -646,14 +729,15 @@ jumpSize n_val_args = 2 * (1 + n_val_args)
       -- spectral/puzzle. TODO Perhaps adjusting the default threshold would be a
       -- better solution?
     
    -classOpSize :: UnfoldingOpts -> VarSet -> [CoreExpr] -> ExprTree
    +classOpSize :: UnfoldingOpts -> ETVars -> Id -> [CoreExpr] -> ExprTree
     -- See Note [Conlike is interesting]
    -classOpSize _ _ []
    +classOpSize _ _ _ []
       = etZero
    -classOpSize opts svars val_args
    +classOpSize opts vs fn val_args
       | arg1 : _ <- val_args
    -  , Just dict <- interesting_id svars arg1
    -  = vanillaCallSize (length val_args) `etAddN`
    +  , Just dict <- recordCaseOf vs arg1
    +  = warnPprTrace (not (isId dict)) "classOpSize" (ppr fn <+> ppr val_args) $
    +    vanillaCallSize (length val_args) `etAddN`
         etZero { et_cases = unitBag (ScrutOf dict (unfoldingDictDiscount opts)) }
                -- If the class op is scrutinising a lambda bound dictionary then
                -- give it a discount, to encourage the inlining of this function
    @@ -661,10 +745,10 @@ classOpSize opts svars val_args
       | otherwise
       = exprTreeN (vanillaCallSize (length val_args))
     
    -funSize :: UnfoldingOpts -> VarSet -> Id -> Int -> ExprTree
    +funSize :: UnfoldingOpts -> ETVars -> Id -> Int -> ExprTree
     -- Size for function calls that are not constructors or primops
     -- Note [Function applications]
    -funSize opts svars fun n_val_args
    +funSize opts (avs,_) fun n_val_args
       | fun `hasKey` buildIdKey   = etZero  -- Wwant to inline applications of build/augment
       | fun `hasKey` augmentIdKey = etZero  -- so we give size zero to the whole call
       | otherwise = SizeIs { et_size  = size
    @@ -677,7 +761,7 @@ funSize opts svars fun n_val_args
         -- Discount if this is an interesting variable, and is applied
         -- Discount is enough to make the application free (but not negative!)
         --  See Note [Function and non-function discounts]
    -    cases | n_val_args > 0, fun `elemVarSet` svars
    +    cases | n_val_args > 0, fun `elemVarSet` avs
               = unitBag (ScrutOf fun size)
               | otherwise
               = emptyBag
    @@ -920,6 +1004,10 @@ etZero = SizeIs { et_size = 0, et_cases = emptyBag, et_ret = 0 }
     
     data Size = STooBig | SSize {-# UNPACK #-} !Int
     
    +instance Outputable Size where
    +  ppr STooBig = text "STooBig"
    +  ppr (SSize n) = int n
    +
     sizeN :: Int -> Size
     sizeN n = SSize n
     
    @@ -931,6 +1019,10 @@ addSizeN :: Int -> Size -> Size
     addSizeN n1 (SSize n2) = SSize (n1+n2)
     addSizeN _  STooBig    = STooBig
     
    +adjustSize :: (Int -> Int) -> Size -> Size
    +adjustSize f (SSize n) = SSize (f n)
    +adjustSize _ STooBig   = STooBig
    +
     leqSize :: Size -> Int -> Bool
     leqSize STooBig   _ = False
     leqSize (SSize n) m = n <= m
    @@ -944,6 +1036,27 @@ data InlineContext
          }
     
     -------------------------
    +exprTreeWillInline :: Int -> ExprTree -> Bool
    +-- (cheapExprTreeSize limit et) takes an upper bound `n` on the
    +-- size of et; i.e. without discounts etc.
    +-- Return True if (s <- limit), False otherwise
    +-- Bales out early in the False case
    +exprTreeWillInline limit et
    +  = go et (\n -> n <= limit) 0
    +  where
    +    go :: ExprTree -> (Int -> Bool) -> Int -> Bool
    +    go _      _ n | n > limit = False
    +    go TooBig _ _             = False
    +    go (SizeIs { et_size = size, et_cases = cases }) k n
    +      = foldr go_ct k cases (n+size)
    +
    +    go_ct :: CaseTree -> (Int -> Bool) -> Int -> Bool
    +    go_ct (ScrutOf {})      k n = k n
    +    go_ct (CaseOf _ _ alts) k n = foldr go_alt k alts n
    +
    +    go_alt :: AltTree -> (Int -> Bool) -> Int -> Bool
    +    go_alt (AltTree _ _ et) k n = go et k (n+10)
    +
     exprTreeSize :: InlineContext -> ExprTree -> Size
     exprTreeSize _    TooBig = STooBig
     exprTreeSize !ic (SizeIs { et_size  = size
    @@ -963,16 +1076,18 @@ caseTreeSize ic (ScrutOf bndr disc)
           ArgIsLam    -> sizeN (-disc)  -- Apply discount
           ArgIsCon {} -> sizeN (-disc)  -- Apply discount
     
    -caseTreeSize ic (CaseOf var alts)
    -  = case lookupBndr ic var of
    +caseTreeSize ic (CaseOf scrut_var case_bndr alts)
    +  = case lookupBndr ic scrut_var of
           ArgNoInfo     -> keptCaseSize ic alts
           ArgIsLam      -> keptCaseSize ic alts
           ArgIsNot cons -> keptCaseSize ic (trim_alts cons alts)
    -      ArgIsCon con args
    +      arg_summ@(ArgIsCon con args)
              | Just (AltTree _ bs rhs) <- find_alt con alts
    -         , let ic' = ic { ic_bound = ic_bound ic `extendVarEnvList`
    -                                     (bs `zip` args) }
    -                     -- In DEFAULT case, bs is empty, so extend is a no-op
    +         , let new_summaries :: [(Var,ArgSummary)]
    +               new_summaries = (case_bndr,arg_summ) : bs `zip` args
    +                  -- Don't forget to add a summary for the case binder!
    +               ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
    +                     -- In DEFAULT case, bs is empty, so extending is a no-op
              -> exprTreeSize ic' rhs
              | otherwise  -- Happens for empty alternatives
              -> keptCaseSize ic alts
    @@ -1002,17 +1117,11 @@ keptCaseSize ic alts
         -- If there are no alternatives (case e of {}), we get just the size of the scrutinee
       where
         size_alt :: AltTree -> Size
    -    size_alt (AltTree _ _ rhs) = sizeN 10 `addSize` exprTreeSize ic rhs
    -        -- Add 10 for each alternative
    -        -- Don't charge for args, so that wrappers look cheap
    -        -- (See comments about wrappers with Case)
    -        --
    -        -- IMPORTANT: *do* charge 1 for the alternative, else we
    -        -- find that giant case nests are treated as practically free
    -        -- A good example is Foreign.C.Error.errnoToIOError
    -
    -lookupBndr :: InlineContext -> Id -> ArgSummary
    +    size_alt (AltTree _ _ rhs) = exprTreeSize ic rhs
    +        -- Cost for the alternative is already in `rhs`
    +
    +lookupBndr :: HasDebugCallStack => InlineContext -> Id -> ArgSummary
     lookupBndr (IC { ic_bound = bound_env, ic_free = lookup_free }) var
    -  | Just info <- lookupVarEnv bound_env var = info
    +  | Just info <- assertPpr (isId var) (ppr var) $
    +                 lookupVarEnv bound_env var = info
       | otherwise                               = lookup_free var
    -
    
    
    =====================================
    compiler/GHC/Core/Unfold/Make.hs
    =====================================
    @@ -376,8 +376,8 @@ certainlyWillInline opts fn_info rhs'
                  UnfNever   -> Nothing
                  UnfWhen {} -> Just (fn_unf { uf_src = src', uf_tmpl = tmpl' })
                                  -- INLINE functions have UnfWhen
    -             UnfIfGoodArgs { ug_size = size, ug_args = args }
    -                        -> do_cunf size args src' tmpl'
    +             UnfIfGoodArgs { ug_args = args, ug_tree = tree }
    +                        -> do_cunf args tree src' tmpl'
             where
               src' | isCompulsorySource src = src  -- Do not change InlineCompulsory!
                    | otherwise              = StableSystemSrc
    @@ -396,19 +396,20 @@ certainlyWillInline opts fn_info rhs'
         noinline = isNoInlinePragma (inlinePragInfo fn_info)
         fn_unf   = unfoldingInfo fn_info -- NB: loop-breakers never inline
     
    -        -- The UnfIfGoodArgs case seems important.  If we w/w small functions
    -        -- binary sizes go up by 10%!  (This is with SplitObjs.)
    -        -- I'm not totally sure why.
    -        -- INLINABLE functions come via this path
    -        --    See Note [certainlyWillInline: INLINABLE]
    -    do_cunf size args src' tmpl'
    +    -- The UnfIfGoodArgs case seems important.  If we w/w small functions
    +    -- binary sizes go up by 10%!  (This is with SplitObjs.)
    +    -- I'm not totally sure why.
    +    -- INLINABLE functions come via this path
    +    --    See Note [certainlyWillInline: INLINABLE]
    +    do_cunf args tree src' tmpl'
           | arityInfo fn_info > 0  -- See Note [certainlyWillInline: be careful of thunks]
           , not (isDeadEndSig (dmdSigInfo fn_info))
                   -- Do not unconditionally inline a bottoming functions even if
                   -- it seems smallish. We've carefully lifted it out to top level,
                   -- so we don't want to re-inline it.
           , let unf_arity = length args
    -      , size - (10 * (unf_arity + 1)) <= unfoldingUseThreshold opts
    +            limit = unfoldingUseThreshold opts + (10 * (unf_arity + 1))
    +      , exprTreeWillInline limit tree
           = Just (fn_unf { uf_src      = src'
                          , uf_tmpl     = tmpl'
                          , uf_guidance = UnfWhen { ug_arity     = unf_arity
    
    
    =====================================
    compiler/GHC/Driver/Config/Core/Opt/Simplify.hs
    =====================================
    @@ -19,15 +19,17 @@ import GHC.Driver.Config.Core.Rules ( initRuleOpts )
     import GHC.Driver.Config.Core.Opt.Arity ( initArityOpts )
     import GHC.Driver.DynFlags ( DynFlags(..), GeneralFlag(..), gopt )
     
    -import GHC.Runtime.Context ( InteractiveContext(..) )
    +import GHC.Runtime.Context ( InteractiveContext(..), icInteractiveModule )
     
     import GHC.Types.Basic ( CompilerPhase(..) )
     import GHC.Types.Var ( Var )
     
    +import GHC.Unit.Types( Module )
    +
     initSimplifyExprOpts :: DynFlags -> InteractiveContext -> SimplifyExprOpts
     initSimplifyExprOpts dflags ic = SimplifyExprOpts
       { se_fam_inst = snd $ ic_instances ic
    -  , se_mode = (initSimplMode dflags InitialPhase "GHCi")
    +  , se_mode = (initSimplMode dflags mod InitialPhase "GHCi")
         { sm_inline = False
           -- Do not do any inlining, in case we expose some
           -- unboxed tuple stuff that confuses the bytecode
    @@ -38,6 +40,8 @@ initSimplifyExprOpts dflags ic = SimplifyExprOpts
         , te_tick_factor = simplTickFactor dflags
         }
       }
    +  where
    +    mod = icInteractiveModule ic
     
     initSimplifyOpts :: DynFlags -> [Var] -> Int -> SimplMode -> RuleBase -> SimplifyOpts
     initSimplifyOpts dflags extra_vars iterations mode hpt_rule_base = let
    @@ -56,9 +60,10 @@ initSimplifyOpts dflags extra_vars iterations mode hpt_rule_base = let
         }
       in opts
     
    -initSimplMode :: DynFlags -> CompilerPhase -> String -> SimplMode
    -initSimplMode dflags phase name = SimplMode
    -  { sm_names = [name]
    +initSimplMode :: DynFlags -> Module -> CompilerPhase -> String -> SimplMode
    +initSimplMode dflags mod phase name = SimplMode
    +  { sm_module = mod
    +  , sm_names = [name]
       , sm_phase = phase
       , sm_rules = gopt Opt_EnableRewriteRules dflags
       , sm_eta_expand = gopt Opt_DoLambdaEtaExpansion dflags
    @@ -76,8 +81,8 @@ initSimplMode dflags phase name = SimplMode
       , sm_co_opt_opts = initOptCoercionOpts dflags
       }
     
    -initGentleSimplMode :: DynFlags -> SimplMode
    -initGentleSimplMode dflags = (initSimplMode dflags InitialPhase "Gentle")
    +initGentleSimplMode :: DynFlags -> Module -> SimplMode
    +initGentleSimplMode dflags mod = (initSimplMode dflags mod InitialPhase "Gentle")
       { -- Don't do case-of-case transformations.
         -- This makes full laziness work better
         sm_case_case = False
    
    
    =====================================
    compiler/GHC/Types/Id.hs
    =====================================
    @@ -752,7 +752,7 @@ idTagSig_maybe = tagSig . idInfo
     -- loop breaker. See 'unfoldingInfo'.
     --
     -- If you really want the unfolding of a strong loopbreaker, call 'realIdUnfolding'.
    -idUnfolding :: IdUnfoldingFun
    +idUnfolding :: HasDebugCallStack => IdUnfoldingFun
     idUnfolding id = unfoldingInfo (idInfo id)
     
     noUnfoldingFun :: IdUnfoldingFun
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97fac8936b424f47b3687f542c8485cf2d39d7b5
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97fac8936b424f47b3687f542c8485cf2d39d7b5
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 22 22:05:47 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Sun, 22 Oct 2023 18:05:47 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Wibbles
    Message-ID: <65359cbb583d6_1f7b0ddb16fe01539f4@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    f5fbeeb2 by Simon Peyton Jones at 2023-10-22T23:05:29+01:00
    Wibbles
    
    - - - - -
    
    
    4 changed files:
    
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Opt/Simplify/Utils.hs
    - compiler/GHC/Core/Unfold.hs
    - compiler/GHC/Core/Unfold/Make.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -10,7 +10,7 @@ This module contains inlining logic used by the simplifier.
     
     module GHC.Core.Opt.Simplify.Inline (
             -- * The smart inlining decisions are made by callSiteInline
    -        callSiteInline, CallCtxt(..),
    +        callSiteInline,
     
             exprSummary
         ) where
    @@ -40,7 +40,7 @@ import Data.List (isPrefixOf)
     {-
     ************************************************************************
     *                                                                      *
    -\subsection{callSiteInline}
    +                  callSiteInline
     *                                                                      *
     ************************************************************************
     
    @@ -510,55 +510,14 @@ This kind of thing can occur if you have
             foo = let x = e in (x,x)
     
     which Roman did.
    -
    -
     -}
     
    -{-
    -computeDiscount :: [Int] -> Int -> [ArgSummary] -> CallCtxt
    -                -> Int
    -computeDiscount arg_discounts res_discount arg_infos cont_info
    -
    -  = 10          -- Discount of 10 because the result replaces the call
    -                -- so we count 10 for the function itself
    -
    -    + 10 * length actual_arg_discounts
    -               -- Discount of 10 for each arg supplied,
    -               -- because the result replaces the call
    -
    -    + total_arg_discount + res_discount'
    -  where
    -    actual_arg_discounts = zipWith mk_arg_discount arg_discounts arg_infos
    -    total_arg_discount   = sum actual_arg_discounts
    -
    -    mk_arg_discount _        TrivArg    = 0
    -    mk_arg_discount _        NonTrivArg = 10
    -    mk_arg_discount discount ValueArg   = discount
     
    -    res_discount'
    -      | LT <- arg_discounts `compareLength` arg_infos
    -      = res_discount   -- Over-saturated
    -      | otherwise
    -      = case cont_info of
    -           BoringCtxt  -> 0
    -           CaseCtxt    -> res_discount  -- Presumably a constructor
    -           ValAppCtxt  -> res_discount  -- Presumably a function
    -           _           -> 40 `min` res_discount
    -                -- ToDo: this 40 `min` res_discount doesn't seem right
    -                --   for DiscArgCtxt it shouldn't matter because the function will
    -                --       get the arg discount for any non-triv arg
    -                --   for RuleArgCtxt we do want to be keener to inline; but not only
    -                --       constructor results
    -                --   for RhsCtxt I suppose that exposing a data con is good in general
    -                --   And 40 seems very arbitrary
    -                --
    -                -- res_discount can be very large when a function returns
    -                -- constructors; but we only want to invoke that large discount
    -                -- when there's a case continuation.
    -                -- Otherwise we, rather arbitrarily, threshold it.  Yuk.
    -                -- But we want to avoid inlining large functions that return
    -                -- constructors into contexts that are simply "interesting"
    --}
    +{- *********************************************************************
    +*                                                                      *
    +                  Computing ArgSummary
    +*                                                                      *
    +********************************************************************* -}
     
     {- Note [Interesting arguments]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Utils.hs
    =====================================
    @@ -29,6 +29,9 @@ module GHC.Core.Opt.Simplify.Utils (
             mkBoringStop, mkRhsStop, mkLazyArgStop,
             interestingCallContext,
     
    +        -- The CallCtxt type
    +        CallCtxt(..),
    +        
             -- ArgInfo
             ArgInfo(..), ArgSpec(..), RewriteCall(..), mkArgInfo,
             addValArgTo, addCastTo, addTyArgTo,
    @@ -516,6 +519,38 @@ contHoleType (Select { sc_dup = d, sc_bndr =  b, sc_env = se })
       = perhapsSubstTy d se (idType b)
     
     
    +contHasRules :: SimplCont -> Bool
    +-- If the argument has form (f x y), where x,y are boring,
    +-- and f is marked INLINE, then we don't want to inline f.
    +-- But if the context of the argument is
    +--      g (f x y)
    +-- where g has rules, then we *do* want to inline f, in case it
    +-- exposes a rule that might fire.  Similarly, if the context is
    +--      h (g (f x x))
    +-- where h has rules, then we do want to inline f.  So contHasRules
    +-- tries to see if the context of the f-call is a call to a function
    +-- with rules.
    +--
    +-- The ai_encl flag makes this happen; if it's
    +-- set, the inliner gets just enough keener to inline f
    +-- regardless of how boring f's arguments are, if it's marked INLINE
    +--
    +-- The alternative would be to *always* inline an INLINE function,
    +-- regardless of how boring its context is; but that seems overkill
    +-- For example, it'd mean that wrapper functions were always inlined
    +contHasRules cont
    +  = go cont
    +  where
    +    go (ApplyToVal { sc_cont = cont }) = go cont
    +    go (ApplyToTy  { sc_cont = cont }) = go cont
    +    go (CastIt _ cont)                 = go cont
    +    go (StrictArg { sc_fun = fun })    = ai_encl fun
    +    go (Stop _ RuleArgCtxt _)          = True
    +    go (TickIt _ c)                    = go c
    +    go (Select {})                     = False
    +    go (StrictBind {})                 = False      -- ??
    +    go (Stop _ _ _)                    = False
    +
     -- Computes the multiplicity scaling factor at the hole. That is, in (case [] of
     -- x ::(p) _ { … }) (respectively for arguments of functions), the scaling
     -- factor is p. And in E[G[]], the scaling factor is the product of the scaling
    @@ -709,15 +744,36 @@ make use of the strictness info for the function.
     -}
     
     
    -{-
    -************************************************************************
    +{- *********************************************************************
     *                                                                      *
    -        Interesting arguments
    +             CallCtxt: the context of a call
     *                                                                      *
    -************************************************************************
    +********************************************************************* -}
     
    -Note [Interesting call context]
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +data CallCtxt
    +  = BoringCtxt
    +  | RhsCtxt RecFlag     -- Rhs of a let-binding; see Note [RHS of lets]
    +  | DiscArgCtxt         -- Argument of a function with non-zero arg discount
    +  | RuleArgCtxt         -- We are somewhere in the argument of a function with rules
    +
    +  | ValAppCtxt          -- We're applied to at least one value arg
    +                        -- This arises when we have ((f x |> co) y)
    +                        -- Then the (f x) has argument 'x' but in a ValAppCtxt
    +
    +  | CaseCtxt            -- We're the scrutinee of a case
    +                        -- that decomposes its scrutinee
    +
    +instance Outputable CallCtxt where
    +  ppr CaseCtxt    = text "CaseCtxt"
    +  ppr ValAppCtxt  = text "ValAppCtxt"
    +  ppr BoringCtxt  = text "BoringCtxt"
    +  ppr (RhsCtxt ir)= text "RhsCtxt" <> parens (ppr ir)
    +  ppr DiscArgCtxt = text "DiscArgCtxt"
    +  ppr RuleArgCtxt = text "RuleArgCtxt"
    +
    +
    +{- Note [Interesting call context]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     We want to avoid inlining an expression where there can't possibly be
     any gain, such as in an argument position.  Hence, if the continuation
     is interesting (eg. a case scrutinee that isn't just a seq, application etc.)
    @@ -873,38 +929,6 @@ interestingCallContext env cont
             -- a build it's *great* to inline it here.  So we must ensure that
             -- the context for (f x) is not totally uninteresting.
     
    -contHasRules :: SimplCont -> Bool
    --- If the argument has form (f x y), where x,y are boring,
    --- and f is marked INLINE, then we don't want to inline f.
    --- But if the context of the argument is
    ---      g (f x y)
    --- where g has rules, then we *do* want to inline f, in case it
    --- exposes a rule that might fire.  Similarly, if the context is
    ---      h (g (f x x))
    --- where h has rules, then we do want to inline f.  So contHasRules
    --- tries to see if the context of the f-call is a call to a function
    --- with rules.
    ---
    --- The ai_encl flag makes this happen; if it's
    --- set, the inliner gets just enough keener to inline f
    --- regardless of how boring f's arguments are, if it's marked INLINE
    ---
    --- The alternative would be to *always* inline an INLINE function,
    --- regardless of how boring its context is; but that seems overkill
    --- For example, it'd mean that wrapper functions were always inlined
    -contHasRules cont
    -  = go cont
    -  where
    -    go (ApplyToVal { sc_cont = cont }) = go cont
    -    go (ApplyToTy  { sc_cont = cont }) = go cont
    -    go (CastIt _ cont)                 = go cont
    -    go (StrictArg { sc_fun = fun })    = ai_encl fun
    -    go (Stop _ RuleArgCtxt _)          = True
    -    go (TickIt _ c)                    = go c
    -    go (Select {})                     = False
    -    go (StrictBind {})                 = False      -- ??
    -    go (Stop _ _ _)                    = False
    -
     
     {-
     ************************************************************************
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -2,7 +2,6 @@
     (c) The University of Glasgow 2006
     (c) The AQUA Project, Glasgow University, 1994-1998
     
    -
     Core-syntax unfoldings
     
     Unfoldings (which can travel across module boundaries) are in Core
    @@ -23,7 +22,7 @@ module GHC.Core.Unfold (
     
             ExprTree, exprTree, exprTreeSize,
             exprTreeWillInline, couldBeSmallEnoughToInline,
    -        ArgSummary(..), CallCtxt(..), hasArgInfo,
    +        ArgSummary(..), hasArgInfo,
             Size, leqSize, addSizeN, adjustSize,
             InlineContext(..),
     
    @@ -49,7 +48,7 @@ import GHC.Types.Var.Env
     import GHC.Types.Literal
     import GHC.Types.Id.Info
     import GHC.Types.RepType ( isZeroBitTy )
    -import GHC.Types.Basic  ( Arity, RecFlag )
    +import GHC.Types.Basic  ( Arity )
     import GHC.Types.ForeignCall
     import GHC.Types.Tickish
     
    @@ -65,6 +64,67 @@ import GHC.Data.Bag
     import qualified Data.ByteString as BS
     
     
    +{- Note [Overview of inlining heuristics]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Key examples
    +------------
    +Example 1:
    +
    +   let f x = case x of
    +               A -> True
    +               B -> 
    +   in ...(f A)....(f B)...
    +
    +Even though f's entire RHS is big, it collapses to something small when applied
    +to A.  We'd like to spot this.
    +
    +Example 1:
    +
    +   let f x = case x of
    +               (p,q) -> case p of
    +                           A -> True
    +                           B -> 
    +   in ...(f (A,3))....
    +
    +This is similar to Example 1, but nested.
    +
    +Example 3:
    +
    +   let j x = case y of
    +               A -> True
    +               B -> 
    +   in case y of
    +         A -> ..(j 3)...(j 4)....
    +         B -> ...
    +
    +Here we want to spot that although the free far `y` is unknown at j's definition
    +site, we know that y=A at the two calls in the A-alternative of the body. If `y`
    +had been an argument we'd have spotted this; we'd like to get the same goodness
    +when `y` is a free variable.
    +
    +This kind of thing can occur a lot with join points.
    +
    +Design overview
    +---------------
    +The question is whethe or not to inline f = rhs.
    +The key idea is to abstract `rhs` to an ExprTree, which gives a measure of
    +size, but records structure for case-expressions.
    +
    +
    +The moving parts
    +-----------------
    +* An unfolding is accompanied (in its UnfoldingGuidance) with its GHC.Core.ExprTree,
    +  computed by GHC.Core.Unfold.exprTree.
    +
    +* At a call site, GHC.Core.Opt.Simplify.Inline.contArgs constructs an ArgSummary
    +  for each value argument. This reflects any nested data construtors.
    +
    +* Then GHC.Core.Unfold.exprTreeSize takes information about the context of the
    +  call (particularly the ArgSummary for each argument) and computes a final size
    +  for the inlined body, taking account of case-of-known-consructor.
    +
    +-}
    +
     {- *********************************************************************
     *                                                                      *
                          UnfoldingOpts
    @@ -160,73 +220,7 @@ updateReportPrefix :: Maybe String -> UnfoldingOpts -> UnfoldingOpts
     updateReportPrefix n opts = opts { unfoldingReportPrefix = n }
     
     
    -{- *********************************************************************
    -*                                                                      *
    -                    Argument summary
    -*                                                                      *
    -********************************************************************* -}
    -
    -data ArgSummary = ArgNoInfo
    -                | ArgIsCon AltCon [ArgSummary]  -- Includes type args
    -                | ArgIsNot [AltCon]
    -                | ArgIsLam
    -
    -hasArgInfo :: ArgSummary -> Bool
    -hasArgInfo ArgNoInfo = False
    -hasArgInfo _         = True
    -
    -instance Outputable ArgSummary where
    -  ppr ArgNoInfo       = text "ArgNoInfo"
    -  ppr ArgIsLam        = text "ArgIsLam"
    -  ppr (ArgIsCon c as) = ppr c <> ppr as
    -  ppr (ArgIsNot cs)   = text "ArgIsNot" <> ppr cs
    -
    -data CallCtxt
    -  = BoringCtxt
    -  | RhsCtxt RecFlag     -- Rhs of a let-binding; see Note [RHS of lets]
    -  | DiscArgCtxt         -- Argument of a function with non-zero arg discount
    -  | RuleArgCtxt         -- We are somewhere in the argument of a function with rules
    -
    -  | ValAppCtxt          -- We're applied to at least one value arg
    -                        -- This arises when we have ((f x |> co) y)
    -                        -- Then the (f x) has argument 'x' but in a ValAppCtxt
    -
    -  | CaseCtxt            -- We're the scrutinee of a case
    -                        -- that decomposes its scrutinee
    -
    -instance Outputable CallCtxt where
    -  ppr CaseCtxt    = text "CaseCtxt"
    -  ppr ValAppCtxt  = text "ValAppCtxt"
    -  ppr BoringCtxt  = text "BoringCtxt"
    -  ppr (RhsCtxt ir)= text "RhsCtxt" <> parens (ppr ir)
    -  ppr DiscArgCtxt = text "DiscArgCtxt"
    -  ppr RuleArgCtxt = text "RuleArgCtxt"
    -
     {-
    -Note [Calculate unfolding guidance on the non-occ-anal'd expression]
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -Notice that we give the non-occur-analysed expression to
    -calcUnfoldingGuidance.  In some ways it'd be better to occur-analyse
    -first; for example, sometimes during simplification, there's a large
    -let-bound thing which has been substituted, and so is now dead; so
    -'expr' contains two copies of the thing while the occurrence-analysed
    -expression doesn't.
    -
    -Nevertheless, we *don't* and *must not* occ-analyse before computing
    -the size because
    -
    -a) The size computation bales out after a while, whereas occurrence
    -   analysis does not.
    -
    -b) Residency increases sharply if you occ-anal first.  I'm not
    -   100% sure why, but it's a large effect.  Compiling Cabal went
    -   from residency of 534M to over 800M with this one change.
    -
    -This can occasionally mean that the guidance is very pessimistic;
    -it gets fixed up next round.  And it should be rare, because large
    -let-bound things that are dead are usually caught by preInlineUnconditionally
    -
    -
     ************************************************************************
     *                                                                      *
     \subsection{The UnfoldingGuidance type}
    @@ -295,21 +289,18 @@ calcUnfoldingGuidance opts is_top_bottoming expr
         is_case (CaseOf {})  = True
         is_case (ScrutOf {}) = False
     
    -{- We use 'couldBeSmallEnoughToInline' to avoid exporting inlinings that
    -   we ``couldn't possibly use'' on the other side.  Can be overridden w/
    -   flaggery.  Just the same as smallEnoughToInline, except that it has no
    -   actual arguments.
    --}
     
     couldBeSmallEnoughToInline :: UnfoldingOpts -> Int -> CoreExpr -> Bool
    +-- We use 'couldBeSmallEnoughToInline' to avoid exporting inlinings that
    +-- we ``couldn't possibly use'' on the other side.  Can be overridden
    +-- w/flaggery.  Just the same as smallEnoughToInline, except that it has no
    +-- actual arguments.
     couldBeSmallEnoughToInline opts threshold rhs
       = exprTreeWillInline threshold $
         exprTree opts [] body
       where
         (_, body) = collectBinders rhs
     
    -----------------
    -
     
     {- Note [Inline unsafeCoerce]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    @@ -1035,6 +1026,22 @@ data InlineContext
                                             --          so apply result discount
          }
     
    +data ArgSummary = ArgNoInfo
    +                | ArgIsCon AltCon [ArgSummary]  -- Includes type args
    +                | ArgIsNot [AltCon]
    +                | ArgIsLam
    +
    +hasArgInfo :: ArgSummary -> Bool
    +hasArgInfo ArgNoInfo = False
    +hasArgInfo _         = True
    +
    +instance Outputable ArgSummary where
    +  ppr ArgNoInfo       = text "ArgNoInfo"
    +  ppr ArgIsLam        = text "ArgIsLam"
    +  ppr (ArgIsCon c as) = ppr c <> ppr as
    +  ppr (ArgIsNot cs)   = text "ArgIsNot" <> ppr cs
    +
    +
     -------------------------
     exprTreeWillInline :: Int -> ExprTree -> Bool
     -- (cheapExprTreeSize limit et) takes an upper bound `n` on the
    @@ -1057,6 +1064,8 @@ exprTreeWillInline limit et
         go_alt :: AltTree -> (Int -> Bool) -> Int -> Bool
         go_alt (AltTree _ _ et) k n = go et k (n+10)
     
    +
    +-------------------------
     exprTreeSize :: InlineContext -> ExprTree -> Size
     exprTreeSize _    TooBig = STooBig
     exprTreeSize !ic (SizeIs { et_size  = size
    
    
    =====================================
    compiler/GHC/Core/Unfold/Make.hs
    =====================================
    @@ -312,6 +312,29 @@ Note [Honour INLINE on 0-ary bindings].
     
     I'm a bit worried that it's possible for the same kind of problem
     to arise for non-0-ary functions too, but let's wait and see.
    +
    +Note [Calculate unfolding guidance on the non-occ-anal'd expression]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Notice that we give the non-occur-analysed expression to
    +calcUnfoldingGuidance.  In some ways it'd be better to occur-analyse
    +first; for example, sometimes during simplification, there's a large
    +let-bound thing which has been substituted, and so is now dead; so
    +'expr' contains two copies of the thing while the occurrence-analysed
    +expression doesn't.
    +
    +Nevertheless, we *don't* and *must not* occ-analyse before computing
    +the size because
    +
    +a) The size computation bales out after a while, whereas occurrence
    +   analysis does not.
    +
    +b) Residency increases sharply if you occ-anal first.  I'm not
    +   100% sure why, but it's a large effect.  Compiling Cabal went
    +   from residency of 534M to over 800M with this one change.
    +
    +This can occasionally mean that the guidance is very pessimistic;
    +it gets fixed up next round.  And it should be rare, because large
    +let-bound things that are dead are usually caught by preInlineUnconditionally
     -}
     
     mkUnfolding :: UnfoldingOpts
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5fbeeb2fd05518f1afb2ee3225bc083b960a81a
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5fbeeb2fd05518f1afb2ee3225bc083b960a81a
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 07:56:13 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 03:56:13 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Wibbles
    Message-ID: <6536271dad74d_1f7b0d1b759c3c1814f@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    6ae7c217 by Simon Peyton Jones at 2023-10-23T08:55:56+01:00
    Wibbles
    
    - - - - -
    
    
    2 changed files:
    
    - compiler/GHC/Core/Opt/Simplify/Utils.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Utils.hs
    =====================================
    @@ -31,7 +31,7 @@ module GHC.Core.Opt.Simplify.Utils (
     
             -- The CallCtxt type
             CallCtxt(..),
    -        
    +
             -- ArgInfo
             ArgInfo(..), ArgSpec(..), RewriteCall(..), mkArgInfo,
             addValArgTo, addCastTo, addTyArgTo,
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -585,7 +585,7 @@ exprTree opts args expr
           | Just v <- recordCaseOf vs scrut
           = -- pprTrace "recordCaseOf" (ppr v $$ ppr lvs $$ ppr scrut $$ ppr alts) $
             go vs scrut `et_add`
    -        etZero { et_cases = unitBag (CaseOf v b (map (alt_alt_tree v) alts)) }
    +        etOneCase (CaseOf v b (map (alt_alt_tree v) alts))
           where
             alt_alt_tree :: Id -> Alt Var -> AltTree
             alt_alt_tree v (Alt con bs rhs)
    @@ -729,7 +729,7 @@ classOpSize opts vs fn val_args
       , Just dict <- recordCaseOf vs arg1
       = warnPprTrace (not (isId dict)) "classOpSize" (ppr fn <+> ppr val_args) $
         vanillaCallSize (length val_args) `etAddN`
    -    etZero { et_cases = unitBag (ScrutOf dict (unfoldingDictDiscount opts)) }
    +    etOneCase (ScrutOf dict (unfoldingDictDiscount opts))
                -- If the class op is scrutinising a lambda bound dictionary then
                -- give it a discount, to encourage the inlining of this function
                -- The actual discount is rather arbitrarily chosen
    @@ -985,6 +985,8 @@ etAddAlt bOMB_OUT_SIZE (SizeIs { et_size = n1, et_cases = c1, et_ret = ret1 })
     etZero :: ExprTree
     etZero = SizeIs { et_size = 0, et_cases = emptyBag, et_ret = 0 }
     
    +etOneCase :: CaseTree -> ExprTree
    +etOneCase ct = SizeIs { et_size = 0, et_cases = unitBag ct, et_ret = 0 }
     
     {- *********************************************************************
     *                                                                      *
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ae7c21799125224a9dc0ced3e99f2f286bda0fb
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ae7c21799125224a9dc0ced3e99f2f286bda0fb
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 09:05:24 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 05:05:24 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Wibbles
    Message-ID: <6536375465990_1f7b0d1d1f660819073d@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    f433129d by Simon Peyton Jones at 2023-10-23T10:05:11+01:00
    Wibbles
    
    - - - - -
    
    
    2 changed files:
    
    - compiler/GHC/Core/Opt/Simplify/Iteration.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Iteration.hs
    =====================================
    @@ -660,9 +660,7 @@ tryCastWorkerWrapper env bind_cxt old_bndr occ_info bndr (Cast rhs co)
                _ -> mkLetUnfolding uf_opts top_lvl VanillaSrc work_id work_rhs
     
     tryCastWorkerWrapper env _ _ _ bndr rhs  -- All other bindings
    -  = do { traceSmpl "tcww:no" (vcat [ text "bndr:" <+> ppr bndr
    -                                   , text "rhs:" <+> ppr rhs ])
    -        ; return (mkFloatBind env (NonRec bndr rhs)) }
    +  = return (mkFloatBind env (NonRec bndr rhs))
     
     mkCastWrapperInlinePrag :: InlinePragma -> InlinePragma
     -- See Note [Cast worker/wrapper]
    @@ -952,7 +950,6 @@ completeBind env bind_cxt old_bndr new_bndr new_rhs
             -- See Note [In-scope set as a substitution]
     
           ; if postInlineUnconditionally env bind_cxt new_bndr_w_info occ_info eta_rhs
    -
             then -- Inline and discard the binding
                  do  { tick (PostInlineUnconditionally old_bndr)
                      ; let unf_rhs = maybeUnfoldingTemplate new_unfolding `orElse` eta_rhs
    @@ -3219,10 +3216,9 @@ simplAlts :: SimplEnv
               -> SimplM OutExpr  -- Returns the complete simplified case expression
     
     simplAlts env0 scrut case_bndr alts cont'
    -  = do  { traceSmpl "simplAlts" (vcat [ ppr case_bndr
    -                                      , text "cont':" <+> ppr cont'
    -                                      , text "in_scope" <+> ppr (seInScope env0) ])
    -        ; (env1, case_bndr1) <- simplBinder env0 case_bndr
    +  = do  { (env1, case_bndr1) <- simplBinder env0 case_bndr
    +        ; traceSmpl "simplAlts" (vcat [ ppr case_bndr <+> ppr case_bndr1
    +                                      , text "cont':" <+> ppr cont' ])
             ; let case_bndr2 = case_bndr1 `setIdUnfolding` evaldUnfolding
                   env2       = modifyInScope env1 case_bndr2
                   -- See Note [Case binder evaluated-ness]
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -1089,19 +1089,19 @@ caseTreeSize ic (ScrutOf bndr disc)
     
     caseTreeSize ic (CaseOf scrut_var case_bndr alts)
       = case lookupBndr ic scrut_var of
    -      ArgNoInfo     -> keptCaseSize ic alts
    -      ArgIsLam      -> keptCaseSize ic alts
    -      ArgIsNot cons -> keptCaseSize ic (trim_alts cons alts)
    +      ArgNoInfo     -> keptCaseSize ic case_bndr alts
    +      ArgIsLam      -> keptCaseSize ic case_bndr alts
    +      ArgIsNot cons -> keptCaseSize ic case_bndr (trim_alts cons alts)
           arg_summ@(ArgIsCon con args)
    -         | Just (AltTree _ bs rhs) <- find_alt con alts
    +         | Just (AltTree _ bndrs rhs) <- find_alt con alts
              , let new_summaries :: [(Var,ArgSummary)]
    -               new_summaries = (case_bndr,arg_summ) : bs `zip` args
    +               new_summaries = (case_bndr,arg_summ) : bndrs `zip` args
                       -- Don't forget to add a summary for the case binder!
                    ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
                          -- In DEFAULT case, bs is empty, so extending is a no-op
              -> exprTreeSize ic' rhs
              | otherwise  -- Happens for empty alternatives
    -         -> keptCaseSize ic alts
    +         -> keptCaseSize ic case_bndr alts
     
     find_alt :: AltCon -> [AltTree] -> Maybe AltTree
     find_alt _   []                     = Nothing
    @@ -1120,16 +1120,22 @@ trim_alts acs (alt:alts)
       | AltTree con _ _ <- alt, con `elem` acs = trim_alts acs alts
       | otherwise                              = alt : trim_alts acs alts
     
    -keptCaseSize :: InlineContext -> [AltTree] -> Size
    +keptCaseSize :: InlineContext -> Id -> [AltTree] -> Size
     -- Size of a (retained) case expression
    -keptCaseSize ic alts
    +keptCaseSize ic case_bndr alts
       = foldr (addSize . size_alt) (sizeN 0) alts
         -- We make the case itself free, but charge for each alternative
         -- If there are no alternatives (case e of {}), we get just the size of the scrutinee
       where
         size_alt :: AltTree -> Size
    -    size_alt (AltTree _ _ rhs) = exprTreeSize ic rhs
    +    size_alt (AltTree _ bndrs rhs) = exprTreeSize ic' rhs
             -- Cost for the alternative is already in `rhs`
    +      where
    +        -- Must extend ic_bound, lest a captured variable is
    +        -- looked up in ic_free by lookupBndr
    +        new_summaries :: [(Var,ArgSummary)]
    +        new_summaries = [(b,ArgNoInfo) | b <- case_bndr:bndrs]
    +        ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
     
     lookupBndr :: HasDebugCallStack => InlineContext -> Id -> ArgSummary
     lookupBndr (IC { ic_bound = bound_env, ic_free = lookup_free }) var
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f433129ddb8e7597d6944c023f8152b141ee8210
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f433129ddb8e7597d6944c023f8152b141ee8210
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 10:29:54 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Mon, 23 Oct 2023 06:29:54 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 11 commits: Move
     function checks to RTS configure
    Message-ID: <65364b221e109_1f7b0d1f3a07cc200979@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    f8534f46 by Alan Zimmerman at 2023-10-23T06:29:33-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    0be70e34 by Simon Hengel at 2023-10-23T06:29:35-04:00
    Update primitives.rst
    - - - - -
    
    
    27 changed files:
    
    - .gitignore
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Parser.y
    - compiler/GHC/Parser/Annotation.hs
    - compiler/GHC/Parser/PostProcess.hs
    - configure.ac
    - distrib/cross-port
    - docs/coding-style.html
    - docs/rts/rts.tex
    - docs/users_guide/exts/primitives.rst
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Rules/Lint.hs
    - hadrian/src/Rules/Register.hs
    - hadrian/src/Rules/SourceDist.hs
    - hadrian/src/Settings/Packages.hs
    - libraries/base/changelog.md
    - m4/fp_cc_supports__atomics.m4
    - m4/fptools_set_haskell_platform_vars.m4
    - m4/ghc_convert_os.m4
    - rts/PrimOps.cmm
    - rts/configure.ac
    - + rts/ghcplatform.h.bottom
    - + rts/ghcplatform.h.top.in
    - rts/rts.cabal
    - testsuite/tests/parser/should_compile/DumpSemis.stderr
    - testsuite/tests/parser/should_compile/T15323.stderr
    - testsuite/tests/printer/Test20297.stdout
    
    
    Changes:
    
    =====================================
    .gitignore
    =====================================
    @@ -184,8 +184,8 @@ _darcs/
     /linter.log
     /mk/are-validating.mk
     /mk/build.mk
    -/mk/config.h
    -/mk/config.h.in
    +/mk/unused.h
    +/mk/unused.h.in
     /mk/config.mk
     /mk/config.mk.old
     /mk/system-cxx-std-lib-1.0.conf
    
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -229,7 +229,7 @@ section "The word size story."
              must contain at least 30 bits. GHC always implements
              'Int' using the primitive type 'Int#', whose size equals
              the @MachDeps.h@ constant @WORD\_SIZE\_IN\_BITS at .
    -         This is normally set based on the @config.h@ parameter
    +         This is normally set based on the RTS @ghcautoconf.h@ parameter
              @SIZEOF\_HSWORD@, i.e., 32 bits on 32-bit machines, 64
              bits on 64-bit machines.
     
    
    
    =====================================
    compiler/GHC/Parser.y
    =====================================
    @@ -2269,7 +2269,7 @@ atype :: { LHsType GhcPs }
             | PREFIX_TILDE atype             {% acsA (\cs -> sLL $1 $> (mkBangTy (EpAnn (glR $1) [mj AnnTilde $1] cs) SrcLazy $2)) }
             | PREFIX_BANG  atype             {% acsA (\cs -> sLL $1 $> (mkBangTy (EpAnn (glR $1) [mj AnnBang $1] cs) SrcStrict $2)) }
     
    -        | '{' fielddecls '}'             {% do { decls <- acsA (\cs -> (sLL $1 $> $ HsRecTy (EpAnn (glR $1) (AnnList (Just $ listAsAnchor $2) (Just $ moc $1) (Just $ mcc $3) [] []) cs) $2))
    +        | '{' fielddecls '}'             {% do { decls <- acsA (\cs -> (sLL $1 $> $ HsRecTy (EpAnn (glR $1) (AnnList (listAsAnchorM $2) (Just $ moc $1) (Just $ mcc $3) [] []) cs) $2))
                                                    ; checkRecordSyntax decls }}
                                                             -- Constructor sigs only
             | '(' ')'                        {% acsA (\cs -> sLL $1 $> $ HsTupleTy (EpAnn (glR $1) (AnnParen AnnParens (glAA $1) (glAA $2)) cs)
    @@ -2407,7 +2407,7 @@ gadt_constrlist :: { Located ([AddEpAnn]
                               ,[LConDecl GhcPs]) } -- Returned in order
     
             : 'where' '{'        gadt_constrs '}'    {% checkEmptyGADTs $
    -                                                      L (comb2 $1 $3)
    +                                                      L (comb2 $1 $4)
                                                             ([mj AnnWhere $1
                                                              ,moc $2
                                                              ,mcc $4]
    @@ -2588,8 +2588,9 @@ rhs     :: { Located (GRHSs GhcPs (LHsExpr GhcPs)) }
             : '=' exp wherebinds    {% runPV (unECP $2) >>= \ $2 ->
                                       do { let L l (bs, csw) = adaptWhereBinds $3
                                          ; let loc = (comb3 $1 $2 (L l bs))
    +                                     ; let locg = (comb2 $1 $2)
                                          ; acs (\cs ->
    -                                       sL loc (GRHSs csw (unguardedRHS (EpAnn (anc $ rs loc) (GrhsAnn Nothing (mj AnnEqual $1)) cs) loc $2)
    +                                       sL loc (GRHSs csw (unguardedRHS (EpAnn (anc $ rs locg) (GrhsAnn Nothing (mj AnnEqual $1)) cs) locg $2)
                                                           bs)) } }
             | gdrhs wherebinds      {% do { let {L l (bs, csw) = adaptWhereBinds $2}
                                           ; acs (\cs -> sL (comb2 $1 (L l bs))
    @@ -3324,7 +3325,7 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs
     alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) }
             : PATS alt_rhs { $2 >>= \ $2 ->
                              acsA (\cs -> sLLAsl $1 $>
    -                                         (Match { m_ext = EpAnn (listAsAnchor $1) [] cs
    +                                         (Match { m_ext = EpAnn (listAsAnchor $1 $>) [] cs
                                                     , m_ctxt = CaseAlt -- for \case and \cases, this will be changed during post-processing
                                                     , m_pats = $1
                                                     , m_grhss = unLoc $2 }))}
    @@ -3336,7 +3337,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) }
     
     ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) }
             : '->' exp            { unECP $2 >>= \ $2 ->
    -                                acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (glR $1) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) }
    +                                acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) }
             | gdpats              { $1 >>= \gdpats ->
                                     return $ sL1 gdpats (reverse (unLoc gdpats)) }
     
    @@ -4465,9 +4466,16 @@ hsDoAnn :: Located a -> LocatedAn t b -> AnnKeywordId -> AnnList
     hsDoAnn (L l _) (L ll _) kw
       = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (srcSpan2e l)] []
     
    -listAsAnchor :: [LocatedAn t a] -> Anchor
    -listAsAnchor [] = spanAsAnchor noSrcSpan
    -listAsAnchor (L l _:_) = spanAsAnchor (locA l)
    +listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor
    +listAsAnchor [] (L l _) = spanAsAnchor l
    +listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s)
    +
    +listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor
    +listAsAnchorM [] = Nothing
    +listAsAnchorM (L l _:_) =
    +  case locA l of
    +    RealSrcSpan ll _ -> Just $ realSpanAsAnchor ll
    +    _                -> Nothing
     
     hsTok :: Located Token -> LHsToken tok GhcPs
     hsTok (L l _) = L (mkTokenLocation l) HsTok
    @@ -4528,7 +4536,6 @@ addTrailingAnnL (L (SrcSpanAnn anns l) a) ta = do
     -- Mostly use to add AnnComma, special case it to NOP if adding a zero-width annotation
     addTrailingCommaN :: MonadP m => LocatedN a -> SrcSpan -> m (LocatedN a)
     addTrailingCommaN (L (SrcSpanAnn anns l) a) span = do
    -  -- cs <- getCommentsFor l
       let cs = emptyComments
       -- AZ:TODO: generalise updating comments into an annotation
       let anns' = if isZeroWidthSpan span
    
    
    =====================================
    compiler/GHC/Parser/Annotation.hs
    =====================================
    @@ -19,8 +19,8 @@ module GHC.Parser.Annotation (
       DeltaPos(..), deltaPos, getDeltaLine,
     
       EpAnn(..), Anchor(..), AnchorOperation(..),
    -  spanAsAnchor, realSpanAsAnchor,
       NoAnn(..),
    +  spanAsAnchor, realSpanAsAnchor, spanFromAnchor,
     
       -- ** Comments in Annotations
     
    @@ -549,6 +549,9 @@ spanAsAnchor s  = Anchor (realSrcSpan s) UnchangedAnchor
     realSpanAsAnchor :: RealSrcSpan -> Anchor
     realSpanAsAnchor s  = Anchor s UnchangedAnchor
     
    +spanFromAnchor :: Anchor -> SrcSpan
    +spanFromAnchor a = RealSrcSpan (anchor a) Strict.Nothing
    +
     -- ---------------------------------------------------------------------
     
     -- | When we are parsing we add comments that belong a particular AST
    
    
    =====================================
    compiler/GHC/Parser/PostProcess.hs
    =====================================
    @@ -831,11 +831,18 @@ mkGadtDecl loc names dcol ty = do
     
       let an = EpAnn (spanAsAnchor loc) annsa (cs Semi.<> csa)
     
    +  let bndrs_loc = case outer_bndrs of
    +        HsOuterImplicit{} -> getLoc ty
    +        HsOuterExplicit an _ ->
    +          case an of
    +            EpAnnNotUsed -> getLoc ty
    +            an' -> SrcSpanAnn (EpAnn (entry an') noAnn emptyComments) (spanFromAnchor (entry an'))
    +
       pure $ L l ConDeclGADT
                          { con_g_ext  = an
                          , con_names  = names
                          , con_dcolon = dcol
    -                     , con_bndrs  = L (getLoc ty) outer_bndrs
    +                     , con_bndrs  = L bndrs_loc outer_bndrs
                          , con_mb_cxt = mcxt
                          , con_g_args = args
                          , con_res_ty = res_ty
    
    
    =====================================
    configure.ac
    =====================================
    @@ -32,8 +32,8 @@ AC_CONFIG_MACRO_DIRS([m4])
     # checkout), then we ship a file 'VERSION' containing the full version
     # when the source distribution was created.
     
    -if test ! -f mk/config.h.in; then
    -   echo "mk/config.h.in doesn't exist: perhaps you haven't run 'python3 boot'?"
    +if test ! -f rts/ghcautoconf.h.autoconf.in; then
    +   echo "rts/ghcautoconf.h.autoconf.in doesn't exist: perhaps you haven't run 'python3 boot'?"
        exit 1
     fi
     
    @@ -84,8 +84,11 @@ AC_PREREQ([2.69])
     # Prepare to generate the following header files
     #
     
    -# This one is autogenerated by autoheader.
    -AC_CONFIG_HEADER(mk/config.h)
    +dnl so the next header, which is manually maintained, doesn't get
    +dnl overwritten by an autogenerated header. Once we have no more
    +dnl `AC_CONFIG_HEADER` calls (issue #23966) we can delete all mention
    +dnl of `mk/unused.h`.
    +AC_CONFIG_HEADER(mk/unused.h)
     # This one is manually maintained.
     AC_CONFIG_HEADER(compiler/ghc-llvm-version.h)
     
    @@ -138,27 +141,6 @@ if test "$EnableDistroToolchain" = "YES"; then
       TarballsAutodownload=NO
     fi
     
    -AC_ARG_ENABLE(asserts-all-ways,
    -[AS_HELP_STRING([--enable-asserts-all-ways],
    -                [Usually ASSERTs are only compiled in the DEBUG way,
    -                 this will enable them in all ways.])],
    -  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    -  [EnableAssertsAllWays=NO]
    -)
    -if test "$enable_asserts_all_ways" = "yes" ; then
    -   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    -fi
    -
    -AC_ARG_ENABLE(native-io-manager,
    -[AS_HELP_STRING([--enable-native-io-manager],
    -                [Enable the native I/O manager by default.])],
    -  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    -  [EnableNativeIOManager=NO]
    -)
    -if test "$EnableNativeIOManager" = "YES"; then
    -  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    -fi
    -
     AC_ARG_ENABLE(ghc-toolchain,
     [AS_HELP_STRING([--enable-ghc-toolchain],
                     [Whether to use the newer ghc-toolchain tool to configure ghc targets])],
    @@ -319,9 +301,6 @@ dnl ** Do a build with tables next to code?
     dnl --------------------------------------------------------------
     
     GHC_TABLES_NEXT_TO_CODE
    -if test x"$TablesNextToCode" = xYES; then
    -   AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])
    -fi
     AC_SUBST(TablesNextToCode)
     
     # Requires FPTOOLS_SET_PLATFORMS_VARS to be run first.
    @@ -617,12 +596,15 @@ dnl    unregisterised, Sparc, and PPC backends. Also determines whether
     dnl    linking to libatomic is required for atomic operations, e.g. on
     dnl    RISCV64 GCC.
     FP_CC_SUPPORTS__ATOMICS
    +if test "$need_latomic" = 1; then
    +    AC_SUBST([NeedLibatomic],[YES])
    +else
    +    AC_SUBST([NeedLibatomic],[NO])
    +fi
     
     dnl ** look to see if we have a C compiler using an llvm back end.
     dnl
     FP_CC_LLVM_BACKEND
    -AS_IF([test x"$CcLlvmBackend" = x"YES"],
    -  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
     AC_SUBST(CcLlvmBackend)
     
     FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
    @@ -845,88 +827,14 @@ dnl --------------------------------------------------
     dnl ### program checking section ends here ###
     dnl --------------------------------------------------
     
    -dnl --------------------------------------------------
    -dnl * Platform header file and syscall feature tests
    -dnl ### checking the state of the local header files and syscalls ###
    -
    -dnl ** Enable large file support.  NB. do this before testing the type of
    -dnl    off_t, because it will affect the result of that test.
    -AC_SYS_LARGEFILE
    -
    -dnl ** check for specific header (.h) files that we are interested in
    -AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    -
    -dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    -AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    -[[#if HAVE_SYS_PARAM_H
    -# include 
    -#endif
    -]])
    -
    -dnl ** check whether a declaration for `environ` is provided by libc.
    -FP_CHECK_ENVIRON
    -
    -dnl ** do we have long longs?
    -AC_CHECK_TYPES([long long])
    -
    -dnl ** what are the sizes of various types
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    -if test "$ac_cv_type_long_long" = yes; then
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    -fi
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    -if test "$ac_cv_type_long_long" = yes; then
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    -fi
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    -
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    -FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    -
    -
     dnl for use in settings file
    +AC_CHECK_SIZEOF([void *])
     TargetWordSize=$ac_cv_sizeof_void_p
     AC_SUBST(TargetWordSize)
     
     AC_C_BIGENDIAN([TargetWordBigEndian=YES],[TargetWordBigEndian=NO])
     AC_SUBST(TargetWordBigEndian)
     
    -FP_CHECK_FUNC([WinExec],
    -  [@%:@include ], [WinExec("",0)])
    -
    -FP_CHECK_FUNC([GetModuleFileName],
    -  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    -
    -dnl ** check for more functions
    -dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    -AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    -
    -dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    -dnl ** _POSIX_C_SOURCE is defined
    -AC_CHECK_DECLS([ctime_r], , ,
    -[#define _POSIX_SOURCE 1
    -#define _POSIX_C_SOURCE 199506L
    -#include ])
    -
    -dnl On Linux we should have program_invocation_short_name
    -AC_CHECK_DECLS([program_invocation_short_name], , ,
    -[#define _GNU_SOURCE 1
    -#include ])
    -
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    
    
    =====================================
    distrib/cross-port
    =====================================
    @@ -28,7 +28,7 @@ if [ ! -f b1-stamp ]; then
     
        # For cross-compilation, at this stage you may want to set up a source
        # tree on the target machine, run the configure script there, and bring
    -   # the resulting mk/config.h file back into this tree before building
    +   # the resulting rts/ghcautoconf.h.autoconf file back into this tree before building
        # the libraries.
     
        touch mk/build.mk
    @@ -38,7 +38,7 @@ if [ ! -f b1-stamp ]; then
     
        # We could optimise slightly by not building hslibs here.  Also, building
        # the RTS is not necessary (and might not be desirable if we're using
    -   # a config.h from the target system).
    +   # a ghcautoconf.h from the target system).
        make stage1
     
       cd ..
    
    
    =====================================
    docs/coding-style.html
    =====================================
    @@ -108,7 +108,7 @@ POSIX-compliant to explicitly say so by having #include
     
     

  • Some architectures have memory alignment constraints. Others don't have any constraints but go faster if you align things. These -macros (from config.h) tell you which alignment to use +macros (from ghcautoconf.h) tell you which alignment to use
       /* minimum alignment of unsigned int */
    
    
    =====================================
    docs/rts/rts.tex
    =====================================
    @@ -1970,10 +1970,9 @@ Here the right-hand sides of @range@ and @ys@ are both thunks; the former
     is static while the latter is dynamic.
     
     The layout of a thunk is the same as that for a function closure.
    -However, thunks must have a payload of at least @MIN_UPD_SIZE@
    -words to allow it to be overwritten with a black hole and an
    -indirection.  The compiler may have to add extra non-pointer fields to
    -satisfy this constraint.
    +However, a thunk header always contains an extra padding word at the
    +end. This allows the thunk to be overwritten with an indirection,
    +where the padding word will be repurposed as the indirectee pointer.
     
     \begin{center}
     \begin{tabular}{|l|l|l|l|l|}\hline
    
    
    =====================================
    docs/users_guide/exts/primitives.rst
    =====================================
    @@ -12,7 +12,7 @@ you write will be optimised to the efficient unboxed version in any
     case. And if it isn't, we'd like to know about it.
     
     All these primitive data types and operations are exported by the
    -library :base-ref:`GHC.Exts.`.
    +module :base-ref:`GHC.Exts.`.
     
     If you want to mention any of the primitive data types or operations in
     your program, you must first import ``GHC.Exts`` to bring them into
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -155,10 +155,10 @@ generatePackageCode context@(Context stage pkg _ _) = do
         when (pkg == rts) $ do
             root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file ->
                 build $ target context GenApply [] [file]
    -        let go gen file = generate file (semiEmptyTarget stage) gen
             root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ ->
                 need . pure =<< pkgSetupConfigFile context
    -        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH
    +        root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ ->
    +            need . pure =<< pkgSetupConfigFile context
             root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context
             root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines"
             root -/- "**" -/- dir -/- "include/rts/EventTypes.h" %> genEventTypes "--event-types-array"
    @@ -357,62 +357,6 @@ ghcWrapper stage  = do
                                          else [])
                                    ++ [ "$@" ]
     
    --- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that
    --- the resulting 'String' is a valid C preprocessor identifier.
    -cppify :: String -> String
    -cppify = replaceEq '-' '_' . replaceEq '.' '_'
    -
    --- | Generate @ghcplatform.h@ header.
    --- ROMES:TODO: For the runtime-retargetable GHC, these will eventually have to
    --- be determined at runtime, and no longer hardcoded to a file (passed as -D
    --- flags to the preprocessor, probably)
    -generateGhcPlatformH :: Expr String
    -generateGhcPlatformH = do
    -    trackGenerateHs
    -    stage    <- getStage
    -    let chooseSetting x y = case stage of { Stage0 {} -> x; _ -> y }
    -    buildPlatform  <- chooseSetting (queryBuild targetPlatformTriple) (queryHost targetPlatformTriple)
    -    buildArch      <- chooseSetting (queryBuild queryArch)   (queryHost queryArch)
    -    buildOs        <- chooseSetting (queryBuild queryOS)     (queryHost queryOS)
    -    buildVendor    <- chooseSetting (queryBuild queryVendor) (queryHost queryVendor)
    -    hostPlatform   <- chooseSetting (queryHost targetPlatformTriple) (queryTarget targetPlatformTriple)
    -    hostArch       <- chooseSetting (queryHost queryArch)    (queryTarget queryArch)
    -    hostOs         <- chooseSetting (queryHost queryOS)      (queryTarget queryOS)
    -    hostVendor     <- chooseSetting (queryHost queryVendor)  (queryTarget queryVendor)
    -    ghcUnreg       <- queryTarget tgtUnregisterised
    -    return . unlines $
    -        [ "#if !defined(__GHCPLATFORM_H__)"
    -        , "#define __GHCPLATFORM_H__"
    -        , ""
    -        , "#define BuildPlatform_TYPE  " ++ cppify buildPlatform
    -        , "#define HostPlatform_TYPE   " ++ cppify hostPlatform
    -        , ""
    -        , "#define " ++ cppify buildPlatform   ++ "_BUILD 1"
    -        , "#define " ++ cppify hostPlatform ++ "_HOST 1"
    -        , ""
    -        , "#define " ++ buildArch   ++ "_BUILD_ARCH 1"
    -        , "#define " ++ hostArch ++ "_HOST_ARCH 1"
    -        , "#define BUILD_ARCH " ++ show buildArch
    -        , "#define HOST_ARCH "  ++ show hostArch
    -        , ""
    -        , "#define " ++ buildOs   ++ "_BUILD_OS 1"
    -        , "#define " ++ hostOs ++ "_HOST_OS 1"
    -        , "#define BUILD_OS " ++ show buildOs
    -        , "#define HOST_OS "  ++ show hostOs
    -        , ""
    -        , "#define " ++ buildVendor   ++ "_BUILD_VENDOR 1"
    -        , "#define " ++ hostVendor ++ "_HOST_VENDOR 1"
    -        , "#define BUILD_VENDOR " ++ show buildVendor
    -        , "#define HOST_VENDOR "  ++ show hostVendor
    -        , ""
    -        ]
    -        ++
    -        [ "#define UnregisterisedCompiler 1" | ghcUnreg ]
    -        ++
    -        [ ""
    -        , "#endif /* __GHCPLATFORM_H__ */"
    -        ]
    -
     generateSettings :: Expr String
     generateSettings = do
         ctx <- getContext
    
    
    =====================================
    hadrian/src/Rules/Lint.hs
    =====================================
    @@ -22,6 +22,8 @@ lintRules = do
           cmd_ (Cwd "libraries/base") "./configure"
       "rts" -/- "include" -/- "ghcautoconf.h" %> \_ ->
           cmd_ (Cwd "rts") "./configure"
    +  "rts" -/- "include" -/- "ghcplatform.h" %> \_ ->
    +      cmd_ (Cwd "rts") "./configure"
     
     lint :: Action () -> Action ()
     lint lintAction = do
    @@ -68,7 +70,6 @@ base = do
       let includeDirs =
             [ "rts/include"
             , "libraries/base/include"
    -        , stage1RtsInc
             ]
       runHLint includeDirs [] "libraries/base"
     
    
    
    =====================================
    hadrian/src/Rules/Register.hs
    =====================================
    @@ -51,12 +51,6 @@ configurePackageRules = do
               isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend
               when isGmp $
                 need [buildP -/- "include/ghc-gmp.h"]
    -        when (pkg == rts) $ do
    -          -- Rts.h is a header listed in the cabal file, and configuring
    -          -- therefore wants to ensure that the header "works" post-configure.
    -          -- But it (transitively) includes this, so we must ensure it exists
    -          -- for that check to work.
    -          need [buildP -/- "include/ghcplatform.h"]
             Cabal.configurePackage ctx
     
         root -/- "**/autogen/cabal_macros.h" %> \out -> do
    
    
    =====================================
    hadrian/src/Rules/SourceDist.hs
    =====================================
    @@ -156,7 +156,8 @@ prepareTree dest = do
           , pkgPath terminfo -/- "configure"
           , "configure"
           , "aclocal.m4"
    -      , "mk" -/- "config.h.in" ]
    +      , "mk" -/- "unused.h.in"
    +      ]
     
         copyAlexHappyFiles =
           forM_ alexHappyFiles $ \(stg, pkg, inp, out) -> do
    
    
    =====================================
    hadrian/src/Settings/Packages.hs
    =====================================
    @@ -281,8 +281,8 @@ rtsPackageArgs = package rts ? do
         targetArch     <- queryTarget queryArch
         targetOs       <- queryTarget queryOS
         targetVendor   <- queryTarget queryVendor
    -    ghcUnreg       <- yesNo <$> queryTarget tgtUnregisterised
    -    ghcEnableTNC   <- yesNo <$> queryTarget tgtTablesNextToCode
    +    ghcUnreg       <- queryTarget tgtUnregisterised
    +    ghcEnableTNC   <- queryTarget tgtTablesNextToCode
         rtsWays        <- getRtsWays
         way            <- getWay
         path           <- getBuildPath
    @@ -355,8 +355,8 @@ rtsPackageArgs = package rts ? do
                 , "-DTargetArch="                ++ show targetArch
                 , "-DTargetOS="                  ++ show targetOs
                 , "-DTargetVendor="              ++ show targetVendor
    -            , "-DGhcUnregisterised="         ++ show ghcUnreg
    -            , "-DTablesNextToCode="          ++ show ghcEnableTNC
    +            , "-DGhcUnregisterised="         ++ show (yesNo ghcUnreg)
    +            , "-DTablesNextToCode="          ++ show (yesNo ghcEnableTNC)
                 , "-DRtsWay=\"rts_" ++ show way ++ "\""
                 ]
     
    @@ -414,6 +414,8 @@ rtsPackageArgs = package rts ? do
               , flag UseLibzstd                 `cabalFlag` "libzstd"
               , flag StaticLibzstd              `cabalFlag` "static-libzstd"
               , queryTargetTarget tgtSymbolsHaveLeadingUnderscore `cabalFlag` "leading-underscore"
    +          , ghcUnreg                        `cabalFlag` "unregisterised"
    +          , ghcEnableTNC                    `cabalFlag` "tables-next-to-code"
               , Debug `wayUnit` way             `cabalFlag` "find-ptr"
               ]
             , builder (Cabal Setup) ? mconcat
    
    
    =====================================
    libraries/base/changelog.md
    =====================================
    @@ -9,14 +9,16 @@
       * Always use `safe` call to `read` for regular files and block devices on unix if the RTS is multi-threaded, regardless of `O_NONBLOCK`.
         ([CLC proposal #166](https://github.com/haskell/core-libraries-committee/issues/166))
       * Export List from Data.List ([CLC proposal #182](https://github.com/haskell/core-libraries-committee/issues/182)).
    +  * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86))
    +  * Fix exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192))
     
    -## 4.19.0.0 *TBA*
    +## 4.19.0.0 *October 2023*
       * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{head,tail}`.
         Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it.
         ([CLC proposal #87](https://github.com/haskell/core-libraries-committee/issues/87) and [#114](https://github.com/haskell/core-libraries-committee/issues/114))
    -  * `GHC.Conc.Sync` now exports `fromThreadId :: ThreadId -> Word64`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
    +  * Add `fromThreadId :: ThreadId -> Word64` to `GHC.Conc.Sync`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
       * Add `Data.List.!?` ([CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110))
    -  * `maximumBy`/`minimumBy` are now marked as `INLINE` improving performance for unpackable
    +  * Mark `maximumBy`/`minimumBy` as `INLINE` improving performance for unpackable
         types significantly.
       * Add INLINABLE pragmas to `generic*` functions in Data.OldList ([CLC proposal #129](https://github.com/haskell/core-libraries-committee/issues/130))
       * Export `getSolo` from `Data.Tuple`.
    @@ -34,20 +36,18 @@
       * Add `COMPLETE` pragmas to the `TypeRep`, `SSymbol`, `SChar`, and `SNat` pattern synonyms.
           ([CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149))
       * Make `($)` representation polymorphic ([CLC proposal #132](https://github.com/haskell/core-libraries-committee/issues/132))
    -  * Implemented [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst),
    +  * Implement [GHC Proposal #433](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst),
         adding the class `Unsatisfiable :: ErrorMessage -> TypeError` to `GHC.TypeError`,
         which provides a mechanism for custom type errors that reports the errors in
         a more predictable behaviour than `TypeError`.
       * Add more instances for `Compose`: `Enum`, `Bounded`, `Num`, `Real`, `Integral` ([CLC proposal #160](https://github.com/haskell/core-libraries-committee/issues/160))
       * Make `(&)` representation polymorphic in the return type ([CLC proposal #158](https://github.com/haskell/core-libraries-committee/issues/158))
       * Implement `GHC.IORef.atomicSwapIORef` via a new dedicated primop `atomicSwapMutVar#` ([CLC proposal #139](https://github.com/haskell/core-libraries-committee/issues/139))
    -  * Change codebuffers to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134))
    -  * Add nominal role annotations to SNat/SSymbol/SChar ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170))
    +  * Change `BufferCodec` to use an unboxed implementation, while providing a compatibility layer using pattern synonyms. ([CLC proposal #134](https://github.com/haskell/core-libraries-committee/issues/134))
    +  * Add nominal role annotations to `SNat` / `SSymbol` / `SChar` ([CLC proposal #170](https://github.com/haskell/core-libraries-committee/issues/170))
       * Make `Semigroup`'s `stimes` specializable. ([CLC proposal #8](https://github.com/haskell/core-libraries-committee/issues/8))
    -  * Deprecate `Data.List.NonEmpty.unzip` ([CLC proposal #86](https://github.com/haskell/core-libraries-committee/issues/86))
    -  * Fixed exponent overflow/underflow bugs in the `Read` instances for `Float` and `Double` ([CLC proposal #192](https://github.com/haskell/core-libraries-committee/issues/192))
       * Implement `copyBytes`, `fillBytes`, `moveBytes` and `stimes` for `Data.Array.Byte.ByteArray` using primops ([CLC proposal #188](https://github.com/haskell/core-libraries-committee/issues/188))
    -  * Add rewrite rules for conversion between Int64/Word64 and Float/Double on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)).
    +  * Add rewrite rules for conversion between `Int64` / `Word64` and `Float` / `Double` on 64-bit architectures ([CLC proposal #203](https://github.com/haskell/core-libraries-committee/issues/203)).
     
     ## 4.18.0.0 *March 2023*
       * Shipped with GHC 9.6.1
    
    
    =====================================
    m4/fp_cc_supports__atomics.m4
    =====================================
    @@ -61,12 +61,4 @@ AC_DEFUN([FP_CC_SUPPORTS__ATOMICS],
             AC_MSG_RESULT(no)
             AC_MSG_ERROR([C compiler needs to support __atomic primitives.])
         ])
    -    AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    -    if test "$need_latomic" = 1; then
    -        AC_SUBST([NeedLibatomic],[YES])
    -    else
    -        AC_SUBST([NeedLibatomic],[NO])
    -    fi
    -    AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    -        [Define to 1 if we need -latomic.])
     ])
    
    
    =====================================
    m4/fptools_set_haskell_platform_vars.m4
    =====================================
    @@ -82,7 +82,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS],
             solaris2)
                 test -z "[$]2" || eval "[$]2=OSSolaris2"
                 ;;
    -        mingw32|windows)
    +        mingw32|mingw64|windows)
                 test -z "[$]2" || eval "[$]2=OSMinGW32"
                 ;;
             freebsd)
    @@ -162,8 +162,6 @@ AC_DEFUN([GHC_SUBSECTIONS_VIA_SYMBOLS],
                 TargetHasSubsectionsViaSymbols=NO
              else
                 TargetHasSubsectionsViaSymbols=YES
    -            AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    -                   [Define to 1 if Apple-style dead-stripping is supported.])
              fi
             ],
             [TargetHasSubsectionsViaSymbols=NO
    
    
    =====================================
    m4/ghc_convert_os.m4
    =====================================
    @@ -22,7 +22,7 @@ AC_DEFUN([GHC_CONVERT_OS],[
           openbsd*)
             $3="openbsd"
             ;;
    -      windows|mingw32)
    +      windows|mingw32|mingw64)
             $3="mingw32"
             ;;
           # As far as I'm aware, none of these have relevant variants
    
    
    =====================================
    rts/PrimOps.cmm
    =====================================
    @@ -740,25 +740,15 @@ stg_atomicModifyMutVar2zh ( gcptr mv, gcptr f )
     
             obviously we can share (f x).
     
    -         z = [stg_ap_2 f x]  (max (HS + 2) MIN_UPD_SIZE)
    -         y = [stg_sel_0 z]   (max (HS + 1) MIN_UPD_SIZE)
    +         z = [stg_ap_2 f x]  (SIZEOF_StgThunkHeader + WDS(2))
    +         y = [stg_sel_0 z]   (SIZEOF_StgThunkHeader + WDS(1))
         */
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 1
    -#define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),WDS(MIN_UPD_SIZE-1))
    -#else
     #define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(1))
     #define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),0)
    -#endif
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2
    -#define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
    -#else
     #define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(2))
     #define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),0)
    -#endif
     
     #define SIZE (THUNK_2_SIZE + THUNK_1_SIZE)
     
    @@ -815,13 +805,8 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f )
              z = [stg_ap_2 f x]  (max (HS + 2) MIN_UPD_SIZE)
         */
     
    -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2
    -#define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
    -#define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
    -#else
     #define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(2))
     #define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),0)
    -#endif
     
         HP_CHK_GEN_TICKY(THUNK_SIZE);
     
    
    
    =====================================
    rts/configure.ac
    =====================================
    @@ -22,17 +22,153 @@ dnl     #define SIZEOF_CHAR 0
     dnl   recently.
     AC_PREREQ([2.69])
     
    +AC_CONFIG_FILES([ghcplatform.h.top])
    +
     AC_CONFIG_HEADERS([ghcautoconf.h.autoconf])
     
    +AC_ARG_ENABLE(asserts-all-ways,
    +[AS_HELP_STRING([--enable-asserts-all-ways],
    +                [Usually ASSERTs are only compiled in the DEBUG way,
    +                 this will enable them in all ways.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableAssertsAllWays])],
    +  [EnableAssertsAllWays=NO]
    +)
    +if test "$enable_asserts_all_ways" = "yes" ; then
    +   AC_DEFINE([USE_ASSERTS_ALL_WAYS], [1], [Compile-in ASSERTs in all ways.])
    +fi
    +
    +AC_ARG_ENABLE(native-io-manager,
    +[AS_HELP_STRING([--enable-native-io-manager],
    +                [Enable the native I/O manager by default.])],
    +  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableNativeIOManager])],
    +  [EnableNativeIOManager=NO]
    +)
    +if test "$EnableNativeIOManager" = "YES"; then
    +  AC_DEFINE_UNQUOTED([DEFAULT_NATIVE_IO_MANAGER], [1], [Enable Native I/O manager as default.])
    +fi
    +
     # We have to run these unconditionally, but we may discard their
     # results in the following code
     AC_CANONICAL_BUILD
     AC_CANONICAL_HOST
     
    +dnl ** Do a build with tables next to code?
    +dnl --------------------------------------------------------------
    +
    +AS_IF(
    +  [test "$CABAL_FLAG_tables_next_to_code" = 1],
    +  [AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are laid out next to code])])
    +
    +dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set),
    +dnl later CC is copied to CC_STAGE{1,2,3}
    +AC_PROG_CC([cc gcc clang])
    +
    +dnl make extensions visible to allow feature-tests to detect them lateron
    +AC_USE_SYSTEM_EXTENSIONS
    +
    +dnl ** Used to determine how to compile ghc-prim's atomics.c, used by
    +dnl    unregisterised, Sparc, and PPC backends. Also determines whether
    +dnl    linking to libatomic is required for atomic operations, e.g. on
    +dnl    RISCV64 GCC.
    +FP_CC_SUPPORTS__ATOMICS
    +AC_DEFINE([HAVE_C11_ATOMICS], [1], [Does C compiler support __atomic primitives?])
    +AC_DEFINE_UNQUOTED([NEED_ATOMIC_LIB], [$need_latomic],
    +    [Define to 1 if we need -latomic for sub-word atomic operations.])
    +
    +dnl ** look to see if we have a C compiler using an llvm back end.
    +dnl
    +FP_CC_LLVM_BACKEND
    +AS_IF([test x"$CcLlvmBackend" = x"YES"],
    +  [AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
    +
    +GHC_CONVERT_PLATFORM_PARTS([build], [Build])
    +FPTOOLS_SET_PLATFORM_VARS([build],[Build])
    +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Build])
    +
     GHC_CONVERT_PLATFORM_PARTS([host], [Host])
     FPTOOLS_SET_PLATFORM_VARS([host], [Host])
     FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
     
    +GHC_SUBSECTIONS_VIA_SYMBOLS
    +AS_IF([test x"${TargetHasSubsectionsViaSymbols}" = x"YES"],
    +  [AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
    +    [Define to 1 if Apple-style dead-stripping is supported.])])
    +
    +dnl --------------------------------------------------
    +dnl * Platform header file and syscall feature tests
    +dnl ### checking the state of the local header files and syscalls ###
    +
    +dnl ** Enable large file support.  NB. do this before testing the type of
    +dnl    off_t, because it will affect the result of that test.
    +AC_SYS_LARGEFILE
    +
    +dnl ** check for specific header (.h) files that we are interested in
    +AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h])
    +
    +dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708
    +AC_CHECK_HEADERS([sys/cpuset.h], [], [],
    +[[#if HAVE_SYS_PARAM_H
    +# include 
    +#endif
    +]])
    +
    +dnl ** check whether a declaration for `environ` is provided by libc.
    +FP_CHECK_ENVIRON
    +
    +dnl ** do we have long longs?
    +AC_CHECK_TYPES([long long])
    +
    +dnl ** what are the sizes of various types
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
    +if test "$ac_cv_type_long_long" = yes; then
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
    +fi
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
    +
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
    +FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
    +
    +
    +FP_CHECK_FUNC([WinExec],
    +  [@%:@include ], [WinExec("",0)])
    +
    +FP_CHECK_FUNC([GetModuleFileName],
    +  [@%:@include ], [GetModuleFileName((HMODULE)0,(LPTSTR)0,0)])
    +
    +dnl ** check for more functions
    +dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
    +AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity sched_getaffinity setlocale uselocale])
    +
    +dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
    +dnl ** _POSIX_C_SOURCE is defined
    +AC_CHECK_DECLS([ctime_r], , ,
    +[#define _POSIX_SOURCE 1
    +#define _POSIX_C_SOURCE 199506L
    +#include ])
    +
    +dnl On Linux we should have program_invocation_short_name
    +AC_CHECK_DECLS([program_invocation_short_name], , ,
    +[#define _GNU_SOURCE 1
    +#include ])
    +
     dnl ** check for math library
     dnl    Keep that check as early as possible.
     dnl    as we need to know whether we need libm
    @@ -140,7 +276,6 @@ AC_ARG_ENABLE(large-address-space,
     )
     
     use_large_address_space=no
    -AC_CHECK_SIZEOF([void *])
     if test "$ac_cv_sizeof_void_p" -eq 8 ; then
         if test "x$EnableLargeAddressSpace" = "xyes" ; then
             if test "$ghc_host_os" = "darwin" ; then
    @@ -223,19 +358,41 @@ dnl --------------------------------------------------------------
     AC_OUTPUT
     
     dnl ######################################################################
    -dnl Generate ghcautoconf.h
    +dnl Generate ghcplatform.h
     dnl ######################################################################
     
     [
     mkdir -p include
    +
    +touch include/ghcplatform.h
    +> include/ghcplatform.h
    +
    +cat ghcplatform.h.top                          >> include/ghcplatform.h
    +]
    +
    +dnl ** Do an unregisterised build?
    +dnl --------------------------------------------------------------
    +AS_IF(
    +  [test "$CABAL_FLAG_unregisterised" = 1],
    +  [echo "#define UnregisterisedCompiler 1"     >> include/ghcplatform.h])
    +
    +[
    +cat $srcdir/ghcplatform.h.bottom               >> include/ghcplatform.h
    +]
    +
    +dnl ######################################################################
    +dnl Generate ghcautoconf.h
    +dnl ######################################################################
    +
    +[
     touch include/ghcautoconf.h
     > include/ghcautoconf.h
     
     echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h
     echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h
    -# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO
    +# Copy the contents of ghcautoconf.h.autoconf, turning '#define PACKAGE_FOO
     # "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
    -cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \
    +cat ghcautoconf.h.autoconf | sed \
        -e 's,^\([	 ]*\)#[	 ]*define[	 ][	 ]*\(PACKAGE_[A-Z]*\)[	 ][ 	]*".*".*$,\1/* #undef \2 */,' \
        -e '/__GLASGOW_HASKELL/d' \
        -e '/REMOVE ME/d' \
    
    
    =====================================
    rts/ghcplatform.h.bottom
    =====================================
    @@ -0,0 +1,2 @@
    +
    +#endif /* __GHCPLATFORM_H__ */
    
    
    =====================================
    rts/ghcplatform.h.top.in
    =====================================
    @@ -0,0 +1,23 @@
    +#if !defined(__GHCPLATFORM_H__)
    +#define __GHCPLATFORM_H__
    +
    +#define BuildPlatform_TYPE  @BuildPlatform_CPP@
    +#define HostPlatform_TYPE   @HostPlatform_CPP@
    +
    +#define @BuildPlatform_CPP at _BUILD  1
    +#define @HostPlatform_CPP at _HOST  1
    +
    +#define @BuildArch_CPP at _BUILD_ARCH  1
    +#define @HostArch_CPP at _HOST_ARCH  1
    +#define BUILD_ARCH  "@BuildArch_CPP@"
    +#define HOST_ARCH  "@HostArch_CPP@"
    +
    +#define @BuildOS_CPP at _BUILD_OS  1
    +#define @HostOS_CPP at _HOST_OS  1
    +#define BUILD_OS  "@BuildOS_CPP@"
    +#define HOST_OS  "@HostOS_CPP@"
    +
    +#define @BuildVendor_CPP at _BUILD_VENDOR  1
    +#define @HostVendor_CPP at _HOST_VENDOR  1
    +#define BUILD_VENDOR  "@BuildVendor_CPP@"
    +#define HOST_VENDOR  "@HostVendor_CPP@"
    
    
    =====================================
    rts/rts.cabal
    =====================================
    @@ -54,6 +54,10 @@ flag static-libzstd
       default: False
     flag leading-underscore
       default: False
    +flag unregisterised
    +  default: False
    +flag tables-next-to-code
    +  default: False
     flag smp
       default: True
     flag find-ptr
    @@ -240,7 +244,7 @@ library
     
           include-dirs: include
           includes: Rts.h
    -      autogen-includes: ghcautoconf.h
    +      autogen-includes: ghcautoconf.h ghcplatform.h
           install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
                             ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
                             -- ^ from include
    
    
    =====================================
    testsuite/tests/parser/should_compile/DumpSemis.stderr
    =====================================
    @@ -1829,7 +1829,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:39:6 }
    +                        { DumpSemis.hs:39:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -1862,7 +1862,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:39:8-9 }
    +                            { DumpSemis.hs:39:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -1898,7 +1898,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:40:6 }
    +                        { DumpSemis.hs:40:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -1931,7 +1931,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:40:8-9 }
    +                            { DumpSemis.hs:40:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -1969,7 +1969,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:41:6 }
    +                        { DumpSemis.hs:41:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -2002,7 +2002,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:41:8-9 }
    +                            { DumpSemis.hs:41:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -2042,7 +2042,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:42:6 }
    +                        { DumpSemis.hs:42:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -2075,7 +2075,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:42:8-9 }
    +                            { DumpSemis.hs:42:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -2100,3 +2100,5 @@
                             (NoExtField)))))]))))))]
                 (EmptyLocalBinds
                  (NoExtField)))))])))))]))
    +
    +
    
    
    =====================================
    testsuite/tests/parser/should_compile/T15323.stderr
    =====================================
    @@ -100,7 +100,14 @@
                  (EpaSpan { T15323.hs:6:17-18 }))
                 (HsNormalTok))
                (L
    -            (SrcSpanAnn (EpAnnNotUsed) { T15323.hs:6:20-54 })
    +            (SrcSpanAnn (EpAnn
    +                         (Anchor
    +                          { T15323.hs:6:20-25 }
    +                          (UnchangedAnchor))
    +                         (AnnListItem
    +                          [])
    +                         (EpaComments
    +                          [])) { T15323.hs:6:20-25 })
                 (HsOuterExplicit
                  (EpAnn
                   (Anchor
    
    
    =====================================
    testsuite/tests/printer/Test20297.stdout
    =====================================
    @@ -82,11 +82,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.hs:(5,5)-(7,7) })
    +               { Test20297.hs:5:5-7 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.hs:(5,5)-(7,7) }
    +                 { Test20297.hs:5:5-7 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -182,11 +182,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.hs:(9,5)-(11,26) })
    +               { Test20297.hs:9:5-7 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.hs:(9,5)-(11,26) }
    +                 { Test20297.hs:9:5-7 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -422,11 +422,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.ppr.hs:(4,3)-(5,7) })
    +               { Test20297.ppr.hs:4:3-5 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.ppr.hs:(4,3)-(5,7) }
    +                 { Test20297.ppr.hs:4:3-5 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -508,11 +508,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.ppr.hs:(7,3)-(9,24) })
    +               { Test20297.ppr.hs:7:3-5 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.ppr.hs:(7,3)-(9,24) }
    +                 { Test20297.ppr.hs:7:3-5 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -655,4 +655,3 @@
                             (EmptyLocalBinds
                              (NoExtField)))))]))))]}
                   [])))))])))))]))
    -
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96719ad7617c4f55a3ead99c3e2811e2f3934928...0be70e34d14e99b8f5b9a6daa839482d49c83dcc
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96719ad7617c4f55a3ead99c3e2811e2f3934928...0be70e34d14e99b8f5b9a6daa839482d49c83dcc
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 13:10:08 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Mon, 23 Oct 2023 09:10:08 -0400
    Subject: [Git][ghc/ghc][master] EPA Some tweaks to annotations
    Message-ID: <653670b0d176f_1f7b0d22d451f8230661@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    
    
    6 changed files:
    
    - compiler/GHC/Parser.y
    - compiler/GHC/Parser/Annotation.hs
    - compiler/GHC/Parser/PostProcess.hs
    - testsuite/tests/parser/should_compile/DumpSemis.stderr
    - testsuite/tests/parser/should_compile/T15323.stderr
    - testsuite/tests/printer/Test20297.stdout
    
    
    Changes:
    
    =====================================
    compiler/GHC/Parser.y
    =====================================
    @@ -2269,7 +2269,7 @@ atype :: { LHsType GhcPs }
             | PREFIX_TILDE atype             {% acsA (\cs -> sLL $1 $> (mkBangTy (EpAnn (glR $1) [mj AnnTilde $1] cs) SrcLazy $2)) }
             | PREFIX_BANG  atype             {% acsA (\cs -> sLL $1 $> (mkBangTy (EpAnn (glR $1) [mj AnnBang $1] cs) SrcStrict $2)) }
     
    -        | '{' fielddecls '}'             {% do { decls <- acsA (\cs -> (sLL $1 $> $ HsRecTy (EpAnn (glR $1) (AnnList (Just $ listAsAnchor $2) (Just $ moc $1) (Just $ mcc $3) [] []) cs) $2))
    +        | '{' fielddecls '}'             {% do { decls <- acsA (\cs -> (sLL $1 $> $ HsRecTy (EpAnn (glR $1) (AnnList (listAsAnchorM $2) (Just $ moc $1) (Just $ mcc $3) [] []) cs) $2))
                                                    ; checkRecordSyntax decls }}
                                                             -- Constructor sigs only
             | '(' ')'                        {% acsA (\cs -> sLL $1 $> $ HsTupleTy (EpAnn (glR $1) (AnnParen AnnParens (glAA $1) (glAA $2)) cs)
    @@ -2407,7 +2407,7 @@ gadt_constrlist :: { Located ([AddEpAnn]
                               ,[LConDecl GhcPs]) } -- Returned in order
     
             : 'where' '{'        gadt_constrs '}'    {% checkEmptyGADTs $
    -                                                      L (comb2 $1 $3)
    +                                                      L (comb2 $1 $4)
                                                             ([mj AnnWhere $1
                                                              ,moc $2
                                                              ,mcc $4]
    @@ -2588,8 +2588,9 @@ rhs     :: { Located (GRHSs GhcPs (LHsExpr GhcPs)) }
             : '=' exp wherebinds    {% runPV (unECP $2) >>= \ $2 ->
                                       do { let L l (bs, csw) = adaptWhereBinds $3
                                          ; let loc = (comb3 $1 $2 (L l bs))
    +                                     ; let locg = (comb2 $1 $2)
                                          ; acs (\cs ->
    -                                       sL loc (GRHSs csw (unguardedRHS (EpAnn (anc $ rs loc) (GrhsAnn Nothing (mj AnnEqual $1)) cs) loc $2)
    +                                       sL loc (GRHSs csw (unguardedRHS (EpAnn (anc $ rs locg) (GrhsAnn Nothing (mj AnnEqual $1)) cs) locg $2)
                                                           bs)) } }
             | gdrhs wherebinds      {% do { let {L l (bs, csw) = adaptWhereBinds $2}
                                           ; acs (\cs -> sL (comb2 $1 (L l bs))
    @@ -3324,7 +3325,7 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs
     alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) }
             : PATS alt_rhs { $2 >>= \ $2 ->
                              acsA (\cs -> sLLAsl $1 $>
    -                                         (Match { m_ext = EpAnn (listAsAnchor $1) [] cs
    +                                         (Match { m_ext = EpAnn (listAsAnchor $1 $>) [] cs
                                                     , m_ctxt = CaseAlt -- for \case and \cases, this will be changed during post-processing
                                                     , m_pats = $1
                                                     , m_grhss = unLoc $2 }))}
    @@ -3336,7 +3337,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) }
     
     ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) }
             : '->' exp            { unECP $2 >>= \ $2 ->
    -                                acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (glR $1) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) }
    +                                acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) }
             | gdpats              { $1 >>= \gdpats ->
                                     return $ sL1 gdpats (reverse (unLoc gdpats)) }
     
    @@ -4465,9 +4466,16 @@ hsDoAnn :: Located a -> LocatedAn t b -> AnnKeywordId -> AnnList
     hsDoAnn (L l _) (L ll _) kw
       = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (srcSpan2e l)] []
     
    -listAsAnchor :: [LocatedAn t a] -> Anchor
    -listAsAnchor [] = spanAsAnchor noSrcSpan
    -listAsAnchor (L l _:_) = spanAsAnchor (locA l)
    +listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor
    +listAsAnchor [] (L l _) = spanAsAnchor l
    +listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s)
    +
    +listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor
    +listAsAnchorM [] = Nothing
    +listAsAnchorM (L l _:_) =
    +  case locA l of
    +    RealSrcSpan ll _ -> Just $ realSpanAsAnchor ll
    +    _                -> Nothing
     
     hsTok :: Located Token -> LHsToken tok GhcPs
     hsTok (L l _) = L (mkTokenLocation l) HsTok
    @@ -4528,7 +4536,6 @@ addTrailingAnnL (L (SrcSpanAnn anns l) a) ta = do
     -- Mostly use to add AnnComma, special case it to NOP if adding a zero-width annotation
     addTrailingCommaN :: MonadP m => LocatedN a -> SrcSpan -> m (LocatedN a)
     addTrailingCommaN (L (SrcSpanAnn anns l) a) span = do
    -  -- cs <- getCommentsFor l
       let cs = emptyComments
       -- AZ:TODO: generalise updating comments into an annotation
       let anns' = if isZeroWidthSpan span
    
    
    =====================================
    compiler/GHC/Parser/Annotation.hs
    =====================================
    @@ -19,8 +19,8 @@ module GHC.Parser.Annotation (
       DeltaPos(..), deltaPos, getDeltaLine,
     
       EpAnn(..), Anchor(..), AnchorOperation(..),
    -  spanAsAnchor, realSpanAsAnchor,
       NoAnn(..),
    +  spanAsAnchor, realSpanAsAnchor, spanFromAnchor,
     
       -- ** Comments in Annotations
     
    @@ -549,6 +549,9 @@ spanAsAnchor s  = Anchor (realSrcSpan s) UnchangedAnchor
     realSpanAsAnchor :: RealSrcSpan -> Anchor
     realSpanAsAnchor s  = Anchor s UnchangedAnchor
     
    +spanFromAnchor :: Anchor -> SrcSpan
    +spanFromAnchor a = RealSrcSpan (anchor a) Strict.Nothing
    +
     -- ---------------------------------------------------------------------
     
     -- | When we are parsing we add comments that belong a particular AST
    
    
    =====================================
    compiler/GHC/Parser/PostProcess.hs
    =====================================
    @@ -831,11 +831,18 @@ mkGadtDecl loc names dcol ty = do
     
       let an = EpAnn (spanAsAnchor loc) annsa (cs Semi.<> csa)
     
    +  let bndrs_loc = case outer_bndrs of
    +        HsOuterImplicit{} -> getLoc ty
    +        HsOuterExplicit an _ ->
    +          case an of
    +            EpAnnNotUsed -> getLoc ty
    +            an' -> SrcSpanAnn (EpAnn (entry an') noAnn emptyComments) (spanFromAnchor (entry an'))
    +
       pure $ L l ConDeclGADT
                          { con_g_ext  = an
                          , con_names  = names
                          , con_dcolon = dcol
    -                     , con_bndrs  = L (getLoc ty) outer_bndrs
    +                     , con_bndrs  = L bndrs_loc outer_bndrs
                          , con_mb_cxt = mcxt
                          , con_g_args = args
                          , con_res_ty = res_ty
    
    
    =====================================
    testsuite/tests/parser/should_compile/DumpSemis.stderr
    =====================================
    @@ -1829,7 +1829,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:39:6 }
    +                        { DumpSemis.hs:39:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -1862,7 +1862,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:39:8-9 }
    +                            { DumpSemis.hs:39:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -1898,7 +1898,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:40:6 }
    +                        { DumpSemis.hs:40:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -1931,7 +1931,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:40:8-9 }
    +                            { DumpSemis.hs:40:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -1969,7 +1969,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:41:6 }
    +                        { DumpSemis.hs:41:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -2002,7 +2002,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:41:8-9 }
    +                            { DumpSemis.hs:41:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -2042,7 +2042,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:42:6 }
    +                        { DumpSemis.hs:42:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -2075,7 +2075,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:42:8-9 }
    +                            { DumpSemis.hs:42:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -2100,3 +2100,5 @@
                             (NoExtField)))))]))))))]
                 (EmptyLocalBinds
                  (NoExtField)))))])))))]))
    +
    +
    
    
    =====================================
    testsuite/tests/parser/should_compile/T15323.stderr
    =====================================
    @@ -100,7 +100,14 @@
                  (EpaSpan { T15323.hs:6:17-18 }))
                 (HsNormalTok))
                (L
    -            (SrcSpanAnn (EpAnnNotUsed) { T15323.hs:6:20-54 })
    +            (SrcSpanAnn (EpAnn
    +                         (Anchor
    +                          { T15323.hs:6:20-25 }
    +                          (UnchangedAnchor))
    +                         (AnnListItem
    +                          [])
    +                         (EpaComments
    +                          [])) { T15323.hs:6:20-25 })
                 (HsOuterExplicit
                  (EpAnn
                   (Anchor
    
    
    =====================================
    testsuite/tests/printer/Test20297.stdout
    =====================================
    @@ -82,11 +82,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.hs:(5,5)-(7,7) })
    +               { Test20297.hs:5:5-7 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.hs:(5,5)-(7,7) }
    +                 { Test20297.hs:5:5-7 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -182,11 +182,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.hs:(9,5)-(11,26) })
    +               { Test20297.hs:9:5-7 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.hs:(9,5)-(11,26) }
    +                 { Test20297.hs:9:5-7 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -422,11 +422,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.ppr.hs:(4,3)-(5,7) })
    +               { Test20297.ppr.hs:4:3-5 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.ppr.hs:(4,3)-(5,7) }
    +                 { Test20297.ppr.hs:4:3-5 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -508,11 +508,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.ppr.hs:(7,3)-(9,24) })
    +               { Test20297.ppr.hs:7:3-5 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.ppr.hs:(7,3)-(9,24) }
    +                 { Test20297.ppr.hs:7:3-5 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -655,4 +655,3 @@
                             (EmptyLocalBinds
                              (NoExtField)))))]))))]}
                   [])))))])))))]))
    -
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de78b32a611b764a077ea70b02068f7d9cfa535a
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de78b32a611b764a077ea70b02068f7d9cfa535a
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 13:10:47 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Mon, 23 Oct 2023 09:10:47 -0400
    Subject: [Git][ghc/ghc][master] Update primitives.rst
    Message-ID: <653670d720ac9_1f7b0d22d458ec233937@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    
    
    1 changed file:
    
    - docs/users_guide/exts/primitives.rst
    
    
    Changes:
    
    =====================================
    docs/users_guide/exts/primitives.rst
    =====================================
    @@ -12,7 +12,7 @@ you write will be optimised to the efficient unboxed version in any
     case. And if it isn't, we'd like to know about it.
     
     All these primitive data types and operations are exported by the
    -library :base-ref:`GHC.Exts.`.
    +module :base-ref:`GHC.Exts.`.
     
     If you want to mention any of the primitive data types or operations in
     your program, you must first import ``GHC.Exts`` to bring them into
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5a8780d9cdb08a07663b97f75a4cc1553fbf2b0
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5a8780d9cdb08a07663b97f75a4cc1553fbf2b0
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 15:38:17 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 11:38:17 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] More wibbles
    Message-ID: <65369369c40e6_1f7b0d26b071d02383b0@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    358f3509 by Simon Peyton Jones at 2023-10-23T16:37:54+01:00
    More wibbles
    
    In particular, respect OtherCon
    
    - - - - -
    
    
    4 changed files:
    
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Seq.hs
    - compiler/GHC/Core/Subst.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -617,11 +617,19 @@ exprSummary env e = go env e []
           | Just con <- isDataConWorkId_maybe f
           = ArgIsCon (DataAlt con) (map (exprSummary env) args)
     
    -      | Just rhs <- expandUnfolding_maybe (idUnfolding f)
    -      = go (zapSubstEnv env) rhs args
    +      | OtherCon cs <- unfolding
    +      = ArgIsNot cs
     
    -      | idArity f > valArgCount args
    +      | Just rhs <- expandUnfolding_maybe unfolding
    +      = pprTrace "exprSummary:expanded" (ppr f <+> text "==>" <+> ppr rhs) $
    +        go (zapSubstEnv env) rhs args
    +
    +      | pprTrace "exprSummary:no-expand" (ppr f <+> text "unf" <+> ppr (idUnfolding f)) $
    +        idArity f > valArgCount args
           = ArgIsLam
     
           | otherwise
           = ArgNoInfo
    +      where
    +        unfolding = idUnfolding f
    +
    
    
    =====================================
    compiler/GHC/Core/Seq.hs
    =====================================
    @@ -7,7 +7,7 @@
     module GHC.Core.Seq (
             -- * Utilities for forcing Core structures
             seqExpr, seqExprs, seqUnfolding, seqRules,
    -        megaSeqIdInfo, seqRuleInfo, seqBinds,
    +        megaSeqIdInfo, seqRuleInfo, seqBinds, seqGuidance
         ) where
     
     import GHC.Prelude
    
    
    =====================================
    compiler/GHC/Core/Subst.hs
    =====================================
    @@ -37,6 +37,7 @@ module GHC.Core.Subst (
     import GHC.Prelude
     
     import GHC.Core
    +import GHC.Core.Unfold
     import GHC.Core.FVs
     import GHC.Core.Seq
     import GHC.Core.Utils
    @@ -54,6 +55,7 @@ import GHC.Types.Unique.Supply
     
     import GHC.Builtin.Names
     import GHC.Data.Maybe
    +import GHC.Data.Bag
     
     import GHC.Utils.Misc
     import GHC.Utils.Outputable
    @@ -509,18 +511,70 @@ substUnfolding subst df@(DFunUnfolding { df_bndrs = bndrs, df_args = args })
         (subst',bndrs') = substBndrs subst bndrs
         args'           = map (substExpr subst') args
     
    -substUnfolding subst unf@(CoreUnfolding { uf_tmpl = tmpl, uf_src = src })
    +substUnfolding subst unf@(CoreUnfolding { uf_tmpl = tmpl, uf_src = src
    +                                        , uf_guidance = guidance })
       -- Retain stable unfoldings
       | not (isStableSource src)  -- Zap an unstable unfolding, to save substitution work
       = NoUnfolding
       | otherwise                 -- But keep a stable one!
    -  = seqExpr new_tmpl `seq`
    -    unf { uf_tmpl = new_tmpl }
    +  = seqExpr new_tmpl `seq` seqGuidance new_guidance `seq`
    +    unf { uf_tmpl = new_tmpl, uf_guidance = new_guidance  }
       where
    -    new_tmpl = substExpr subst tmpl
    +    new_tmpl     = substExpr subst tmpl
    +    new_guidance = substGuidance subst guidance
     
     substUnfolding _ unf = unf      -- NoUnfolding, OtherCon
     
    +substGuidance :: Subst -> UnfoldingGuidance -> UnfoldingGuidance
    +substGuidance subst guidance
    +  = case guidance of
    +      UnfNever   -> guidance
    +      UnfWhen {} -> guidance
    +      UnfIfGoodArgs { ug_args = args, ug_tree = et }
    +        -> UnfIfGoodArgs { ug_args = args', ug_tree = substExprTree subst' et }
    +        where
    +           (subst', args') = substBndrs subst args
    +
    +-------------------------
    +substExprTree :: Subst -> ExprTree -> ExprTree
    +-- ExprTrees have free variables, and so must be substituted
    +substExprTree _     TooBig = TooBig
    +substExprTree subst (SizeIs { et_size  = size
    +                            , et_cases = cases
    +                            , et_ret   = ret_discount })
    +   = case extra_size of
    +       STooBig     -> TooBig
    +       SSize extra -> SizeIs { et_size = size + extra
    +                             , et_cases = cases'
    +                             , et_ret = ret_discount }
    +   where
    +     (extra_size, cases') = foldr subst_ct (sizeZero, emptyBag) cases
    +
    +     subst_ct :: CaseTree -> (Size, Bag CaseTree) -> (Size, Bag CaseTree)
    +     subst_ct (ScrutOf v d) (n, cts)
    +        = case lookupIdSubst subst v of
    +             Var v' -> (n, ScrutOf v' d `consBag` cts)
    +             _ -> (n, cts)
    +
    +     subst_ct (CaseOf v case_bndr alts) (n, cts)
    +        = case lookupIdSubst subst v of
    +             Var v' -> (n, CaseOf v' case_bndr' alts' `consBag` cts)
    +             _ -> (n `addSize` extra, cts)
    +        where
    +          (subst', case_bndr') = substBndr subst case_bndr
    +          alts' = map (subst_alt subst') alts
    +          extra = keptCaseSize boringInlineContext case_bndr alts
    +
    +     subst_alt subst (AltTree con bs rhs)
    +        = AltTree con bs' (substExprTree subst' rhs)
    +        where
    +          (subst', bs') = substBndrs subst bs
    +
    +boringInlineContext :: InlineContext
    +boringInlineContext = IC { ic_free = \_ -> ArgNoInfo
    +                         , ic_bound = emptyVarEnv
    +                         , ic_want_res = False }
    +
     ------------------
     substIdOcc :: Subst -> Id -> Id
     -- These Ids should not be substituted to non-Ids
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -20,10 +20,11 @@ find, unsurprisingly, a Core expression.
     module GHC.Core.Unfold (
             Unfolding, UnfoldingGuidance,   -- Abstract types
     
    -        ExprTree, exprTree, exprTreeSize,
    +        ExprTree, exprTree, exprTreeSize, keptCaseSize,
             exprTreeWillInline, couldBeSmallEnoughToInline,
             ArgSummary(..), hasArgInfo,
    -        Size, leqSize, addSizeN, adjustSize,
    +
    +        Size(..), leqSize, addSizeN, addSize, adjustSize, sizeZero,
             InlineContext(..),
     
             UnfoldingOpts (..), defaultUnfoldingOpts,
    @@ -1001,6 +1002,9 @@ instance Outputable Size where
       ppr STooBig = text "STooBig"
       ppr (SSize n) = int n
     
    +sizeZero :: Size
    +sizeZero = SSize 0
    +
     sizeN :: Int -> Size
     sizeN n = SSize n
     
    @@ -1142,3 +1146,5 @@ lookupBndr (IC { ic_bound = bound_env, ic_free = lookup_free }) var
       | Just info <- assertPpr (isId var) (ppr var) $
                      lookupVarEnv bound_env var = info
       | otherwise                               = lookup_free var
    +
    +
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/358f3509bf6d496e65586f804191e57d4f350d68
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/358f3509bf6d496e65586f804191e57d4f350d68
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 15:41:09 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 11:41:09 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] oops remove spurious trace
    Message-ID: <65369415dc96b_1f7b0d26df8bc82387ac@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9228296c by Simon Peyton Jones at 2023-10-23T16:40:42+01:00
    oops remove spurious trace
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -621,11 +621,9 @@ exprSummary env e = go env e []
           = ArgIsNot cs
     
           | Just rhs <- expandUnfolding_maybe unfolding
    -      = pprTrace "exprSummary:expanded" (ppr f <+> text "==>" <+> ppr rhs) $
    -        go (zapSubstEnv env) rhs args
    +      = go (zapSubstEnv env) rhs args
     
    -      | pprTrace "exprSummary:no-expand" (ppr f <+> text "unf" <+> ppr (idUnfolding f)) $
    -        idArity f > valArgCount args
    +      | idArity f > valArgCount args
           = ArgIsLam
     
           | otherwise
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9228296c6e5d7edd673a01d4c5e9ff8ec7e475e9
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9228296c6e5d7edd673a01d4c5e9ff8ec7e475e9
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 16:34:39 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 12:34:39 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Value args only in ExprTrees
    Message-ID: <6536a09f9fcdd_1f7b0d281f67d823937a@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    5dd14df7 by Simon Peyton Jones at 2023-10-23T17:34:18+01:00
    Value args only in ExprTrees
    
    - - - - -
    
    
    4 changed files:
    
    - compiler/GHC/Core.hs
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Subst.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core.hs
    =====================================
    @@ -1388,9 +1388,9 @@ data UnfoldingGuidance
         }
     
       | UnfIfGoodArgs {     -- Arose from a normal Id
    -      ug_args :: [Var],      -- Arguments
    +      ug_args :: [Id],       -- Value arguments only
           ug_tree :: ExprTree    -- Abstraction of the body
    -      -- Invariant: free vars of ug_tree are the ug_args, plus variables
    +      -- Invariant: free Ids of ug_tree are the ug_args, plus Ids
           --            in scope at the binding site of the function definition
         }
     
    @@ -1411,7 +1411,9 @@ data CaseTree
                            -- nothing relies on non-empty-ness
       | ScrutOf Id Int     -- If this Id is bound to a value, apply this discount
     
    -data AltTree  = AltTree AltCon [Var] ExprTree
    +data AltTree  = AltTree AltCon
    +                        [Id]      -- Term variables only
    +                        ExprTree
     
     {- Note [UnfoldingCache]
     ~~~~~~~~~~~~~~~~~~~~~~~~
    
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -267,10 +267,11 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
                                , text "case depth =" <+> int case_depth
                                , text "final_size =" <+> ppr final_size ]
       where
    -    (lone_variable, arg_infos, call_cont) = contArgs cont
    -    cont_info  = interestingCallContext env call_cont
    -    case_depth = seCaseDepth env
    -    opts       = seUnfoldingOpts env
    +    (arg_infos, call_cont) = contArgs cont
    +    lone_variable = loneVariable cont
    +    cont_info     = interestingCallContext env call_cont
    +    case_depth    = seCaseDepth env
    +    opts          = seUnfoldingOpts env
     
         -- Unpack the UnfoldingCache lazily because it may not be needed, and all
         -- its fields are strict; so evaluating unf_cache at all forces all the
    @@ -551,24 +552,24 @@ rule for (*) (df d) can fire.  To do this
     -}
     
     -------------------
    -contArgs :: SimplCont -> (Bool, [ArgSummary], SimplCont)
    --- Summarises value args, discards type args and coercions
    +contArgs :: SimplCont -> ( [ArgSummary]   -- One for each value argument
    +                         , SimplCont )    -- The rest
    +-- Summarises value args, discards type args and casts.
     -- The returned continuation of the call is only used to
     -- answer questions like "are you interesting?"
    -contArgs cont
    -  | lone cont = (True, [], cont)
    -  | otherwise = go [] cont
    +contArgs cont = go [] cont
       where
    -    lone (ApplyToTy  {}) = False  -- See Note [Lone variables] in GHC.Core.Unfold
    -    lone (ApplyToVal {}) = False  -- NB: even a type application or cast
    -    lone (CastIt {})     = False  --     stops it being "lone"
    -    lone _               = True
    -
         go args (ApplyToVal { sc_arg = arg, sc_env = se, sc_cont = k })
                                             = go (exprSummary se arg : args) k
         go args (ApplyToTy { sc_cont = k }) = go args k
         go args (CastIt _ k)                = go args k
    -    go args k                           = (False, reverse args, k)
    +    go args k                           = (reverse args, k)
    +
    +loneVariable :: SimplCont -> Bool
    +loneVariable (ApplyToTy  {}) = False  -- See Note [Lone variables] in GHC.Core.Unfold
    +loneVariable (ApplyToVal {}) = False  -- NB: even a type application or cast
    +loneVariable (CastIt {})     = False  --     stops it being "lone"
    +loneVariable _               = True
     
     ------------------------------
     exprSummary :: SimplEnv -> CoreExpr -> ArgSummary
    @@ -583,10 +584,13 @@ exprSummary :: SimplEnv -> CoreExpr -> ArgSummary
     --     We want to see that x is (a,b) at the call site of f
     exprSummary env e = go env e []
       where
    -    go :: SimplEnv -> CoreExpr -> [CoreExpr] -> ArgSummary
    +    go :: SimplEnv -> CoreExpr
    +       -> [CoreExpr]   -- Value arg only
    +       -> ArgSummary
         go env (Cast e _) as = go env e as
         go env (Tick _ e) as = go env e as
    -    go env (App f a)  as = go env f (a:as)
    +    go env (App f a)  as | isValArg a = go env f (a:as)
    +                         | otherwise  = go env f as
         go env (Let b e)  as = go env' e as
           where
             env' = env `addNewInScopeIds` bindersOf b
    @@ -613,17 +617,20 @@ exprSummary env e = go env e []
     
         go _ _ _ = ArgNoInfo
     
    -    go_var env f args
    +    go_var :: SimplEnv -> Id
    +           -> [CoreExpr]   -- Value args only
    +           -> ArgSummary
    +    go_var env f val_args
           | Just con <- isDataConWorkId_maybe f
    -      = ArgIsCon (DataAlt con) (map (exprSummary env) args)
    +      = ArgIsCon (DataAlt con) (map (exprSummary env) val_args)
     
           | OtherCon cs <- unfolding
           = ArgIsNot cs
     
           | Just rhs <- expandUnfolding_maybe unfolding
    -      = go (zapSubstEnv env) rhs args
    +      = go (zapSubstEnv env) rhs val_args
     
    -      | idArity f > valArgCount args
    +      | idArity f > length val_args
           = ArgIsLam
     
           | otherwise
    
    
    =====================================
    compiler/GHC/Core/Subst.hs
    =====================================
    @@ -41,8 +41,9 @@ import GHC.Core.Unfold
     import GHC.Core.FVs
     import GHC.Core.Seq
     import GHC.Core.Utils
    -import GHC.Core.Type    -- Subst comes from here
    -import GHC.Core.Coercion( tyCoFVsOfCo, mkCoVarCo, substCoVarBndr )
    +import GHC.Core.TyCo.Subst    -- Subst comes from here
    +import GHC.Core.Type( mkTyVarTy, noFreeVarsOfType, tyCoFVsOfType, tyCoVarsOfType )
    +import GHC.Core.Coercion( tyCoFVsOfCo, mkCoVarCo )
     
     import GHC.Types.Var.Set
     import GHC.Types.Var.Env as InScopeSet
    @@ -341,14 +342,14 @@ preserve occ info in rules.
     -- | Substitutes a 'Var' for another one according to the 'Subst' given, returning
     -- the result and an updated 'Subst' that should be used by subsequent substitutions.
     -- 'IdInfo' is preserved by this process, although it is substituted into appropriately.
    -substBndr :: Subst -> Var -> (Subst, Var)
    +substBndr :: HasDebugCallStack => Subst -> Var -> (Subst, Var)
     substBndr subst bndr
       | isTyVar bndr  = substTyVarBndr subst bndr
       | isCoVar bndr  = substCoVarBndr subst bndr
       | otherwise     = substIdBndr (text "var-bndr") subst subst bndr
     
     -- | Applies 'substBndr' to a number of 'Var's, accumulating a new 'Subst' left-to-right
    -substBndrs :: Traversable f => Subst -> f Var -> (Subst, f Var)
    +substBndrs :: (HasDebugCallStack, Traversable f) => Subst -> f Var -> (Subst, f Var)
     substBndrs = mapAccumL substBndr
     {-# INLINE substBndrs #-}
     
    @@ -531,17 +532,18 @@ substGuidance subst guidance
           UnfNever   -> guidance
           UnfWhen {} -> guidance
           UnfIfGoodArgs { ug_args = args, ug_tree = et }
    -        -> UnfIfGoodArgs { ug_args = args', ug_tree = substExprTree subst' et }
    +        -> UnfIfGoodArgs { ug_args = args, ug_tree = substExprTree id_env et }
             where
    -           (subst', args') = substBndrs subst args
    +           id_env = getIdSubstEnv subst `delVarEnvList` args
     
     -------------------------
    -substExprTree :: Subst -> ExprTree -> ExprTree
    --- ExprTrees have free variables, and so must be substituted
    +substExprTree :: IdSubstEnv -> ExprTree -> ExprTree
    +-- ExprTrees have free Ids, and so must be substituted
    +-- But Ids /only/ not tyvars, so substitution is very simple
     substExprTree _     TooBig = TooBig
    -substExprTree subst (SizeIs { et_size  = size
    -                            , et_cases = cases
    -                            , et_ret   = ret_discount })
    +substExprTree id_env (SizeIs { et_size  = size
    +                             , et_cases = cases
    +                             , et_ret   = ret_discount })
        = case extra_size of
            STooBig     -> TooBig
            SSize extra -> SizeIs { et_size = size + extra
    @@ -552,23 +554,23 @@ substExprTree subst (SizeIs { et_size  = size
     
          subst_ct :: CaseTree -> (Size, Bag CaseTree) -> (Size, Bag CaseTree)
          subst_ct (ScrutOf v d) (n, cts)
    -        = case lookupIdSubst subst v of
    -             Var v' -> (n, ScrutOf v' d `consBag` cts)
    +        = case lookupVarEnv id_env v of
    +             Just (Var v') -> (n, ScrutOf v' d `consBag` cts)
                  _ -> (n, cts)
     
          subst_ct (CaseOf v case_bndr alts) (n, cts)
    -        = case lookupIdSubst subst v of
    -             Var v' -> (n, CaseOf v' case_bndr' alts' `consBag` cts)
    +        = case lookupVarEnv id_env v of
    +             Just (Var v') -> (n, CaseOf v' case_bndr alts' `consBag` cts)
                  _ -> (n `addSize` extra, cts)
             where
    -          (subst', case_bndr') = substBndr subst case_bndr
    -          alts' = map (subst_alt subst') alts
    +          id_env' = id_env `delVarEnv` case_bndr
    +          alts' = map (subst_alt id_env') alts
               extra = keptCaseSize boringInlineContext case_bndr alts
     
    -     subst_alt subst (AltTree con bs rhs)
    -        = AltTree con bs' (substExprTree subst' rhs)
    +     subst_alt id_env (AltTree con bs rhs)
    +        = AltTree con bs (substExprTree id_env' rhs)
             where
    -          (subst', bs') = substBndrs subst bs
    +          id_env' = id_env `delVarEnvList` bs
     
     boringInlineContext :: InlineContext
     boringInlineContext = IC { ic_free = \_ -> ArgNoInfo
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -1033,7 +1033,7 @@ data InlineContext
          }
     
     data ArgSummary = ArgNoInfo
    -                | ArgIsCon AltCon [ArgSummary]  -- Includes type args
    +                | ArgIsCon AltCon [ArgSummary]  -- Value args only
                     | ArgIsNot [AltCon]
                     | ArgIsLam
     
    @@ -1096,14 +1096,17 @@ caseTreeSize ic (CaseOf scrut_var case_bndr alts)
           ArgNoInfo     -> keptCaseSize ic case_bndr alts
           ArgIsLam      -> keptCaseSize ic case_bndr alts
           ArgIsNot cons -> keptCaseSize ic case_bndr (trim_alts cons alts)
    +
           arg_summ@(ArgIsCon con args)
    -         | Just (AltTree _ bndrs rhs) <- find_alt con alts
    -         , let new_summaries :: [(Var,ArgSummary)]
    +         | Just at@(AltTree alt_con bndrs rhs) <- find_alt con alts
    +         , let new_summaries :: [(Id,ArgSummary)]
                    new_summaries = (case_bndr,arg_summ) : bndrs `zip` args
                       -- Don't forget to add a summary for the case binder!
                    ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
                          -- In DEFAULT case, bs is empty, so extending is a no-op
    -         -> exprTreeSize ic' rhs
    +         -> assertPpr ((alt_con == DEFAULT) || (bndrs `equalLength` args)) (ppr arg_summ $$ ppr at) $
    +            exprTreeSize ic' rhs
    +
              | otherwise  -- Happens for empty alternatives
              -> keptCaseSize ic case_bndr alts
     
    @@ -1132,7 +1135,8 @@ keptCaseSize ic case_bndr alts
         -- If there are no alternatives (case e of {}), we get just the size of the scrutinee
       where
         size_alt :: AltTree -> Size
    -    size_alt (AltTree _ bndrs rhs) = exprTreeSize ic' rhs
    +    size_alt (AltTree _ bndrs rhs)
    +       = exprTreeSize ic' rhs
             -- Cost for the alternative is already in `rhs`
           where
             -- Must extend ic_bound, lest a captured variable is
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5dd14df786b897eb976a8bd2cf8d257cba56bc76
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5dd14df786b897eb976a8bd2cf8d257cba56bc76
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 16:42:15 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 12:42:15 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Another wibble
    Message-ID: <6536a26785a5c_1f7b0d282ad5f0243578@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    bb79ef2b by Simon Peyton Jones at 2023-10-23T17:42:02+01:00
    Another wibble
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -590,7 +590,9 @@ exprTree opts args expr
           where
             alt_alt_tree :: Id -> Alt Var -> AltTree
             alt_alt_tree v (Alt con bs rhs)
    -          = AltTree con bs (10 `etAddN` go (add_alt_bndrs v bs) rhs)
    +          = AltTree con val_bs (10 `etAddN` go (add_alt_bndrs v val_bs) rhs)
    +          where
    +            val_bs = filter isId bs
     
             add_alt_bndrs v bs
               | v `elemVarSet` avs = (avs `extendVarSetList` (b:bs), lvs)
    @@ -1141,7 +1143,7 @@ keptCaseSize ic case_bndr alts
           where
             -- Must extend ic_bound, lest a captured variable is
             -- looked up in ic_free by lookupBndr
    -        new_summaries :: [(Var,ArgSummary)]
    +        new_summaries :: [(Id,ArgSummary)]
             new_summaries = [(b,ArgNoInfo) | b <- case_bndr:bndrs]
             ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
     
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bb79ef2b991d24560d4c1b6cf94c9696e1e1149a
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bb79ef2b991d24560d4c1b6cf94c9696e1e1149a
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 19:46:01 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 15:46:01 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Be a little bit more eager
    Message-ID: <6536cd799e355_1f7b0d2c9810f8255198@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    1fe57484 by Simon Peyton Jones at 2023-10-23T20:45:44+01:00
    Be a little bit more eager
    
    - - - - -
    
    
    2 changed files:
    
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -615,7 +615,8 @@ exprSummary env e = go env e []
           where
             env' = modifyInScope env b  -- Tricky corner here
     
    -    go _ _ _ = ArgNoInfo
    +    go _ _ _ = ArgIsNot []    -- Some structure; not all boring
    +                              -- Example of improvement: base/tests/T9848
     
         go_var :: SimplEnv -> Id
                -> [CoreExpr]   -- Value args only
    @@ -624,12 +625,16 @@ exprSummary env e = go env e []
           | Just con <- isDataConWorkId_maybe f
           = ArgIsCon (DataAlt con) (map (exprSummary env) val_args)
     
    -      | OtherCon cs <- unfolding
    -      = ArgIsNot cs
    +      | DFunUnfolding {} <- unfolding
    +      = ArgIsNot []  -- Says "this is a data con" without saying which
    +                     -- Will also return this for ($df d1 .. dn)
     
           | Just rhs <- expandUnfolding_maybe unfolding
           = go (zapSubstEnv env) rhs val_args
     
    +      | OtherCon cs <- unfolding
    +      = ArgIsNot cs
    +
           | idArity f > length val_args
           = ArgIsLam
     
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -562,9 +562,9 @@ exprTree opts args expr
         -----------------------------
         -- size_up_app is used when there's ONE OR MORE value args
         go_app :: ETVars -> CoreExpr -> [CoreExpr] -> ExprTree
    -                   -- args are the non-void value args
    +                   -- args are the value args
         go_app vs (App fun arg) args
    -               | arg_is_free arg = go_app vs fun args
    +               | isTypeArg arg   = go_app vs fun args
                    | otherwise       = go vs arg `et_add`
                                        go_app vs fun (arg:args)
         go_app vs (Var fun)     args = callTree opts vs fun args
    @@ -1089,7 +1089,8 @@ caseTreeSize :: InlineContext -> CaseTree -> Size
     caseTreeSize ic (ScrutOf bndr disc)
       = case lookupBndr ic bndr of
           ArgNoInfo   -> sizeN 0
    -      ArgIsNot {} -> sizeN 0
    +      ArgIsNot {} -> sizeN (-disc)  -- E.g. bndr is a DFun application
    +                                    --      T8732 need to inline mapM_
           ArgIsLam    -> sizeN (-disc)  -- Apply discount
           ArgIsCon {} -> sizeN (-disc)  -- Apply discount
     
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1fe57484a32e5c5e24d67457412df83cf095eb05
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1fe57484a32e5c5e24d67457412df83cf095eb05
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 20:42:50 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 16:42:50 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Comment out unused arg_is_free
    Message-ID: <6536daca2b9d_1f7b0d2df34c882557f4@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    40dc3213 by Simon Peyton Jones at 2023-10-23T21:42:32+01:00
    Comment out unused arg_is_free
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -667,6 +667,7 @@ recordCaseOf vs (Tick _ e) = recordCaseOf vs e
     recordCaseOf vs (Cast e _) = recordCaseOf vs e
     recordCaseOf _     _       = Nothing
     
    +{-
     arg_is_free :: CoreExpr -> Bool
     -- "free" means we don't charge for this
     -- occurrence in a function application
    @@ -676,6 +677,7 @@ arg_is_free (Cast e _)    = arg_is_free e
     arg_is_free (Type {})     = True
     arg_is_free (Coercion {}) = True
     arg_is_free _             = False
    +-}
     
     id_is_free :: Id -> Bool
     id_is_free id = not (isJoinId id) && isZeroBitTy (idType id)
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/40dc321331a0dea1910e857ca9182ab0903e2952
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/40dc321331a0dea1910e857ca9182ab0903e2952
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 20:48:25 2023
    From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz))
    Date: Mon, 23 Oct 2023 16:48:25 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/az/T23459-haddock-option-a
    Message-ID: <6536dc195f7d8_1f7b0d2e0188e82563b9@gitlab.mail>
    
    
    
    Alan Zimmerman pushed new branch wip/az/T23459-haddock-option-a at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/T23459-haddock-option-a
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 20:52:50 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 23 Oct 2023 16:52:50 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Fix scoping bug
    Message-ID: <6536dd21d74c7_1f7b0d2e46ae782595c6@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    0d908997 by Simon Peyton Jones at 2023-10-23T21:52:38+01:00
    Fix scoping bug
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -230,17 +230,21 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
                                   BoringCtxt -> False
                                   _          -> True
     
    -          zapped_env = zapSubstEnv env
    -          context = IC { ic_bound    = mkVarEnv (arg_bndrs `zip` arg_infos)
    -                       , ic_free     = getFreeSummary zapped_env
    +          bound_env = mkVarEnv (arg_bndrs `zip` (arg_infos ++ repeat ArgNoInfo))
    +                      -- Crucial to include /all/ arg_bndrs, lest we treat
    +                      -- them as free and use ic_free instead
    +          context = IC { ic_bound    = bound_env
    +                       , ic_free     = getFreeSummary
                            , ic_want_res = want_result }
               size :: Size
               size = exprTreeSize context expr_tree
     
    -          getFreeSummary :: SimplEnv -> Id -> ArgSummary
    +          in_scope = seInScope env
    +
    +          getFreeSummary :: Id -> ArgSummary
               -- Get the ArgSummary of a free variable
    -          getFreeSummary env x
    -            = case lookupInScope (seInScope env) x of
    +          getFreeSummary x
    +            = case lookupInScope in_scope x of
                     Just x' | warnPprTrace (not (isId x')) "GFS" (vcat
                                 [ ppr fn <+> equals <+> ppr unf_template
                                 , text "expr_tree:" <+> ppr expr_tree
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0d90899712a4be18293d58cacd2941c291664a6b
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0d90899712a4be18293d58cacd2941c291664a6b
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 22:34:43 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Mon, 23 Oct 2023 18:34:43 -0400
    Subject: [Git][ghc/ghc][wip/T24106] rts/eventlog: Record CCS allocations,
     entries, and ticks
    Message-ID: <6536f50341f3b_1f7b0d308a3218263229@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/T24106 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    c54a3c12 by Ben Gamari at 2023-10-23T18:34:32-04:00
    rts/eventlog: Record CCS allocations, entries, and ticks
    
    Here we introduce a family of three new eventlog events to
    record allocations, entries, and ticks from cost-centre stacks when time
    profiling.
    
    Fixes #24106.
    
    (cherry picked from commit 8feef4a9dba3a94486be1f6d6aab6abb96b61366)
    
    - - - - -
    
    
    3 changed files:
    
    - docs/users_guide/eventlog-formats.rst
    - rts/eventlog/EventLog.c
    - rts/gen_event_types.py
    
    
    Changes:
    
    =====================================
    docs/users_guide/eventlog-formats.rst
    =====================================
    @@ -741,7 +741,6 @@ A variable-length packet encoding a heap profile sample broken down by,
        :field Word8: stack depth
        :field Word32[]: cost centre stack starting with inner-most (cost centre numbers)
     
    -
     String break-down
     ^^^^^^^^^^^^^^^^^
     
    @@ -771,8 +770,8 @@ the current cost centre stack is emitted. Together these
     enable a user to construct an approximate track of the
     executation of their program.
     
    -Profile begin event
    -~~~~~~~~~~~~~~~~~~~
    +Time Profile begin event
    +~~~~~~~~~~~~~~~~~~~~~~~~
     
     .. event-type:: PROF_BEGIN
     
    @@ -782,10 +781,8 @@ Profile begin event
     
        Marks the beginning of a time profile.
     
    -Profile sample event
    -~~~~~~~~~~~~~~~~~~~~
    -
    -A variable-length packet encoding a profile sample.
    +Time profile sample event
    +~~~~~~~~~~~~~~~~~~~~~~~~~
     
     .. event-type:: PROF_SAMPLE_COST_CENTRE
     
    @@ -796,6 +793,43 @@ A variable-length packet encoding a profile sample.
        :field Word8: stack depth
        :field Word32[]: cost centre stack starting with inner-most (cost centre numbers)
     
    +   Marks a point in time where a capability was seen to be executing in the
    +   given cost-centre stack.
    +
    +Time profile cost-centre events
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +
    +.. event-type:: PROF_BEGIN_COST_CENTRE_STACK_SAMPLES
    +
    +   :tag: 170
    +   :length: fixed
    +
    +   Marks the beginning of a set of :event-type:`PROF_SAMPLE_COST_CENTRE_STACK`
    +   samples.
    +
    +.. event-type:: PROF_SAMPLE_COST_CENTRE_STACK
    +
    +   :tag: 171
    +   :length: fixed
    +   :field Word64: cost-centre stack number
    +   :field Word64: parent cost-centre stack number
    +   :field Word64: cost-centre number
    +   :field Word64: allocations performed by CCS in bytes
    +   :field Word64: number of entries
    +   :field Word64: number of ticks
    +
    +   Marks the total allocations, entries and ticks attributed to a cost-centre
    +   stack up to this point in execution.
    +
    +.. event-type:: PROF_END_COST_CENTRE_STACK_SAMPLES
    +
    +   :tag: 172
    +   :length: fixed
    +
    +   Marks the end of a set of :event-type:`PROF_SAMPLE_COST_CENTRE_STACK`
    +   samples.
    +
    +
     Biographical profile sample event
     ---------------------------------
     
    
    
    =====================================
    rts/eventlog/EventLog.c
    =====================================
    @@ -1355,6 +1355,37 @@ void postProfSampleCostCentre(Capability *cap,
         RELEASE_LOCK(&eventBufMutex);
     }
     
    +static void postProfCostCentreStackAllocs_(CostCentreStack const *ccs)
    +{
    +    ensureRoomForEvent(&eventBuf, EVENT_PROF_SAMPLE_COST_CENTRE_STACK);
    +    postEventHeader(&eventBuf, EVENT_PROF_SAMPLE_COST_CENTRE_STACK);
    +    postWord64(&eventBuf, ccs->ccsID);
    +    postWord64(&eventBuf, ccs->cc->ccID);
    +    postWord64(&eventBuf, ccs->prevStack->ccsID);
    +    postWord64(&eventBuf, ccs->mem_alloc * sizeof(W_));
    +    postWord64(&eventBuf, ccs->scc_count);
    +    postWord64(&eventBuf, ccs->time_ticks);
    +
    +    for (IndexTable *i = ccs->indexTable; i != 0; i = i->next) {
    +        if (!i->back_edge) {
    +            postProfCostCentreStackAllocs_(i->ccs);
    +        }
    +    }
    +}
    +
    +void postProfCostCentreStackAllocs(CostCentreStack const *ccs)
    +{
    +    ACQUIRE_LOCK(&eventBufMutex);
    +    ensureRoomForEvent(&eventBuf, EVENT_PROF_BEGIN_COST_CENTRE_STACK_SAMPLES);
    +    postEventHeader(&eventBuf, EVENT_PROF_BEGIN_COST_CENTRE_STACK_SAMPLES);
    +
    +    postProfCostCentreStackAllocs_(ccs);
    +
    +    ensureRoomForEvent(&eventBuf, EVENT_PROF_END_COST_CENTRE_STACK_SAMPLES);
    +    postEventHeader(&eventBuf, EVENT_PROF_END_COST_CENTRE_STACK_SAMPLES);
    +    RELEASE_LOCK(&eventBufMutex);
    +}
    +
     // This event is output at the start of profiling so the tick interval can
     // be reported. Once the tick interval is reported the total executation time
     // can be calculated from how many samples there are.
    
    
    =====================================
    rts/gen_event_types.py
    =====================================
    @@ -120,6 +120,12 @@ event_types = [
         EventType(167, 'PROF_SAMPLE_COST_CENTRE',      VariableLength,        'Time profile cost-centre stack'),
         EventType(168, 'PROF_BEGIN',                   [Word64],              'Start of a time profile'),
         EventType(169, 'IPE',                          VariableLength,        'An IPE entry'),
    +    EventType(170, 'PROF_BEGIN_COST_CENTRE_STACK_SAMPLES',
    +                                                   [],                    'Marks the beginning of a set of PROF_SAMPLE_COST_CENTRE_STACK samples'),
    +    EventType(171, 'PROF_SAMPLE_COST_CENTRE_STACK',[Word64, Word64, Word64, Word64, Word64, Word64],
    +                                                                          'Report allocations, ticks, and entries performed by a cost-centre stack'),
    +    EventType(172, 'PROF_END_COST_CENTRE_STACK_SAMPLES',
    +                                                   [],                    'Marks the end of a set of PROF_SAMPLE_COST_CENTRE_STACK samples'),
     
         EventType(181, 'USER_BINARY_MSG',              VariableLength,        'User binary message'),
     
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c54a3c121e2d8ed65669c0bff5b2dd170e9529fb
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c54a3c121e2d8ed65669c0bff5b2dd170e9529fb
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 23:26:36 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Mon, 23 Oct 2023 19:26:36 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/sym-type
    Message-ID: <6537012c5a0ef_1f7b0d31c7a81827041b@gitlab.mail>
    
    
    
    Ben Gamari pushed new branch wip/sym-type at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/sym-type
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 23:28:34 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Mon, 23 Oct 2023 19:28:34 -0400
    Subject: [Git][ghc/ghc][wip/sym-type] rts/linker: Clearly define SymType
    Message-ID: <653701a2b7e3c_1f7b0d31c7a8182723e@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/sym-type at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    13a6f3f1 by Ben Gamari at 2023-10-23T19:28:18-04:00
    rts/linker: Clearly define SymType
    
    Previously SymType was both an enumeration of three symbol types *and*
    an orthogonal flag (`DUP_DISCARD`, introduced in !9475). This was quite
    fragile as it meant that to extract the symbol type one had to careful
    mask out the flag. Naturally this wasn't done consistently.
    
    Fix this by renaming the field to `flags` and adding an accessor.
    
    Fixes #24117.
    
    - - - - -
    
    
    5 changed files:
    
    - rts/Linker.c
    - rts/LinkerInternals.h
    - rts/linker/Elf.c
    - rts/linker/MachO.c
    - rts/linker/PEi386.c
    
    
    Changes:
    
    =====================================
    rts/Linker.c
    =====================================
    @@ -226,7 +226,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key,
     static const char *
     symbolTypeString (SymType type)
     {
    -    switch (type & ~SYM_TYPE_DUP_DISCARD) {
    +    switch (type) {
             case SYM_TYPE_CODE: return "code";
             case SYM_TYPE_DATA: return "data";
             case SYM_TYPE_INDIRECT_DATA: return "indirect-data";
    @@ -262,6 +262,7 @@ int ghciInsertSymbolTable(
        SymbolAddr* data,
        SymStrength strength,
        SymType type,
    +   uint16_t flags,
        ObjectCode *owner)
     {
        RtsSymbolInfo *pinfo = lookupStrHashTable(table, key);
    @@ -271,21 +272,21 @@ int ghciInsertSymbolTable(
           pinfo->value = data;
           pinfo->owner = owner;
           pinfo->strength = strength;
    -      pinfo->type = type;
    +      pinfo->flags = (uint16_t) type | flags;
           insertStrHashTable(table, key, pinfo);
           return 1;
        }
    -   else if (pinfo->type ^ type)
    +   else if (getRtsSymbolType(pinfo) != type)
        {
            /* We were asked to discard the symbol on duplicates, do so quietly.  */
    -       if (!(type & SYM_TYPE_DUP_DISCARD))
    +       if (!(flags & SYM_FLAG_DUP_DISCARD))
            {
              debugBelch("Symbol type mismatch.\n");
              debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n",
                         key, obj_name, symbolTypeString(type));
              debugBelch("      yet was defined by %" PATH_FMT " to be a %s symbol.\n",
                         pinfo->owner ? pinfo->owner->fileName : WSTR(""),
    -                    symbolTypeString(pinfo->type));
    +                    symbolTypeString(getRtsSymbolType(pinfo)));
            }
            return 1;
        }
    @@ -466,7 +467,7 @@ initLinker_ (int retain_cafs)
         for (const RtsSymbolVal *sym = rtsSyms; sym->lbl != NULL; sym++) {
             if (! ghciInsertSymbolTable(WSTR("(GHCi built-in symbols)"),
                                         symhash, sym->lbl, sym->addr,
    -                                    sym->strength, sym->type, NULL)) {
    +                                    sym->strength, sym->type, 0, NULL)) {
                 barf("ghciInsertSymbolTable failed");
             }
             IF_DEBUG(linker, debugBelch("initLinker: inserting rts symbol %s, %p\n", sym->lbl, sym->addr));
    @@ -476,7 +477,7 @@ initLinker_ (int retain_cafs)
         if (! ghciInsertSymbolTable(WSTR("(GHCi built-in symbols)"), symhash,
                                     MAYBE_LEADING_UNDERSCORE_STR("newCAF"),
                                     retain_cafs ? newRetainedCAF : newGCdCAF,
    -                                HS_BOOL_FALSE, SYM_TYPE_CODE, NULL)) {
    +                                HS_BOOL_FALSE, SYM_TYPE_CODE, 0, NULL)) {
             barf("ghciInsertSymbolTable failed");
         }
     
    @@ -864,7 +865,7 @@ HsBool removeLibrarySearchPath(HsPtr dll_path_index)
     HsInt insertSymbol(pathchar* obj_name, SymbolName* key, SymbolAddr* data)
     {
         return ghciInsertSymbolTable(obj_name, symhash, key, data, HS_BOOL_FALSE,
    -                                 SYM_TYPE_CODE, NULL);
    +                                 SYM_TYPE_CODE, 0, NULL);
     }
     
     /* -----------------------------------------------------------------------------
    @@ -961,7 +962,7 @@ SymbolAddr* lookupDependentSymbol (SymbolName* lbl, ObjectCode *dependent, SymTy
             if (strcmp(lbl, "__fini_array_start") == 0) { return (SymbolAddr *) &RTS_NO_FINI; }
             if (type) {
                 // This is an assumption
    -            *type = pinfo->type;
    +            *type = getRtsSymbolType(pinfo);
             }
     
             if (dependent) {
    @@ -1696,7 +1697,7 @@ int ocTryLoad (ObjectCode* oc) {
                 && !ghciInsertSymbolTable(oc->fileName, symhash, symbol.name,
                                           symbol.addr,
                                           isSymbolWeak(oc, symbol.name),
    -                                      symbol.type, oc)) {
    +                                      symbol.type, 0, oc)) {
                 return 0;
             }
         }
    
    
    =====================================
    rts/LinkerInternals.h
    =====================================
    @@ -55,17 +55,27 @@ typedef struct _Section    Section;
     
     /* What kind of thing a symbol identifies. We need to know this to determine how
      * to process overflowing relocations. See Note [Processing overflowed relocations].
    - * This is bitfield however only the option SYM_TYPE_DUP_DISCARD can be combined
    - * with the other values. */
    + */
     typedef enum _SymType {
         SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */
         SYM_TYPE_DATA = 1 << 1, /* the symbol is data */
         SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */
    -    SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library
    -                                      however if a duplicate is found with a mismatching
    -                                      SymType then discard this one.  */
     } SymType;
     
    +#define SYM_TYPE_MASK (SYM_TYPE_CODE | SYM_TYPE_DATA | SYM_TYPE_INDIRECT_DATA)
    +
    +INLINE_HEADER SymType symbolFlagsToSymbolType(uint16_t flags) {
    +    return (SymType) (flags & SYM_TYPE_MASK);
    +}
    +
    +/*
    + * The symbol is a symbol in a BFD import library
    + * however if a duplicate is found with a mismatching
    + * SymType then discard this one.
    + *
    + */
    +#define SYM_FLAG_DUP_DISCARD (1 << 3)
    +
     
     #if defined(OBJFORMAT_ELF)
     #  include "linker/ElfTypes.h"
    @@ -438,9 +448,14 @@ typedef struct _RtsSymbolInfo {
         SymbolAddr* value;
         ObjectCode *owner;
         SymStrength strength;
    -    SymType type;
    +    // This is a bitfield combining SymType with the SYM_FLAG_* flags.
    +    uint16_t flags;
     } RtsSymbolInfo;
     
    +INLINE_HEADER SymType getRtsSymbolType(RtsSymbolInfo *pinfo) {
    +    return symbolFlagsToSymbolType(pinfo->flags);
    +}
    +
     #include "BeginPrivate.h"
     
     void exitLinker( void );
    @@ -466,6 +481,8 @@ int ghciInsertSymbolTable(
         SymbolAddr* data,
         SymStrength weak,
         SymType type,
    +    // One of SYM_FLAG_*
    +    uint16_t flags,
         ObjectCode *owner);
     
     /* Lock-free version of lookupSymbol. When 'dependent' is not NULL, adds it as a
    
    
    =====================================
    rts/linker/Elf.c
    =====================================
    @@ -1083,7 +1083,7 @@ ocGetNames_ELF ( ObjectCode* oc )
                                setWeakSymbol(oc, nm);
                            }
                            if (!ghciInsertSymbolTable(oc->fileName, symhash,
    -                                                  nm, symbol->addr, isWeak, sym_type, oc)
    +                                                  nm, symbol->addr, isWeak, sym_type, 0, oc)
                                ) {
                                goto fail;
                            }
    
    
    =====================================
    rts/linker/MachO.c
    =====================================
    @@ -1390,14 +1390,15 @@ ocGetNames_MachO(ObjectCode* oc)
                         {
                                 IF_DEBUG(linker_verbose, debugBelch("ocGetNames_MachO: inserting %s\n", nm));
                                 SymbolAddr* addr = oc->info->macho_symbols[i].addr;
    -                            // TODO: Make figure out how to determine this from the object file
    -                            SymType sym_type = SYM_TYPE_CODE;
    +                            // TODO: Figure out how to determine this from the object file
    +                            const SymType sym_type = SYM_TYPE_CODE;
                                 ghciInsertSymbolTable( oc->fileName
                                                      , symhash
                                                      , nm
                                                      , addr
                                                      , HS_BOOL_FALSE
                                                      , sym_type
    +                                                 , 0
                                                      , oc);
     
                                 oc->symbols[curSymbol].name = nm;
    @@ -1440,7 +1441,7 @@ ocGetNames_MachO(ObjectCode* oc)
     
                     IF_DEBUG(linker_verbose, debugBelch("ocGetNames_MachO: inserting common symbol: %s\n", nm));
                     ghciInsertSymbolTable(oc->fileName, symhash, nm,
    -                                       (void*)commonCounter, HS_BOOL_FALSE, sym_type, oc);
    +                                       (void*)commonCounter, HS_BOOL_FALSE, sym_type, 0, oc);
                     oc->symbols[curSymbol].name = nm;
                     oc->symbols[curSymbol].addr = oc->info->macho_symbols[i].addr;
                     curSymbol++;
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -299,7 +299,7 @@
        These two issues mean that for GHC we need to take a different approach
        to handling import libraries.  For normal C libraries we have proper
        differentiation between CODE and DATA.   For GHC produced import libraries
    -   we do not.   As such the SYM_TYPE_DUP_DISCARD tells the linker that if a
    +   we do not.   As such the SYM_FLAG_DUP_DISCARD tells the linker that if a
        duplicate symbol is found, and we were going to discard it anyway, just do
        so quitely.  This works because the RTS symbols themselves are provided by
        the currently loaded RTS as built-in symbols.
    @@ -438,7 +438,7 @@ void initLinker_PEi386(void)
         if (!ghciInsertSymbolTable(WSTR("(GHCi/Ld special symbols)"),
                                    symhash, "__image_base__",
                                    GetModuleHandleW (NULL), HS_BOOL_TRUE,
    -                               SYM_TYPE_CODE, NULL)) {
    +                               SYM_TYPE_CODE, 0, NULL)) {
             barf("ghciInsertSymbolTable failed");
         }
     
    @@ -1814,9 +1814,8 @@ ocGetNames_PEi386 ( ObjectCode* oc )
               sname = strdup (sname);
               addr  = strdup (addr);
               type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA;
    -          type |= SYM_TYPE_DUP_DISCARD;
               if (!ghciInsertSymbolTable(oc->fileName, symhash, sname,
    -                                     addr, false, type, oc)) {
    +                                     addr, false, type, SYM_FLAG_DUP_DISCARD, oc)) {
                  releaseOcInfo (oc);
                  stgFree (oc->image);
                  oc->image = NULL;
    @@ -1895,7 +1894,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
               stgFree(tmp);
               sname = strdup (sname);
               if (!ghciInsertSymbolTable(oc->fileName, symhash, sname,
    -                                     addr, false, type, oc))
    +                                     addr, false, type, 0, oc))
                    return false;
     
               break;
    @@ -1918,7 +1917,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
              }
     
              if (! ghciInsertSymbolTable(oc->fileName, symhash, sname, addr,
    -                                     isWeak, type, oc))
    +                                     isWeak, type, 0, oc))
                  return false;
           } else {
               /* We're skipping the symbol, but if we ever load this
    @@ -2321,7 +2320,9 @@ SymbolAddr *lookupSymbol_PEi386(SymbolName *lbl, ObjectCode *dependent, SymType
             sym = lookupSymbolInDLLs(lbl, dependent);
             return sym; // might be NULL if not found
         } else {
    -        if (type) *type = pinfo->type;
    +        if (type) {
    +            *type = getRtsSymbolType(pinfo);
    +        }
     
             if (pinfo && pinfo->owner && isSymbolImport (pinfo->owner, lbl))
             {
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13a6f3f15895322c96956ef8e48e8a640e866ff6
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13a6f3f15895322c96956ef8e48e8a640e866ff6
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 23:29:01 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Mon, 23 Oct 2023 19:29:01 -0400
    Subject: [Git][ghc/ghc][wip/sym-type] rts/linker: Clearly define SymType
    Message-ID: <653701bdd7f16_1f7b0d320c11c4272523@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/sym-type at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    b1341272 by Ben Gamari at 2023-10-23T19:28:53-04:00
    rts/linker: Clearly define SymType
    
    Previously SymType was both an enumeration of three symbol types *and*
    an orthogonal flag (`DUP_DISCARD`, introduced in !9475). This was quite
    fragile as it meant that to extract the symbol type one had to careful
    mask out the flag. Naturally this wasn't done consistently.
    
    Fix this by renaming the field to `flags` and adding an accessor.
    
    Fixes #24117.
    
    - - - - -
    
    
    5 changed files:
    
    - rts/Linker.c
    - rts/LinkerInternals.h
    - rts/linker/Elf.c
    - rts/linker/MachO.c
    - rts/linker/PEi386.c
    
    
    Changes:
    
    =====================================
    rts/Linker.c
    =====================================
    @@ -226,7 +226,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key,
     static const char *
     symbolTypeString (SymType type)
     {
    -    switch (type & ~SYM_TYPE_DUP_DISCARD) {
    +    switch (type) {
             case SYM_TYPE_CODE: return "code";
             case SYM_TYPE_DATA: return "data";
             case SYM_TYPE_INDIRECT_DATA: return "indirect-data";
    @@ -262,6 +262,7 @@ int ghciInsertSymbolTable(
        SymbolAddr* data,
        SymStrength strength,
        SymType type,
    +   uint16_t flags,
        ObjectCode *owner)
     {
        RtsSymbolInfo *pinfo = lookupStrHashTable(table, key);
    @@ -271,21 +272,21 @@ int ghciInsertSymbolTable(
           pinfo->value = data;
           pinfo->owner = owner;
           pinfo->strength = strength;
    -      pinfo->type = type;
    +      pinfo->flags = (uint16_t) type | flags;
           insertStrHashTable(table, key, pinfo);
           return 1;
        }
    -   else if (pinfo->type ^ type)
    +   else if (getRtsSymbolType(pinfo) != type)
        {
            /* We were asked to discard the symbol on duplicates, do so quietly.  */
    -       if (!(type & SYM_TYPE_DUP_DISCARD))
    +       if (!(flags & SYM_FLAG_DUP_DISCARD))
            {
              debugBelch("Symbol type mismatch.\n");
              debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n",
                         key, obj_name, symbolTypeString(type));
              debugBelch("      yet was defined by %" PATH_FMT " to be a %s symbol.\n",
                         pinfo->owner ? pinfo->owner->fileName : WSTR(""),
    -                    symbolTypeString(pinfo->type));
    +                    symbolTypeString(getRtsSymbolType(pinfo)));
            }
            return 1;
        }
    @@ -466,7 +467,7 @@ initLinker_ (int retain_cafs)
         for (const RtsSymbolVal *sym = rtsSyms; sym->lbl != NULL; sym++) {
             if (! ghciInsertSymbolTable(WSTR("(GHCi built-in symbols)"),
                                         symhash, sym->lbl, sym->addr,
    -                                    sym->strength, sym->type, NULL)) {
    +                                    sym->strength, sym->type, 0, NULL)) {
                 barf("ghciInsertSymbolTable failed");
             }
             IF_DEBUG(linker, debugBelch("initLinker: inserting rts symbol %s, %p\n", sym->lbl, sym->addr));
    @@ -476,7 +477,7 @@ initLinker_ (int retain_cafs)
         if (! ghciInsertSymbolTable(WSTR("(GHCi built-in symbols)"), symhash,
                                     MAYBE_LEADING_UNDERSCORE_STR("newCAF"),
                                     retain_cafs ? newRetainedCAF : newGCdCAF,
    -                                HS_BOOL_FALSE, SYM_TYPE_CODE, NULL)) {
    +                                HS_BOOL_FALSE, SYM_TYPE_CODE, 0, NULL)) {
             barf("ghciInsertSymbolTable failed");
         }
     
    @@ -864,7 +865,7 @@ HsBool removeLibrarySearchPath(HsPtr dll_path_index)
     HsInt insertSymbol(pathchar* obj_name, SymbolName* key, SymbolAddr* data)
     {
         return ghciInsertSymbolTable(obj_name, symhash, key, data, HS_BOOL_FALSE,
    -                                 SYM_TYPE_CODE, NULL);
    +                                 SYM_TYPE_CODE, 0, NULL);
     }
     
     /* -----------------------------------------------------------------------------
    @@ -961,7 +962,7 @@ SymbolAddr* lookupDependentSymbol (SymbolName* lbl, ObjectCode *dependent, SymTy
             if (strcmp(lbl, "__fini_array_start") == 0) { return (SymbolAddr *) &RTS_NO_FINI; }
             if (type) {
                 // This is an assumption
    -            *type = pinfo->type;
    +            *type = getRtsSymbolType(pinfo);
             }
     
             if (dependent) {
    @@ -1696,7 +1697,7 @@ int ocTryLoad (ObjectCode* oc) {
                 && !ghciInsertSymbolTable(oc->fileName, symhash, symbol.name,
                                           symbol.addr,
                                           isSymbolWeak(oc, symbol.name),
    -                                      symbol.type, oc)) {
    +                                      symbol.type, 0, oc)) {
                 return 0;
             }
         }
    
    
    =====================================
    rts/LinkerInternals.h
    =====================================
    @@ -55,17 +55,27 @@ typedef struct _Section    Section;
     
     /* What kind of thing a symbol identifies. We need to know this to determine how
      * to process overflowing relocations. See Note [Processing overflowed relocations].
    - * This is bitfield however only the option SYM_TYPE_DUP_DISCARD can be combined
    - * with the other values. */
    + */
     typedef enum _SymType {
         SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */
         SYM_TYPE_DATA = 1 << 1, /* the symbol is data */
         SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */
    -    SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library
    -                                      however if a duplicate is found with a mismatching
    -                                      SymType then discard this one.  */
     } SymType;
     
    +#define SYM_TYPE_MASK (SYM_TYPE_CODE | SYM_TYPE_DATA | SYM_TYPE_INDIRECT_DATA)
    +
    +INLINE_HEADER SymType symbolFlagsToSymbolType(uint16_t flags) {
    +    return (SymType) (flags & SYM_TYPE_MASK);
    +}
    +
    +/*
    + * The symbol is a symbol in a BFD import library
    + * however if a duplicate is found with a mismatching
    + * SymType then discard this one.
    + *
    + */
    +#define SYM_FLAG_DUP_DISCARD (1 << 3)
    +
     
     #if defined(OBJFORMAT_ELF)
     #  include "linker/ElfTypes.h"
    @@ -438,9 +448,14 @@ typedef struct _RtsSymbolInfo {
         SymbolAddr* value;
         ObjectCode *owner;
         SymStrength strength;
    -    SymType type;
    +    // This is a bitfield combining SymType with the SYM_FLAG_* flags.
    +    uint16_t flags;
     } RtsSymbolInfo;
     
    +INLINE_HEADER SymType getRtsSymbolType(RtsSymbolInfo *pinfo) {
    +    return symbolFlagsToSymbolType(pinfo->flags);
    +}
    +
     #include "BeginPrivate.h"
     
     void exitLinker( void );
    @@ -466,6 +481,8 @@ int ghciInsertSymbolTable(
         SymbolAddr* data,
         SymStrength weak,
         SymType type,
    +    // One of SYM_FLAG_*
    +    uint16_t flags,
         ObjectCode *owner);
     
     /* Lock-free version of lookupSymbol. When 'dependent' is not NULL, adds it as a
    
    
    =====================================
    rts/linker/Elf.c
    =====================================
    @@ -1083,7 +1083,7 @@ ocGetNames_ELF ( ObjectCode* oc )
                                setWeakSymbol(oc, nm);
                            }
                            if (!ghciInsertSymbolTable(oc->fileName, symhash,
    -                                                  nm, symbol->addr, isWeak, sym_type, oc)
    +                                                  nm, symbol->addr, isWeak, sym_type, 0, oc)
                                ) {
                                goto fail;
                            }
    
    
    =====================================
    rts/linker/MachO.c
    =====================================
    @@ -1390,14 +1390,15 @@ ocGetNames_MachO(ObjectCode* oc)
                         {
                                 IF_DEBUG(linker_verbose, debugBelch("ocGetNames_MachO: inserting %s\n", nm));
                                 SymbolAddr* addr = oc->info->macho_symbols[i].addr;
    -                            // TODO: Make figure out how to determine this from the object file
    -                            SymType sym_type = SYM_TYPE_CODE;
    +                            // TODO: Figure out how to determine this from the object file
    +                            const SymType sym_type = SYM_TYPE_CODE;
                                 ghciInsertSymbolTable( oc->fileName
                                                      , symhash
                                                      , nm
                                                      , addr
                                                      , HS_BOOL_FALSE
                                                      , sym_type
    +                                                 , 0
                                                      , oc);
     
                                 oc->symbols[curSymbol].name = nm;
    @@ -1440,7 +1441,7 @@ ocGetNames_MachO(ObjectCode* oc)
     
                     IF_DEBUG(linker_verbose, debugBelch("ocGetNames_MachO: inserting common symbol: %s\n", nm));
                     ghciInsertSymbolTable(oc->fileName, symhash, nm,
    -                                       (void*)commonCounter, HS_BOOL_FALSE, sym_type, oc);
    +                                       (void*)commonCounter, HS_BOOL_FALSE, sym_type, 0, oc);
                     oc->symbols[curSymbol].name = nm;
                     oc->symbols[curSymbol].addr = oc->info->macho_symbols[i].addr;
                     curSymbol++;
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -299,7 +299,7 @@
        These two issues mean that for GHC we need to take a different approach
        to handling import libraries.  For normal C libraries we have proper
        differentiation between CODE and DATA.   For GHC produced import libraries
    -   we do not.   As such the SYM_TYPE_DUP_DISCARD tells the linker that if a
    +   we do not.   As such the SYM_FLAG_DUP_DISCARD tells the linker that if a
        duplicate symbol is found, and we were going to discard it anyway, just do
        so quitely.  This works because the RTS symbols themselves are provided by
        the currently loaded RTS as built-in symbols.
    @@ -438,7 +438,7 @@ void initLinker_PEi386(void)
         if (!ghciInsertSymbolTable(WSTR("(GHCi/Ld special symbols)"),
                                    symhash, "__image_base__",
                                    GetModuleHandleW (NULL), HS_BOOL_TRUE,
    -                               SYM_TYPE_CODE, NULL)) {
    +                               SYM_TYPE_CODE, 0, NULL)) {
             barf("ghciInsertSymbolTable failed");
         }
     
    @@ -1814,9 +1814,8 @@ ocGetNames_PEi386 ( ObjectCode* oc )
               sname = strdup (sname);
               addr  = strdup (addr);
               type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA;
    -          type |= SYM_TYPE_DUP_DISCARD;
               if (!ghciInsertSymbolTable(oc->fileName, symhash, sname,
    -                                     addr, false, type, oc)) {
    +                                     addr, false, type, SYM_FLAG_DUP_DISCARD, oc)) {
                  releaseOcInfo (oc);
                  stgFree (oc->image);
                  oc->image = NULL;
    @@ -1895,7 +1894,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
               stgFree(tmp);
               sname = strdup (sname);
               if (!ghciInsertSymbolTable(oc->fileName, symhash, sname,
    -                                     addr, false, type, oc))
    +                                     addr, false, type, 0, oc))
                    return false;
     
               break;
    @@ -1918,7 +1917,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
              }
     
              if (! ghciInsertSymbolTable(oc->fileName, symhash, sname, addr,
    -                                     isWeak, type, oc))
    +                                     isWeak, type, 0, oc))
                  return false;
           } else {
               /* We're skipping the symbol, but if we ever load this
    @@ -2321,7 +2320,9 @@ SymbolAddr *lookupSymbol_PEi386(SymbolName *lbl, ObjectCode *dependent, SymType
             sym = lookupSymbolInDLLs(lbl, dependent);
             return sym; // might be NULL if not found
         } else {
    -        if (type) *type = pinfo->type;
    +        if (type) {
    +            *type = getRtsSymbolType(pinfo);
    +        }
     
             if (pinfo && pinfo->owner && isSymbolImport (pinfo->owner, lbl))
             {
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b13412720f73ba2838dfba8019aba5baa1b638d1
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b13412720f73ba2838dfba8019aba5baa1b638d1
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 23 23:35:12 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Mon, 23 Oct 2023 19:35:12 -0400
    Subject: [Git][ghc/ghc][wip/sym-type] rts/linker: Clearly define SymType
    Message-ID: <653703306b9a_1f7b0d32194f60276290@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/sym-type at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    b98afad4 by Ben Gamari at 2023-10-23T19:34:58-04:00
    rts/linker: Clearly define SymType
    
    Previously SymType was both an enumeration of three symbol types *and*
    an orthogonal flag (`DUP_DISCARD`, introduced in !9475). This was quite
    fragile as it meant that to extract the symbol type one had to careful
    mask out the flag. Naturally this wasn't done consistently.
    
    Fix this by renaming the field to `flags` and adding an accessor.
    
    Fixes #24117.
    
    - - - - -
    
    
    5 changed files:
    
    - rts/Linker.c
    - rts/LinkerInternals.h
    - rts/linker/Elf.c
    - rts/linker/MachO.c
    - rts/linker/PEi386.c
    
    
    Changes:
    
    =====================================
    rts/Linker.c
    =====================================
    @@ -226,7 +226,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key,
     static const char *
     symbolTypeString (SymType type)
     {
    -    switch (type & ~SYM_TYPE_DUP_DISCARD) {
    +    switch (type) {
             case SYM_TYPE_CODE: return "code";
             case SYM_TYPE_DATA: return "data";
             case SYM_TYPE_INDIRECT_DATA: return "indirect-data";
    @@ -262,6 +262,7 @@ int ghciInsertSymbolTable(
        SymbolAddr* data,
        SymStrength strength,
        SymType type,
    +   uint16_t flags,
        ObjectCode *owner)
     {
        RtsSymbolInfo *pinfo = lookupStrHashTable(table, key);
    @@ -271,21 +272,21 @@ int ghciInsertSymbolTable(
           pinfo->value = data;
           pinfo->owner = owner;
           pinfo->strength = strength;
    -      pinfo->type = type;
    +      pinfo->flags = (uint16_t) type | flags;
           insertStrHashTable(table, key, pinfo);
           return 1;
        }
    -   else if (pinfo->type ^ type)
    +   else if (getRtsSymbolType(pinfo) != type)
        {
            /* We were asked to discard the symbol on duplicates, do so quietly.  */
    -       if (!(type & SYM_TYPE_DUP_DISCARD))
    +       if (!(flags & SYM_FLAG_DUP_DISCARD))
            {
              debugBelch("Symbol type mismatch.\n");
              debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n",
                         key, obj_name, symbolTypeString(type));
              debugBelch("      yet was defined by %" PATH_FMT " to be a %s symbol.\n",
                         pinfo->owner ? pinfo->owner->fileName : WSTR(""),
    -                    symbolTypeString(pinfo->type));
    +                    symbolTypeString(getRtsSymbolType(pinfo)));
            }
            return 1;
        }
    @@ -466,7 +467,7 @@ initLinker_ (int retain_cafs)
         for (const RtsSymbolVal *sym = rtsSyms; sym->lbl != NULL; sym++) {
             if (! ghciInsertSymbolTable(WSTR("(GHCi built-in symbols)"),
                                         symhash, sym->lbl, sym->addr,
    -                                    sym->strength, sym->type, NULL)) {
    +                                    sym->strength, sym->type, 0, NULL)) {
                 barf("ghciInsertSymbolTable failed");
             }
             IF_DEBUG(linker, debugBelch("initLinker: inserting rts symbol %s, %p\n", sym->lbl, sym->addr));
    @@ -476,7 +477,7 @@ initLinker_ (int retain_cafs)
         if (! ghciInsertSymbolTable(WSTR("(GHCi built-in symbols)"), symhash,
                                     MAYBE_LEADING_UNDERSCORE_STR("newCAF"),
                                     retain_cafs ? newRetainedCAF : newGCdCAF,
    -                                HS_BOOL_FALSE, SYM_TYPE_CODE, NULL)) {
    +                                HS_BOOL_FALSE, SYM_TYPE_CODE, 0, NULL)) {
             barf("ghciInsertSymbolTable failed");
         }
     
    @@ -864,7 +865,7 @@ HsBool removeLibrarySearchPath(HsPtr dll_path_index)
     HsInt insertSymbol(pathchar* obj_name, SymbolName* key, SymbolAddr* data)
     {
         return ghciInsertSymbolTable(obj_name, symhash, key, data, HS_BOOL_FALSE,
    -                                 SYM_TYPE_CODE, NULL);
    +                                 SYM_TYPE_CODE, 0, NULL);
     }
     
     /* -----------------------------------------------------------------------------
    @@ -961,7 +962,7 @@ SymbolAddr* lookupDependentSymbol (SymbolName* lbl, ObjectCode *dependent, SymTy
             if (strcmp(lbl, "__fini_array_start") == 0) { return (SymbolAddr *) &RTS_NO_FINI; }
             if (type) {
                 // This is an assumption
    -            *type = pinfo->type;
    +            *type = getRtsSymbolType(pinfo);
             }
     
             if (dependent) {
    @@ -1696,7 +1697,7 @@ int ocTryLoad (ObjectCode* oc) {
                 && !ghciInsertSymbolTable(oc->fileName, symhash, symbol.name,
                                           symbol.addr,
                                           isSymbolWeak(oc, symbol.name),
    -                                      symbol.type, oc)) {
    +                                      symbol.type, 0, oc)) {
                 return 0;
             }
         }
    
    
    =====================================
    rts/LinkerInternals.h
    =====================================
    @@ -55,17 +55,26 @@ typedef struct _Section    Section;
     
     /* What kind of thing a symbol identifies. We need to know this to determine how
      * to process overflowing relocations. See Note [Processing overflowed relocations].
    - * This is bitfield however only the option SYM_TYPE_DUP_DISCARD can be combined
    - * with the other values. */
    + */
     typedef enum _SymType {
         SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */
         SYM_TYPE_DATA = 1 << 1, /* the symbol is data */
         SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */
    -    SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library
    -                                      however if a duplicate is found with a mismatching
    -                                      SymType then discard this one.  */
     } SymType;
     
    +#define SYM_TYPE_MASK (SYM_TYPE_CODE | SYM_TYPE_DATA | SYM_TYPE_INDIRECT_DATA)
    +
    +INLINE_HEADER SymType symbolFlagsToSymbolType(uint16_t flags) {
    +    return (SymType) (flags & SYM_TYPE_MASK);
    +}
    +
    +/*
    + * The symbol is a symbol in a BFD import library
    + * however if a duplicate is found with a mismatching
    + * SymType then discard this one.
    + */
    +#define SYM_FLAG_DUP_DISCARD (1 << 3)
    +
     
     #if defined(OBJFORMAT_ELF)
     #  include "linker/ElfTypes.h"
    @@ -438,9 +447,14 @@ typedef struct _RtsSymbolInfo {
         SymbolAddr* value;
         ObjectCode *owner;
         SymStrength strength;
    -    SymType type;
    +    // This is a bitfield combining SymType with the SYM_FLAG_* flags.
    +    uint16_t flags;
     } RtsSymbolInfo;
     
    +INLINE_HEADER SymType getRtsSymbolType(RtsSymbolInfo *pinfo) {
    +    return symbolFlagsToSymbolType(pinfo->flags);
    +}
    +
     #include "BeginPrivate.h"
     
     void exitLinker( void );
    @@ -466,6 +480,8 @@ int ghciInsertSymbolTable(
         SymbolAddr* data,
         SymStrength weak,
         SymType type,
    +    // One of SYM_FLAG_*
    +    uint16_t flags,
         ObjectCode *owner);
     
     /* Lock-free version of lookupSymbol. When 'dependent' is not NULL, adds it as a
    
    
    =====================================
    rts/linker/Elf.c
    =====================================
    @@ -1083,7 +1083,7 @@ ocGetNames_ELF ( ObjectCode* oc )
                                setWeakSymbol(oc, nm);
                            }
                            if (!ghciInsertSymbolTable(oc->fileName, symhash,
    -                                                  nm, symbol->addr, isWeak, sym_type, oc)
    +                                                  nm, symbol->addr, isWeak, sym_type, 0, oc)
                                ) {
                                goto fail;
                            }
    
    
    =====================================
    rts/linker/MachO.c
    =====================================
    @@ -1390,14 +1390,15 @@ ocGetNames_MachO(ObjectCode* oc)
                         {
                                 IF_DEBUG(linker_verbose, debugBelch("ocGetNames_MachO: inserting %s\n", nm));
                                 SymbolAddr* addr = oc->info->macho_symbols[i].addr;
    -                            // TODO: Make figure out how to determine this from the object file
    -                            SymType sym_type = SYM_TYPE_CODE;
    +                            // TODO: Figure out how to determine this from the object file
    +                            const SymType sym_type = SYM_TYPE_CODE;
                                 ghciInsertSymbolTable( oc->fileName
                                                      , symhash
                                                      , nm
                                                      , addr
                                                      , HS_BOOL_FALSE
                                                      , sym_type
    +                                                 , 0
                                                      , oc);
     
                                 oc->symbols[curSymbol].name = nm;
    @@ -1440,7 +1441,7 @@ ocGetNames_MachO(ObjectCode* oc)
     
                     IF_DEBUG(linker_verbose, debugBelch("ocGetNames_MachO: inserting common symbol: %s\n", nm));
                     ghciInsertSymbolTable(oc->fileName, symhash, nm,
    -                                       (void*)commonCounter, HS_BOOL_FALSE, sym_type, oc);
    +                                       (void*)commonCounter, HS_BOOL_FALSE, sym_type, 0, oc);
                     oc->symbols[curSymbol].name = nm;
                     oc->symbols[curSymbol].addr = oc->info->macho_symbols[i].addr;
                     curSymbol++;
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -299,7 +299,7 @@
        These two issues mean that for GHC we need to take a different approach
        to handling import libraries.  For normal C libraries we have proper
        differentiation between CODE and DATA.   For GHC produced import libraries
    -   we do not.   As such the SYM_TYPE_DUP_DISCARD tells the linker that if a
    +   we do not.   As such the SYM_FLAG_DUP_DISCARD tells the linker that if a
        duplicate symbol is found, and we were going to discard it anyway, just do
        so quitely.  This works because the RTS symbols themselves are provided by
        the currently loaded RTS as built-in symbols.
    @@ -438,7 +438,7 @@ void initLinker_PEi386(void)
         if (!ghciInsertSymbolTable(WSTR("(GHCi/Ld special symbols)"),
                                    symhash, "__image_base__",
                                    GetModuleHandleW (NULL), HS_BOOL_TRUE,
    -                               SYM_TYPE_CODE, NULL)) {
    +                               SYM_TYPE_CODE, 0, NULL)) {
             barf("ghciInsertSymbolTable failed");
         }
     
    @@ -1814,9 +1814,8 @@ ocGetNames_PEi386 ( ObjectCode* oc )
               sname = strdup (sname);
               addr  = strdup (addr);
               type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA;
    -          type |= SYM_TYPE_DUP_DISCARD;
               if (!ghciInsertSymbolTable(oc->fileName, symhash, sname,
    -                                     addr, false, type, oc)) {
    +                                     addr, false, type, SYM_FLAG_DUP_DISCARD, oc)) {
                  releaseOcInfo (oc);
                  stgFree (oc->image);
                  oc->image = NULL;
    @@ -1895,7 +1894,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
               stgFree(tmp);
               sname = strdup (sname);
               if (!ghciInsertSymbolTable(oc->fileName, symhash, sname,
    -                                     addr, false, type, oc))
    +                                     addr, false, type, 0, oc))
                    return false;
     
               break;
    @@ -1918,7 +1917,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
              }
     
              if (! ghciInsertSymbolTable(oc->fileName, symhash, sname, addr,
    -                                     isWeak, type, oc))
    +                                     isWeak, type, 0, oc))
                  return false;
           } else {
               /* We're skipping the symbol, but if we ever load this
    @@ -2321,7 +2320,9 @@ SymbolAddr *lookupSymbol_PEi386(SymbolName *lbl, ObjectCode *dependent, SymType
             sym = lookupSymbolInDLLs(lbl, dependent);
             return sym; // might be NULL if not found
         } else {
    -        if (type) *type = pinfo->type;
    +        if (type) {
    +            *type = getRtsSymbolType(pinfo);
    +        }
     
             if (pinfo && pinfo->owner && isSymbolImport (pinfo->owner, lbl))
             {
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b98afad479dd6064bec3bb6a269221a95851004e
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b98afad479dd6064bec3bb6a269221a95851004e
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 06:39:08 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Tue, 24 Oct 2023 02:39:08 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/unique-increment
    Message-ID: <6537668cc8b82_1f7b0d3c0c5710289387@gitlab.mail>
    
    
    
    Sebastian Graf pushed new branch wip/unique-increment at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/unique-increment
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 09:32:43 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Tue, 24 Oct 2023 05:32:43 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Take care with void args
    Message-ID: <65378f3b2e68_1f7b0d3ffdd8943054da@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    abf63bf8 by Simon Peyton Jones at 2023-10-24T10:32:26+01:00
    Take care with void args
    
    - - - - -
    
    
    2 changed files:
    
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -31,7 +31,6 @@ import GHC.Types.Name
     import GHC.Types.Var.Env
     
     import GHC.Utils.Logger
    -import GHC.Utils.Misc
     import GHC.Utils.Outputable
     import GHC.Utils.Panic
     
    @@ -221,14 +220,18 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
             | otherwise
             -> traceInline logger env fn str (mk_doc some_benefit extra_doc False) Nothing
             where
    -          some_benefit = calc_some_benefit (length arg_bndrs)
    +          n_bndrs = length arg_bndrs
    +          some_benefit  = calc_some_benefit n_bndrs
    +          small_enough  = adjusted_size `leqSize` unfoldingUseThreshold opts
    +          adjusted_size = adjustSize adjust_size rhs_size
     
    +          --------  Compute the size of the ExprTree in this context -----------
    +          rhs_size = exprTreeSize context expr_tree
               want_result
    -             | LT <- arg_bndrs `compareLength` arg_infos
    -                         = True  -- Over-saturated
    -             | otherwise = case cont_info of
    -                              BoringCtxt -> False
    -                              _          -> True
    +             | n_bndrs < n_val_args = True  -- Over-saturated
    +             | otherwise            = case cont_info of
    +                                        BoringCtxt -> False
    +                                        _          -> True
     
               bound_env = mkVarEnv (arg_bndrs `zip` (arg_infos ++ repeat ArgNoInfo))
                           -- Crucial to include /all/ arg_bndrs, lest we treat
    @@ -236,11 +239,8 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
               context = IC { ic_bound    = bound_env
                            , ic_free     = getFreeSummary
                            , ic_want_res = want_result }
    -          size :: Size
    -          size = exprTreeSize context expr_tree
     
               in_scope = seInScope env
    -
               getFreeSummary :: Id -> ArgSummary
               -- Get the ArgSummary of a free variable
               getFreeSummary x
    @@ -254,28 +254,37 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
                             -> exprSummary env expr
                     _ -> ArgNoInfo
     
    +          -------- adjust_size ----------------
    +          adjust_size size = size - call_size + depth_penalty size
    +
    +          -- Subtract size of the call, because the result replaces the call
    +          -- We count 10 for the function itself, 10 for each arg supplied,
    +          call_size = 10 + 10*n_val_args
     
               -- Adjust by the depth scaling
               -- See Note [Avoid inlining into deeply nested cases]
               depth_threshold = unfoldingCaseThreshold opts
               depth_scaling   = unfoldingCaseScaling opts
     
    -          add_depth_penalty size = size + (size * (case_depth - depth_threshold))
    -                                                  `div` depth_scaling
    -          final_size | case_depth <= depth_threshold = size
    -                     | otherwise = adjustSize add_depth_penalty size
    -
    -          small_enough = final_size `leqSize` unfoldingUseThreshold opts
    +          depth_penalty size
    +            | case_depth <= depth_threshold = 0
    +            | otherwise = (size * (case_depth - depth_threshold)) `div` depth_scaling
     
    -          extra_doc = vcat [ text "size =" <+> ppr size
    +          extra_doc = vcat [ text "size =" <+> ppr rhs_size
                                , text "case depth =" <+> int case_depth
    -                           , text "final_size =" <+> ppr final_size ]
    +                           , text "adjusted_size =" <+> ppr adjusted_size ]
    +
       where
         (arg_infos, call_cont) = contArgs cont
    -    lone_variable = loneVariable cont
    -    cont_info     = interestingCallContext env call_cont
    -    case_depth    = seCaseDepth env
    -    opts          = seUnfoldingOpts env
    +    n_val_args       = length arg_infos
    +    lone_variable    = loneVariable cont
    +    cont_info        = interestingCallContext env call_cont
    +    case_depth       = seCaseDepth env
    +    opts             = seUnfoldingOpts env
    +    interesting_args = any hasArgInfo arg_infos
    +                -- NB: (any hasArgInfo arg_infos) looks at the
    +                -- over-saturated args too which is "wrong";
    +                -- but if over-saturated we inline anyway.
     
         -- Unpack the UnfoldingCache lazily because it may not be needed, and all
         -- its fields are strict; so evaluating unf_cache at all forces all the
    @@ -284,20 +293,6 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
         -- See Note [UnfoldingCache] in GHC.Core
         UnfoldingCache{ uf_is_work_free = is_wf, uf_expandable = is_exp } = unf_cache
     
    -    mk_doc some_benefit extra_doc yes_or_no
    -      = vcat [ text "arg infos" <+> ppr arg_infos
    -             , text "interesting continuation" <+> ppr cont_info
    -             , text "some_benefit" <+> ppr some_benefit
    -             , text "is exp:" <+> ppr is_exp
    -             , text "is work-free:" <+> ppr is_wf
    -             , text "guidance" <+> ppr guidance
    -             , extra_doc
    -             , text "ANSWER =" <+> if yes_or_no then text "YES" else text "NO"]
    -
    -    ctx = log_default_dump_context (logFlags logger)
    -    str = "Considering inlining: " ++ showSDocOneLine ctx (ppr fn)
    -    n_val_args = length arg_infos
    -
                -- some_benefit is used when the RHS is small enough
                -- and the call has enough (or too many) value
                -- arguments (ie n_val_args >= arity). But there must
    @@ -313,10 +308,6 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
           where
             saturated      = n_val_args >= uf_arity
             over_saturated = n_val_args > uf_arity
    -        interesting_args = any hasArgInfo arg_infos
    -                -- NB: (any nonTriv arg_infos) looks at the
    -                -- over-saturated args too which is "wrong";
    -                -- but if over-saturated we inline anyway.
     
             interesting_call
               | over_saturated
    @@ -331,6 +322,19 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
                               -> uf_arity > 0  -- See Note [RHS of lets]
                   _other      -> False         -- See Note [Nested functions]
     
    +    mk_doc some_benefit extra_doc yes_or_no
    +      = vcat [ text "arg infos" <+> ppr arg_infos
    +             , text "interesting continuation" <+> ppr cont_info
    +             , text "some_benefit" <+> ppr some_benefit
    +             , text "is exp:" <+> ppr is_exp
    +             , text "is work-free:" <+> ppr is_wf
    +             , text "guidance" <+> ppr guidance
    +             , extra_doc
    +             , text "ANSWER =" <+> if yes_or_no then text "YES" else text "NO"]
    +
    +    ctx = log_default_dump_context (logFlags logger)
    +    str = "Considering inlining: " ++ showSDocOneLine ctx (ppr fn)
    +
     {- Note [RHS of lets]
     ~~~~~~~~~~~~~~~~~~~~~
     When the call is the argument of a function with a RULE, or the RHS of a let,
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -518,8 +518,8 @@ exprTree opts args expr
         go _  (Lit lit)    = exprTreeN (litSize lit)
     
         go vs (Lam b e)
    -      | isId b, not (id_is_free b) = go vs' e `et_add` lamSize opts
    -      | otherwise                  = go vs' e
    +      | isId b, not (isZeroBitId b) = go vs' e `et_add` lamSize opts
    +      | otherwise                   = go vs' e
           where
             vs' = vs `add_lv` b
     
    @@ -532,12 +532,10 @@ exprTree opts args expr
           where
             vs' = vs `add_lvs` map fst pairs
     
    -    go vs e@(App {}) = go_app vs e []
    -
    -    go vs (Var f) | id_is_free f = exprTreeN 0
    -                    -- Use calLSize to ensure we get constructor
    +    go vs e@(App {}) = go_app vs e [] 0
    +    go vs (Var f)    = callTree opts vs f [] 0
    +                    -- Use callTree to ensure we get constructor
                         -- discounts even on nullary constructors
    -                    | otherwise  = callTree opts vs f []
     
         go vs (Case e b _ alts) = go_case vs e b alts
     
    @@ -561,17 +559,18 @@ exprTree opts args expr
     
         -----------------------------
         -- size_up_app is used when there's ONE OR MORE value args
    -    go_app :: ETVars -> CoreExpr -> [CoreExpr] -> ExprTree
    +    go_app :: ETVars -> CoreExpr -> [CoreExpr] -> Int -> ExprTree
                        -- args are the value args
    -    go_app vs (App fun arg) args
    -               | isTypeArg arg   = go_app vs fun args
    -               | otherwise       = go vs arg `et_add`
    -                                   go_app vs fun (arg:args)
    -    go_app vs (Var fun)     args = callTree opts vs fun args
    -    go_app vs (Tick _ expr) args = go_app vs expr args
    -    go_app vs (Cast expr _) args = go_app vs expr args
    -    go_app vs other         args = vanillaCallSize (length args) `etAddN`
    -                                   go vs other
    +    go_app vs (App fun arg) args voids
    +                  | isTypeArg arg      = go_app vs fun args voids
    +                  | isZeroBitArg arg   = go_app vs fun (arg:args) (voids+1)
    +                  | otherwise          = go vs arg `et_add`
    +                                         go_app vs fun (arg:args) voids
    +    go_app vs (Var fun)     args voids = callTree opts vs fun args voids
    +    go_app vs (Tick _ expr) args voids = go_app vs expr args voids
    +    go_app vs (Cast expr _) args voids = go_app vs expr args voids
    +    go_app vs other         args voids = vanillaCallSize (length args) voids `etAddN`
    +                                         go vs other
            -- if the lhs is not an App or a Var, or an invisible thing like a
            -- Tick or Cast, then we should charge for a complete call plus the
            -- size of the lhs itself.
    @@ -667,23 +666,18 @@ recordCaseOf vs (Tick _ e) = recordCaseOf vs e
     recordCaseOf vs (Cast e _) = recordCaseOf vs e
     recordCaseOf _     _       = Nothing
     
    -{-
    -arg_is_free :: CoreExpr -> Bool
    --- "free" means we don't charge for this
    --- occurrence in a function application
    -arg_is_free (Var id)      = id_is_free id
    -arg_is_free (Tick _ e)    = arg_is_free e
    -arg_is_free (Cast e _)    = arg_is_free e
    -arg_is_free (Type {})     = True
    -arg_is_free (Coercion {}) = True
    -arg_is_free _             = False
    --}
    +isZeroBitArg :: CoreExpr -> Bool
    +-- We could take ticks and casts into account, but it makes little
    +-- difference, and avoiding a recursive function here is good.
    +isZeroBitArg (Var id) = isZeroBitId id
    +isZeroBitArg _        = False
     
    -id_is_free :: Id -> Bool
    -id_is_free id = not (isJoinId id) && isZeroBitTy (idType id)
    -   -- Don't count expressions such as State# RealWorld
    -   -- exclude join points, because they can be rep-polymorphic
    -   -- and typePrimRep will crash
    +isZeroBitId :: Id -> Bool
    +-- Don't count expressions such as State# RealWorld
    +isZeroBitId id = assertPpr (not (isJoinId id)) (ppr id) $
    +                   -- Exclude join points, because they can be rep-polymorphic
    +                   -- and typePrimRep will crash
    +                 isZeroBitTy (idType id)
     
     
     -- | Finds a nominal size of a string literal.
    @@ -699,52 +693,52 @@ litSize _other = 0    -- Must match size of nullary constructors
                           --            (eg via case binding)
     
     ----------------------------
    -callTree :: UnfoldingOpts -> ETVars -> Id -> [CoreExpr] -> ExprTree
    -callTree opts vs fun val_args
    +callTree :: UnfoldingOpts -> ETVars -> Id -> [CoreExpr] -> Int -> ExprTree
    +callTree opts vs fun val_args voids
       = case idDetails fun of
    -      FCallId _        -> exprTreeN (vanillaCallSize n_val_args)
    -      JoinId {}        -> exprTreeN (jumpSize        n_val_args)
    +      FCallId _        -> exprTreeN (vanillaCallSize n_val_args voids)
    +      JoinId {}        -> exprTreeN (jumpSize        n_val_args voids)
           PrimOpId op _    -> exprTreeN (primOpSize op   n_val_args)
           DataConWorkId dc -> conSize dc n_val_args
    -      ClassOpId {}     -> classOpSize opts vs fun val_args
    -      _                -> funSize opts vs fun n_val_args
    +      ClassOpId {}     -> classOpSize opts vs fun val_args voids
    +      _                -> funSize opts vs fun n_val_args voids
       where
         n_val_args = length val_args
     
     -- | The size of a function call
    -vanillaCallSize :: Int -> Int
    -vanillaCallSize n_val_args = 10 * (1 + n_val_args)
    +vanillaCallSize :: Int -> Int -> Int
    +vanillaCallSize n_val_args voids = 10 * (1 + n_val_args - voids)
             -- The 1+ is for the function itself
             -- Add 1 for each non-trivial value arg
     
     -- | The size of a jump to a join point
    -jumpSize :: Int -> Int
    -jumpSize n_val_args = 2 * (1 + n_val_args)
    +jumpSize :: Int -> Int -> Int
    +jumpSize n_val_args voids = 2 * (1 + n_val_args - voids)
       -- A jump is 20% the size of a function call. Making jumps free reopens
       -- bug #6048, but making them any more expensive loses a 21% improvement in
       -- spectral/puzzle. TODO Perhaps adjusting the default threshold would be a
       -- better solution?
     
    -classOpSize :: UnfoldingOpts -> ETVars -> Id -> [CoreExpr] -> ExprTree
    +classOpSize :: UnfoldingOpts -> ETVars -> Id -> [CoreExpr] -> Int -> ExprTree
     -- See Note [Conlike is interesting]
    -classOpSize _ _ _ []
    +classOpSize _ _ _ [] _
       = etZero
    -classOpSize opts vs fn val_args
    +classOpSize opts vs fn val_args voids
       | arg1 : _ <- val_args
       , Just dict <- recordCaseOf vs arg1
       = warnPprTrace (not (isId dict)) "classOpSize" (ppr fn <+> ppr val_args) $
    -    vanillaCallSize (length val_args) `etAddN`
    +    vanillaCallSize (length val_args) voids `etAddN`
         etOneCase (ScrutOf dict (unfoldingDictDiscount opts))
                -- If the class op is scrutinising a lambda bound dictionary then
                -- give it a discount, to encourage the inlining of this function
                -- The actual discount is rather arbitrarily chosen
       | otherwise
    -  = exprTreeN (vanillaCallSize (length val_args))
    +  = exprTreeN (vanillaCallSize (length val_args) voids)
     
    -funSize :: UnfoldingOpts -> ETVars -> Id -> Int -> ExprTree
    +funSize :: UnfoldingOpts -> ETVars -> Id -> Int -> Int -> ExprTree
     -- Size for function calls that are not constructors or primops
     -- Note [Function applications]
    -funSize opts (avs,_) fun n_val_args
    +funSize opts (avs,_) fun n_val_args voids
       | fun `hasKey` buildIdKey   = etZero  -- Wwant to inline applications of build/augment
       | fun `hasKey` augmentIdKey = etZero  -- so we give size zero to the whole call
       | otherwise = SizeIs { et_size  = size
    @@ -752,13 +746,14 @@ funSize opts (avs,_) fun n_val_args
                            , et_ret   = res_discount }
       where
         size | n_val_args == 0 = 0
    -         | otherwise       = vanillaCallSize n_val_args
    +         | otherwise       = vanillaCallSize n_val_args voids
     
         -- Discount if this is an interesting variable, and is applied
    -    -- Discount is enough to make the application free (but not negative!)
    +    -- If the function is an argument and is applied to some values,
    +    -- give it a discount -- maybe we can apply that lambda.
         --  See Note [Function and non-function discounts]
         cases | n_val_args > 0, fun `elemVarSet` avs
    -          = unitBag (ScrutOf fun size)
    +          = unitBag (ScrutOf fun (unfoldingFunAppDiscount opts))
               | otherwise
               = emptyBag
     
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abf63bf8b0934dd400e8c9e202e877b956807dc6
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abf63bf8b0934dd400e8c9e202e877b956807dc6
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 12:01:38 2023
    From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith))
    Date: Tue, 24 Oct 2023 08:01:38 -0400
    Subject: [Git][ghc/ghc][wip/jsbits-userguide] Fix typos
    Message-ID: <6537b2222a25_1f7b0d438ae664317431@gitlab.mail>
    
    
    
    Josh Meredith pushed to branch wip/jsbits-userguide at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    722987bc by Sylvain Henry at 2023-10-24T12:01:34+00:00
    Fix typos
    - - - - -
    
    
    1 changed file:
    
    - docs/users_guide/javascript.rst
    
    
    Changes:
    
    =====================================
    docs/users_guide/javascript.rst
    =====================================
    @@ -295,7 +295,7 @@ expects a ``CString`` (passed as the equivalent ``Ptr CChar``) and a
     for the string's pointer and offset, and one for the size, which will be passed as a
     JavaScript number.
     
    -Next, the JavaScript ``h$getcwd`` function demonstrates a several details:
    +Next, the JavaScript ``h$getcwd`` function demonstrates several details:
     
     * In the try clause, the ``cwd`` value is first accessed using a NodeJS-provided method.
       This value is immediately encoded using ``h$encodeUtf8``, which is provided by the
    @@ -413,7 +413,7 @@ use Haskell wrapper functions to convert the imported functions to the appropria
     format.
     
     In other cases, C functions are used for performance. For these cases, pure-Haskell
    -implementations are the preferred first step for compatability with the JavaScript
    +implementations are the preferred first step for compatibility with the JavaScript
     backend since it would be more future-proof against changes to the RTS data format.
     Depending on the use case, compiler-optimised JS code might be hard to complete with
     using hand-written JavaScript. Generally, the most likely performance gains from
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/722987bc93bd19c5dd0ae3d7f06b1449b3fe09a7
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/722987bc93bd19c5dd0ae3d7f06b1449b3fe09a7
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 12:04:26 2023
    From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith))
    Date: Tue, 24 Oct 2023 08:04:26 -0400
    Subject: [Git][ghc/ghc][wip/jsbits-userguide] 90 commits: Ensure unconstrained
     instance dictionaries get IPE info
    Message-ID: <6537b2ca743bb_1f7b0d4353c800322844@gitlab.mail>
    
    
    
    Josh Meredith pushed to branch wip/jsbits-userguide at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00
    Ensure unconstrained instance dictionaries get IPE info
    
    In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up
    with an initial source span based on the span of the binder, which was causing
    instance dictionaries without dynamic superclass constraints to not have source
    locations in their IPE info. Now they do.
    
    Resolves #24005
    
    - - - - -
    390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00
    rts: Split up rts/include/stg/MachRegs.h by arch
    
    - - - - -
    3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00
    Actually set hackage index state
    
    Or at least, use a version of the cabal command that *claims* to set the
    index state.
    
    Time will tell.
    
    - - - - -
    46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00
    Update hackage index state
    
    - - - - -
    d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00
    Ensure hadrian uses CI's hackage index state
    
    - - - - -
    e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00
    Do not use O_NONBLOCK on regular files or block devices
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/166
    
    - - - - -
    a06197c4 by David Binder at 2023-10-08T15:06:55-04:00
    Update hpc-bin submodule to 0.69
    
    - - - - -
    ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00
    Update Hadrian with correct path to happy file for hpc-bin
    
    - - - - -
    94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00
    EPA: Introduce HasAnnotation class
    
    The class is defined as
    
        class HasAnnotation e where
          noAnnSrcSpan :: SrcSpan -> e
    
    This generalises noAnnSrcSpan, and allows
    
        noLocA :: (HasAnnotation e) => a -> GenLocated e a
        noLocA = L (noAnnSrcSpan noSrcSpan)
    
    - - - - -
    8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00
    Bump unix submodule to v2.8.3.0
    
    - - - - -
    e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00
    Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.
    
    The motivation for the flag is given in #21917.
    
    - - - - -
    3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Add ghcToolchain to tool args list
    
    This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.
    
    - - - - -
    476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Normalise triple via config.sub
    
    We were not normalising the target triple anymore like we did with the
    old make build system.
    
    Fixes #23856
    
    - - - - -
    303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add missing vendor normalisation
    
    This is copied from m4/ghc_convert_vendor.m4
    
    Towards #23868
    
    - - - - -
    838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add loongarch64 to parseArch
    
    Towards #23868
    
    - - - - -
    1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Add same LD hack to ghc-toolchain
    
    In the ./configure script, if you pass the `LD` variable then this has
    the effect of stopping use searching for a linker and hence passing
    `-fuse-ld=...`.
    
    We want to emulate this logic in ghc-toolchain, if a use explicilty
    specifies `LD` variable then don't add `-fuse-ld=..` with the goal of
    making ./configure and ghc-toolchain agree on which flags to use when
    using the C compiler as a linker.
    
    This is quite unsavoury as we don't bake the choice of LD into the
    configuration anywhere but what's important for now is making
    ghc-toolchain and ./configure agree as much as possible.
    
    See #23857 for more discussion
    
    - - - - -
    42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check for C99 support with -std=c99
    
    Previously we failed to try enabling C99 support with `-std=c99`, as
    `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which
    don't enable C99 by default.
    
    Fixes #23879.
    
    - - - - -
    da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro
    
    In very old toolchains the BYTE_ORDER macro is not set but thankfully
    the __BYTE_ORDER__ macro can be used instead.
    
    - - - - -
    d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: AC_PATH_TARGET_TOOL for LD
    
    We want to make sure that LD is set to an absolute path in order to be
    consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL
    macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which
    might use a relative path.
    
    - - - - -
    171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check whether we need -std=gnu99 for CPP as well
    
    In ./configure the C99 flag is passed to the C compiler when used as a C
    preprocessor. So we also check the same thing in ghc-toolchain.
    
    - - - - -
    89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Check for --target linker flag separately to C compiler
    
    There are situations where the C compiler doesn't accept `--target` but
    when used as a linker it does (but doesn't do anything most likely)
    
    In particular with old gcc toolchains, the C compiler doesn't support
    --target but when used as a linker it does.
    
    - - - - -
    37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Use Cc to compile test file in nopie check
    
    We were attempting to use the C compiler, as a linker, to compile a file
    in the nopie check, but that won't work in general as the flags we pass
    to the linker might not be compatible with the ones we pass when using
    the C compiler.
    
    - - - - -
    9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Error when ghc-toolchain fails to compile
    
    This is a small QOL change as if you are working on ghc-toolchain and it
    fails to compile then configure will continue and can give you outdated
    results.
    
    - - - - -
    1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Check whether -no-pie works when the C compiler is used as a linker
    
    `-no-pie` is a flag we pass when using the C compiler as a linker (see
    pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
    compiler used as a linker supports the flag, rather than just the C
    compiler.
    
    - - - - -
    62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Remove javascript special case for --target detection
    
    emcc when used as a linker seems to ignore the --target flag, and for
    consistency with configure which now tests for --target, we remove this
    special case.
    
    - - - - -
    0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00
    toolchain: Don't pass --target to emscripten toolchain
    
    As noted in `Note [Don't pass --target to emscripten toolchain]`,
    emscripten's `emcc` is rather inconsistent with respect to its treatment
    of the `--target` flag. Avoid this by special-casing this toolchain
    in the `configure` script and `ghc-toolchain`.
    
    Fixes on aspect of #23744.
    
    - - - - -
    6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure
    
    Stop passing -gcc-options which mixed together linker flags and
    non-linker flags. There's no guarantee the C compiler will accept both
    of these in each mode.
    
    - - - - -
    c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00
    configure: Probe stage0 link flags
    
    For consistency with later stages and CC.
    
    - - - - -
    1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00
    Stricter Binary.get in GHC.Types.Unit (#23964)
    
    I noticed some thunking while looking at Core.
    This change has very modest, but throughout positive ghc/alloc effect:
    
    ```
     hard_hole_fits(normal) ghc/alloc    283,057,664    281,620,872  -0.5%
    
                  geo. mean                                          -0.1%
                  minimum                                            -0.5%
                  maximum                                            +0.0%
    ```
    
    Fixes #23964.
    
    - - - - -
    a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00
    rel_eng/upload.sh cleanups
    
    - - - - -
    80705335 by doyougnu at 2023-10-10T19:03:18-04:00
    ci: add javascript label rule
    
    This adds a rule which triggers the javascript job when the "javascript"
    label is assigned to an MR.
    
    - - - - -
    a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00
    Make 'wWarningFlagsDeps' include every WarningFlag
    
    Fixes #24071.
    
    - - - - -
    d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00
    Fix pretty printing of overlap pragmas in TH splices (fixes #24074)
    
    - - - - -
    0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    AArch NCG: Refactor getRegister'
    
    Remove some special cases which can be handled just as well by the
    generic case.
    
    This increases code re-use while also fixing #23749. Since some of the
    special case wasn't upholding Note [Signed arithmetic on AArch64].
    
    - - - - -
    1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over mem management checks
    
    These are for heap allocation, a strictly RTS concern.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    The RTS configure one has a new
    ```
    AC_CHECK_SIZEOF([void *])
    ```
    that the top-level configure version didn't have, so that
    `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
    commits, that can go away.
    
    Progress towards #17191
    
    - - - - -
    41130a65 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `__thread` check
    
    This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over misc function checks
    
    These are for general use in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `eventfd` check
    
    This check is for the RTS part of the event manager and has a
    corresponding part in `base`.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    58f3babf by John Ericson at 2023-10-11T16:02:48-04:00
    Split `FP_CHECK_PTHREADS` and move part to RTS configure
    
    `NEED_PTHREAD_LIB` is unused since
    3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
    system), and so is no longer defined.
    
    Progress towards #17191
    
    - - - - -
    e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00
    nativeGen: section flags for .text$foo only
    
    Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
    #22834 in !9810.
    
    It does however add "xr" indiscriminatly to .text sections
    even if splitSections is disabled. This leads to the assembler saying:
    
    ghc_1.s:7849:0: error:
         Warning: Ignoring changed section attributes for .text
         |
    7849 | .section .text,"xr"
         | ^
    
    - - - - -
    f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00
    Modularity: pass TempDir instead of DynFlags (#17957)
    
    - - - - -
    34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00
    Test that functions from `mingwex` are available
    
    Ryan wrote these two minimizations, but they never got added to the test
    suite.
    
    See #23309, #23378
    
    Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com>
    Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com>
    
    - - - - -
    bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00
    Do not check for the `mingwex` library in `/configure`
    
    See the recent discussion in !10360 --- Cabal will itself check for the
    library for the packages that need it, and while the autoconf check
    additionally does some other things like define a `HAS_LIBMINGWEX` C
    Preprocessor macro, those other things are also unused and unneeded.
    
    Progress towards #17191, which aims to get rid of `/configure` entirely.
    
    - - - - -
    43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00
    base: Introduce move modules into src
    
    The only non-move changes here are whitespace changes to pass the
    `whitespace` test and a few testsuite adaptations.
    
    - - - - -
    df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00
    [PEi386 linker] Bounds check and null-deref guard
    
    We should resonably be able to expect that we won't exceed the number of
    sections if we assume to be dealing with legal object files. We can however
    not guarantee that we get some negative values, and while we try to
    special case most, we should exclude negative indexing into the sections
    array.
    
    We also need to ensure that we do not try to derefences targetSection,
    if it is NULL, due to the switch statement.
    
    - - - - -
    c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
    Move apple compat check to RTS configure
    
    - - - - -
    c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
    Move clock/timer fun checks to RTS configure
    
    Actual library check (which will set the Cabal flag) is left in the
    top-level configure for now.
    
    Progress towards #17191
    
    - - - - -
    7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
    Move visibility and "musttail" annotation checks to the RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
    Move leading underscore checks to RTS configure
    
    `CabalLeadingUnderscore` is done via Hadrian already, so we can stop
    `AC_SUBST`ing it completely.
    
    - - - - -
    25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
    Move alloca, fork, const, and big endian checks to RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    - - - - -
    5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
    Move libdl check to RTS configure
    
    - - - - -
    ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
    Adjust `FP_FIND_LIBFFI`
    
    Just set vars, and `AC_SUBST` in top-level configure.
    
    Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
    be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
    make build system).
    
    - - - - -
    f399812c by John Ericson at 2023-10-12T10:31:13-04:00
    Split BFD support to RTS configure
    
    The flag is still in the top-level configure, but the other checks
    (which define various macros --- important) are in the RTS configure.
    
    - - - - -
    f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
    Split libm check between top level and RTS
    
    - - - - -
    dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
    CgUtils.fixStgRegStmt respect register width
    
    This change ensure that the reg + offset computation is always of the
    same size.  Before this we could end up with a 64bit register, and then
    add a 32bit offset (on 32bit platforms).  This not only would fail type
    sanity checking, but also incorrectly truncate 64bit values into 32bit
    values silently on 32bit architectures.
    
    - - - - -
    9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00
    Fix restarts in .ghcid
    
    Using the whole of `hadrian/` restarted in a loop for me.
    
    - - - - -
    fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    NoFib results (omitted = 0.0%):
    ```
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             pretty           0.0%     -1.6%
                scc           0.0%     -1.7%
    --------------------------------------------------------------------------------
                Min           0.0%     -1.7%
                Max           0.0%     -0.0%
     Geometric Mean          -0.0%     -0.0%
    ```
    
    - - - - -
    32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00
    hadrian: Move ghcBinDeps into ghcLibDeps
    
    This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the
    `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc`
    library so need to make sure they are present in the libdir even if we
    are not going to build `ghc-bin`.
    
    This also fixes things for cross compilers because the stage2
    cross-compiler requires the ghc-usage.txt file, but we are using
    the stage2 lib folder but not building stage3:exe:ghc-bin so
    ghc-usage.txt was not being generated.
    
    - - - - -
    ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00
    Combine GREs when combining in mkImportOccEnv
    
    In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import
    item in favour of another, as explained in Note [Dealing with imports]
    in `GHC.Rename.Names`. However, this can cause us to lose track of
    important parent information.
    
    Consider for example #24084:
    
      module M1 where { class C a where { type T a } }
      module M2 ( module M1 ) where { import M1 }
      module M3 where { import M2 ( C, T ); instance C () where T () = () }
    
    When processing the import list of `M3`, we start off (for reasons that
    are not relevant right now) with two `Avail`s attached to `T`, namely
    `C(C, T)` and `T(T)`. We combine them in the `combine` function of
    `mkImportOccEnv`; as described in Note [Dealing with imports] we discard
    `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not**
    discard the information want that `C` is the parent of `T`. Indeed,
    losing track of this information can cause errors when importing,
    as we could get an error of the form
    
      ‘T’ is not a (visible) associated type of class ‘C’
    
    We fix this by combining the two GREs for `T` using `plusGRE`.
    
    Fixes #24084
    
    - - - - -
    257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00
    hadrian: Pass -DNOSMP to C compiler when needed
    
    Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
    SMP, but doesn't pass it to CC as well, leading to the following
    compilation error on mips64el:
    
    | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
    Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
    ===> Command failed with error code: 1
    In file included from rts/include/Stg.h:348,
                     from rts/include/Rts.h:38,
                     from rts/hooks/FlagDefaults.c:8:
    rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
      416 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
      440 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
      464 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    
    The old make system correctly passed this flag to both GHC and CC [1].
    
    Fix this error by passing -DNOSMP to CC as well.
    
    [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
    
    Closes #24082
    
    - - - - -
    13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00
    Users Guide: Drop dead code for Haddock refs to `parallel`
    
    I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was
    not substituted. It is dead code -- there is no `parallel-ref` usages
    and it doesn't look like there ever was (going back to
    3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it.
    
    - - - - -
    fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)
    
    bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".
    
    - - - - -
    cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Bignum: fix right shift of negative BigNat with native backend
    
    - - - - -
    cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Rts: expose rtsOutOfBoundsAccess symbol
    
    - - - - -
    72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Hadrian: enable `-fcheck-prim-bounds` in validate flavour
    
    This allows T24066 to fail when the bug is present.
    
    Otherwise the out-of-bound access isn't detected as it happens in
    ghc-bignum which wasn't compiled with the bounds check.
    
    - - - - -
    f9436990 by John Ericson at 2023-10-18T19:41:01-04:00
    Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in`
    
    Fixes #24091
    Progress on #23966
    
    Issue #24091 reports that `@ProjectVersion@` is no longer being
    substituted in the GHC user's guide. I assume this is a recent issue,
    but I am not sure how it's worked since
    c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and
    configure are trying to substitute the same `.in` file!
    
    Now only Hadrian does. That is better anyways; already something that
    issue #23966 requested.
    
    It seems like we were missing some dependencies in Hadrian. (I really,
    really hate that this is possible!) Hopefully it is fixed now.
    
    - - - - -
    b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00
    `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`
    
    Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
    be defined. (Guaranteed including a test in the testsuite.)
    
    - - - - -
    0295375a by John Ericson at 2023-10-18T19:41:37-04:00
    Generate `ghcversion.h` from a `.in` file
    
    Now that there are no conditional sections (see the previous commit), we
    can just a do simple substitution rather than pasting it together line
    by line.
    
    Progress on #23966
    
    - - - - -
    740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00
    Add a regression test for #24064
    
    - - - - -
    921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00
    CLC Proposal #182: Export List from Data.List
    
    Proposal link: https://github.com/haskell/core-libraries-committee/issues/182
    
    - - - - -
    4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
    rts: fix small argument passing on big-endian arch (fix #23387)
    
    - - - - -
    b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
    Interpreter: fix literal alignment on big-endian architectures (fix #19261)
    
    Literals weren't correctly aligned on big-endian, despite what the
    comment said.
    
    - - - - -
    a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
    Testsuite: recomp011 and recomp015 are fixed on powerpc
    
    These tests have been fixed but not tested and re-enabled on big-endian
    powerpc (see comments in #11260 and #11323)
    
    - - - - -
    fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
    CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
    - - - - -
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    
    
    30 changed files:
    
    - .ghcid
    - .gitignore
    - .gitlab/ci.sh
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    - .gitlab/rel_eng/upload.sh
    - compiler/CodeGen.Platform.h
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/ByteCode/Asm.hs
    - compiler/GHC/CmmToAsm.hs
    - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
    - compiler/GHC/CmmToAsm/AArch64/Instr.hs
    - compiler/GHC/CmmToAsm/AArch64/Ppr.hs
    - compiler/GHC/CmmToAsm/AArch64/Regs.hs
    - compiler/GHC/CmmToAsm/Ppr.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Data/OrdList.hs
    - compiler/GHC/Driver/Config/Tidy.hs
    - compiler/GHC/Driver/Flags.hs
    - compiler/GHC/Driver/Session.hs
    - compiler/GHC/Hs/Expr.hs
    - compiler/GHC/Hs/Extension.hs
    - compiler/GHC/Hs/Type.hs
    - compiler/GHC/Hs/Utils.hs
    - compiler/GHC/Iface/Tidy.hs
    - compiler/GHC/Parser.y
    - compiler/GHC/Parser/Annotation.hs
    - compiler/GHC/Parser/PostProcess.hs
    - compiler/GHC/Rename/Env.hs
    - compiler/GHC/Rename/Names.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/722987bc93bd19c5dd0ae3d7f06b1449b3fe09a7...4d075924b44b281ff48760c9184a8de47a5044d4
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/722987bc93bd19c5dd0ae3d7f06b1449b3fe09a7...4d075924b44b281ff48760c9184a8de47a5044d4
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 14:19:42 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Tue, 24 Oct 2023 10:19:42 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: EPA Some
     tweaks to annotations
    Message-ID: <6537d27e299ae_1f7b0d46a8405836465d@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    2145ddaf by Cheng Shao at 2023-10-24T10:19:33-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    
    
    10 changed files:
    
    - compiler/GHC/Parser.y
    - compiler/GHC/Parser/Annotation.hs
    - compiler/GHC/Parser/PostProcess.hs
    - docs/users_guide/exts/primitives.rst
    - docs/users_guide/javascript.rst
    - testsuite/tests/ghc-api/all.T
    - testsuite/tests/ghc-api/downsweep/all.T
    - testsuite/tests/parser/should_compile/DumpSemis.stderr
    - testsuite/tests/parser/should_compile/T15323.stderr
    - testsuite/tests/printer/Test20297.stdout
    
    
    Changes:
    
    =====================================
    compiler/GHC/Parser.y
    =====================================
    @@ -2269,7 +2269,7 @@ atype :: { LHsType GhcPs }
             | PREFIX_TILDE atype             {% acsA (\cs -> sLL $1 $> (mkBangTy (EpAnn (glR $1) [mj AnnTilde $1] cs) SrcLazy $2)) }
             | PREFIX_BANG  atype             {% acsA (\cs -> sLL $1 $> (mkBangTy (EpAnn (glR $1) [mj AnnBang $1] cs) SrcStrict $2)) }
     
    -        | '{' fielddecls '}'             {% do { decls <- acsA (\cs -> (sLL $1 $> $ HsRecTy (EpAnn (glR $1) (AnnList (Just $ listAsAnchor $2) (Just $ moc $1) (Just $ mcc $3) [] []) cs) $2))
    +        | '{' fielddecls '}'             {% do { decls <- acsA (\cs -> (sLL $1 $> $ HsRecTy (EpAnn (glR $1) (AnnList (listAsAnchorM $2) (Just $ moc $1) (Just $ mcc $3) [] []) cs) $2))
                                                    ; checkRecordSyntax decls }}
                                                             -- Constructor sigs only
             | '(' ')'                        {% acsA (\cs -> sLL $1 $> $ HsTupleTy (EpAnn (glR $1) (AnnParen AnnParens (glAA $1) (glAA $2)) cs)
    @@ -2407,7 +2407,7 @@ gadt_constrlist :: { Located ([AddEpAnn]
                               ,[LConDecl GhcPs]) } -- Returned in order
     
             : 'where' '{'        gadt_constrs '}'    {% checkEmptyGADTs $
    -                                                      L (comb2 $1 $3)
    +                                                      L (comb2 $1 $4)
                                                             ([mj AnnWhere $1
                                                              ,moc $2
                                                              ,mcc $4]
    @@ -2588,8 +2588,9 @@ rhs     :: { Located (GRHSs GhcPs (LHsExpr GhcPs)) }
             : '=' exp wherebinds    {% runPV (unECP $2) >>= \ $2 ->
                                       do { let L l (bs, csw) = adaptWhereBinds $3
                                          ; let loc = (comb3 $1 $2 (L l bs))
    +                                     ; let locg = (comb2 $1 $2)
                                          ; acs (\cs ->
    -                                       sL loc (GRHSs csw (unguardedRHS (EpAnn (anc $ rs loc) (GrhsAnn Nothing (mj AnnEqual $1)) cs) loc $2)
    +                                       sL loc (GRHSs csw (unguardedRHS (EpAnn (anc $ rs locg) (GrhsAnn Nothing (mj AnnEqual $1)) cs) locg $2)
                                                           bs)) } }
             | gdrhs wherebinds      {% do { let {L l (bs, csw) = adaptWhereBinds $2}
                                           ; acs (\cs -> sL (comb2 $1 (L l bs))
    @@ -3324,7 +3325,7 @@ alts1(PATS) :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs
     alt(PATS) :: { forall b. DisambECP b => PV (LMatch GhcPs (LocatedA b)) }
             : PATS alt_rhs { $2 >>= \ $2 ->
                              acsA (\cs -> sLLAsl $1 $>
    -                                         (Match { m_ext = EpAnn (listAsAnchor $1) [] cs
    +                                         (Match { m_ext = EpAnn (listAsAnchor $1 $>) [] cs
                                                     , m_ctxt = CaseAlt -- for \case and \cases, this will be changed during post-processing
                                                     , m_pats = $1
                                                     , m_grhss = unLoc $2 }))}
    @@ -3336,7 +3337,7 @@ alt_rhs :: { forall b. DisambECP b => PV (Located (GRHSs GhcPs (LocatedA b))) }
     
     ralt :: { forall b. DisambECP b => PV (Located [LGRHS GhcPs (LocatedA b)]) }
             : '->' exp            { unECP $2 >>= \ $2 ->
    -                                acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (glR $1) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 $2) $2)) }
    +                                acs (\cs -> sLL $1 $> (unguardedRHS (EpAnn (spanAsAnchor $ comb2 $1 (reLoc $2)) (GrhsAnn Nothing (mu AnnRarrow $1)) cs) (comb2 $1 (reLoc $2)) $2)) }
             | gdpats              { $1 >>= \gdpats ->
                                     return $ sL1 gdpats (reverse (unLoc gdpats)) }
     
    @@ -4465,9 +4466,16 @@ hsDoAnn :: Located a -> LocatedAn t b -> AnnKeywordId -> AnnList
     hsDoAnn (L l _) (L ll _) kw
       = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (srcSpan2e l)] []
     
    -listAsAnchor :: [LocatedAn t a] -> Anchor
    -listAsAnchor [] = spanAsAnchor noSrcSpan
    -listAsAnchor (L l _:_) = spanAsAnchor (locA l)
    +listAsAnchor :: [LocatedAn t a] -> Located b -> Anchor
    +listAsAnchor [] (L l _) = spanAsAnchor l
    +listAsAnchor (h:_) s = spanAsAnchor (comb2 (reLoc h) s)
    +
    +listAsAnchorM :: [LocatedAn t a] -> Maybe Anchor
    +listAsAnchorM [] = Nothing
    +listAsAnchorM (L l _:_) =
    +  case locA l of
    +    RealSrcSpan ll _ -> Just $ realSpanAsAnchor ll
    +    _                -> Nothing
     
     hsTok :: Located Token -> LHsToken tok GhcPs
     hsTok (L l _) = L (mkTokenLocation l) HsTok
    @@ -4528,7 +4536,6 @@ addTrailingAnnL (L (SrcSpanAnn anns l) a) ta = do
     -- Mostly use to add AnnComma, special case it to NOP if adding a zero-width annotation
     addTrailingCommaN :: MonadP m => LocatedN a -> SrcSpan -> m (LocatedN a)
     addTrailingCommaN (L (SrcSpanAnn anns l) a) span = do
    -  -- cs <- getCommentsFor l
       let cs = emptyComments
       -- AZ:TODO: generalise updating comments into an annotation
       let anns' = if isZeroWidthSpan span
    
    
    =====================================
    compiler/GHC/Parser/Annotation.hs
    =====================================
    @@ -19,8 +19,8 @@ module GHC.Parser.Annotation (
       DeltaPos(..), deltaPos, getDeltaLine,
     
       EpAnn(..), Anchor(..), AnchorOperation(..),
    -  spanAsAnchor, realSpanAsAnchor,
       NoAnn(..),
    +  spanAsAnchor, realSpanAsAnchor, spanFromAnchor,
     
       -- ** Comments in Annotations
     
    @@ -549,6 +549,9 @@ spanAsAnchor s  = Anchor (realSrcSpan s) UnchangedAnchor
     realSpanAsAnchor :: RealSrcSpan -> Anchor
     realSpanAsAnchor s  = Anchor s UnchangedAnchor
     
    +spanFromAnchor :: Anchor -> SrcSpan
    +spanFromAnchor a = RealSrcSpan (anchor a) Strict.Nothing
    +
     -- ---------------------------------------------------------------------
     
     -- | When we are parsing we add comments that belong a particular AST
    
    
    =====================================
    compiler/GHC/Parser/PostProcess.hs
    =====================================
    @@ -831,11 +831,18 @@ mkGadtDecl loc names dcol ty = do
     
       let an = EpAnn (spanAsAnchor loc) annsa (cs Semi.<> csa)
     
    +  let bndrs_loc = case outer_bndrs of
    +        HsOuterImplicit{} -> getLoc ty
    +        HsOuterExplicit an _ ->
    +          case an of
    +            EpAnnNotUsed -> getLoc ty
    +            an' -> SrcSpanAnn (EpAnn (entry an') noAnn emptyComments) (spanFromAnchor (entry an'))
    +
       pure $ L l ConDeclGADT
                          { con_g_ext  = an
                          , con_names  = names
                          , con_dcolon = dcol
    -                     , con_bndrs  = L (getLoc ty) outer_bndrs
    +                     , con_bndrs  = L bndrs_loc outer_bndrs
                          , con_mb_cxt = mcxt
                          , con_g_args = args
                          , con_res_ty = res_ty
    
    
    =====================================
    docs/users_guide/exts/primitives.rst
    =====================================
    @@ -12,7 +12,7 @@ you write will be optimised to the efficient unboxed version in any
     case. And if it isn't, we'd like to know about it.
     
     All these primitive data types and operations are exported by the
    -library :base-ref:`GHC.Exts.`.
    +module :base-ref:`GHC.Exts.`.
     
     If you want to mention any of the primitive data types or operations in
     your program, you must first import ``GHC.Exts`` to bring them into
    
    
    =====================================
    docs/users_guide/javascript.rst
    =====================================
    @@ -1,7 +1,7 @@
     .. _ffi-javascript:
     
     FFI and the JavaScript Backend
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    +==============================
     
     .. index::
        single: FFI and the JavaScript Backend
    @@ -22,8 +22,46 @@ look like:
       foreign import javascript "((x,y) => { return x + y; })"
         js_add :: Int -> Int -> Int
     
    +.. _`JavaScript FFI Types`:
    +
    +JavaScript FFI Types
    +--------------------
    +
    +Some types are able to be used directly in the type signatures of foreign
    +exports, without conversion to a ``JSVal``. We saw in the first example
    +that ``Int`` is one of these.
    +
    +There are a number of supported types that can be passed directly in this
    +way, and they act as primitives within GHC's JavaScript RTS. This is in
    +comparison to data structures that are implemented in Haskell, such as
    +``String`` - being a list, this doesn't have a primitive JavaScript implementation,
    +and isn't equivalent to a JavaScript string.
    +
    +The following types are supported in this way:
    +
    +* ``Int``, including ``Int32`` and other sized numerical values.
    +* ``Int64``, and other 64 bit numbers are passed as two variables to the function,
    +  where the first includes the sign and the higher bits
    +* ``Bool``
    +* ``Char``
    +* ``Any``
    +* ``ByteArray#``
    +* ``Double`` and ``Float``
    +* ``MVar#``, and other RTS objects
    +* Unboxed tuples (e.g. ``(# a, b #)``) can appear in the return type, and are
    +  constructed in JavaScript using macros such as ``RETURN_UBX_TUP2(x, y)``.
    +
    +As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so
    +the following example would compile successfully - despite `5` not being a valid JavaScript value
    +for the Haskell `Bool` type:
    +
    +.. code-block:: haskell
    +
    +  foreign import javascript "((x) => { return 5; })"
    +    type_error :: Bool -> Bool
    +
     JSVal
    -~~~~~
    +^^^^^
     
     The JavaScript backend has a concept of an untyped 'plain' JavaScript
     value, under the guise of the type ``JSVal``. Values having this type
    @@ -46,36 +84,9 @@ It also contains functions for working with objects:
     * ``isUndefined :: JSVal -> Bool`` - test for the JavaScript ``undefined``
     * ``getProp :: JSVal -> String -> JSVal`` - object field access
     
    -JavaScript FFI Types
    -~~~~~~~~~~~~~~~~~~~~
    -
    -Some types are able to be used directly in the type signatures of foreign
    -exports, without conversion to a ``JSVal``. We saw in the first example
    -that ``Int`` is one of these.
    -
    -The supported types are those with primitive JavaScript representations
    -that match the Haskell type. This means types such as the Haskell ``String``
    -type aren't supported directly, because they're lists - which don't have
    -a primitive JavaScript representation, and so are incompatible with each
    -other.
    -
    -The following types are supported in this way:
    -
    -* ``Int``
    -* ``Bool``
    -* ``Char``
    -
    -As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so
    -the following example would compile successfully - despite `5` not being a valid JavaScript value
    -for the Haskell `Bool` type:
    -
    -.. code-block:: haskell
    -
    -  foreign import javascript "((x) => { return 5; })"
    -    type_error :: Bool -> Bool
     
     JavaScript Callbacks
    -~~~~~~~~~~~~~~~~~~~~
    +^^^^^^^^^^^^^^^^^^^^
     
     The JavaScript execution model is based around callback functions, and
     GHC's JavaScript backend implements these as a type in order to support
    @@ -173,3 +184,240 @@ We have to make sure not to use ``releaseCallback`` on any functions that
     are to be available in HTML, because we want these functions to be in
     memory indefinitely.
     
    +Writing Replacement Implementations for Libraries with C FFI Functions
    +----------------------------------------------------------------------
    +
    +Many libraries make use of C FFI functions to accomplish low-level or
    +performance sensitive operations - known as ``cbits`` and often kept in
    +a folder with this name. For such a library to support the JavaScript
    +backend, the ``cbits`` must have replacement implementations.
    +
    +In principle, it is possible for the JavaScript backend to automatically
    +compile ``cbits`` using Emscripten, but this requires wrappers to convert
    +data between the JS backend's RTS data format, and the format expected by
    +Emscripten-compiled functions. Since C functions are often used where
    +performance is more critical, there's potential for the data conversions
    +to negate this purpose.
    +
    +Instead, it is more effective for a library to provide an alternate
    +implementation for functions using the C FFI - either by providing direct
    +one-to-one replacement JavaScript functions, or by using C preprocessor
    +directives to replace C FFI imports with some combination of JS FFI imports
    +and pure-Haskell implementation.
    +
    +Direct Implementation of C FFI Imports in JavaScript as ``jsbits``
    +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    +
    +When the JavaScript backend generates code for a C FFI import, it will call
    +the function named in the import string, prepended by ``h$`` - so the imported
    +C function ``open`` will look for the JavaScript function ``h$open``. No verification
    +is done to ensure that these functions are actually implemented in the linked
    +JavaScript files, so there can be runtime errors when a missing JavaScript
    +function is called.
    +
    +Based on this, implementing a C function in JavaScript is a matter of providing
    +a function of the correct shape (based on the C FFI import type signature) in
    +any of the linked JavaScript sources. External JavaScript sources are linked
    +by either providing them as an argument to GHC, or listing them in the ``js-sources``
    +field of the cabal file - in which case it would usually be inside a predicate to
    +detect the ``javascript`` architecture, such as:
    +
    +.. code-block:: cabal
    +
    +  library
    +
    +    if arch(javascript)
    +      js-sources:
    +        jsbits/example.js
    +
    +Note that ``js-sources`` requires Cabal 3.10 to be used with library targets, and
    +Cabal 3.12 to be used with executable targets.
    +
    +The shape required of the JavaScript function will depend on the particular
    +C types used:
    +
    +* primitives, such as ``CInt`` will map directly to a single JavaScript argument
    +  using JavaScript primitives. In the case of ``CInt``, this will be a JavaScript
    +  number. Note that in the case of return values, a JavaScript number will usually
    +  need to be rounded or cast back to an integral value in cases where mathematical
    +  operations are used
    +
    +* pointer values, including ``CString``, are passed as an unboxed ``(ptr, offset)``
    +  pair. For arguments, being unboxed will mean these are passed as two top-level
    +  arguments to the function. For return values, unboxed values should be returned
    +  from JavaScript functions by using a special C preprocessor macro,
    +  ``RETURN_UBX_TUP2(ptr, offset)``
    +
    +* ``CString``, in addition to the above pointer handling, will need to be decoded
    +  and encoded to convert them between character arrays and JavaScript strings.
    +
    +* other RTS primitive types are discussed previously in `JavaScript FFI Types`_.
    +
    +As an example, let's consider the implementation of ``getcwd``:
    +
    +.. code-block:: haskell
    +
    +  -- unix:System.Posix.Directory
    +
    +  foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar)
    +
    +.. code-block:: javascript
    +
    +  // libraries/base/jsbits/base.js
    +
    +  //#OPTIONS: CPP
    +
    +  function h$getcwd(buf, off, buf_size) {
    +    try {
    +      var cwd = h$encodeUtf8(process.cwd());
    +      if (buf_size < cwd.len && buf_size !== 0) {
    +        h$setErrno("ERANGE");
    +        RETURN_UBX_TUP2(null, 0);
    +      } else if (buf !== null) {
    +        h$copyMutableByteArray(cwd, 0, buf, off, cwd.len);
    +        RETURN_UBX_TUP2(buf, off);
    +      } else if (buf_size === 0) {
    +        RETURN_UBX_TUP2(cwd, 0);
    +      } else {
    +        var out = h$newByteArray(buf_size);
    +        h$copyMutableByteArray(cwd, 0, out, off, cwd.len);
    +      }
    +    } catch (e) {
    +      h$setErrno(e);
    +      RETURN_UBX_TUP2(null, 0);
    +    }
    +  }
    +
    +Here, the C function ``getcwd`` maps to the JavaScript function ``h$getcwd``, which
    +exists in a ``.js`` file within ``base``'s ``jsbits`` subdirectory. ``h$getcwd``
    +expects a ``CString`` (passed as the equivalent ``Ptr CChar``) and a
    +``CSize`` argument. This results in three arguments to the JavaScript function - two
    +for the string's pointer and offset, and one for the size, which will be passed as a
    +JavaScript number.
    +
    +Next, the JavaScript ``h$getcwd`` function demonstrates several details:
    +
    +* In the try clause, the ``cwd`` value is first accessed using a NodeJS-provided method.
    +  This value is immediately encoded using ``h$encodeUtf8``, which is provided by the
    +  JavaScript backend. This function will only return the pointer for the encoded value,
    +  and the offset will always be 0
    +
    +* Next, we select one of several cases - based on the specification of the C function
    +  that we're trying to immitate
    +
    +* In the first case where the given buffer size is too small, but not zero, the function
    +  must set the ``ERANGE`` error code, which we do here with ``h$setErrno``, and return
    +  ``null``. As we saw in the function arguments, pointers are passed as a ``(ptr, offset)``
    +  pair - meaning ``null`` is represented by returning the unboxed pair ``(null, 0)``
    +
    +* In the second case where there is enough space in ``buf`` to successfully copy the
    +  bytes, we do so using ``h$copyMutableByteArray`` - a function supplied by GHC's JavaScript
    +  RTS
    +
    +* In the third case where ``buf_size`` is 0, this indicates in the C function's specification
    +  that we can allocate a new buffer of the appropriate size to return. We already have
    +  this in the form of the previously encoded ``cwd``, so we can just return it, along
    +  with the 0 offset
    +
    +* In the last case where ``buf`` is null, and ``buf_size`` is large enough, we allocate a
    +  new buffer, this time with ``buf_size`` bytes of space using ``h$newByteArray``, and
    +  we again perform a mutable copy
    +
    +* To use C preprocessor macros in linked JavaScript files, the file must open with the
    +  ``//#OPTIONS: CPP`` line, as is shown towards the start of this snippet
    +
    +* If an error occurs, the catch clause will pass it to ``h$setErrno`` and return the
    +  ``(null, 0)`` pointer and offset pair - which is a behaviour expected by the C function
    +  in the error case.
    +
    +Writing JavaScript Functions to be NodeJS and Browser Aware
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +
    +In the above example of implementing ``getcwd``, the function we use in the JavaScript
    +implementation is from NodeJS, and the behaviour doesn't make sense to implement in a
    +browser. Therefore, the actual implementation will include a C preprocessor condition
    +to check if we're compiling for the browser, in which case ``h$unsupported(-1)`` will
    +be called. There can be multiple non-browser JavaScript runtimes, so we'll also have
    +to check at runtime to make sure that NodeJS is in use.
    +
    +.. code-block:: javascript
    +
    +  function h$getcwd(buf, off, buf_size) {
    +  #ifndef GHCJS_BROWSER
    +    if (h$isNode()) {
    +      try {
    +        var cwd = h$encodeUtf8(process.cwd());
    +        if (buf_size < cwd.len && buf_size !== 0) {
    +          h$setErrno("ERANGE");
    +          return (null, 0);
    +        } else if (buf !== null) {
    +          h$copyMutableByteArray(cwd, 0, buf, off, cwd.len);
    +          RETURN_UBX_TUP2(buf, off);
    +        } else if (buf_size === 0) {
    +          RETURN_UBX_TUP2(cwd, 0);
    +        } else {
    +          var out = h$newByteArray(buf_size);
    +          h$copyMutableByteArray(cwd, 0, out, off, cwd.len);
    +        }
    +      } catch (e) {
    +        h$setErrno(e);
    +        RETURN_UBX_TUP2(null, 0);
    +      }
    +    } else
    +  #endif
    +      h$unsupported();
    +      RETURN_UBX_TUP2(null, 0);
    +  }
    +
    +Replacing C FFI Imports with Pure Haskell and JavaScript
    +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    +
    +Instead of providing a direct JavaScript implementation for each C FFI import, we can
    +instead use the C preprocessor to conditionally remove these C imports (and possibly
    +use sites as well). Then, some combination of JavaScript FFI imports and Haskell
    +implementation can be added instead. As in the direct implementation section, any
    +linked JavaScript files should usually be in a ``if arch(javascript)`` condition in
    +the cabal file.
    +
    +As an example of a mixed Haskell and JavaScript implementation replacing a C
    +implementation, consider ``base:GHC.Clock``:
    +
    +.. code-block:: haskell
    +
    +  #if defined(javascript_HOST_ARCH)
    +  getMonotonicTimeNSec :: IO Word64
    +  getMonotonicTimeNSec = do
    +    w <- getMonotonicTimeMSec
    +    return (floor w * 1000000)
    +
    +  foreign import javascript unsafe "performance.now"
    +    getMonotonicTimeMSec :: IO Double
    +
    +  #else
    +  foreign import ccall unsafe "getMonotonicNSec"
    +    getMonotonicTimeNSec :: IO Word64
    +  #endif
    +
    +Here, the ``getMonotonicTimeNSec`` C FFI import is replaced by the JavaScript FFI
    +import ``getMonotonicTimeMSec``, which imports the standard JavaScript function
    +``performance.now``. However, because this JavaScript implementation
    +returns the time as a ``Double`` of floating point milliseconds, it must be wrapped
    +by a Haskell function to extract the integral value that's expected.
    +
    +In this case, the choice of using a mixed Haskell and JavaScript replacement
    +implementation was caused by the limitation of clocks being system calls. In a lot
    +of cases, C functions are used for similar system-level functionality. In such
    +cases, it's recommended to import the required system functions from standard
    +JavaScript libraries (or from the runtime, as was required for ``getcwd``), and
    +use Haskell wrapper functions to convert the imported functions to the appropriate
    +format.
    +
    +In other cases, C functions are used for performance. For these cases, pure-Haskell
    +implementations are the preferred first step for compatibility with the JavaScript
    +backend since it would be more future-proof against changes to the RTS data format.
    +Depending on the use case, compiler-optimised JS code might be hard to complete with
    +using hand-written JavaScript. Generally, the most likely performance gains from
    +hand-written JavaScript come from functions with data that stays as JavaScript
    +primitive types for a long time, especially strings. For this, ``JSVal`` allows
    +values to be passed between ``Haskell`` and ``JavaScript`` without a marshalling
    +penalty.
    
    
    =====================================
    testsuite/tests/ghc-api/all.T
    =====================================
    @@ -1,3 +1,5 @@
    +setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
    +
     test('ghcApi', normal, compile_and_run, ['-package ghc'])
     test('T6145', js_broken(22352), makefile_test, ['T6145'])
     test('T8639_api', req_rts_linker,
    
    
    =====================================
    testsuite/tests/ghc-api/downsweep/all.T
    =====================================
    @@ -1,3 +1,5 @@
    +setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
    +
     test('PartialDownsweep',
          [ extra_run_opts('"' + config.libdir + '"')
          , ignore_stderr
    
    
    =====================================
    testsuite/tests/parser/should_compile/DumpSemis.stderr
    =====================================
    @@ -1829,7 +1829,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:39:6 }
    +                        { DumpSemis.hs:39:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -1862,7 +1862,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:39:8-9 }
    +                            { DumpSemis.hs:39:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -1898,7 +1898,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:40:6 }
    +                        { DumpSemis.hs:40:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -1931,7 +1931,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:40:8-9 }
    +                            { DumpSemis.hs:40:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -1969,7 +1969,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:41:6 }
    +                        { DumpSemis.hs:41:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -2002,7 +2002,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:41:8-9 }
    +                            { DumpSemis.hs:41:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -2042,7 +2042,7 @@
                          (Match
                           (EpAnn
                            (Anchor
    -                        { DumpSemis.hs:42:6 }
    +                        { DumpSemis.hs:42:6-13 }
                             (UnchangedAnchor))
                            []
                            (EpaComments
    @@ -2075,7 +2075,7 @@
                              (GRHS
                               (EpAnn
                                (Anchor
    -                            { DumpSemis.hs:42:8-9 }
    +                            { DumpSemis.hs:42:8-13 }
                                 (UnchangedAnchor))
                                (GrhsAnn
                                 (Nothing)
    @@ -2100,3 +2100,5 @@
                             (NoExtField)))))]))))))]
                 (EmptyLocalBinds
                  (NoExtField)))))])))))]))
    +
    +
    
    
    =====================================
    testsuite/tests/parser/should_compile/T15323.stderr
    =====================================
    @@ -100,7 +100,14 @@
                  (EpaSpan { T15323.hs:6:17-18 }))
                 (HsNormalTok))
                (L
    -            (SrcSpanAnn (EpAnnNotUsed) { T15323.hs:6:20-54 })
    +            (SrcSpanAnn (EpAnn
    +                         (Anchor
    +                          { T15323.hs:6:20-25 }
    +                          (UnchangedAnchor))
    +                         (AnnListItem
    +                          [])
    +                         (EpaComments
    +                          [])) { T15323.hs:6:20-25 })
                 (HsOuterExplicit
                  (EpAnn
                   (Anchor
    
    
    =====================================
    testsuite/tests/printer/Test20297.stdout
    =====================================
    @@ -82,11 +82,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.hs:(5,5)-(7,7) })
    +               { Test20297.hs:5:5-7 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.hs:(5,5)-(7,7) }
    +                 { Test20297.hs:5:5-7 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -182,11 +182,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.hs:(9,5)-(11,26) })
    +               { Test20297.hs:9:5-7 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.hs:(9,5)-(11,26) }
    +                 { Test20297.hs:9:5-7 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -422,11 +422,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.ppr.hs:(4,3)-(5,7) })
    +               { Test20297.ppr.hs:4:3-5 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.ppr.hs:(4,3)-(5,7) }
    +                 { Test20297.ppr.hs:4:3-5 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -508,11 +508,11 @@
                 [(L
                   (SrcSpanAnn
                    (EpAnnNotUsed)
    -               { Test20297.ppr.hs:(7,3)-(9,24) })
    +               { Test20297.ppr.hs:7:3-5 })
                   (GRHS
                    (EpAnn
                     (Anchor
    -                 { Test20297.ppr.hs:(7,3)-(9,24) }
    +                 { Test20297.ppr.hs:7:3-5 }
                      (UnchangedAnchor))
                     (GrhsAnn
                      (Nothing)
    @@ -655,4 +655,3 @@
                             (EmptyLocalBinds
                              (NoExtField)))))]))))]}
                   [])))))])))))]))
    -
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0be70e34d14e99b8f5b9a6daa839482d49c83dcc...2145ddaf5cadf9840f49c9fb567a47b12df116cd
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0be70e34d14e99b8f5b9a6daa839482d49c83dcc...2145ddaf5cadf9840f49c9fb567a47b12df116cd
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 16:38:48 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Tue, 24 Oct 2023 12:38:48 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Comments
    Message-ID: <6537f3185235e_1f7b0d49faab38439898@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    c6fe0842 by Simon Peyton Jones at 2023-10-24T17:38:35+01:00
    Comments
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -560,7 +560,11 @@ exprTree opts args expr
         -----------------------------
         -- size_up_app is used when there's ONE OR MORE value args
         go_app :: ETVars -> CoreExpr -> [CoreExpr] -> Int -> ExprTree
    -                   -- args are the value args
    +        -- args:  all the value args
    +        -- voids: counts the zero-bit arguments; don't charge for these
    +        --        This makes a difference in ST-heavy code which does
    +        --        does a lot of state passing, and which can be in an
    +        --        inner loop.
         go_app vs (App fun arg) args voids
                       | isTypeArg arg      = go_app vs fun args voids
                       | isZeroBitArg arg   = go_app vs fun (arg:args) (voids+1)
    @@ -745,7 +749,7 @@ funSize opts (avs,_) fun n_val_args voids
                            , et_cases = cases
                            , et_ret   = res_discount }
       where
    -    size | n_val_args == 0 = 0
    +    size | n_val_args == 0 = 0    -- Naked variable counts zero
              | otherwise       = vanillaCallSize n_val_args voids
     
         -- Discount if this is an interesting variable, and is applied
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6fe0842f50a31ac9045264469503b5b5b6f8dd4
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6fe0842f50a31ac9045264469503b5b5b6f8dd4
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 17:09:54 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Tue, 24 Oct 2023 13:09:54 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] testsuite: increase
     timeout of ghc-api tests for wasm32
    Message-ID: <6537fa6237a6f_1f7b0d4ac3b94c45146b@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    dde1d7ff by Cheng Shao at 2023-10-24T13:09:50-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    
    
    2 changed files:
    
    - testsuite/tests/ghc-api/all.T
    - testsuite/tests/ghc-api/downsweep/all.T
    
    
    Changes:
    
    =====================================
    testsuite/tests/ghc-api/all.T
    =====================================
    @@ -1,3 +1,5 @@
    +setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
    +
     test('ghcApi', normal, compile_and_run, ['-package ghc'])
     test('T6145', js_broken(22352), makefile_test, ['T6145'])
     test('T8639_api', req_rts_linker,
    
    
    =====================================
    testsuite/tests/ghc-api/downsweep/all.T
    =====================================
    @@ -1,3 +1,5 @@
    +setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
    +
     test('PartialDownsweep',
          [ extra_run_opts('"' + config.libdir + '"')
          , ignore_stderr
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dde1d7ff0656269a90b512984fd19de8da21411d
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dde1d7ff0656269a90b512984fd19de8da21411d
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 19:40:41 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Tue, 24 Oct 2023 15:40:41 -0400
    Subject: [Git][ghc/ghc][master] JS/userguide: add explanation of writing jsbits
    Message-ID: <65381db9a3683_1f7b0d4e84a4d84681b5@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    
    
    1 changed file:
    
    - docs/users_guide/javascript.rst
    
    
    Changes:
    
    =====================================
    docs/users_guide/javascript.rst
    =====================================
    @@ -1,7 +1,7 @@
     .. _ffi-javascript:
     
     FFI and the JavaScript Backend
    -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    +==============================
     
     .. index::
        single: FFI and the JavaScript Backend
    @@ -22,8 +22,46 @@ look like:
       foreign import javascript "((x,y) => { return x + y; })"
         js_add :: Int -> Int -> Int
     
    +.. _`JavaScript FFI Types`:
    +
    +JavaScript FFI Types
    +--------------------
    +
    +Some types are able to be used directly in the type signatures of foreign
    +exports, without conversion to a ``JSVal``. We saw in the first example
    +that ``Int`` is one of these.
    +
    +There are a number of supported types that can be passed directly in this
    +way, and they act as primitives within GHC's JavaScript RTS. This is in
    +comparison to data structures that are implemented in Haskell, such as
    +``String`` - being a list, this doesn't have a primitive JavaScript implementation,
    +and isn't equivalent to a JavaScript string.
    +
    +The following types are supported in this way:
    +
    +* ``Int``, including ``Int32`` and other sized numerical values.
    +* ``Int64``, and other 64 bit numbers are passed as two variables to the function,
    +  where the first includes the sign and the higher bits
    +* ``Bool``
    +* ``Char``
    +* ``Any``
    +* ``ByteArray#``
    +* ``Double`` and ``Float``
    +* ``MVar#``, and other RTS objects
    +* Unboxed tuples (e.g. ``(# a, b #)``) can appear in the return type, and are
    +  constructed in JavaScript using macros such as ``RETURN_UBX_TUP2(x, y)``.
    +
    +As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so
    +the following example would compile successfully - despite `5` not being a valid JavaScript value
    +for the Haskell `Bool` type:
    +
    +.. code-block:: haskell
    +
    +  foreign import javascript "((x) => { return 5; })"
    +    type_error :: Bool -> Bool
    +
     JSVal
    -~~~~~
    +^^^^^
     
     The JavaScript backend has a concept of an untyped 'plain' JavaScript
     value, under the guise of the type ``JSVal``. Values having this type
    @@ -46,36 +84,9 @@ It also contains functions for working with objects:
     * ``isUndefined :: JSVal -> Bool`` - test for the JavaScript ``undefined``
     * ``getProp :: JSVal -> String -> JSVal`` - object field access
     
    -JavaScript FFI Types
    -~~~~~~~~~~~~~~~~~~~~
    -
    -Some types are able to be used directly in the type signatures of foreign
    -exports, without conversion to a ``JSVal``. We saw in the first example
    -that ``Int`` is one of these.
    -
    -The supported types are those with primitive JavaScript representations
    -that match the Haskell type. This means types such as the Haskell ``String``
    -type aren't supported directly, because they're lists - which don't have
    -a primitive JavaScript representation, and so are incompatible with each
    -other.
    -
    -The following types are supported in this way:
    -
    -* ``Int``
    -* ``Bool``
    -* ``Char``
    -
    -As in the C FFI, types in the JavaScript FFI can't be type checked against the foreign code, so
    -the following example would compile successfully - despite `5` not being a valid JavaScript value
    -for the Haskell `Bool` type:
    -
    -.. code-block:: haskell
    -
    -  foreign import javascript "((x) => { return 5; })"
    -    type_error :: Bool -> Bool
     
     JavaScript Callbacks
    -~~~~~~~~~~~~~~~~~~~~
    +^^^^^^^^^^^^^^^^^^^^
     
     The JavaScript execution model is based around callback functions, and
     GHC's JavaScript backend implements these as a type in order to support
    @@ -173,3 +184,240 @@ We have to make sure not to use ``releaseCallback`` on any functions that
     are to be available in HTML, because we want these functions to be in
     memory indefinitely.
     
    +Writing Replacement Implementations for Libraries with C FFI Functions
    +----------------------------------------------------------------------
    +
    +Many libraries make use of C FFI functions to accomplish low-level or
    +performance sensitive operations - known as ``cbits`` and often kept in
    +a folder with this name. For such a library to support the JavaScript
    +backend, the ``cbits`` must have replacement implementations.
    +
    +In principle, it is possible for the JavaScript backend to automatically
    +compile ``cbits`` using Emscripten, but this requires wrappers to convert
    +data between the JS backend's RTS data format, and the format expected by
    +Emscripten-compiled functions. Since C functions are often used where
    +performance is more critical, there's potential for the data conversions
    +to negate this purpose.
    +
    +Instead, it is more effective for a library to provide an alternate
    +implementation for functions using the C FFI - either by providing direct
    +one-to-one replacement JavaScript functions, or by using C preprocessor
    +directives to replace C FFI imports with some combination of JS FFI imports
    +and pure-Haskell implementation.
    +
    +Direct Implementation of C FFI Imports in JavaScript as ``jsbits``
    +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    +
    +When the JavaScript backend generates code for a C FFI import, it will call
    +the function named in the import string, prepended by ``h$`` - so the imported
    +C function ``open`` will look for the JavaScript function ``h$open``. No verification
    +is done to ensure that these functions are actually implemented in the linked
    +JavaScript files, so there can be runtime errors when a missing JavaScript
    +function is called.
    +
    +Based on this, implementing a C function in JavaScript is a matter of providing
    +a function of the correct shape (based on the C FFI import type signature) in
    +any of the linked JavaScript sources. External JavaScript sources are linked
    +by either providing them as an argument to GHC, or listing them in the ``js-sources``
    +field of the cabal file - in which case it would usually be inside a predicate to
    +detect the ``javascript`` architecture, such as:
    +
    +.. code-block:: cabal
    +
    +  library
    +
    +    if arch(javascript)
    +      js-sources:
    +        jsbits/example.js
    +
    +Note that ``js-sources`` requires Cabal 3.10 to be used with library targets, and
    +Cabal 3.12 to be used with executable targets.
    +
    +The shape required of the JavaScript function will depend on the particular
    +C types used:
    +
    +* primitives, such as ``CInt`` will map directly to a single JavaScript argument
    +  using JavaScript primitives. In the case of ``CInt``, this will be a JavaScript
    +  number. Note that in the case of return values, a JavaScript number will usually
    +  need to be rounded or cast back to an integral value in cases where mathematical
    +  operations are used
    +
    +* pointer values, including ``CString``, are passed as an unboxed ``(ptr, offset)``
    +  pair. For arguments, being unboxed will mean these are passed as two top-level
    +  arguments to the function. For return values, unboxed values should be returned
    +  from JavaScript functions by using a special C preprocessor macro,
    +  ``RETURN_UBX_TUP2(ptr, offset)``
    +
    +* ``CString``, in addition to the above pointer handling, will need to be decoded
    +  and encoded to convert them between character arrays and JavaScript strings.
    +
    +* other RTS primitive types are discussed previously in `JavaScript FFI Types`_.
    +
    +As an example, let's consider the implementation of ``getcwd``:
    +
    +.. code-block:: haskell
    +
    +  -- unix:System.Posix.Directory
    +
    +  foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar)
    +
    +.. code-block:: javascript
    +
    +  // libraries/base/jsbits/base.js
    +
    +  //#OPTIONS: CPP
    +
    +  function h$getcwd(buf, off, buf_size) {
    +    try {
    +      var cwd = h$encodeUtf8(process.cwd());
    +      if (buf_size < cwd.len && buf_size !== 0) {
    +        h$setErrno("ERANGE");
    +        RETURN_UBX_TUP2(null, 0);
    +      } else if (buf !== null) {
    +        h$copyMutableByteArray(cwd, 0, buf, off, cwd.len);
    +        RETURN_UBX_TUP2(buf, off);
    +      } else if (buf_size === 0) {
    +        RETURN_UBX_TUP2(cwd, 0);
    +      } else {
    +        var out = h$newByteArray(buf_size);
    +        h$copyMutableByteArray(cwd, 0, out, off, cwd.len);
    +      }
    +    } catch (e) {
    +      h$setErrno(e);
    +      RETURN_UBX_TUP2(null, 0);
    +    }
    +  }
    +
    +Here, the C function ``getcwd`` maps to the JavaScript function ``h$getcwd``, which
    +exists in a ``.js`` file within ``base``'s ``jsbits`` subdirectory. ``h$getcwd``
    +expects a ``CString`` (passed as the equivalent ``Ptr CChar``) and a
    +``CSize`` argument. This results in three arguments to the JavaScript function - two
    +for the string's pointer and offset, and one for the size, which will be passed as a
    +JavaScript number.
    +
    +Next, the JavaScript ``h$getcwd`` function demonstrates several details:
    +
    +* In the try clause, the ``cwd`` value is first accessed using a NodeJS-provided method.
    +  This value is immediately encoded using ``h$encodeUtf8``, which is provided by the
    +  JavaScript backend. This function will only return the pointer for the encoded value,
    +  and the offset will always be 0
    +
    +* Next, we select one of several cases - based on the specification of the C function
    +  that we're trying to immitate
    +
    +* In the first case where the given buffer size is too small, but not zero, the function
    +  must set the ``ERANGE`` error code, which we do here with ``h$setErrno``, and return
    +  ``null``. As we saw in the function arguments, pointers are passed as a ``(ptr, offset)``
    +  pair - meaning ``null`` is represented by returning the unboxed pair ``(null, 0)``
    +
    +* In the second case where there is enough space in ``buf`` to successfully copy the
    +  bytes, we do so using ``h$copyMutableByteArray`` - a function supplied by GHC's JavaScript
    +  RTS
    +
    +* In the third case where ``buf_size`` is 0, this indicates in the C function's specification
    +  that we can allocate a new buffer of the appropriate size to return. We already have
    +  this in the form of the previously encoded ``cwd``, so we can just return it, along
    +  with the 0 offset
    +
    +* In the last case where ``buf`` is null, and ``buf_size`` is large enough, we allocate a
    +  new buffer, this time with ``buf_size`` bytes of space using ``h$newByteArray``, and
    +  we again perform a mutable copy
    +
    +* To use C preprocessor macros in linked JavaScript files, the file must open with the
    +  ``//#OPTIONS: CPP`` line, as is shown towards the start of this snippet
    +
    +* If an error occurs, the catch clause will pass it to ``h$setErrno`` and return the
    +  ``(null, 0)`` pointer and offset pair - which is a behaviour expected by the C function
    +  in the error case.
    +
    +Writing JavaScript Functions to be NodeJS and Browser Aware
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +
    +In the above example of implementing ``getcwd``, the function we use in the JavaScript
    +implementation is from NodeJS, and the behaviour doesn't make sense to implement in a
    +browser. Therefore, the actual implementation will include a C preprocessor condition
    +to check if we're compiling for the browser, in which case ``h$unsupported(-1)`` will
    +be called. There can be multiple non-browser JavaScript runtimes, so we'll also have
    +to check at runtime to make sure that NodeJS is in use.
    +
    +.. code-block:: javascript
    +
    +  function h$getcwd(buf, off, buf_size) {
    +  #ifndef GHCJS_BROWSER
    +    if (h$isNode()) {
    +      try {
    +        var cwd = h$encodeUtf8(process.cwd());
    +        if (buf_size < cwd.len && buf_size !== 0) {
    +          h$setErrno("ERANGE");
    +          return (null, 0);
    +        } else if (buf !== null) {
    +          h$copyMutableByteArray(cwd, 0, buf, off, cwd.len);
    +          RETURN_UBX_TUP2(buf, off);
    +        } else if (buf_size === 0) {
    +          RETURN_UBX_TUP2(cwd, 0);
    +        } else {
    +          var out = h$newByteArray(buf_size);
    +          h$copyMutableByteArray(cwd, 0, out, off, cwd.len);
    +        }
    +      } catch (e) {
    +        h$setErrno(e);
    +        RETURN_UBX_TUP2(null, 0);
    +      }
    +    } else
    +  #endif
    +      h$unsupported();
    +      RETURN_UBX_TUP2(null, 0);
    +  }
    +
    +Replacing C FFI Imports with Pure Haskell and JavaScript
    +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    +
    +Instead of providing a direct JavaScript implementation for each C FFI import, we can
    +instead use the C preprocessor to conditionally remove these C imports (and possibly
    +use sites as well). Then, some combination of JavaScript FFI imports and Haskell
    +implementation can be added instead. As in the direct implementation section, any
    +linked JavaScript files should usually be in a ``if arch(javascript)`` condition in
    +the cabal file.
    +
    +As an example of a mixed Haskell and JavaScript implementation replacing a C
    +implementation, consider ``base:GHC.Clock``:
    +
    +.. code-block:: haskell
    +
    +  #if defined(javascript_HOST_ARCH)
    +  getMonotonicTimeNSec :: IO Word64
    +  getMonotonicTimeNSec = do
    +    w <- getMonotonicTimeMSec
    +    return (floor w * 1000000)
    +
    +  foreign import javascript unsafe "performance.now"
    +    getMonotonicTimeMSec :: IO Double
    +
    +  #else
    +  foreign import ccall unsafe "getMonotonicNSec"
    +    getMonotonicTimeNSec :: IO Word64
    +  #endif
    +
    +Here, the ``getMonotonicTimeNSec`` C FFI import is replaced by the JavaScript FFI
    +import ``getMonotonicTimeMSec``, which imports the standard JavaScript function
    +``performance.now``. However, because this JavaScript implementation
    +returns the time as a ``Double`` of floating point milliseconds, it must be wrapped
    +by a Haskell function to extract the integral value that's expected.
    +
    +In this case, the choice of using a mixed Haskell and JavaScript replacement
    +implementation was caused by the limitation of clocks being system calls. In a lot
    +of cases, C functions are used for similar system-level functionality. In such
    +cases, it's recommended to import the required system functions from standard
    +JavaScript libraries (or from the runtime, as was required for ``getcwd``), and
    +use Haskell wrapper functions to convert the imported functions to the appropriate
    +format.
    +
    +In other cases, C functions are used for performance. For these cases, pure-Haskell
    +implementations are the preferred first step for compatibility with the JavaScript
    +backend since it would be more future-proof against changes to the RTS data format.
    +Depending on the use case, compiler-optimised JS code might be hard to complete with
    +using hand-written JavaScript. Generally, the most likely performance gains from
    +hand-written JavaScript come from functions with data that stays as JavaScript
    +primitive types for a long time, especially strings. For this, ``JSVal`` allows
    +values to be passed between ``Haskell`` and ``JavaScript`` without a marshalling
    +penalty.
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d075924b44b281ff48760c9184a8de47a5044d4
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d075924b44b281ff48760c9184a8de47a5044d4
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 19:41:10 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Tue, 24 Oct 2023 15:41:10 -0400
    Subject: [Git][ghc/ghc][master] testsuite: increase timeout of ghc-api tests
     for wasm32
    Message-ID: <65381dd68a644_1f7b0d4e75d85447148f@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    
    
    2 changed files:
    
    - testsuite/tests/ghc-api/all.T
    - testsuite/tests/ghc-api/downsweep/all.T
    
    
    Changes:
    
    =====================================
    testsuite/tests/ghc-api/all.T
    =====================================
    @@ -1,3 +1,5 @@
    +setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
    +
     test('ghcApi', normal, compile_and_run, ['-package ghc'])
     test('T6145', js_broken(22352), makefile_test, ['T6145'])
     test('T8639_api', req_rts_linker,
    
    
    =====================================
    testsuite/tests/ghc-api/downsweep/all.T
    =====================================
    @@ -1,3 +1,5 @@
    +setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
    +
     test('PartialDownsweep',
          [ extra_run_opts('"' + config.libdir + '"')
          , ignore_stderr
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07ab5cc10d4ce8db0c3b099d8bd34da66db51b9e
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07ab5cc10d4ce8db0c3b099d8bd34da66db51b9e
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 24 22:10:33 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Tue, 24 Oct 2023 18:10:33 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Limit case width and depth
    Message-ID: <653840d8f2fdc_1f7b0d5284b94c4750a1@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    1f12a52e by Simon Peyton Jones at 2023-10-24T23:10:08+01:00
    Limit case width and depth
    
    - - - - -
    
    
    2 changed files:
    
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -646,6 +646,11 @@ exprSummary env e = go env e []
           | idArity f > length val_args
           = ArgIsLam
     
    +      | not (null val_args)
    +      = ArgIsNot []   -- Use ArgIsNot [] for args with some structure e.g. (f xs)
    +                      -- This makes the call not totally-boring, and hence makes
    +                      -- INLINE things inline (which they won't if all args are boring)
    +
           | otherwise
           = ArgNoInfo
           where
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -155,6 +155,12 @@ data UnfoldingOpts = UnfoldingOpts
        , unfoldingCaseScaling :: !Int
           -- ^ Penalize depth with 1/x
     
    +   , exprTreeCaseWidth :: !Int
    +      -- ^ Don't make ExprTrees with a case width greater than this
    +
    +   , exprTreeCaseDepth :: !Int
    +      -- ^ Don't make ExprTrees with a case depth greater than this
    +
        , unfoldingReportPrefix :: !(Maybe String)
           -- ^ Only report inlining decisions for names with this prefix
        }
    @@ -191,6 +197,9 @@ defaultUnfoldingOpts = UnfoldingOpts
     
           -- Don't filter inlining decision reports
        , unfoldingReportPrefix = Nothing
    +
    +   , exprTreeCaseWidth = 4
    +   , exprTreeCaseDepth = 4
        }
     
     -- Helpers for "GHC.Driver.Session"
    @@ -490,6 +499,12 @@ We maintain:
     
       This is IMPORTANT, because even a call like (reverse xs) would otherwise record
       a ScrutOf for `reverse` which is very silly.
    +
    +Wrinkles:
    +
    +* We must be careful about recording enormous functions, with very wide or very
    +  deep case trees. (This can happen with Generics; e.g. test T5642.)  We limit
    +  both with UnfoldingOpts, and 
     -}
     
     type ETVars = (VarSet,VarSet)  -- (avs, lvs)
    @@ -499,54 +514,83 @@ exprTree :: UnfoldingOpts -> [Var] -> CoreExpr -> ExprTree
     -- Note [Computing the size of an expression]
     
     exprTree opts args expr
    -  = go (mkVarSet args, emptyVarSet) expr
    +  = go (exprTreeCaseDepth opts) (mkVarSet args, emptyVarSet) expr
       where
    +    !max_width     = exprTreeCaseWidth opts
         !bOMB_OUT_SIZE = unfoldingCreationThreshold opts
            -- Bomb out if size gets bigger than this
            -- Forcing bOMB_OUT_SIZE early prevents repeated
            -- unboxing of the Int argument.
     
    +    ok_case :: Int -> Int -> Bool
    +    ok_case case_depth n_alts  -- Case is not too deep, nor too wide
    +      = case_depth > 0 && n_alts <= max_width
    +
         et_add     = etAdd bOMB_OUT_SIZE
         et_add_alt = etAddAlt bOMB_OUT_SIZE
     
    -    go :: ETVars -> CoreExpr -> ExprTree
    +    go :: Int -> ETVars -> CoreExpr -> ExprTree
    +          -- cd is the unused case depth; decreases toward zero
               -- (avs,lvs): see Note [Constructing an ExprTree]
    -    go vs (Cast e _)   = go vs e
    -    go vs (Tick _ e)   = go vs e
    -    go _  (Type _)     = exprTreeN 0
    -    go _  (Coercion _) = exprTreeN 0
    -    go _  (Lit lit)    = exprTreeN (litSize lit)
    -
    -    go vs (Lam b e)
    -      | isId b, not (isZeroBitId b) = go vs' e `et_add` lamSize opts
    -      | otherwise                   = go vs' e
    +    go cd vs (Cast e _)      = go cd vs e
    +    go cd vs (Tick _ e)      = go cd vs e
    +    go _  _  (Type _)        = exprTreeN 0
    +    go _  _  (Coercion _)    = exprTreeN 0
    +    go _  _  (Lit lit)       = exprTreeN (litSize lit)
    +    go cd vs (Case e b _ as) = go_case cd vs e b as
    +    go cd vs (Let bind body) = go_let cd vs bind body
    +    go cd vs (Lam b e)       = go_lam cd vs b e
    +    go cd vs e@(App {})      = go_app cd vs e
    +    go _  vs (Var f)         = callTree opts vs f [] 0
    +                               -- Use callTree to ensure we get constructor
    +                               -- discounts even on nullary constructors
    +    -------------------
    +    go_lam cd vs bndr body
    +      | isId bndr, not (isZeroBitId bndr) = go cd vs' body `et_add` lamSize opts
    +      | otherwise                         = go cd vs' body
           where
    -        vs' = vs `add_lv` b
    +        vs' = vs `add_lv` bndr
     
    -    go vs (Let (NonRec binder rhs) body)
    -      = go_bind vs (binder, rhs)  `et_add`
    -        go (vs `add_lv` binder) body
    +    -------------------
    +    go_let cd vs (NonRec binder rhs) body
    +      = go_bind cd vs (binder, rhs)  `et_add`
    +        go cd (vs `add_lv` binder) body
     
    -    go vs (Let (Rec pairs) body)
    -      = foldr (et_add . go_bind vs') (go vs' body) pairs
    +    go_let cd vs (Rec pairs) body
    +      = foldr (et_add . go_bind cd vs') (go cd vs' body) pairs
           where
             vs' = vs `add_lvs` map fst pairs
     
    -    go vs e@(App {}) = go_app vs e [] 0
    -    go vs (Var f)    = callTree opts vs f [] 0
    -                    -- Use callTree to ensure we get constructor
    -                    -- discounts even on nullary constructors
    -
    -    go vs (Case e b _ alts) = go_case vs e b alts
    +    -------------------
    +    go_app cd vs e = lgo e [] 0
    +      where
    +         lgo :: CoreExpr -> [CoreExpr] -> Int -> ExprTree
    +             -- args:  all the value args
    +             -- voids: counts the zero-bit arguments; don't charge for these
    +             --        This makes a difference in ST-heavy code which does a lot
    +             --        of state passing, and which can be in an inner loop.
    +         lgo (App fun arg) args voids
    +                    | isTypeArg arg    = lgo fun args voids
    +                    | isZeroBitArg arg = lgo fun (arg:args) (voids+1)
    +                    | otherwise        = go cd vs arg `et_add`
    +                                         lgo fun (arg:args) voids
    +         lgo (Var fun)     args voids  = callTree opts vs fun args voids
    +         lgo (Tick _ expr) args voids  = lgo expr args voids
    +         lgo (Cast expr _) args voids  = lgo expr args voids
    +         lgo other         args voids  = vanillaCallSize (length args) voids
    +                                         `etAddN` go cd vs other
    +         -- if the lhs is not an App or a Var, or an invisible thing like a
    +         -- Tick or Cast, then we should charge for a complete call plus the
    +         -- size of the lhs itself.
     
         -----------------------------
    -    go_bind vs (bndr, rhs)
    +    go_bind cd vs (bndr, rhs)
           | JoinPoint join_arity <- idJoinPointHood bndr
           , (bndrs, body) <- collectNBinders join_arity rhs
                               -- Skip arguments to join point
    -      = go (vs `add_lvs` bndrs) body
    +      = go cd (vs `add_lvs` bndrs) body
           | otherwise
    -      = size_up_alloc bndr `etAddN` go vs rhs
    +      = size_up_alloc bndr `etAddN` go cd vs rhs
     
         -- Cost to allocate binding with given binder
         size_up_alloc bndr
    @@ -558,42 +602,25 @@ exprTree opts args expr
           = 10
     
         -----------------------------
    -    -- size_up_app is used when there's ONE OR MORE value args
    -    go_app :: ETVars -> CoreExpr -> [CoreExpr] -> Int -> ExprTree
    -        -- args:  all the value args
    -        -- voids: counts the zero-bit arguments; don't charge for these
    -        --        This makes a difference in ST-heavy code which does
    -        --        does a lot of state passing, and which can be in an
    -        --        inner loop.
    -    go_app vs (App fun arg) args voids
    -                  | isTypeArg arg      = go_app vs fun args voids
    -                  | isZeroBitArg arg   = go_app vs fun (arg:args) (voids+1)
    -                  | otherwise          = go vs arg `et_add`
    -                                         go_app vs fun (arg:args) voids
    -    go_app vs (Var fun)     args voids = callTree opts vs fun args voids
    -    go_app vs (Tick _ expr) args voids = go_app vs expr args voids
    -    go_app vs (Cast expr _) args voids = go_app vs expr args voids
    -    go_app vs other         args voids = vanillaCallSize (length args) voids `etAddN`
    -                                         go vs other
    -       -- if the lhs is not an App or a Var, or an invisible thing like a
    -       -- Tick or Cast, then we should charge for a complete call plus the
    -       -- size of the lhs itself.
    -
    -    -----------------------------
    +    go_case :: Int -> ETVars -> CoreExpr -> Id -> [CoreAlt] -> ExprTree
         -- Empty case
    -    go_case vs scrut _ [] = go vs scrut
    +    go_case cd vs scrut _ [] = go cd vs scrut
              -- case e of {} never returns, so take size of scrutinee
     
         -- Record a CaseOf
    -    go_case vs@(avs,lvs) scrut b alts                 -- Now alts is non-empty
    +    go_case cd vs@(avs,lvs) scrut b alts
           | Just v <- recordCaseOf vs scrut
    -      = -- pprTrace "recordCaseOf" (ppr v $$ ppr lvs $$ ppr scrut $$ ppr alts) $
    -        go vs scrut `et_add`
    -        etOneCase (CaseOf v b (map (alt_alt_tree v) alts))
    +      = go cd vs scrut `et_add`
    +        (if   ok_case cd n_alts
    +         then etOneCase (CaseOf v b (map (alt_alt_tree v) alts))
    +         else etOneCase (ScrutOf v (10 * n_alts)) `et_add`
    +              go_alts cd vs b alts)
           where
    +        cd1 = cd - 1
    +        n_alts = length alts
             alt_alt_tree :: Id -> Alt Var -> AltTree
             alt_alt_tree v (Alt con bs rhs)
    -          = AltTree con val_bs (10 `etAddN` go (add_alt_bndrs v val_bs) rhs)
    +          = AltTree con val_bs (10 `etAddN` go cd1 (add_alt_bndrs v val_bs) rhs)
               where
                 val_bs = filter isId bs
     
    @@ -603,14 +630,18 @@ exprTree opts args expr
               | otherwise = vs
     
         -- Don't record a CaseOf
    -    go_case vs scrut b alts    -- alts is non-empty
    +    go_case cd vs scrut b alts    -- alts is non-empty
           = caseSize scrut alts `etAddN`   -- A bit odd that this is only in one branch
    -        go vs scrut         `et_add`
    -        foldr1 et_add_alt (map alt_expr_tree alts)
    +        go cd vs scrut      `et_add`
    +        go_alts cd vs b alts
    +
    +    go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> ExprTree
    +    go_alts cd vs b alts = foldr1 et_add_alt (map alt_expr_tree alts)
           where
    +        cd1 = cd - 1
             alt_expr_tree :: Alt Var -> ExprTree
             alt_expr_tree (Alt _con bs rhs)
    -          = 10 `etAddN` go (vs `add_lvs` (b:bs)) rhs
    +          = 10 `etAddN` go cd1 (vs `add_lvs` (b:bs)) rhs
                 -- Don't charge for bndrs, so that wrappers look cheap
                 -- (See comments about wrappers with Case)
                 -- Don't forget to add the case binder, b, to lvs.
    @@ -773,13 +804,13 @@ lamSize opts = SizeIs { et_size = 10, et_cases = emptyBag
     conSize :: DataCon -> Int -> ExprTree
     -- Does not need to include the size of the arguments themselves
     conSize dc n_val_args
    -  = SizeIs { et_size = n, et_cases = emptyBag, et_ret = n }
    +  | isUnboxedTupleDataCon dc
    +  = etZero     -- See Note [Unboxed tuple size and result discount]
    +  | otherwise  -- See Note [Constructor size and result discount]
    +  = SizeIs { et_size = size, et_cases = emptyBag, et_ret = 10 }
       where
    -    n | n_val_args == 0 = 0   -- Like variables
    -      | unboxed_tuple   = 0   -- See Note [Unboxed tuple size and result discount]
    -      | otherwise       = 10  -- See Note [Constructor size and result discount]
    -
    -    unboxed_tuple = isUnboxedTupleDataCon dc
    +    size | n_val_args == 0 = 0  -- Like variables
    +         | otherwise       = 10
     
     primOpSize :: PrimOp -> Int -> Int
     primOpSize op n_val_args
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f12a52edf520f7f6776daad02dd72daf562fa6b
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f12a52edf520f7f6776daad02dd72daf562fa6b
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Wed Oct 25 16:04:43 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Wed, 25 Oct 2023 12:04:43 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/T24056
    Message-ID: <65393c9b9eccf_1f7b0d6a98d6d053455d@gitlab.mail>
    
    
    
    Ben Gamari pushed new branch wip/T24056 at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24056
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Wed Oct 25 16:05:34 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Wed, 25 Oct 2023 12:05:34 -0400
    Subject: [Git][ghc/ghc][wip/T24056] gitlab-ci: Bump LLVM bootstrap jobs to
     Debian 12
    Message-ID: <65393cce1ca8b_1f7b0d6abbdcac534782@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/T24056 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    cb5ac6ae by Ben Gamari at 2023-10-25T12:05:20-04:00
    gitlab-ci: Bump LLVM bootstrap jobs to Debian 12
    
    As the Debian 10 images have too old an LLVM.
    
    Addresses #24056.
    
    - - - - -
    
    
    2 changed files:
    
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    
    
    Changes:
    
    =====================================
    .gitlab/generate-ci/gen_ci.hs
    =====================================
    @@ -979,7 +979,7 @@ job_groups =
          , -- Nightly allowed to fail: #22343
            modifyNightlyJobs allowFailure
             (modifyValidateJobs manual (validateBuilds Amd64 (Linux Debian10) noTntc))
    -     , onlyRule LLVMBackend (validateBuilds Amd64 (Linux Debian10) llvm)
    +     , onlyRule LLVMBackend (validateBuilds Amd64 (Linux Debian12) llvm)
          , disableValidate (standardBuilds Amd64 (Linux Debian11))
          , disableValidate (standardBuilds Amd64 (Linux Debian12))
          -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
    @@ -1003,7 +1003,7 @@ job_groups =
          , fastCI (standardBuilds AArch64 Darwin)
          , fastCI (standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla))
          , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian11) (splitSectionsBroken vanilla))
    -     , disableValidate (validateBuilds AArch64 (Linux Debian10) llvm)
    +     , disableValidate (validateBuilds AArch64 (Linux Debian12) llvm)
          , standardBuildsWithConfig I386 (Linux Debian10) (splitSectionsBroken vanilla)
          -- Fully static build, in theory usable on any linux distribution.
          , fullyStaticBrokenTests (standardBuildsWithConfig Amd64 (Linux Alpine312) (splitSectionsBroken static))
    
    
    =====================================
    .gitlab/jobs.yaml
    =====================================
    @@ -380,7 +380,7 @@
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-aarch64-linux-deb10-validate+llvm": {
    +  "nightly-aarch64-linux-deb11-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -391,7 +391,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-aarch64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-aarch64-linux-deb11-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -401,14 +401,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "aarch64-linux-deb10-$CACHE_REV",
    +      "key": "aarch64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -434,15 +434,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-aarch64-linux-deb11-validate",
    +      "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "aarch64-linux-deb10-validate+llvm",
    +      "TEST_ENV": "aarch64-linux-deb11-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-aarch64-linux-deb11-validate": {
    +  "nightly-aarch64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -453,7 +453,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-aarch64-linux-deb11-validate.tar.xz",
    +        "ghc-aarch64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -463,14 +463,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "aarch64-linux-deb11-$CACHE_REV",
    +      "key": "aarch64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -496,11 +496,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-aarch64-linux-deb11-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "aarch64-linux-deb11-validate",
    +      "TEST_ENV": "aarch64-linux-deb12-validate+llvm",
           "XZ_OPT": "-9"
         }
       },
    @@ -1523,18 +1523,18 @@
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-validate+llvm": {
    +  "nightly-x86_64-linux-deb10-validate+thread_sanitizer": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
           ".gitlab/ci.sh clean",
           "cat ci_timings"
         ],
    -    "allow_failure": false,
    +    "allow_failure": true,
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1577,26 +1577,28 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    +      "BUILD_FLAVOUR": "validate+thread_sanitizer",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "HADRIAN_ARGS": "--docs=none",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+llvm",
    +      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    +      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-validate+thread_sanitizer": {
    +  "nightly-x86_64-linux-deb10-zstd-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
           ".gitlab/ci.sh clean",
           "cat ci_timings"
         ],
    -    "allow_failure": true,
    +    "allow_failure": false,
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
    +        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1639,17 +1641,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    -      "BUILD_FLAVOUR": "validate+thread_sanitizer",
    -      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "HADRIAN_ARGS": "--docs=none",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BUILD_FLAVOUR": "validate",
    +      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    -      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions",
    +      "TEST_ENV": "x86_64-linux-deb10-zstd-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-zstd-validate": {
    +  "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1660,7 +1660,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1670,14 +1670,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb10-$CACHE_REV",
    +      "key": "x86_64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -1703,15 +1703,17 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
    +      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    +      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    +      "CROSS_TARGET": "aarch64-linux-gnu",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-zstd-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
    +  "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1722,7 +1724,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1764,18 +1766,19 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "BIGNUM_BACKEND": "native",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    -      "CROSS_TARGET": "aarch64-linux-gnu",
    +      "CONFIGURE_WRAPPER": "emconfigure",
    +      "CROSS_EMULATOR": "js-emulator",
    +      "CROSS_TARGET": "javascript-unknown-ghcjs",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
    +  "nightly-x86_64-linux-deb11-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1786,7 +1789,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1828,19 +1831,16 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "native",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    +      "BIGNUM_BACKEND": "gmp",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CONFIGURE_WRAPPER": "emconfigure",
    -      "CROSS_EMULATOR": "js-emulator",
    -      "CROSS_TARGET": "javascript-unknown-ghcjs",
    +      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-validate": {
    +  "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1851,7 +1851,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1894,15 +1894,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-validate",
    +      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    +      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": {
    +  "nightly-x86_64-linux-deb12-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1913,7 +1913,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1923,14 +1923,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb11-$CACHE_REV",
    +      "key": "x86_64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -1956,15 +1956,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    -      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate",
    +      "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    -      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "RUNTEST_ARGS": "",
    +      "TEST_ENV": "x86_64-linux-deb12-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb12-validate": {
    +  "nightly-x86_64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1975,7 +1975,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb12-validate.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -2018,11 +2018,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb12-validate",
    +      "TEST_ENV": "x86_64-linux-deb12-validate+llvm",
           "XZ_OPT": "-9"
         }
       },
    @@ -4969,7 +4969,7 @@
           "TEST_ENV": "x86_64-linux-deb10-validate+debug_info"
         }
       },
    -  "x86_64-linux-deb10-validate+llvm": {
    +  "x86_64-linux-deb10-validate+thread_sanitizer": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -4980,7 +4980,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5006,8 +5006,9 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    -        "when": "on_success"
    +        "allow_failure": true,
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "when": "manual"
           }
         ],
         "script": [
    @@ -5023,14 +5024,16 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    +      "BUILD_FLAVOUR": "validate+thread_sanitizer",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "HADRIAN_ARGS": "--docs=none",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+llvm"
    +      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    +      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
         }
       },
    -  "x86_64-linux-deb10-validate+thread_sanitizer": {
    +  "x86_64-linux-deb10-zstd-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5041,7 +5044,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
    +        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5067,9 +5070,8 @@
         ],
         "rules": [
           {
    -        "allow_failure": true,
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    -        "when": "manual"
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "when": "on_success"
           }
         ],
         "script": [
    @@ -5085,16 +5087,14 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    -      "BUILD_FLAVOUR": "validate+thread_sanitizer",
    -      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "HADRIAN_ARGS": "--docs=none",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BUILD_FLAVOUR": "validate",
    +      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    -      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
    +      "TEST_ENV": "x86_64-linux-deb10-zstd-validate"
         }
       },
    -  "x86_64-linux-deb10-zstd-validate": {
    +  "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5105,7 +5105,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5115,14 +5115,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb10-$CACHE_REV",
    +      "key": "x86_64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -5131,7 +5131,7 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5148,14 +5148,16 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
    +      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    +      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    +      "CROSS_TARGET": "aarch64-linux-gnu",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-zstd-validate"
    +      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
         }
       },
    -  "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
    +  "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5166,7 +5168,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5192,7 +5194,7 @@
         ],
         "rules": [
           {
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5208,17 +5210,18 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "BIGNUM_BACKEND": "native",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    -      "CROSS_TARGET": "aarch64-linux-gnu",
    +      "CONFIGURE_WRAPPER": "emconfigure",
    +      "CROSS_EMULATOR": "js-emulator",
    +      "CROSS_TARGET": "javascript-unknown-ghcjs",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
    +      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate"
         }
       },
    -  "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
    +  "x86_64-linux-deb11-validate+boot_nonmoving_gc": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5229,7 +5232,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5255,7 +5258,7 @@
         ],
         "rules": [
           {
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5271,18 +5274,15 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "native",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    -      "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CONFIGURE_WRAPPER": "emconfigure",
    -      "CROSS_EMULATOR": "js-emulator",
    -      "CROSS_TARGET": "javascript-unknown-ghcjs",
    -      "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate"
    +      "BIGNUM_BACKEND": "gmp",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    +      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc"
         }
       },
    -  "x86_64-linux-deb11-validate+boot_nonmoving_gc": {
    +  "x86_64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5293,7 +5293,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5303,14 +5303,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb11-$CACHE_REV",
    +      "key": "x86_64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -5319,7 +5319,7 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5336,11 +5336,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    -      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    -      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc"
    +      "RUNTEST_ARGS": "",
    +      "TEST_ENV": "x86_64-linux-deb12-validate+llvm"
         }
       },
       "x86_64-linux-fedora33-release": {
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb5ac6ae60504df2a477ffe1440cca1ee33dbe70
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb5ac6ae60504df2a477ffe1440cca1ee33dbe70
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Wed Oct 25 19:33:24 2023
    From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz))
    Date: Wed, 25 Oct 2023 15:33:24 -0400
    Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve-2023-07-15] 101 commits:
     Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.
    Message-ID: <65396d842538_1f7b0d6f988bd0557457@gitlab.mail>
    
    
    
    Alan Zimmerman pushed to branch wip/az/locateda-epa-improve-2023-07-15 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00
    Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.
    
    The motivation for the flag is given in #21917.
    
    - - - - -
    3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Add ghcToolchain to tool args list
    
    This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.
    
    - - - - -
    476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Normalise triple via config.sub
    
    We were not normalising the target triple anymore like we did with the
    old make build system.
    
    Fixes #23856
    
    - - - - -
    303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add missing vendor normalisation
    
    This is copied from m4/ghc_convert_vendor.m4
    
    Towards #23868
    
    - - - - -
    838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add loongarch64 to parseArch
    
    Towards #23868
    
    - - - - -
    1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Add same LD hack to ghc-toolchain
    
    In the ./configure script, if you pass the `LD` variable then this has
    the effect of stopping use searching for a linker and hence passing
    `-fuse-ld=...`.
    
    We want to emulate this logic in ghc-toolchain, if a use explicilty
    specifies `LD` variable then don't add `-fuse-ld=..` with the goal of
    making ./configure and ghc-toolchain agree on which flags to use when
    using the C compiler as a linker.
    
    This is quite unsavoury as we don't bake the choice of LD into the
    configuration anywhere but what's important for now is making
    ghc-toolchain and ./configure agree as much as possible.
    
    See #23857 for more discussion
    
    - - - - -
    42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check for C99 support with -std=c99
    
    Previously we failed to try enabling C99 support with `-std=c99`, as
    `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which
    don't enable C99 by default.
    
    Fixes #23879.
    
    - - - - -
    da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro
    
    In very old toolchains the BYTE_ORDER macro is not set but thankfully
    the __BYTE_ORDER__ macro can be used instead.
    
    - - - - -
    d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: AC_PATH_TARGET_TOOL for LD
    
    We want to make sure that LD is set to an absolute path in order to be
    consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL
    macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which
    might use a relative path.
    
    - - - - -
    171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check whether we need -std=gnu99 for CPP as well
    
    In ./configure the C99 flag is passed to the C compiler when used as a C
    preprocessor. So we also check the same thing in ghc-toolchain.
    
    - - - - -
    89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Check for --target linker flag separately to C compiler
    
    There are situations where the C compiler doesn't accept `--target` but
    when used as a linker it does (but doesn't do anything most likely)
    
    In particular with old gcc toolchains, the C compiler doesn't support
    --target but when used as a linker it does.
    
    - - - - -
    37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Use Cc to compile test file in nopie check
    
    We were attempting to use the C compiler, as a linker, to compile a file
    in the nopie check, but that won't work in general as the flags we pass
    to the linker might not be compatible with the ones we pass when using
    the C compiler.
    
    - - - - -
    9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Error when ghc-toolchain fails to compile
    
    This is a small QOL change as if you are working on ghc-toolchain and it
    fails to compile then configure will continue and can give you outdated
    results.
    
    - - - - -
    1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Check whether -no-pie works when the C compiler is used as a linker
    
    `-no-pie` is a flag we pass when using the C compiler as a linker (see
    pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
    compiler used as a linker supports the flag, rather than just the C
    compiler.
    
    - - - - -
    62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Remove javascript special case for --target detection
    
    emcc when used as a linker seems to ignore the --target flag, and for
    consistency with configure which now tests for --target, we remove this
    special case.
    
    - - - - -
    0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00
    toolchain: Don't pass --target to emscripten toolchain
    
    As noted in `Note [Don't pass --target to emscripten toolchain]`,
    emscripten's `emcc` is rather inconsistent with respect to its treatment
    of the `--target` flag. Avoid this by special-casing this toolchain
    in the `configure` script and `ghc-toolchain`.
    
    Fixes on aspect of #23744.
    
    - - - - -
    6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure
    
    Stop passing -gcc-options which mixed together linker flags and
    non-linker flags. There's no guarantee the C compiler will accept both
    of these in each mode.
    
    - - - - -
    c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00
    configure: Probe stage0 link flags
    
    For consistency with later stages and CC.
    
    - - - - -
    1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00
    Stricter Binary.get in GHC.Types.Unit (#23964)
    
    I noticed some thunking while looking at Core.
    This change has very modest, but throughout positive ghc/alloc effect:
    
    ```
     hard_hole_fits(normal) ghc/alloc    283,057,664    281,620,872  -0.5%
    
                  geo. mean                                          -0.1%
                  minimum                                            -0.5%
                  maximum                                            +0.0%
    ```
    
    Fixes #23964.
    
    - - - - -
    a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00
    rel_eng/upload.sh cleanups
    
    - - - - -
    80705335 by doyougnu at 2023-10-10T19:03:18-04:00
    ci: add javascript label rule
    
    This adds a rule which triggers the javascript job when the "javascript"
    label is assigned to an MR.
    
    - - - - -
    a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00
    Make 'wWarningFlagsDeps' include every WarningFlag
    
    Fixes #24071.
    
    - - - - -
    d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00
    Fix pretty printing of overlap pragmas in TH splices (fixes #24074)
    
    - - - - -
    0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    AArch NCG: Refactor getRegister'
    
    Remove some special cases which can be handled just as well by the
    generic case.
    
    This increases code re-use while also fixing #23749. Since some of the
    special case wasn't upholding Note [Signed arithmetic on AArch64].
    
    - - - - -
    1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over mem management checks
    
    These are for heap allocation, a strictly RTS concern.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    The RTS configure one has a new
    ```
    AC_CHECK_SIZEOF([void *])
    ```
    that the top-level configure version didn't have, so that
    `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
    commits, that can go away.
    
    Progress towards #17191
    
    - - - - -
    41130a65 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `__thread` check
    
    This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over misc function checks
    
    These are for general use in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `eventfd` check
    
    This check is for the RTS part of the event manager and has a
    corresponding part in `base`.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    58f3babf by John Ericson at 2023-10-11T16:02:48-04:00
    Split `FP_CHECK_PTHREADS` and move part to RTS configure
    
    `NEED_PTHREAD_LIB` is unused since
    3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
    system), and so is no longer defined.
    
    Progress towards #17191
    
    - - - - -
    e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00
    nativeGen: section flags for .text$foo only
    
    Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
    #22834 in !9810.
    
    It does however add "xr" indiscriminatly to .text sections
    even if splitSections is disabled. This leads to the assembler saying:
    
    ghc_1.s:7849:0: error:
         Warning: Ignoring changed section attributes for .text
         |
    7849 | .section .text,"xr"
         | ^
    
    - - - - -
    f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00
    Modularity: pass TempDir instead of DynFlags (#17957)
    
    - - - - -
    34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00
    Test that functions from `mingwex` are available
    
    Ryan wrote these two minimizations, but they never got added to the test
    suite.
    
    See #23309, #23378
    
    Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com>
    Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com>
    
    - - - - -
    bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00
    Do not check for the `mingwex` library in `/configure`
    
    See the recent discussion in !10360 --- Cabal will itself check for the
    library for the packages that need it, and while the autoconf check
    additionally does some other things like define a `HAS_LIBMINGWEX` C
    Preprocessor macro, those other things are also unused and unneeded.
    
    Progress towards #17191, which aims to get rid of `/configure` entirely.
    
    - - - - -
    43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00
    base: Introduce move modules into src
    
    The only non-move changes here are whitespace changes to pass the
    `whitespace` test and a few testsuite adaptations.
    
    - - - - -
    df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00
    [PEi386 linker] Bounds check and null-deref guard
    
    We should resonably be able to expect that we won't exceed the number of
    sections if we assume to be dealing with legal object files. We can however
    not guarantee that we get some negative values, and while we try to
    special case most, we should exclude negative indexing into the sections
    array.
    
    We also need to ensure that we do not try to derefences targetSection,
    if it is NULL, due to the switch statement.
    
    - - - - -
    c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
    Move apple compat check to RTS configure
    
    - - - - -
    c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
    Move clock/timer fun checks to RTS configure
    
    Actual library check (which will set the Cabal flag) is left in the
    top-level configure for now.
    
    Progress towards #17191
    
    - - - - -
    7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
    Move visibility and "musttail" annotation checks to the RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
    Move leading underscore checks to RTS configure
    
    `CabalLeadingUnderscore` is done via Hadrian already, so we can stop
    `AC_SUBST`ing it completely.
    
    - - - - -
    25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
    Move alloca, fork, const, and big endian checks to RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    - - - - -
    5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
    Move libdl check to RTS configure
    
    - - - - -
    ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
    Adjust `FP_FIND_LIBFFI`
    
    Just set vars, and `AC_SUBST` in top-level configure.
    
    Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
    be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
    make build system).
    
    - - - - -
    f399812c by John Ericson at 2023-10-12T10:31:13-04:00
    Split BFD support to RTS configure
    
    The flag is still in the top-level configure, but the other checks
    (which define various macros --- important) are in the RTS configure.
    
    - - - - -
    f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
    Split libm check between top level and RTS
    
    - - - - -
    dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
    CgUtils.fixStgRegStmt respect register width
    
    This change ensure that the reg + offset computation is always of the
    same size.  Before this we could end up with a 64bit register, and then
    add a 32bit offset (on 32bit platforms).  This not only would fail type
    sanity checking, but also incorrectly truncate 64bit values into 32bit
    values silently on 32bit architectures.
    
    - - - - -
    9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00
    Fix restarts in .ghcid
    
    Using the whole of `hadrian/` restarted in a loop for me.
    
    - - - - -
    fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    NoFib results (omitted = 0.0%):
    ```
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             pretty           0.0%     -1.6%
                scc           0.0%     -1.7%
    --------------------------------------------------------------------------------
                Min           0.0%     -1.7%
                Max           0.0%     -0.0%
     Geometric Mean          -0.0%     -0.0%
    ```
    
    - - - - -
    32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00
    hadrian: Move ghcBinDeps into ghcLibDeps
    
    This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the
    `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc`
    library so need to make sure they are present in the libdir even if we
    are not going to build `ghc-bin`.
    
    This also fixes things for cross compilers because the stage2
    cross-compiler requires the ghc-usage.txt file, but we are using
    the stage2 lib folder but not building stage3:exe:ghc-bin so
    ghc-usage.txt was not being generated.
    
    - - - - -
    ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00
    Combine GREs when combining in mkImportOccEnv
    
    In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import
    item in favour of another, as explained in Note [Dealing with imports]
    in `GHC.Rename.Names`. However, this can cause us to lose track of
    important parent information.
    
    Consider for example #24084:
    
      module M1 where { class C a where { type T a } }
      module M2 ( module M1 ) where { import M1 }
      module M3 where { import M2 ( C, T ); instance C () where T () = () }
    
    When processing the import list of `M3`, we start off (for reasons that
    are not relevant right now) with two `Avail`s attached to `T`, namely
    `C(C, T)` and `T(T)`. We combine them in the `combine` function of
    `mkImportOccEnv`; as described in Note [Dealing with imports] we discard
    `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not**
    discard the information want that `C` is the parent of `T`. Indeed,
    losing track of this information can cause errors when importing,
    as we could get an error of the form
    
      ‘T’ is not a (visible) associated type of class ‘C’
    
    We fix this by combining the two GREs for `T` using `plusGRE`.
    
    Fixes #24084
    
    - - - - -
    257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00
    hadrian: Pass -DNOSMP to C compiler when needed
    
    Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
    SMP, but doesn't pass it to CC as well, leading to the following
    compilation error on mips64el:
    
    | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
    Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
    ===> Command failed with error code: 1
    In file included from rts/include/Stg.h:348,
                     from rts/include/Rts.h:38,
                     from rts/hooks/FlagDefaults.c:8:
    rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
      416 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
      440 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
      464 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    
    The old make system correctly passed this flag to both GHC and CC [1].
    
    Fix this error by passing -DNOSMP to CC as well.
    
    [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
    
    Closes #24082
    
    - - - - -
    13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00
    Users Guide: Drop dead code for Haddock refs to `parallel`
    
    I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was
    not substituted. It is dead code -- there is no `parallel-ref` usages
    and it doesn't look like there ever was (going back to
    3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it.
    
    - - - - -
    fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)
    
    bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".
    
    - - - - -
    cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Bignum: fix right shift of negative BigNat with native backend
    
    - - - - -
    cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Rts: expose rtsOutOfBoundsAccess symbol
    
    - - - - -
    72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Hadrian: enable `-fcheck-prim-bounds` in validate flavour
    
    This allows T24066 to fail when the bug is present.
    
    Otherwise the out-of-bound access isn't detected as it happens in
    ghc-bignum which wasn't compiled with the bounds check.
    
    - - - - -
    f9436990 by John Ericson at 2023-10-18T19:41:01-04:00
    Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in`
    
    Fixes #24091
    Progress on #23966
    
    Issue #24091 reports that `@ProjectVersion@` is no longer being
    substituted in the GHC user's guide. I assume this is a recent issue,
    but I am not sure how it's worked since
    c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and
    configure are trying to substitute the same `.in` file!
    
    Now only Hadrian does. That is better anyways; already something that
    issue #23966 requested.
    
    It seems like we were missing some dependencies in Hadrian. (I really,
    really hate that this is possible!) Hopefully it is fixed now.
    
    - - - - -
    b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00
    `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`
    
    Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
    be defined. (Guaranteed including a test in the testsuite.)
    
    - - - - -
    0295375a by John Ericson at 2023-10-18T19:41:37-04:00
    Generate `ghcversion.h` from a `.in` file
    
    Now that there are no conditional sections (see the previous commit), we
    can just a do simple substitution rather than pasting it together line
    by line.
    
    Progress on #23966
    
    - - - - -
    740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00
    Add a regression test for #24064
    
    - - - - -
    921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00
    CLC Proposal #182: Export List from Data.List
    
    Proposal link: https://github.com/haskell/core-libraries-committee/issues/182
    
    - - - - -
    4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
    rts: fix small argument passing on big-endian arch (fix #23387)
    
    - - - - -
    b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
    Interpreter: fix literal alignment on big-endian architectures (fix #19261)
    
    Literals weren't correctly aligned on big-endian, despite what the
    comment said.
    
    - - - - -
    a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
    Testsuite: recomp011 and recomp015 are fixed on powerpc
    
    These tests have been fixed but not tested and re-enabled on big-endian
    powerpc (see comments in #11260 and #11323)
    
    - - - - -
    fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
    CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
    - - - - -
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    f72eabb7 by Alan Zimmerman at 2023-10-23T20:17:57+01:00
    EPA: print doc comments as normal comments
    
    And ignore the ones allocated in haddock processing.
    
    It does not guarantee that every original haddock-like comment appears
    in the output, as it discards ones that have no legal attachment point.
    
    closes #23459
    
    - - - - -
    8b0e7549 by Alan Zimmerman at 2023-10-24T18:08:54+01:00
    EPA: Use full range for Anchor
    
    EPA: Use the current Anchor end as prior end
    
    Use the original anchor location end as the source of truth for
    calculating print deltas.
    
    This allows original spacing to apply in most cases, only changed AST
    items need initial delta positions.
    
    EPA: Add DArrow to TrailingAnn
    
    [EPA] Introduce HasTrailing in ExactPrint
    
    EPA use [TrailingAnn] in enterAnn
    
    And remove it from ExactPrint (LocatedN RdrName)
    
    EPA: In HsDo, put TrailingAnns at top of LastStmt
    
    EPA: do not convert comments to deltas when balancing.
    
    EPA: deal with fallout from getMonoBind
    
    EPA fix captureLineSpacing
    
    EPA print any comments in the span before exiting it
    EPA: getting rid of tweakDelta
    
    EPA: Add comments to AnchorOperation
    
    EPA: remove AnnEofComment
    
    It is no longer used
    
    - - - - -
    9076c2fd by Alan Zimmerman at 2023-10-25T19:35:53+01:00
    EPA: make locA a function, not a field name
    
    - - - - -
    86e7b42f by Alan Zimmerman at 2023-10-25T19:35:53+01:00
    EPA: generalise reLoc
    
    [2023-10-01 Sun]
    Failures
       HsDocTy
    
    - - - - -
    bbdba926 by Alan Zimmerman at 2023-10-25T19:35:53+01:00
    EPA: get rid of l2l and friends
    
    - - - - -
    7a9b4f40 by Alan Zimmerman at 2023-10-25T19:35:53+01:00
    EPA: get rid of l2l and friends
    
    - - - - -
    43811c41 by Alan Zimmerman at 2023-10-25T19:35:53+01:00
    EPA: harmonise acsa and acsA
    
    [2023-10-01 Sun]
    Failing tests
      HsDocTy
    
    - - - - -
    51700672 by Alan Zimmerman at 2023-10-25T19:35:54+01:00
    EPA: Replace Anchor with EpaLocation
    
    [2023-09-21 Thu]
    Only test failing is
       HsDocTy
    
    - - - - -
    728f196f by Alan Zimmerman at 2023-10-25T19:35:54+01:00
    EPA: get rid of AnchorOperation
    
    [2023-09-21 Thu]
    Only error is
      HsDocTy
    
    - - - - -
    fc4d1907 by Alan Zimmerman at 2023-10-25T19:35:54+01:00
    EPA: splitLHsForAllTyInvis no ann returned
    
    - - - - -
    8df8722d by Alan Zimmerman at 2023-10-25T19:35:54+01:00
    EPA: Replace Monoid with NoAnn
    
    [2023-08-19 Sat]
    AddClassMethod fails
    
    - - - - -
    656d4e22 by Alan Zimmerman at 2023-10-25T19:35:54+01:00
    EPA: Use SrcSpan in EpaSpan
    
    [2023-09-04 Mon]
    No errors or warnings in check-exact
    
    [2023-09-21 Thu]
    Test failures
       HsDocTy
    
    - - - - -
    0872a79a by Alan Zimmerman at 2023-10-25T19:35:54+01:00
    EPA: Present no longer has annotation
    
    - - - - -
    cc1db737 by Alan Zimmerman at 2023-10-25T19:35:54+01:00
    EPA: empty tup_tail has no ann
    
    Parser.y: tup_tail rule was
              | {- empty -} %shift   { return [Left noAnn] }
    
    This means we add an extra Missing constructor if the last item was a comma.
    
    Change the annotation type to a Bool to indicate this, and use the
    EpAnn Anchor for the print location for the others.
    
    - - - - -
    b12e16f7 by Alan Zimmerman at 2023-10-25T19:35:55+01:00
    EPA: Remove parenthesizeHsType
    
    - - - - -
    1cfdc747 by Alan Zimmerman at 2023-10-25T19:35:55+01:00
    EPA: Remove EpAnnNotUsed
    
    [2023-10-01 Sun]
    Failures
      HsDocTy
      T15242
    
    - - - - -
    a2dcb187 by Alan Zimmerman at 2023-10-25T19:35:55+01:00
    EPA: Remove SrcSpanAnn
    
    [2023-10-12 Thu]
      Failures
        HsDocTy
        T15242
    
    - - - - -
    28cbc152 by Alan Zimmerman at 2023-10-25T19:35:55+01:00
    EPA: Remove SrcSpanAnn completely
    
    - - - - -
    334e71e3 by Alan Zimmerman at 2023-10-25T19:35:55+01:00
    Clean up mkScope
    
    - - - - -
    c2f22705 by Alan Zimmerman at 2023-10-25T19:35:55+01:00
    EPA: Clean up TC Monad Utils
    
    - - - - -
    8e9efb95 by Alan Zimmerman at 2023-10-25T19:35:56+01:00
    EPA: EpaDelta for comment has no comments
    
    [2023-09-23 Sat]
    Current failures
       HsDocTy
       T15242
    
    - - - - -
    de361366 by Alan Zimmerman at 2023-10-25T19:35:56+01:00
    Semigroup instances for AnnList and AnnContext
    
    - - - - -
    
    
    30 changed files:
    
    - .ghcid
    - .gitignore
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    - .gitlab/rel_eng/upload.sh
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/ByteCode/Asm.hs
    - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
    - compiler/GHC/CmmToAsm/AArch64/Instr.hs
    - compiler/GHC/CmmToAsm/AArch64/Ppr.hs
    - compiler/GHC/CmmToAsm/AArch64/Regs.hs
    - compiler/GHC/CmmToAsm/Ppr.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Data/OrdList.hs
    - compiler/GHC/Driver/Config/Tidy.hs
    - compiler/GHC/Driver/Flags.hs
    - compiler/GHC/Driver/Session.hs
    - compiler/GHC/Hs.hs
    - compiler/GHC/Hs/Binds.hs
    - compiler/GHC/Hs/Decls.hs
    - compiler/GHC/Hs/Dump.hs
    - compiler/GHC/Hs/Expr.hs
    - compiler/GHC/Hs/Extension.hs
    - compiler/GHC/Hs/ImpExp.hs
    - compiler/GHC/Hs/Pat.hs
    - compiler/GHC/Hs/Type.hs
    - compiler/GHC/Hs/Utils.hs
    - compiler/GHC/HsToCore/Arrows.hs
    - compiler/GHC/HsToCore/Docs.hs
    - compiler/GHC/HsToCore/Monad.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d847e83e7ddd6e3aa0be83cb40636fab0a5b10f0...de36136680d4fde57abd0467829c9e4db2f3d90c
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d847e83e7ddd6e3aa0be83cb40636fab0a5b10f0...de36136680d4fde57abd0467829c9e4db2f3d90c
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Wed Oct 25 20:23:59 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Wed, 25 Oct 2023 16:23:59 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] 2 commits: White space
    Message-ID: <6539795fb3cea_1f7b0d708e3e905576de@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9ae2e8bb by Simon Peyton Jones at 2023-10-25T08:49:52+01:00
    White space
    
    - - - - -
    417d47c6 by Simon Peyton Jones at 2023-10-25T21:23:37+01:00
    Simplify size calculations
    
    - - - - -
    
    
    6 changed files:
    
    - compiler/GHC/Core.hs
    - compiler/GHC/Core/Opt/Simplify/Inline.hs
    - compiler/GHC/Core/Ppr.hs
    - compiler/GHC/Core/Seq.hs
    - compiler/GHC/Core/Subst.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core.hs
    =====================================
    @@ -1397,11 +1397,10 @@ data UnfoldingGuidance
       | UnfNever        -- The RHS is big, so don't inline it
     
     data ExprTree
    -  = TooBig
    -  | SizeIs { et_size  :: {-# UNPACK #-} !Int
    -           , et_ret   :: {-# UNPACK #-} !Int
    -                -- ^ Discount when result is scrutinised
    -           , et_cases :: Bag CaseTree
    +  = ExprTree { et_tot   :: {-# UNPACK #-} !Int   -- ^ Size of whole tree
    +             , et_size  :: {-# UNPACK #-} !Int   -- ^ Size of the bit apart from et_cases
    +             , et_ret   :: {-# UNPACK #-} !Int   -- ^ Discount when result is scrutinised
    +             , et_cases :: Bag CaseTree
         }
     
     data CaseTree
    
    
    =====================================
    compiler/GHC/Core/Opt/Simplify/Inline.hs
    =====================================
    @@ -222,11 +222,11 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
             where
               n_bndrs = length arg_bndrs
               some_benefit  = calc_some_benefit n_bndrs
    -          small_enough  = adjusted_size `leqSize` unfoldingUseThreshold opts
    -          adjusted_size = adjustSize adjust_size rhs_size
    +          small_enough  = adjusted_size <= unfoldingUseThreshold opts
    +          rhs_size      = exprTreeSize context expr_tree
    +          adjusted_size = rhs_size - call_size + depth_penalty
     
               --------  Compute the size of the ExprTree in this context -----------
    -          rhs_size = exprTreeSize context expr_tree
               want_result
                  | n_bndrs < n_val_args = True  -- Over-saturated
                  | otherwise            = case cont_info of
    @@ -254,9 +254,7 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
                             -> exprSummary env expr
                     _ -> ArgNoInfo
     
    -          -------- adjust_size ----------------
    -          adjust_size size = size - call_size + depth_penalty size
    -
    +          -------- Size adjustements ----------------
               -- Subtract size of the call, because the result replaces the call
               -- We count 10 for the function itself, 10 for each arg supplied,
               call_size = 10 + 10*n_val_args
    @@ -266,9 +264,9 @@ tryUnfolding logger env fn cont unf_template unf_cache guidance
               depth_threshold = unfoldingCaseThreshold opts
               depth_scaling   = unfoldingCaseScaling opts
     
    -          depth_penalty size
    +          depth_penalty
                 | case_depth <= depth_threshold = 0
    -            | otherwise = (size * (case_depth - depth_threshold)) `div` depth_scaling
    +            | otherwise = (rhs_size * (case_depth - depth_threshold)) `div` depth_scaling
     
               extra_doc = vcat [ text "size =" <+> ppr rhs_size
                                , text "case depth =" <+> int case_depth
    
    
    =====================================
    compiler/GHC/Core/Ppr.hs
    =====================================
    @@ -628,9 +628,9 @@ instance Outputable UnfoldingGuidance where
                    ppr et ]
     
     instance Outputable ExprTree where
    -  ppr TooBig         = text "TooBig"
    -  ppr (SizeIs { et_size = size, et_ret = ret, et_cases = cases })
    -    = int size <> char '/' <> int ret <> brackets (sep (map ppr (bagToList cases)))
    +  ppr (ExprTree { et_tot = tot, et_size = size, et_ret = ret, et_cases = cases })
    +    = int tot <> char '/' <> int size <> char '/' <> int ret
    +       <> brackets (sep (map ppr (bagToList cases)))
     
     instance Outputable CaseTree where
       ppr (ScrutOf x n)   = ppr x <> colon <> int n
    
    
    =====================================
    compiler/GHC/Core/Seq.hs
    =====================================
    @@ -126,9 +126,8 @@ seqGuidance (UnfIfGoodArgs bs et) = seqBndrs bs `seq` seqET et
     seqGuidance _                     = ()
     
     seqET :: ExprTree -> ()
    -seqET TooBig = ()
    -seqET (SizeIs { et_size = size, et_cases = cases, et_ret = ret })
    -  = size `seq` ret `seq` seqBag seqCT cases
    +seqET (ExprTree { et_tot = tot, et_size = size, et_cases = cases, et_ret = ret })
    +  = tot `seq` size `seq` ret `seq` seqBag seqCT cases
     
     seqCT :: CaseTree -> ()
     seqCT (ScrutOf x i) = x `seq` i `seq` ()
    
    
    =====================================
    compiler/GHC/Core/Subst.hs
    =====================================
    @@ -540,17 +540,22 @@ substGuidance subst guidance
     substExprTree :: IdSubstEnv -> ExprTree -> ExprTree
     -- ExprTrees have free Ids, and so must be substituted
     -- But Ids /only/ not tyvars, so substitution is very simple
    -substExprTree _     TooBig = TooBig
    -substExprTree id_env (SizeIs { et_size  = size
    -                             , et_cases = cases
    -                             , et_ret   = ret_discount })
    -   = case extra_size of
    -       STooBig     -> TooBig
    -       SSize extra -> SizeIs { et_size = size + extra
    -                             , et_cases = cases'
    -                             , et_ret = ret_discount }
    +--
    +-- We might be substituting a big tree in place of a variable
    +-- but we don't account for that in the size: I think it doesn't
    +-- matter, and the ExprTree will be refreshed soon enough.
    +substExprTree id_env (ExprTree { et_tot = tot
    +                               , et_size  = size
    +                               , et_cases = cases
    +                               , et_ret   = ret_discount })
    +   = ExprTree { et_tot   = tot
    +              , et_size  = size + extra_size
    +              , et_cases = cases'
    +              , et_ret   = ret_discount }
        where
    -     (extra_size, cases') = foldr subst_ct (sizeZero, emptyBag) cases
    +     (extra_size, cases') = foldr subst_ct (0, emptyBag) cases
    +     -- The extra_size is just in case we substitute a non-variable for
    +     -- for a variable, in which case a CaseOf won't work. Unlikely.
     
          subst_ct :: CaseTree -> (Size, Bag CaseTree) -> (Size, Bag CaseTree)
          subst_ct (ScrutOf v d) (n, cts)
    @@ -561,22 +566,17 @@ substExprTree id_env (SizeIs { et_size  = size
          subst_ct (CaseOf v case_bndr alts) (n, cts)
             = case lookupVarEnv id_env v of
                  Just (Var v') -> (n, CaseOf v' case_bndr alts' `consBag` cts)
    -             _ -> (n `addSize` extra, cts)
    +             _ -> (n + extra, cts)
             where
               id_env' = id_env `delVarEnv` case_bndr
               alts' = map (subst_alt id_env') alts
    -          extra = keptCaseSize boringInlineContext case_bndr alts
    +          extra = keptCaseSize alts
     
          subst_alt id_env (AltTree con bs rhs)
             = AltTree con bs (substExprTree id_env' rhs)
             where
               id_env' = id_env `delVarEnvList` bs
     
    -boringInlineContext :: InlineContext
    -boringInlineContext = IC { ic_free = \_ -> ArgNoInfo
    -                         , ic_bound = emptyVarEnv
    -                         , ic_want_res = False }
    -
     ------------------
     substIdOcc :: Subst -> Id -> Id
     -- These Ids should not be substituted to non-Ids
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -24,8 +24,7 @@ module GHC.Core.Unfold (
             exprTreeWillInline, couldBeSmallEnoughToInline,
             ArgSummary(..), hasArgInfo,
     
    -        Size(..), leqSize, addSizeN, addSize, adjustSize, sizeZero,
    -        InlineContext(..),
    +        Size, InlineContext(..),
     
             UnfoldingOpts (..), defaultUnfoldingOpts,
             updateCreationThreshold, updateUseThreshold,
    @@ -277,10 +276,9 @@ calcUnfoldingGuidance opts is_top_bottoming (Tick t expr)
       = calcUnfoldingGuidance opts is_top_bottoming expr
     calcUnfoldingGuidance opts is_top_bottoming expr
       = case exprTree opts val_bndrs body of
    -      TooBig -> UnfNever
    -      et@(SizeIs { et_size = size, et_cases = cases })
    -        | not (any is_case cases)
    -        , uncondInline expr n_val_bndrs size
    +      Nothing -> UnfNever
    +      Just et@(ExprTree { et_size = tot })
    +        | uncondInline expr n_val_bndrs tot
             -> UnfWhen { ug_unsat_ok  = unSaturatedOk
                        , ug_boring_ok =  boringCxtOk
                        , ug_arity     = n_val_bndrs }   -- Note [INLINE for small functions]
    @@ -296,18 +294,15 @@ calcUnfoldingGuidance opts is_top_bottoming expr
         val_bndrs   = filter isId bndrs
         n_val_bndrs = length val_bndrs
     
    -    is_case (CaseOf {})  = True
    -    is_case (ScrutOf {}) = False
    -
    -
     couldBeSmallEnoughToInline :: UnfoldingOpts -> Int -> CoreExpr -> Bool
     -- We use 'couldBeSmallEnoughToInline' to avoid exporting inlinings that
     -- we ``couldn't possibly use'' on the other side.  Can be overridden
     -- w/flaggery.  Just the same as smallEnoughToInline, except that it has no
     -- actual arguments.
     couldBeSmallEnoughToInline opts threshold rhs
    -  = exprTreeWillInline threshold $
    -    exprTree opts [] body
    +  = case exprTree opts [] body of
    +      Nothing -> False
    +      Just et -> exprTreeWillInline threshold et
       where
         (_, body) = collectBinders rhs
     
    @@ -504,13 +499,14 @@ Wrinkles:
     
     * We must be careful about recording enormous functions, with very wide or very
       deep case trees. (This can happen with Generics; e.g. test T5642.)  We limit
    -  both with UnfoldingOpts, and 
    +  both with UnfoldingOpts.
     -}
     
     type ETVars = (VarSet,VarSet)  -- (avs, lvs)
                   -- See Note [Constructing an ExprTree]
     
    -exprTree :: UnfoldingOpts -> [Var] -> CoreExpr -> ExprTree
    +exprTree :: UnfoldingOpts -> [Var] -> CoreExpr -> Maybe ExprTree
    +-- Nothing => too big
     -- Note [Computing the size of an expression]
     
     exprTree opts args expr
    @@ -526,27 +522,27 @@ exprTree opts args expr
         ok_case case_depth n_alts  -- Case is not too deep, nor too wide
           = case_depth > 0 && n_alts <= max_width
     
    -    et_add     = etAdd bOMB_OUT_SIZE
    -    et_add_alt = etAddAlt bOMB_OUT_SIZE
    +    et_add     = metAdd bOMB_OUT_SIZE
    +    et_add_alt = metAddAlt bOMB_OUT_SIZE
     
    -    go :: Int -> ETVars -> CoreExpr -> ExprTree
    +    go :: Int -> ETVars -> CoreExpr -> Maybe ExprTree
               -- cd is the unused case depth; decreases toward zero
               -- (avs,lvs): see Note [Constructing an ExprTree]
         go cd vs (Cast e _)      = go cd vs e
         go cd vs (Tick _ e)      = go cd vs e
    -    go _  _  (Type _)        = exprTreeN 0
    -    go _  _  (Coercion _)    = exprTreeN 0
    -    go _  _  (Lit lit)       = exprTreeN (litSize lit)
    +    go _  _  (Type _)        = Just (exprTreeN 0)
    +    go _  _  (Coercion _)    = Just (exprTreeN 0)
    +    go _  _  (Lit lit)       = Just (exprTreeN (litSize lit))
         go cd vs (Case e b _ as) = go_case cd vs e b as
         go cd vs (Let bind body) = go_let cd vs bind body
         go cd vs (Lam b e)       = go_lam cd vs b e
         go cd vs e@(App {})      = go_app cd vs e
    -    go _  vs (Var f)         = callTree opts vs f [] 0
    +    go _  vs (Var f)         = Just (callTree opts vs f [] 0)
                                    -- Use callTree to ensure we get constructor
                                    -- discounts even on nullary constructors
         -------------------
         go_lam cd vs bndr body
    -      | isId bndr, not (isZeroBitId bndr) = go cd vs' body `et_add` lamSize opts
    +      | isId bndr, not (isZeroBitId bndr) = go cd vs' body `et_add` Just (lamSize opts)
           | otherwise                         = go cd vs' body
           where
             vs' = vs `add_lv` bndr
    @@ -564,7 +560,7 @@ exprTree opts args expr
         -------------------
         go_app cd vs e = lgo e [] 0
           where
    -         lgo :: CoreExpr -> [CoreExpr] -> Int -> ExprTree
    +         lgo :: CoreExpr -> [CoreExpr] -> Int -> Maybe ExprTree
                  -- args:  all the value args
                  -- voids: counts the zero-bit arguments; don't charge for these
                  --        This makes a difference in ST-heavy code which does a lot
    @@ -574,11 +570,11 @@ exprTree opts args expr
                         | isZeroBitArg arg = lgo fun (arg:args) (voids+1)
                         | otherwise        = go cd vs arg `et_add`
                                              lgo fun (arg:args) voids
    -         lgo (Var fun)     args voids  = callTree opts vs fun args voids
    +         lgo (Var fun)     args voids  = Just (callTree opts vs fun args voids)
              lgo (Tick _ expr) args voids  = lgo expr args voids
              lgo (Cast expr _) args voids  = lgo expr args voids
              lgo other         args voids  = vanillaCallSize (length args) voids
    -                                         `etAddN` go cd vs other
    +                                         `metAddN` go cd vs other
              -- if the lhs is not an App or a Var, or an invisible thing like a
              -- Tick or Cast, then we should charge for a complete call plus the
              -- size of the lhs itself.
    @@ -590,7 +586,7 @@ exprTree opts args expr
                               -- Skip arguments to join point
           = go cd (vs `add_lvs` bndrs) body
           | otherwise
    -      = size_up_alloc bndr `etAddN` go cd vs rhs
    +      = size_up_alloc bndr `metAddN` go cd vs rhs
     
         -- Cost to allocate binding with given binder
         size_up_alloc bndr
    @@ -602,7 +598,7 @@ exprTree opts args expr
           = 10
     
         -----------------------------
    -    go_case :: Int -> ETVars -> CoreExpr -> Id -> [CoreAlt] -> ExprTree
    +    go_case :: Int -> ETVars -> CoreExpr -> Id -> [CoreAlt] -> Maybe ExprTree
         -- Empty case
         go_case cd vs scrut _ [] = go cd vs scrut
              -- case e of {} never returns, so take size of scrutinee
    @@ -612,15 +608,17 @@ exprTree opts args expr
           | Just v <- recordCaseOf vs scrut
           = go cd vs scrut `et_add`
             (if   ok_case cd n_alts
    -         then etOneCase (CaseOf v b (map (alt_alt_tree v) alts))
    -         else etOneCase (ScrutOf v (10 * n_alts)) `et_add`
    +         then do { alts' <- mapM (alt_alt_tree v) alts
    +                 ; etCaseOf bOMB_OUT_SIZE v b alts' }
    +         else Just (etScrutOf v (10 * n_alts)) `et_add`
                   go_alts cd vs b alts)
           where
             cd1 = cd - 1
             n_alts = length alts
    -        alt_alt_tree :: Id -> Alt Var -> AltTree
    +        alt_alt_tree :: Id -> Alt Var -> Maybe AltTree
             alt_alt_tree v (Alt con bs rhs)
    -          = AltTree con val_bs (10 `etAddN` go cd1 (add_alt_bndrs v val_bs) rhs)
    +          = do { rhs <- 10 `metAddN` go cd1 (add_alt_bndrs v val_bs) rhs
    +               ; return (AltTree con val_bs rhs) }
               where
                 val_bs = filter isId bs
     
    @@ -631,17 +629,17 @@ exprTree opts args expr
     
         -- Don't record a CaseOf
         go_case cd vs scrut b alts    -- alts is non-empty
    -      = caseSize scrut alts `etAddN`   -- A bit odd that this is only in one branch
    +      = caseSize scrut alts `metAddN`   -- A bit odd that this is only in one branch
             go cd vs scrut      `et_add`
             go_alts cd vs b alts
     
    -    go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> ExprTree
    +    go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> Maybe ExprTree
         go_alts cd vs b alts = foldr1 et_add_alt (map alt_expr_tree alts)
           where
             cd1 = cd - 1
    -        alt_expr_tree :: Alt Var -> ExprTree
    +        alt_expr_tree :: Alt Var -> Maybe ExprTree
             alt_expr_tree (Alt _con bs rhs)
    -          = 10 `etAddN` go cd1 (vs `add_lvs` (b:bs)) rhs
    +          = 10 `metAddN` go cd1 (vs `add_lvs` (b:bs)) rhs
                 -- Don't charge for bndrs, so that wrappers look cheap
                 -- (See comments about wrappers with Case)
                 -- Don't forget to add the case binder, b, to lvs.
    @@ -650,7 +648,7 @@ exprTree opts args expr
                 -- find that giant case nests are treated as practically free
                 -- A good example is Foreign.C.Error.errnoToIOError
     
    -caseSize :: CoreExpr -> [CoreAlt] -> Int
    +caseSize :: CoreExpr -> [CoreAlt] -> Size
     caseSize scrut alts
       | is_inline_scrut scrut, lengthAtMost alts 1 = -10
       | otherwise                                  = 0
    @@ -716,7 +714,7 @@ isZeroBitId id = assertPpr (not (isJoinId id)) (ppr id) $
     
     
     -- | Finds a nominal size of a string literal.
    -litSize :: Literal -> Int
    +litSize :: Literal -> Size
     -- Used by GHC.Core.Unfold.exprTree
     litSize (LitNumber LitNumBigNat _)  = 100
     litSize (LitString str) = 10 + 10 * ((BS.length str + 3) `div` 4)
    @@ -763,7 +761,7 @@ classOpSize opts vs fn val_args voids
       , Just dict <- recordCaseOf vs arg1
       = warnPprTrace (not (isId dict)) "classOpSize" (ppr fn <+> ppr val_args) $
         vanillaCallSize (length val_args) voids `etAddN`
    -    etOneCase (ScrutOf dict (unfoldingDictDiscount opts))
    +    etScrutOf dict (unfoldingDictDiscount opts)
                -- If the class op is scrutinising a lambda bound dictionary then
                -- give it a discount, to encourage the inlining of this function
                -- The actual discount is rather arbitrarily chosen
    @@ -776,9 +774,9 @@ funSize :: UnfoldingOpts -> ETVars -> Id -> Int -> Int -> ExprTree
     funSize opts (avs,_) fun n_val_args voids
       | fun `hasKey` buildIdKey   = etZero  -- Wwant to inline applications of build/augment
       | fun `hasKey` augmentIdKey = etZero  -- so we give size zero to the whole call
    -  | otherwise = SizeIs { et_size  = size
    -                       , et_cases = cases
    -                       , et_ret   = res_discount }
    +  | otherwise = ExprTree { et_tot = size, et_size  = size
    +                         , et_cases = cases
    +                         , et_ret   = res_discount }
       where
         size | n_val_args == 0 = 0    -- Naked variable counts zero
              | otherwise       = vanillaCallSize n_val_args voids
    @@ -798,8 +796,9 @@ funSize opts (avs,_) fun n_val_args voids
     
     lamSize :: UnfoldingOpts -> ExprTree
     -- Does not include the size of the body, just the lambda itself
    -lamSize opts = SizeIs { et_size = 10, et_cases = emptyBag
    -                      , et_ret = unfoldingFunAppDiscount opts }
    +lamSize opts = ExprTree { et_size = 10, et_tot = 10
    +                        , et_cases = emptyBag
    +                        , et_ret = unfoldingFunAppDiscount opts }
     
     conSize :: DataCon -> Int -> ExprTree
     -- Does not need to include the size of the arguments themselves
    @@ -807,7 +806,8 @@ conSize dc n_val_args
       | isUnboxedTupleDataCon dc
       = etZero     -- See Note [Unboxed tuple size and result discount]
       | otherwise  -- See Note [Constructor size and result discount]
    -  = SizeIs { et_size = size, et_cases = emptyBag, et_ret = 10 }
    +  = ExprTree { et_size = size, et_tot = size
    +             , et_cases = emptyBag, et_ret = 10 }
       where
         size | n_val_args == 0 = 0  -- Like variables
              | otherwise       = 10
    @@ -981,47 +981,70 @@ Code for manipulating sizes
     -}
     
     ---------------------------------------
    --- | The "expression tree"; an abstraction of the RHS of the function
    -exprTreeN :: Int -> ExprTree
    -exprTreeN n = SizeIs { et_size = n, et_cases = emptyBag, et_ret = 0 }
    +metAddN :: Int -> Maybe ExprTree -> Maybe ExprTree
    +metAddN _ Nothing = Nothing
    +metAddN n (Just et) = Just (n `etAddN` et)
     
     etAddN :: Int -> ExprTree -> ExprTree
    -etAddN _ TooBig = TooBig
    -etAddN n1 (SizeIs { et_size = n2, et_cases = c2, et_ret = ret2 })
    -  = SizeIs { et_size = n1+n2, et_cases = c2, et_ret = ret2 }
    +-- Does not account for et_tot geting too big, but that doesn't
    +-- matter; the extra increment is always small, and we never get
    +-- a long cascade of etAddNs
    +etAddN n1 (ExprTree { et_tot = t2, et_size = n2, et_cases = c2, et_ret = ret2 })
    +  = ExprTree { et_tot = n1+t2, et_size = n1+n2, et_cases = c2, et_ret = ret2 }
     
    -etAdd :: Int -> ExprTree -> ExprTree -> ExprTree
    +metAdd :: Size -> Maybe ExprTree -> Maybe ExprTree -> Maybe ExprTree
     -- Takes return value from the right hand argument
    -etAdd _ TooBig _ = TooBig
    -etAdd _ _ TooBig = TooBig
    -etAdd bOMB_OUT_SIZE (SizeIs { et_size = n1, et_cases = c1, et_ret = _ret1 })
    -                    (SizeIs { et_size = n2, et_cases = c2, et_ret = ret2 })
    -  | n12 >= bOMB_OUT_SIZE = TooBig
    -  | otherwise = SizeIs { et_size  = n12
    -                       , et_cases = c1 `unionBags` c2
    -                       , et_ret   = ret2 }
    -  where
    -    n12 = n1 + n2
    -
    -etAddAlt :: Int -> ExprTree -> ExprTree -> ExprTree
    --- etAddalt is used to add the sizes of case alternatives
    -etAddAlt _  TooBig _ = TooBig
    -etAddAlt _  _ TooBig = TooBig
    -etAddAlt bOMB_OUT_SIZE (SizeIs { et_size = n1, et_cases = c1, et_ret = ret1 })
    -                       (SizeIs { et_size = n2, et_cases = c2, et_ret = ret2 })
    -  | n12 >= bOMB_OUT_SIZE = TooBig
    -  | otherwise = SizeIs { et_size  = n12
    -                       , et_cases = c1 `unionBags` c2
    -                       , et_ret   = ret1 + ret2 }
    -                           -- et_ret: see Note [etAddAlt result discounts]
    -  where
    -    n12 = n1 + n2
    +metAdd _ Nothing _ = Nothing
    +metAdd _ _ Nothing = Nothing
    +metAdd bOMB_OUT_SIZE (Just et1) (Just et2)
    +  | ExprTree { et_tot = t1, et_size = n1, et_cases = c1, et_ret = _ret1 } <- et1
    +  , ExprTree { et_tot = t2, et_size = n2, et_cases = c2, et_ret =  ret2 } <- et2
    +  , let t12 = t1 + t2
    +  = if   t12 >= bOMB_OUT_SIZE
    +    then Nothing
    +    else Just (ExprTree { et_tot = t12
    +                        , et_size  = n1 + n2
    +                        , et_cases = c1 `unionBags` c2
    +                        , et_ret   = ret2 })
    +
    +metAddAlt :: Size -> Maybe ExprTree -> Maybe ExprTree -> Maybe ExprTree
    +-- Adds return discounts from both args
    +metAddAlt _ Nothing _ = Nothing
    +metAddAlt _ _ Nothing = Nothing
    +metAddAlt bOMB_OUT_SIZE (Just et1) (Just et2)
    +  | ExprTree { et_tot = t1, et_size = n1, et_cases = c1, et_ret = ret1 } <- et1
    +  , ExprTree { et_tot = t2, et_size = n2, et_cases = c2, et_ret = ret2 } <- et2
    +  , let t12 = t1 + t2
    +  = if   t12 >= bOMB_OUT_SIZE
    +    then Nothing
    +    else Just (ExprTree { et_tot = t12
    +                        , et_size  = n1 + n2
    +                        , et_cases = c1 `unionBags` c2
    +                        , et_ret   = ret1 + ret2 })
    +
    +
    +-- | The "expression tree"; an abstraction of the RHS of the function
    +exprTreeN :: Int -> ExprTree
    +exprTreeN n = ExprTree { et_size = n, et_tot = n, et_cases = emptyBag, et_ret = 0 }
     
     etZero :: ExprTree
    -etZero = SizeIs { et_size = 0, et_cases = emptyBag, et_ret = 0 }
    +etZero = ExprTree { et_tot = 0, et_size = 0, et_cases = emptyBag, et_ret = 0 }
    +
    +etCaseOf :: Int -> Id -> Id -> [AltTree] -> Maybe ExprTree
    +-- We make the case itself free, but charge for each alternative
    +-- If there are no alternatives (case e of {}), we get just the size of the scrutinee
    +etCaseOf bOMB_OUT_SIZE scrut case_bndr alts
    +  | tot >= bOMB_OUT_SIZE = Nothing
    +  | otherwise            = Just (ExprTree { et_tot = tot, et_size = 0, et_ret = 0
    +                                          , et_cases = unitBag case_tree })
    +  where
    +    case_tree = CaseOf scrut case_bndr alts
    +    tot = foldl' add_alt 0 alts
    +    add_alt n (AltTree _ _ (ExprTree { et_tot = tot })) = n+tot
     
    -etOneCase :: CaseTree -> ExprTree
    -etOneCase ct = SizeIs { et_size = 0, et_cases = unitBag ct, et_ret = 0 }
    +etScrutOf :: Id -> Int -> ExprTree
    +etScrutOf v d = ExprTree { et_tot = 0, et_size = 0, et_ret = 0
    +                         , et_cases = unitBag (ScrutOf v d) }
     
     {- *********************************************************************
     *                                                                      *
    @@ -1030,8 +1053,9 @@ etOneCase ct = SizeIs { et_size = 0, et_cases = unitBag ct, et_ret = 0 }
     *                                                                      *
     ********************************************************************* -}
     
    -data Size = STooBig | SSize {-# UNPACK #-} !Int
    +type Size = Int
     
    +{-
     instance Outputable Size where
       ppr STooBig = text "STooBig"
       ppr (SSize n) = int n
    @@ -1057,6 +1081,7 @@ adjustSize _ STooBig   = STooBig
     leqSize :: Size -> Int -> Bool
     leqSize STooBig   _ = False
     leqSize (SSize n) m = n <= m
    +-}
     
     -------------------------
     data InlineContext
    @@ -1087,32 +1112,15 @@ exprTreeWillInline :: Int -> ExprTree -> Bool
     -- (cheapExprTreeSize limit et) takes an upper bound `n` on the
     -- size of et; i.e. without discounts etc.
     -- Return True if (s <- limit), False otherwise
    --- Bales out early in the False case
    -exprTreeWillInline limit et
    -  = go et (\n -> n <= limit) 0
    -  where
    -    go :: ExprTree -> (Int -> Bool) -> Int -> Bool
    -    go _      _ n | n > limit = False
    -    go TooBig _ _             = False
    -    go (SizeIs { et_size = size, et_cases = cases }) k n
    -      = foldr go_ct k cases (n+size)
    -
    -    go_ct :: CaseTree -> (Int -> Bool) -> Int -> Bool
    -    go_ct (ScrutOf {})      k n = k n
    -    go_ct (CaseOf _ _ alts) k n = foldr go_alt k alts n
    -
    -    go_alt :: AltTree -> (Int -> Bool) -> Int -> Bool
    -    go_alt (AltTree _ _ et) k n = go et k (n+10)
    -
    +exprTreeWillInline limit (ExprTree { et_tot = tot }) = tot < limit
     
     -------------------------
     exprTreeSize :: InlineContext -> ExprTree -> Size
    -exprTreeSize _    TooBig = STooBig
    -exprTreeSize !ic (SizeIs { et_size  = size
    -                         , et_cases = cases
    -                         , et_ret   = ret_discount })
    -  = foldr (addSize . caseTreeSize (ic { ic_want_res = False }))
    -          (sizeN discounted_size) cases
    +exprTreeSize !ic (ExprTree { et_size  = size
    +                           , et_cases = cases
    +                           , et_ret   = ret_discount })
    +  = foldr ((+) . caseTreeSize (ic { ic_want_res = False }))
    +          discounted_size cases
       where
         discounted_size | ic_want_res ic = size - ret_discount
                         | otherwise      = size
    @@ -1120,17 +1128,17 @@ exprTreeSize !ic (SizeIs { et_size  = size
     caseTreeSize :: InlineContext -> CaseTree -> Size
     caseTreeSize ic (ScrutOf bndr disc)
       = case lookupBndr ic bndr of
    -      ArgNoInfo   -> sizeN 0
    -      ArgIsNot {} -> sizeN (-disc)  -- E.g. bndr is a DFun application
    -                                    --      T8732 need to inline mapM_
    -      ArgIsLam    -> sizeN (-disc)  -- Apply discount
    -      ArgIsCon {} -> sizeN (-disc)  -- Apply discount
    +      ArgNoInfo   -> 0
    +      ArgIsNot {} -> -disc  -- E.g. bndr is a DFun application
    +                            --      T8732 need to inline mapM_
    +      ArgIsLam    -> -disc  -- Apply discount
    +      ArgIsCon {} -> -disc  -- Apply discount
     
     caseTreeSize ic (CaseOf scrut_var case_bndr alts)
       = case lookupBndr ic scrut_var of
    -      ArgNoInfo     -> keptCaseSize ic case_bndr alts
    -      ArgIsLam      -> keptCaseSize ic case_bndr alts
    -      ArgIsNot cons -> keptCaseSize ic case_bndr (trim_alts cons alts)
    +      ArgNoInfo     -> keptCaseSize alts
    +      ArgIsLam      -> keptCaseSize alts
    +      ArgIsNot cons -> keptCaseSize (trim_alts cons alts)
     
           arg_summ@(ArgIsCon con args)
              | Just at@(AltTree alt_con bndrs rhs) <- find_alt con alts
    @@ -1143,7 +1151,7 @@ caseTreeSize ic (CaseOf scrut_var case_bndr alts)
                 exprTreeSize ic' rhs
     
              | otherwise  -- Happens for empty alternatives
    -         -> keptCaseSize ic case_bndr alts
    +         -> keptCaseSize alts
     
     find_alt :: AltCon -> [AltTree] -> Maybe AltTree
     find_alt _   []                     = Nothing
    @@ -1162,28 +1170,20 @@ trim_alts acs (alt:alts)
       | AltTree con _ _ <- alt, con `elem` acs = trim_alts acs alts
       | otherwise                              = alt : trim_alts acs alts
     
    -keptCaseSize :: InlineContext -> Id -> [AltTree] -> Size
    +keptCaseSize :: [AltTree] -> Size
     -- Size of a (retained) case expression
    -keptCaseSize ic case_bndr alts
    -  = foldr (addSize . size_alt) (sizeN 0) alts
    -    -- We make the case itself free, but charge for each alternative
    -    -- If there are no alternatives (case e of {}), we get just the size of the scrutinee
    +keptCaseSize alts = foldr add_alt 0 alts
    +  -- Just add up the  sizes of the alternatives
    +  -- We make the case itself free, but charge for each alternatives (that
    +  -- is already included in the AltTrees
    +  -- If there are no alternatives (case e of {}), we get zero
       where
    -    size_alt :: AltTree -> Size
    -    size_alt (AltTree _ bndrs rhs)
    -       = exprTreeSize ic' rhs
    -        -- Cost for the alternative is already in `rhs`
    -      where
    -        -- Must extend ic_bound, lest a captured variable is
    -        -- looked up in ic_free by lookupBndr
    -        new_summaries :: [(Id,ArgSummary)]
    -        new_summaries = [(b,ArgNoInfo) | b <- case_bndr:bndrs]
    -        ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
    +    add_alt :: AltTree -> Size -> Size
    +    add_alt (AltTree _ _ (ExprTree { et_tot = tot })) n = n+tot
    +        -- Cost for the alternative is already in `tot`
     
     lookupBndr :: HasDebugCallStack => InlineContext -> Id -> ArgSummary
     lookupBndr (IC { ic_bound = bound_env, ic_free = lookup_free }) var
       | Just info <- assertPpr (isId var) (ppr var) $
                      lookupVarEnv bound_env var = info
       | otherwise                               = lookup_free var
    -
    -
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f12a52edf520f7f6776daad02dd72daf562fa6b...417d47c6eb3565af96ea2fbe6c45410527a102f7
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f12a52edf520f7f6776daad02dd72daf562fa6b...417d47c6eb3565af96ea2fbe6c45410527a102f7
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Wed Oct 25 21:12:38 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Wed, 25 Oct 2023 17:12:38 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Fix egregious error
    Message-ID: <653984c6160c5_1f7b0d720636c45590c@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    0a6e8228 by Simon Peyton Jones at 2023-10-25T22:12:22+01:00
    Fix egregious error
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -277,7 +277,7 @@ calcUnfoldingGuidance opts is_top_bottoming (Tick t expr)
     calcUnfoldingGuidance opts is_top_bottoming expr
       = case exprTree opts val_bndrs body of
           Nothing -> UnfNever
    -      Just et@(ExprTree { et_size = tot })
    +      Just et@(ExprTree { et_tot = tot })
             | uncondInline expr n_val_bndrs tot
             -> UnfWhen { ug_unsat_ok  = unSaturatedOk
                        , ug_boring_ok =  boringCxtOk
    @@ -634,6 +634,7 @@ exprTree opts args expr
             go_alts cd vs b alts
     
         go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> Maybe ExprTree
    +    -- Add up the sizes of all RHSs, plus 10 for each alternative
         go_alts cd vs b alts = foldr1 et_add_alt (map alt_expr_tree alts)
           where
             cd1 = cd - 1
    @@ -1002,7 +1003,7 @@ metAdd bOMB_OUT_SIZE (Just et1) (Just et2)
       , let t12 = t1 + t2
       = if   t12 >= bOMB_OUT_SIZE
         then Nothing
    -    else Just (ExprTree { et_tot = t12
    +    else Just (ExprTree { et_tot   = t12
                             , et_size  = n1 + n2
                             , et_cases = c1 `unionBags` c2
                             , et_ret   = ret2 })
    @@ -1017,7 +1018,7 @@ metAddAlt bOMB_OUT_SIZE (Just et1) (Just et2)
       , let t12 = t1 + t2
       = if   t12 >= bOMB_OUT_SIZE
         then Nothing
    -    else Just (ExprTree { et_tot = t12
    +    else Just (ExprTree { et_tot   = t12
                             , et_size  = n1 + n2
                             , et_cases = c1 `unionBags` c2
                             , et_ret   = ret1 + ret2 })
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a6e82288a9dff673753af5672b73cb77efba06c
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a6e82288a9dff673753af5672b73cb77efba06c
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Wed Oct 25 22:09:37 2023
    From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz))
    Date: Wed, 25 Oct 2023 18:09:37 -0400
    Subject: [Git][ghc/ghc][wip/az/ghc-cpp] 2 commits: Starting on expression
     parser.
    Message-ID: <6539922123452_1f7b0d7362b2f4561321@gitlab.mail>
    
    
    
    Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    df453303 by Alan Zimmerman at 2023-10-05T23:03:45+01:00
    Starting on expression parser.
    
    But it hangs. Time for Text.Parsec.Expr
    
    - - - - -
    01f6c1eb by Alan Zimmerman at 2023-10-25T23:08:32+01:00
    Start integrating the ghc-cpp work
    
    >From https://github.com/alanz/ghc-cpp
    
    - - - - -
    
    
    13 changed files:
    
    - + utils/check-cpp/.gitignore
    - + utils/check-cpp/Eval.hs
    - + utils/check-cpp/Example1.hs
    - + utils/check-cpp/Example2.hs
    - + utils/check-cpp/Lexer.x
    - + utils/check-cpp/Macro.hs
    - utils/check-cpp/Main.hs
    - utils/check-cpp/Parse.hs
    - + utils/check-cpp/ParseOld.hs
    - + utils/check-cpp/ParserM.hs
    - utils/check-cpp/PreProcess.hs
    - + utils/check-cpp/README.md
    - + utils/check-cpp/Types.hs
    
    
    Changes:
    
    =====================================
    utils/check-cpp/.gitignore
    =====================================
    @@ -0,0 +1 @@
    +Lexer.hs
    
    
    =====================================
    utils/check-cpp/Eval.hs
    =====================================
    @@ -0,0 +1,38 @@
    +module Eval where
    +
    +import Parse
    +
    +-- ---------------------------------------------------------------------
    +
    +eval :: Expr -> Int
    +eval (Parens e) = eval e
    +eval (Var v) = error $ "need to look up :" ++ v
    +eval (IntVal i) = i
    +eval (Plus e1 e2) = (eval e1) + (eval e2)
    +eval (Times e1 e2) = (eval e1) * (eval e2)
    +eval (BinOp op e1 e2) = evalOp op (eval e1) (eval e2)
    +
    +evalOp :: Op -> Int -> Int -> Int
    +evalOp LogicalOr e1 e2 = fromBool $ (toBool e1) || (toBool e2)
    +evalOp LogicalAnd e1 e2 = fromBool $ (toBool e1) || (toBool e2)
    +evalOp CmpEqual e1 e2 = fromBool $ e1 == e2
    +evalOp CmpGt e1 e2 = fromBool $ e1 > e2
    +evalOp CmpGtE e1 e2 = fromBool $ e1 >= e2
    +evalOp CmpLt e1 e2 = fromBool $ e1 < e2
    +evalOp CmpLtE e1 e2 = fromBool $ e1 <= e2
    +
    +toBool :: Int -> Bool
    +toBool 0 = False
    +toBool _ = True
    +
    +fromBool :: Bool -> Int
    +fromBool False = 0
    +fromBool True = 1
    +
    +-- ---------------------------------------------------------------------
    +
    +v0 :: Int
    +v0 = eval (Plus (IntVal 1) (IntVal 3))
    +
    +v1 :: Int
    +v1 = eval (BinOp CmpGt (IntVal 4) (IntVal 3))
    
    
    =====================================
    utils/check-cpp/Example1.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE GhcCPP #-}
    +module Example1 where
    +
    +y = 3
    +
    +#define FOO
    +
    +x =
    +#ifndef FOO
    +  "hello"
    +#else
    +  "bye now"
    +#endif
    +
    +foo = putStrLn x
    
    
    =====================================
    utils/check-cpp/Example2.hs
    =====================================
    @@ -0,0 +1,19 @@
    +{-# LANGUAGE GhcCPP #-}
    +module Example2 where
    +
    +/* package ghc-exactprint-1.7.0.1 */
    +#ifndef VERSION_ghc_exactprint
    +#define VERSION_ghc_exactprint "1.7.0.1"
    +#endif /* VERSION_ghc_exactprint */
    +-- #ifndef MIN_VERSION_ghc_exactprint
    +-- #define MIN_VERSION_ghc_exactprint(major1,major2,minor) (\
    +--   (major1) <  1 || \
    +--   (major1) == 1 && (major2) <  7 || \
    +--   (major1) == 1 && (major2) == 7 && (minor) <= 0)
    +-- #endif /* MIN_VERSION_ghc_exactprint */
    +
    +#ifdef VERSION_ghc_exactprint
    +x = "got version"
    +#else
    +x = "no version"
    +#endif
    
    
    =====================================
    utils/check-cpp/Lexer.x
    =====================================
    @@ -0,0 +1,129 @@
    +{
    +module Lexer (lex_tok, lexCppTokenStream) where
    +
    +import ParserM (
    +                St, init_pos,
    +                ParserM (..), Action, mkTv, Token(..), start_code,
    +                setStartCode,
    +                show_pos, position,
    +                AlexInput(..), alexGetByte)
    +import qualified ParserM as ParserM (input)
    +import Control.Monad
    +
    +-- The lexer is based on
    +-- https://timsong-cpp.github.io/cppwp/n4140/lex.pptoken
    +}
    +
    +words :-
    +
    +    <0>         $white+              ;
    +---------------------------------------
    +    <0>         "{"                  { mkTv TOpenBrace }
    +    <0>         "}"                  { mkTv TCloseBrace }
    +    <0>         "["                  { mkTv TOpenBracket }
    +    <0>         "]"                  { mkTv TCloseBracket }
    +    <0>         "#"                  { mkTv THash }
    +    <0>         "##"                 { mkTv THashHash }
    +    <0>         "("                  { mkTv TOpenParen }
    +    <0>         ")"                  { mkTv TCloseParen }
    +    <0>         "<:"                 { mkTv TLtColon }
    +    <0>         ":>"                 { mkTv TColonGt}
    +    <0>         "<%"                 { mkTv TLtPercent }
    +    <0>         "%>"                 { mkTv TPercentGt }
    +    <0>         "%:"                 { mkTv TPercentColon }
    +    <0>         "%:%:"               { mkTv TPercentColonTwice }
    +    <0>         ";"                  { mkTv TSemi }
    +    <0>         ":"                  { mkTv TColon }
    +    <0>         "..."                { mkTv TDotDotDot }
    +    <0>         "new"                { mkTv TNew }
    +    <0>         "delete"             { mkTv TDelete }
    +    <0>         "?"                  { mkTv TQuestion }
    +    <0>         "::"                 { mkTv TColonColon}
    +    <0>         "."                  { mkTv TDot }
    +    <0>         ".*"                 { mkTv TDotStar }
    +    <0>         "+"                  { mkTv TPlus }
    +    <0>         "-"                  { mkTv TMinus }
    +    <0>         "*"                  { mkTv TStar }
    +    <0>         "/"                  { mkTv TSlash }
    +    <0>         "%"                  { mkTv TPercent }
    +    <0>         "^"                  { mkTv TUpArrow }
    +    <0>         "&"                  { mkTv TAmpersand }
    +    <0>         "|"                  { mkTv TPipe }
    +    <0>         "~"                  { mkTv TTilde }
    +    <0>         "!"                  { mkTv TExclamation }
    +    <0>         "="                  { mkTv TEqual }
    +    <0>         "<"                  { mkTv TOpenAngle }
    +    <0>         ">"                  { mkTv TCloseAngle }
    +    <0>         "+="                 { mkTv TPlusEqual }
    +    <0>         "-="                 { mkTv TMinusEqual }
    +    <0>         "*="                 { mkTv TStarEqual }
    +    <0>         "/="                 { mkTv TSlashEqual }
    +    <0>         "%="                 { mkTv TPercentEqual }
    +    <0>         "^="                 { mkTv TUpEqual }
    +    <0>         "&="                 { mkTv TAmpersandEqual }
    +    <0>         "|="                 { mkTv TPipeEqual }
    +    <0>         "<<"                 { mkTv TLtLt }
    +    <0>         ">>"                 { mkTv TGtGt }
    +    <0>         ">>="                { mkTv TGtGtEqual }
    +    <0>         "<<="                { mkTv TLtLtEqual }
    +    <0>         "=="                 { mkTv TEqualEqual }
    +    <0>         "!="                 { mkTv TExclaimEqual }
    +    <0>         "<="                 { mkTv TLtEqual }
    +    <0>         ">="                 { mkTv TGtEqual }
    +    <0>         "&&"                 { mkTv TAmpersandTwice }
    +    <0>         "||"                 { mkTv TPipePipe }
    +    <0>         "++"                 { mkTv TPlusPlus }
    +    <0>         "--"                 { mkTv TMinusMinus }
    +    <0>         ","                  { mkTv TComma }
    +    <0>         "->*"                { mkTv TMinusGtStar }
    +    <0>         "->"                 { mkTv TMinusGt }
    +    <0>         "and"                { mkTv TAnd }
    +    <0>         "and_eq"             { mkTv TAndEq }
    +    <0>         "bitand"             { mkTv TBitand }
    +    <0>         "bitor"              { mkTv TBitor }
    +    <0>         "compl"              { mkTv TCompl }
    +    <0>         "not"                { mkTv TNot }
    +    <0>         "not_eq"             { mkTv TNotEq }
    +    <0>         "or"                 { mkTv TOr }
    +    <0>         "or_eq"              { mkTv TOrEq }
    +    <0>         "xor"                { mkTv TXor }
    +    <0>         "xor_eq"             { mkTv TXorEq }
    +----------------------------------------
    +    <0>         [a-z][a-zA-Z0-9\#_]* { mkTv TLowerName }
    +    <0>         [A-Z][a-zA-Z0-9\#_]* { mkTv TUpperName }
    +    <0>         \-? [0-9][0-9]*      { mkTv TInteger  }
    +    <0>         \" [^\"]* \"         { mkTv (TString . tail . init) }
    +    <0>         ()                   { begin other }
    +
    +         .+                   { \i -> do {setStartCode 0;
    +                                                 mkTv TOther i} }
    +
    +{
    +
    +begin :: Int -> Action
    +begin sc _str =
    +  do setStartCode sc
    +     get_tok
    +
    +get_tok :: ParserM Token
    +get_tok = ParserM $ \i st ->
    +   case alexScan i (start_code st) of
    +       AlexEOF -> Right (i, st, TEOF "")
    +       AlexError _ -> Left ("Lexical error at " ++ show_pos (position i))
    +       AlexSkip i' _ -> case get_tok of
    +                            ParserM f -> f i' st
    +       AlexToken i' l a -> case a $ take l $ ParserM.input i of
    +                               ParserM f -> f i' st
    +
    +lex_tok :: (Token -> ParserM a) -> ParserM a
    +lex_tok cont = get_tok >>= cont
    +
    +lexCppTokenStream :: String -> St -> Either String (AlexInput, St, [Token])
    +lexCppTokenStream s = unParserM go (AlexInput init_pos [] s)
    +    where
    +    go = do
    +      ltok <- lex_tok return
    +      case ltok of
    +        TEOF _ -> return []
    +        _ -> liftM (ltok:) go
    +}
    
    
    =====================================
    utils/check-cpp/Macro.hs
    =====================================
    @@ -0,0 +1,121 @@
    +module Macro where
    +
    +-- From https://gcc.gnu.org/onlinedocs/cpp/Macros.html
    +
    +{-
    +
    +A macro is a fragment of code which has been given a name. Whenever
    +the name is used, it is replaced by the contents of the macro. There
    +are two kinds of macros. They differ mostly in what they look like
    +when they are used. Object-like macros resemble data objects when
    +used, function-like macros resemble function calls.
    +
    +... the preprocessor operator `defined` can never be defined as a macro
    +
    +If the expansion of a macro contains its own name, either directly or
    +via intermediate macros, it is not expanded again when the expansion
    +is examined for more macros. See
    +https://gcc.gnu.org/onlinedocs/cpp/Self-Referential-Macros.html for
    +details
    +
    +-}
    +
    +-- TODO: Parse tokens with original locations in them.
    +
    +import qualified Data.Map as Map
    +import Data.Maybe
    +
    +import Eval
    +import Lexer
    +import Parse
    +import ParserM
    +import Types
    +
    +-- ---------------------------------------------------------------------
    +
    +process :: PpState -> Input -> (PpState, Output)
    +process s str = (s0, o)
    +  where
    +    o = case regularParse cppDirective str of
    +        Left _ -> undefined
    +        Right r -> r
    +    s0 = case o of
    +        CppDefine name toks -> define s name toks
    +        CppInclude _ -> undefined
    +        CppIfdef name -> ifdef s name
    +        CppIf toks -> cppIf s toks
    +        CppIfndef name -> ifndef s name
    +        CppElse -> undefined
    +        CppEndif -> undefined
    +
    +-- ---------------------------------------------------------------------
    +
    +define :: PpState -> String -> MacroDef -> PpState
    +define s name toks = s{pp_defines = Map.insert (MacroName name Nothing) toks (pp_defines s)}
    +
    +ifdef :: PpState -> String -> PpState
    +ifdef s name =
    +    case Map.lookup (MacroName name Nothing) (pp_defines s) of
    +        Just _ -> s{pp_accepting = True}
    +        _ -> s{pp_accepting = False}
    +
    +ifndef :: PpState -> String -> PpState
    +ifndef s name =
    +    case Map.lookup (MacroName name Nothing) (pp_defines s) of
    +        Just _ -> s{pp_accepting = False}
    +        _ -> s{pp_accepting = True}
    +
    +cppIf :: PpState -> [String] -> PpState
    +cppIf s toks = r
    +  where
    +    expanded = expand s (unwords toks)
    +    -- toks0 = cppLex expanded
    +    -- r = error (show toks0)
    +    v = case regularParse plusTimesExpr expanded of
    +        Left err -> error $ show err
    +        Right tree -> eval tree
    +    --    We evaluate to an Int, which we convert to a bool
    +    r = s{pp_accepting = toBool v}
    +
    +-- ---------------------------------------------------------------------
    +
    +cppLex :: String -> Either String [Token]
    +cppLex s = case lexCppTokenStream s init_state of
    +    Left err -> Left err
    +    Right (_inp, _st, toks) -> Right toks
    +
    +-- ---------------------------------------------------------------------
    +
    +expand :: PpState -> String -> String
    +expand s str = expanded
    +  where
    +    -- TODO: repeat until re-expand or fixpoint
    +    toks = case cppLex str of
    +        Left err -> error err
    +        Right tks -> tks
    +    expanded = unwords $ concatMap (expandOne s) toks
    +
    +expandOne :: PpState -> Token -> [String]
    +expandOne s tok = r
    +  where
    +    -- TODO: protect against looking up `define`
    +    r =
    +        fromMaybe
    +            [t_str tok]
    +            (Map.lookup (MacroName (t_str tok) Nothing) (pp_defines s))
    +
    +-- ---------------------------------------------------------------------
    +
    +m0 :: (PpState, Output)
    +m0 = do
    +    let (s0, _) = process initPpState "#define FOO 3"
    +    let (s1, _) = process s0 "#ifdef FOO"
    +    process s1 "# if FOO == 4"
    +
    +-- ---------------------------------------------------------------------
    +
    +m1 :: Either String [Token]
    +m1 = cppLex "`"
    +
    +m2 :: Either String [Token]
    +m2 = cppLex "hello(5)"
    
    
    =====================================
    utils/check-cpp/Main.hs
    =====================================
    @@ -26,7 +26,9 @@ import GHC.Utils.Error
     import GHC.Utils.Outputable
     import qualified Text.Parsec as Parsec
     
    +-- import ParseOld
     import Parse
    +import Types
     import ParseSimulate
     import PreProcess
     
    @@ -58,8 +60,8 @@ parseString libdir includes str = ghcWrapper libdir $ do
         return $ strGetToks includes pflags "fake_test_file.hs" str
     
     strGetToks :: Includes -> Lexer.ParserOpts -> FilePath -> String -> [Located Token]
    --- strGetToks includes popts filename str = reverse $ lexAll pstate
    -strGetToks includes popts filename str = reverse $ lexAll (trace ("pstate=" ++ show initState) pstate)
    +strGetToks includes popts filename str = reverse $ lexAll pstate
    +-- strGetToks includes popts filename str = reverse $ lexAll (trace ("pstate=" ++ show initState) pstate)
       where
         includeMap = Map.fromList $ map (\(k, v) -> (k, stringToStringBuffer (intercalate "\n" v))) includes
         initState = initPpState{pp_includes = includeMap}
    @@ -69,7 +71,8 @@ strGetToks includes popts filename str = reverse $ lexAll (trace ("pstate=" ++ s
         -- cpp_enabled = Lexer.GhcCppBit `Lexer.xtest` Lexer.pExtsBitmap popts
     
         lexAll state = case unP (ppLexerDbg True return) state of
    -        POk _ t@(L _ ITeof) -> [t]
    +        -- POk _ t@(L _ ITeof) -> [t]
    +        POk s t@(L _ ITeof) -> trace ("lexall end:s=" ++ show (Lexer.pp s)) [t]
             POk state' t -> t : lexAll state'
             -- (trace ("lexAll: " ++ show (unLoc t)) state')
             PFailed pst -> error $ "failed" ++ showErrorMessages (GHC.GhcPsMessage <$> GHC.getPsErrorMessages pst)
    @@ -299,3 +302,14 @@ testIncludes =
             , ["#define FOO"]
             )
         ]
    +
    +t11 :: IO ()
    +t11 = do
    +    doTest
    +        [ "#define FOO 4"
    +        , "#if FOO > 3"
    +        , "x = 1"
    +        , "#else"
    +        , "x = 5"
    +        , "#endif"
    +        ]
    
    
    =====================================
    utils/check-cpp/Parse.hs
    =====================================
    @@ -1,40 +1,82 @@
     module Parse where
     
     import Data.Char
    +
    +import Control.Monad (void)
    +import Data.Functor.Identity
    +import Debug.Trace
     import GHC.Parser.Errors.Ppr ()
    +import Text.Parsec
     import qualified Text.Parsec as Parsec
     import Text.Parsec.Char as PS
     import Text.Parsec.Combinator as PS
    -import Text.Parsec.Prim as PS
    -import Text.Parsec.String (Parser)
    +import qualified Text.Parsec.Expr as E
    +import Text.Parsec.Language (emptyDef)
    +import Text.Parsec.Prim as PS hiding (token)
    +import qualified Text.Parsec.Token as P
    +
    +import Types
    +
    +-- =====================================================================
    +-- First parse to CPP tokens, using a C++-like language spec
    +-- https://gcc.gnu.org/onlinedocs/cpp/Tokenization.html
     
    --- import Debug.Trace
    +lexer :: P.TokenParser ()
    +lexer = P.makeTokenParser exprDef
     
    +exprDef :: P.LanguageDef st
    +exprDef =
    +    emptyDef
    +        { P.commentStart = "/*"
    +        , P.commentEnd = "*/"
    +        , P.commentLine = "//"
    +        , P.nestedComments = False
    +        , P.identStart = letter <|> char '_'
    +        , P.identLetter = alphaNum <|> oneOf "_'"
    +        , P.opStart = P.opLetter exprDef
    +        , P.opLetter = oneOf ":!#$%&*+./<=>?@\\^|-~"
    +        , P.reservedOpNames = []
    +        , P.reservedNames = []
    +        , P.caseSensitive = True
    +        }
    +
    +-- =====================================================================
     -- ---------------------------------------------------------------------
     
    +-- type CppParser = Parsec String PpState
     type CppParser = Parsec String ()
     
    -regularParse :: Parser a -> String -> Either Parsec.ParseError a
    +parseDirective :: String -> Either Parsec.ParseError CppDirective
    +parseDirective = regularParse cppDirective
    +
    +regularParse :: CppParser a -> String -> Either Parsec.ParseError a
    +-- regularParse :: CppParser a -> String -> Either Parsec.ParseError (PpState, a)
     regularParse p = PS.parse p ""
     
    +-- regularParse :: CppParser a -> String -> Either Parsec.ParseError a
    +-- regularParse p str = do
    +--     case parsePpState initPpState p str of
    +--         Left e ->Left e
    +--         Right (_,r) -> Right r
    +
    +-- parsePpState :: PpState -> Parsec String PpState a -> String -> Either ParseError (PpState, a)
    +-- parsePpState s p = Parsec.runParser p' s "source"
    +--   where
    +--     p' = do
    +--         r <- p
    +--         s' <- Parsec.getState
    +--         return (s', r)
    +
     -- TODO: delete this
     cppDefinition :: CppParser (String, [String])
     cppDefinition = do
         _ <- PS.char '#'
         _ <- whiteSpace
    -    _ <- lexeme (PS.string "define")
    +    eToken "define"
         name <- cppToken
         definition <- cppTokens
         return (name, definition)
     
    -data CppDirective
    -    = CppInclude String
    -    | CppDefine String [String]
    -    | CppIfdef String
    -    | CppIfndef String
    -    | CppElse
    -    | CppEndif
    -    deriving (Show, Eq)
     
     cppDirective :: CppParser CppDirective
     cppDirective = do
    @@ -44,10 +86,10 @@ cppDirective = do
             [ cppKw "define" >> cmdDefinition
             , try $ cppKw "include" >> cmdInclude
             , try $ cppKw "ifdef" >> cmdIfdef
    -        , cppKw "ifndef" >> cmdIfndef
    +        , try $ cppKw "ifndef" >> cmdIfndef
    +        , try $ cppKw "if" >> cmdIf
             , try $ cppKw "else" >> return CppElse
             , cppKw "endif" >> return CppEndif
    -        -- , cppKw "if" CppIfKw
             -- , cppKw "elif" CppElifKw
             -- , cppKw "undef" CppUndefKw
             -- , cppKw "error" CppErrorKw
    @@ -63,23 +105,19 @@ cmdInclude = do
     cmdDefinition :: CppParser CppDirective
     cmdDefinition = do
         name <- cppToken
    -    definition <- cppTokens
    -    return $ CppDefine name definition
    +    CppDefine name <$> cppTokens
     
     cmdIfdef :: CppParser CppDirective
    -cmdIfdef = do
    -    name <- cppToken
    -    return $ CppIfdef name
    +cmdIfdef = CppIfdef <$> cppToken
     
     cmdIfndef :: CppParser CppDirective
    -cmdIfndef = do
    -    name <- cppToken
    -    return $ CppIfndef name
    +cmdIfndef = CppIfndef <$> cppToken
    +
    +cmdIf :: CppParser CppDirective
    +cmdIf = CppIf <$> cppTokens
     
     cppKw :: String -> CppParser ()
    -cppKw kw = do
    -    _ <- lexeme (PS.string kw)
    -    return ()
    +cppKw kw = void $ lexeme (PS.string kw)
     
     cppComment :: CppParser ()
     cppComment = do
    @@ -89,106 +127,144 @@ cppComment = do
     
     whiteSpace :: CppParser ()
     whiteSpace = do
    -    _ <- PS.many (PS.choice [cppComment, PS.space >> return ()])
    +    _ <- PS.many (PS.choice [cppComment, void PS.space])
         return ()
     
     lexeme :: CppParser a -> CppParser a
     lexeme p = p <* whiteSpace
     
     cppToken :: CppParser String
    -cppToken = lexeme (PS.many1 (PS.satisfy (\c -> not (isSpace c))))
    +cppToken = lexeme (PS.many1 (PS.satisfy (not . isSpace)))
     
     cppTokens :: CppParser [String]
     cppTokens = PS.many cppToken
     
    +-- token :: String -> CppParser ()
    +-- token str = do
    +--     _ <- lexeme (PS.string str)
    +--     return ()
    +
     -- ---------------------------------------------------------------------
    --- import GHC.S.Types
    -
    --- parseS :: String -> Either ParseError S
    --- parseS = parse expr ""
    -
    --- lexer :: P.TokenParser ()
    --- lexer =
    ---     P.makeTokenParser
    ---         ( emptyDef
    ---             { P.reservedNames =
    ---                 [ "define"
    ---                 , "include"
    ---                 , "undef"
    ---                 , "error"
    ---                 , "ifdef"
    ---                 , "ifndef"
    ---                 , "if"
    ---                 , "elif"
    ---                 , "else"
    ---                 , "endif"
    ---                 ]
    ---             }
    ---         )
    -
    --- slam :: Parser S
    --- slam = P.parens lexer $ do
    ---     P.reserved lexer "lam"
    ---     ident <- P.identifier lexer
    ---     body <- expr
    ---     return (SLam (Atom ident) body)
    -
    --- slet :: Parser S
    --- slet = P.parens lexer $ do
    ---     P.reserved lexer "let"
    ---     (ident, e1) <- P.parens lexer $ do
    ---         idnt <- P.identifier lexer
    ---         expr1 <- expr
    ---         return (idnt, expr1)
    ---     e2 <- expr
    ---     return (SLet (Atom ident) e1 e2)
    -
    --- sletrec :: Parser S
    --- sletrec = P.parens lexer $ do
    ---     P.reserved lexer "letrec"
    ---     ls <- P.parens lexer $ many1 $ P.parens lexer $ do
    ---         idnt <- P.identifier lexer
    ---         expr1 <- expr
    ---         return (Atom idnt, expr1)
    ---     e2 <- expr
    ---     return (SLetRec ls e2)
    -
    --- scase :: Parser S
    --- scase = P.parens lexer $ do
    ---     P.reserved lexer "case"
    ---     e <- expr
    ---     alt <- optionMaybe (P.identifier lexer)
    ---     alts <- P.parens lexer $ many1 $ P.parens lexer $ do
    ---         pat <- expr
    ---         ex <- expr
    ---         return (pat, ex)
    ---     case alt of
    ---         Just alt -> return (SCase (Atom alt) e alts)
    ---         Nothing -> return (SCase (Atom "_") e alts)
    -
    --- swild :: Parser S
    --- swild = do
    ---     P.symbol lexer "_"
    ---     return SWild
    -
    --- sbinop :: Parser S
    --- sbinop = P.parens lexer $ do
    ---     e1 <- expr
    ---     op <- P.operator lexer
    ---     e2 <- expr
    ---     return (SBinOp (Atom op) e1 e2)
    -
    --- expr :: Parser S
    --- expr =
    ---     choice
    ---         [ try slam
    ---         , try sbinop
    ---         , try slet
    ---         , try sletrec
    ---         , try scase
    ---         , STuple <$> P.parens lexer (many expr)
    ---         , swild
    ---         , SAtom <$> (Atom <$> (P.identifier lexer))
    ---         , SString <$> P.stringLiteral lexer
    ---         , SInt <$> P.integer lexer
    ---         ]
    +-- Expression language
    +-- NOTE: need to take care of macro expansion while parsing. Or perhaps before?
    +
    +
    +data Expr
    +    = Parens Expr
    +    | Var String
    +    | IntVal Int
    +    | Plus Expr Expr
    +    | Times Expr Expr
    +    | BinOp Op Expr Expr
    +    deriving (Show)
    +
    +data Op
    +    = LogicalOr
    +    | LogicalAnd
    +    | CmpEqual
    +    | CmpGt
    +    | CmpGtE
    +    | CmpLt
    +    | CmpLtE
    +    deriving (Show)
    +
    +-- -------------------------------------
    +
    +plusTimesExpr :: CppParser Expr
    +plusTimesExpr = E.buildExpressionParser eTable eTerm
    +
    +eTable :: [[E.Operator String () Data.Functor.Identity.Identity Expr]]
    +eTable =
    +    -- Via https://learn.microsoft.com/en-us/cpp/cpp/cpp-built-in-operators-precedence-and-associativity?view=msvc-170
    +    [ [E.Infix (Times <$ symbol "*") E.AssocLeft]
    +    , [E.Infix (Plus <$ symbol "+") E.AssocLeft]
    +    ,
    +        [ E.Infix (try $ BinOp CmpLtE <$ symbol "<=") E.AssocLeft
    +        , E.Infix (try $ BinOp CmpGtE <$ symbol ">=") E.AssocLeft
    +        , E.Infix (BinOp CmpLt <$ symbol "<") E.AssocLeft
    +        , E.Infix (BinOp CmpGt <$ symbol ">") E.AssocLeft
    +        ]
    +    , [E.Infix (BinOp CmpEqual <$ symbol "==") E.AssocLeft]
    +    , [E.Infix (BinOp LogicalAnd <$ symbol "&&") E.AssocLeft]
    +    , [E.Infix (BinOp LogicalOr <$ symbol "||") E.AssocLeft]
    +    ]
    +
    +eTerm :: CppParser Expr
    +eTerm =
    +    eVariable -- <|> pteNum
    +        <|> pteParens
    +        <|> eInteger
    +
    +pteParens :: CppParser Expr
    +pteParens = Parens <$> between (symbol "(") (symbol ")") plusTimesExpr
    +
    +symbol :: String -> CppParser String
    +symbol s = lexeme $ string s
    +
    +-- -------------------------------------
    +
    +eExpr :: CppParser Expr
    +eExpr = choice [eParens, eBinOp, eVariable]
    +
    +eParens :: CppParser Expr
    +eParens = P.parens lexer $ do
    +    Parens <$> eExpr
    +
    +eBinOp :: CppParser Expr
    +eBinOp = do
    +    e1 <- eExpr
    +    op <- eOp
    +    -- _ <- cppToken
    +    -- let op = Or
    +    BinOp op e1 <$> eExpr
    +
    +eOp :: CppParser Op
    +eOp = do
    +    -- op <- P.operator lexer
    +    op <- P.operator (trace "foo" lexer)
    +    return $ trace ("op=" ++ show op) LogicalOr
    +
    +eVariable :: CppParser Expr
    +eVariable = do
    +    v <- P.identifier lexer
    +    return $ Var v
    +
    +eToken :: String -> CppParser ()
    +eToken = P.reserved lexer
    +
    +eInteger :: CppParser Expr
    +eInteger = IntVal <$> integer
    +
    +integer :: CppParser Int
    +integer = read <$> lexeme (many1 digit)
    +
    +-- ---------------------------------------------------------------------
    +
    +doATest :: String -> Either Parsec.ParseError CppDirective
    +doATest str = regularParse cppDirective str
    +
    +t0 :: Either Parsec.ParseError CppDirective
    +t0 = doATest "#define FOO(m1,m2,m) ((m1) <  1 || (m1) == 1 && (m2) <  7 || (m1) == 1 && (m2) == 7 && (m) <= 0)"
    +
    +t1 :: Either Parsec.ParseError Expr
    +t1 = regularParse plusTimesExpr "(m < 1)"
    +
    +t2 :: Either Parsec.ParseError Expr
    +t2 = regularParse plusTimesExpr "((m1) <  1 || (m1) == 1 && (m2) <  7 || (m1) == 1 && (m2) == 7 && (m) <= 0)"
    +
    +-- (Parens
    +--  (BinOp LogicalOr
    +--         (BinOp LogicalOr
    +--                (BinOp CmpLt (Parens (Var "m1")) (IntVal 1))
    +--                (BinOp LogicalAnd
    +--                       (BinOp CmpEqual (Parens (Var "m1")) (IntVal 1))
    +--                       (BinOp CmpLt (Parens (Var "m2")) (IntVal 7))))
    +--         (BinOp LogicalAnd
    +--                (BinOp LogicalAnd
    +--                       (BinOp CmpEqual (Parens (Var "m1")) (IntVal 1))
    +--                       (BinOp CmpEqual (Parens (Var "m2")) (IntVal 7)))
    +--                (BinOp CmpLtE (Parens (Var "m")) (IntVal 0)))))
    +
    +
    +t3 :: Either ParseError CppDirective
    +t3 = regularParse cppDirective "# if FOO == 4"
    
    
    =====================================
    utils/check-cpp/ParseOld.hs
    =====================================
    @@ -0,0 +1,249 @@
    +module ParseOld where
    +
    +import Data.Char
    +
    +import Data.Functor.Identity
    +import GHC.Parser.Errors.Ppr ()
    +import Text.Parsec
    +import qualified Text.Parsec as Parsec
    +import Text.Parsec.Char as PS
    +import Text.Parsec.Combinator as PS
    +import qualified Text.Parsec.Expr as E
    +import Text.Parsec.Language (emptyDef)
    +import Text.Parsec.Prim as PS hiding (token)
    +import Text.Parsec.String
    +
    +-- import Text.Parsec.String (Parser)
    +import qualified Text.Parsec.Token as P
    +
    +import Debug.Trace
    +
    +-- ---------------------------------------------------------------------
    +
    +type CppParser = Parsec String ()
    +
    +regularParse :: Parser a -> String -> Either Parsec.ParseError a
    +regularParse p = PS.parse p ""
    +
    +-- TODO: delete this
    +cppDefinition :: CppParser (String, [String])
    +cppDefinition = do
    +    _ <- PS.char '#'
    +    _ <- whiteSpace
    +    eToken "define"
    +    name <- cppToken
    +    definition <- cppTokens
    +    return (name, definition)
    +
    +data CppDirective
    +    = CppInclude String
    +    | CppDefine String [String]
    +    | CppIfdef String
    +    | CppIfndef String
    +    | CppElse
    +    | CppEndif
    +    deriving (Show, Eq)
    +
    +cppDirective :: CppParser CppDirective
    +cppDirective = do
    +    _ <- PS.char '#'
    +    _ <- whiteSpace
    +    choice
    +        [ cppKw "define" >> cmdDefinition
    +        , try $ cppKw "include" >> cmdInclude
    +        , try $ cppKw "ifdef" >> cmdIfdef
    +        , cppKw "ifndef" >> cmdIfndef
    +        , try $ cppKw "else" >> return CppElse
    +        , cppKw "endif" >> return CppEndif
    +        -- , cppKw "if" CppIfKw
    +        -- , cppKw "elif" CppElifKw
    +        -- , cppKw "undef" CppUndefKw
    +        -- , cppKw "error" CppErrorKw
    +        ]
    +
    +cmdInclude :: CppParser CppDirective
    +cmdInclude = do
    +    _ <- string "\""
    +    filename <- many1 (satisfy (\c -> not (isSpace c || c == '"')))
    +    _ <- string "\""
    +    return $ CppInclude filename
    +
    +cmdDefinition :: CppParser CppDirective
    +cmdDefinition = do
    +    name <- cppToken
    +    definition <- cppTokens
    +    return $ CppDefine name definition
    +
    +cmdIfdef :: CppParser CppDirective
    +cmdIfdef = do
    +    name <- cppToken
    +    return $ CppIfdef name
    +
    +cmdIfndef :: CppParser CppDirective
    +cmdIfndef = do
    +    name <- cppToken
    +    return $ CppIfndef name
    +
    +cppKw :: String -> CppParser ()
    +cppKw kw = do
    +    _ <- lexeme (PS.string kw)
    +    return ()
    +
    +cppComment :: CppParser ()
    +cppComment = do
    +    _ <- PS.string "/*"
    +    _ <- PS.manyTill PS.anyChar (PS.try (PS.string "*/"))
    +    return ()
    +
    +whiteSpace :: CppParser ()
    +whiteSpace = do
    +    _ <- PS.many (PS.choice [cppComment, PS.space >> return ()])
    +    return ()
    +
    +lexeme :: CppParser a -> CppParser a
    +lexeme p = p <* whiteSpace
    +
    +cppToken :: CppParser String
    +cppToken = lexeme (PS.many1 (PS.satisfy (\c -> not (isSpace c))))
    +
    +cppTokens :: CppParser [String]
    +cppTokens = PS.many cppToken
    +
    +-- token :: String -> CppParser ()
    +-- token str = do
    +--     _ <- lexeme (PS.string str)
    +--     return ()
    +
    +-- ---------------------------------------------------------------------
    +-- Expression language
    +-- NOTE: need to take care of macro expansion while parsing. Or perhaps before?
    +
    +lexer :: P.TokenParser ()
    +lexer = P.makeTokenParser exprDef
    +
    +exprDef :: P.LanguageDef st
    +exprDef =
    +    emptyDef
    +        { P.commentStart = "/*"
    +        , P.commentEnd = "*/"
    +        , P.commentLine = "//"
    +        , P.nestedComments = False
    +        , P.identStart = letter <|> char '_'
    +        , P.identLetter = alphaNum <|> oneOf "_'"
    +        , P.opStart = P.opLetter exprDef
    +        , P.opLetter = oneOf ":!#$%&*+./<=>?@\\^|-~"
    +        , P.reservedOpNames = []
    +        , P.reservedNames = []
    +        , P.caseSensitive = True
    +        }
    +
    +data Expr
    +    = Parens Expr
    +    | Var String
    +    | IntVal Int
    +    | Plus Expr Expr
    +    | Times Expr Expr
    +    | BinOp Op Expr Expr
    +    deriving (Show)
    +
    +data Op
    +    = Or
    +    | And
    +    | CmpEqual
    +    | CmpGt
    +    | CmpGtE
    +    | CmpLt
    +    | CmpLtE
    +    deriving (Show)
    +
    +-- -------------------------------------
    +
    +plusTimesExpr :: CppParser Expr
    +plusTimesExpr = E.buildExpressionParser eTable eTerm
    +
    +eTable :: [[E.Operator String () Data.Functor.Identity.Identity Expr]]
    +eTable =
    +    [ [E.Infix (Times <$ symbol "*") E.AssocLeft]
    +    , [E.Infix (Plus <$ symbol "+") E.AssocLeft]
    +    , [E.Infix (BinOp CmpLt <$ symbol "<") E.AssocLeft]
    +    ]
    +
    +eTerm :: CppParser Expr
    +eTerm = eVariable -- <|> pteNum
    +        <|> pteParens
    +        <|> eInteger
    +
    +pteParens :: CppParser Expr
    +pteParens = Parens <$> between (symbol "(") (symbol ")") plusTimesExpr
    +
    +symbol :: String -> CppParser String
    +symbol s = lexeme $ string s
    +
    +-- expr    = E.buildExpressionParser table term
    +--           "expression"
    +
    +-- term    =  parens expr
    +--          <|> natural
    +--           "simple expression"
    +
    +-- table   = [ [prefix "-" negate, prefix "+" id ]
    +--            , [postfix "++" (+1)]
    +--            , [binary "*" (*) AssocLeft, binary "/" (div) AssocLeft ]
    +--            , [binary "+" (+) AssocLeft, binary "-" (-)   AssocLeft ]
    +--            ]
    +
    +-- binary  name fun assoc = Infix (do{ reservedOp name; return fun }) assoc
    +-- prefix  name fun       = Prefix (do{ reservedOp name; return fun })
    +-- postfix name fun       = Postfix (do{ reservedOp name; return fun })
    +
    +-- -------------------------------------
    +
    +eExpr :: CppParser Expr
    +eExpr = choice [eParens, eBinOp, eVariable]
    +
    +eParens :: CppParser Expr
    +eParens = P.parens lexer $ do
    +    e <- eExpr
    +    return $ Parens e
    +
    +eBinOp :: CppParser Expr
    +eBinOp = do
    +    e1 <- eExpr
    +    op <- eOp
    +    -- _ <- cppToken
    +    -- let op = Or
    +    e2 <- eExpr
    +    return $ BinOp op e1 e2
    +
    +eOp :: CppParser Op
    +eOp = do
    +    -- op <- P.operator lexer
    +    op <- P.operator (trace "foo" lexer)
    +    return $ trace ("op=" ++ show op) Or
    +
    +eVariable :: CppParser Expr
    +eVariable = do
    +    v <- P.identifier lexer
    +    return $ Var v
    +
    +eToken :: String -> CppParser ()
    +eToken str = P.reserved lexer str
    +
    +eInteger :: Parser Expr
    +eInteger = IntVal <$> integer
    +
    +integer :: Parser Int
    +integer = read <$> lexeme (many1 digit)
    +
    +-- ---------------------------------------------------------------------
    +
    +doATest :: String -> Either Parsec.ParseError CppDirective
    +doATest str =
    +    regularParse cppDirective str
    +
    +t0 :: Either Parsec.ParseError CppDirective
    +t0 = doATest "#define FOO(m1,m2,m) ((m1) <  1 || (m1) == 1 && (m2) <  7 || (m1) == 1 && (m2) == 7 && (m) <= 0)"
    +
    +t1 :: Either Parsec.ParseError Expr
    +-- t1 = regularParse eExpr "(m < 1)"
    +t1 = regularParse plusTimesExpr "(m < 1)"
    
    
    =====================================
    utils/check-cpp/ParserM.hs
    =====================================
    @@ -0,0 +1,254 @@
    +{-# LANGUAGE BinaryLiterals #-}
    +
    +module ParserM (
    +    -- Parser Monad
    +    ParserM (..),
    +    AlexInput (..),
    +    run_parser,
    +    -- Parser state
    +    St,
    +    init_state,
    +    StartCode,
    +    start_code,
    +    setStartCode,
    +    -- Tokens
    +    Token (..),
    +    -- Actions
    +    Action,
    +    andBegin,
    +    mkT,
    +    mkTv,
    +    -- Positions
    +    init_pos,
    +    get_pos,
    +    show_pos,
    +    -- Input
    +    alexGetByte,
    +    alexInputPrevChar,
    +    -- Other
    +    happyError,
    +) where
    +
    +import Control.Applicative
    +
    +import Control.Monad.Fail (MonadFail (..))
    +import Prelude hiding (fail)
    +
    +import Control.Monad (ap, liftM)
    +import Data.Bits (shiftR, (.&.), (.|.))
    +import Data.Char (ord)
    +import Data.Word (Word8)
    +
    +-- Parser Monad
    +newtype ParserM a = ParserM {unParserM :: AlexInput -> St -> Either String (AlexInput, St, a)}
    +
    +-- newtype P a       = P     { unP :: PState -> ParseResult a }
    +
    +instance Functor ParserM where
    +    fmap = liftM
    +
    +instance Applicative ParserM where
    +    pure a = ParserM $ \i s -> Right (i, s, a)
    +    (<*>) = ap
    +
    +instance Monad ParserM where
    +    ParserM m >>= k = ParserM $ \i s -> case m i s of
    +        Right (i', s', x) ->
    +            case k x of
    +                ParserM y -> y i' s'
    +        Left err ->
    +            Left err
    +
    +instance MonadFail ParserM where
    +    fail err = ParserM $ \_ _ -> Left err
    +
    +run_parser :: ParserM a -> (String -> Either String a)
    +run_parser (ParserM f) =
    +    \s -> case f (AlexInput init_pos [] s) init_state of
    +        Left es -> Left es
    +        Right (_, _, x) -> Right x
    +
    +-- Parser state
    +
    +data St = St
    +    { start_code :: !StartCode
    +    , brace_depth :: !Int
    +    }
    +    deriving (Show)
    +type StartCode = Int
    +
    +init_state :: St
    +init_state =
    +    St
    +        { start_code = 0
    +        , brace_depth = 0
    +        }
    +
    +-- Tokens
    +
    +data Token
    +    = TEOF {t_str :: String}
    +    | TOpenBrace {t_str :: String}
    +    | TCloseBrace {t_str :: String}
    +    | TOpenBracket {t_str :: String}
    +    | TCloseBracket {t_str :: String}
    +    | THash {t_str :: String}
    +    | THashHash {t_str :: String}
    +    | TOpenParen {t_str :: String}
    +    | TCloseParen {t_str :: String}
    +    | TLtColon {t_str :: String}
    +    | TColonGt {t_str :: String}
    +    | TLtPercent {t_str :: String}
    +    | TPercentGt {t_str :: String}
    +    | TPercentColon {t_str :: String}
    +    | TPercentColonTwice {t_str :: String}
    +    | TSemi {t_str :: String}
    +    | TColon {t_str :: String}
    +    | TDotDotDot {t_str :: String}
    +    | TNew {t_str :: String}
    +    | TDelete {t_str :: String}
    +    | TQuestion {t_str :: String}
    +    | TColonColon {t_str :: String}
    +    | TDot {t_str :: String}
    +    | TDotStar {t_str :: String}
    +    | TPlus {t_str :: String}
    +    | TMinus {t_str :: String}
    +    | TStar {t_str :: String}
    +    | TSlash {t_str :: String}
    +    | TPercent {t_str :: String}
    +    | TUpArrow {t_str :: String}
    +    | TAmpersand {t_str :: String}
    +    | TPipe {t_str :: String}
    +    | TTilde {t_str :: String}
    +    | TExclamation {t_str :: String}
    +    | TEqual {t_str :: String}
    +    | TOpenAngle {t_str :: String}
    +    | TCloseAngle {t_str :: String}
    +    | TPlusEqual {t_str :: String}
    +    | TMinusEqual {t_str :: String}
    +    | TStarEqual {t_str :: String}
    +    | TSlashEqual {t_str :: String}
    +    | TPercentEqual {t_str :: String}
    +    | TUpEqual {t_str :: String}
    +    | TAmpersandEqual {t_str :: String}
    +    | TPipeEqual {t_str :: String}
    +    | TLtLt {t_str :: String}
    +    | TGtGt {t_str :: String}
    +    | TGtGtEqual {t_str :: String}
    +    | TLtLtEqual {t_str :: String}
    +    | TEqualEqual {t_str :: String}
    +    | TExclaimEqual {t_str :: String}
    +    | TLtEqual {t_str :: String}
    +    | TGtEqual {t_str :: String}
    +    | TAmpersandTwice {t_str :: String}
    +    | TPipePipe {t_str :: String}
    +    | TPlusPlus {t_str :: String}
    +    | TMinusMinus {t_str :: String}
    +    | TComma {t_str :: String}
    +    | TMinusGtStar {t_str :: String}
    +    | TMinusGt {t_str :: String}
    +    | TAnd {t_str :: String}
    +    | TAndEq {t_str :: String}
    +    | TBitand {t_str :: String}
    +    | TBitor {t_str :: String}
    +    | TCompl {t_str :: String}
    +    | TNot {t_str :: String}
    +    | TNotEq {t_str :: String}
    +    | TOr {t_str :: String}
    +    | TOrEq {t_str :: String}
    +    | TXor {t_str :: String}
    +    | TXorEq {t_str :: String}
    +    | TLowerName {t_str :: String}
    +    | TUpperName {t_str :: String}
    +    | TString {t_str :: String}
    +    | TInteger {t_str :: String}
    +    | TOther {t_str :: String}
    +    deriving (Show)
    +
    +-- Actions
    +
    +type Action = String -> ParserM Token
    +
    +setStartCode :: StartCode -> ParserM ()
    +setStartCode sc = ParserM $ \i st -> Right (i, st{start_code = sc}, ())
    +
    +andBegin :: Action -> StartCode -> Action
    +(act `andBegin` sc) x = do
    +    setStartCode sc
    +    act x
    +
    +mkT :: Token -> Action
    +mkT t = mkTv (const t)
    +
    +mkTv :: (String -> Token) -> Action
    +mkTv f str = ParserM (\i st -> Right (i, st, f str))
    +
    +-- begin :: Int -> Action
    +-- begin sc _span _buf _len _buf2 =
    +--   do setStartCode sc
    +--      lex_tok
    +
    +-- Positions
    +
    +data Pos = Pos !Int {- Line -} !Int {- Column -}
    +    deriving (Show)
    +
    +get_pos :: ParserM Pos
    +get_pos = ParserM $ \i@(AlexInput p _ _) st -> Right (i, st, p)
    +
    +alexMove :: Pos -> Char -> Pos
    +alexMove (Pos l _) '\n' = Pos (l + 1) 1
    +alexMove (Pos l c) '\t' = Pos l ((c + 8) `div` 8 * 8)
    +alexMove (Pos l c) _ = Pos l (c + 1)
    +
    +init_pos :: Pos
    +init_pos = Pos 1 0
    +
    +show_pos :: Pos -> String
    +show_pos (Pos l c) = "line " ++ show l ++ ", column " ++ show c
    +
    +-- Input
    +
    +data AlexInput = AlexInput
    +    { position :: !Pos
    +    , char_bytes :: [Word8]
    +    , input :: String
    +    }
    +    deriving (Show)
    +
    +alexGetByte :: AlexInput -> Maybe (Word8, AlexInput)
    +alexGetByte (AlexInput p (w : ws) cs) =
    +    Just (w, AlexInput p ws cs)
    +alexGetByte (AlexInput p [] (c : cs)) =
    +    alexGetByte (AlexInput (alexMove p c) (utf8_encode c) cs)
    +alexGetByte (AlexInput _ [] []) =
    +    Nothing
    +
    +-- annoyingly, this doesn't seem to exist anywhere else as a standalone function
    +utf8_encode :: Char -> [Word8]
    +utf8_encode c = case ord c of
    +    n
    +        | n < 0x80 -> [fromIntegral n]
    +        | n < 0x800 ->
    +            [ fromIntegral $ 0b11000000 .|. (n `shiftR` 6)
    +            , fromIntegral $ 0b10000000 .|. (n .&. 0b111111)
    +            ]
    +        | n < 0x10000 ->
    +            [ fromIntegral $ 0b11100000 .|. (n `shiftR` 12)
    +            , fromIntegral $ 0b10000000 .|. ((n `shiftR` 6) .&. 0b111111)
    +            , fromIntegral $ 0b10000000 .|. (n .&. 0b111111)
    +            ]
    +        | otherwise ->
    +            [ fromIntegral $ 0b11110000 .|. (n `shiftR` 18)
    +            , fromIntegral $ 0b10000000 .|. ((n `shiftR` 12) .&. 0b111111)
    +            , fromIntegral $ 0b10000000 .|. ((n `shiftR` 6) .&. 0b111111)
    +            , fromIntegral $ 0b10000000 .|. (n .&. 0b111111)
    +            ]
    +
    +alexInputPrevChar :: AlexInput -> Char
    +alexInputPrevChar _ = error "Lexer doesn't implement alexInputPrevChar"
    +
    +happyError :: ParserM a
    +happyError = do
    +    p <- get_pos
    +    fail $ "Parse error at " ++ show_pos p
    
    
    =====================================
    utils/check-cpp/PreProcess.hs
    =====================================
    @@ -14,32 +14,36 @@ import GHC.Types.SrcLoc
     
     import Debug.Trace
     
    +import Macro
    +
    +-- import ParseOld
     import Parse
    +import Types
     
     -- ---------------------------------------------------------------------
     
     type PP = P PpState
     
    -initPpState :: PpState
    -initPpState =
    -    PpState
    -        { pp_defines = Map.empty
    -        , pp_includes = Map.empty
    -        , pp_include_stack = []
    -        , pp_continuation = []
    -        , pp_context = []
    -        , pp_accepting = True
    -        }
    -
    -data PpState = PpState
    -    { pp_defines :: !(Map String [String])
    -    , pp_includes :: !(Map String StringBuffer)
    -    , pp_include_stack :: ![Lexer.AlexInput]
    -    , pp_continuation :: ![Located Token]
    -    , pp_context :: ![Token] -- What preprocessor directive we are currently processing
    -    , pp_accepting :: !Bool
    -    }
    -    deriving (Show)
    +-- initPpState :: PpState
    +-- initPpState =
    +--     PpState
    +--         { pp_defines = Map.empty
    +--         , pp_includes = Map.empty
    +--         , pp_include_stack = []
    +--         , pp_continuation = []
    +--         , pp_context = []
    +--         , pp_accepting = True
    +--         }
    +
    +-- data PpState = PpState
    +--     { pp_defines :: !(Map String [String])
    +--     , pp_includes :: !(Map String StringBuffer)
    +--     , pp_include_stack :: ![Lexer.AlexInput]
    +--     , pp_continuation :: ![Located Token]
    +--     , pp_context :: ![Token] -- What preprocessor directive we are currently processing
    +--     , pp_accepting :: !Bool
    +--     }
    +--     deriving (Show)
     
     -- deriving instance Show Lexer.AlexInput
     -- ---------------------------------------------------------------------
    @@ -124,6 +128,9 @@ processCpp fs = do
                 ppInclude filename
             Right (CppDefine name def) -> do
                 ppDefine name def
    +        Right (CppIf cond) -> do
    +            ppIf cond
    +            return ()
             Right (CppIfdef name) -> do
                 defined <- ppIsDefined name
                 setAccepting defined
    @@ -237,12 +244,21 @@ ppInclude filename = do
     ppDefine :: String -> [String] -> PP ()
     ppDefine name val = P $ \s ->
         -- POk s{pp = (pp s){pp_defines = Set.insert (cleanTokenString def) (pp_defines (pp s))}} ()
    -    POk s{pp = (pp s){pp_defines = Map.insert (trace ("ppDefine:def=[" ++ name ++ "]") name) val (pp_defines (pp s))}} ()
    +    POk s{pp = (pp s){pp_defines = Map.insert (trace ("ppDefine:def=[" ++ name ++ "]") (MacroName name Nothing)) val (pp_defines (pp s))}} ()
     
     ppIsDefined :: String -> PP Bool
     ppIsDefined def = P $ \s ->
         -- POk s (Map.member def (pp_defines (pp s)))
    -    POk s (Map.member (trace ("ppIsDefined:def=[" ++ def ++ "]") def) (pp_defines (pp s)))
    +    POk s (Map.member (trace ("ppIsDefined:def=[" ++ def ++ "]") (MacroName def Nothing)) (pp_defines (pp s)))
    +
    +ppIf :: [String] -> PP Bool
    +ppIf toks = P $ \s ->
    +    -- -- POk s (Map.member def (pp_defines (pp s)))
    +    -- POk s (Map.member (trace ("ppIsDefined:def=[" ++ def ++ "]") def) (pp_defines (pp s)))
    +    let
    +        s' = cppIf (pp s) toks
    +     in
    +        POk s{pp = s'} (pp_accepting s')
     
     -- | Take a @FastString@ of the form "#define FOO\n" and strip off all but "FOO"
     cleanTokenString :: FastString -> String
    
    
    =====================================
    utils/check-cpp/README.md
    =====================================
    @@ -0,0 +1,8 @@
    +
    +Until the build works properly. do
    +
    +```
    +alex Lexer.x
    +```
    +
    +in this directory to make the lexer.
    
    
    =====================================
    utils/check-cpp/Types.hs
    =====================================
    @@ -0,0 +1,63 @@
    +module Types where
    +
    +import GHC.Parser.Lexer (Token (..))
    +import GHC.Types.SrcLoc
    +import qualified GHC.Parser.Lexer as Lexer
    +import GHC.Data.StringBuffer
    +
    +import Data.Map (Map)
    +import qualified Data.Map as Map
    +
    +-- ---------------------------------------------------------------------
    +
    +initPpState :: PpState
    +initPpState =
    +    PpState
    +        { pp_defines = Map.empty
    +        , pp_includes = Map.empty
    +        , pp_include_stack = []
    +        , pp_continuation = []
    +        , pp_context = []
    +        , pp_accepting = True
    +        }
    +
    +data PpState = PpState
    +    { pp_defines :: !(Map MacroName MacroDef)
    +    , pp_includes :: !(Map String StringBuffer)
    +    , pp_include_stack :: ![Lexer.AlexInput]
    +    , pp_continuation :: ![Located Token]
    +    , pp_context :: ![Token] -- What preprocessor directive we are currently processing
    +    , pp_accepting :: !Bool
    +    }
    +    deriving (Show)
    +
    +-- ---------------------------------------------------------------------
    +
    +data CppDirective
    +    = CppInclude String
    +    | CppDefine String [String]
    +    | CppIfdef String
    +    | CppIfndef String
    +    | CppIf [String]
    +    | CppElse
    +    | CppEndif
    +    deriving (Show, Eq)
    +
    +-- ---------------------------------------------------------------------
    +
    +type MacroArgs = [String]
    +data MacroName = MacroName String (Maybe MacroArgs)
    +    deriving (Show, Eq, Ord)
    +type MacroDef = [String]
    +
    +-- data PpState = PpState
    +--     { pp_defines :: !(Map MacroName MacroDef)
    +--     , pp_accepting :: !Bool
    +--     }
    +--     deriving (Show, Eq)
    +
    +-- initPpState :: PpState
    +-- initPpState = PpState{pp_defines = Map.empty, pp_accepting = True}
    +
    +type Input = String
    +type Output = CppDirective
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c7e0f6989772855c535829f761e60ae396843dd...01f6c1eb7cf6fbb55d902f3d76f0a2b2707d2741
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c7e0f6989772855c535829f761e60ae396843dd...01f6c1eb7cf6fbb55d902f3d76f0a2b2707d2741
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 26 10:24:20 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Thu, 26 Oct 2023 06:24:20 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: testsuite:
     increase timeout of ghc-api tests for wasm32
    Message-ID: <653a3e54491c8_1f7b0d842a1d5c595566@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    cb17578f by Greg Steuck at 2023-10-26T06:24:01-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    461aa625 by Sylvain Henry at 2023-10-26T06:24:13-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    
    
    10 changed files:
    
    - compiler/GHC/Driver/Config/Linker.hs
    - compiler/GHC/Linker/Config.hs
    - compiler/GHC/Linker/Dynamic.hs
    - + compiler/GHC/Linker/External.hs
    - compiler/GHC/Linker/Static.hs
    - compiler/GHC/SysTools/Tasks.hs
    - compiler/ghc.cabal.in
    - rts/posix/OSMem.c
    - testsuite/tests/ghc-api/all.T
    - testsuite/tests/ghc-api/downsweep/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Driver/Config/Linker.hs
    =====================================
    @@ -1,13 +1,93 @@
     module GHC.Driver.Config.Linker
       ( initFrameworkOpts
    -  ) where
    +  , initLinkerConfig
    +  )
    +where
     
    +import GHC.Prelude
    +import GHC.Platform
     import GHC.Linker.Config
     
     import GHC.Driver.DynFlags
    +import GHC.Driver.Session
    +
    +import Data.List (isPrefixOf)
     
     initFrameworkOpts :: DynFlags -> FrameworkOpts
     initFrameworkOpts dflags = FrameworkOpts
       { foFrameworkPaths    = frameworkPaths    dflags
       , foCmdlineFrameworks = cmdlineFrameworks dflags
       }
    +
    +-- | Initialize linker configuration from DynFlags
    +initLinkerConfig :: DynFlags -> LinkerConfig
    +initLinkerConfig dflags =
    +  let
    +    -- see Note [Solaris linker]
    +    ld_filter = case platformOS (targetPlatform dflags) of
    +                  OSSolaris2 -> sunos_ld_filter
    +                  _          -> id
    +    sunos_ld_filter :: String -> String
    +    sunos_ld_filter = unlines . sunos_ld_filter' . lines
    +    sunos_ld_filter' x = if (undefined_found x && ld_warning_found x)
    +                          then (ld_prefix x) ++ (ld_postfix x)
    +                          else x
    +    breakStartsWith x y = break (isPrefixOf x) y
    +    ld_prefix = fst . breakStartsWith "Undefined"
    +    undefined_found = not . null . snd . breakStartsWith "Undefined"
    +    ld_warn_break = breakStartsWith "ld: warning: symbol referencing errors"
    +    ld_postfix = tail . snd . ld_warn_break
    +    ld_warning_found = not . null . snd . ld_warn_break
    +
    +    -- program and arguments
    +    --
    +    -- `-optl` args come at the end, so that later `-l` options
    +    -- given there manually can fill in symbols needed by
    +    -- Haskell libraries coming in via `args`.
    +    (p,pre_args) = pgm_l dflags
    +    post_args    = map Option (getOpts dflags opt_l)
    +
    +  in LinkerConfig
    +    { linkerProgram     = p
    +    , linkerOptionsPre  = pre_args
    +    , linkerOptionsPost = post_args
    +    , linkerTempDir     = tmpDir dflags
    +    , linkerFilter      = ld_filter
    +    }
    +
    +{- Note [Solaris linker]
    +   ~~~~~~~~~~~~~~~~~~~~~
    +  SunOS/Solaris ld emits harmless warning messages about unresolved
    +  symbols in case of compiling into shared library when we do not
    +  link against all the required libs. That is the case of GHC which
    +  does not link against RTS library explicitly in order to be able to
    +  choose the library later based on binary application linking
    +  parameters. The warnings look like:
    +
    +Undefined                       first referenced
    +  symbol                             in file
    +stg_ap_n_fast                       ./T2386_Lib.o
    +stg_upd_frame_info                  ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziLib_litE_closure ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziLib_appE_closure ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziLib_conE_closure ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziSyntax_mkNameGzud_closure ./T2386_Lib.o
    +newCAF                              ./T2386_Lib.o
    +stg_bh_upd_frame_info               ./T2386_Lib.o
    +stg_ap_ppp_fast                     ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziLib_stringL_closure ./T2386_Lib.o
    +stg_ap_p_fast                       ./T2386_Lib.o
    +stg_ap_pp_fast                      ./T2386_Lib.o
    +ld: warning: symbol referencing errors
    +
    +  this is actually coming from T2386 testcase. The emitting of those
    +  warnings is also a reason why so many TH testcases fail on Solaris.
    +
    +  Following filter code is SunOS/Solaris linker specific and should
    +  filter out only linker warnings. Please note that the logic is a
    +  little bit more complex due to the simple reason that we need to preserve
    +  any other linker emitted messages. If there are any. Simply speaking
    +  if we see "Undefined" and later "ld: warning:..." then we omit all
    +  text between (including) the marks. Otherwise we copy the whole output.
    +-}
    +
    
    
    =====================================
    compiler/GHC/Linker/Config.hs
    =====================================
    @@ -2,12 +2,26 @@
     
     module GHC.Linker.Config
       ( FrameworkOpts(..)
    -  ) where
    +  , LinkerConfig(..)
    +  )
    +where
     
     import GHC.Prelude
    +import GHC.Utils.TmpFs
    +import GHC.Utils.CliOption
     
     -- used on darwin only
     data FrameworkOpts = FrameworkOpts
       { foFrameworkPaths    :: [String]
       , foCmdlineFrameworks :: [String]
       }
    +
    +-- | External linker configuration
    +data LinkerConfig = LinkerConfig
    +  { linkerProgram     :: String           -- ^ Linker program
    +  , linkerOptionsPre  :: [Option]         -- ^ Linker options (before user options)
    +  , linkerOptionsPost :: [Option]         -- ^ Linker options (after user options)
    +  , linkerTempDir     :: TempDir          -- ^ Temporary directory to use
    +  , linkerFilter      :: String -> String -- ^ Output filter
    +  }
    +
    
    
    =====================================
    compiler/GHC/Linker/Dynamic.hs
    =====================================
    @@ -20,7 +20,7 @@ import GHC.Unit.Types
     import GHC.Unit.State
     import GHC.Linker.MacOS
     import GHC.Linker.Unit
    -import GHC.SysTools.Tasks
    +import GHC.Linker.External
     import GHC.Utils.Logger
     import GHC.Utils.TmpFs
     
    @@ -98,6 +98,8 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
         pkg_framework_opts <- getUnitFrameworkOpts unit_env (map unitId pkgs)
         let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform
     
    +    let linker_config = initLinkerConfig dflags
    +
         case os of
             OSMinGW32 -> do
                 -------------------------------------------------------------
    @@ -107,7 +109,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
                                 Just s -> s
                                 Nothing -> "HSdll.dll"
     
    -            runLink logger tmpfs dflags (
    +            runLink logger tmpfs linker_config (
                         map Option verbFlags
                      ++ [ Option "-o"
                         , FileOption "" output_fn
    @@ -167,7 +169,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
                 instName <- case dylibInstallName dflags of
                     Just n -> return n
                     Nothing -> return $ "@rpath" `combine` (takeFileName output_fn)
    -            runLink logger tmpfs dflags (
    +            runLink logger tmpfs linker_config (
                         map Option verbFlags
                      ++ [ Option "-dynamiclib"
                         , Option "-o"
    @@ -212,7 +214,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
                                     -- See Note [-Bsymbolic assumptions by GHC]
                                     ["-Wl,-Bsymbolic" | not unregisterised]
     
    -            runLink logger tmpfs dflags (
    +            runLink logger tmpfs linker_config (
                         map Option verbFlags
                      ++ libmLinkOpts platform
                      ++ [ Option "-o"
    
    
    =====================================
    compiler/GHC/Linker/External.hs
    =====================================
    @@ -0,0 +1,26 @@
    +-- | External ("system") linker
    +module GHC.Linker.External
    +  ( LinkerConfig(..)
    +  , runLink
    +  )
    +where
    +
    +import GHC.Prelude
    +import GHC.Utils.TmpFs
    +import GHC.Utils.Logger
    +import GHC.Utils.Error
    +import GHC.Utils.CliOption
    +import GHC.SysTools.Process
    +import GHC.Linker.Config
    +
    +-- | Run the external linker
    +runLink :: Logger -> TmpFs -> LinkerConfig -> [Option] -> IO ()
    +runLink logger tmpfs cfg args = traceSystoolCommand logger "linker" $ do
    +  let all_args = linkerOptionsPre cfg ++ args ++ linkerOptionsPost cfg
    +
    +  -- on Windows, mangle environment variables to account for a bug in Windows
    +  -- Vista
    +  mb_env <- getGccEnv all_args
    +
    +  runSomethingResponseFile logger tmpfs (linkerTempDir cfg) (linkerFilter cfg)
    +    "Linker" (linkerProgram cfg) all_args mb_env
    
    
    =====================================
    compiler/GHC/Linker/Static.hs
    =====================================
    @@ -26,6 +26,7 @@ import GHC.Linker.MacOS
     import GHC.Linker.Unit
     import GHC.Linker.Dynamic
     import GHC.Linker.ExtraObj
    +import GHC.Linker.External
     import GHC.Linker.Windows
     import GHC.Linker.Static.Utils
     
    @@ -181,14 +182,12 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
           OSMinGW32 | gopt Opt_GenManifest dflags -> maybeCreateManifest logger tmpfs dflags output_fn
           _                                       -> return []
     
    -    let link dflags args | platformOS platform == OSDarwin
    -                            = do
    -                                 GHC.SysTools.runLink logger tmpfs dflags args
    -                                 -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004
    -                                 when (gopt Opt_RPath dflags) $
    -                                   GHC.Linker.MacOS.runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn
    -                         | otherwise
    -                            = GHC.SysTools.runLink logger tmpfs dflags args
    +    let linker_config = initLinkerConfig dflags
    +    let link dflags args = do
    +          runLink logger tmpfs linker_config args
    +          -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004
    +          when (platformOS platform == OSDarwin && gopt Opt_RPath dflags) $
    +            GHC.Linker.MacOS.runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn
     
         link dflags (
                            map GHC.SysTools.Option verbFlags
    
    
    =====================================
    compiler/GHC/SysTools/Tasks.hs
    =====================================
    @@ -10,7 +10,6 @@
     module GHC.SysTools.Tasks where
     
     import GHC.Prelude
    -import GHC.Platform
     import GHC.ForeignSrcLang
     
     import GHC.CmmToLlvm.Config (LlvmVersion, llvmVersionStr, supportedLlvmVersionUpperBound, parseLlvmVersion, supportedLlvmVersionLowerBound)
    @@ -264,68 +263,6 @@ figureLlvmVersion logger dflags = traceSystoolCommand logger "llc" $ do
                                     ++ ")") ]
                     return Nothing)
     
    -
    -
    -runLink :: Logger -> TmpFs -> DynFlags -> [Option] -> IO ()
    -runLink logger tmpfs dflags args = traceSystoolCommand logger "linker" $ do
    -  -- `-optl` args come at the end, so that later `-l` options
    -  -- given there manually can fill in symbols needed by
    -  -- Haskell libraries coming in via `args`.
    -  let (p,args0) = pgm_l dflags
    -      optl_args = map Option (getOpts dflags opt_l)
    -      args2     = args0 ++ args ++ optl_args
    -  mb_env <- getGccEnv args2
    -  runSomethingResponseFile logger tmpfs (tmpDir dflags) ld_filter "Linker" p args2 mb_env
    -  where
    -    ld_filter = case (platformOS (targetPlatform dflags)) of
    -                  OSSolaris2 -> sunos_ld_filter
    -                  _ -> id
    -{-
    -  SunOS/Solaris ld emits harmless warning messages about unresolved
    -  symbols in case of compiling into shared library when we do not
    -  link against all the required libs. That is the case of GHC which
    -  does not link against RTS library explicitly in order to be able to
    -  choose the library later based on binary application linking
    -  parameters. The warnings look like:
    -
    -Undefined                       first referenced
    -  symbol                             in file
    -stg_ap_n_fast                       ./T2386_Lib.o
    -stg_upd_frame_info                  ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziLib_litE_closure ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziLib_appE_closure ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziLib_conE_closure ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziSyntax_mkNameGzud_closure ./T2386_Lib.o
    -newCAF                              ./T2386_Lib.o
    -stg_bh_upd_frame_info               ./T2386_Lib.o
    -stg_ap_ppp_fast                     ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziLib_stringL_closure ./T2386_Lib.o
    -stg_ap_p_fast                       ./T2386_Lib.o
    -stg_ap_pp_fast                      ./T2386_Lib.o
    -ld: warning: symbol referencing errors
    -
    -  this is actually coming from T2386 testcase. The emitting of those
    -  warnings is also a reason why so many TH testcases fail on Solaris.
    -
    -  Following filter code is SunOS/Solaris linker specific and should
    -  filter out only linker warnings. Please note that the logic is a
    -  little bit more complex due to the simple reason that we need to preserve
    -  any other linker emitted messages. If there are any. Simply speaking
    -  if we see "Undefined" and later "ld: warning:..." then we omit all
    -  text between (including) the marks. Otherwise we copy the whole output.
    --}
    -    sunos_ld_filter :: String -> String
    -    sunos_ld_filter = unlines . sunos_ld_filter' . lines
    -    sunos_ld_filter' x = if (undefined_found x && ld_warning_found x)
    -                          then (ld_prefix x) ++ (ld_postfix x)
    -                          else x
    -    breakStartsWith x y = break (isPrefixOf x) y
    -    ld_prefix = fst . breakStartsWith "Undefined"
    -    undefined_found = not . null . snd . breakStartsWith "Undefined"
    -    ld_warn_break = breakStartsWith "ld: warning: symbol referencing errors"
    -    ld_postfix = tail . snd . ld_warn_break
    -    ld_warning_found = not . null . snd . ld_warn_break
    -
     -- See Note [Merging object files for GHCi] in GHC.Driver.Pipeline.
     runMergeObjects :: Logger -> TmpFs -> DynFlags -> [Option] -> IO ()
     runMergeObjects logger tmpfs dflags args =
    
    
    =====================================
    compiler/ghc.cabal.in
    =====================================
    @@ -580,6 +580,7 @@ Library
             GHC.Linker.Config
             GHC.Linker.Deps
             GHC.Linker.Dynamic
    +        GHC.Linker.External
             GHC.Linker.ExtraObj
             GHC.Linker.Loader
             GHC.Linker.MacOS
    
    
    =====================================
    rts/posix/OSMem.c
    =====================================
    @@ -530,7 +530,7 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len)
                 (void*)startAddress, (void*)minimumAddress);
         }
     
    -#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H)
    +#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H) && defined(RLIMIT_AS)
         struct rlimit asLimit;
         /* rlim_t is signed on some platforms, including FreeBSD;
          * explicitly cast to avoid sign compare error */
    
    
    =====================================
    testsuite/tests/ghc-api/all.T
    =====================================
    @@ -1,3 +1,5 @@
    +setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
    +
     test('ghcApi', normal, compile_and_run, ['-package ghc'])
     test('T6145', js_broken(22352), makefile_test, ['T6145'])
     test('T8639_api', req_rts_linker,
    
    
    =====================================
    testsuite/tests/ghc-api/downsweep/all.T
    =====================================
    @@ -1,3 +1,5 @@
    +setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
    +
     test('PartialDownsweep',
          [ extra_run_opts('"' + config.libdir + '"')
          , ignore_stderr
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dde1d7ff0656269a90b512984fd19de8da21411d...461aa62543484fe3abfaa74275797431099baccf
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dde1d7ff0656269a90b512984fd19de8da21411d...461aa62543484fe3abfaa74275797431099baccf
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 26 10:52:13 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Thu, 26 Oct 2023 06:52:13 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/T24078
    Message-ID: <653a44dd2245b_1f7b0d84dc7fec60885f@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed new branch wip/T24078 at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24078
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 26 12:44:49 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Thu, 26 Oct 2023 08:44:49 -0400
    Subject: [Git][ghc/ghc][master] Explicitly require RLIMIT_AS before use in
     OSMem.c
    Message-ID: <653a5f419cadd_1f7b0d8779c90864376@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    
    
    1 changed file:
    
    - rts/posix/OSMem.c
    
    
    Changes:
    
    =====================================
    rts/posix/OSMem.c
    =====================================
    @@ -530,7 +530,7 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len)
                 (void*)startAddress, (void*)minimumAddress);
         }
     
    -#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H)
    +#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H) && defined(RLIMIT_AS)
         struct rlimit asLimit;
         /* rlim_t is signed on some platforms, including FreeBSD;
          * explicitly cast to avoid sign compare error */
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0d6acca56286e03b01886906b61de4424a97dec5
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0d6acca56286e03b01886906b61de4424a97dec5
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 26 12:45:47 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Thu, 26 Oct 2023 08:45:47 -0400
    Subject: [Git][ghc/ghc][master] Modularity: modularize external linker
    Message-ID: <653a5f7b917ee_1f7b0d86e85a5464671@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    
    
    7 changed files:
    
    - compiler/GHC/Driver/Config/Linker.hs
    - compiler/GHC/Linker/Config.hs
    - compiler/GHC/Linker/Dynamic.hs
    - + compiler/GHC/Linker/External.hs
    - compiler/GHC/Linker/Static.hs
    - compiler/GHC/SysTools/Tasks.hs
    - compiler/ghc.cabal.in
    
    
    Changes:
    
    =====================================
    compiler/GHC/Driver/Config/Linker.hs
    =====================================
    @@ -1,13 +1,93 @@
     module GHC.Driver.Config.Linker
       ( initFrameworkOpts
    -  ) where
    +  , initLinkerConfig
    +  )
    +where
     
    +import GHC.Prelude
    +import GHC.Platform
     import GHC.Linker.Config
     
     import GHC.Driver.DynFlags
    +import GHC.Driver.Session
    +
    +import Data.List (isPrefixOf)
     
     initFrameworkOpts :: DynFlags -> FrameworkOpts
     initFrameworkOpts dflags = FrameworkOpts
       { foFrameworkPaths    = frameworkPaths    dflags
       , foCmdlineFrameworks = cmdlineFrameworks dflags
       }
    +
    +-- | Initialize linker configuration from DynFlags
    +initLinkerConfig :: DynFlags -> LinkerConfig
    +initLinkerConfig dflags =
    +  let
    +    -- see Note [Solaris linker]
    +    ld_filter = case platformOS (targetPlatform dflags) of
    +                  OSSolaris2 -> sunos_ld_filter
    +                  _          -> id
    +    sunos_ld_filter :: String -> String
    +    sunos_ld_filter = unlines . sunos_ld_filter' . lines
    +    sunos_ld_filter' x = if (undefined_found x && ld_warning_found x)
    +                          then (ld_prefix x) ++ (ld_postfix x)
    +                          else x
    +    breakStartsWith x y = break (isPrefixOf x) y
    +    ld_prefix = fst . breakStartsWith "Undefined"
    +    undefined_found = not . null . snd . breakStartsWith "Undefined"
    +    ld_warn_break = breakStartsWith "ld: warning: symbol referencing errors"
    +    ld_postfix = tail . snd . ld_warn_break
    +    ld_warning_found = not . null . snd . ld_warn_break
    +
    +    -- program and arguments
    +    --
    +    -- `-optl` args come at the end, so that later `-l` options
    +    -- given there manually can fill in symbols needed by
    +    -- Haskell libraries coming in via `args`.
    +    (p,pre_args) = pgm_l dflags
    +    post_args    = map Option (getOpts dflags opt_l)
    +
    +  in LinkerConfig
    +    { linkerProgram     = p
    +    , linkerOptionsPre  = pre_args
    +    , linkerOptionsPost = post_args
    +    , linkerTempDir     = tmpDir dflags
    +    , linkerFilter      = ld_filter
    +    }
    +
    +{- Note [Solaris linker]
    +   ~~~~~~~~~~~~~~~~~~~~~
    +  SunOS/Solaris ld emits harmless warning messages about unresolved
    +  symbols in case of compiling into shared library when we do not
    +  link against all the required libs. That is the case of GHC which
    +  does not link against RTS library explicitly in order to be able to
    +  choose the library later based on binary application linking
    +  parameters. The warnings look like:
    +
    +Undefined                       first referenced
    +  symbol                             in file
    +stg_ap_n_fast                       ./T2386_Lib.o
    +stg_upd_frame_info                  ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziLib_litE_closure ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziLib_appE_closure ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziLib_conE_closure ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziSyntax_mkNameGzud_closure ./T2386_Lib.o
    +newCAF                              ./T2386_Lib.o
    +stg_bh_upd_frame_info               ./T2386_Lib.o
    +stg_ap_ppp_fast                     ./T2386_Lib.o
    +templatezmhaskell_LanguageziHaskellziTHziLib_stringL_closure ./T2386_Lib.o
    +stg_ap_p_fast                       ./T2386_Lib.o
    +stg_ap_pp_fast                      ./T2386_Lib.o
    +ld: warning: symbol referencing errors
    +
    +  this is actually coming from T2386 testcase. The emitting of those
    +  warnings is also a reason why so many TH testcases fail on Solaris.
    +
    +  Following filter code is SunOS/Solaris linker specific and should
    +  filter out only linker warnings. Please note that the logic is a
    +  little bit more complex due to the simple reason that we need to preserve
    +  any other linker emitted messages. If there are any. Simply speaking
    +  if we see "Undefined" and later "ld: warning:..." then we omit all
    +  text between (including) the marks. Otherwise we copy the whole output.
    +-}
    +
    
    
    =====================================
    compiler/GHC/Linker/Config.hs
    =====================================
    @@ -2,12 +2,26 @@
     
     module GHC.Linker.Config
       ( FrameworkOpts(..)
    -  ) where
    +  , LinkerConfig(..)
    +  )
    +where
     
     import GHC.Prelude
    +import GHC.Utils.TmpFs
    +import GHC.Utils.CliOption
     
     -- used on darwin only
     data FrameworkOpts = FrameworkOpts
       { foFrameworkPaths    :: [String]
       , foCmdlineFrameworks :: [String]
       }
    +
    +-- | External linker configuration
    +data LinkerConfig = LinkerConfig
    +  { linkerProgram     :: String           -- ^ Linker program
    +  , linkerOptionsPre  :: [Option]         -- ^ Linker options (before user options)
    +  , linkerOptionsPost :: [Option]         -- ^ Linker options (after user options)
    +  , linkerTempDir     :: TempDir          -- ^ Temporary directory to use
    +  , linkerFilter      :: String -> String -- ^ Output filter
    +  }
    +
    
    
    =====================================
    compiler/GHC/Linker/Dynamic.hs
    =====================================
    @@ -20,7 +20,7 @@ import GHC.Unit.Types
     import GHC.Unit.State
     import GHC.Linker.MacOS
     import GHC.Linker.Unit
    -import GHC.SysTools.Tasks
    +import GHC.Linker.External
     import GHC.Utils.Logger
     import GHC.Utils.TmpFs
     
    @@ -98,6 +98,8 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
         pkg_framework_opts <- getUnitFrameworkOpts unit_env (map unitId pkgs)
         let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform
     
    +    let linker_config = initLinkerConfig dflags
    +
         case os of
             OSMinGW32 -> do
                 -------------------------------------------------------------
    @@ -107,7 +109,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
                                 Just s -> s
                                 Nothing -> "HSdll.dll"
     
    -            runLink logger tmpfs dflags (
    +            runLink logger tmpfs linker_config (
                         map Option verbFlags
                      ++ [ Option "-o"
                         , FileOption "" output_fn
    @@ -167,7 +169,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
                 instName <- case dylibInstallName dflags of
                     Just n -> return n
                     Nothing -> return $ "@rpath" `combine` (takeFileName output_fn)
    -            runLink logger tmpfs dflags (
    +            runLink logger tmpfs linker_config (
                         map Option verbFlags
                      ++ [ Option "-dynamiclib"
                         , Option "-o"
    @@ -212,7 +214,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
                                     -- See Note [-Bsymbolic assumptions by GHC]
                                     ["-Wl,-Bsymbolic" | not unregisterised]
     
    -            runLink logger tmpfs dflags (
    +            runLink logger tmpfs linker_config (
                         map Option verbFlags
                      ++ libmLinkOpts platform
                      ++ [ Option "-o"
    
    
    =====================================
    compiler/GHC/Linker/External.hs
    =====================================
    @@ -0,0 +1,26 @@
    +-- | External ("system") linker
    +module GHC.Linker.External
    +  ( LinkerConfig(..)
    +  , runLink
    +  )
    +where
    +
    +import GHC.Prelude
    +import GHC.Utils.TmpFs
    +import GHC.Utils.Logger
    +import GHC.Utils.Error
    +import GHC.Utils.CliOption
    +import GHC.SysTools.Process
    +import GHC.Linker.Config
    +
    +-- | Run the external linker
    +runLink :: Logger -> TmpFs -> LinkerConfig -> [Option] -> IO ()
    +runLink logger tmpfs cfg args = traceSystoolCommand logger "linker" $ do
    +  let all_args = linkerOptionsPre cfg ++ args ++ linkerOptionsPost cfg
    +
    +  -- on Windows, mangle environment variables to account for a bug in Windows
    +  -- Vista
    +  mb_env <- getGccEnv all_args
    +
    +  runSomethingResponseFile logger tmpfs (linkerTempDir cfg) (linkerFilter cfg)
    +    "Linker" (linkerProgram cfg) all_args mb_env
    
    
    =====================================
    compiler/GHC/Linker/Static.hs
    =====================================
    @@ -26,6 +26,7 @@ import GHC.Linker.MacOS
     import GHC.Linker.Unit
     import GHC.Linker.Dynamic
     import GHC.Linker.ExtraObj
    +import GHC.Linker.External
     import GHC.Linker.Windows
     import GHC.Linker.Static.Utils
     
    @@ -181,14 +182,12 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
           OSMinGW32 | gopt Opt_GenManifest dflags -> maybeCreateManifest logger tmpfs dflags output_fn
           _                                       -> return []
     
    -    let link dflags args | platformOS platform == OSDarwin
    -                            = do
    -                                 GHC.SysTools.runLink logger tmpfs dflags args
    -                                 -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004
    -                                 when (gopt Opt_RPath dflags) $
    -                                   GHC.Linker.MacOS.runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn
    -                         | otherwise
    -                            = GHC.SysTools.runLink logger tmpfs dflags args
    +    let linker_config = initLinkerConfig dflags
    +    let link dflags args = do
    +          runLink logger tmpfs linker_config args
    +          -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004
    +          when (platformOS platform == OSDarwin && gopt Opt_RPath dflags) $
    +            GHC.Linker.MacOS.runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn
     
         link dflags (
                            map GHC.SysTools.Option verbFlags
    
    
    =====================================
    compiler/GHC/SysTools/Tasks.hs
    =====================================
    @@ -10,7 +10,6 @@
     module GHC.SysTools.Tasks where
     
     import GHC.Prelude
    -import GHC.Platform
     import GHC.ForeignSrcLang
     
     import GHC.CmmToLlvm.Config (LlvmVersion, llvmVersionStr, supportedLlvmVersionUpperBound, parseLlvmVersion, supportedLlvmVersionLowerBound)
    @@ -264,68 +263,6 @@ figureLlvmVersion logger dflags = traceSystoolCommand logger "llc" $ do
                                     ++ ")") ]
                     return Nothing)
     
    -
    -
    -runLink :: Logger -> TmpFs -> DynFlags -> [Option] -> IO ()
    -runLink logger tmpfs dflags args = traceSystoolCommand logger "linker" $ do
    -  -- `-optl` args come at the end, so that later `-l` options
    -  -- given there manually can fill in symbols needed by
    -  -- Haskell libraries coming in via `args`.
    -  let (p,args0) = pgm_l dflags
    -      optl_args = map Option (getOpts dflags opt_l)
    -      args2     = args0 ++ args ++ optl_args
    -  mb_env <- getGccEnv args2
    -  runSomethingResponseFile logger tmpfs (tmpDir dflags) ld_filter "Linker" p args2 mb_env
    -  where
    -    ld_filter = case (platformOS (targetPlatform dflags)) of
    -                  OSSolaris2 -> sunos_ld_filter
    -                  _ -> id
    -{-
    -  SunOS/Solaris ld emits harmless warning messages about unresolved
    -  symbols in case of compiling into shared library when we do not
    -  link against all the required libs. That is the case of GHC which
    -  does not link against RTS library explicitly in order to be able to
    -  choose the library later based on binary application linking
    -  parameters. The warnings look like:
    -
    -Undefined                       first referenced
    -  symbol                             in file
    -stg_ap_n_fast                       ./T2386_Lib.o
    -stg_upd_frame_info                  ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziLib_litE_closure ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziLib_appE_closure ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziLib_conE_closure ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziSyntax_mkNameGzud_closure ./T2386_Lib.o
    -newCAF                              ./T2386_Lib.o
    -stg_bh_upd_frame_info               ./T2386_Lib.o
    -stg_ap_ppp_fast                     ./T2386_Lib.o
    -templatezmhaskell_LanguageziHaskellziTHziLib_stringL_closure ./T2386_Lib.o
    -stg_ap_p_fast                       ./T2386_Lib.o
    -stg_ap_pp_fast                      ./T2386_Lib.o
    -ld: warning: symbol referencing errors
    -
    -  this is actually coming from T2386 testcase. The emitting of those
    -  warnings is also a reason why so many TH testcases fail on Solaris.
    -
    -  Following filter code is SunOS/Solaris linker specific and should
    -  filter out only linker warnings. Please note that the logic is a
    -  little bit more complex due to the simple reason that we need to preserve
    -  any other linker emitted messages. If there are any. Simply speaking
    -  if we see "Undefined" and later "ld: warning:..." then we omit all
    -  text between (including) the marks. Otherwise we copy the whole output.
    --}
    -    sunos_ld_filter :: String -> String
    -    sunos_ld_filter = unlines . sunos_ld_filter' . lines
    -    sunos_ld_filter' x = if (undefined_found x && ld_warning_found x)
    -                          then (ld_prefix x) ++ (ld_postfix x)
    -                          else x
    -    breakStartsWith x y = break (isPrefixOf x) y
    -    ld_prefix = fst . breakStartsWith "Undefined"
    -    undefined_found = not . null . snd . breakStartsWith "Undefined"
    -    ld_warn_break = breakStartsWith "ld: warning: symbol referencing errors"
    -    ld_postfix = tail . snd . ld_warn_break
    -    ld_warning_found = not . null . snd . ld_warn_break
    -
     -- See Note [Merging object files for GHCi] in GHC.Driver.Pipeline.
     runMergeObjects :: Logger -> TmpFs -> DynFlags -> [Option] -> IO ()
     runMergeObjects logger tmpfs dflags args =
    
    
    =====================================
    compiler/ghc.cabal.in
    =====================================
    @@ -580,6 +580,7 @@ Library
             GHC.Linker.Config
             GHC.Linker.Deps
             GHC.Linker.Dynamic
    +        GHC.Linker.External
             GHC.Linker.ExtraObj
             GHC.Linker.Loader
             GHC.Linker.MacOS
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9408b086775960a2e0a6b0b6f8091e79bcf9ddd5
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9408b086775960a2e0a6b0b6f8091e79bcf9ddd5
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 26 14:36:14 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Thu, 26 Oct 2023 10:36:14 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Further improvements
    Message-ID: <653a795e8ad6e_1f7b0d8aa40260659898@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    170af01b by Simon Peyton Jones at 2023-10-26T15:35:17+01:00
    Further improvements
    
    * Fix threshold in SpecConstr
    * Need to recurse in keptCaseSize
    
    - - - - -
    
    
    4 changed files:
    
    - compiler/GHC/Builtin/PrimOps.hs
    - compiler/GHC/Core.hs
    - compiler/GHC/Core/Subst.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/PrimOps.hs
    =====================================
    @@ -703,7 +703,7 @@ primOpIsDiv op = case op of
     primOpCodeSize
     ~~~~~~~~~~~~~~
     Gives an indication of the code size of a primop, for the purposes of
    -calculating unfolding sizes; see GHC.Core.Unfold.sizeExpr.
    +calculating unfolding sizes; see GHC.Core.Unfold.exprTree
     -}
     
     primOpCodeSize :: PrimOp -> Int
    
    
    =====================================
    compiler/GHC/Core.hs
    =====================================
    @@ -14,6 +14,7 @@ module GHC.Core (
             CoreProgram, CoreExpr, CoreAlt, CoreBind, CoreArg, CoreBndr,
             TaggedExpr, TaggedAlt, TaggedBind, TaggedArg, TaggedBndr(..), deTagExpr,
             ExprTree(..), CaseTree(..), AltTree(..),
    +        Size, Discount,
     
             -- * In/Out type synonyms
             InId, InBind, InExpr, InAlt, InArg, InType, InKind,
    @@ -1396,19 +1397,23 @@ data UnfoldingGuidance
     
       | UnfNever        -- The RHS is big, so don't inline it
     
    +type Size     = Int
    +type Discount = Int
    +
     data ExprTree
    -  = ExprTree { et_tot   :: {-# UNPACK #-} !Int   -- ^ Size of whole tree
    -             , et_size  :: {-# UNPACK #-} !Int   -- ^ Size of the bit apart from et_cases
    -             , et_ret   :: {-# UNPACK #-} !Int   -- ^ Discount when result is scrutinised
    +  = ExprTree { et_tot   :: {-# UNPACK #-} !Size      -- ^ Size of whole tree
    +             , et_size  :: {-# UNPACK #-} !Size      -- ^ Size of the bit apart from et_cases
    +             , et_ret   :: {-# UNPACK #-} !Discount  -- ^ Discount when result is scrutinised
                  , et_cases :: Bag CaseTree
         }
     
     data CaseTree
    -  = CaseOf Id          -- Abstracts a case expression on this Id
    -           Id          -- Case binder
    -           [AltTree]   -- Always non-empty, but not worth making NonEmpty;
    -                       -- nothing relies on non-empty-ness
    -  | ScrutOf Id Int     -- If this Id is bound to a value, apply this discount
    +  = CaseOf Id            -- Abstracts a case expression on this Id
    +           Id            -- Case binder
    +           [AltTree]     -- Always non-empty, but not worth making NonEmpty;
    +                         -- nothing relies on non-empty-ness
    +
    +  | ScrutOf Id Discount  -- If this Id is bound to a value, apply this discount
     
     data AltTree  = AltTree AltCon
                             [Id]      -- Term variables only
    
    
    =====================================
    compiler/GHC/Core/Subst.hs
    =====================================
    @@ -570,7 +570,7 @@ substExprTree id_env (ExprTree { et_tot = tot
             where
               id_env' = id_env `delVarEnv` case_bndr
               alts' = map (subst_alt id_env') alts
    -          extra = keptCaseSize alts
    +          extra = altTreesSize alts
     
          subst_alt id_env (AltTree con bs rhs)
             = AltTree con bs (substExprTree id_env' rhs)
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -20,7 +20,7 @@ find, unsurprisingly, a Core expression.
     module GHC.Core.Unfold (
             Unfolding, UnfoldingGuidance,   -- Abstract types
     
    -        ExprTree, exprTree, exprTreeSize, keptCaseSize,
    +        ExprTree, exprTree, exprTreeSize, altTreesSize,
             exprTreeWillInline, couldBeSmallEnoughToInline,
             ArgSummary(..), hasArgInfo,
     
    @@ -60,6 +60,7 @@ import GHC.Utils.Outputable
     import GHC.Utils.Panic
     
     import GHC.Data.Bag
    +import GHC.Data.Maybe
     
     import qualified Data.ByteString as BS
     
    @@ -133,22 +134,22 @@ The moving parts
     
     -- | Unfolding options
     data UnfoldingOpts = UnfoldingOpts
    -   { unfoldingCreationThreshold :: !Int
    +   { unfoldingCreationThreshold :: !Size
           -- ^ Threshold above which unfoldings are not *created*
     
    -   , unfoldingUseThreshold :: !Int
    +   , unfoldingUseThreshold :: !Size
           -- ^ Threshold above which unfoldings are not *inlined*
     
    -   , unfoldingFunAppDiscount :: !Int
    +   , unfoldingFunAppDiscount :: !Discount
           -- ^ Discount for lambdas that are used (applied)
     
    -   , unfoldingDictDiscount :: !Int
    +   , unfoldingDictDiscount :: !Discount
           -- ^ Discount for dictionaries
     
        , unfoldingVeryAggressive :: !Bool
           -- ^ Force inlining in many more cases
     
    -   , unfoldingCaseThreshold :: !Int
    +   , unfoldingCaseThreshold :: !Size
           -- ^ Don't consider depth up to x
     
        , unfoldingCaseScaling :: !Int
    @@ -203,23 +204,23 @@ defaultUnfoldingOpts = UnfoldingOpts
     
     -- Helpers for "GHC.Driver.Session"
     
    -updateCreationThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts
    +updateCreationThreshold :: Size -> UnfoldingOpts -> UnfoldingOpts
     updateCreationThreshold n opts = opts { unfoldingCreationThreshold = n }
     
    -updateUseThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts
    +updateUseThreshold :: Size -> UnfoldingOpts -> UnfoldingOpts
     updateUseThreshold n opts = opts { unfoldingUseThreshold = n }
     
    -updateFunAppDiscount :: Int -> UnfoldingOpts -> UnfoldingOpts
    +updateFunAppDiscount :: Discount -> UnfoldingOpts -> UnfoldingOpts
     updateFunAppDiscount n opts = opts { unfoldingFunAppDiscount = n }
     
    -updateDictDiscount :: Int -> UnfoldingOpts -> UnfoldingOpts
    +updateDictDiscount :: Discount -> UnfoldingOpts -> UnfoldingOpts
     updateDictDiscount n opts = opts { unfoldingDictDiscount = n }
     
     updateVeryAggressive :: Bool -> UnfoldingOpts -> UnfoldingOpts
     updateVeryAggressive n opts = opts { unfoldingVeryAggressive = n }
     
     
    -updateCaseThreshold :: Int -> UnfoldingOpts -> UnfoldingOpts
    +updateCaseThreshold :: Size -> UnfoldingOpts -> UnfoldingOpts
     updateCaseThreshold n opts = opts { unfoldingCaseThreshold = n }
     
     updateCaseScaling :: Int -> UnfoldingOpts -> UnfoldingOpts
    @@ -294,19 +295,19 @@ calcUnfoldingGuidance opts is_top_bottoming expr
         val_bndrs   = filter isId bndrs
         n_val_bndrs = length val_bndrs
     
    -couldBeSmallEnoughToInline :: UnfoldingOpts -> Int -> CoreExpr -> Bool
    +couldBeSmallEnoughToInline :: UnfoldingOpts -> Size -> CoreExpr -> Bool
     -- We use 'couldBeSmallEnoughToInline' to avoid exporting inlinings that
     -- we ``couldn't possibly use'' on the other side.  Can be overridden
     -- w/flaggery.  Just the same as smallEnoughToInline, except that it has no
     -- actual arguments.
     couldBeSmallEnoughToInline opts threshold rhs
    -  = case exprTree opts [] body of
    -      Nothing -> False
    -      Just et -> exprTreeWillInline threshold et
    +  = isJust (exprTree opts' [] body)
       where
    +    opts' = opts { unfoldingCreationThreshold = threshold }
    +            -- We use a different (and larger) theshold here for
    +            -- creating specialised copies of the function
         (_, body) = collectBinders rhs
     
    -
     {- Note [Inline unsafeCoerce]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     We really want to inline unsafeCoerce, even when applied to boring
    @@ -326,7 +327,7 @@ as trivial iff rhs is. This is (U4) in Note [Implementing unsafeCoerce].
     
     Note [Computing the size of an expression]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -The basic idea of sizeExpr is obvious enough: count nodes.  But getting the
    +The basic idea of exprSizeTree is obvious enough: count nodes.  But getting the
     heuristics right has taken a long time.  Here's the basic strategy:
     
         * Variables, literals: 0
    @@ -379,7 +380,7 @@ inline unconditionally, regardless of how boring the context is.
     
     Things to note:
     
    -(1) We inline *unconditionally* if inlined thing is smaller (using sizeExpr)
    +(1) We inline *unconditionally* if inlined thing is smaller (using exprSizeTree)
         than the thing it's replacing.  Notice that
           (f x) --> (g 3)             -- YES, unconditionally
           (f x) --> x : []            -- YES, *even though* there are two
    @@ -443,7 +444,7 @@ sharing the wrapper closure.
     The solution: don’t ignore coercion arguments after all.
     -}
     
    -uncondInline :: CoreExpr -> Arity -> Int -> Bool
    +uncondInline :: CoreExpr -> Arity -> Size -> Bool
     -- Inline unconditionally if there no size increase
     -- Size of call is arity (+1 for the function)
     -- See Note [INLINE for small functions]
    @@ -526,7 +527,7 @@ exprTree opts args expr
         et_add_alt = metAddAlt bOMB_OUT_SIZE
     
         go :: Int -> ETVars -> CoreExpr -> Maybe ExprTree
    -          -- cd is the unused case depth; decreases toward zero
    +          -- cd is the /unused/ case depth; decreases toward zero
               -- (avs,lvs): see Note [Constructing an ExprTree]
         go cd vs (Cast e _)      = go cd vs e
         go cd vs (Tick _ e)      = go cd vs e
    @@ -740,13 +741,13 @@ callTree opts vs fun val_args voids
         n_val_args = length val_args
     
     -- | The size of a function call
    -vanillaCallSize :: Int -> Int -> Int
    +vanillaCallSize :: Int -> Int -> Size
     vanillaCallSize n_val_args voids = 10 * (1 + n_val_args - voids)
             -- The 1+ is for the function itself
             -- Add 1 for each non-trivial value arg
     
     -- | The size of a jump to a join point
    -jumpSize :: Int -> Int -> Int
    +jumpSize :: Int -> Int -> Size
     jumpSize n_val_args voids = 2 * (1 + n_val_args - voids)
       -- A jump is 20% the size of a function call. Making jumps free reopens
       -- bug #6048, but making them any more expensive loses a 21% improvement in
    @@ -813,7 +814,7 @@ conSize dc n_val_args
         size | n_val_args == 0 = 0  -- Like variables
              | otherwise       = 10
     
    -primOpSize :: PrimOp -> Int -> Int
    +primOpSize :: PrimOp -> Int -> Size
     primOpSize op n_val_args
       | primOpOutOfLine op = op_size + n_val_args
       | otherwise          = op_size
    @@ -982,11 +983,11 @@ Code for manipulating sizes
     -}
     
     ---------------------------------------
    -metAddN :: Int -> Maybe ExprTree -> Maybe ExprTree
    +metAddN :: Size -> Maybe ExprTree -> Maybe ExprTree
     metAddN _ Nothing = Nothing
     metAddN n (Just et) = Just (n `etAddN` et)
     
    -etAddN :: Int -> ExprTree -> ExprTree
    +etAddN :: Size -> ExprTree -> ExprTree
     -- Does not account for et_tot geting too big, but that doesn't
     -- matter; the extra increment is always small, and we never get
     -- a long cascade of etAddNs
    @@ -1025,13 +1026,13 @@ metAddAlt bOMB_OUT_SIZE (Just et1) (Just et2)
     
     
     -- | The "expression tree"; an abstraction of the RHS of the function
    -exprTreeN :: Int -> ExprTree
    +exprTreeN :: Size -> ExprTree
     exprTreeN n = ExprTree { et_size = n, et_tot = n, et_cases = emptyBag, et_ret = 0 }
     
     etZero :: ExprTree
     etZero = ExprTree { et_tot = 0, et_size = 0, et_cases = emptyBag, et_ret = 0 }
     
    -etCaseOf :: Int -> Id -> Id -> [AltTree] -> Maybe ExprTree
    +etCaseOf :: Size -> Id -> Id -> [AltTree] -> Maybe ExprTree
     -- We make the case itself free, but charge for each alternative
     -- If there are no alternatives (case e of {}), we get just the size of the scrutinee
     etCaseOf bOMB_OUT_SIZE scrut case_bndr alts
    @@ -1040,10 +1041,15 @@ etCaseOf bOMB_OUT_SIZE scrut case_bndr alts
                                               , et_cases = unitBag case_tree })
       where
         case_tree = CaseOf scrut case_bndr alts
    -    tot = foldl' add_alt 0 alts
    +    tot = altTreesSize alts
    +
    +altTreesSize :: [AltTree] -> Size
    +-- Total aize of a [AltTree]
    +altTreesSize alts = foldl' add_alt 0 alts
    +  where
         add_alt n (AltTree _ _ (ExprTree { et_tot = tot })) = n+tot
     
    -etScrutOf :: Id -> Int -> ExprTree
    +etScrutOf :: Id -> Discount -> ExprTree
     etScrutOf v d = ExprTree { et_tot = 0, et_size = 0, et_ret = 0
                              , et_cases = unitBag (ScrutOf v d) }
     
    @@ -1054,37 +1060,6 @@ etScrutOf v d = ExprTree { et_tot = 0, et_size = 0, et_ret = 0
     *                                                                      *
     ********************************************************************* -}
     
    -type Size = Int
    -
    -{-
    -instance Outputable Size where
    -  ppr STooBig = text "STooBig"
    -  ppr (SSize n) = int n
    -
    -sizeZero :: Size
    -sizeZero = SSize 0
    -
    -sizeN :: Int -> Size
    -sizeN n = SSize n
    -
    -addSize :: Size -> Size -> Size
    -addSize (SSize n1) (SSize n2) = SSize (n1+n2)
    -addSize _          _          = STooBig
    -
    -addSizeN :: Int -> Size -> Size
    -addSizeN n1 (SSize n2) = SSize (n1+n2)
    -addSizeN _  STooBig    = STooBig
    -
    -adjustSize :: (Int -> Int) -> Size -> Size
    -adjustSize f (SSize n) = SSize (f n)
    -adjustSize _ STooBig   = STooBig
    -
    -leqSize :: Size -> Int -> Bool
    -leqSize STooBig   _ = False
    -leqSize (SSize n) m = n <= m
    --}
    -
    --------------------------
     data InlineContext
        = IC { ic_free  :: Id -> ArgSummary  -- Current unfoldings for free variables
             , ic_bound :: IdEnv ArgSummary  -- Summaries for local variables
    @@ -1109,11 +1084,11 @@ instance Outputable ArgSummary where
     
     
     -------------------------
    -exprTreeWillInline :: Int -> ExprTree -> Bool
    +exprTreeWillInline :: Size -> ExprTree -> Bool
     -- (cheapExprTreeSize limit et) takes an upper bound `n` on the
     -- size of et; i.e. without discounts etc.
    --- Return True if (s <- limit), False otherwise
    -exprTreeWillInline limit (ExprTree { et_tot = tot }) = tot < limit
    +-- Return True if (s <= limit), False otherwise
    +exprTreeWillInline limit (ExprTree { et_tot = tot }) = tot <= limit
     
     -------------------------
     exprTreeSize :: InlineContext -> ExprTree -> Size
    @@ -1137,9 +1112,9 @@ caseTreeSize ic (ScrutOf bndr disc)
     
     caseTreeSize ic (CaseOf scrut_var case_bndr alts)
       = case lookupBndr ic scrut_var of
    -      ArgNoInfo     -> keptCaseSize alts
    -      ArgIsLam      -> keptCaseSize alts
    -      ArgIsNot cons -> keptCaseSize (trim_alts cons alts)
    +      ArgNoInfo     -> keptCaseSize ic case_bndr alts
    +      ArgIsLam      -> keptCaseSize ic case_bndr alts
    +      ArgIsNot cons -> keptCaseSize ic case_bndr (trim_alts cons alts)
     
           arg_summ@(ArgIsCon con args)
              | Just at@(AltTree alt_con bndrs rhs) <- find_alt con alts
    @@ -1152,7 +1127,7 @@ caseTreeSize ic (CaseOf scrut_var case_bndr alts)
                 exprTreeSize ic' rhs
     
              | otherwise  -- Happens for empty alternatives
    -         -> keptCaseSize alts
    +         -> keptCaseSize ic case_bndr alts
     
     find_alt :: AltCon -> [AltTree] -> Maybe AltTree
     find_alt _   []                     = Nothing
    @@ -1171,17 +1146,28 @@ trim_alts acs (alt:alts)
       | AltTree con _ _ <- alt, con `elem` acs = trim_alts acs alts
       | otherwise                              = alt : trim_alts acs alts
     
    -keptCaseSize :: [AltTree] -> Size
    +keptCaseSize :: InlineContext -> Id -> [AltTree] -> Size
     -- Size of a (retained) case expression
    -keptCaseSize alts = foldr add_alt 0 alts
    +keptCaseSize ic case_bndr alts = foldr ((+) . size_alt) 0 alts
       -- Just add up the  sizes of the alternatives
    -  -- We make the case itself free, but charge for each alternatives (that
    -  -- is already included in the AltTrees
    +  -- We make the case itself free, but charge for each alternatives
    +  -- (the latter is already included in the AltTrees)
       -- If there are no alternatives (case e of {}), we get zero
    +  -- We recurse in case we have
    +  --    args = [a,b], expr_tree = [CaseOf a [ X -> CaseOf b [...]
    +  --                                        , Y -> CaseOf b [...] ] ]
    +  -- Then for a call with ArgInfo for `b`, but not `a`, we want to get
    +  -- the trimmed trees in the X and Y branches
       where
    -    add_alt :: AltTree -> Size -> Size
    -    add_alt (AltTree _ _ (ExprTree { et_tot = tot })) n = n+tot
    -        -- Cost for the alternative is already in `tot`
    +    size_alt :: AltTree -> Size
    +    size_alt (AltTree _ bndrs rhs) = exprTreeSize ic' rhs
    +        -- Cost for the alternative is already in `rhs`
    +      where
    +        -- Must extend ic_bound, lest a captured variable
    +        -- is looked up in ic_free by lookupBndr
    +        new_summaries :: [(Id,ArgSummary)]
    +        new_summaries = [(b,ArgNoInfo) | b <- case_bndr:bndrs]
    +        ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
     
     lookupBndr :: HasDebugCallStack => InlineContext -> Id -> ArgSummary
     lookupBndr (IC { ic_bound = bound_env, ic_free = lookup_free }) var
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/170af01bd2fe224de2279a418a6c63d124c692f0
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/170af01bd2fe224de2279a418a6c63d124c692f0
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 26 16:32:46 2023
    From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index))
    Date: Thu, 26 Oct 2023 12:32:46 -0400
    Subject: [Git][ghc/ghc][wip/int-index/t2t-expr] 108 commits: Simplify and
     correct nasty case in coercion opt
    Message-ID: <653a94ae64a28_1f7b0d8d6b216866966d@gitlab.mail>
    
    
    
    Vladislav Zavialov pushed to branch wip/int-index/t2t-expr at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00
    Simplify and correct nasty case in coercion opt
    
    This fixes #21062.
    
    No test case, because triggering this code seems challenging.
    
    - - - - -
    9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Bump bytestring submodule to 0.12.0.2
    
    - - - - -
    4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Inline bucket_match
    
    - - - - -
    f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00
    configure: Fix #21712 again
    
    This is a bit of a shot in the dark to fix #24033, which appears to be
    another instance of #21712. For some reason the ld-override logic
    *still* appears to be active on Darwin targets (or at least one).
    Consequently, on misconfigured systems we may choose a non-`ld64`
    linker.
    
    It's a bit unclear exactly what happened in #24033 but ultimately the
    check added for #21712 was not quite right, checking for the
    `ghc_host_os` (the value of which depends upon the bootstrap compiler)
    instead of the target platform. Fix this.
    
    Fixes #24033.
    
    - - - - -
    2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00
    Add a regression test for #24029
    
    - - - - -
    8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00
    Fix non-symbolic children lookup of fixity decl
    
    The fix for #23664 did not correctly account for non-symbolic names
    when looking up children of a given parent. This one-line fix changes
    that.
    
    Fixes #24037
    
    - - - - -
    a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00
    rts: fix incorrect ticket reference
    
    - - - - -
    e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00
    users-guide: Fix discussion of -Wpartial-fields
    
     * fix a few typos
     * add a new example showing when the warning fires
     * clarify the existing example
     * point out -Wincomplete-record-selects
    
    Fixes #24049.
    
    - - - - -
    8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00
    Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"
    
    This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.
    
    `-optP` should pass options to the preprocessor, that might be a very
    different program to the C compiler, so passing the options to the C
    compiler is likely to result in `-optP` being useless.
    
    Fixes #17185 and #21291
    
    - - - - -
    8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00
    rts/nonmoving: Fix on LLP64 platforms
    
    Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL`
    size suffix. However, this is wrong on LLP64 platforms like Windows,
    where `long` is 32-bits.
    
    Fixes #23003.
    Fixes #24042.
    
    - - - - -
    f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00
    Fix isAArch64Bitmask for 32bit immediates.
    
    Fixes #23802
    
    - - - - -
    63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00
    Work around perf note fetch failure
    
    Addresses #24055.
    
    - - - - -
    242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00
    Add a test for #21348
    
    - - - - -
    7d390bce by Rewbert at 2023-10-05T05:38:08-04:00
    Fixes #24046
    
    - - - - -
    69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00
    Ensure unconstrained instance dictionaries get IPE info
    
    In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up
    with an initial source span based on the span of the binder, which was causing
    instance dictionaries without dynamic superclass constraints to not have source
    locations in their IPE info. Now they do.
    
    Resolves #24005
    
    - - - - -
    390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00
    rts: Split up rts/include/stg/MachRegs.h by arch
    
    - - - - -
    3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00
    Actually set hackage index state
    
    Or at least, use a version of the cabal command that *claims* to set the
    index state.
    
    Time will tell.
    
    - - - - -
    46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00
    Update hackage index state
    
    - - - - -
    d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00
    Ensure hadrian uses CI's hackage index state
    
    - - - - -
    e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00
    Do not use O_NONBLOCK on regular files or block devices
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/166
    
    - - - - -
    a06197c4 by David Binder at 2023-10-08T15:06:55-04:00
    Update hpc-bin submodule to 0.69
    
    - - - - -
    ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00
    Update Hadrian with correct path to happy file for hpc-bin
    
    - - - - -
    94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00
    EPA: Introduce HasAnnotation class
    
    The class is defined as
    
        class HasAnnotation e where
          noAnnSrcSpan :: SrcSpan -> e
    
    This generalises noAnnSrcSpan, and allows
    
        noLocA :: (HasAnnotation e) => a -> GenLocated e a
        noLocA = L (noAnnSrcSpan noSrcSpan)
    
    - - - - -
    8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00
    Bump unix submodule to v2.8.3.0
    
    - - - - -
    e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00
    Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.
    
    The motivation for the flag is given in #21917.
    
    - - - - -
    3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Add ghcToolchain to tool args list
    
    This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.
    
    - - - - -
    476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Normalise triple via config.sub
    
    We were not normalising the target triple anymore like we did with the
    old make build system.
    
    Fixes #23856
    
    - - - - -
    303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add missing vendor normalisation
    
    This is copied from m4/ghc_convert_vendor.m4
    
    Towards #23868
    
    - - - - -
    838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add loongarch64 to parseArch
    
    Towards #23868
    
    - - - - -
    1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Add same LD hack to ghc-toolchain
    
    In the ./configure script, if you pass the `LD` variable then this has
    the effect of stopping use searching for a linker and hence passing
    `-fuse-ld=...`.
    
    We want to emulate this logic in ghc-toolchain, if a use explicilty
    specifies `LD` variable then don't add `-fuse-ld=..` with the goal of
    making ./configure and ghc-toolchain agree on which flags to use when
    using the C compiler as a linker.
    
    This is quite unsavoury as we don't bake the choice of LD into the
    configuration anywhere but what's important for now is making
    ghc-toolchain and ./configure agree as much as possible.
    
    See #23857 for more discussion
    
    - - - - -
    42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check for C99 support with -std=c99
    
    Previously we failed to try enabling C99 support with `-std=c99`, as
    `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which
    don't enable C99 by default.
    
    Fixes #23879.
    
    - - - - -
    da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro
    
    In very old toolchains the BYTE_ORDER macro is not set but thankfully
    the __BYTE_ORDER__ macro can be used instead.
    
    - - - - -
    d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: AC_PATH_TARGET_TOOL for LD
    
    We want to make sure that LD is set to an absolute path in order to be
    consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL
    macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which
    might use a relative path.
    
    - - - - -
    171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check whether we need -std=gnu99 for CPP as well
    
    In ./configure the C99 flag is passed to the C compiler when used as a C
    preprocessor. So we also check the same thing in ghc-toolchain.
    
    - - - - -
    89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Check for --target linker flag separately to C compiler
    
    There are situations where the C compiler doesn't accept `--target` but
    when used as a linker it does (but doesn't do anything most likely)
    
    In particular with old gcc toolchains, the C compiler doesn't support
    --target but when used as a linker it does.
    
    - - - - -
    37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Use Cc to compile test file in nopie check
    
    We were attempting to use the C compiler, as a linker, to compile a file
    in the nopie check, but that won't work in general as the flags we pass
    to the linker might not be compatible with the ones we pass when using
    the C compiler.
    
    - - - - -
    9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Error when ghc-toolchain fails to compile
    
    This is a small QOL change as if you are working on ghc-toolchain and it
    fails to compile then configure will continue and can give you outdated
    results.
    
    - - - - -
    1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Check whether -no-pie works when the C compiler is used as a linker
    
    `-no-pie` is a flag we pass when using the C compiler as a linker (see
    pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
    compiler used as a linker supports the flag, rather than just the C
    compiler.
    
    - - - - -
    62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Remove javascript special case for --target detection
    
    emcc when used as a linker seems to ignore the --target flag, and for
    consistency with configure which now tests for --target, we remove this
    special case.
    
    - - - - -
    0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00
    toolchain: Don't pass --target to emscripten toolchain
    
    As noted in `Note [Don't pass --target to emscripten toolchain]`,
    emscripten's `emcc` is rather inconsistent with respect to its treatment
    of the `--target` flag. Avoid this by special-casing this toolchain
    in the `configure` script and `ghc-toolchain`.
    
    Fixes on aspect of #23744.
    
    - - - - -
    6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure
    
    Stop passing -gcc-options which mixed together linker flags and
    non-linker flags. There's no guarantee the C compiler will accept both
    of these in each mode.
    
    - - - - -
    c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00
    configure: Probe stage0 link flags
    
    For consistency with later stages and CC.
    
    - - - - -
    1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00
    Stricter Binary.get in GHC.Types.Unit (#23964)
    
    I noticed some thunking while looking at Core.
    This change has very modest, but throughout positive ghc/alloc effect:
    
    ```
     hard_hole_fits(normal) ghc/alloc    283,057,664    281,620,872  -0.5%
    
                  geo. mean                                          -0.1%
                  minimum                                            -0.5%
                  maximum                                            +0.0%
    ```
    
    Fixes #23964.
    
    - - - - -
    a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00
    rel_eng/upload.sh cleanups
    
    - - - - -
    80705335 by doyougnu at 2023-10-10T19:03:18-04:00
    ci: add javascript label rule
    
    This adds a rule which triggers the javascript job when the "javascript"
    label is assigned to an MR.
    
    - - - - -
    a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00
    Make 'wWarningFlagsDeps' include every WarningFlag
    
    Fixes #24071.
    
    - - - - -
    d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00
    Fix pretty printing of overlap pragmas in TH splices (fixes #24074)
    
    - - - - -
    0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    AArch NCG: Refactor getRegister'
    
    Remove some special cases which can be handled just as well by the
    generic case.
    
    This increases code re-use while also fixing #23749. Since some of the
    special case wasn't upholding Note [Signed arithmetic on AArch64].
    
    - - - - -
    1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over mem management checks
    
    These are for heap allocation, a strictly RTS concern.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    The RTS configure one has a new
    ```
    AC_CHECK_SIZEOF([void *])
    ```
    that the top-level configure version didn't have, so that
    `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
    commits, that can go away.
    
    Progress towards #17191
    
    - - - - -
    41130a65 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `__thread` check
    
    This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over misc function checks
    
    These are for general use in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `eventfd` check
    
    This check is for the RTS part of the event manager and has a
    corresponding part in `base`.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    58f3babf by John Ericson at 2023-10-11T16:02:48-04:00
    Split `FP_CHECK_PTHREADS` and move part to RTS configure
    
    `NEED_PTHREAD_LIB` is unused since
    3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
    system), and so is no longer defined.
    
    Progress towards #17191
    
    - - - - -
    e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00
    nativeGen: section flags for .text$foo only
    
    Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
    #22834 in !9810.
    
    It does however add "xr" indiscriminatly to .text sections
    even if splitSections is disabled. This leads to the assembler saying:
    
    ghc_1.s:7849:0: error:
         Warning: Ignoring changed section attributes for .text
         |
    7849 | .section .text,"xr"
         | ^
    
    - - - - -
    f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00
    Modularity: pass TempDir instead of DynFlags (#17957)
    
    - - - - -
    34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00
    Test that functions from `mingwex` are available
    
    Ryan wrote these two minimizations, but they never got added to the test
    suite.
    
    See #23309, #23378
    
    Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com>
    Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com>
    
    - - - - -
    bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00
    Do not check for the `mingwex` library in `/configure`
    
    See the recent discussion in !10360 --- Cabal will itself check for the
    library for the packages that need it, and while the autoconf check
    additionally does some other things like define a `HAS_LIBMINGWEX` C
    Preprocessor macro, those other things are also unused and unneeded.
    
    Progress towards #17191, which aims to get rid of `/configure` entirely.
    
    - - - - -
    43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00
    base: Introduce move modules into src
    
    The only non-move changes here are whitespace changes to pass the
    `whitespace` test and a few testsuite adaptations.
    
    - - - - -
    df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00
    [PEi386 linker] Bounds check and null-deref guard
    
    We should resonably be able to expect that we won't exceed the number of
    sections if we assume to be dealing with legal object files. We can however
    not guarantee that we get some negative values, and while we try to
    special case most, we should exclude negative indexing into the sections
    array.
    
    We also need to ensure that we do not try to derefences targetSection,
    if it is NULL, due to the switch statement.
    
    - - - - -
    c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
    Move apple compat check to RTS configure
    
    - - - - -
    c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
    Move clock/timer fun checks to RTS configure
    
    Actual library check (which will set the Cabal flag) is left in the
    top-level configure for now.
    
    Progress towards #17191
    
    - - - - -
    7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
    Move visibility and "musttail" annotation checks to the RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
    Move leading underscore checks to RTS configure
    
    `CabalLeadingUnderscore` is done via Hadrian already, so we can stop
    `AC_SUBST`ing it completely.
    
    - - - - -
    25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
    Move alloca, fork, const, and big endian checks to RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    - - - - -
    5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
    Move libdl check to RTS configure
    
    - - - - -
    ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
    Adjust `FP_FIND_LIBFFI`
    
    Just set vars, and `AC_SUBST` in top-level configure.
    
    Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
    be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
    make build system).
    
    - - - - -
    f399812c by John Ericson at 2023-10-12T10:31:13-04:00
    Split BFD support to RTS configure
    
    The flag is still in the top-level configure, but the other checks
    (which define various macros --- important) are in the RTS configure.
    
    - - - - -
    f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
    Split libm check between top level and RTS
    
    - - - - -
    dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
    CgUtils.fixStgRegStmt respect register width
    
    This change ensure that the reg + offset computation is always of the
    same size.  Before this we could end up with a 64bit register, and then
    add a 32bit offset (on 32bit platforms).  This not only would fail type
    sanity checking, but also incorrectly truncate 64bit values into 32bit
    values silently on 32bit architectures.
    
    - - - - -
    9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00
    Fix restarts in .ghcid
    
    Using the whole of `hadrian/` restarted in a loop for me.
    
    - - - - -
    fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    NoFib results (omitted = 0.0%):
    ```
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             pretty           0.0%     -1.6%
                scc           0.0%     -1.7%
    --------------------------------------------------------------------------------
                Min           0.0%     -1.7%
                Max           0.0%     -0.0%
     Geometric Mean          -0.0%     -0.0%
    ```
    
    - - - - -
    32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00
    hadrian: Move ghcBinDeps into ghcLibDeps
    
    This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the
    `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc`
    library so need to make sure they are present in the libdir even if we
    are not going to build `ghc-bin`.
    
    This also fixes things for cross compilers because the stage2
    cross-compiler requires the ghc-usage.txt file, but we are using
    the stage2 lib folder but not building stage3:exe:ghc-bin so
    ghc-usage.txt was not being generated.
    
    - - - - -
    ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00
    Combine GREs when combining in mkImportOccEnv
    
    In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import
    item in favour of another, as explained in Note [Dealing with imports]
    in `GHC.Rename.Names`. However, this can cause us to lose track of
    important parent information.
    
    Consider for example #24084:
    
      module M1 where { class C a where { type T a } }
      module M2 ( module M1 ) where { import M1 }
      module M3 where { import M2 ( C, T ); instance C () where T () = () }
    
    When processing the import list of `M3`, we start off (for reasons that
    are not relevant right now) with two `Avail`s attached to `T`, namely
    `C(C, T)` and `T(T)`. We combine them in the `combine` function of
    `mkImportOccEnv`; as described in Note [Dealing with imports] we discard
    `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not**
    discard the information want that `C` is the parent of `T`. Indeed,
    losing track of this information can cause errors when importing,
    as we could get an error of the form
    
      ‘T’ is not a (visible) associated type of class ‘C’
    
    We fix this by combining the two GREs for `T` using `plusGRE`.
    
    Fixes #24084
    
    - - - - -
    257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00
    hadrian: Pass -DNOSMP to C compiler when needed
    
    Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
    SMP, but doesn't pass it to CC as well, leading to the following
    compilation error on mips64el:
    
    | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
    Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
    ===> Command failed with error code: 1
    In file included from rts/include/Stg.h:348,
                     from rts/include/Rts.h:38,
                     from rts/hooks/FlagDefaults.c:8:
    rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
      416 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
      440 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
      464 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    
    The old make system correctly passed this flag to both GHC and CC [1].
    
    Fix this error by passing -DNOSMP to CC as well.
    
    [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
    
    Closes #24082
    
    - - - - -
    13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00
    Users Guide: Drop dead code for Haddock refs to `parallel`
    
    I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was
    not substituted. It is dead code -- there is no `parallel-ref` usages
    and it doesn't look like there ever was (going back to
    3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it.
    
    - - - - -
    fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)
    
    bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".
    
    - - - - -
    cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Bignum: fix right shift of negative BigNat with native backend
    
    - - - - -
    cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Rts: expose rtsOutOfBoundsAccess symbol
    
    - - - - -
    72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Hadrian: enable `-fcheck-prim-bounds` in validate flavour
    
    This allows T24066 to fail when the bug is present.
    
    Otherwise the out-of-bound access isn't detected as it happens in
    ghc-bignum which wasn't compiled with the bounds check.
    
    - - - - -
    f9436990 by John Ericson at 2023-10-18T19:41:01-04:00
    Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in`
    
    Fixes #24091
    Progress on #23966
    
    Issue #24091 reports that `@ProjectVersion@` is no longer being
    substituted in the GHC user's guide. I assume this is a recent issue,
    but I am not sure how it's worked since
    c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and
    configure are trying to substitute the same `.in` file!
    
    Now only Hadrian does. That is better anyways; already something that
    issue #23966 requested.
    
    It seems like we were missing some dependencies in Hadrian. (I really,
    really hate that this is possible!) Hopefully it is fixed now.
    
    - - - - -
    b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00
    `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`
    
    Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
    be defined. (Guaranteed including a test in the testsuite.)
    
    - - - - -
    0295375a by John Ericson at 2023-10-18T19:41:37-04:00
    Generate `ghcversion.h` from a `.in` file
    
    Now that there are no conditional sections (see the previous commit), we
    can just a do simple substitution rather than pasting it together line
    by line.
    
    Progress on #23966
    
    - - - - -
    740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00
    Add a regression test for #24064
    
    - - - - -
    921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00
    CLC Proposal #182: Export List from Data.List
    
    Proposal link: https://github.com/haskell/core-libraries-committee/issues/182
    
    - - - - -
    4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
    rts: fix small argument passing on big-endian arch (fix #23387)
    
    - - - - -
    b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
    Interpreter: fix literal alignment on big-endian architectures (fix #19261)
    
    Literals weren't correctly aligned on big-endian, despite what the
    comment said.
    
    - - - - -
    a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
    Testsuite: recomp011 and recomp015 are fixed on powerpc
    
    These tests have been fixed but not tested and re-enabled on big-endian
    powerpc (see comments in #11260 and #11323)
    
    - - - - -
    fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
    CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
    - - - - -
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    e4e3837a by Vladislav Zavialov at 2023-10-26T19:32:32+03:00
    WIP: T2T in Expressions
    
    - - - - -
    
    
    30 changed files:
    
    - .ghcid
    - .gitignore
    - .gitlab/ci.sh
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    - .gitlab/rel_eng/upload.sh
    - .gitlab/test-metrics.sh
    - compiler/CodeGen.Platform.h
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/ByteCode/Asm.hs
    - compiler/GHC/CmmToAsm.hs
    - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
    - compiler/GHC/CmmToAsm/AArch64/Instr.hs
    - compiler/GHC/CmmToAsm/AArch64/Ppr.hs
    - compiler/GHC/CmmToAsm/AArch64/Regs.hs
    - compiler/GHC/CmmToAsm/Ppr.hs
    - compiler/GHC/Core/Coercion.hs
    - compiler/GHC/Core/Coercion/Opt.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Data/FastString.hs
    - compiler/GHC/Data/OrdList.hs
    - compiler/GHC/Driver/Config/Linker.hs
    - compiler/GHC/Driver/Config/Tidy.hs
    - compiler/GHC/Driver/Flags.hs
    - compiler/GHC/Driver/Pipeline/Execute.hs
    - compiler/GHC/Driver/Session.hs
    - compiler/GHC/Hs/Expr.hs
    - compiler/GHC/Hs/Extension.hs
    - compiler/GHC/Hs/Type.hs
    - compiler/GHC/Hs/Utils.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96bbea260945576e201a4931e79ec7db755cc821...e4e3837ad3f39437368fdf1aa195534b0198b90b
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96bbea260945576e201a4931e79ec7db755cc821...e4e3837ad3f39437368fdf1aa195534b0198b90b
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 26 21:33:35 2023
    From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring))
    Date: Thu, 26 Oct 2023 17:33:35 -0400
    Subject: [Git][ghc/ghc][wip/T15226-stg] Teach tag-inference about SeqOp/seq#
    Message-ID: <653adb2f669f7_1f7b0d949853846884df@gitlab.mail>
    
    
    
    Matthew Craven pushed to branch wip/T15226-stg at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    f8c340c7 by Matthew Craven at 2023-10-26T17:32:48-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    
    
    13 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.stderr
    - testsuite/tests/simplStg/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/inferTags003.hs
    - + testsuite/tests/simplStg/should_compile/inferTags003.stderr
    - + testsuite/tests/simplStg/should_compile/inferTags004.hs
    - + testsuite/tests/simplStg/should_compile/inferTags004.stderr
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -3640,7 +3640,7 @@ primop SparkOp "spark#" GenPrimOp
        with effect = ReadWriteEffect
        code_size = { primOpCodeSizeForeignCall }
     
    --- See Note [seq# magic] in GHC.Core.Op.ConstantFold
    +-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
     primop SeqOp "seq#" GenPrimOp
        a -> State# s -> (# State# s, a #)
        with
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2108,6 +2108,9 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a
    +  properly-tagged pointer inside of its unboxed-tuple result.
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/Stg/InferTags.hs
    =====================================
    @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) )
     import GHC.Types.Unique.Supply (mkSplitUniqSupply)
     import GHC.Types.RepType (dataConRuntimeRepStrictness)
     import GHC.Core (AltCon(..))
    +import GHC.Builtin.PrimOps ( PrimOp(..) )
     import Data.List (mapAccumL)
     import GHC.Utils.Outputable
     import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull )
    @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args)
              | otherwise
              = --pprTrace "inferAppUnknown" (ppr fun) $
                TagDunno
    --- TODO:
    --- If we have something like:
    ---   let x = thunk in
    ---   f g = case g of g' -> (# x, g' #)
    --- then we *do* know that g' will be properly tagged,
    --- so we should return TagTagged [TagDunno,TagProper] but currently we infer
    --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr.
    --- Seems not to matter much but should be changed eventually.
     
     inferTagExpr env (StgConApp con cn args tys)
       = (inferConTag env con args, StgConApp con cn args tys)
    @@ -340,9 +333,21 @@ inferTagExpr env (StgTick tick body)
         (info, body') = inferTagExpr env body
     
     inferTagExpr _ (StgOpApp op args ty)
    -  = -- Do any primops guarantee to return a properly tagged value?
    -    -- I think not.  Ditto foreign calls.
    -    (TagDunno, StgOpApp op args ty)
    +  | StgPrimOp SeqOp <- op
    +  -- Recall seq# :: a -> State# s -> (# State# s, a #)
    +  -- However the output State# token has been unarised away,
    +  -- so we now effectively have
    +  --    seq# :: a -> State# s -> (# a #)
    +  -- The key point is the result of `seq#` is guaranteed evaluated and properly
    +  -- tagged (because that result comes directly from evaluating the arg),
    +  -- and we want tag inference to reflect that knowledge (#15226).
    +  -- Hence `TagTuple [TagProper]`.
    +  -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
    +  = (TagTuple [TagProper], StgOpApp op args ty)
    +  -- Do any other primops guarantee to return a properly tagged value?
    +  -- Probably not, and that is the conservative assumption anyway.
    +  -- (And foreign calls definitely need not make promises.)
    +  | otherwise = (TagDunno, StgOpApp op args ty)
     
     inferTagExpr env (StgLet ext bind body)
       = (info, StgLet ext bind' body')
    
    
    =====================================
    compiler/GHC/Stg/InferTags/Rewrite.hs
    =====================================
    @@ -217,7 +217,7 @@ withLcl fv act = do
     When compiling bytecode we call myCoreToStg to get STG code first.
     myCoreToStg in turn calls out to stg2stg which runs the STG to STG
     passes followed by free variables analysis and the tag inference pass including
    -it's rewriting phase at the end.
    +its rewriting phase at the end.
     Running tag inference is important as it upholds Note [Strict Field Invariant].
     While code executed by GHCi doesn't take advantage of the SFI it can call into
     compiled code which does. So it must still make sure that the SFI is upheld.
    @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr
     rewriteExpr (e at StgCase {})          = rewriteCase e
     rewriteExpr (e at StgLet {})           = rewriteLet e
     rewriteExpr (e at StgLetNoEscape {})   = rewriteLetNoEscape e
    -rewriteExpr (StgTick t e)     = StgTick t <$!> rewriteExpr e
    +rewriteExpr (StgTick t e)           = StgTick t <$!> rewriteExpr e
     rewriteExpr e@(StgConApp {})        = rewriteConApp e
    -rewriteExpr e@(StgApp {})     = rewriteApp e
    -rewriteExpr (StgLit lit)           = return $! (StgLit lit)
    -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do
    -        (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty)
    +rewriteExpr e@(StgOpApp {})         = rewriteOpApp e
    +rewriteExpr e@(StgApp {})           = rewriteApp e
    +rewriteExpr (StgLit lit)            = return $! (StgLit lit)
     
     
     rewriteCase :: InferStgExpr -> RM TgStgExpr
    @@ -488,6 +486,33 @@ rewriteApp (StgApp f args)
     rewriteApp (StgApp f args) = return $ StgApp f args
     rewriteApp _ = panic "Impossible"
     
    +{-
    +Note [Rewriting primop arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Given an application `op# x y`, is it worth applying `rewriteArg` to
    +`x` and `y`?  All that will do will be to set the `tagSig` for that
    +occurrence of `x` and `y` to record whether it is evaluated and
    +properly tagged. For the vast majority of primops that's a waste of
    +time: the argument is an `Int#` or something.
    +
    +But code generation for `seq#` and `dataToTag#` /does/ consult that
    +tag, to statically avoid generating an eval:
    +* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig`
    +* `dataToTag#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`.
    +
    +So for these we should call `rewriteArgs`.
    +
    +-}
    +
    +rewriteOpApp :: InferStgExpr -> RM TgStgExpr
    +rewriteOpApp (StgOpApp op args res_ty) = case op of
    +  op@(StgPrimOp primOp)
    +    | primOp == SeqOp || primOp == DataToTagOp
    +    -- see Note [Rewriting primop arguments]
    +    -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    +  _ -> pure $! StgOpApp op args res_ty
    +rewriteOpApp _ = panic "Impossible"
    +
     -- `mkSeq` x x' e generates `case x of x' -> e`
     -- We could also substitute x' for x in e but that's so rarely beneficial
     -- that we don't bother.
    
    
    =====================================
    compiler/GHC/Stg/InferTags/TagSig.hs
    =====================================
    @@ -5,7 +5,7 @@
     -- We export this type from this module instead of GHC.Stg.InferTags.Types
     -- because it's used by more than the analysis itself. For example in interface
     -- files where we record a tag signature for bindings.
    --- By putting the sig into it's own module we can avoid module loops.
    +-- By putting the sig into its own module we can avoid module loops.
     module GHC.Stg.InferTags.TagSig
     
     where
    @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> ()
     seqTagInfo TagTagged      = ()
     seqTagInfo TagDunno       = ()
     seqTagInfo TagProper      = ()
    -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    \ No newline at end of file
    +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of
     --
     -- In more complex cases, there is a foreign call (out of line) fallback. This
     -- might happen e.g. if there's enough static information, such as statically
    --- know arguments.
    +-- known arguments.
     emitPrimOp
       :: StgToCmmConfig
       -> PrimOp            -- ^ The primop
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T15226b where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- tag inference should not insert an eval for x' in making the strict pair
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -0,0 +1,48 @@
    +
    +==================== Final STG: ====================
    +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
    +    {} \r [conrep conrep1]
    +        case conrep of conrep2 [Occ=Once1] {
    +        __DEFAULT ->
    +        case conrep1 of conrep3 [Occ=Once1] {
    +        __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
    +        };
    +        };
    +
    +T15226b.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [x y void]
    +        case seq# [x GHC.Prim.void#] of {
    +        Solo# ipv1 [Occ=Once1] ->
    +        let {
    +          sat [Occ=Once1] :: T15226b.StrictPair a b
    +          [LclId] =
    +              {ipv1, y} \u []
    +                  case y of conrep [Occ=Once1] {
    +                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    +                  };
    +        } in  seq# [sat GHC.Prim.void#];
    +        };
    +
    +T15226b.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#;
    +
    +T15226b.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
    +    {} \r [eta eta]
    +        case eta of eta {
    +        __DEFAULT ->
    +        case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; };
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/all.T
    =====================================
    @@ -18,3 +18,8 @@ test('T22840', [extra_files(
             [ 'T22840A.hs'
             , 'T22840B.hs'
             ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks'])
    +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds'])
    +test('inferTags003', [ only_ways(['optasm']),
    +                       grep_errmsg(r'(call stg\_ap\_0)', [1])
    +                     ], compile, ['-ddump-cmm -dno-typeable-binds -O'])
    +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques'])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE MagicHash #-}
    +module M where
    +
    +import GHC.Exts
    +import GHC.IO
    +
    +data T a = MkT !Bool !a
    +
    +fun :: T a -> IO a
    +{-# OPAQUE fun #-}
    +fun (MkT _ x) = IO $ \s -> noinline seq# x s
    +-- evaluate/seq# should not produce its own eval for x
    +-- since it is properly tagged (from a strict field)
    +
    +-- uses noinline to prevent caseRules from eliding the seq# in Core
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.stderr
    =====================================
    @@ -0,0 +1,177 @@
    +
    +==================== Output Cmm ====================
    +[M.$WMkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cEx,
    +                        label: block_cEx_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cEA,
    +                        label: M.$WMkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cED,
    +                        label: block_cED_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEA: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH;   // CmmCondBranch
    +       cEG: // global
    +           R1 = M.$WMkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cEH: // global
    +           I64[Sp - 16] = cEx;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEx; else goto cEy;   // CmmCondBranch
    +       cEy: // global
    +           call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEx: // global
    +           // slowCall
    +           I64[Sp] = cED;   // CmmStore
    +           _sEi::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _sEi::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cED: // global
    +           // slow_call for _sEh::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cEL; else goto cEK;   // CmmCondBranch
    +       cEL: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEK: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.$WMkT_closure" {
    +     M.$WMkT_closure:
    +         const M.$WMkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.fun_entry() { //  [R2]
    +         { info_tbls: [(cEV,
    +                        label: block_cEV_info
    +                        rep: StackRep []
    +                        srt: Nothing),
    +                       (cEY,
    +                        label: M.fun_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEY: // global
    +           if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0;   // CmmCondBranch
    +       cEZ: // global
    +           R1 = M.fun_closure;   // CmmAssign
    +           call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cF0: // global
    +           I64[Sp - 8] = cEV;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           Sp = Sp - 8;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEV; else goto cEW;   // CmmCondBranch
    +       cEW: // global
    +           call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEV: // global
    +           R1 = P64[R1 + 15];   // CmmAssign
    +           Sp = Sp + 8;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.fun_closure" {
    +     M.fun_closure:
    +         const M.fun_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cFc,
    +                        label: block_cFc_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cFf,
    +                        label: M.MkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cFi,
    +                        label: block_cFi_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFf: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm;   // CmmCondBranch
    +       cFl: // global
    +           R1 = M.MkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cFm: // global
    +           I64[Sp - 16] = cFc;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cFc; else goto cFd;   // CmmCondBranch
    +       cFd: // global
    +           call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFc: // global
    +           // slowCall
    +           I64[Sp] = cFi;   // CmmStore
    +           _tEq::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _tEq::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFi: // global
    +           // slow_call for _B1::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cFq; else goto cFp;   // CmmCondBranch
    +       cFq: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFp: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.MkT_closure" {
    +     M.MkT_closure:
    +         const M.MkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_con_entry() { //  []
    +         { info_tbls: [(cFw,
    +                        label: M.MkT_con_info
    +                        rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFw: // global
    +           R1 = R1 + 1;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + }]
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.hs
    =====================================
    @@ -0,0 +1,11 @@
    +{-# LANGUAGE BangPatterns, UnboxedTuples #-}
    +module InferTags004 where
    +
    +x :: Int
    +x = x
    +
    +f :: a -> (# Int, a #)
    +-- Adapted from a TODO in InferTags.
    +-- f's tag signature should indicate that the second component
    +-- of its result is properly tagged: TagTuple[TagDunno,TagProper]
    +f g = case g of !g' -> (# x, g' #)
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.stderr
    =====================================
    @@ -0,0 +1,13 @@
    +
    +==================== CodeGenAnal STG: ====================
    +Rec {
    +(InferTags004.x, ) = {} \u [] InferTags004.x;
    +end Rec }
    +
    +(InferTags004.f, ) =
    +    {} \r [(g, )]
    +        case g of (g', ) {
    +        __DEFAULT -> (#,#) [InferTags004.x g'];
    +        };
    +
    +
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8c340c7e59e2bd4e600f1b3e436828e8a176d0c
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8c340c7e59e2bd4e600f1b3e436828e8a176d0c
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Thu Oct 26 22:49:55 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Thu, 26 Oct 2023 18:49:55 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Explicitly
     require RLIMIT_AS before use in OSMem.c
    Message-ID: <653aed139e87e_1f7b0d963352707032ee@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    298578a2 by doyougnu at 2023-10-26T18:49:38-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    e73aa26e by Simon Peyton Jones at 2023-10-26T18:49:38-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    
    
    15 changed files:
    
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/Driver/Config/Linker.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/Linker/Config.hs
    - compiler/GHC/Linker/Dynamic.hs
    - + compiler/GHC/Linker/External.hs
    - compiler/GHC/Linker/Static.hs
    - compiler/GHC/StgToJS/Apply.hs
    - compiler/GHC/StgToJS/Arg.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/461aa62543484fe3abfaa74275797431099baccf...e73aa26e006079e2061cbd504a63e3ad25adc1fe
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/461aa62543484fe3abfaa74275797431099baccf...e73aa26e006079e2061cbd504a63e3ad25adc1fe
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 02:50:02 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Thu, 26 Oct 2023 22:50:02 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: js: add JStg
     IR, remove unsaturated constructor
    Message-ID: <653b255a75138_1f7b0d9bedf9187123d1@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    f3e64f91 by doyougnu at 2023-10-26T22:49:58-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    a6129449 by Simon Peyton Jones at 2023-10-26T22:49:58-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    
    
    11 changed files:
    
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/StgToJS/Apply.hs
    - compiler/GHC/StgToJS/Arg.hs
    - compiler/GHC/StgToJS/Closure.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e73aa26e006079e2061cbd504a63e3ad25adc1fe...a61294493a1ef5c02b444c20c823a673fd19eecb
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e73aa26e006079e2061cbd504a63e3ad25adc1fe...a61294493a1ef5c02b444c20c823a673fd19eecb
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 03:23:08 2023
    From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring))
    Date: Thu, 26 Oct 2023 23:23:08 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/bump-bytestring-0.11.5.3
    Message-ID: <653b2d1ce1bf3_1f7b0d9cdc41187174a8@gitlab.mail>
    
    
    
    Matthew Craven pushed new branch wip/bump-bytestring-0.11.5.3 at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-bytestring-0.11.5.3
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 06:20:47 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Fri, 27 Oct 2023 02:20:47 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: js: add JStg
     IR, remove unsaturated constructor
    Message-ID: <653b56bf43216_1f7b0da10878887289e9@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    d5dfe08b by doyougnu at 2023-10-27T02:20:43-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    ee493bfc by Simon Peyton Jones at 2023-10-27T02:20:43-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    
    
    11 changed files:
    
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/StgToJS/Apply.hs
    - compiler/GHC/StgToJS/Arg.hs
    - compiler/GHC/StgToJS/Closure.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a61294493a1ef5c02b444c20c823a673fd19eecb...ee493bfc0424b089ddd009bdde49da1c8c0c4f7e
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a61294493a1ef5c02b444c20c823a673fd19eecb...ee493bfc0424b089ddd009bdde49da1c8c0c4f7e
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 10:01:23 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Fri, 27 Oct 2023 06:01:23 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: js: add JStg
     IR, remove unsaturated constructor
    Message-ID: <653b8a7346cd2_1f7b0da613675c7612ae@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    c6e78b8e by doyougnu at 2023-10-27T06:01:02-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    52de01d4 by Simon Peyton Jones at 2023-10-27T06:01:02-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    
    
    11 changed files:
    
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/StgToJS/Apply.hs
    - compiler/GHC/StgToJS/Arg.hs
    - compiler/GHC/StgToJS/Closure.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee493bfc0424b089ddd009bdde49da1c8c0c4f7e...52de01d47cb4cc4e1a1633aa95844bd0fe37b92e
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee493bfc0424b089ddd009bdde49da1c8c0c4f7e...52de01d47cb4cc4e1a1633aa95844bd0fe37b92e
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 12:41:41 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Fri, 27 Oct 2023 08:41:41 -0400
    Subject: [Git][ghc/ghc][master] js: add JStg IR, remove unsaturated constructor
    Message-ID: <653bb005b60c7_1f7b0da9af2e5077569b@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    
    
    11 changed files:
    
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/StgToJS/Apply.hs
    - compiler/GHC/StgToJS/Arg.hs
    - compiler/GHC/StgToJS/Closure.hs
    - compiler/GHC/StgToJS/CodeGen.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0f3503006cf1a0be2a456ac868765720e7cb85c
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0f3503006cf1a0be2a456ac868765720e7cb85c
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 12:42:25 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Fri, 27 Oct 2023 08:42:25 -0400
    Subject: [Git][ghc/ghc][master] Fix a bug in tail calls with ticks
    Message-ID: <653bb031283ca_1f7b0da9af2e507790b3@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Opt/OccurAnal.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/OccurAnal.hs
    =====================================
    @@ -2493,32 +2493,34 @@ But it is not necessary to gather CoVars from the types of other binders.
     -}
     
     occAnal env (Tick tickish body)
    -  | SourceNote{} <- tickish
    -  = WUD usage (Tick tickish body')
    -                  -- SourceNotes are best-effort; so we just proceed as usual.
    -                  -- If we drop a tick due to the issues described below it's
    -                  -- not the end of the world.
    +  = WUD usage' (Tick tickish body')
    +  where
    +    WUD usage body' = occAnal env body
     
    -  | tickish `tickishScopesLike` SoftScope
    -  = WUD (markAllNonTail usage) (Tick tickish body')
    +    usage'
    +      | tickish `tickishScopesLike` SoftScope
    +      = usage  -- For soft-scoped ticks (including SourceNotes) we don't want
    +               -- to lose join-point-hood, so we don't mess with `usage` (#24078)
     
    -  | Breakpoint _ _ ids _ <- tickish
    -  = WUD (addManyOccs usage_lam (mkVarSet ids)) (Tick tickish body')
    -    -- never substitute for any of the Ids in a Breakpoint
    +      -- For a non-soft tick scope, we can inline lambdas only, so we
    +      -- abandon tail calls, and do markAllInsideLam too: usage_lam
    +
    +      |  Breakpoint _ _ ids _ <- tickish
    +      = -- Never substitute for any of the Ids in a Breakpoint
    +        addManyOccs usage_lam (mkVarSet ids)
    +
    +      | otherwise
    +      = usage_lam
     
    -  | otherwise
    -  = WUD usage_lam (Tick tickish body')
    -  where
    -    (WUD usage body') = occAnal env body
    -    -- for a non-soft tick scope, we can inline lambdas only
         usage_lam = markAllNonTail (markAllInsideLam usage)
    -                  -- TODO There may be ways to make ticks and join points play
    -                  -- nicer together, but right now there are problems:
    -                  --   let j x = ... in tick (j 1)
    -                  -- Making j a join point may cause the simplifier to drop t
    -                  -- (if the tick is put into the continuation). So we don't
    -                  -- count j 1 as a tail call.
    -                  -- See #14242.
    +
    +    -- TODO There may be ways to make ticks and join points play
    +    -- nicer together, but right now there are problems:
    +    --   let j x = ... in tick (j 1)
    +    -- Making j a join point may cause the simplifier to drop t
    +    -- (if the tick is put into the continuation). So we don't
    +    -- count j 1 as a tail call.
    +    -- See #14242.
     
     occAnal env (Cast expr co)
       = let  (WUD usage expr') = occAnal env expr
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35587eba3feb609bc6de3a290e7e47641137f946
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35587eba3feb609bc6de3a290e7e47641137f946
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 16:02:11 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Fri, 27 Oct 2023 12:02:11 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] More care with discounts and sizes
    Message-ID: <653bdf03caf24_1f7b0daf07146c78933f@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    d9ba9b84 by Simon Peyton Jones at 2023-10-27T17:01:33+01:00
    More care with discounts and sizes
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -519,10 +519,6 @@ exprTree opts args expr
            -- Forcing bOMB_OUT_SIZE early prevents repeated
            -- unboxing of the Int argument.
     
    -    ok_case :: Int -> Int -> Bool
    -    ok_case case_depth n_alts  -- Case is not too deep, nor too wide
    -      = case_depth > 0 && n_alts <= max_width
    -
         et_add     = metAdd bOMB_OUT_SIZE
         et_add_alt = metAddAlt bOMB_OUT_SIZE
     
    @@ -606,19 +602,20 @@ exprTree opts args expr
     
         -- Record a CaseOf
         go_case cd vs@(avs,lvs) scrut b alts
    -      | Just v <- recordCaseOf vs scrut
    +      | Just v <- interestingVarScrut vs scrut
           = go cd vs scrut `et_add`
    -        (if   ok_case cd n_alts
    +        (if   record_case cd n_alts
              then do { alts' <- mapM (alt_alt_tree v) alts
                      ; etCaseOf bOMB_OUT_SIZE v b alts' }
    -         else Just (etScrutOf v (10 * n_alts)) `et_add`
    +         else Just (etScrutOf v caseElimDiscount) `et_add`
    +              -- When this scrutinee has structure, we expect to eliminate the case
                   go_alts cd vs b alts)
           where
             cd1 = cd - 1
             n_alts = length alts
             alt_alt_tree :: Id -> Alt Var -> Maybe AltTree
             alt_alt_tree v (Alt con bs rhs)
    -          = do { rhs <- 10 `metAddN` go cd1 (add_alt_bndrs v val_bs) rhs
    +          = do { rhs <- go cd1 (add_alt_bndrs v val_bs) rhs
                    ; return (AltTree con val_bs rhs) }
               where
                 val_bs = filter isId bs
    @@ -630,25 +627,29 @@ exprTree opts args expr
     
         -- Don't record a CaseOf
         go_case cd vs scrut b alts    -- alts is non-empty
    -      = caseSize scrut alts `metAddN`   -- A bit odd that this is only in one branch
    -        go cd vs scrut      `et_add`
    -        go_alts cd vs b alts
    +      = caseSize scrut alts     `metAddN`   -- A bit odd that this is only in one branch
    +        (altSize * length alts) `metAddN`
    +            -- IMPORTANT: charge `altSize` for each alternative, else we
    +            -- find that giant case nests are treated as practically free
    +            -- A good example is Foreign.C.Error.errnoToIOError
    +        go cd vs scrut `et_add` go_alts cd vs b alts
    +
    +    record_case :: Int -> Int -> Bool
    +    -- True <=> record CaseOf; False <=> record ScrutOf
    +    record_case case_depth n_alts  -- Case is not too deep, nor too wide
    +      = case_depth > 0 && n_alts <= max_width
     
         go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> Maybe ExprTree
    -    -- Add up the sizes of all RHSs, plus 10 for each alternative
    +    -- Add up the sizes of all RHSs
         go_alts cd vs b alts = foldr1 et_add_alt (map alt_expr_tree alts)
           where
             cd1 = cd - 1
             alt_expr_tree :: Alt Var -> Maybe ExprTree
    -        alt_expr_tree (Alt _con bs rhs)
    -          = 10 `metAddN` go cd1 (vs `add_lvs` (b:bs)) rhs
    +        alt_expr_tree (Alt _con bs rhs) = go cd1 (vs `add_lvs` (b:bs)) rhs
                 -- Don't charge for bndrs, so that wrappers look cheap
                 -- (See comments about wrappers with Case)
                 -- Don't forget to add the case binder, b, to lvs.
                 --
    -            -- IMPORTANT: *do* charge 10 for the alternative, else we
    -            -- find that giant case nests are treated as practically free
    -            -- A good example is Foreign.C.Error.errnoToIOError
     
     caseSize :: CoreExpr -> [CoreAlt] -> Size
     caseSize scrut alts
    @@ -693,13 +694,14 @@ add_lv (avs,lvs) b = (avs, lvs `extendVarSet` b)
     add_lvs :: ETVars -> [Var] -> ETVars
     add_lvs (avs,lvs) bs = (avs, lvs `extendVarSetList` bs)
     
    -recordCaseOf :: ETVars -> CoreExpr -> Maybe Id
    -recordCaseOf (_,lvs) (Var v)
    +interestingVarScrut :: ETVars -> CoreExpr -> Maybe Id
    +-- The scrutinee of a case is worth recording
    +interestingVarScrut (_,lvs) (Var v)
          | v `elemVarSet` lvs  = Nothing
          | otherwise           = Just v
    -recordCaseOf vs (Tick _ e) = recordCaseOf vs e
    -recordCaseOf vs (Cast e _) = recordCaseOf vs e
    -recordCaseOf _     _       = Nothing
    +interestingVarScrut vs (Tick _ e) = interestingVarScrut vs e
    +interestingVarScrut vs (Cast e _) = interestingVarScrut vs e
    +interestingVarScrut _     _       = Nothing
     
     isZeroBitArg :: CoreExpr -> Bool
     -- We could take ticks and casts into account, but it makes little
    @@ -760,7 +762,7 @@ classOpSize _ _ _ [] _
       = etZero
     classOpSize opts vs fn val_args voids
       | arg1 : _ <- val_args
    -  , Just dict <- recordCaseOf vs arg1
    +  , Just dict <- interestingVarScrut vs arg1
       = warnPprTrace (not (isId dict)) "classOpSize" (ppr fn <+> ppr val_args) $
         vanillaCallSize (length val_args) voids `etAddN`
         etScrutOf dict (unfoldingDictDiscount opts)
    @@ -821,7 +823,13 @@ primOpSize op n_val_args
      where
        op_size = primOpCodeSize op
     
    +altSize :: Size
    +-- We charge `altSize` for each alternative in a case
    +altSize = 10
     
    +caseElimDiscount :: Discount
    +-- Bonus for eliminating a case
    +caseElimDiscount = 10
     
     {- Note [Constructor size and result discount]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    @@ -983,6 +991,9 @@ Code for manipulating sizes
     -}
     
     ---------------------------------------
    +-- Right associative; predence level unimportant
    +infixr 5 `metAddN`, `etAddN`, `metAdd`, `metAddAlt`
    +
     metAddN :: Size -> Maybe ExprTree -> Maybe ExprTree
     metAddN _ Nothing = Nothing
     metAddN n (Just et) = Just (n `etAddN` et)
    @@ -1041,7 +1052,7 @@ etCaseOf bOMB_OUT_SIZE scrut case_bndr alts
                                               , et_cases = unitBag case_tree })
       where
         case_tree = CaseOf scrut case_bndr alts
    -    tot = altTreesSize alts
    +    tot       = altTreesSize alts
     
     altTreesSize :: [AltTree] -> Size
     -- Total aize of a [AltTree]
    @@ -1124,7 +1135,8 @@ caseTreeSize ic (CaseOf scrut_var case_bndr alts)
                    ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
                          -- In DEFAULT case, bs is empty, so extending is a no-op
              -> assertPpr ((alt_con == DEFAULT) || (bndrs `equalLength` args)) (ppr arg_summ $$ ppr at) $
    -            exprTreeSize ic' rhs
    +            exprTreeSize ic' rhs - caseElimDiscount
    +              -- Take off a discount for eliminating the case expression itself
     
              | otherwise  -- Happens for empty alternatives
              -> keptCaseSize ic case_bndr alts
    @@ -1148,17 +1160,19 @@ trim_alts acs (alt:alts)
     
     keptCaseSize :: InlineContext -> Id -> [AltTree] -> Size
     -- Size of a (retained) case expression
    -keptCaseSize ic case_bndr alts = foldr ((+) . size_alt) 0 alts
    +keptCaseSize ic case_bndr alts = foldr ((+) . size_alt) case_size alts
       -- Just add up the  sizes of the alternatives
    -  -- We make the case itself free, but charge for each alternatives
    -  -- (the latter is already included in the AltTrees)
    -  -- If there are no alternatives (case e of {}), we get zero
       -- We recurse in case we have
       --    args = [a,b], expr_tree = [CaseOf a [ X -> CaseOf b [...]
       --                                        , Y -> CaseOf b [...] ] ]
       -- Then for a call with ArgInfo for `b`, but not `a`, we want to get
       -- the trimmed trees in the X and Y branches
       where
    +    case_size = altSize * length alts
    +      -- We make the case itself free, but charge for each alternatives
    +      -- (the latter is already included in the AltTrees)
    +      -- If there are no alternatives (case e of {}), we get zero
    +
         size_alt :: AltTree -> Size
         size_alt (AltTree _ bndrs rhs) = exprTreeSize ic' rhs
             -- Cost for the alternative is already in `rhs`
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d9ba9b843f9b0ba4e05be4a7396e1ba1b4cf18c9
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d9ba9b843f9b0ba4e05be4a7396e1ba1b4cf18c9
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 16:36:36 2023
    From: gitlab at gitlab.haskell.org (David (@knothed))
    Date: Fri, 27 Oct 2023 12:36:36 -0400
    Subject: [Git][ghc/ghc][wip/or-pats] 92 commits: Add a flag -fkeep-auto-rules
     to optionally keep auto-generated rules around.
    Message-ID: <653be7142839b_1f7b0daf5e15007913a7@gitlab.mail>
    
    
    
    David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00
    Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.
    
    The motivation for the flag is given in #21917.
    
    - - - - -
    3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Add ghcToolchain to tool args list
    
    This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.
    
    - - - - -
    476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Normalise triple via config.sub
    
    We were not normalising the target triple anymore like we did with the
    old make build system.
    
    Fixes #23856
    
    - - - - -
    303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add missing vendor normalisation
    
    This is copied from m4/ghc_convert_vendor.m4
    
    Towards #23868
    
    - - - - -
    838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add loongarch64 to parseArch
    
    Towards #23868
    
    - - - - -
    1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Add same LD hack to ghc-toolchain
    
    In the ./configure script, if you pass the `LD` variable then this has
    the effect of stopping use searching for a linker and hence passing
    `-fuse-ld=...`.
    
    We want to emulate this logic in ghc-toolchain, if a use explicilty
    specifies `LD` variable then don't add `-fuse-ld=..` with the goal of
    making ./configure and ghc-toolchain agree on which flags to use when
    using the C compiler as a linker.
    
    This is quite unsavoury as we don't bake the choice of LD into the
    configuration anywhere but what's important for now is making
    ghc-toolchain and ./configure agree as much as possible.
    
    See #23857 for more discussion
    
    - - - - -
    42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check for C99 support with -std=c99
    
    Previously we failed to try enabling C99 support with `-std=c99`, as
    `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which
    don't enable C99 by default.
    
    Fixes #23879.
    
    - - - - -
    da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro
    
    In very old toolchains the BYTE_ORDER macro is not set but thankfully
    the __BYTE_ORDER__ macro can be used instead.
    
    - - - - -
    d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: AC_PATH_TARGET_TOOL for LD
    
    We want to make sure that LD is set to an absolute path in order to be
    consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL
    macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which
    might use a relative path.
    
    - - - - -
    171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check whether we need -std=gnu99 for CPP as well
    
    In ./configure the C99 flag is passed to the C compiler when used as a C
    preprocessor. So we also check the same thing in ghc-toolchain.
    
    - - - - -
    89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Check for --target linker flag separately to C compiler
    
    There are situations where the C compiler doesn't accept `--target` but
    when used as a linker it does (but doesn't do anything most likely)
    
    In particular with old gcc toolchains, the C compiler doesn't support
    --target but when used as a linker it does.
    
    - - - - -
    37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Use Cc to compile test file in nopie check
    
    We were attempting to use the C compiler, as a linker, to compile a file
    in the nopie check, but that won't work in general as the flags we pass
    to the linker might not be compatible with the ones we pass when using
    the C compiler.
    
    - - - - -
    9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Error when ghc-toolchain fails to compile
    
    This is a small QOL change as if you are working on ghc-toolchain and it
    fails to compile then configure will continue and can give you outdated
    results.
    
    - - - - -
    1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Check whether -no-pie works when the C compiler is used as a linker
    
    `-no-pie` is a flag we pass when using the C compiler as a linker (see
    pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
    compiler used as a linker supports the flag, rather than just the C
    compiler.
    
    - - - - -
    62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Remove javascript special case for --target detection
    
    emcc when used as a linker seems to ignore the --target flag, and for
    consistency with configure which now tests for --target, we remove this
    special case.
    
    - - - - -
    0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00
    toolchain: Don't pass --target to emscripten toolchain
    
    As noted in `Note [Don't pass --target to emscripten toolchain]`,
    emscripten's `emcc` is rather inconsistent with respect to its treatment
    of the `--target` flag. Avoid this by special-casing this toolchain
    in the `configure` script and `ghc-toolchain`.
    
    Fixes on aspect of #23744.
    
    - - - - -
    6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure
    
    Stop passing -gcc-options which mixed together linker flags and
    non-linker flags. There's no guarantee the C compiler will accept both
    of these in each mode.
    
    - - - - -
    c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00
    configure: Probe stage0 link flags
    
    For consistency with later stages and CC.
    
    - - - - -
    1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00
    Stricter Binary.get in GHC.Types.Unit (#23964)
    
    I noticed some thunking while looking at Core.
    This change has very modest, but throughout positive ghc/alloc effect:
    
    ```
     hard_hole_fits(normal) ghc/alloc    283,057,664    281,620,872  -0.5%
    
                  geo. mean                                          -0.1%
                  minimum                                            -0.5%
                  maximum                                            +0.0%
    ```
    
    Fixes #23964.
    
    - - - - -
    a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00
    rel_eng/upload.sh cleanups
    
    - - - - -
    80705335 by doyougnu at 2023-10-10T19:03:18-04:00
    ci: add javascript label rule
    
    This adds a rule which triggers the javascript job when the "javascript"
    label is assigned to an MR.
    
    - - - - -
    a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00
    Make 'wWarningFlagsDeps' include every WarningFlag
    
    Fixes #24071.
    
    - - - - -
    d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00
    Fix pretty printing of overlap pragmas in TH splices (fixes #24074)
    
    - - - - -
    0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    AArch NCG: Refactor getRegister'
    
    Remove some special cases which can be handled just as well by the
    generic case.
    
    This increases code re-use while also fixing #23749. Since some of the
    special case wasn't upholding Note [Signed arithmetic on AArch64].
    
    - - - - -
    1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over mem management checks
    
    These are for heap allocation, a strictly RTS concern.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    The RTS configure one has a new
    ```
    AC_CHECK_SIZEOF([void *])
    ```
    that the top-level configure version didn't have, so that
    `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
    commits, that can go away.
    
    Progress towards #17191
    
    - - - - -
    41130a65 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `__thread` check
    
    This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over misc function checks
    
    These are for general use in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `eventfd` check
    
    This check is for the RTS part of the event manager and has a
    corresponding part in `base`.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    58f3babf by John Ericson at 2023-10-11T16:02:48-04:00
    Split `FP_CHECK_PTHREADS` and move part to RTS configure
    
    `NEED_PTHREAD_LIB` is unused since
    3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
    system), and so is no longer defined.
    
    Progress towards #17191
    
    - - - - -
    e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00
    nativeGen: section flags for .text$foo only
    
    Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
    #22834 in !9810.
    
    It does however add "xr" indiscriminatly to .text sections
    even if splitSections is disabled. This leads to the assembler saying:
    
    ghc_1.s:7849:0: error:
         Warning: Ignoring changed section attributes for .text
         |
    7849 | .section .text,"xr"
         | ^
    
    - - - - -
    f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00
    Modularity: pass TempDir instead of DynFlags (#17957)
    
    - - - - -
    34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00
    Test that functions from `mingwex` are available
    
    Ryan wrote these two minimizations, but they never got added to the test
    suite.
    
    See #23309, #23378
    
    Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com>
    Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com>
    
    - - - - -
    bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00
    Do not check for the `mingwex` library in `/configure`
    
    See the recent discussion in !10360 --- Cabal will itself check for the
    library for the packages that need it, and while the autoconf check
    additionally does some other things like define a `HAS_LIBMINGWEX` C
    Preprocessor macro, those other things are also unused and unneeded.
    
    Progress towards #17191, which aims to get rid of `/configure` entirely.
    
    - - - - -
    43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00
    base: Introduce move modules into src
    
    The only non-move changes here are whitespace changes to pass the
    `whitespace` test and a few testsuite adaptations.
    
    - - - - -
    df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00
    [PEi386 linker] Bounds check and null-deref guard
    
    We should resonably be able to expect that we won't exceed the number of
    sections if we assume to be dealing with legal object files. We can however
    not guarantee that we get some negative values, and while we try to
    special case most, we should exclude negative indexing into the sections
    array.
    
    We also need to ensure that we do not try to derefences targetSection,
    if it is NULL, due to the switch statement.
    
    - - - - -
    c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
    Move apple compat check to RTS configure
    
    - - - - -
    c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
    Move clock/timer fun checks to RTS configure
    
    Actual library check (which will set the Cabal flag) is left in the
    top-level configure for now.
    
    Progress towards #17191
    
    - - - - -
    7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
    Move visibility and "musttail" annotation checks to the RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
    Move leading underscore checks to RTS configure
    
    `CabalLeadingUnderscore` is done via Hadrian already, so we can stop
    `AC_SUBST`ing it completely.
    
    - - - - -
    25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
    Move alloca, fork, const, and big endian checks to RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    - - - - -
    5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
    Move libdl check to RTS configure
    
    - - - - -
    ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
    Adjust `FP_FIND_LIBFFI`
    
    Just set vars, and `AC_SUBST` in top-level configure.
    
    Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
    be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
    make build system).
    
    - - - - -
    f399812c by John Ericson at 2023-10-12T10:31:13-04:00
    Split BFD support to RTS configure
    
    The flag is still in the top-level configure, but the other checks
    (which define various macros --- important) are in the RTS configure.
    
    - - - - -
    f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
    Split libm check between top level and RTS
    
    - - - - -
    dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
    CgUtils.fixStgRegStmt respect register width
    
    This change ensure that the reg + offset computation is always of the
    same size.  Before this we could end up with a 64bit register, and then
    add a 32bit offset (on 32bit platforms).  This not only would fail type
    sanity checking, but also incorrectly truncate 64bit values into 32bit
    values silently on 32bit architectures.
    
    - - - - -
    9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00
    Fix restarts in .ghcid
    
    Using the whole of `hadrian/` restarted in a loop for me.
    
    - - - - -
    fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    NoFib results (omitted = 0.0%):
    ```
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             pretty           0.0%     -1.6%
                scc           0.0%     -1.7%
    --------------------------------------------------------------------------------
                Min           0.0%     -1.7%
                Max           0.0%     -0.0%
     Geometric Mean          -0.0%     -0.0%
    ```
    
    - - - - -
    32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00
    hadrian: Move ghcBinDeps into ghcLibDeps
    
    This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the
    `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc`
    library so need to make sure they are present in the libdir even if we
    are not going to build `ghc-bin`.
    
    This also fixes things for cross compilers because the stage2
    cross-compiler requires the ghc-usage.txt file, but we are using
    the stage2 lib folder but not building stage3:exe:ghc-bin so
    ghc-usage.txt was not being generated.
    
    - - - - -
    ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00
    Combine GREs when combining in mkImportOccEnv
    
    In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import
    item in favour of another, as explained in Note [Dealing with imports]
    in `GHC.Rename.Names`. However, this can cause us to lose track of
    important parent information.
    
    Consider for example #24084:
    
      module M1 where { class C a where { type T a } }
      module M2 ( module M1 ) where { import M1 }
      module M3 where { import M2 ( C, T ); instance C () where T () = () }
    
    When processing the import list of `M3`, we start off (for reasons that
    are not relevant right now) with two `Avail`s attached to `T`, namely
    `C(C, T)` and `T(T)`. We combine them in the `combine` function of
    `mkImportOccEnv`; as described in Note [Dealing with imports] we discard
    `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not**
    discard the information want that `C` is the parent of `T`. Indeed,
    losing track of this information can cause errors when importing,
    as we could get an error of the form
    
      ‘T’ is not a (visible) associated type of class ‘C’
    
    We fix this by combining the two GREs for `T` using `plusGRE`.
    
    Fixes #24084
    
    - - - - -
    257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00
    hadrian: Pass -DNOSMP to C compiler when needed
    
    Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
    SMP, but doesn't pass it to CC as well, leading to the following
    compilation error on mips64el:
    
    | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
    Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
    ===> Command failed with error code: 1
    In file included from rts/include/Stg.h:348,
                     from rts/include/Rts.h:38,
                     from rts/hooks/FlagDefaults.c:8:
    rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
      416 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
      440 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
      464 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    
    The old make system correctly passed this flag to both GHC and CC [1].
    
    Fix this error by passing -DNOSMP to CC as well.
    
    [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
    
    Closes #24082
    
    - - - - -
    13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00
    Users Guide: Drop dead code for Haddock refs to `parallel`
    
    I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was
    not substituted. It is dead code -- there is no `parallel-ref` usages
    and it doesn't look like there ever was (going back to
    3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it.
    
    - - - - -
    fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)
    
    bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".
    
    - - - - -
    cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Bignum: fix right shift of negative BigNat with native backend
    
    - - - - -
    cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Rts: expose rtsOutOfBoundsAccess symbol
    
    - - - - -
    72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Hadrian: enable `-fcheck-prim-bounds` in validate flavour
    
    This allows T24066 to fail when the bug is present.
    
    Otherwise the out-of-bound access isn't detected as it happens in
    ghc-bignum which wasn't compiled with the bounds check.
    
    - - - - -
    f9436990 by John Ericson at 2023-10-18T19:41:01-04:00
    Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in`
    
    Fixes #24091
    Progress on #23966
    
    Issue #24091 reports that `@ProjectVersion@` is no longer being
    substituted in the GHC user's guide. I assume this is a recent issue,
    but I am not sure how it's worked since
    c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and
    configure are trying to substitute the same `.in` file!
    
    Now only Hadrian does. That is better anyways; already something that
    issue #23966 requested.
    
    It seems like we were missing some dependencies in Hadrian. (I really,
    really hate that this is possible!) Hopefully it is fixed now.
    
    - - - - -
    b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00
    `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`
    
    Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
    be defined. (Guaranteed including a test in the testsuite.)
    
    - - - - -
    0295375a by John Ericson at 2023-10-18T19:41:37-04:00
    Generate `ghcversion.h` from a `.in` file
    
    Now that there are no conditional sections (see the previous commit), we
    can just a do simple substitution rather than pasting it together line
    by line.
    
    Progress on #23966
    
    - - - - -
    740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00
    Add a regression test for #24064
    
    - - - - -
    921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00
    CLC Proposal #182: Export List from Data.List
    
    Proposal link: https://github.com/haskell/core-libraries-committee/issues/182
    
    - - - - -
    4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
    rts: fix small argument passing on big-endian arch (fix #23387)
    
    - - - - -
    b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
    Interpreter: fix literal alignment on big-endian architectures (fix #19261)
    
    Literals weren't correctly aligned on big-endian, despite what the
    comment said.
    
    - - - - -
    a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
    Testsuite: recomp011 and recomp015 are fixed on powerpc
    
    These tests have been fixed but not tested and re-enabled on big-endian
    powerpc (see comments in #11260 and #11323)
    
    - - - - -
    fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
    CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
    - - - - -
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    18b656ee by David Knothe at 2023-10-27T18:35:39+02:00
    Implement Or Patterns (Proposal 0522)
    
    This commit introduces a language extension, `OrPatterns`, as described in proposal 0522.
    
    It extends the syntax by the production
    `pat -> (one of pat1, ..., patk)`.
    The or-pattern `pat` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order.
    
    Currently, or-patterns cannot bind variables. They are still of great use as they discourage the use of wildcard patterns in favour of writing out all "default" cases explicitly:
    
    ```
    isIrrefutableHsPat pat = case pat of
      ...
      (one of WildPat{}, VarPat{}, LazyPat{})
          = True
      (one of PArrPat{}, ConPatIn{}, LitPat{}, NPat{}, NPlusKPat{}, ListPat{})
          = False
    ```
    
    This makes code safer where data types are extended now and then - just like GHC's `Pat` in the example when adding the new `OrPat` constructor. This would be catched by `-fwarn-incomplete-patterns`, but not when a wildcard pattern was used.
    
    - Update submodule haddock.
    
    stuff
    
    Implement empty one of
    
    Prohibit TyApps
    
    Remove unused
    
    update submodule haddock
    
    Update tests
    
    Parser.y
    
    - - - - -
    05fb8685 by David Knothe at 2023-10-27T18:35:40+02:00
    infixpat
    
    - - - - -
    e7ec8d47 by David Knothe at 2023-10-27T18:35:40+02:00
    ppr&tests
    
    - - - - -
    428a0cb6 by David Knothe at 2023-10-27T18:35:40+02:00
    Fix PatSyn tests
    
    - - - - -
    0bbb6ec3 by David Knothe at 2023-10-27T18:35:40+02:00
    Revert "Fix PatSyn tests"
    
    This reverts commit af82f8db8f7e03e130c28ef09a2a2c9c5fffaa5a.
    
    - - - - -
    c7bd1596 by David Knothe at 2023-10-27T18:35:41+02:00
    Nonbreaking parser change
    
    - - - - -
    438218fe by David Knothe at 2023-10-27T18:35:41+02:00
    refactor
    
    - - - - -
    
    
    30 changed files:
    
    - .ghcid
    - .gitignore
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    - .gitlab/rel_eng/upload.sh
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/ByteCode/Asm.hs
    - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
    - compiler/GHC/CmmToAsm/AArch64/Instr.hs
    - compiler/GHC/CmmToAsm/AArch64/Ppr.hs
    - compiler/GHC/CmmToAsm/AArch64/Regs.hs
    - compiler/GHC/CmmToAsm/Ppr.hs
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Data/OrdList.hs
    - compiler/GHC/Driver/Config/Linker.hs
    - compiler/GHC/Driver/Config/Tidy.hs
    - compiler/GHC/Driver/Flags.hs
    - compiler/GHC/Driver/Session.hs
    - compiler/GHC/Hs/Pat.hs
    - compiler/GHC/Hs/Syn/Type.hs
    - compiler/GHC/Hs/Utils.hs
    - compiler/GHC/HsToCore/Match.hs
    - compiler/GHC/HsToCore/Pmc/Check.hs
    - compiler/GHC/HsToCore/Pmc/Desugar.hs
    - compiler/GHC/HsToCore/Pmc/Types.hs
    - compiler/GHC/HsToCore/Utils.hs
    - compiler/GHC/Iface/Ext/Ast.hs
    - compiler/GHC/Iface/Tidy.hs
    - + compiler/GHC/JS/Ident.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/436f0454705c93ea0324056d69267a880029cf67...438218fe2555c066d51e1a5bb009e4f8edaa7aaa
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/436f0454705c93ea0324056d69267a880029cf67...438218fe2555c066d51e1a5bb009e4f8edaa7aaa
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 17:14:09 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Fri, 27 Oct 2023 13:14:09 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: js: add JStg
     IR, remove unsaturated constructor
    Message-ID: <653befe16fb42_1f7b0db0bdf1548018c8@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    1cabb35c by Matthew Craven at 2023-10-27T13:14:00-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    a199418f by Mario Blažević at 2023-10-27T13:14:05-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    
    
    16 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - compiler/GHC/StgToJS/Apply.hs
    - compiler/GHC/StgToJS/Arg.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/52de01d47cb4cc4e1a1633aa95844bd0fe37b92e...a199418fcb0413b650b1eeada15c285c5477b91c
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/52de01d47cb4cc4e1a1633aa95844bd0fe37b92e...a199418fcb0413b650b1eeada15c285c5477b91c
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 17:15:34 2023
    From: gitlab at gitlab.haskell.org (Matthew Craven (@clyring))
    Date: Fri, 27 Oct 2023 13:15:34 -0400
    Subject: [Git][ghc/ghc][wip/bump-bytestring-0.11.5.3] Bump bytestring
     submodule to 0.11.5.3
    Message-ID: <653bf036bbbd4_1f7b0db043ef948068c5@gitlab.mail>
    
    
    
    Matthew Craven pushed to branch wip/bump-bytestring-0.11.5.3 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    97a187bf by Matthew Craven at 2023-10-27T13:14:30-04:00
    Bump bytestring submodule to 0.11.5.3
    
    - - - - -
    
    
    2 changed files:
    
    - libraries/bytestring
    - testsuite/tests/ghci/scripts/all.T
    
    
    Changes:
    
    =====================================
    libraries/bytestring
    =====================================
    @@ -1 +1 @@
    -Subproject commit e377f49b046c986184cf802c8c6386b04c1f1aeb
    +Subproject commit 248bab33a07bfbab69f4bfcf853332a59953eeaf
    
    
    =====================================
    testsuite/tests/ghci/scripts/all.T
    =====================================
    @@ -57,7 +57,11 @@ test('ghci024',
     test('T9367',
          [req_interp, when(fast() or config.os != 'mingw32', skip)],
          makefile_test, [])
    -test('ghci025', extra_files(['Ghci025B.hs', 'Ghci025C.hs', 'Ghci025D.hs']), ghci_script, ['ghci025.script'])
    +test('ghci025',
    +     [  extra_files(['Ghci025B.hs', 'Ghci025C.hs', 'Ghci025D.hs']),
    +        normalise_version("bytestring")],
    +     ghci_script,
    +     ['ghci025.script']),
     test('ghci026', extra_files(['../prog002']), ghci_script, ['ghci026.script'])
     
     test('ghci027', [], ghci_script, ['ghci027.script'])
    @@ -215,7 +219,7 @@ test('T9762',
      , pre_cmd('$MAKE -s --no-print-directory T9762_prep')
      ],
      ghci_script, ['T9762.script'])
    -test('T9881', normal, ghci_script, ['T9881.script'])
    +test('T9881', normalise_version("bytestring"), ghci_script, ['T9881.script'])
     test('T9878', [], ghci_script, ['T9878.script'])
     test('T9878b', [extra_run_opts('-fobject-code')], ghci_script,
          ['T9878b.script'])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97a187bfd713663fccb8bc4f4f0c92792547f9c2
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97a187bfd713663fccb8bc4f4f0c92792547f9c2
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 18:49:30 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Fri, 27 Oct 2023 14:49:30 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/T24124
    Message-ID: <653c063a2725c_1f7b0db30b3b38812853@gitlab.mail>
    
    
    
    Sebastian Graf pushed new branch wip/T24124 at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24124
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 18:51:00 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Fri, 27 Oct 2023 14:51:00 -0400
    Subject: [Git][ghc/ghc][wip/T24124] 2 commits: CorePrep: Attach evaldUnfolding
     to floats to detect more values
    Message-ID: <653c0694419c1_1f7b0db30b3b388130dc@gitlab.mail>
    
    
    
    Sebastian Graf pushed to branch wip/T24124 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    db6b4d53 by Sebastian Graf at 2023-10-27T20:50:26+02:00
    CorePrep: Attach evaldUnfolding to floats to detect more values
    
    See `Note [Pin evaluatedness on floats]`.
    
    - - - - -
    18ee9661 by Sebastian Graf at 2023-10-27T20:50:50+02:00
    CorePrep: Treat seq# and dataToTag# as strict functions (#24124)
    
    See the new `Note [seq# magic]`.
    I also implemented a new `Note [Flatten case-bind]`.
    
    Fixes #24124.
    
    - - - - -
    
    
    5 changed files:
    
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - + testsuite/tests/core-to-stg/T24124.hs
    - + testsuite/tests/core-to-stg/T24124.stderr
    - testsuite/tests/core-to-stg/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2028,6 +2028,9 @@ is:
          case e of 
       by GHC.Core.Opt.ConstantFold.caseRules; see Note [caseRules for dataToTag]
     
    +* Similar to Note [seq# magic], we case-bind the arg of dataToTag# in
    +  GHC.CoreToStg.Prep.
    +
     See #15696 for a long saga.
     -}
     
    @@ -2108,6 +2111,19 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- GHC.CoreToStg.Prep: Finally case-bind the arg of seq#, e.g.,
    +
    +    case seq# (f 13) s of (# r, s' #) -> ...
    +    ==>
    +    case f 13 of sat of __DEFAULT ->
    +    case seq# sat s of (# r, s' #) -> ...,
    +
    +  encoding its call-by-value nature. Note that strictness analysis and the
    +  Simplifier will never see this case binding, so #5129 as above is not an
    +  issue. Plus, CorePrep never case-binds an argument variable anyway.
    +  (Exploiting CbV-ness for argument vars is a job for tag inference, see
    +  #15226.)
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/CoreToStg/Prep.hs
    =====================================
    @@ -70,6 +70,7 @@ import GHC.Types.Unique.Supply
     
     import Data.List        ( unfoldr )
     import Control.Monad
    +import GHC.Builtin.PrimOps
     
     {-
     Note [CorePrep Overview]
    @@ -679,9 +680,11 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
                    else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $
                                    -- Note [Silly extra arguments]
                         (do { v <- newVar (idType bndr)
    -                        ; let float = mkNonRecFloat env topDmd False v rhs2
    +                        ; let float@(Float (NonRec v' _) _ _) =
    +                                mkNonRecFloat env topDmd False v rhs2
    +                        -- v' has demand info and possibly evaldUnfolding
                             ; return ( snocFloat floats2 float
    -                                 , cpeEtaExpand arity (Var v)) })
    +                                 , cpeEtaExpand arity (Var v')) })
     
             -- Wrap floating ticks
            ; let (floats4, rhs4) = wrapTicks floats3 rhs3
    @@ -848,7 +851,11 @@ cpeRhsE env (Case scrut bndr ty alts)
                    where err = mkImpossibleExpr ty "cpeRhsE: missing case alternative"
            ; alts'' <- mapM (sat_alt env') alts'
     
    -       ; return (floats, Case scrut' bndr2 ty alts'') }
    +       ; case alts'' of
    +           [Alt DEFAULT _ rhs] -- See Note [Flatten case-binds]
    +             | float <- mkNonRecFloat env evalDmd (isUnliftedType ty) bndr2 scrut'
    +             -> return (snocFloat floats float, rhs)
    +           _ -> return (floats, Case scrut' bndr2 ty alts'') }
       where
         sat_alt env (Alt con bs rhs)
            = do { (env2, bs') <- cpCloneBndrs env bs
    @@ -1087,16 +1094,24 @@ cpeApp top_env expr
                ; mb_saturate hd app floats unsat_ticks depth }
             where
               depth = val_args args
    -          stricts = case idDmdSig v of
    -                            DmdSig (DmdType _ demands)
    -                              | listLengthCmp demands depth /= GT -> demands
    -                                    -- length demands <= depth
    -                              | otherwise                         -> []
    -                -- If depth < length demands, then we have too few args to
    -                -- satisfy strictness  info so we have to  ignore all the
    -                -- strictness info, e.g. + (error "urk")
    -                -- Here, we can't evaluate the arg strictly, because this
    -                -- partial application might be seq'd
    +          stricts
    +            | PrimOpId op _ <- idDetails v
    +            , Just demands <- case op of
    +                SeqOp       -> Just [evalDmd,topDmd] -- See Note [seq# magic]
    +                DataToTagOp -> Just [evalDmd]        -- See Note [dataToTag# magic]
    +                _           -> Nothing
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = pprTrace "here" (ppr op $$ ppr args) demands
    +
    +            | DmdSig (DmdType _ demands) <- idDmdSig v
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = demands
    +            | otherwise
    +            = [] -- If depth < length demands, then we have too few args to
    +                 -- satisfy strictness  info so we have to  ignore all the
    +                 -- strictness info, e.g. + (error "urk")
    +                 -- Here, we can't evaluate the arg strictly, because this
    +                 -- partial application might be seq'd
     
             -- We inlined into something that's not a var and has no args.
             -- Bounce it back up to cpeRhsE.
    @@ -1484,8 +1499,10 @@ cpeArg env dmd arg
              else do { v <- newVar arg_ty
                      -- See Note [Eta expansion of arguments in CorePrep]
                      ; let arg3 = cpeEtaExpandArg env arg2
    -                       arg_float = mkNonRecFloat env dmd is_unlifted v arg3
    -                 ; return (snocFloat floats2 arg_float, varToCoreExpr v) }
    +                       arg_float@(Float (NonRec v' _) _ _) =
    +                         mkNonRecFloat env dmd is_unlifted v arg3
    +                       -- v' has demand info and possibly evaldUnfolding
    +                 ; return (snocFloat floats2 arg_float, varToCoreExpr v') }
            }
     
     cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg
    @@ -1704,6 +1721,81 @@ Note [Pin demand info on floats]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     We pin demand info on floated lets, so that we can see the one-shot thunks.
     
    +Note [Pin evaluatedness on floats]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider a call to a CBV function, such as a DataCon worker with strict fields:
    +
    +  data T a = T !a
    +  ... f (T e) ...
    +
    +During ANFisation, we will `mkNonRecFloat` for `e`, binding it to a
    +fresh binder `sat`.
    +Now there are two interesting cases:
    +
    + 1. When `e=Just y` is a value, we will float `sat=Just y` as far as possible,
    +    to top-level, even. It is important that we mark `sat` as evaluated (via
    +    setting its unfolding to `evaldUnfolding`), otherwise we get a superfluous
    +    thunk to carry out the field seq on T's field, because
    +    `exprIsHNF sat == False`:
    +
    +      let sat = Just y in
    +      let sat2 = case sat of x { __DEFAULT } -> T x in
    +        -- NONONO, want just `sat2 = T x`
    +      f sat2
    +
    +    This happened in $walexGetByte, where the thunk caused additional
    +    allocation.
    +
    + 2. Similarly, when `e` is not a value, we still know that it is strictly
    +    evaluated. Hence it is going to be case-bound, and we anticipate that `sat`
    +    will be a case binder which is *always* evaluated.
    +    Hence in this case, we also mark `sat` as evaluated via its unfolding.
    +    This happened in GHC.Linker.Deps.$wgetLinkDeps, where without
    +    `evaldUnfolding` we ended up with this:
    +
    +      Word64Map = ... | Bin ... ... !Word64Map !Word64Map
    +      case ... of { Word64Map.Bin a b l r ->
    +      case insert ... of sat { __DEFAULT ->
    +      case Word64Map.Bin a b l sat of sat2 { __DEFAULT ->
    +      f sat2
    +      }}}
    +
    +    Note that *the DataCon app `Bin a b l sat` was case-bound*, because it was
    +    not detected to be a value according to `exprIsHNF`.
    +    That is because the strict field `sat` lacked the `evaldUnfolding`,
    +    although it ended up being case-bound.
    +
    +    There is one small wrinkle: It could be that `sat=insert ...` floats to
    +    top-level, where it is not eagerly evaluated. In this case, we may not
    +    give `sat` an `evaldUnfolding`. We detect this case by looking at the
    +    `FloatInfo` of `sat=insert ...`: If it says `TopLvlFloatable`, we are
    +    conservative and will not give `sat` an `evaldUnfolding`.
    +
    +TLDR; when creating a new float `sat=e` in `mkNonRecFloat`, propagate `sat` with
    +an `evaldUnfolding` if either
    +
    + 1. `e` is a value, or
    + 2. `sat=e` is case-bound, but won't float to top-level.
    +
    +Note [Flatten case-binds]
    +~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider the following program involving seq#:
    +
    +  data T a = T !a
    +  ... seq# (case x of y { __DEFAULT -> T y }) s ...
    +  ==> {ANFise, exploiting CbV-ness as in Note [seq# magic] and cpe_app}
    +  ... case (case x of y { __DEFAULT -> T y }) of sat { __DEFAULT -> seq# sat s }
    +
    +(Why didn't the Simplifier float out `case x of y`? Because `seq#` is lazy;
    +see Note [seq# magic].)
    +Note the case-of-case. This is not bad per sé, but we can easily flatten
    +this situation by calling `mkNonRecFloat` to create strict binding `y=x`:
    +
    +  ... case x of y { __DEFAULT -> let sat = T y in seq# sat s } ...
    +
    +where `T y` is simply let-bound, thus far less likely to confuse passes
    +downstream.
    +
     Note [Speculative evaluation]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Since call-by-value is much cheaper than call-by-need, we case-bind arguments
    @@ -1984,9 +2076,8 @@ zipManyFloats = foldr zipFloats emptyFloats
     
     mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind
     mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $
    -  Float (NonRec bndr' rhs) bound info
    +  Float (NonRec bndr2 rhs) bound info
       where
    -    bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats]
         (bound,info)
           | is_lifted, is_hnf        = (LetBound, TopLvlFloatable)
               -- is_lifted: We currently don't allow unlifted values at the
    @@ -2017,6 +2108,14 @@ mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr
         is_rec_call = (`elemUnVarSet` cpe_rec_ids env)
         is_data_con = isJust . isDataConId_maybe
     
    +    bndr1 = bndr `setIdDemandInfo` dmd -- See Note [Pin demand info on floats]
    +    bndr2
    +      | is_hnf || (bound == CaseBound && info /= TopLvlFloatable)
    +        -- See Note [Pin evaluatedness on floats]
    +      = bndr1 `setIdUnfolding` evaldUnfolding
    +      | otherwise
    +      = bndr1
    +
     -- | Wrap floats around an expression
     wrapBinds :: Floats -> CpeBody -> CpeBody
     wrapBinds floats body
    
    
    =====================================
    testsuite/tests/core-to-stg/T24124.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T24124 where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- CorePrep should evaluate `MkStrictPair` and its fields strictly
    
    
    =====================================
    testsuite/tests/core-to-stg/T24124.stderr
    =====================================
    @@ -0,0 +1,193 @@
    +
    +==================== CorePrep ====================
    +Result size of CorePrep
    +  = {terms: 119, types: 108, coercions: 22, joins: 0/1}
    +
    +-- RHS size: {terms: 13, types: 8, coercions: 0, joins: 0/0}
    +T24124.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T24124.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []]
    +T24124.$WMkStrictPair
    +  = \ (@a)
    +      (@b)
    +      (conrep [Occ=Once1] :: a)
    +      (conrep1 [Occ=Once1] :: b) ->
    +      case conrep of conrep2 [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      case conrep1 of conrep3 [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      T24124.MkStrictPair @a @b conrep2 conrep3
    +      }
    +      }
    +
    +-- RHS size: {terms: 20, types: 27, coercions: 0, joins: 0/1}
    +T24124.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T24124.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []]
    +T24124.testFun1
    +  = \ (@a)
    +      (@b)
    +      (x [Occ=Once1] :: a)
    +      (y [Occ=Once1, OS=OneShot] :: b)
    +      (s [Occ=Once1, OS=OneShot]
    +         :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    +      case GHC.Prim.seq# @a @GHC.Prim.RealWorld x s of
    +      { (# ipv [Occ=Once1], ipv1 [Occ=Once1] #) ->
    +      case y of conrep [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      let {
    +        sat [Occ=Once1, Dmd=SL] :: T24124.StrictPair a b
    +        [LclId, Unf=OtherCon []]
    +        sat = T24124.MkStrictPair @a @b ipv1 conrep } in
    +      GHC.Prim.seq# @(T24124.StrictPair a b) @GHC.Prim.RealWorld sat ipv
    +      }
    +      }
    +
    +-- RHS size: {terms: 9, types: 8, coercions: 15, joins: 0/0}
    +T24124.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T24124.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []]
    +T24124.testFun
    +  = (\ (@a)
    +       (@b)
    +       (eta [Occ=Once1] :: a)
    +       (eta [Occ=Once1] :: b)
    +       (eta [Occ=Once1] :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    +       T24124.testFun1 @a @b eta eta eta)
    +    `cast` (forall (a :: <*>_N) (b :: <*>_N).
    +            _R
    +            %<'GHC.Types.Many>_N ->_R _R
    +            %<'GHC.Types.Many>_N ->_R Sym (GHC.Types.N:IO[0]
    +                                               _R)
    +            :: (forall a b.
    +                a
    +                -> b
    +                -> GHC.Prim.State# GHC.Prim.RealWorld
    +                -> (# GHC.Prim.State# GHC.Prim.RealWorld, T24124.StrictPair a b #))
    +               ~R# (forall a b. a -> b -> GHC.Types.IO (T24124.StrictPair a b)))
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule4 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule4 = "main"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule3 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule3 = GHC.Types.TrNameS T24124.$trModule4
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule2 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule2 = "T24124"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule1 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule1 = GHC.Types.TrNameS T24124.$trModule2
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule :: GHC.Types.Module
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule
    +  = GHC.Types.Module T24124.$trModule3 T24124.$trModule1
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +$krep :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep = GHC.Types.KindRepVar 1#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +$krep1 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep1 = GHC.Types.KindRepVar 0#
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair2 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair2 = "StrictPair"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair1 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair1 = GHC.Types.TrNameS T24124.$tcStrictPair2
    +
    +-- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair :: GHC.Types.TyCon
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair
    +  = GHC.Types.TyCon
    +      9300255393514929474#Word64
    +      9110283622559092784#Word64
    +      T24124.$trModule
    +      T24124.$tcStrictPair1
    +      0#
    +      GHC.Types.krep$*->*->*
    +
    +-- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0}
    +$krep2 :: [GHC.Types.KindRep]
    +[GblId, Unf=OtherCon []]
    +$krep2
    +  = GHC.Types.:
    +      @GHC.Types.KindRep $krep (GHC.Types.[] @GHC.Types.KindRep)
    +
    +-- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0}
    +$krep3 :: [GHC.Types.KindRep]
    +[GblId, Unf=OtherCon []]
    +$krep3 = GHC.Types.: @GHC.Types.KindRep $krep1 $krep2
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +$krep4 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep4 = GHC.Types.KindRepTyConApp T24124.$tcStrictPair $krep3
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +$krep5 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep5 = GHC.Types.KindRepFun $krep $krep4
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair1 [InlPrag=[~]] :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair1 = GHC.Types.KindRepFun $krep1 $krep5
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair3 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair3 = "'MkStrictPair"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair2 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair2
    +  = GHC.Types.TrNameS T24124.$tc'MkStrictPair3
    +
    +-- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair :: GHC.Types.TyCon
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair
    +  = GHC.Types.TyCon
    +      2381261223169708323#Word64
    +      3151447712495713176#Word64
    +      T24124.$trModule
    +      T24124.$tc'MkStrictPair2
    +      2#
    +      T24124.$tc'MkStrictPair1
    +
    +-- RHS size: {terms: 7, types: 6, coercions: 7, joins: 0/0}
    +T24124.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []]
    +T24124.MkStrictPair
    +  = (\ (@a[sk:1])
    +       (@b[sk:1])
    +       (eta [Occ=Once1] :: a)
    +       (eta [Occ=Once1] :: b) ->
    +       T24124.MkStrictPair @a[sk:1] @b[sk:1] eta eta)
    +    `cast` ( b %1 -> T24124.StrictPair a b>_R
    +            :: (forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b)
    +               ~R# (forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b))
    +
    +
    +
    
    
    =====================================
    testsuite/tests/core-to-stg/all.T
    =====================================
    @@ -3,3 +3,4 @@
     test('T19700', normal, compile, ['-O'])
     test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -ddump-prep'])
     test('T23914', normal, compile, ['-O'])
    +test('T24124', [grep_errmsg(r'= .*MkStrictPair.*in')], compile, ['-O -dsuppress-uniques -ddump-prep'])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc604a0f7f941536ba2bd3a375bc554de2431098...18ee96617f034b03ea418c0117e3318a0c1d8594
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc604a0f7f941536ba2bd3a375bc554de2431098...18ee96617f034b03ea418c0117e3318a0c1d8594
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 20:01:36 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Fri, 27 Oct 2023 16:01:36 -0400
    Subject: [Git][ghc/ghc][wip/T20424] 2665 commits: Respect -po when heap
     profiling (#21446)
    Message-ID: <653c1720359a7_1f7b0db4b318208287eb@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/T20424 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00
    Respect -po when heap profiling (#21446)
    
    - - - - -
    1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00
    add test case for #21446
    
    - - - - -
    c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00
    avoid hadrian/bindist/Makefile install_docs error when --docs=none
    
    When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated.
    Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index
    to avoid the error:
    
    /usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory
    make: *** [Makefile:195: install_docs] Error 1
    
    - - - - -
    158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00
    Correct base's changelog for 4.16.1.0
    
    This commit reaffects the new Ix instances of the foreign integral
    types from base 4.17 to 4.16.1.0
    
    closes #21529
    
    - - - - -
    a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00
    STG: only print cost-center if asked to
    
    - - - - -
    50347ded by Gergő Érdi at 2022-05-10T11:43:33+00:00
    Improve "Glomming" note
    
    Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order
    references, and thus needing to glom, is not a cause for concern when its
    root cause is rewrite rules.
    
    - - - - -
    df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00
    update INSTALL
    - - - - -
    dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00
    driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode
    
    It seems like it was just an oversight to use the incorrect DynFlags
    (global rather than local) when implementing these two options. Using
    the local flags allows users to request these intermediate files get
    cleaned up, which works fine in --make mode because
    
    1. Interface files are stored in memory
    2. Object files are only cleaned at the end of session (after link)
    
    Fixes #21349
    
    - - - - -
    35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00
    configure: Check for ffi.h
    
    As noted in #21485, we checked for ffi.h yet then failed to throw an
    error if it is missing.
    
    Fixes #21485.
    
    - - - - -
    bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00
    Check for uninferrable variables in tcInferPatSynDecl
    
    This fixes #21479
    
    See Note [Unquantified tyvars in a pattern synonym]
    
    While doing this, I found that some error messages pointed at the
    pattern synonym /name/, rather than the /declaration/ so I widened the
    SrcSpan to encompass the declaration.
    
    - - - - -
    142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00
    hadrian: Fix split-sections transformer
    
    The splitSections transformer has been broken since -dynamic-too support
    was implemented in hadrian. This is because we actually build the
    dynamic way when building the dynamic way, so the predicate would always
    fail.
    
    The fix is to just always pass `split-sections` even if it doesn't do
    anything for a particular way.
    
    Fixes #21138
    
    - - - - -
    699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00
    packaging: Build perf builds with -split-sections
    
    In 8f71d958 the make build system was made to use split-sections on
    linux systems but it appears this logic never made it to hadrian.
    There is the split_sections flavour transformer but this doesn't appear
    to be used for perf builds on linux.
    
    Closes #21135
    
    - - - - -
    21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00
    Use the wrapper for an unlifted binding
    
    We assumed the wrapper for an unlifted binding is the identity,
    but as #21516 showed, that is no always true.
    
    Solution is simple: use it.
    
    - - - - -
    68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00
    docs: Fix path to GHC API docs in index.html
    
    In the make bindists we generate documentation in docs/ghc-<VER> but the
    hadrian bindists generate docs/ghc/ so the path to the GHC API docs was
    wrong in the index.html file.
    
    Rather than make the hadrian and make bindists the same it was easier to
    assume that if you're using the mkDocs script that you're using hadrian
    bindists.
    
    Fixes #21509
    
    - - - - -
    9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00
    hadrian: Don't pass -j to haddock
    
    This has high potential for oversubcribing as many haddock jobs can be
    spawned in parralel which will each request the given number of
    capabilities.
    
    Once -jsem is implemented (#19416, !5176) we can expose that haddock via
    haddock and use that to pass a semaphore.
    
    Ticket #21136
    
    - - - - -
    fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00
    hadrian: Only copy and install libffi headers when using in-tree libffi
    
    When passed `--use-system-libffi` then we shouldn't copy and install the
    headers from the system package. Instead the headers are expected to be
    available as a runtime dependency on the users system.
    
    Fixes #21485 #21487
    
    - - - - -
    5b791ed3 by mikael at 2022-05-11T08:22:13-04:00
    FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10.
    
    - - - - -
    8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00
    Make floating-point abs IEEE 754 compliant
    
    The old code used by via-C backend didn't handle the sign bit of NaN.
    
    See #21043.
    
    - - - - -
    4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00
    EPA: do statement with leading semicolon has wrong anchor
    
    The code
    
        do; a <- doAsync; b
    
    Generated an incorrect Anchor for the statement list that starts after
    the first semicolon.
    
    This commit fixes it.
    
    Closes #20256
    
    - - - - -
    e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00
    Specialiser: saturate DFuns correctly
    
    Ticket #21489 showed that the saturation mechanism for
    DFuns (see Note Specialising DFuns) should use both
    UnspecType and UnspecArg.
    
    We weren't doing that; but this MR fixes that problem.
    
    No test case because it's hard to tickle, but it showed up in
    Gergo's work with GHC-as-a-library.
    
    - - - - -
    fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00
    gitlab-ci: Check for dynamic msys2 dependencies
    
    Both #20878 and #21196 were caused by unwanted dynamic dependencies
    being introduced by boot libraries. Ensure that we catch this in CI by
    attempting to run GHC in an environment with a minimal PATH.
    
    - - - - -
    3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00
    Add back Debian9 CI jobs
    
    We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
    not being at EOL until April 2023 and they still need tinfo5.
    
    Fixes #21469
    
    - - - - -
    dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00
    rts: Drop setExecutable
    
    Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been
    dead code. Drop it.
    
    - - - - -
    32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00
    Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat
    
    This missing guard gave rise to #21519.
    
    - - - - -
    2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00
    Add mention of -hi to RTS --help
    
    Fixes #21546
    
    - - - - -
    a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00
    Decouple dynflags in Cmm parser (related to #17957)
    
    - - - - -
    3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00
    Remove Module argument from initCmmParserConfig
    
    - - - - -
    2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00
    Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config
    
    - - - - -
    b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00
    Decouple dynflags in GHC.Core.Opt.Arity (related to #17957)
    
    Metric Decrease:
        T16875
    
    - - - - -
    3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00
    Update extending_ghc for TcPlugin changes
    
    The documentation still mentioned Derived constraints and
    an outdated datatype TcPluginResult.
    
    - - - - -
    668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00
    Fix printing of brackets in multiplicities (#20315)
    
    Change mulArrow to allow for printing of correct application precedence
    where necessary and update callers of mulArrow to reflect this.
    
    As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type.
    
    Fixes #20315
    
    - - - - -
    30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00
    rts: Add debug output on ocResolve failure
    
    This makes it easier to see how resolution failures nest.
    
    - - - - -
    53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00
    rts/PEi386: Fix handling of weak symbols
    
    Previously we would flag the symbol as weak but failed
    to set its address, which must be computed from an "auxiliary"
    symbol entry the follows the weak symbol.
    
    Fixes #21556.
    
    - - - - -
    5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00
    testsuite: Add tests for #21556
    
    - - - - -
    49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00
    Re-export augment and build from GHC.List
    
    Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127
    
    - - - - -
    aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00
    Comments only around HsWrapper
    
    - - - - -
    27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00
    hadrian: Introduce linting flavour transformer (+lint)
    
    The linting flavour enables -dlint uniformly across anything build by
    the stage1 compiler.
    
    -dcmm-lint is not currently enabled because it fails on i386 (see #21563)
    
    - - - - -
    3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00
    hadrian: Uniformly enable -dlint with enableLinting transformer
    
    This fixes some bugs where
    
    * -dcore-lint was being passed when building stage1 libraries with the
      boot compiler
    * -dcore-lint was not being passed when building executables.
    
    Fixes #20135
    
    - - - - -
    3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00
    Make closure macros EXTERN_INLINE to make debugging easier
    
    Implements #21424.
    
    The RTS macros get_itbl and friends are extremely helpful during debugging.
    However only a select few of those were available in the compiled RTS as actual symbols
    as the rest were INLINE macros.
    
    This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites
    but allow us to use their compiled counterparts during debugging.
    
    This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell
    since `get_fun_itbl` will now be available as symbol!
    
    - - - - -
    93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00
    packaging: Introduce CI job for generating hackage documentation
    
    This adds a CI job (hackage-doc-tarball) which generates the necessary
    tarballs for uploading libraries and documentation to hackage. The
    release script knows to download this folder and the upload script will
    also upload the release to hackage as part of the release.
    
    The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs
    
    There are two modes, preparation and upload.
    
    * The `prepare` mode takes a link to a bindist and creates a folder containing the
      source and doc tarballs ready to upload to hackage.
    * The `upload` mode takes the folder created by prepare and performs the upload to
      hackage.
    
    Fixes #21493
    
    Related to #21512
    
    - - - - -
    65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00
    Add arity to the INLINE pragmas for pattern synonyms
    
    The lack of INLNE arity was exposed by #21531.  The fix is
    simple enough, if a bit clumsy.
    
    - - - - -
    43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00
    Misc cleanup
    
    - Remove groupWithName (unused)
    - Use the RuntimeRepType synonym where possible
    - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM
    
    No functional changes.
    
    - - - - -
    8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00
    TcPlugin: access to irreducible givens + fix passed ev_binds_var
    
    - - - - -
    fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00
    driver: Introduce pgmcxx
    
    Here we introduce proper support for compilation of C++ objects. This
    includes:
    
     * logic in `configure` to detect the C++ toolchain and propagating this
       information into the `settings` file
     * logic in the driver to use the C++ toolchain when compiling C++
       sources
    
    - - - - -
    43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00
    testsuite: Build T20918 with HC, not CXX
    
    - - - - -
    0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00
    Introduce package to capture dependency on C++ stdlib
    
    Here we introduce a new "virtual" package into the initial package
    database, `system-cxx-std-lib`. This gives users a convenient, platform
    agnostic way to link against C++ libraries, addressing #20010.
    
    Fixes #20010.
    
    - - - - -
    03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00
    testsuite: Add tests for system-cxx-std-lib package
    
    Test that we can successfully link against C++ code both in GHCi and
    batch compilation.
    
    See #20010
    
    - - - - -
    5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00
    OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420)
    
    - - - - -
    eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00
    Adjust flags for pprTrace
    
    We were using defaultSDocContext for pprTrace, which suppresses
    lots of useful infomation. This small MR adds
    
       GHC.Utils.Outputable.traceSDocContext
    
    and uses it for pprTrace and pprTraceUserWarning.
    
    traceSDocContext is a global, and hence not influenced by flags,
    but that seems unavoidable.  But I made the sdocPprDebug bit
    controlled by unsafeHasPprDebug, since we have the latter for
    exactly this purpose.
    
    Fixes #21569
    
    - - - - -
    d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00
    Fix bad interaction between withDict and the Specialiser
    
    This MR fixes a bad bug, where the withDict was inlined too
    vigorously, which in turn made the type-class Specialiser generate
    a bogus specialisation, because it saw the same overloaded function
    applied to two /different/ dictionaries.
    
    Solution: inline `withDict` later.  See (WD8) of Note [withDict]
    in GHC.HsToCore.Expr
    
    See #21575, which is fixed by this change.
    
    - - - - -
    70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00
    Bump time submodule to 1.12.2
    
    This bumps the time submodule to the 1.12.2 release.
    
    Fixes #21571
    
    - - - - -
    2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00
    Remove unused test files (#21582)
    
    Those files were moved to the perf/ subtree in 11c9a469, and then
    accidentally reintroduced in 680ef2c8.
    
    - - - - -
    cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00
    CafAnal: Improve code clarity
    
    Here we implement a few measures to improve the clarity of the CAF
    analysis implementation. Specifically:
    
    * Use CafInfo instead of Bool since the former is more descriptive
    * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact
      CAFs
    * Add numerous comments
    
    - - - - -
    b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00
    codeGen: Ensure that static datacon apps are included in SRTs
    
    When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT
    filters out recursive references, as described in Note [recursive SRTs].
    However, doing so for static functions would be unsound, for the reason
    described in Note [Invalid optimisation: shortcutting].
    
    However, the same argument applies to static data constructor
    applications, as we discovered in #20959. Fix this by ensuring that
    static data constructor applications are included in recursive SRTs.
    
    The approach here is not entirely satisfactory, but it is a starting
    point.
    
    Fixes #20959.
    
    - - - - -
    0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00
    Add test for #21558
    
    This is now fixed on master and 9.2 branch.
    
    Closes #21558
    
    - - - - -
    ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00
    Don't store LlvmConfig into DynFlags
    
    LlvmConfig contains information read from llvm-passes and llvm-targets
    files in GHC's top directory. Reading these files is done only when
    needed (i.e. when the LLVM backend is used) and cached for the whole
    compiler session. This patch changes the way this is done:
    
    - Split LlvmConfig into LlvmConfig and LlvmConfigCache
    
    - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no
      good reason to store it in DynFlags. As it is fixed per session, we
      store it in the session state instead (HscEnv).
    
    - Initializing LlvmConfigCache required some changes to driver functions
      such as newHscEnv. I've used the opportunity to untangle initHscEnv
      from initGhcMonad (in top-level GHC module) and to move it to
      GHC.Driver.Main, close to newHscEnv.
    
    - I've also made `cmmPipeline` independent of HscEnv in order to remove
      the call to newHscEnv in regalloc_unit_tests.
    
    - - - - -
    828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00
    Give all EXTERN_INLINE closure macros prototypes
    
    - - - - -
    cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00
    base: Introduce [sg]etFinalizerExceptionHandler
    
    This introduces a global hook which is called when an exception is
    thrown during finalization.
    
    - - - - -
    372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00
    base: Throw exceptions raised while closing finalized Handles
    
    Fixes #21336.
    
    - - - - -
    3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00
    testsuite: Add tests for #21336
    
    - - - - -
    297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00
    Add release flavour and use it for the release jobs
    
    The release flavour is essentially the same as the perf flavour
    currently but also enables `-haddock`. I have hopefully updated all the
    relevant places where the `-perf` flavour was hardcoded.
    
    Fixes #21486
    
    - - - - -
    a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00
    ci: Don't build sphinx documentation on centos
    
    The centos docker image lacks the sphinx builder so we disable building
    sphinx docs for these jobs.
    
    Fixes #21580
    
    - - - - -
    209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00
    ci: Use correct syntax when args list is empty
    
    This seems to fail on the ancient version of bash present on CentOS
    
    - - - - -
    02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00
    hadrian: Don't attempt to build dynamic profiling libraries
    
    We only support building static profiling libraries, the transformer was
    requesting things like a dynamic, threaded, debug, profiling RTS, which
    we have never produced nor distributed.
    
    Fixes #21567
    
    - - - - -
    35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00
    configure: Check CC_STAGE0 for --target support
    
    We previously only checked the stage 1/2 compiler
    for --target support. We got away with this for quite a while but it
    eventually caught up with us in #21579, where `bytestring`'s new NEON
    implementation was unbuildable on Darwin due to Rosetta's seemingly
    random logic for determining which executable image to execute. This
    lead to a confusing failure to build `bytestring`'s cbits, when `clang`
    tried to compile NEON builtins while targetting x86-64.
    
    Fix this by checking CC_STAGE0 for --target support.
    
    Fixes #21579.
    
    - - - - -
    0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00
    add dominator analysis of `CmmGraph`
    
    This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper
    around two existing algorithms in GHC: the Lengauer-Tarjan dominator
    analysis from the X86 back end and the reverse postorder ordering from
    the Cmm Dataflow framework.  Issue #20726 proposes that we evaluate
    some alternatives for dominator analysis, but for the time being, the
    best path forward is simply to use the existing analysis on
    `CmmGraph`s.
    
    This commit addresses a bullet in #21200.
    
    - - - - -
    54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00
    add dominator-tree function
    
    - - - - -
    05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00
    add HasDebugCallStack; remove unneeded extensions
    
    - - - - -
    0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00
    document fields of `DominatorSet`
    - - - - -
    8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00
    nonmoving: Fix documentation of GC statistics fields
    
    These were previously incorrect.
    
    Fixes #21553.
    
    - - - - -
    c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00
    Remove pprTrace from pushCoercionIntoLambda (#21555)
    
    This firstly caused spurious output to be emitted (as evidenced by
     #21555) but even worse caused a massive coercion to be attempted to be
     printed (> 200k terms) which would invariably eats up all the memory of
     your computer.
    
    The good news is that removing this trace allows the program to compile
    to completion, the bad news is that the program exhibits a core lint
    error (on 9.0.2) but not any other releases it seems.
    
    Fixes #21577 and #21555
    
    - - - - -
    a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00
    docs: Fix LlvmVersion in manpage (#21280)
    
    - - - - -
    36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00
    validate: Use $make rather than make
    
    In the validate script we are careful to use the $make variable as this
    stores whether we are using gmake, make, quiet mode etc. There was just
    this one place where we failed to use it.
    
    Fixes #21598
    
    - - - - -
    4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00
    Change `Backend` type and remove direct dependencies
    
    With this change, `Backend` becomes an abstract type
    (there are no more exposed value constructors).
    Decisions that were formerly made by asking "is the
    current back end equal to (or different from) this named value
    constructor?" are now made by interrogating the back end about
    its properties, which are functions exported by `GHC.Driver.Backend`.
    
    There is a description of how to migrate code using `Backend` in the
    user guide.
    
    Clients using the GHC API can find a backdoor to access the Backend
    datatype in GHC.Driver.Backend.Internal.
    
    Bumps haddock submodule.
    
    Fixes #20927
    
    - - - - -
    ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00
    Respect DESTDIR in hadrian bindist Makefile, fixes #19646
    
    - - - - -
    7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00
    Test DESTDIR in test_hadrian()
    
    - - - - -
    ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00
    Consider the stage of typeable evidence when checking stage restriction
    
    We were considering all Typeable evidence to be "BuiltinInstance"s which
    meant the stage restriction was going unchecked. In-fact, typeable has
    evidence and so we need to apply the stage restriction.
    
    This is
    complicated by the fact we don't generate typeable evidence and the
    corresponding DFunIds until after typechecking is concluded so we
    introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which
    records whether the evidence is going to be local or not.
    
    Fixes #21547
    
    - - - - -
    ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00
    Modularize GHC.Core.Opt.LiberateCase
    
    Progress towards #17957
    
    - - - - -
    bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00
    Improve FloatOut and SpecConstr
    
    This patch addresses a relatively obscure situation that arose
    when chasing perf regressions in !7847, which itself is fixing
    
    It does two things:
    
    * SpecConstr can specialise on ($df d1 d2) dictionary arguments
    * FloatOut no longer checks argument strictness
    
    See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr.
    
    A test case is difficult to construct, but it makes a big difference
    in nofib/real/eff/VSM, at least when we have the patch for #21286
    installed. (The latter stops worker/wrapper for dictionary arguments).
    
    There is a spectacular, but slightly illusory, improvement in
    runtime perf on T15426.  I have documented the specifics in
    T15426 itself.
    
    Metric Decrease:
        T15426
    
    - - - - -
    1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00
    Make debug a `Bool` not an `Int` in `StgToCmmConfig`
    
    We don't need any more resolution than this.
    
    Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer
    conveying any "level" information.
    
    - - - - -
    e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00
    EPA : Remove duplicate comments in DataFamInstD
    
    The code
    
      data instance Method PGMigration = MigrationQuery Query
                                       -- ^ Run a query against the database
                                       | MigrationCode (Connection -> IO (Either String ()))
                                       -- ^ Run any arbitrary IO code
    
    Resulted in two instances of the "-- ^ Run a query against the database"
    comment appearing in the Exact Print Annotations when it was parsed.
    
    Ensure only one is kept.
    
    Closes #20239
    
    - - - - -
    e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00
    EPA: Comment Order Reversed
    
    Make sure comments captured in the exact print annotations are in
    order of increasing location
    
    Closes #20718
    
    - - - - -
    4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00
    Add test for T21455
    
    - - - - -
    e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00
    Allow passing -po outside profiling way
    
    Resolves #21455
    
    - - - - -
    3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00
    Fix haddock_*_perf tests on non-GNU-grep systems
    
    Using regexp pattern requires `egrep` and straight up `+`.  The
    haddock_parser_perf and haddock_renamer_perf tests now pass on
    OpenBSD. They previously incorrectly parsed the files and awk
    complained about invalid syntax.
    
    - - - - -
    1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00
    hadrian/bindist: Drop redundant include of install.mk
    
    `install.mk` is already included by `config.mk`. Moreover, `install.mk`
    depends upon `config.mk` to set `RelocatableBuild`, making this first
    include incorrect.
    
    - - - - -
    f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00
    Remove -z wxneeded for OpenBSD
    
    With all the recent W^X fixes in the loader this workaround is not
    necessary any longer. I verified that the only tests failing for me on
    OpenBSD 7.1-current are the same (libc++ related) before and after
    this commit (with --fast).
    
    - - - - -
    7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00
    Use UnionListsOrd instead of UnionLists in most places.
    
    This should get rid of most, if not all "Overlong lists" errors and fix #20016
    
    - - - - -
    81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00
    Fix #21563 by using Word64 for 64bit shift code.
    
    We use the 64bit shifts only on 64bit platforms. But we
    compile the code always so compiling it on 32bit caused a
    lint error. So use Word64 instead.
    
    - - - - -
    2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00
    Fix compilation with -haddock on GHC <= 8.10
    
    -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors
    when it encounters invalid haddock syntax.
    
    This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b
    enabled -haddock by default on many flavours.
    
    Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem
    managed to slip throught the cracks.
    
    - - - - -
    cfb9faff by sheaf at 2022-05-24T22:15:12-04:00
    Hadrian: don't add "lib" for relocatable builds
    
    The conditional in hadrian/bindist/Makefile depended on the target OS,
    but it makes more sense to use whether we are using a relocatable build.
    (Currently this only gets set to true on Windows, but this ensures
    that the logic stays correctly coupled.)
    
    - - - - -
    9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00
    Remove HscEnv from GHC.HsToCore.Usage (related to #17957)
    
    Metric Decrease:
        T16875
    
    - - - - -
    2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00
    SimpleOpt: beta-reduce through casts
    
    The simple optimiser would sometimes fail to
    beta-reduce a lambda when there were casts
    in between the lambda and its arguments.
    This can cause problems because we rely on
    representation-polymorphic lambdas getting
    beta-reduced away (for example, those
    that arise from newtype constructors with
    representation-polymorphic arguments, with
    UnliftedNewtypes).
    
    - - - - -
    e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00
    Desugar RecordUpd in `tcExpr`
    
    This patch typechecks record updates by desugaring them inside
    the typechecker using the HsExpansion mechanism, and then typechecking
    this desugared result.
    
    Example:
    
        data T p q = T1 { x :: Int, y :: Bool, z :: Char }
                   | T2 { v :: Char }
                   | T3 { x :: Int }
                   | T4 { p :: Float, y :: Bool, x :: Int }
                   | T5
    
    The record update `e { x=e1, y=e2 }` desugars as follows
    
      e { x=e1, y=e2 }
        ===>
      let { x' = e1; y' = e2 } in
      case e of
         T1 _ _ z -> T1 x' y' z
         T4 p _ _ -> T4 p y' x'
    
    The desugared expression is put into an HsExpansion, and we typecheck
    that.
    
    The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr.
    
    Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289
    
    Updates haddock submodule
    
    - - - - -
    2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00
    update README
    - - - - -
    3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00
    Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602)
    
    - - - - -
    ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00
    Add Haddocks for `WwOpts`
    
    - - - - -
    da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00
    Avoid global compiler state for `GHC.Core.Opt.WorkWrap`
    
    Progress towards #17957
    
    - - - - -
    3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00
    Optimiser: avoid introducing bad rep-poly
    
    The functions `pushCoValArg` and `pushCoercionIntoLambda` could
    introduce bad representation-polymorphism. Example:
    
      type RR :: RuntimeRep
      type family RR where { RR = IntRep }
      type F :: TYPE RR
      type family F where  { F  = Int# }
    
      co = GRefl F (TYPE RR[0])
        :: (F :: TYPE RR)
        ~# (F |> TYPE RR[0] :: TYPE IntRep)
    
      f :: F -> ()
    
    `pushCoValArg` would transform the unproblematic application
    
      (f |> (co -> <()>)) (arg :: F |> TYPE RR[0])
    
    into an application in which the argument does not have a fixed
    `RuntimeRep`:
    
      f ((arg |> sym co) :: (F :: TYPE RR))
    
    - - - - -
    b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00
    executablePath test: fix file extension treatment
    
    The executablePath test strips the file extension (if any) when
    comparing the query result with the expected value.  This is to
    handle platforms where GHC adds a file extension to the output
    program file (e.g. .exe on Windows).
    
    After the initial check, the file gets deleted (if supported).
    However, it tries to delete the *stripped* filename, which is
    incorrect.  The test currently passes only because Windows does not
    allow deleting the program while any process created from it is
    alive.
    
    Make the test program correct in general by deleting the
    *non-stripped* executable filename.
    
    - - - - -
    afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00
    fix executablePath test for NetBSD
    
    executablePath support for NetBSD was added in
    a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not
    updated.
    
    Update the test so that it works for NetBSD.  This requires handling
    some quirks:
    
    - The result of getExecutablePath could include "./" segments.
      Therefore use System.FilePath.equalFilePath to compare paths.
    
    - The sysctl(2) call returns the original executable name even after
      it was deleted.  Add `canQueryAfterDelete :: [FilePath]` and
      adjust expectations for the post-delete query accordingly.
    
    Also add a note to the `executablePath` haddock to advise that
    NetBSD behaves differently from other OSes when the file has been
    deleted.
    
    Also accept a decrease in memory usage for T16875.  On Windows, the
    metric is -2.2% of baseline, just outside the allowed ±2%.  I don't
    see how this commit could have influenced this metric, so I suppose
    it's something in the CI environment.
    
    Metric Decrease:
        T16875
    
    - - - - -
    d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00
    Factor out `initArityOps` to `GHC.Driver.Config.*` module
    
    We want `DynFlags` only mentioned in `GHC.Driver`.
    
    - - - - -
    44bb7111 by romes at 2022-05-26T16:27:57+00:00
    TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs
    
    - - - - -
    88e58600 by sheaf at 2022-05-26T17:38:43-04:00
    Add tests for eta-expansion of data constructors
    
    This patch adds several tests relating to the eta-expansion of
    data constructors, including UnliftedNewtypes and DataTypeContexts.
    
    - - - - -
    d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00
    Generalize breakTyVarCycle to work with TyFamLHS
    
    The function breakTyVarCycle_maybe has been installed
    in a dark corner of GHC to catch some gremlins (a.k.a.
    occurs-check failures) who lurk
    there. But it previously only caught gremlins of the
    form (a ~ ... F a ...), where some of our intrepid users
    have spawned gremlins of the form (G a ~ ... F (G a) ...).
    This commit improves breakTyVarCycle_maybe (and renames
    it to breakTyEqCycle_maybe) to catch the new gremlins.
    
    Happily, the change is remarkably small.
    
    The gory details are in Note [Type equality cycles].
    
    Test cases: typecheck/should_compile/{T21515,T21473}.
    
    - - - - -
    ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00
    [base] Fix the links in the Data.Data module
    
    fix #21658
    fix #21657
    fix #21657
    
    - - - - -
    3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00
    Use a class to check validity of withDict
    
    This moves handling of the magic 'withDict' function from the desugarer
    to the typechecker. Details in Note [withDict].
    
    I've extracted a part of T16646Fail to a separate file T16646Fail2,
    because the new error in 'reify' hides the errors from 'f' and 'g'.
    
    WithDict now works with casts, this fixes #21328.
    
    Part of #19915
    
    - - - - -
    b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00
    Fix FreeVars computation for mdo
    
    Commit acb188e0 introduced a regression in the computation of free
    variables in mdo statements, as the logic in
    GHC.Rename.Expr.segmentRecStmts was slightly different depending on
    whether the recursive do block corresponded to an mdo statement or
    a rec statment.
    
    This patch restores the previous computation for mdo blocks.
    
    Fixes #21654
    
    - - - - -
    0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00
    T16875: Stabilise (temporarily) by increasing acceptance threshold
    
    The theory is that on windows there is some difference in the
    environment between pipelines on master and merge requests which affects
    all tests equally but because T16875 barely allocates anything it is the
    test which is affected the most.
    
    See #21557
    
    - - - - -
    6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00
    make: Fix make maintainer-clean deleting a file tracked by source control
    
    Fixes #21659
    
    - - - - -
    fbf2f254 by Andrew Lelechenko at 2022-05-28T21:01:58-04:00
    Expand documentation of hIsTerminalDevice
    
    - - - - -
    0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00
    export IsList from GHC.IsList
    
    it is still re-exported from GHC.Exts
    
    - - - - -
    91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00
    MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR
    
    ARM64_RELOC_SUBTRACTOR relocations are paired with an
    AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2
    The linker was doing it in two steps, basically:
      *addend <- *addend - sym2
      *addend <- *addend + sym1
    The first operation was likely to overflow. For example when the
    relocation target was 32-bit and both sym1/sym2 were 64-bit addresses.
    With the small memory model, (sym1-sym2) would fit in 32 bits but
    (*addend-sym2) may not.
    
    Now the linker does it in one step:
      *addend <- *addend + sym1 - sym2
    
    - - - - -
    acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00
    Some fixes to SRT documentation
    
    - reordered the 3 SRT implementation cases from the most general to the
      most specific one:
        USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD
    - added requirements for each
    - found and documented a confusion about "SRT inlining" not supported
      with MachO. (It is fixed in the following commit)
    
    - - - - -
    5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00
    Enable USE_INLINE_SRT_FIELD on ARM64
    
    It was previously disabled because of:
    - a confusion about "SRT inlining" (see removed comment in this commit)
    - a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR
      relocation: fixed by a previous commit.
    
    - - - - -
    59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00
    ci: Make sure to exit promptly if `make install` fails.
    
    Due to the vageries of bash, you have to explicitly handle the failure
    and exit when in a function.
    
    This failed to exit promptly when !8247 was failing.
    
    See #21358 for the general issue
    
    - - - - -
    5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00
    Split GHC.HsToCore.Foreign.Decl
    
    This is preliminary work for JavaScript support. It's better to put the
    code handling the desugaring of Prim, C and JavaScript declarations into
    separate modules.
    
    - - - - -
    6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00
    Bump hadrian to LTS-19.8 (GHC 9.0.2)
    
    - - - - -
    f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00
    Hadrian: remove unused code
    
    - - - - -
    2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Eta reduction with casted function
    
    We want to be able to eta-reduce
       \x y. ((f x) |> co) y
    by pushing 'co' inwards.  A very small change accommodates this
    See Note [Eta reduction with casted function]
    
    - - - - -
    f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Do arity trimming at bindings, rather than in exprArity
    
    Sometimes there are very large casts, and coercionRKind
    can be slow.
    
    - - - - -
    610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Make findRhsArity take RecFlag
    
    This avoids a fixpoint iteration for the common case of
    non-recursive bindings.
    
    - - - - -
    80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Comments and white space
    
    - - - - -
    0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    Make PrimOpId record levity
    
    This patch concerns #20155, part (1)
    
    The general idea is that since primops have curried bindings
    (currently in PrimOpWrappers.hs) we don't need to eta-expand
    them.  But we /do/ need to eta-expand the levity-polymorphic ones,
    because they /don't/ have bindings.
    
    This patch makes a start in that direction, by identifying the
    levity-polymophic primops in the PrimOpId IdDetails constructor.
    
    For the moment, I'm still eta-expanding all primops (by saying
    that hasNoBinding returns True for all primops), because of the
    bug reported in #20155.  But I hope that before long we can
    tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding.
    
    - - - - -
    6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
    A bunch of changes related to eta reduction
    
    This is a large collection of changes all relating to eta
    reduction, originally triggered by #18993, but there followed
    a long saga.
    
    Specifics:
    
    * Move state-hack stuff from GHC.Types.Id (where it never belonged)
      to GHC.Core.Opt.Arity (which seems much more appropriate).
    
    * Add a crucial mkCast in the Cast case of
      GHC.Core.Opt.Arity.eta_expand; helps with T18223
    
    * Add clarifying notes about eta-reducing to PAPs.
      See Note [Do not eta reduce PAPs]
    
    * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity,
      where it properly belongs.  See Note [Eta reduce PAPs]
    
    * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for
      when eta-expansion is wanted, to make wantEtaExpansion, and all that
      same function in GHC.Core.Opt.Simplify.simplStableUnfolding.  It was
      previously inconsistent, but it's doing the same thing.
    
    * I did a substantial refactor of ArityType; see Note [ArityType].
      This allowed me to do away with the somewhat mysterious takeOneShots;
      more generally it allows arityType to describe the function, leaving
      its clients to decide how to use that information.
    
      I made ArityType abstract, so that clients have to use functions
      to access it.
    
    * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called
      mkLam before) aware of the floats that the simplifier builds up, so
      that it can still do eta-reduction even if there are some floats.
      (Previously that would not happen.)  That means passing the floats
      to rebuildLam, and an extra check when eta-reducting (etaFloatOk).
    
    * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info
      in the idDemandInfo of the binder, as well as the CallArity info. The
      occurrence analyser did this but we were failing to take advantage here.
    
      In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity;
      see Note [Combining arityType with demand info], and functions
      idDemandOneShots and combineWithDemandOneShots.
    
      (These changes partly drove my refactoring of ArityType.)
    
    * In GHC.Core.Opt.Arity.findRhsArity
      * I'm now taking account of the demand on the binder to give
        extra one-shot info.  E.g. if the fn is always called with two
        args, we can give better one-shot info on the binders
        than if we just look at the RHS.
    
      * Don't do any fixpointing in the non-recursive
        case -- simple short cut.
    
      * Trim arity inside the loop. See Note [Trim arity inside the loop]
    
    * Make SimpleOpt respect the eta-reduction flag
      (Some associated refactoring here.)
    
    * I made the CallCtxt which the Simplifier uses distinguish between
      recursive and non-recursive right-hand sides.
         data CallCtxt = ... | RhsCtxt RecFlag | ...
      It affects only one thing:
         - We call an RHS context interesting only if it is non-recursive
           see Note [RHS of lets] in GHC.Core.Unfold
    
    * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification.
      See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep.
    
    Other incidental changes
    
    * Fix a fairly long-standing outright bug in the ApplyToVal case of
      GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the
      tail of 'dmds' in the recursive call, which meant the demands were All
      Wrong.  I have no idea why this has not caused problems before now.
    
    * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg
    
    Metrics: compile_time/bytes allocated
                                   Test    Metric       Baseline      New value Change
    ---------------------------------------------------------------------------------------
    MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,743,297,692  2,619,762,992  -4.5% GOOD
                         T18223(normal) ghc/alloc  1,103,161,360    972,415,992 -11.9% GOOD
                          T3064(normal) ghc/alloc    201,222,500    184,085,360  -8.5% GOOD
                          T8095(normal) ghc/alloc  3,216,292,528  3,254,416,960  +1.2%
                          T9630(normal) ghc/alloc  1,514,131,032  1,557,719,312  +2.9%  BAD
                     parsing001(normal) ghc/alloc    530,409,812    525,077,696  -1.0%
    
    geo. mean                                 -0.1%
    
    Nofib:
           Program           Size    Allocs   Runtime   Elapsed  TotalMem
    --------------------------------------------------------------------------------
             banner          +0.0%     +0.4%     -8.9%     -8.7%      0.0%
        exact-reals          +0.0%     -7.4%    -36.3%    -37.4%      0.0%
     fannkuch-redux          +0.0%     -0.1%     -1.0%     -1.0%      0.0%
               fft2          -0.1%     -0.2%    -17.8%    -19.2%      0.0%
              fluid          +0.0%     -1.3%     -2.1%     -2.1%      0.0%
                 gg          -0.0%     +2.2%     -0.2%     -0.1%      0.0%
      spectral-norm          +0.1%     -0.2%      0.0%      0.0%      0.0%
                tak          +0.0%     -0.3%     -9.8%     -9.8%      0.0%
               x2n1          +0.0%     -0.2%     -3.2%     -3.2%      0.0%
    --------------------------------------------------------------------------------
                Min          -3.5%     -7.4%    -58.7%    -59.9%      0.0%
                Max          +0.1%     +2.2%    +32.9%    +32.9%      0.0%
     Geometric Mean          -0.0%     -0.1%    -14.2%    -14.8%     -0.0%
    
    Metric Decrease:
        MultiLayerModulesTH_OneShot
        T18223
        T3064
        T15185
        T14766
    Metric Increase:
        T9630
    
    - - - - -
    cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00
    hadrian: Fix building from source-dist without alex/happy
    
    This fixes two bugs which were adding dependencies on alex/happy when
    building from a source dist.
    
    * When we try to pass `--with-alex` and `--with-happy` to cabal when
      configuring but the builders are not set. This is fixed by making them
      optional.
    * When we configure, cabal requires alex/happy because of the
      build-tool-depends fields. These are now made optional with a cabal
      flag (build-tool-depends) for compiler/hpc-bin/genprimopcode.
    
    Fixes #21627
    
    - - - - -
    a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00
    ci: Test the bootstrap without ALEX/HAPPY on path
    
    - - - - -
    0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00
    ci: Test bootstrapping in release jobs
    
    - - - - -
    d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00
    ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label
    
    - - - - -
    18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00
    rts: Remove explicit timescale for deprecating -h flag
    
    We originally planned to remove the flag in 9.4 but there's actually no
    great rush to do so and it's probably less confusing (forever) to keep
    the message around suggesting an explicit profiling option.
    
    Fixes #21545
    
    - - - - -
    eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00
    Enable -dlint in hadrian lint transformer
    
    Now #21563 is fixed we can properly enable `-dlint` in CI rather than a
    subset of the flags.
    
    - - - - -
    0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00
    upload-ghc-libs: Allow candidate-only upload
    
    - - - - -
    83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00
    Avoid using DynFlags in GHC.Linker.Unit (#17957)
    
    - - - - -
    5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00
    hadrian: Introduce new package database for executables needed to build stage0
    
    These executables (such as hsc2hs) are built using the boot compiler and
    crucially, most libraries from the global package database.
    
    We also move other build-time executables to be built in this stage such
    as linters which also cleans up which libraries end up in the global
    package database. This allows us to remove hacks where linters-common is
    removed from the package database when a bindist is created.
    
    This fixes issues caused by infinite recursion due to bytestring adding
    a dependency on template-haskell.
    
    Fixes #21634
    
    - - - - -
    0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00
    Build stage1 with -V as well
    
    This helps tracing errors which happen when building stage1
    
    - - - - -
    15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00
    Revert "packaging: Build perf builds with -split-sections"
    
    This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f.
    
    Split sections causes segfaults in profiling way with old toolchains
    (deb9) and on windows (#21670)
    
    Fixes #21670
    
    - - - - -
    d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00
    Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard
    
    Progress towards #17957
    
    Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other
    modules as thoroughly as I usually do. This does mean that risk of
    `DynFlags` "creeping back in" is higher than it usually is.
    
    After we do the same process to the other Core passes, and then figure
    out what we want to do about `CoreM`, we can finish the job started
    here.
    
    That is a good deal more work, however, so it certainly makes sense to
    land this now.
    
    - - - - -
    a720322f by romes at 2022-06-01T07:44:44-04:00
    Restore Note [Quasi-quote overview]
    
    - - - - -
    392ce3fc by romes at 2022-06-01T07:44:44-04:00
    Move UntypedSpliceFlavour from L.H.S to GHC.Hs
    
    UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr`
    but was defined in the client-independent L.H.S.Expr.
    
    - - - - -
    7975202b by romes at 2022-06-01T07:44:44-04:00
    TTG: Rework and improve splices
    
    This commit redefines the structure of Splices in the AST.
    
    We get rid of `HsSplice` which used to represent typed and untyped
    splices, quasi quotes, and the result of splicing either an expression,
    a type or a pattern.
    
    Instead we have `HsUntypedSplice` which models an untyped splice or a
    quasi quoter, which works in practice just like untyped splices.
    
    The `HsExpr` constructor `HsSpliceE` which used to be constructed with
    an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The
    former is directly constructed with an `HsExpr` and the latter now takes
    an `HsUntypedSplice`.
    
    Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now
    take an `HsUntypedSplice` instead of a `HsSplice` (remember only
    /untyped splices/ can be spliced as types or patterns).
    
    The result of splicing an expression, type, or pattern is now
    comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`,
    `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType
    GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult
    (HsExpr GhcRn)`
    
    Overall the TTG extension points are now better used to
    make invalid states unrepresentable and model the progression between
    stages better.
    
    See Note [Lifecycle of an untyped splice, and PendingRnSplice]
    and Note [Lifecycle of an typed splice, and PendingTcSplice] for more
    details.
    
    Updates haddock submodule
    
    Fixes #21263
    
    -------------------------
    Metric Decrease:
        hard_hole_fits
    -------------------------
    
    - - - - -
    320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00
    Add test for #21619
    
    Fixes #21619
    
    - - - - -
    ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00
    Pure Haskell implementation of GHC.Unicode
    
    Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/).
    
    Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691.
    
    - Remove current Unicode cbits.
    - Add generator for Unicode property files from Unicode Character Database.
    - Generate internal modules.
    - Update GHC.Unicode.
    - Add unicode003 test for general categories and case mappings.
    - Add Python scripts to check 'base' Unicode tests outputs and characters properties.
    
    Fixes #21375
    
    -------------------------
    Metric Decrease:
        T16875
    Metric Increase:
        T4029
        T18304
        haddock.base
    -------------------------
    
    - - - - -
    514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00
    typos
    
    - - - - -
    9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00
    source-dist: Copy in files created by ./boot
    
    Since we started producing source dists with hadrian we stopped copying
    in the files created by ./boot which adds a dependency on python3 and
    autoreconf. This adds back in the files which were created by running
    configure.
    
    Fixes #21673 #21672 and #21626
    
    - - - - -
    a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00
    ci: Don't try to run ./boot when testing bootstrap of source dist
    
    - - - - -
    e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00
    Language.Haskell.Syntax: Fix docs for PromotedConsT etc.
    
    Fixes ghc/ghc#21675.
    
    - - - - -
    87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00
    Bump bytestring, process, and text submodules
    
    Metric Decrease:
        T5631
    Metric Increase:
        T18223
    
    (cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af)
    
    - - - - -
    24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00
    Bump Cabal submodule
    
    To current `master`.
    
    (cherry picked from commit fbb59c212415188486aafd970eafef170516356a)
    
    - - - - -
    5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00
    hadrian/tool-args: Write output to intermediate file rather than via stdout
    
    This allows us to see the output of hadrian while it is doing the setup.
    
    - - - - -
    468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00
    Make -fcompact-unwind the default
    
    This is a follow-up to !7247 (closed) making the inclusion of compact unwinding
    sections the default.
    
    Also a slight refactoring/simplification of the flag handling to add
    -fno-compact-unwind.
    
    - - - - -
    819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00
    hadrian bootstrap: add plans for 9.0.2 and 9.2.3
    
    - - - - -
    9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00
    ci: Add matrix for bootstrap sources
    
    - - - - -
    ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00
    HsToCore.Coverage: Improve haddocks
    
    - - - - -
    f065804e by John Ericson at 2022-06-02T15:42:59+00:00
    Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller
    
    No need to inline traversing a maybe for `mkModBreaks`. And better to
    make each function do one thing and let the caller deside when than
    scatter the decision making and make the caller seem more imperative.
    
    - - - - -
    d550d907 by John Ericson at 2022-06-02T15:42:59+00:00
    Rename `HsToCore.{Coverage -> Ticks}`
    
    The old name made it confusing why disabling HPC didn't disable the
    entire pass. The name makes it clear --- there are other reasons to add
    ticks in addition.
    
    - - - - -
    6520da95 by John Ericson at 2022-06-02T15:42:59+00:00
    Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq`
    
    As proposed in
    https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and
    https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676,
    `GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and
    backend-specific (only for the bytecode interpreter), and mix entry
    writing is just for HPC.
    
    With this split we separate out those interpreter- and HPC-specific
    its, and keep the main `GHC.HsToCore.Ticks` agnostic.
    
    Also, instead of passing the reversed list and count around, we use
    `SizedSeq` which abstracts over the algorithm. This is much nicer to
    avoid noise and prevents bugs.
    
    (The bugs are not just hypothetical! I missed up the reverses on an
    earlier draft of this commit.)
    
    - - - - -
    1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00
    GHC.HsToCore.Breakpoints: Slightly improve perf
    
    We have the length already, so we might as well use that rather than
    O(n) recomputing it.
    
    - - - - -
    5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00
    HsToCore.Coverage: Purge DynFlags
    
    Finishes what !7467 (closed) started.
    
    Progress towards #17957
    
    - - - - -
    9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00
    Deprecate TypeInType extension
    
    This commit fixes #20312
    It deprecates "TypeInType" extension
    according to the following proposal:
    https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst
    
    It has been already implemented.
    
    The migration strategy:
     1. Disable TypeInType
     2. Enable both DataKinds and PolyKinds extensions
    
    Metric Decrease:
        T16875
    
    - - - - -
    f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00
    Diagnostics conversions, part 6 (#20116)
    
    Replaces uses of `TcRnUnknownMessage` with proper diagnostics
    constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and
    `GHC.Tc.Gen.Sig`.
    
    - - - - -
    04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00
    Ensure floated dictionaries are in scope (again)
    
    In the Specialiser, we missed one more call to
    bringFloatedDictsIntoScope (see #21391).
    
    This omission led to #21689. The problem is that the call
    to `rewriteClassOps` needs to have in scope any dictionaries
    floated out of the arguments we have just specialised.
    
    Easy fix.
    
    - - - - -
    a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00
    Don't print the number of deps in count-deps tests
    
    It is redundant information and a source of needless version control
    conflicts when multiple MRs are changing the deps list.
    
    Just printing the list and not also its length is fine.
    
    - - - - -
    a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00
    Core.Lint: Reduce `DynFlags` and `HscEnv`
    
    Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com>
    
    - - - - -
    56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00
    Fix a CSE shadowing bug.
    
    We used to process the rhs of non-recursive bindings and their body
    using the same env. If we had something like
        let x = ... x ...
    this caused trouble because the two xs refer to different binders
    but we would substitute both for a new binder x2 causing out of scope
    errors.
    
    We now simply use two different envs for the rhs and body in cse_bind.
    It's all explained in the Note [Separate envs for let rhs and body]
    
    Fixes #21685
    
    - - - - -
    28880828 by sheaf at 2022-06-09T09:12:19-04:00
    Typecheck remaining ValArgs in rebuildHsApps
    
    This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it
    to tcRemainingValArgs. The logic is moved to rebuildHsApps, which
    ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg.
    
    This patch also refactors the treatment of stupid theta for data
    constructors, changing the place we drop stupid theta arguments
    from dsConLike to mkDataConRep (now the datacon wrapper drops these
    arguments).
    
    We decided not to implement PHASE 2 of the FixedRuntimeRep plan for
    these remaining ValArgs. Future directions are outlined on the wiki:
      https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs
    
    Fixes #21544 and #21650
    
    - - - - -
    1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00
    Add test for T21682
    
    Fixes #21682
    
    - - - - -
    8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00
    Document dataToTag# primop
    
    - - - - -
    7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00
    Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115
    
    - - - - -
    46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00
    Fix TcRnPragmaWarning meaning
    
    - - - - -
    69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00
    getProcessCPUTime: Fix the getrusage fallback to account for system CPU time
    
    clock_gettime reports the combined total or user AND system time so in
    order to replicate it with getrusage we need to add both system and user
    time together.
    
    See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime
    
    Some sample measurements when building Cabal with this patch
    
    t1: rusage
    t2: clock_gettime
    
    t1: 62347518000; t2: 62347520873
    t1: 62395687000; t2: 62395690171
    t1: 62432435000; t2: 62432437313
    t1: 62478489000; t2: 62478492465
    t1: 62514990000; t2: 62514992534
    t1: 62515479000; t2: 62515480327
    t1: 62515485000; t2: 62515486344
    
    Fixes #21656
    
    - - - - -
    722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00
    Use <br> instead of newline character
    
    - - - - -
    dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00
    Use (fixed_lev = True) in mkDataTyConRhs
    
    - - - - -
    ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00
    hadrian: Fix testing stage1 compiler
    
    There were various issues with testing the stage1 compiler..
    
    1. The wrapper was not being built
    2. The wrapper was picking up the stage0 package database and trying to
       load prelude from that.
    3. The wrappers never worked on windows so just don't support that for
       now.
    
    Fixes #21072
    
    - - - - -
    ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00
    validate: Ensure that $make variable is set
    
    Currently the `$make` variable is used without being set in `validate`'s
    Hadrian path, which uses make to install the binary distribution. Fix
    this.
    
    Fixes #21687.
    
    - - - - -
    59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00
    CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv`
    
    The call sites in `Driver.Main` are duplicative, but this is good,
    because the next step is to remove `InteractiveContext` from `Core.Lint`
    into `Core.Lint.Interactive`.
    
    Also further clean up `Core.Lint` to use a better configuration record
    than the one we initially added.
    
    - - - - -
    aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00
    hadrian: Run xattr -rc . on bindist tarball
    
    Fixes #21506.
    
    - - - - -
    cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00
    configure: Hide spurious warning from ld
    
    Previously the check_for_gold_t22266 configure check could result in
    spurious warnings coming from the linker being blurted to stderr.
    Suppress these by piping stderr to /dev/null.
    
    - - - - -
    e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00
    cmm: Add surface syntax for MO_MulMayOflo
    
    - - - - -
    bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00
    configure: Don't attempt to override linker on Darwin
    
    Configure's --enable-ld-override functionality is intended to ensure
    that we don't rely on ld.bfd, which tends to be slow and buggy, on
    Linux and Windows. However, on Darwin the lack of sensible package
    management makes it extremely easy for users to have awkward mixtures of
    toolchain components from, e.g., XCode, the Apple Command-Line Tools
    package, and homebrew. This leads to extremely confusing problems
    like #21712.
    
    Here we avoid this by simply giving up on linker selection on Darwin
    altogether. This isn't so bad since the Apple ld64 linker has decent
    performance and AFAICT fairly reliable.
    
    Closes #21712.
    
    - - - - -
    25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00
    replace quadratic nub to fight byte code gen perf explosion
    
    Despite this code having been present in the core-to-bytecode
    implementation, I have observed it in the wild starting with 9.2,
    causing enormous slowdown in certain situations.
    
    My test case produces the following profiles:
    
    Before:
    
    ```
    	total time  =      559.77 secs   (559766 ticks @ 1000 us, 1 processor)
    	total alloc = 513,985,665,640 bytes  (excludes profiling overheads)
    
    COST CENTRE MODULE         SRC                                         %time %alloc  ticks     bytes
    
    elem_by     Data.OldList   libraries/base/Data/OldList.hs:429:1-7       67.6   92.9  378282 477447404296
    eqInt       GHC.Classes    libraries/ghc-prim/GHC/Classes.hs:275:8-14   12.4    0.0  69333        32
    $c>>=       GHC.Data.IOEnv <no location info>                            6.9    0.6  38475 3020371232
    ```
    
    After:
    
    ```
    	total time  =       89.83 secs   (89833 ticks @ 1000 us, 1 processor)
    	total alloc = 39,365,306,360 bytes  (excludes profiling overheads)
    
    COST CENTRE           MODULE                SRC                                                                  %time %alloc  ticks     bytes
    
    $c>>=                 GHC.Data.IOEnv        <no location info>                                                    43.6    7.7  39156 3020403424
    doCase                GHC.StgToByteCode     compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53)                        2.5    7.4   2246 2920777088
    
    ```
    
    - - - - -
    aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00
    hadrian: Don't install `include/` directory in bindist.
    
    The install_includes for the RTS package used to be put in the top-level
    ./include folder but this would lead to confusing things happening if
    you installed multiple GHC versions side-by-side.
    
    We don't need this folder anymore because install-includes
    is honoured properly by cabal and the relevant header files already
    copied in by the cabal installation process.
    
    If you want to depend on the header files for the RTS in a Haskell
    project then you just have to depend on the `rts` package and the
    correct include directories will be provided for you.
    
    If you want to depend on the header files in a standard C project then
    you should query ghc-pkg to get the right paths.
    
    ```
    ghc-pkg field rts include-dirs  --simple-output
    ```
    
    Fixes #21609
    
    - - - - -
    03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00
    Enable eventlogs on nightly perf job
    
    - - - - -
    ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00
    Repair dead link in TH haddocks
    
    Closes #21724
    
    - - - - -
    99ff3818 by sheaf at 2022-06-16T16:30:39-04:00
    Hadrian: allow configuring Hsc2Hs
    
    This patch adds the ability to pass options to Hsc2Hs as Hadrian
    key/value settings, in the same way as cabal configure options,
    using the syntax:
    
      *.*.hsc2hs.run.opts += ...
    
    - - - - -
    9c575f24 by sheaf at 2022-06-16T16:30:39-04:00
    Hadrian bootstrap: look up hsc2hs
    
    Hadrian bootstrapping looks up where to find ghc_pkg, but the same
    logic was not in place for hsc2hs which meant we could fail to
    find the appropriate hsc2hs executabe when bootstrapping Hadrian.
    This patch adds that missing logic.
    
    - - - - -
    229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00
    ghc-heap: Add (broken) test for #21622
    
    - - - - -
    cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00
    ghc-heap: Don't Box NULL pointers
    
    Previously we could construct a `Box` of a NULL pointer from the `link`
    field of `StgWeak`. Now we take care to avoid ever introducing such
    pointers in `collect_pointers` and ensure that the `link` field is
    represented as a `Maybe` in the `Closure` type.
    
    Fixes #21622
    
    - - - - -
    31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00
    winio: Add support to console handles to handleToHANDLE
    
    - - - - -
    711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00
    CmmToAsm/AArch64: Add SMUL[LH] instructions
    
    These will be needed to fix #21624.
    
    - - - - -
    d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00
    CmmToAsm/AArch64: Fix syntax of OpRegShift operands
    
    Previously this produced invalid assembly containing a redundant comma.
    
    - - - - -
    a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00
    ncg/aarch64: Fix implementation of IntMulMayOflo
    
    The code generated for IntMulMayOflo was previously wrong as it
    depended upon the overflow flag, which the AArch64 MUL instruction does
    not set. Fix this.
    
    Fixes #21624.
    
    - - - - -
    26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00
    testsuite: Add test for #21624
    
    Ensuring that mulIntMayOflo# behaves as expected.
    
    - - - - -
    94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00
    CprAnal: Set signatures of DFuns to top
    
    The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal
    that is observable in a debug build. The CPR signature of a recursive DFunId
    was never updated and hence the optimistic arity 0 bottom signature triggered a
    mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any
    code because WW doesn't exploit bottom CPR signatures.
    
    - - - - -
    b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00
    CorePrep: Don't speculatively evaluate recursive calls (#20836)
    
    In #20836 we have optimised a terminating program into an endless loop,
    because we speculated the self-recursive call of a recursive DFun.
    Now we track the set of enclosing recursive binders in CorePrep to prevent
    speculation of such self-recursive calls.
    
    See the updates to Note [Speculative evaluation] for details.
    
    Fixes #20836.
    
    - - - - -
    49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00
    Simplify: Take care with eta reduction in recursive RHSs (#21652)
    
    Similar to the fix to #20836 in CorePrep, we now track the set of enclosing
    recursive binders in the SimplEnv and SimpleOptEnv.
    See Note [Eta reduction in recursive RHSs] for details.
    
    I also updated Note [Arity robustness] with the insights Simon and I had in a
    call discussing the issue.
    
    Fixes #21652.
    
    Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to
    additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation
    of a large list literal at the top-level that didn't happen before (presumably
    because it was too interesting to float to the top-level). There's not much we
    can do about that.
    
    Metric Increase:
        T16577
    
    - - - - -
    2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00
    Ignore .hie-bios
    
    - - - - -
    e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00
    Instantiate top level foralls in partial type signatures
    
    The main fix for #21667 is the new call to tcInstTypeBnders
    in tcHsPartialSigType. It was really a simple omission before.
    
    I also moved the decision about whether we need to apply the
    Monomorphism Restriction, from `decideGeneralisationPlan` to
    `tcPolyInfer`.  That removes a flag from the InferGen constructor,
    which is good.
    
    But more importantly, it allows the new function,
       checkMonomorphismRestriction
    called from `tcPolyInfer`, to "see" the `Types` involved rather than
    the `HsTypes`.  And that in turn matters because we invoke the MR for
    partial signatures if none of the partial signatures in the group have
    any overloading context; and we can't answer that question for HsTypes.
    See Note [Partial type signatures and the monomorphism restriction]
    in GHC.Tc.Gen.Bind.
    
    This latter is really a pre-existing bug.
    
    - - - - -
    262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00
    Make Outputable instance for InlineSig print the InlineSpec
    
    Fix ghc/ghc#21739
    
    Squash fix ghc/ghc#21739
    
    - - - - -
    b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00
    Add NO_BOOT to hackage_doc_tarball job
    
    We were attempting to boot a src-tarball which doesn't work as ./boot is
    not included in the source tarball. This slipped through as the job is
    only run on nightly.
    
    - - - - -
    d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00
    HsToken for @-patterns and TypeApplications (#19623)
    
    One more step towards the new design of EPA.
    
    - - - - -
    159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00
    linker: only keep rtl exception tables if they have been relocated
    
    - - - - -
    da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00
    Ticky:Make json info a separate field.
    
    - - - - -
    1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00
    Revert "Ticky:Make json info a separate field."
    
    This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862.
    
    This was pushed directly without review.
    
    - - - - -
    f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00
    Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags
    
    These flags affect the behaviour of local let floating.
    
    If `-flocal-float-out` is disabled (the default) then we disable all
    local floating.
    
    ```
    …(let x = let y = e in (a,b) in body)...
    ===>
    …(let y = e; x = (a,b) in body)...
    
    ```
    
    Further to this, top-level local floating can be disabled on it's own by
    passing -fno-local-float-out-top-level.
    
    ```
    x = let y = e in (a,b)
    ===>
    y = e; x = (a,b)
    ```
    
    Note that this is only about local floating, ie, floating two adjacent
    lets past each other and doesn't say anything about the global floating
    pass which is controlled by `-fno-float`.
    
    Fixes #13663
    
    - - - - -
    4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00
    Check for Int overflows in Data.Array.Byte
    
    - - - - -
    2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00
    Add a basic test for ByteArray's Monoid instance
    
    - - - - -
    fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00
    Rename `copyByteArray` to `unsafeCopyByteArray`
    
    - - - - -
    ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00
    testsuite: Add test for #21719
    
    Happily, this has been fixed since 9.2.
    
    - - - - -
    19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00
    Use lookupNameCache instead of lookupOrigIO
    
    - - - - -
    4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00
    Break out thNameToGhcNameIO (ref. #21730)
    
    - - - - -
    eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00
    Add laws for 'toInteger' and 'toRational'
    
    CLC discussion here:
    https://github.com/haskell/core-libraries-committee/issues/58
    
    - - - - -
    c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00
    Correct documentation of defaults of the `-V` RTS option
    
    - - - - -
    b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00
    Transcribe discussion from #21483 into a Note
    
    In #21483 I had a discussion with Simon Marlow about the memory
    retention behaviour of -Fd. I have just transcribed that conversation
    here as it elucidates the potentially subtle assumptions which led to
    the design of the memory retention behaviours of -Fd.
    
    Fixes #21483
    
    - - - - -
    980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00
    eventlog: Don't leave dangling pointers hanging around
    
    Previously we failed to reset pointers to various eventlog buffers to
    NULL after freeing them. In principle we shouldn't look at them after
    they are freed but nevertheless it is good practice to set them to a
    well-defined value.
    
    - - - - -
    575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00
    runhaskell
    - - - - -
    e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00
    re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural
    
    CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45
    
    - - - - -
    5d45aa97 by Gergő Érdi at 2022-06-22T22:00:46-04:00
    When specialising, look through floatable ticks.
    
    Fixes #21697.
    
    - - - - -
    531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00
    TagCheck.hs: Properly check if arguments are boxed types.
    
    For one by mistake I had been checking against the kind of runtime rep
    instead of the boxity.
    
    This uncovered another bug, namely that we tried to generate the
    checking code before we had associated the function arguments with
    a register, so this could never have worked to begin with.
    
    This fixes #21729 and both of the above issues.
    
    - - - - -
    c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00
    Use correct arch for the FreeBSD triple in gen-data-layout.sh
    
    Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798
    Relevant upstream issue: #15718
    
    - - - - -
    75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00
    Bump nofib submodule.
    
    Allows the shake runner to build with 9.2.3 among other things.
    
    Fixes #21772
    
    - - - - -
    0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00
    Bump ghc-prim and base versions
    
    To 0.9.0 and 4.17.0 respectively.
    
    Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm,
    terminfo, text, unix, haddock, and hsc2hs submodules.
    
    (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095)
    
    - - - - -
    4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00
    testsuite: Use normalise_version more consistently
    
    Previously several tests' output were unnecessarily dependent on version
    numbers, particularly of `base`. Fix this.
    
    - - - - -
    d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00
    linters: Fix lint-submodule-refs when crashing trying to find plausible branches
    
    - - - - -
    38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
    hadrian: Improve haddocks for ghcDebugAssertions
    
    - - - - -
    ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
    Don't mark lambda binders as OtherCon
    
    We used to put OtherCon unfoldings on lambda binders of workers
    and sometimes also join points/specializations with with the
    assumption that since the wrapper would force these arguments
    once we execute the RHS they would indeed be in WHNF.
    
    This was wrong for reasons detailed in #21472. So now we purge
    evaluated unfoldings from *all* lambda binders.
    
    This fixes #21472, but at the cost of sometimes not using as efficient a
    calling convention. It can also change inlining behaviour as some
    occurances will no longer look like value arguments when they did
    before.
    
    As consequence we also change how we compute CBV information for
    arguments slightly. We now *always* determine the CBV convention
    for arguments during tidy. Earlier in the pipeline we merely mark
    functions as candidates for having their arguments treated as CBV.
    
    As before the process is described in the relevant notes:
    Note [CBV Function Ids]
    Note [Attaching CBV Marks to ids]
    Note [Never put `OtherCon` unfoldigns on lambda binders]
    
    -------------------------
    Metric Decrease:
        T12425
        T13035
        T18223
        T18223
        T18923
        MultiLayerModulesTH_OneShot
    Metric Increase:
        WWRec
    -------------------------
    
    - - - - -
    06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00
    Add suggestions for unrecognised pragmas (#21589)
    
    In case of a misspelled pragma, offer possible corrections as to what
    the user could have meant.
    
    Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589
    
    - - - - -
    3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00
    Remove the traces of i386-*-openbsd, long live amd64
    
    OpenBSD will not ship any ghc packages on i386 starting with 7.2
    release.  This means there will not be a bootstrap compiler easily
    available.  The last available binaries are ghc-8.10.6 which is
    already not supported as bootstrap for HEAD.
    
    See here for more information:
    
    https://marc.info/?l=openbsd-ports&m=165060700222580&w=2
    
    - - - - -
    58530271 by Andrew Lelechenko at 2022-06-27T08:03:34-04:00
    Add Foldable1 and Bifoldable1 type classes
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9
    
    Instances roughly follow
    https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1
    but the API of `Foldable1` was expanded in comparison to `semigroupoids`.
    
    Compatibility shim is available from https://github.com/phadej/foldable1 (to be released).
    
    Closes #13573.
    
    - - - - -
    a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00
    add levity polymorphism to addrToAny#
    
    - - - - -
    f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00
    add tests for addrToAny# levity
    
    - - - - -
    07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00
    hadrian: Update main README page
    
    This README had some quite out-of-date content about the build system so
    I did a complete pass deleting old material. I also made the section
    about flavours more prominent and mentioned flavour transformers.
    
    - - - - -
    79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00
    testsuite: Hide output from test compilations with verbosity==2
    
    Previously the output from test compilations used to determine whether,
    e.g., profiling libraries are available was shown with verbosity
    levels >= 2. However, the default level is 2, meaning that most users
    were often spammed with confusing errors. Fix this by bumping the
    verbosity threshold for this output to >=3.
    
    Fixes #21760.
    - - - - -
    995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00
    configure: Only probe for LD in FIND_LD
    
    Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD
    rather early in `configure`. However, it turns out that this breaks
    `configure`'s `ld`-override logic, which assumes that `LD` was set by
    the user and aborts.
    
    Fixes #21778.
    
    - - - - -
    b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00
    `.hs-boot` make rules: add missing order-only dependency on target directory
    
    Noticed missing target directory dependency as a build failure in
    `make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100):
    
        "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot
        cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory
        libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory
        make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254
        make: *** [Makefile:128: all] Error 2 shuffle=1656129254
    
    Note that `cp` complains about inability to create target file.
    
    The change adds order-only dependency on a target directory (similar to
    the rest of rules in that file).
    
    The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build
    system megapatch`.) where upfront directory creation was never added to
    `.hs-boot` files.
    
    - - - - -
    57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00
    Mark AArch64/Darwin as requiring sign-extension
    
    Apple's AArch64 ABI requires that the caller sign-extend small integer
    arguments. Set platformCConvNeedsExtension to reflect this fact.
    
    Fixes #21773.
    
    - - - - -
    df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00
    -ddump-llvm shouldn't imply -fllvm
    
    Previously -ddump-llvm would change the backend used, which contrasts
    with all other dump flags. This is quite surprising and cost me quite
    a bit of time. Dump flags should not change compiler behavior.
    
    Fixes #21776.
    
    - - - - -
    70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00
    CmmToAsm/AArch64: Re-format argument handling logic
    
    Previously there were very long, hard to parse lines. Fix this.
    
    - - - - -
    696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00
    CmmToAsm/AArch64: Sign-extend narrow C arguments
    
    The AArch64/Darwin ABI requires that function arguments narrower
    than 32-bits must be sign-extended by the caller. We neglected to
    do this, resulting in #20735.
    
    Fixes #20735.
    
    - - - - -
    c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00
    testsuite: Add test for #20735
    
    - - - - -
    16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00
    integer-gmp: Fix cabal file
    
    Evidently fields may not come after sections in a cabal file.
    
    - - - - -
    03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00
    ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist)
    
    before the change `make install` was failing as:
    
    ```
    "mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc"
    make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'.  Stop.
    ```
    
    I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf`
    is created (somewhat manually), but not the .install varianlt of it.
    
    The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere.
    
    Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784
    
    - - - - -
    eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00
    Comments only, about join points
    
    This MR just adds some documentation about why casts
    destroy join points, following #21716.
    
    - - - - -
    251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00
    Cleanup BuiltInSyntax vs UserSyntax
    
    There was some confusion about whether FUN/TYPE/One/Many should be
    BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as
    BuiltInSyntax is for things which are directly constructed by the parser
    rather than going through normal renaming channels.
    
    I fixed all the obviously wrong places I could find and added a test for
    the original bug which was caused by this (#21752)
    
    Fixes #21752 #20695 #18302
    
    - - - - -
    0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00
    template-haskell: Bump version to 2.19.0.0
    
    Bumps text and exceptions submodules due to bounds.
    
    - - - - -
    bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00
    Tiny tweak to `IOPort#` documentation
    
    The exclamation mark and bracket don’t seem to make sense here. I’ve
    looked through the history, and I don’t think they’re deliberate – possibly
    a copy-and-paste error.
    - - - - -
    70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00
    Remove `CoreOccurAnal` constructor of the `CoreToDo` type
    
    It was dead code since the last occurence in an expression context got
    removed in 71916e1c018dded2e68d6769a2dbb8777da12664.
    
    - - - - -
    d0722170 by nineonine at 2022-07-01T08:15:56-04:00
    Fix panic with UnliftedFFITypes+CApiFFI (#14624)
    
    When declaring foreign import using CAPI calling convention, using
    unlifted unboxed types would result in compiler panic. There was
    an attempt to fix the situation in #9274, however it only addressed
    some of the ByteArray cases.
    
    This patch fixes other missed cases for all prims that may be used
    as basic foreign types.
    
    - - - - -
    eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00
    rts: gc stats: account properly for copied bytes in sequential collections
    
    We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow]
    counters during sequential collections. As well, we were double counting for
    parallel collections.
    
    To fix this we add an `else` clause to the `if (is_par_gc())`.
    
    The par_* counters do not need to be updated in the sequential case
    because they must be 0.
    
    - - - - -
    f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00
    desugar: Look through ticks when warning about possible literal overflow
    
    Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up
    between the appliation of `neg` to its argument. This defeated the
    special logic which looks for `NegApp ... (HsOverLit` to warn about
    possible overflow if a user writes a negative literal (without out
    NegativeLiterals) in their code.
    
    Fixes #21701
    
    - - - - -
    f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00
    ci: Fix definition of slow-validate flavour (so that -dlint) is passed
    
    In this embarassing sequence of events we were running slow-validate
    without -dlint.
    
    - - - - -
    bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00
    Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411
    - - - - -
    9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00
    Data.Foldable1: Remove references to Foldable-specific note
    
    ...as discussed in
    https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455.
    
    - - - - -
    3a8970ac by romes at 2022-07-03T14:11:31-04:00
    TTG: Move HsModule to L.H.S
    
    Move the definition of HsModule defined in GHC.Hs to
    Language.Haskell.Syntax with an added TTG parameter and corresponding
    extension fields.
    
    This is progress towards having the haskell-syntax package, as described
    in #21592
    
    - - - - -
    f9f80995 by romes at 2022-07-03T14:11:31-04:00
    TTG: Move ImpExp client-independent bits to L.H.S.ImpExp
    
    Move the GHC-independent definitions from GHC.Hs.ImpExp to
    Language.Haskell.Syntax.ImpExp with the required TTG extension fields
    such as to keep the AST independent from GHC.
    
    This is progress towards having the haskell-syntax package, as described
    in #21592
    
    Bumps haddock submodule
    
    - - - - -
    c43dbac0 by romes at 2022-07-03T14:11:31-04:00
    Refactor ModuleName to L.H.S.Module.Name
    
    ModuleName used to live in GHC.Unit.Module.Name. In this commit, the
    definition of ModuleName and its associated functions are moved to
    Language.Haskell.Syntax.Module.Name according to the current plan
    towards making the AST GHC-independent.
    
    The instances for ModuleName for Outputable, Uniquable and Binary were
    moved to the module in which the class is defined because these instances
    depend on GHC.
    
    The instance of Eq for ModuleName is slightly changed to no longer
    depend on unique explicitly and instead uses FastString's instance of
    Eq.
    
    - - - - -
    2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00
    Expand `Ord` instance for `Down`
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610
    
    - - - - -
    36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00
    Add applyWhen to Data.Function per CLC prop
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233
    
    - - - - -
    3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00
    hadrian: Don't read package environments in ghc-stage1 wrapper
    
    The stage1 compiler may be on the brink of existence and not have even a
    working base library. You may have installed packages globally with a
    similar stage2 compiler which will then lead to arguments such as
    --show-iface not even working because you are passing too many package
    flags. The solution is simple, don't read these implicit files.
    
    Fixes #21803
    
    - - - - -
    aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00
    Ticky:Make json info a separate field.
    
    Fixes #21233
    
    - - - - -
    74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00
    Add docs:<pkg> command to hadrian to build docs for just one package
    
    - - - - -
    418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00
    upload-docs: propagate publish correctly in upload_sdist
    
    - - - - -
    ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00
    docs-upload: Fix upload script when no packages are listed
    
    - - - - -
    d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00
    hadrian: Add --haddock-base-url option for specifying base-url when generating docs
    
    The motiviation for this flag is to be able to produce documentation
    which is suitable for uploading for hackage, ie, the cross-package links
    work correctly.
    
    There are basically three values you want to set this to:
    
    * off - default, base_url = ../%pkg% which works for local browsing
    * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload
    * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation.
    
    The `%pkg%` string is a template variable which is replaced with the
    package identifier for the relevant package.
    
    This is one step towards fixing #21749
    
    - - - - -
    41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00
    Add nightly job for generating docs suitable for hackage upload
    
    - - - - -
    620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00
    ghci: Support :set prompt in multi repl
    
    This adds supports for various :set commands apart from `:set <FLAG>` in
    multi repl, this includes `:set prompt` and so-on.
    
    Fixes #21796
    
    - - - - -
    b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00
    Vendor filepath inside template-haskell
    
    Adding filepath as a dependency of template-haskell means that it can't
    be reinstalled if any build-plan depends on template-haskell.
    
    This is a temporary solution for the 9.4 release.
    
    A longer term solution is to split-up the template-haskell package into
    the wired-in part and a non-wired-in part which can be reinstalled. This
    was deemed quite risky on the 9.4 release timescale.
    
    Fixes #21738
    
    - - - - -
    c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00
    Factor fields of `CoreDoSimplify` into separate data type
    
    This avoids some partiality. The work @mmhat is doing cleaning up and
    modularizing `Core.Opt` will build on this nicely.
    
    - - - - -
    d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00
    https urls
    - - - - -
    803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00
    options and typos
    - - - - -
    5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00
    grammar
    - - - - -
    4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00
    sources
    - - - - -
    c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00
    Fix lint warnings in bootstrap.py
    
    - - - - -
    86ced2ad by romes at 2022-07-06T01:36:23-04:00
    Restore Eq instance of ImportDeclQualifiedStyle
    
    Fixes #21819
    
    - - - - -
    3547e264 by romes at 2022-07-06T13:50:27-04:00
    Prune L.H.S modules of GHC dependencies
    
    Move around datatypes, functions and instances that are GHC-specific out
    of the `Language.Haskell.Syntax.*` modules to reduce the GHC
    dependencies in them -- progressing towards #21592
    
    Creates a module `Language.Haskell.Syntax.Basic` to hold basic
    definitions required by the other L.H.S modules (and don't belong in any
    of them)
    
    - - - - -
    e4eea07b by romes at 2022-07-06T13:50:27-04:00
    TTG: Move CoreTickish out of LHS.Binds
    
    Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and
    move them to the extension point instance, according to the plan
    outlined in #21592 to separate the base AST from the GHC specific bits.
    
    - - - - -
    acc1816b by romes at 2022-07-06T13:50:27-04:00
    TTG for ForeignImport/Export
    
    Add a TTG parameter to both `ForeignImport` and `ForeignExport` and,
    according to #21592, move the GHC-specific bits in them and in the other
    AST data types related to foreign imports and exports to the TTG
    extension point.
    
    - - - - -
    371c5ecf by romes at 2022-07-06T13:50:27-04:00
    TTG for HsTyLit
    
    Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText`
    fields to the extension point and out of the base AST.
    
    Progress towards #21592
    
    - - - - -
    fd379d1b by romes at 2022-07-06T13:50:27-04:00
    Remove many GHC dependencies from L.H.S
    
    Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC
    imports according to the plan in the linked issue.
    
    Moves more GHC-specific declarations to `GHC.*` and brings more required
    GHC-independent declarations to `Language.Haskell.Syntax.*` (extending
    e.g. `Language.Haskell.Syntax.Basic`).
    
    Progress towards #21592
    
    Bump haddock submodule for !8308
    
    -------------------------
    Metric Decrease:
        hard_hole_fits
    -------------------------
    
    - - - - -
    c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00
    Fix exact printing of the HsRule name
    
    Prior to this branch, the HsRule name was
    
        XRec pass (SourceText,RuleName)
    
    and there is an ExactPrint instance for (SourceText, RuleName).
    
    The SourceText has moved to a different location, so synthesise the
    original to trigger the correct instance when printing.
    
    We need both the SourceText and RuleName when exact printing, as it is
    possible to have a NoSourceText variant, in which case we fall back to
    the FastString.
    
    - - - - -
    665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00
    driver: Fix issue with module loops and multiple home units
    
    We were attempting to rehydrate all dependencies of a particular module,
    but we actually only needed to rehydrate those of the current package
    (as those are the ones participating in the loop).
    
    This fixes loading GHC into a multi-unit session.
    
    Fixes #21814
    
    - - - - -
    bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00
    Remove a bogus #define from ClosureMacros.h
    
    - - - - -
    fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00
    winio: make consoleReadNonBlocking not wait for any events at all.
    
    - - - - -
    42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00
    rts: allow NULL to be used as an invalid StgStablePtr
    
    - - - - -
    3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00
    RTS: Add stack marker to StgCRunAsm.S
    
    Every object file must be properly marked for non-executable stack, even if it
    contains no code.
    
    - - - - -
    a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00
    Bump unix submodule
    
    Adds `config.sub` to unix's `.gitignore`, fixing #19574.
    
    - - - - -
    3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00
    ghci: Fix most calls to isLoaded to work in multi-mode
    
    The most egrarious thing this fixes is the report about the total number
    of loaded modules after starting a session.
    
    Ticket #20889
    
    - - - - -
    fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00
    Enable :edit command in ghci multi-mode.
    
    This works after the last change to isLoaded.
    
    Ticket #20888
    
    - - - - -
    46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00
    Fix a scoping bug in the Specialiser
    
    In the call to `specLookupRule` in `already_covered`, in `specCalls`,
    we need an in-scope set that includes the free vars of the arguments.
    But we simply were not guaranteeing that: did not include the
    `rule_bndrs`.
    
    Easily fixed.  I'm not sure how how this bug has lain for quite
    so long without biting us.
    
    Fixes #21828.
    
    - - - - -
    6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
    Edit Note [idArity varies independently of dmdTypeDepth]
    
    ...and refer to it in GHC.Core.Lint.lintLetBind.
    
    Fixes #21452
    
    - - - - -
    89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
    Tiny documentation wibbles (comments only)
    
    - - - - -
    61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00
    fix readme
    - - - - -
    61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00
    fix bootstrap
    - - - - -
    8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00
    tarball
    - - - - -
    e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00
    hie-files: Fix scopes for deriving clauses and instance signatures (#18425)
    
    - - - - -
    c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00
    hie-files: Record location of filled in default method bindings
    
    This is useful for hie files to reconstruct the evidence that default methods
    depend on.
    
    - - - - -
    9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00
    testsuite: Factor out common parts from hiefile tests
    
    - - - - -
    6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00
    Hadrian: update documentation of settings
    
    The documentation for key-value settings was a bit out of date.
    This patch updates it to account for `cabal.configure.opts` and
    `hsc2hs.run.opts`.
    
    The user-settings document was also re-arranged, to make the key-value
    settings more prominent (as it doesn't involve changing the Hadrian
    source code, and thus doesn't require any recompilation of Hadrian).
    
    - - - - -
    a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00
    Fix potential space leak that arise from ModuleGraphs retaining references
    to previous ModuleGraphs, in particular the lazy `mg_non_boot` field.
    This manifests in `extendMG`.
    
    Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which
    is only called in two places in the compiler, and should only be called at most
    once for every home unit:
    
    GHC.Driver.Make:
          mainModuleSrcPath :: Maybe String
          mainModuleSrcPath = do
            ms <- mgLookupModule mod_graph (mainModIs hue)
            ml_hs_file (ms_location ms)
    
    GHCI.UI:
    listModuleLine modl line = do
       graph <- GHC.getModuleGraph
       let this = GHC.mgLookupModule graph modl
    
    Instead `mgLookupModule` can be a linear function that looks through the entire
    list of `ModuleGraphNodes`
    
    Fixes #21816
    
    - - - - -
    dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00
    rts: Fix AdjustorPool bitmap manipulation
    
    Previously the implementation of bitmap_first_unset assumed that
    `__builtin_clz` would accept `uint8_t` however it apparently rather
    extends its argument to `unsigned int`.
    
    To fix this we simply revert to a naive implementation since handling
    the various corner cases with `clz` is quite tricky. This should be
    fine given that AdjustorPool isn't particularly hot. Ideally we would
    have a single, optimised bitmap implementation in the RTS but I'll leave
    this for future work.
    
    Fixes #21838.
    
    - - - - -
    ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00
    Change GHCi bytecode return convention for unlifted datatypes.
    
    This changes the bytecode return convention for unlifted
    algebraic datatypes to be the same as for lifted
    types, i.e. ENTER/PUSH_ALTS instead of
    RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED
    
    Fixes #20849
    
    - - - - -
    5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00
    Compute record-dot-syntax types
    Ensures type information for record-dot-syntax
    is included in HieASTs. See #21797
    
    - - - - -
    89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00
    Add record-dot-syntax test
    
    - - - - -
    4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00
    Document RuntimeRep polymorphism limitations of catch#, et al
    
    As noted in #21868, several primops accepting continuations producing
    RuntimeRep-polymorphic results aren't nearly as polymorphic as their
    types suggest. Document this limitation and adapt the `UnliftedWeakPtr`
    test to avoid breaking this limitation in `keepAlive#`.
    
    - - - - -
    4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00
    Make keepAlive# out-of-line
    
    This is a naive approach to fixing the unsoundness noticed in #21708.
    Specifically, we remove the lowering of `keepAlive#` via CorePrep and
    instead turn it into an out-of-line primop.
    This is simple, inefficient (since the continuation must now be heap
    allocated), but good enough for 9.4.1. We will revisit this
    (particiularly via #16098) in a future release.
    
    Metric Increase:
        T4978
        T7257
        T9203
    
    - - - - -
    1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00
    Suppress extra output from configure check for c++ libraries
    
    - - - - -
    3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00
    rel-notes: Drop mention of #21745 fix
    
    Since we have backported the fix to 9.4.1.
    
    - - - - -
    b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00
    Align the behaviour of `dopt` and `log_dopt`
    
    Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying
    function `log_dopt`) were different as the latter did not take the
    verbosity level into account. This led to problems during the
    refactoring as we cannot simply replace calls to `dopt` with calls to
    `logHasDumpFlag`.
    
    In addition to that a subtle bug in the GHC module was fixed:
    `setSessionDynFlags` did not update the logger and as a consequence the
    verbosity value of the logger was not set appropriately.
    
    Fixes #21861
    
    - - - - -
    28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00
    rts: forkOn context switches the target capability
    
    Fixes #21824
    
    - - - - -
    f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00
    cmm: Eliminate orphan Outputable instances
    
    Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and
    `OutputableP` instances for the Cmm AST. This makes it significantly
    easier to use the Cmm pretty-printers in tracing output without
    incurring module import cycles.
    
    - - - - -
    f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00
    cmm: Move toBlockList to GHC.Cmm
    
    - - - - -
    fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00
    compiler: Add haddock sections to GHC.Utils.Panic
    
    - - - - -
    097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00
    configure: Don't override Windows CXXFLAGS
    
    At some point we used the clang distribution from msys2's `MINGW64`
    environment for our Windows toolchain. This defaulted to using libgcc
    and libstdc++ for its runtime library. However, we found for a variety
    of reasons that compiler-rt, libunwind, and libc++ were more reliable,
    consequently we explicitly overrode the CXXFLAGS to use these.
    
    However, since then we have switched to use the `CLANG64` packaging,
    which default to these already. Consequently we can drop these
    arguments, silencing some redundant argument warnings from clang.
    
    Fixes #21669.
    
    - - - - -
    e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/Elf: Check that there are no NULL ctors
    
    - - - - -
    616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/Elf: Introduce support for invoking finalizers on unload
    
    Addresses #20494.
    
    - - - - -
    cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00
    testsuite: Add T20494
    
    - - - - -
    03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Rename finit field to fini
    
    fini is short for "finalizer", which does not contain a "t".
    
    - - - - -
    033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Refactor handling of oc->info
    
    Previously we would free oc->info after running initializers. However,
    we can't do this is we want to also run finalizers.
    
    Moreover, freeing oc->info so early was wrong for another reason:
    we will need it in order to unregister the exception tables (see the
    call to `RtlDeleteFunctionTable`).
    
    In service of #20494.
    
    - - - - -
    f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Add finalization support
    
    This implements #20494 for the PEi386 linker.
    
    Happily, this also appears to fix `T9405`, resolving #21361.
    
    - - - - -
    2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00
    Loader: Implement gnu-style -l:$path syntax
    
    Gnu ld allows `-l` to be passed an absolute file path,
    signalled by a `:` prefix. Implement this in the GHC's
    loader search logic.
    
    - - - - -
    5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00
    Statically-link against libc++ on Windows
    
    Unfortunately on Windows we have no RPATH-like facility, making dynamic
    linking extremely fragile. Since we cannot assume that the user will
    add their GHC installation to `$PATH` (and therefore their DLL
    search path) we cannot assume that the loader will be able to locate our
    `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on
    Windows.
    
    Fixes #21435.
    
    - - - - -
    8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run
    
    It turns out that PE objects may have multiple `.ctors`/`.dtors`
    sections but the RTS linker had assumed that there was only one. Fix
    this.
    
    Fixes #21618.
    
    - - - - -
    fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Respect dtor/ctor priority
    
    Previously we would run constructors and destructors in arbitrary order
    despite explicit priorities.
    
    Fixes #21847.
    
    - - - - -
    1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00
    testsuite: Add test for #21618 and #21847
    
    - - - - -
    6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/PEi386: Fix exception unwind unregistration
    
    RtlDeleteFunctionTable expects a pointer to the .pdata section
    yet we passed it the .xdata section.
    
    Happily, this fixes #21354.
    
    - - - - -
    d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/MachO: Drop dead code
    
    - - - - -
    d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/MachO: Use section flags to identify initializers
    
    - - - - -
    fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00
    rts/linker/MachO: Introduce finalizer support
    
    - - - - -
    5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00
    testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl
    
    - - - - -
    6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00
    rts/linker/Elf: Work around GCC 6 init/fini behavior
    
    It appears that GCC 6t (at least on i386) fails to give
    init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY
    section types, instead marking them as SHT_PROGBITS. This caused T20494
    to fail on Debian.
    
    - - - - -
    5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00
    testsuite: Mark T13366Cxx as unbroken on Darwin
    
    - - - - -
    1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00
    rts/linker: Fix resolution of __dso_handle on Darwin
    
    Darwin expects a leading underscore.
    
    - - - - -
    a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00
    rts/linker: Clean up section kinds
    
    - - - - -
    aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00
    rts/linker: Ensure that __cxa_finalize is called on code unload
    
    - - - - -
    028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00
    testsuite: Fix T11829 on Centos 7
    
    It appears that Centos 7 has a more strict C++ compiler than most
    distributions since std::runtime_error is defined in <stdexcept> rather
    than <exception>. In T11829 we mistakenly imported the latter.
    
    - - - - -
    a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00
    hadrian: Rename documentation directories for consistency with make
    
    * Rename `docs` to `doc`
    * Place pdf documentation in `doc/` instead of `doc/pdfs/`
    
    Fixes #21164.
    
    - - - - -
    b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00
    Fix incorrect proof of applyWhen’s properties
    
    - - - - -
    eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00
    hadrian: Add multi:<pkg> and multi targets for starting a multi-repl
    
    This patch adds support to hadrian for starting a multi-repl containing
    all the packages which stage0 can build. In particular, there is the new
    user-facing command:
    
    ```
    ./hadrian/ghci-multi
    ```
    
    which when executed will start a multi-repl containing the `ghc` package
    and all it's dependencies.
    
    This is implemented by two new hadrian targets:
    
    ```
    ./hadrian/build multi:<pkg>
    ```
    
    Construct the arguments for a multi-repl session where the top-level
    package is <pkg>. For example, `./hadrian/ghci-multi` is implemented
    using `multi:ghc` target.
    
    There is also the `multi` command which constructs a repl for everything
    in stage0 which we can build.
    
    - - - - -
    19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00
    changelog typo
    - - - - -
    af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00
    typos
    
    - - - - -
    415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00
    Refactor SpecConstr to use treat bindings uniformly
    
    This patch, provoked by #21457, simplifies SpecConstr by treating
    top-level and nested bindings uniformly (see the new scBind).
    
    * Eliminates the mysterious scTopBindEnv
    
    * Refactors scBind to handle top-level and nested definitions
      uniformly.
    
    * But, for now at least, continues the status quo of not doing
      SpecConstr for top-level non-recursive bindings.  (In contrast
      we do specialise nested non-recursive bindings, although the
      original paper did not; see Note [Local let bindings].)
    
      I tried the effect of specialising top-level non-recursive
      bindings (which is now dead easy to switch on, unlike before)
      but found some regressions, so I backed off.  See !8135.
    
    It's a pure refactoring.  I think it'll do a better job in a few
    cases, but there is no regression test.
    
    - - - - -
    d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00
    Rule matching: Don't compute the FVs if we don't look at them.
    
    - - - - -
    5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    White space only in FamInstEnv
    
    - - - - -
    ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    Make transferPolyIdInfo work for CPR
    
    I don't know why this hasn't bitten us before, but it was plain wrong.
    
    - - - - -
    9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    Inline mapAccumLM
    
    This function is called in inner loops in the compiler, and it's
    overloaded and higher order.  Best just to inline it.
    
    This popped up when I was looking at something else.  I think
    perhaps GHC is delicately balanced on the cusp of inlining this
    automatically.
    
    - - - - -
    d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    Make SetLevels honour floatConsts
    
    This fix,  in the definition of profitableFloat,
    is just for consistency. `floatConsts` should
    do what it says!
    
    I don't think it'll affect anything much, though.
    
    - - - - -
    d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
    Refactor wantToUnboxArg a bit
    
    * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg
      and similarly wantToUnboxResult to canUnboxResult.
    
    * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for
      the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg,
      avoiding some yukky duplication.
    
      I decided it was clearer to give it a new data type for its
      return type, because I nedeed the FD_RecBox case which was not
      otherwise readiliy expressible.
    
    * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload
    
    * Get rid of the Unlift constructor of UnboxingDecision, eliminate
      two panics, and two arguments to canUnboxArg (new name).  Much
      nicer now.
    
    - - - - -
    6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00
    Allow running memInventory when the concurrent nonmoving gc is enabled
    
    If the nonmoving gc is enabled and we are using a threaded RTS,
    we now try to grab the collector mutex to avoid memInventory and
    the collection racing.
    
    Before memInventory was disabled.
    
    - - - - -
    aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00
    gitignore: don't ignore all aclocal.m4 files
    
    While GHC's own aclocal.m4 is generated by the aclocal tool, other
    packages' aclocal.m4 are committed in the repository. Previously
    `.gitignore` included an entry which covered *any* file named
    `aclocal.m4`, which lead to quite some confusion (e.g. see #21740).
    Fix this by modifying GHC's `.gitignore` to only cover GHC's own
    `aclocal.m4`.
    
    - - - - -
    4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00
    Add mapAccumM, forAccumM to Data.Traversable
    
    Approved by Core Libraries Committee in
    https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433
    
    - - - - -
    bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00
    configure: Use AC_PATH_TOOL to detect tools
    
    Previously we used AC_PATH_PROG which, as noted by #21601, does not
    look for tools with a target prefix,
    breaking cross-compilation.
    
    Fixes #21601.
    
    - - - - -
    e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00
    driver: Fix implementation of -S
    
    We were failing to stop before running the assembler so the object file
    was also created.
    
    Fixes #21869
    
    - - - - -
    e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00
    rts/ProfHeap: Ensure new Censuses are zeroed
    
    When growing the Census array ProfHeap previously neglected to
    zero the new part of the array. Consequently `freeEra` would attempt to
    free random words that often looked suspiciously like pointers.
    
    Fixes #21880.
    
    - - - - -
    81d65f7f by sheaf at 2022-07-21T15:37:22+02:00
    Make withDict opaque to the specialiser
    
    As pointed out in #21575, it is not sufficient to set withDict to inline
    after the typeclass specialiser, because we might inline withDict in one
    module and then import it in another, and we run into the same problem.
    This means we could still end up with incorrect runtime results because
    the typeclass specialiser would assume that distinct typeclass evidence
    terms at the same type are equal, when this is not necessarily the case
    when using withDict.
    
    Instead, this patch introduces a new magicId, 'nospec', which is only
    inlined in CorePrep. We make use of it in the definition of withDict
    to ensure that the typeclass specialiser does not common up distinct
    typeclass evidence terms.
    
    Fixes #21575
    
    - - - - -
    9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00
    Refactored Simplify pass
    
     * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify
       namespace and GHC.Core.Opt.Stats.
       Also removed services from configuration records.
    
     * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration.
    
     * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm`
       and moved the Simplify driver to GHC.Core.Opt.Simplify.
    
     * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env.
    
     * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment
       in GHC.Core.Opt.Simplify.Monad.
    
     * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions
       for those in a new module GHC.Driver.Config.Core.Opt.Simplify.
       Also added initialization functions for `SimplMode` to that module.
    
     * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types
       and the counting types and functions (`SimplCount` and `Tick`) to new
       module GHC.Core.Opt.Stats.
    
     * Added getter functions for the fields of `SimplMode`. The pedantic bottoms
       option and the platform are retrieved from the ArityOpts and RuleOpts and the
       getter functions allow us to retrieve values from `SpecEnv` without the
       knowledge where the data is stored exactly.
    
     * Moved the coercion optimization options from the top environment to
       `SimplMode`. This way the values left in the top environment are those
       dealing with monadic functionality, namely logging, IO related stuff and
       counting. Added a note "The environments of the Simplify pass".
    
     * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of
       `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead.
    
     * Prep work before removing `InteractiveContext` from `HscEnv`.
    
    - - - - -
    2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00
    Make the specialiser deal better with specialised methods
    
    This patch fixes #21848, by being more careful to update unfoldings
    in the type-class specialiser.
    
    See the new Note [Update unfolding after specialisation]
    
    Now that we are being so much more careful about unfoldings,
    it turned out that I could dispense with se_interesting, and
    all its tricky corners. Hooray.  This fixes #21368.
    
    - - - - -
    ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00
    ghc-boot: Clean up UTF-8 codecs
    
    In preparation for moving the UTF-8 codecs into `base`:
    
    * Move them to GHC.Utils.Encoding.UTF8
    * Make names more consistent
    * Add some Haddocks
    
    - - - - -
    e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00
    base: Introduce GHC.Encoding.UTF8
    
    Here we copy a subset of the UTF-8 implementation living in `ghc-boot`
    into `base`, with the intent of dropping the former in the future. For
    this reason, the `ghc-boot` copy is now CPP-guarded on
    `MIN_VERSION_base(4,18,0)`.
    
    Naturally, we can't copy *all* of the functions defined by `ghc-boot` as
    some depend upon `bytestring`; we rather just copy those which only
    depend upon `base` and `ghc-prim`.
    
    Further consolidation?
    ----------------------
    
    Currently GHC ships with at least five UTF-8 implementations:
    
    * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this
      can be used at a number of types including `Addr#`, `ByteArray#`,
      `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this
      can be removed in GHC 9.6+2, when the copies in `base` will become
      available to `ghc-boot`.
    * the copy of the `ghc-boot` definition now exported by
      `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`,
      `ByteArray#`, and `ForeignPtr`
    * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`;
      this is specialised at `Addr#`.
    * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`;
      this is specialised at `Addr#` but, unlike the above, supports
      recovery in the presence of partial codepoints (since in IO contexts
      codepoints may be broken across buffers)
    * the implementation provided by the `text` library
    
    This does seem a tad silly. On the other hand, these implementations
    *do* materially differ from one another (e.g. in the types they support,
    the detail in errors they can report, and the ability to recover from
    partial codepoints). Consequently, it's quite unclear that further
    consolidate would be worthwhile.
    
    - - - - -
    f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00
    Add a Note summarising GHC's UTF-8 implementations
    
    GHC has a somewhat dizzying array of UTF-8 implementations. This note
    describes why this is the case.
    
    - - - - -
    72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00
    upload_ghc_libs: Fix path to documentation
    
    The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35
    but this one occurrence was note updated.
    
    Finally closes #21164.
    
    - - - - -
    a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00
    Add test for #21871
    
    This adds a test for #21871, which was fixed by the No Skolem Info
    rework (MR !7105).
    
    Fixes #21871
    
    - - - - -
    6379f942 by sheaf at 2022-07-22T08:18:46-04:00
    Add test for #21360
    
    The way record updates are typechecked/desugared changed in MR !7981.
    Because we desugar in the typechecker to a simple case expression, the
    pattern match checker becomes able to spot the long-distance information
    and avoid emitting an incorrect pattern match warning.
    
    Fixes #21360
    
    - - - - -
    ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00
    Hadrian: don't try to build "unix" on Windows
    - - - - -
    dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
    Implement DeepSubsumption
    
    This MR adds the language extension -XDeepSubsumption, implementing
    GHC proposal #511.  This change mitigates the impact of GHC proposal
    
    The changes are highly localised, by design.  See Note [Deep subsumption]
    in GHC.Tc.Utils.Unify.
    
    The main changes are:
    
    * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010,
      but off in Haskell2021.
    
      -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change.
      -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds:
      it makes type inference more complicated and less predictable, but it
      may be convenient in practice.
    
    * The main changes are in:
      * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion
      * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation
      * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result
        type. Without deep subsumption, unifyExpectedType would be sufficent.
    
      See Note [Deep subsumption] in GHC.Tc.Utils.Unify.
    
    * There are no changes to Quick Look at all.
    
    * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to
      GHC.Magic.Dict
    
    * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where
      we'd forgotten to take the free vars of the multiplicity of an Id.
    
    * I also had to fix tcSplitNestedSigmaTys
    
      When I did the shallow-subsumption patch
        commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f
        Date:   Sun Feb 2 18:23:11 2020 +0000
        Simple subsumption
    
      I changed tcSplitNestedSigmaTys to not look through function arrows
      any more.  But that was actually an un-forced change.  This function
      is used only in
    
      * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt
      * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass
      * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect
    
      All to do with validity checking and error messages. Acutally its
      fine to look under function arrows here, and quite useful a test
      DeepSubsumption05 (a test motivated by a build failure in the
      `lens` package) shows.
    
      The fix is easy.  I added Note [tcSplitNestedSigmaTys].
    
    - - - - -
    e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00
    Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption
    
    - - - - -
    67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00
    Add DeepSubsumption08
    
    - - - - -
    5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
    Fix the interaction of operator sections and deep subsumption
    
    Fixes DeepSubsumption08
    
    - - - - -
    918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00
    Add DeepSubsumption09
    
    - - - - -
    2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00
    Default implementation for mempty/(<>)
    
    Approved by: https://github.com/haskell/core-libraries-committee/issues/61
    
    This adds a default implementation for `mempty` and `(<>)` along
    with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid`
    instances can be defined in terms of `sconcat` / `mconcat`.
    
    The description for each class has also been updated to include the
    equivalent set of laws for the `sconcat`-only / `mconcat`-only
    instances.
    
    - - - - -
    73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00
    ci: Disable (broken) perf-nofib
    
    See #21859
    
    - - - - -
    c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00
    Docs: clarify ConstraintKinds infelicity
    
    GHC doesn't consistently require the ConstraintKinds extension to
    be enabled, as it allows programs such as type families returning
    a constraint without this extension.
    
    MR !7784 fixes this infelicity, but breaking user programs was deemed
    to not be worth it, so we document it instead.
    
    Fixes #21061.
    
    - - - - -
    5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00
    More improvements to worker/wrapper
    
    This patch fixes #21888, and simplifies finaliseArgBoxities
    by eliminating the (recently introduced) data type FinalDecision.
    
    A delicate interaction meant that this patch
       commit d1c25a48154236861a413e058ea38d1b8320273f
       Date:   Tue Jul 12 16:33:46 2022 +0100
       Refactor wantToUnboxArg a bit
    
    make worker/wrapper go into an infinite loop.  This patch
    fixes it by narrowing the handling of case (B) of
    Note [Boxity for bottoming functions], to deal only the
    arguemnts that are type variables.  Only then do we drop
    the trimBoxity call, which is what caused the bug.
    
    I also
    * Added documentation of case (B), which was previously
      completely un-mentioned.  And a regression test,
      T21888a, to test it.
    
    * Made unboxDeeplyDmd stop at lazy demands.  It's rare anyway
      for a bottoming function to have a lazy argument (mainly when
      the data type is recursive and then we don't want to unbox
      deeply).  Plus there is Note [No lazy, Unboxed demands in
      demand signature]
    
    * Refactored the Case equation for dmdAnal a bit, to do less
      redundant pattern matching.
    
    - - - - -
    b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00
    Fix a small buglet in tryEtaReduce
    
    Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was
    making an ill-formed cast.  It didn't matter, because the subsequent
    guard discarded it; but still worth fixing.  Spurious warnings are
    distracting.
    
    - - - - -
    3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00
    Fix #21889, GHCi misbehaves with Ctrl-C on Windows
    
    On Windows, we create multiple levels of wrappers for GHCi which ultimately
    execute ghc --interactive. In order to handle console events properly, each of
    these wrappers must call FreeConsole() in order to hand off event processing to
    the child process. See #14150.
    
    In addition to this, FreeConsole must only be called from interactive processes (#13411).
    
    This commit makes two changes to fix this situation:
    
    1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole`
       if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi.
    2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather
       than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`:
    
       Before:
       ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe
    
       After:
       ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe
    
    - - - - -
    79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00
    docs: Fix documentation of \cases
    
    Fixes #21902.
    
    - - - - -
    e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00
    ghc-cabal: allow Cabal 3.8 to unbreak make build
    
    When bootstrapping GHC 9.4.*, the build will fail when configuring
    ghc-cabal as part of the make based build system due to this upper
    bound, as Cabal has been updated to a 3.8 release.
    
    Reference #21914, see especially
    https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699
    
    - - - - -
    726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
    Fix isEvaldUnfolding and isValueUnfolding
    
    This fixes (1) in #21831.  Easy, obviously correct.
    
    - - - - -
    5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
    Switch off eta-expansion in rules and unfoldings
    
    I think this change will make little difference except to reduce
    clutter.  But that's it -- if it causes problems we can switch it
    on again.
    
    - - - - -
    d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
    Teach SpecConstr about typeDeterminesValue
    
    This patch addresses #21831, point 2.  See
    Note [generaliseDictPats] in SpecConstr
    
    I took the opportunity to refactor the construction of specialisation
    rules a bit, so that the rule name says what type we are specialising
    at.
    
    Surprisingly, there's a 20% decrease in compile time for test
    perf/compiler/T18223. I took a look at it, and the code size seems the
    same throughout. I did a quick ticky profile which seemed to show a
    bit less substitution going on.  Hmm.  Maybe it's the "don't do
    eta-expansion in stable unfoldings" patch, which is part of the
    same MR as this patch.
    
    Anyway, since it's a move in the right direction, I didn't think it
    was worth looking into further.
    
    Metric Decrease:
        T18223
    
    - - - - -
    65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
    Add a 'notes' file in testsuite/tests/perf/compiler
    
    This file is just a place to accumlate notes about particular
    benchmarks, so that I don't keep re-inventing the wheel.
    
    - - - - -
    61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00
    Get the in-scope set right in FamInstEnv.injectiveBranches
    
    There was an assert error, as Gergo pointed out in #21896.
    
    I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs.
    And also to GHC.Core.Unify.niFixTCvSubst.
    
    I also took the opportunity to get a couple more InScopeSets right,
    and to change some substTyUnchecked into substTy.
    
    This MR touches a lot of other files, but only because I also took the
    opportunity to introduce mkInScopeSetList, and use it.
    
    - - - - -
    4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00
    Add location to cc phase
    
    - - - - -
    96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00
    Avoid as pipeline when compiling c
    
    - - - - -
    2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00
    testsuite: Skip test cases involving -S when testing unregisterised GHC
    
    We no longer generate .s files anyway.
    
    Metric Decrease:
        MultiLayerModules
        T10421
        T13035
        T13701
        T14697
        T16875
        T18140
        T18304
        T18923
        T9198
    
    - - - - -
    82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00
    testsuite: introduce nonmoving_thread_sanity way
    
    (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae)
    
    - - - - -
    4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00
    rts/nonmoving: Track segment state
    
    It can often be useful during debugging to be able to determine the
    state of a nonmoving segment. Introduce some state, enabled by DEBUG, to
    track this.
    
    (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f)
    
    - - - - -
    54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00
    rts/nonmoving: Don't scavenge objects which weren't evacuated
    
    This fixes a rather subtle bug in the logic responsible for scavenging
    objects evacuated to the non-moving generation. In particular, objects
    can be allocated into the non-moving generation by two ways:
    
     a. evacuation out of from-space by the garbage collector
     b. direct allocation by the mutator
    
    Like all evacuation, objects moved by (a) must be scavenged, since they
    may contain references to other objects located in from-space. To
    accomplish this we have the following scheme:
    
     * each nonmoving segment's block descriptor has a scan pointer which
       points to the first object which has yet to be scavenged
    
     * the GC tracks a set of "todo" segments which have pending scavenging
       work
    
     * to scavenge a segment, we scavenge each of the unmarked blocks
       between the scan pointer and segment's `next_free` pointer.
    
       We skip marked blocks since we know the allocator wouldn't have
       allocated into marked blocks (since they contain presumably live
       data).
    
       We can stop at `next_free` since, by
       definition, the GC could not have evacuated any objects to blocks
       above `next_free` (otherwise `next_free wouldn't be the first free
       block).
    
    However, this neglected to consider objects allocated by path (b).
    In short, the problem is that objects directly allocated by the mutator
    may become unreachable (but not swept, since the containing segment is
    not yet full), at which point they may contain references to swept objects.
    Specifically, we observed this in #21885 in the following way:
    
    1. the mutator (specifically in #21885, a `lockCAF`) allocates an object
       (specifically a blackhole, which here we will call `blkh`; see Note
       [Static objects under the nonmoving collector] for the reason why) on
       the non-moving heap. The bitmap of the allocated block remains 0
       (since allocation doesn't affect the bitmap) and the containing
       segment's (which we will call `blkh_seg`) `next_free` is advanced.
    2. We enter the blackhole, evaluating the blackhole to produce a result
       (specificaly a cons cell) in the nursery
    3. The blackhole gets updated into an indirection pointing to the cons
       cell; it is pushed to the generational remembered set
    4. we perform a GC, the cons cell is evacuated into the nonmoving heap
       (into segment `cons_seg`)
    5. the cons cell is marked
    6. the GC concludes
    7. the CAF and blackhole become unreachable
    8. `cons_seg` is filled
    9. we start another GC; the cons cell is swept
    10. we start a new GC
    11. something is evacuated into `blkh_seg`, adding it to the "todo" list
    12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks
        between `scan` and `next_free`, which includes `blkh`). We attempt to
        evacuate `blkh`'s indirectee, which is the previously-swept cons cell.
        This is unsafe, since the indirectee is no longer a valid heap
        object.
    
    The problem here was that the scavenging logic *assumed* that (a) was
    the only source of allocations into the non-moving heap and therefore
    *all* unmarked blocks between `scan` and `next_free` were evacuated.
    However, due to (b) this is not true.
    
    The solution is to ensure that that the scanned region only encompasses
    the region of objects allocated during evacuation. We do this by
    updating `scan` as we push the segment to the todo-segment list to
    point to the block which was evacuated into.
    
    Doing this required changing the nonmoving scavenging implementation's
    update of the `scan` pointer to bump it *once*, instead of after
    scavenging each block as was done previously. This is because we may end
    up evacuating into the segment being scavenged as we scavenge it. This
    was quite tricky to discover but the result is quite simple,
    demonstrating yet again that global mutable state should be used
    exceedingly sparingly.
    
    Fixes #21885
    
    (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060)
    
    - - - - -
    25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00
    testsuite: Skip a few tests as in the nonmoving collector
    
    Residency monitoring under the non-moving collector is quite
    conservative (e.g. the reported value is larger than reality) since
    otherwise we would need to block on concurrent collection. Skip a few
    tests that are sensitive to residency.
    
    (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70)
    
    - - - - -
    42147534 by sternenseemann at 2022-07-26T16:26:53-04:00
    hadrian: add flag disabling selftest rules which require QuickCheck
    
    The hadrian executable depends on QuickCheck for building, meaning this
    library (and its dependencies) will need to be built for bootstrapping
    GHC in the future. Building QuickCheck, however, can require
    TemplateHaskell. When building a statically linking GHC toolchain,
    TemplateHaskell can be tricky to get to work, and cross-compiling
    TemplateHaskell doesn't work at all without -fexternal-interpreter,
    so QuickCheck introduces an element of fragility to GHC's bootstrap.
    
    Since the selftest rules are the only part of hadrian that need
    QuickCheck, we can easily eliminate this bootstrap dependency when
    required by introducing a `selftest` flag guarding the rules' inclusion.
    
    Closes #8699.
    
    - - - - -
    9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00
    Regression test for #21848
    
    - - - - -
    ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00
    driver: Don't create LinkNodes when -no-link is enabled
    
    Fixes #21866
    
    - - - - -
    fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00
    Docs: fix mistaken claim about kind signatures
    
    This patch fixes #21806 by rectifying an incorrect claim about
    the usage of kind variables in the header of a data declaration with
    a standalone kind signature.
    
    It also adds some clarifications about the number of parameters expected
    in GADT declarations and in type family declarations.
    
    - - - - -
    2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00
    testsuite: Correctly set withNativeCodeGen
    
    Fixes #21918
    
    - - - - -
    f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00
    Fix since annotations in GHC.Stack.CloneStack
    
    Fixes #21894
    
    - - - - -
    aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00
    Add -dsuppress-coercion-types to make coercions even smaller.
    
    Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)``
    simply print `` `cast` <Co:11> :: ... ``
    
    - - - - -
    97655ad8 by sheaf at 2022-08-02T19:27:29-04:00
    User's guide: fix typo in hasfield.rst
    
    Fixes #21950
    
    - - - - -
    35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00
    Remove TCvSubst and use Subst for both term and type-level subst
    
    This patch removes the TCvSubst data type and instead uses Subst as
    the environment for both term and type level substitution. This
    change is partially motivated by the existential type proposal,
    which will introduce types that contain expressions and therefore
    forces us to carry around an "IdSubstEnv" even when substituting for
    types. It also reduces the amount of code because "Subst" and
    "TCvSubst" share a lot of common operations. There isn't any
    noticeable impact on performance (geo. mean for ghc/alloc is around
    0.0% but we have -94 loc and one less data type to worry abount).
    
    Currently, the "TCvSubst" data type for substitution on types is
    identical to the "Subst" data type except the former doesn't store
    "IdSubstEnv". Using "Subst" for type-level substitution means there
    will be a redundant field stored in the data type. However, in cases
    where the substitution starts from the expression, using "Subst" for
    type-level substitution saves us from having to project "Subst" into a
    "TCvSubst". This probably explains why the allocation is mostly even
    despite the redundant field.
    
    The patch deletes "TCvSubst" and moves "Subst" and its relevant
    functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst".
    Substitution on expressions is still defined in "GHC.Core.Subst" so we
    don't have to expose the definition of "Expr" in the hs-boot file that
    "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose
    codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed
    into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a
    distinct function from "isEmptySubst"; the former ignores the
    emptiness of "IdSubstEnv"). These exceptions mainly exist for
    performance reasons and will go away when "Expr" and "Type" are
    mutually recursively defined (we won't be able to take those
    shortcuts if we can't make the assumption that expressions don't
    appear in types).
    
    - - - - -
    b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00
    Fix TH + defer-type-errors interaction (#21920)
    
    Previously, we had to disable defer-type-errors in splices because of #7276.
    But this fix is no longer necessary, the test T7276 no longer segfaults
    and is now correctly deferred.
    
    - - - - -
    fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00
    Add a note about about W/W for unlifting strict arguments
    
    This fixes #21236.
    
    - - - - -
    fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00
    Force safeInferred to avoid retaining extra copy of DynFlags
    
    This will only have a (very) modest impact on memory but we don't want
    to retain old copies of DynFlags hanging around so best to force this
    value.
    
    - - - - -
    0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00
    Force name selectors to ensure no reference to Ids enter the NameCache
    
    I observed some unforced thunks in the NameCache which were retaining a
    whole Id, which ends up retaining a Type.. which ends up retaining old
    copies of HscEnv containing stale HomeModInfo.
    
    - - - - -
    0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00
    Fix leaks in --make mode when there are module loops
    
    This patch fixes quite a tricky leak where we would end up retaining
    stale ModDetails due to rehydrating modules against non-finalised
    interfaces.
    
    == Loops with multiple boot files
    
    It is possible for a module graph to have a loop (SCC, when ignoring boot files)
    which requires multiple boot files to break. In this case we must perform the
    necessary hydration steps before and after compiling modules which have boot files
    which are described above for corectness but also perform an additional hydration step
    at the end of the SCC to remove space leaks.
    
    Consider the following example:
    
    ┌───────┐   ┌───────┐
    │       │   │       │
    │   A   │   │   B   │
    │       │   │       │
    └─────┬─┘   └───┬───┘
          │         │
     ┌────▼─────────▼──┐
     │                 │
     │        C        │
     └────┬─────────┬──┘
          │         │
     ┌────▼──┐  ┌───▼───┐
     │       │  │       │
     │ A-boot│  │ B-boot│
     │       │  │       │
     └───────┘  └───────┘
    
     A, B and C live together in a SCC. Say we compile the modules in order
     A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps
     (because A has a boot file). Therefore C will be hydrated relative to A, and the
     ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again,
     and so B will reference C/A,B, its interface will be hydrated relative to both A and B.
     Now there is a space leak because say C is a very big module, there are now two different copies of
     ModDetails kept alive by modules A and B.
    
    The way to avoid this space leak is to rehydrate an entire SCC together at the
    end of compilation so that all the ModDetails point to interfaces for .hs files.
    In this example, when we hydrate A, B and C together then both A and B will refer to
    C/A,B.
    
    See #21900 for some more discussion.
    
    -------------------------------------------------------
    
    In addition to this simple case, there is also the potential for a leak
    during parallel upsweep which is also fixed by this patch. Transcibed is
    Note [ModuleNameSet, efficiency and space leaks]
    
    Note [ModuleNameSet, efficiency and space leaks]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    During unsweep the results of compiling modules are placed into a MVar, to find
    the environment the module needs to compile itself in the MVar is consulted and
    the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking
    module dependencies and recreating the HUG from scratch each time is very expensive.
    
    In serial mode (-j1), this all works out fine because a module can only be compiled after
    its dependencies have finished compiling and not interleaved with compiling module loops.
    Therefore when we create the finalised or no loop interfaces, the HUG only contains
    finalised interfaces.
    
    In parallel mode, we have to be more careful because the HUG variable can contain
    non-finalised interfaces which have been started by another thread. In order to avoid
    a space leak where a finalised interface is compiled against a HPT which contains a
    non-finalised interface we have to restrict the HUG to only the visible modules.
    
    The visible modules is recording in the ModuleNameSet, this is propagated upwards
    whilst compiling and explains which transitive modules are visible from a certain point.
    This set is then used to restrict the HUG before the module is compiled to only
    the visible modules and thus avoiding this tricky space leak.
    
    Efficiency of the ModuleNameSet is of utmost importance because a union occurs for
    each edge in the module graph. Therefore the set is represented directly as an IntSet
    which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is
    too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode.
    
    See test "jspace" for an example which used to trigger this problem.
    
    Fixes #21900
    
    - - - - -
    1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00
    Store interfaces in ModIfaceCache more directly
    
    I realised hydration was completely irrelavant for this cache because
    the ModDetails are pruned from the result. So now it simplifies things a
    lot to just store the ModIface and Linkable, which we can put into the
    cache straight away rather than wait for the final version of a
    HomeModInfo to appear.
    
    - - - - -
    6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00
    cmm: Remove unused ReadOnlyData16
    
    We don't actually emit rodata16 sections anywhere.
    
    - - - - -
    16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00
    findExternalRules: Don't needlessly traverse the list of rules.
    
    - - - - -
    52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00
    Remove backported items from 9.6 release notes
    
    They have been backported to 9.4 in commits 5423d84bd9a28f,
    13c81cb6be95c5, 67ccbd6b2d4b9b.
    
    - - - - -
    78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00
    ci: Fix pages job
    
    The job has been failing because we don't bundle haddock docs anymore in
    the docs dist created by hadrian.
    
    Fixes #21789
    
    - - - - -
    037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00
    codeGen/X86: Don't clobber switch variable in switch generation
    
    Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was
    safe to clobber the switch variable when generating code for a jump
    table since we were at the end of a block. However, this assumption is
    wrong; the register could be live in the jump target.
    
    Fixes #21968.
    
    - - - - -
    50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00
    Fix equality operator in jspace test
    
    - - - - -
    e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    Improve BUILD_PAP comments
    
    - - - - -
    41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    Make dropTail comment a haddock comment
    
    - - - - -
    ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    Add one more sanity check in stg_restore_cccs
    
    - - - - -
    1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    StgToCmm: Fix isSimpleScrut when profiling is enabled.
    
    When profiling is enabled we must enter functions that might represent
    thunks in order for their sccs to show up in the profile.
    
    We might allocate even if the function is already evaluated in this
    case. So we can't consider any potential function thunk to be a simple
    scrut when profiling.
    
    Not doing so caused profiled binaries to segfault.
    
    - - - - -
    fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
    Change `-fprof-late` to insert cost centres after unfolding creation.
    
    The former behaviour of adding cost centres after optimization but
    before unfoldings are created is not available via the flag
    `prof-late-inline` instead.
    
    I also reduced the overhead of -fprof-late* by pushing the cost centres
    into lambdas. This means the cost centres will only account for
    execution of functions and not their partial application.
    
    Further I made LATE_CC cost centres it's own CC flavour so they now
    won't clash with user defined ones if a user uses the same string for
    a custom scc.
    
    LateCC: Don't put cost centres inside constructor workers.
    
    With -fprof-late they are rarely useful as the worker is usually
    inlined. Even if the worker is not inlined or we use -fprof-late-linline
    they are generally not helpful but bloat compile and run time
    significantly. So we just don't add sccs inside constructor workers.
    
    -------------------------
    Metric Decrease:
        T13701
    -------------------------
    
    - - - - -
    f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00
    gitlab-ci: Fix hadrian bootstrapping of release pipelines
    
    Previously we would attempt to test hadrian bootstrapping in the
    `validate` build flavour. However, `ci.sh` refuses to run validation
    builds during release pipelines, resulting in job failures. Fix this by
    testing bootstrapping in the `release` flavour during release pipelines.
    
    We also attempted to record perf notes for these builds, which is
    redundant work and undesirable now since we no longer build in a
    consistent flavour.
    
    - - - - -
    c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00
    compiler: Eliminate two uses of foldr in favor of foldl'
    
    These two uses constructed maps, which is a case where foldl' is
    generally more efficient since we avoid constructing an intermediate
    O(n)-depth stack.
    
    - - - - -
    d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00
    rts: Fix code style
    
    - - - - -
    57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00
    genprimopcode: Drop ArrayArray# references
    
    As ArrayArray# no longer exists
    
    - - - - -
    7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00
    base: Organize Haddocks in GHC.Conc.Sync
    
    - - - - -
    aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00
    Add primop to list threads
    
    A user came to #ghc yesterday wondering how best to check whether they
    were leaking threads. We ended up using the eventlog but it seems to me
    like it would be generally useful if Haskell programs could query their
    own threads.
    
    - - - - -
    6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00
    rts: Move thread labels into TSO
    
    This eliminates the thread label HashTable and instead tracks this
    information in the TSO, allowing us to use proper StgArrBytes arrays for
    backing the label and greatly simplifying management of object lifetimes
    when we expose them to the user with the coming `threadLabel#` primop.
    
    - - - - -
    1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00
    Add a primop to query the label of a thread
    
    - - - - -
    43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00
    base: Share finalization thread label
    
    For efficiency's sake we float the thread label assigned to the
    finalization thread to the top-level, ensuring that we only need to
    encode the label once.
    
    - - - - -
    1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00
    users-guide: Add release notes entry for thread introspection support
    
    - - - - -
    09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00
    hadrian: Fix binary distribution install attributes
    
    Previously we would use plain `cp` to install various parts of the
    binary distribution. However, `cp`'s behavior w.r.t. file attributes is
    quite unclear; for this reason it is much better to rather use
    `install`.
    
    Fixes #21965.
    
    - - - - -
    2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00
    hadrian: Fix installation of system-cxx-std-lib package conf
    
    - - - - -
    7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00
    gitlab-ci: Bump Docker images
    
    To give the ARMv7 job access to lld, fixing #21875.
    
    - - - - -
    afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00
    hadrian: Don't use mk/config.mk.in
    
    Ultimately we want to drop mk/config.mk so here I extract the bits
    needed by the Hadrian bindist installation logic into a Hadrian-specific
    file. While doing this I fixed binary distribution installation, #21901.
    
    - - - - -
    b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00
    hadrian: Fix naming of cross-compiler wrappers
    
    - - - - -
    78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00
    hadrian: Extend xattr Darwin hack to cover /lib
    
    As noted in #21506, it is now necessary to remove extended attributes
    from `/lib` as well as `/bin` to avoid SIP issues on Darwin.
    
    Fixes #21506.
    
    - - - - -
    20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00
    NCG(x86): Compile add+shift as lea if possible.
    
    - - - - -
    742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00
    dataToTag#: Skip runtime tag check if argument is infered tagged
    
    This addresses one part of #21710.
    
    - - - - -
    1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00
    rts: remove redundant stg_traceCcszh
    
    This out-of-line primop has no Haskell wrapper and hasn't been used
    anywhere in the tree. Furthermore, the code gets in the way of !7632, so
    it should be garbage collected.
    
    - - - - -
    a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00
    Document a divergence from the report in parsing function lhss.
    
    GHC is happy to parse `(f) x y = x + y` when it should be a parse error
    based on the Haskell report. Seems harmless enough so we won't fix it
    but it's documented now.
    
    Fixes #19788
    
    - - - - -
    5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00
    gitlab-ci: Add release job for aarch64/debian 11
    
    - - - - -
    5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00
    gitlab-ci: Introduce validation job for aarch64 cross-compilation
    
    Begins to address #11958.
    
    - - - - -
    e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00
    Bump process submodule
    
    - - - - -
    ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00
    gitlab-ci: Add basic support for cross-compiler testiing
    
    Here we add a simple qemu-based test for cross-compilers.
    
    - - - - -
    50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00
    rts: Ensure that Array# card arrays are initialized
    
    In #19143 I noticed that newArray# failed to initialize the card table
    of newly-allocated arrays. However, embarrassingly, I then only fixed
    the issue in newArrayArray# and, in so doing, introduced the potential
    for an integer underflow on zero-length arrays (#21962).
    
    Here I fix the issue in newArray#, this time ensuring that we do not
    underflow in pathological cases.
    
    Fixes #19143.
    
    - - - - -
    e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00
    testsuite: Add test for #21962
    
    - - - - -
    c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00
    gitlab-ci: Don't use coreutils on Darwin
    
    In general we want to ensure that the tested environment is as similar
    as possible to the environment the user will use. In the case of Darwin,
    this means we want to use the system's BSD command-line utilities, not
    coreutils.
    
    This would have caught #21974.
    
    - - - - -
    1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00
    hadrian: Fix bindist installation on Darwin
    
    It turns out that `cp -P` on Darwin does not always copy a symlink as
    a symlink. In order to get these semantics one must pass `-RP`. It's not
    entirely clear whether this is valid under POSIX, but it is nevertheless
    what Apple does.
    
    - - - - -
    681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00
    hadrian: Fix access mode of installed package registration files
    
    Previously hadrian's bindist Makefile would modify package
    registrations placed by `install` via a shell pipeline and `mv`.
    However, the use of `mv` means that if umask is set then the user may
    otherwise end up with package registrations which are inaccessible.
    Fix this by ensuring that the mode is 0644.
    
    - - - - -
    e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00
    Cleanups around pretty-printing
    
    * Remove hack when printing OccNames. No longer needed since e3dcc0d5
    * Remove unused `pprCmms` and `instance Outputable Instr`
    * Simplify `pprCLabel` (no need to pass platform)
    * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by
      ImmLit, but that can take just a String instead.
    * Remove instance `Outputable CLabel` - proper output of labels
      needs a platform, and is done by the `OutputableP` instance
    
    - - - - -
    66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00
    rts/linker: Resolve iconv_* on FreeBSD
    
    FreeBSD's libiconv includes an implementation of the
    iconv_* functions in libc. Unfortunately these can
    only be resolved using dlvsym, which is how the RTS linker
    usually resolves such functions. To fix this we include an ad-hoc
    special case for iconv_*.
    
    Fixes #20354.
    
    - - - - -
    5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00
    system-cxx-std-lib: Add support for FreeBSD libcxxrt
    
    - - - - -
    ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00
    gitlab-ci: Bump to use freebsd13 runners
    
    - - - - -
    d71a2051 by sheaf at 2022-08-09T13:47:28-04:00
    Fix size_up_alloc to account for UnliftedDatatypes
    
    The size_up_alloc function mistakenly considered any type that isn't
    lifted to not allocate anything, which is wrong. What we want instead
    is to check the type isn't boxed. This accounts for (BoxedRep Unlifted).
    
    Fixes #21939
    
    - - - - -
    76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00
    testsuite: 21651 add test for closeFdWith + setNumCapabilities
    
    This bug does not affect windows, which does not use the
    base module GHC.Event.Thread.
    
    - - - - -
    7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00
    base: Fix races in IOManager (setNumCapabilities,closeFdWith)
    
    Fix for #21651
    
    Fixes three bugs:
    
    - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith.
    - The race in closeFdWith described in the ticket.
    - A race in getSystemEventManager where it accesses the 'IOArray' in
      'eventManager' before 'ioManagerCapabilitiesChanged' has written to
      'eventManager', causing an Array Index exception. The fix here is to
      'yield' and retry.
    
    - - - - -
    dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00
    Updates language extension documentation
    
    Adding a 'Status' field with a few values:
    - Deprecated
    - Experimental
    - InternalUseOnly
    - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98'
    
    Those values are pulled from the existing descriptions or elsewhere in
    the documentation.
    
    While at it, include the :implied by: where appropriate, to provide
    more detail.
    
    Fixes #21475
    
    - - - - -
    823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00
    hadrian RunRest: add type signature for stageNumber
    
    avoids warning seen on 9.4.1:
    
    src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults]
        • Defaulting the following constraints to type ‘Integer’
            (Show a0)
              arising from a use of ‘show’
              at src/Settings/Builders/RunTest.hs:264:53-84
            (Num a0)
              arising from a use of ‘stageNumber’
              at src/Settings/Builders/RunTest.hs:264:59-83
        • In the second argument of ‘(++)’, namely
            ‘show (stageNumber (C.stage ctx))’
          In the second argument of ‘($)’, namely
            ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’
          In the expression:
            arg $ "config.stage=" ++ show (stageNumber (C.stage ctx))
        |
    264 |             , arg "-e", arg $ "config.stage="    ++ show (stageNumber (C.stage ctx))
        |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    compilation tested locally
    
    - - - - -
    f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00
    Add support for external static plugins (#20964)
    
    This patch adds a new command-line flag:
    
      -fplugin-library=<file-path>;<unit-id>;<module>;<args>
    
    used like this:
    
      -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"]
    
    It allows a plugin to be loaded directly from a shared library. With
    this approach, GHC doesn't compile anything for the plugin and doesn't
    load any .hi file for the plugin and its dependencies. As such GHC
    doesn't need to support two environments (one for plugins, one for
    target code), which was the more ambitious approach tracked in #14335.
    
    Fix #20964
    
    Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com>
    
    - - - - -
    5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00
    gitlab-ci: Fix ARMv7 build
    
    It appears that the CI refactoring carried out in
    5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some
    critical configuration: setting the build/host/target platforms and
    forcing use of a non-broken linker.
    
    - - - - -
    596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00
    gitlab-ci: Run ARMv7 jobs when ~ARM label is used
    
    - - - - -
    7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00
    hadrian: Don't attempt to install documentation if doc/ doesn't exist
    
    Previously we would attempt to install documentation even if the `doc`
    directory doesn't exist (e.g. due to `--docs=none`). This would result
    in the surprising side-effect of the entire contents of the bindist
    being installed in the destination documentation directory. Fix this.
    
    Fixes #21976.
    
    - - - - -
    67575f20 by normalcoder at 2022-08-10T15:38:34-04:00
    ncg/aarch64: Don't use x18 register on AArch64/Darwin
    
    Apple's ABI documentation [1] says: "The platforms reserve register x18.
    Don’t use this register." While this wasn't problematic in previous
    Darwin releases, macOS 13 appears to start zeroing this register
    periodically. See #21964.
    
    [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
    
    - - - - -
    45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00
    Note [Trimming auto-rules]: State that this improves compiler perf.
    
    - - - - -
    5c24b1b3 by Andrew Lelechenko at 2022-08-10T22:41:50-04:00
    Document that threadDelay / timeout are susceptible to overflows on 32-bit machines
    
    - - - - -
    ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00
    EPA: DotFieldOcc does not have exact print annotations
    
    For the code
    
        {-# LANGUAGE OverloadedRecordUpdate #-}
    
        operatorUpdate f = f{(+) = 1}
    
    There are no exact print annotations for the parens around the +
    symbol, nor does normal ppr print them.
    
    This MR fixes that.
    
    Closes #21805
    
    Updates haddock submodule
    
    - - - - -
    dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00
    Revert "gitlab-ci: Add release job for aarch64/debian 11"
    
    This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46.
    
    The job was not tested before being merged and fails CI
    (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392)
    
    Ticket #22005
    
    - - - - -
    ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00
    typo
    - - - - -
    cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00
    CmmToLlvm: Don't aliasify builtin LLVM variables
    
    Our aliasification logic would previously turn builtin LLVM variables
    into aliases, which apparently confuses LLVM. This manifested in
    initializers failing to be emitted, resulting in many profiling failures
    with the LLVM backend.
    
    Fixes #22019.
    
    - - - - -
    dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00
    run_ci: remove monoidal-containers
    
    Fixes #21492
    
    MonoidalMap is inlined and used to implement Variables, as before.
    
    The top-level value "jobs" is reimplemented as a regular Map, since it
    doesn't use the monoidal union anyway.
    
    - - - - -
    64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00
    CmmToAsm/AArch64: correct a typo
    
    - - - - -
    f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00
    Fix #21979 - compact-share failing with -O
    
    I don't have good reason to believe the optimization level should affect
    if sharing works or not here. So limit the test to the normal way.
    
    - - - - -
    68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00
    users-guide: Fix reference to dead llvm-version substitution
    
    Fixes #22052.
    
    - - - - -
    28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00
    users-guide: Fix incorrect reference to `:extension: role
    
    - - - - -
    71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00
    users-guide: Add :ghc-flag: reference
    
    - - - - -
    385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00
    hadrian: Place manpage in docroot
    
    This relocates it from docs/ to doc/
    
    - - - - -
    84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00
    Bump haddock submodule
    
    Includes merge of `main` into `ghc-head` as well as some Haddock users
    guide fixes.
    
    - - - - -
    59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00
    base: Add changelog entries from ghc-9.2
    
    Closes #21922.
    
    - - - - -
    a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00
    relnotes: Add "included libraries" section
    
    As noted in #21988, some users rely on this.
    
    - - - - -
    a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00
    users-guide: Rephrase the rewrite rule documentation
    
    Previously the wording was a tad unclear. Fix this.
    
    Closes #21114.
    
    - - - - -
    3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00
    Implement Response File support for HPC
    
    This is an improvement to HPC authored by Richard Wallace
    (https://github.com/purefn) and myself. I have received permission from
    him to attempt to upstream it. This improvement was originally
    implemented as a patch to HPC via input-output-hk/haskell.nix:
    https://github.com/input-output-hk/haskell.nix/pull/1464
    
    Paraphrasing Richard, HPC currently requires all inputs as command line arguments.
    With large projects this can result in an argument list too long error.
    I have only seen this error in Nix, but I assume it can occur is a plain Unix environment.
    
    This MR adds the standard response file syntax support to HPC. For
    example you can now pass a file to the command line which contains the
    arguments.
    
    ```
    hpc @response_file_1 @response_file_2 ...
    
    The contents of a Response File must have this format:
    COMMAND ...
    
    example:
    report my_library.tix --include=ModuleA --include=ModuleB
    ```
    
    Updates hpc submodule
    
    Co-authored-by:  Richard Wallace <rwallace at thewallacepack.net>
    
    Fixes #22050
    
    - - - - -
    436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00
    ghc-heap: Fix decoding of TSO closures
    
    An extra field was added to the TSO structure in 6d1700b6 but the
    decoding logic in ghc-heap was not updated for this new field.
    
    Fixes #22046
    
    - - - - -
    a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00
    driver: Honour -x option
    
    The -x option is used to manually specify which phase a file should be
    started to be compiled from (even if it lacks the correct extension). I
    just failed to implement this when refactoring the driver.
    
    In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to
    preprocess source files using GHC.
    
    I added a test to exercise this case.
    
    Fixes #22044
    
    - - - - -
    e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00
    Be more careful in chooseInferredQuantifiers
    
    This fixes #22065. We were failing to retain a quantifier that
    was mentioned in the kind of another retained quantifier.
    
    Easy to fix.
    
    - - - - -
    714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00
    testsuite: Add test for #21583
    
    - - - - -
    989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00
    compiler: Drop --build-id=none hack
    
    Since 2011 the object-joining implementation has had a hack to pass
    `--build-id=none` to `ld` when supported, seemingly to work around a
    linker bug. This hack is now unnecessary and may break downstream users
    who expect objects to have valid build-ids. Remove it.
    
    Closes #22060.
    
    - - - - -
    519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00
    Make ru_fn field strict to avoid retaining Ids
    
    It's better to perform this projection from Id to Name strictly so we
    don't retain an old Id (hence IdInfo, hence Unfolding, hence everything
    etc)
    
    - - - - -
    7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00
    Force `getOccFS bndr` to avoid retaining reference to Bndr.
    
    This is another symptom of #19619
    
    - - - - -
    4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00
    Force unfoldings when they are cleaned-up in Tidy and CorePrep
    
    If these thunks are not forced then the entire unfolding for the binding
    is live throughout the whole of CodeGen despite the fact it should have
    been discarded.
    
    Fixes #22071
    
    - - - - -
    2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00
    haddock docs: Fix links from identifiers to dependent packages
    
    When implementing the base_url changes I made the pretty bad mistake of
    zipping together two lists which were in different orders. The simpler
    thing to do is just modify `haddockDependencies` to also return the
    package identifier so that everything stays in sync.
    
    Fixes #22001
    
    - - - - -
    9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00
    Revert "Refactor SpecConstr to use treat bindings uniformly"
    
    This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729.
    
    This refactoring introduced quite a severe residency regression (900MB
    live from 650MB live when compiling mmark), see #21993 for a reproducer
    and more discussion.
    
    Ticket #21993
    
    - - - - -
    9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00
    tc: warn about lazy annotations on unlifted arguments (fixes #21951)
    
    - - - - -
    e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00
    Fix #22048 where we failed to drop rules for -fomit-interface-pragmas.
    
    Now we also filter the local rules (again) which fixes the issue.
    
    - - - - -
    51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00
    Print constraints in quotes (#21167)
    
    This patch improves the uniformity of error message formatting by
    printing constraints in quotes, as we do for types.
    
    Fix #21167
    
    - - - - -
    ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00
    19217 Implicitly quantify type variables in :kind command
    
    - - - - -
    9939e95f by MorrowM at 2022-08-21T16:51:38-04:00
    Recognize file-header pragmas in GHCi (#21507)
    
    - - - - -
    fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00
    hadrian: Fix bootstrapping with ghc-9.4
    
    The error was that we were trying to link together
    
        containers from boot package library (which depends template-haskell in boot package library)
        template-haskell from in-tree package database
    
    So the fix is to build containers in stage0 (and link against template-haskell built in stage0).
    
    Fixes #21981
    
    - - - - -
    b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00
    Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942.
    
    * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization
    * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence
    * `ParensT` constructor is now always printed parenthesized
    * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down
    * using `>=` instead of former `>` to match the Core type printing logic
    * some test outputs have changed, losing extraneous parentheses
    
    - - - - -
    fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00
    Fix and test for issue #21723
    
    - - - - -
    33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00
    Test for issue #21942
    
    - - - - -
    c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00
    Updated the changelog
    
    - - - - -
    80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00
    hadrian: Don't duplicate binaries on installation
    
    Previously we used `install` on symbolic links, which ended up
    copying the target file rather than installing a symbolic link.
    
    Fixes #22062.
    
    - - - - -
    b929063e by Matthew Farkas-Dyck at 2022-08-24T02:37:01-04:00
    Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`.
    
    Closes #22092.
    
    - - - - -
    112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00
    driver: don't actually merge objects when ar -L works
    
    - - - - -
    a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00
    rts: Consistently use MiB in stats output
    
    Previously we would say `MB` even where we
    meant `MiB`.
    - - - - -
    a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00
    Fix arityType: -fpedantic-bottoms, join points, etc
    
    This MR fixes #21694, #21755.  It also makes sure that #21948 and
    fix to #21694.
    
    * For #21694 the underlying problem was that we were calling arityType
      on an expression that had free join points.  This is a Bad Bad Idea.
      See Note [No free join points in arityType].
    
    * To make "no free join points in arityType" work out I had to avoid
      trying to use eta-expansion for runRW#. This entailed a few changes
      in the Simplifier's treatment of runRW#.  See
      GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#]
    
    * I also made andArityType work correctly with -fpedantic-bottoms;
      see Note [Combining case branches: andWithTail].
    
    * Rewrote Note [Combining case branches: optimistic one-shot-ness]
    
    * arityType previously treated join points differently to other
      let-bindings. This patch makes them unform; arityType analyses
      the RHS of all bindings to get its ArityType, and extends am_sigs.
    
      I realised that, now we have am_sigs giving the ArityType for
      let-bound Ids, we don't need the (pre-dating) special code in
      arityType for join points. But instead we need to extend the env for
      Rec bindings, which weren't doing before.  More uniform now.  See
      Note [arityType for let-bindings].
    
      This meant we could get rid of ae_joins, and in fact get rid of
      EtaExpandArity altogether.  Simpler.
    
    * And finally, it was the strange treatment of join-point Ids in
      arityType (involving a fake ABot type) that led to a serious bug:
      #21755.  Fixed by this refactoring, which treats them uniformly;
      but without breaking #18328.
    
      In fact, the arity for recursive join bindings is pretty tricky;
      see the long Note [Arity for recursive join bindings]
      in GHC.Core.Opt.Simplify.Utils.  That led to more refactoring,
      including deciding that an Id could have an Arity that is bigger
      than its JoinArity; see Note [Invariants on join points], item
      2(b) in GHC.Core
    
    * Make sure that the "demand threshold" for join points in DmdAnal
      is no bigger than the join-arity.  In GHC.Core.Opt.DmdAnal see
      Note [Demand signatures are computed for a threshold arity based on idArity]
    
    * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity,
      where it more properly belongs.
    
    * Remove an old, redundant hack in FloatOut.  The old Note was
      Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels.
    
    Compile time improves very slightly on average:
    
    Metrics: compile_time/bytes allocated
    ---------------------------------------------------------------------------------------
      T18223(normal) ghc/alloc    725,808,720    747,839,216  +3.0%  BAD
      T6048(optasm)  ghc/alloc    105,006,104    101,599,472  -3.2% GOOD
      geo. mean                                          -0.2%
      minimum                                            -3.2%
      maximum                                            +3.0%
    
    For some reason Windows was better
    
       T10421(normal) ghc/alloc    125,888,360    124,129,168  -1.4% GOOD
       T18140(normal) ghc/alloc     85,974,520     83,884,224  -2.4% GOOD
      T18698b(normal) ghc/alloc    236,764,568    234,077,288  -1.1% GOOD
       T18923(normal) ghc/alloc     75,660,528     73,994,512  -2.2% GOOD
        T6048(optasm) ghc/alloc    112,232,512    108,182,520  -3.6% GOOD
      geo. mean                                          -0.6%
    
    I had a quick look at T18223 but it is knee deep in coercions and
    the size of everything looks similar before and after.  I decided
    to accept that 3% increase in exchange for goodness elsewhere.
    
    Metric Decrease:
        T10421
        T18140
        T18698b
        T18923
        T6048
    
    Metric Increase:
        T18223
    
    - - - - -
    909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00
    upload_ghc_libs: Add means of passing Hackage credentials
    
    - - - - -
    28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00
    Scrub some partiality in `CommonBlockElim`.
    
    - - - - -
    54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00
    hadrian: Fix whitespace
    
    Previously this region of Settings.Packages was incorrectly indented.
    
    - - - - -
    c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00
    validate: Drop --legacy flag
    
    In preparation for removal of the legacy `make`-based build system.
    
    - - - - -
    822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00
    gitlab-ci: Drop make build validation jobs
    
    In preparation for removal of the `make`-based build system
    
    - - - - -
    6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00
    Drop make build system
    
    Here we at long last remove the `make`-based build system, it having
    been replaced with the Shake-based Hadrian build system. Users are
    encouraged to refer to the documentation in `hadrian/doc` and this [1]
    blog post for details on using Hadrian.
    
    Closes #17527.
    
    [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html
    
    - - - - -
    dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00
    Remove testsuite/tests/perf/haddock/.gitignore
    
    As noted in #16802, this is no longer needed.
    
    Closes #16802.
    
    - - - - -
    fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00
    Drop hc-build script
    
    This has not worked for many, many years and relied on the now-removed
    `make`-based build system.
    
    - - - - -
    659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00
    Drop mkdirhier
    
    This is only used by nofib's dead `dist` target
    
    - - - - -
    4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00
    Drop mk/{build,install,config}.mk.in
    
    - - - - -
    46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00
    compiler: Drop comment references to make
    
    - - - - -
    d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00
    Add inits1 and tails1 to Data.List.NonEmpty
    
    See https://github.com/haskell/core-libraries-committee/issues/67
    
    - - - - -
    8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00
    Add since annotations and changelog entries
    
    - - - - -
    6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00
    Fix redundant import
    
    This fixes a build error on x86_64-linux-alpine3_12-validate.
    See the function 'loadExternalPlugins' defined in this file.
    
    - - - - -
    4786acf7 by sheaf at 2022-08-26T15:05:23-04:00
    Pmc: consider any 2 dicts of the same type equal
    
    This patch massages the keys used in the `TmOracle` `CoreMap` to ensure
    that dictionaries of coherent classes give the same key.
    That is, whenever we have an expression we want to insert or lookup in
    the `TmOracle` `CoreMap`, we first replace any dictionary
    `$dict_abcd :: ct` with a value of the form `error @ct`.
    
    This allows us to common-up view pattern functions with required
    constraints whose arguments differed only in the uniques of the
    dictionaries they were provided, thus fixing #21662.
    
    This is a rather ad-hoc change to the keys used in the
    `TmOracle` `CoreMap`. In the long run, we would probably want to use
    a different representation for the keys instead of simply using
    `CoreExpr` as-is. This more ambitious plan is outlined in #19272.
    
    Fixes #21662
    Updates unix submodule
    
    - - - - -
    f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00
    Remove label style from printing context
    
    Previously, the SDocContext used for code generation contained
    information whether the labels should use Asm or C style.
    However, at every individual call site, this is known statically.
    This removes the parameter to 'PprCode' and replaces every 'pdoc'
    used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'.
    The OutputableP instance is now used only for dumps.
    
    The output of T15155 changes, it now uses the Asm style
    (which is faithful to what actually happens).
    
    - - - - -
    1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00
    boot: cleanup legacy args
    
    Cleanup legacy boot script args, following removal of the legacy make
    build system.
    
    - - - - -
    95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00
    Improve SpecConstr for evals
    
    As #21763 showed, we were over-specialising in some cases, when
    the function involved was doing a simple 'eval', but not taking
    the value apart, or branching on it.
    
    This MR fixes the problem.  See Note [Do not specialise evals].
    
    Nofib barely budges, except that spectral/cichelli allocates about
    3% less.
    
    Compiler bytes-allocated improves a bit
       geo. mean                                          -0.1%
       minimum                                            -0.5%
       maximum                                            +0.0%
    
    The -0.5% is on T11303b, for what it's worth.
    
    - - - - -
    565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00
    Revert "Revert "Refactor SpecConstr to use treat bindings uniformly""
    
    This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8.
    
    This commit was originally reverted due to an increase in space usage.
    This was diagnosed as because the SCE increased in size and that was
    being retained by another leak. See #22102
    
    - - - - -
    82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00
    Avoid retaining bindings via ModGuts held on the stack
    
    It's better to overwrite the bindings fields of the ModGuts before
    starting an iteration as then all the old bindings can be collected as
    soon as the simplifier has processed them. Otherwise we end up with the
    old bindings being alive until right at the end of the simplifier pass
    as the mg_binds field is only modified right at the end.
    
    - - - - -
    64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00
    Force imposs_deflt_cons in filterAlts
    
    This fixes a pretty serious space leak as the forced thunk would retain
    `Alt b` values which would then contain reference to a lot of old
    bindings and other simplifier gunk.
    
    The OtherCon unfolding was not forced on subsequent simplifier runs so
    more and more old stuff would be retained until the end of
    simplification.
    
    Fixing this has a drastic effect on maximum residency for the mmark
    package which goes from
    
    ```
      45,005,401,056 bytes allocated in the heap
      17,227,721,856 bytes copied during GC
         818,281,720 bytes maximum residency (33 sample(s))
           9,659,144 bytes maximum slop
                2245 MiB total memory in use (0 MB lost due to fragmentation)
    ```
    
    to
    
    ```
      45,039,453,304 bytes allocated in the heap
      13,128,181,400 bytes copied during GC
         331,546,608 bytes maximum residency (40 sample(s))
           7,471,120 bytes maximum slop
                 916 MiB total memory in use (0 MB lost due to fragmentation)
    ```
    
    See #21993 for some more discussion.
    
    - - - - -
    a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00
    Use Solo to avoid retaining the SCE but to avoid performing the substitution
    
    The use of Solo here allows us to force the selection into the SCE to obtain
    the Subst but without forcing the substitution to be applied. The resulting thunk
    is placed into a lazy field which is rarely forced, so forcing it regresses
    peformance.
    
    - - - - -
    161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00
    Fix a nasty loop in Tidy
    
    As the remarkably-simple #22112 showed, we were making a black hole
    in the unfolding of a self-recursive binding.  Boo!
    
    It's a bit tricky.  Documented in GHC.Iface.Tidy,
       Note [tidyTopUnfolding: avoiding black holes]
    
    - - - - -
    68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00
    Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117)
    
    The following `TcRnDiagnostic` messages have been introduced:
    
    TcRnIllegalHsigDefaultMethods
    TcRnBadGenericMethod
    TcRnWarningMinimalDefIncomplete
    TcRnDefaultMethodForPragmaLacksBinding
    TcRnIgnoreSpecialisePragmaOnDefMethod
    TcRnBadMethodErr
    TcRnNoExplicitAssocTypeOrDefaultDeclaration
    
    - - - - -
    cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00
    Fix a bug in anyInRnEnvR
    
    This bug was a subtle error in anyInRnEnvR, introduced by
    
        commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06
        Author: Andreas Klebinger <klebinger.andreas at gmx.at>
        Date:   Sat Jul 9 01:19:52 2022 +0200
    
        Rule matching: Don't compute the FVs if we don't look at them.
    
    The net result was #22028, where a rewrite rule would wrongly
    match on a lambda.
    
    The fix to that function is easy.
    
    - - - - -
    0154bc80 by sheaf at 2022-08-30T06:05:41-04:00
    Various Hadrian bootstrapping fixes
    
      - Don't always produce a distribution archive (#21629)
      - Use correct executable names for ghc-pkg and hsc2hs on windows
        (we were missing the .exe file extension)
      - Fix a bug where we weren't using the right archive format on Windows
        when unpacking the bootstrap sources.
    
    Fixes #21629
    
    - - - - -
    451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00
    ci: Attempt using normal submodule cloning strategy
    
    We do not use any recursively cloned submodules, and this protects us
    from flaky upstream remotes.
    
    Fixes #22121
    
    - - - - -
    9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00
    Fix typo in Any docs: stray "--"
    
    - - - - -
    3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00
    Fix typo in Any docs: syntatic -> syntactic
    
    - - - - -
    7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00
    Add a missing trimArityType
    
    This buglet was exposed by #22114, a consequence of my earlier
    refactoring of arity for join points.
    
    - - - - -
    e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00
    Bump binary submodule to 0.8.9.1
    
    - - - - -
    4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00
    Bump stm submodule to 2.5.1.0
    
    - - - - -
    837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00
    users-guide: Document system-cxx-std-lib
    
    - - - - -
    f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00
    Update submodule containers to 0.6.6
    
    - - - - -
    4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00
    Update submodule process to 1.6.15.0
    
    - - - - -
    1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00
    Bump directory submodule to 1.3.7.1
    
    - - - - -
    7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00
    Bump text submodule to 2.0.1
    
    - - - - -
    fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00
    Bump deepseq submodule to 1.4.8.0
    
    - - - - -
    a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00
    Add dates to base, ghc-prim changelogs
    
    - - - - -
    2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00
    Update autoconf scripts
    
    Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983
    
    - - - - -
    e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00
    Bump bytestring submodule to 0.11.3.1
    
    - - - - -
    f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00
    Update submodule Cabal to tag Cabal-v3.8.1.0
    
    closes #21931
    
    - - - - -
    e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00
    Refine in-tree compiler args for --test-compiler=stage1
    
    Some of the logic to calculate in-tree arguments was not correct for the
    stage1 compiler. Namely we were not correctly reporting whether we were
    building static or dynamic executables and whether debug assertions were
    enabled.
    
    Fixes #22096
    
    - - - - -
    6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00
    Make ghcDebugAssertions into a Stage predicate (Stage -> Bool)
    
    We also care whether we have debug assertions enabled for a stage one
    compiler, but the way which we turned on the assertions was quite
    different from the stage2 compiler. This makes the logic for turning on
    consistent across both and has the advantage of being able to correct
    determine in in-tree args whether a flavour enables assertions or not.
    
    Ticket #22096
    
    - - - - -
    15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00
    Add regression test for #21550
    
    This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5
    "Use local instances with least superclass depth"
    
    - - - - -
    7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00
    Minor cleanup
    
    - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused),
      isCoVar_maybe (duplicated by getCoVar_maybe)
    - Replace a few occurrences of voidPrimId with (# #).
      void# is a deprecated synonym for the unboxed tuple.
    - Use showSDoc in :show linker.
      This makes it consistent with the other :show commands
    
    - - - - -
    31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00
    Change Ord defaults per CLC proposal
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267
    
    - - - - -
    7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00
    Fix bootstrap with ghc-9.0
    
    It turns out Solo is a very recent addition to base, so for older GHC
    versions we just defined it inline here the one place we use it in the
    compiler.
    
    - - - - -
    d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00
    DmdAnal: Don't panic in addCaseBndrDmd (#22039)
    
    Rather conservatively return Top.
    See Note [Untyped demand on case-alternative binders].
    
    I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and
    `fieldBndrDmds`.
    
    Fixes #22039.
    
    - - - - -
    25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00
    gitlab-ci: Ensure that ghc derivation is in scope
    
    Previously the lint-ci job attempted to use cabal-install (specifically
    `cabal update`) without a GHC in PATH. However, cabal-install-3.8
    appears to want GHC, even for `cabal update`.
    
    - - - - -
    f37b621f by sheaf at 2022-09-06T11:51:53+00:00
    Update instances.rst, clarifying InstanceSigs
    
    Fixes #22103
    
    - - - - -
    d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00
    Fix :add docs in user guide
    
    - - - - -
    808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00
    ci: remove unused build_make/test_make in ci script
    
    - - - - -
    d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00
    typo
    - - - - -
    fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00
    typos
    
    - - - - -
    a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00
    whitespace
    
    - - - - -
    04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00
    CmmToAsm: remove unused ModLocation from NatM_State
    
    - - - - -
    ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00
    Minor SDoc cleanup
    
    Change calls to renderWithContext with showSDocOneLine; it's more
    efficient and explanatory.
    
    Remove polyPatSig (unused)
    
    - - - - -
    7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00
    Remove Outputable Char instance
    
    Use 'text' instead of 'ppr'.
    Using 'ppr' on the list "hello" rendered as "h,e,l,l,o".
    
    - - - - -
    77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Export liftA2 from Prelude
    
    Changes:
    In order to be warning free and compatible, we hide Applicative(..)
    from Prelude in a few places and instead import it directly from
    Control.Applicative.
    Please see the migration guide at
    https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md
    for more details.
    
    This means that Applicative is now exported in its entirety from
    Prelude.
    
    Motivation:
    
    This change is motivated by a few things:
    * liftA2 is an often used function, even more so than (<*>) for some
      people.
    * When implementing Applicative, the compiler will prompt you for either
      an implementation of (<*>) or of liftA2, but trying to use the latter
      ends with an error, without further imports. This could be confusing
      for newbies.
    * For teaching, it is often times easier to introduce liftA2 first,
      as it is a natural generalisation of fmap.
    * This change seems to have been unanimously and enthusiastically
      accepted by the CLC members, possibly indicating a lot of love for it.
    * This change causes very limited breakage, see the linked issue below
      for an investigation on this.
    
    See https://github.com/haskell/core-libraries-committee/issues/50
    for the surrounding discussion and more details.
    
    - - - - -
    442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Add changelog entry for liftA2 export from Prelude
    
    - - - - -
    fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Bump submodule containers to one with liftA2 warnings fixed
    
    - - - - -
    f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Bump submodule Cabal to one with liftA2 warnings fixed
    
    - - - - -
    a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
    Isolate some Applicative hidings to GHC.Prelude
    
    By reexporting the entirety of Applicative from GHC.Prelude, we can save
    ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude.
    This also has the benefit of isolating this type of change to
    GHC.Prelude, so that people in the future don't have to think about it.
    
    - - - - -
    9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00
    CmmToC: enable 64-bit CallishMachOp on 32-bit targets
    
    Normally, the unregisterised builds avoid generating 64-bit
    CallishMachOp in StgToCmm, so CmmToC doesn't support these. However,
    there do exist cases where we'd like to invoke cmmToC for other cmm
    inputs which may contain such CallishMachOps, and it's a rather low
    effort to add support for these since they only require calling into
    existing ghc-prim cbits.
    
    - - - - -
    04062510 by Alexis King at 2022-09-11T11:30:32+02:00
    Add native delimited continuations to the RTS
    
    This patch implements GHC proposal 313, "Delimited continuation
    primops", by adding native support for delimited continuations to the
    GHC RTS.
    
    All things considered, the patch is relatively small. It almost
    exclusively consists of changes to the RTS; the compiler itself is
    essentially unaffected. The primops come with fairly extensive Haddock
    documentation, and an overview of the implementation strategy is given
    in the Notes in rts/Continuation.c.
    
    This first stab at the implementation prioritizes simplicity over
    performance. Most notably, every continuation is always stored as a
    single, contiguous chunk of stack. If one of these chunks is
    particularly large, it can result in poor performance, as the current
    implementation does not attempt to cleverly squeeze a subset of the
    stack frames into the existing stack: it must fit all at once. If this
    proves to be a performance issue in practice, a cleverer strategy would
    be a worthwhile target for future improvements.
    
    - - - - -
    ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00
    rts: fix missing dirty_MVAR argument in stg_writeIOPortzh
    
    - - - - -
    a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00
    ci: enable parallel compression for xz
    
    - - - - -
    3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00
    Windows: Always define _UCRT when compiling C code
    
    As seen in #22159, this is required to ensure correct behavior when MinGW-w64
    headers are in the `C_INCLUDE_PATH`.
    
    Fixes #22159.
    
    - - - - -
    65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00
    Add diagnostic codes
    
    This MR adds diagnostic codes, assigning unique numeric codes to
    error and warnings, e.g.
    
      error: [GHC-53633]
      Pattern match is redundant
    
    This is achieved as follows:
    
      - a type family GhcDiagnosticCode that gives the diagnostic code
        for each diagnostic constructor,
      - a type family ConRecursInto that specifies whether to recur into
        an argument of the constructor to obtain a more fine-grained code
        (e.g. different error codes for different 'deriving' errors),
      - generics machinery to generate the value-level function assigning
        each diagnostic its error code; see Note [Diagnostic codes using generics]
        in GHC.Types.Error.Codes.
    
    The upshot is that, to add a new diagnostic code, contributors only need
    to modify the two type families mentioned above. All logic relating to
    diagnostic codes is thus contained to the GHC.Types.Error.Codes module,
    with no code duplication.
    
    This MR also refactors error message datatypes a bit, ensuring we can
    derive Generic for them, and cleans up the logic around constraint
    solver reports by splitting up 'TcSolverReportInfo' into separate
    datatypes (see #20772).
    
    Fixes #21684
    
    - - - - -
    362cca13 by sheaf at 2022-09-13T10:27:53-04:00
    Diagnostic codes: acccept test changes
    
    The testsuite output now contains diagnostic codes, so many tests need
    to be updated at once.
    We decided it was best to keep the diagnostic codes in the testsuite
    output, so that contributors don't inadvertently make changes to the
    diagnostic codes.
    
    - - - - -
    08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00
    Allow imports to reference multiple fields with the same name (#21625)
    
    If a module `M` exports two fields `f` (using DuplicateRecordFields), we can
    still accept
    
        import M (f)
        import M hiding (f)
    
    and treat `f` as referencing both of them.  This was accepted in GHC 9.0, but gave
    rise to an ambiguity error in GHC 9.2.  See #21625.
    
    This patch also documents this behaviour in the user's guide, and updates the
    test for #16745 which is now treated differently.
    
    - - - - -
    c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00
    ci: remove unused appveyor config
    
    - - - - -
    dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00
    compiler: remove unused lazy state monad
    
    - - - - -
    646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00
    Fix typos
    
    This fixes various typos and spelling mistakes
    in the compiler.
    
    Fixes #21891
    
    - - - - -
    7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00
    hadrian: Bump index state
    
    This bumps the index state so a build plan can also be found when
    booting with 9.4.
    
    Fixes #22165
    
    - - - - -
    98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Use a stamp file to record when a package is built in a certain way
    
    Before this patch which library ways we had built wasn't recorded
    directly. So you would run into issues if you build the .conf file with
    some library ways before switching the library ways which you wanted to
    build.
    
    Now there is one stamp file for each way, so in order to build a
    specific way you can need that specific stamp file rather than going
    indirectly via the .conf file.
    
    - - - - -
    b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Inplace/Final package databases
    
    There are now two different package databases per stage. An inplace
    package database contains .conf files which point directly into the
    build directories. The final package database contains .conf files which
    point into the installed locations. The inplace .conf files are created
    before any building happens and have fake ABI hash values. The final
    .conf files are created after a package finished building and contains
    the proper ABI has.
    
    The motivation for this is to make the dependency structure more
    fine-grained when building modules. Now a module depends just depends
    directly on M.o from package p rather than the .conf file depend on the
    .conf file for package p. So when all of a modules direct dependencies
    have finished building we can start building it rather than waiting for
    the whole package to finish.
    
    The secondary motivation is that the multi-repl doesn't need to build
    everything before starting the multi-repl session. We can just configure
    the inplace package-db and use that in order to start the repl.
    
    - - - - -
    6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Add some more packages to multi-cradle
    
    The main improvement here is to pass `-this-unit-id` for executables so
    that they can be added to the multi-cradle if desired as well as normal
    library packages.
    
    - - - - -
    e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Need builders needed by Cabal Configure in parallel
    
    Because of the use of withStaged (which needs the necessary builder)
    when configuring a package, the builds of stage1:exe:ghc-bin and
    stage1:exe:ghc-pkg where being linearised when building a specific
    target like `binary-dist-dir`.
    
    Thankfully the fix is quite local, to supply all the `withStaged`
    arguments together so the needs can be batched together and hence
    performed in parallel.
    
    Fixes #22093
    
    - - - - -
    c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00
    Remove stage1:exe:ghc-bin pre-build from CI script
    
    CI builds stage1:exe:ghc-bin before the binary-dist target which
    introduces some quite bad linearisation (see #22093) because we don't
    build stage1 compiler in parallel with anything. Then when the
    binary-dist target is started we have to build stage1:exe:ghc-pkg before
    doing anything.
    
    Fixes #22094
    
    - - - - -
    71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00
    hadrian: Add extra implicit dependencies from DeriveLift
    
    ghc -M should know that modules which use DeriveLift (or
    TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have
    to add these extra edges manually or the modules will be compiled before
    TH.Lib.Internal is compiled which leads to a desugarer error.
    
    - - - - -
    43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00
    Repair c++ probing on OpenBSD
    
    Failure without this change:
    ```
    checking C++ standard library flavour... libc++
    checking for linkage against 'c++ c++abi'... failed
    checking for linkage against 'c++ cxxrt'... failed
    configure: error: Failed to find C++ standard library
    ```
    
    - - - - -
    534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00
    libraries: template-haskell: vendor filepath differently
    
    Vendoring with ../ in hs-source-dirs prevents upload to hackage.
    
    (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842)
    
    - - - - -
    bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00
    Unbreak Hadrian with Cabal 3.8.
    
    - - - - -
    df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00
    Fix typos
    
    - - - - -
    d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00
    Tag inference: Fix #21954 by retaining tagsigs of vars in function position.
    
    For an expression like:
    
        case x of y
          Con z -> z
    
    If we also retain the tag sig for z we can generate code to immediately return
    it rather than calling out to stg_ap_0_fast.
    
    - - - - -
    7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00
    Stg.InferTags.Rewrite - Avoid some thunks.
    
    - - - - -
    88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00
    hadrian: enable -fprof-late only for profiling ways
    
    - - - - -
    d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00
    hadrian: add late_ccs flavour transformer
    
    - - - - -
    ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00
    configure: remove unused program checks
    
    - - - - -
    9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00
    Update to Unicode 15.0
    
    - - - - -
    c6e9b89a by Andrew Lelechenko at 2022-09-16T13:59:55-04:00
    Avoid partial head and tail in ghc-heap; replace with total pattern-matching
    
    - - - - -
    616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00
    hadrian: relax Cabal upper bound to allow building with Cabal-3.8
    
    A follow up of !8910.
    
    - - - - -
    df35d994 by Alexis King at 2022-09-16T14:01:11-04:00
    Add links to the continuations haddocks in the docs for each primop
    
    fixes #22176
    
    - - - - -
    383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00
    -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice
    
    See the examples in #22057 which show we have to traverse deeply into a
    pattern to determine whether it contains a splice or not. The original
    implementation pointed this out but deemed this very shallow traversal
    "too expensive".
    
    Fixes #22057
    
    I also fixed an oversight in !7821 which meant we lost a warning which
    was present in 9.2.2.
    
    Fixes #22067
    
    - - - - -
    5031bf49 by sheaf at 2022-09-16T21:42:49-04:00
    Hadrian: Don't try to build terminfo on Windows
    
    Commit b42cedbe introduced a dependency on terminfo on Windows,
    but that package isn't available on Windows.
    
    - - - - -
    c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00
    Clean up some. In particular:
    • Delete some dead code, largely under `GHC.Utils`.
    • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`.
    • Clean up `GHC.Types.SrcLoc`.
    • Derive stock `Functor, Foldable, Traversable` for more types.
    • Derive more instances for newtypes.
    
    Bump haddock submodule.
    
    - - - - -
    85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00
    driver: pass original Cmm filename in ModLocation
    
    When compiling Cmm, the ml_hs_file field is used to indicate Cmm
    filename when later generating DWARF information. We should pass the
    original filename here, otherwise for preprocessed Cmm files, the
    filename will be a temporary filename which is confusing.
    
    - - - - -
    63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00
    rts: remove legacy logging cabal flag
    
    - - - - -
    bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00
    rts: make threaded ways optional
    
    For certain targets (e.g. wasm32-wasi), the threaded rts is known not to
    work. This patch adds a "threaded" cabal flag to rts to make threaded
    rts ways optional. Hadrian enables this flag iff the flavour rtsWays
    contains threaded ways.
    
    - - - - -
    8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00
    DeriveFunctor: Check for last type variables using dataConUnivTyVars
    
    Previously, derived instances of `Functor` (as well as the related classes
    `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to
    infer by checking for fields that contain the last type variable. The problem
    was that this last type variable was taken from `tyConTyVars`. For GADTs, the
    type variables in each data constructor are _not_ the same type variables as
    in `tyConTyVars`, leading to #22167.
    
    This fixes the issue by instead checking for the last type variable using
    `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185,
    which also replaced an errant use of `tyConTyVars` with type variables from
    each data constructor.)
    
    Fixes #22167.
    
    - - - - -
    78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00
    Lexer: pass updated buffer to actions (#22201)
    
    In the lexer, predicates have the following type:
    	{ ... } :: user       -- predicate state
    		-> AlexInput  -- input stream before the token
    		-> Int        -- length of the token
    		-> AlexInput  -- input stream after the token
    		-> Bool       -- True <=> accept the token
    This is documented in the Alex manual.
    
    There is access to the input stream both before and after the token.
    But when the time comes to construct the token, GHC passes only the
    initial string buffer to the lexer action. This patch fixes it:
    
    	- type Action = PsSpan -> StringBuffer -> Int ->                 P (PsLocated Token)
    	+ type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token)
    
    Now lexer actions have access to the string buffer both before and after
    the token, just like the predicates. It's just a matter of passing an
    additional function parameter throughout the lexer.
    
    - - - - -
    75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00
    Lexer: define varsym without predicates (#22201)
    
    Before this patch, the varsym lexing rules were defined as follows:
    
    	<0> {
    	  @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix }
    	  @varsym / { followedByOpeningToken }  { varsym_prefix }
    	  @varsym / { precededByClosingToken }  { varsym_suffix }
    	  @varsym                               { varsym_loose_infix }
    	}
    
    Unfortunately, this meant that the predicates 'precededByClosingToken' and
    'followedByOpeningToken' were recomputed several times before we could figure
    out the whitespace context.
    
    With this patch, we check for whitespace context directly in the lexer
    action:
    
    	<0> {
    	  @varsym { with_op_ws varsym }
    	}
    
    The checking for opening/closing tokens happens in 'with_op_ws' now,
    which is part of the lexer action rather than the lexer predicate.
    
    - - - - -
    c1f81b38 by Matthew Farkas-Dyck at 2022-09-19T09:07:05-04:00
    Scrub partiality about `NewOrData`.
    
    Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor.
    
    Closes #22070.
    
    Bump haddock submodule.
    
    - - - - -
    1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00
    CmmToC: emit __builtin_unreachable() after noreturn ccalls
    
    Emit a __builtin_unreachable() call after a foreign call marked as
    CmmNeverReturns. This is crucial to generate correctly typed code for
    wasm; as for other archs, this is also beneficial for the C compiler
    optimizations.
    
    - - - - -
    19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00
    Document :unadd GHCi command in user guide
    
    - - - - -
    545ff490 by sheaf at 2022-09-20T03:50:06-04:00
    Hadrian: merge archives even in stage 0
    
    We now always merge .a archives when ar supports -L.
    This change is necessary in order to bootstrap GHC using GHC 9.4
    on Windows, as nested archives aren't supported.
    Not doing so triggered bug #21990 when trying to use the Win32
    package, with errors such as:
    
      Not a x86_64 PE+ file.
      Unknown COFF 4 type in getHeaderInfo.
    
      ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info
    
    We have to be careful about which ar is meant: in stage 0, the check
    should be done on the system ar (system-ar in system.config).
    
    - - - - -
    59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00
    Fix -Woperator-whitespace for consym (part of #19372)
    
    Due to an oversight, the initial specification and implementation of
    -Woperator-whitespace focused on varsym exclusively and completely
    ignored consym.
    
    This meant that expressions such as "x+ y" would produce a warning,
    while "x:+ y" would not.
    
    The specification was corrected in ghc-proposals pull request #404,
    and this patch updates the implementation accordingly.
    
    Regression test included.
    
    - - - - -
    c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00
    Add `Eq` and `Ord` instances for `Generically1`
    
    These are needed so the subsequent commit overhauling the `*1` classes
    type-checks.
    
    - - - - -
    7beb356e by John Ericson at 2022-09-20T13:11:50-04:00
    Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking
    
    This change is approved by the Core Libraries commitee in
    https://github.com/haskell/core-libraries-committee/issues/10
    
    The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for
    `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`.
    These have the proper flexible contexts that are exactly what the
    instance needs:
    
    For example, instead of
    ```haskell
    instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where
      (==) = eq1
    ```
    we do
    ```haskell
    deriving instance Eq (f (g a)) => Eq (Compose f g a)
    ```
    
    But, that change alone is rather breaking, because until now `Eq (f a)`
    and `Eq1 f` (and respectively the other classes and their `*1`
    equivalents too) are *incomparable* constraints. This has always been an
    annoyance of working with the `*1` classes, and now it would rear it's
    head one last time as an pesky migration.
    
    Instead, we give the `*1` classes superclasses, like so:
    ```haskell
    (forall a. Eq a => Eq (f a)) => Eq1 f
    ```
    along with some laws that canonicity is preserved, like:
    ```haskell
    liftEq (==) = (==)
    ```
    
    and likewise for `*2` classes:
    ```haskell
    (forall a. Eq a => Eq1 (f a)) => Eq2 f
    ```
    and laws:
    ```haskell
    liftEq2 (==) = liftEq1
    ```
    
    The `*1` classes also have default methods using the `*2` classes where
    possible.
    
    What this means, as explained in the docs, is that `*1` classes really
    are generations of the regular classes, indicating that the methods can
    be split into a canonical lifting combined with a canonical inner, with
    the super class "witnessing" the laws[1] in a fashion.
    
    Circling back to the pragmatics of migrating, note that the superclass
    means evidence for the old `Sum`, `Product`, and `Compose` instances is
    (more than) sufficient, so breakage is less likely --- as long no
    instances are "missing", existing polymorphic code will continue to
    work.
    
    Breakage can occur when a datatype implements the `*1` class but not the
    corresponding regular class, but this is almost certainly an oversight.
    For example, containers made that mistake for `Tree` and `Ord`, which I
    fixed in https://github.com/haskell/containers/pull/761, but fixing the
    issue by adding `Ord1` was extremely *un*controversial.
    
    `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show`
    instances. It is unlikely this would have been caught without
    implementing this change.
    
    -----
    
    [1]: In fact, someday, when the laws are part of the language and not
    only documentation, we might be able to drop the superclass field of the
    dictionary by using the laws to recover the superclass in an
    instance-agnostic manner, e.g. with a *non*-overloaded function with
    type:
    
    ```haskell
    DictEq1 f -> DictEq a -> DictEq (f a)
    ```
    
    But I don't wish to get into optomizations now, just demonstrate the
    close relationship between the law and the superclass.
    
    Bump haddock submodule because of test output changing.
    
    - - - - -
    6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00
    Add notes to ghc-prim Haddocks that users should not import it
    
    - - - - -
    ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00
    docs: clarify that LLVM codegen is not available in unregisterised mode
    
    The current docs are misleading and suggest that it is possible to use
    LLVM codegen from an unregisterised build.  This is not the case;
    attempting to pass `-fllvm` to an unregisterised build warns:
    
    ```
    when making flags consistent: warning:
        Target platform uses unregisterised ABI, so compiling via C
    ```
    
    and uses the C codegen anyway.
    
    - - - - -
    854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00
    rts: remove copy-paste error from `cabal.rts.in`
    
    This was, likely accidentally, introduced in 4bf542bf1c.
    
    See: 4bf542bf1cdf2fa468457fc0af21333478293476
    
    - - - - -
    c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00
    hadrian: Add extra_dependencies edges for all different ways
    
    The hack to add extra dependencies needed by DeriveLift extension missed
    the cases for profiles and dynamic ways. For the profiled way this leads
    to errors like:
    
    ```
    GHC error in desugarer lookup in Data.IntSet.Internal:
      Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’
      Perhaps you haven't installed the profiling libraries for package ‘template-haskell’?
      Use -v (or `:set -v` in ghci) to see a list of the files searched for.
    ghc: panic! (the 'impossible' happened)
      GHC version 9.5.20220916:
            initDs
    ```
    
    Therefore the fix is to add these extra edges in.
    
    Fixes #22197
    
    - - - - -
    a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00
    users-guide: fix incorrect ghcappdata folder for unix and windows
    
    - - - - -
    06ccad0d by sheaf at 2022-09-21T08:28:49-04:00
    Don't use isUnliftedType in isTagged
    
    The function GHC.Stg.InferTags.Rewrite.isTagged can be given
    the Id of a join point, which might be representation polymorphic.
    This would cause the call to isUnliftedType to crash. It's better
    to use typeLevity_maybe instead.
    
    Fixes #22212
    
    - - - - -
    c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00
    Add fragmentation statistic to GHC.Stats
    
    Implements #21537
    
    - - - - -
    2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00
    Rename Solo[constructor] to MkSolo
    
    Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst)
    
    Moves all tuples to GHC.Tuple.Prim
    Updates ghc-prim version (and bumps bounds in dependents)
    
    updates haddock submodule
    updates deepseq submodule
    updates text submodule
    
    - - - - -
    9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00
    Update filepath to filepath-1.4.100.0
    
    Updates submodule
    
    * Always rely on vendored filepath
    * filepath must be built as stage0 dependency because it uses
      template-haskell.
    
    Towards #22098
    
    - - - - -
    615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00
    Minor refactor around Outputable
    
    * Replace 'text . show' and 'ppr' with 'int'.
    * Remove Outputable.hs-boot, no longer needed
    * Use pprWithCommas
    * Factor out instructions in AArch64 codegen
    
    - - - - -
    aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00
    Demand: Clear distinction between Call SubDmd and eval Dmd (#21717)
    
    In #21717 we saw a reportedly unsound strictness signature due to an unsound
    definition of plusSubDmd on Calls. This patch contains a description and the fix
    to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`.
    
    This fix means we also get rid of the special handling of `-fpedantic-bottoms`
    in eta-reduction. Thanks to less strict and actually sound strictness results,
    we will no longer eta-reduce the problematic cases in the first place, even
    without `-fpedantic-bottoms`.
    
    So fixing the unsoundness also makes our eta-reduction code simpler with less
    hacks to explain. But there is another, more unfortunate side-effect:
    We *unfix* #21085, but fortunately we have a new fix ready:
    See `Note [mkCall and plusSubDmd]`.
    
    There's another change:
    I decided to make `Note [SubDemand denotes at least one evaluation]` a lot
    simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument
    demands are lazy. That leads to less precise results, but in turn rids ourselves
    from the need for 4 different `OpMode`s and the complication of
    `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code
    that is in line with the paper draft on Demand Analysis.
    
    I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for
    posterity. The fallout in terms of regressions is negligible, as the testsuite
    and NoFib shows.
    
    ```
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             hidden          +0.2%     -0.2%
             linear          -0.0%     -0.7%
    --------------------------------------------------------------------------------
                Min          -0.0%     -0.7%
                Max          +0.2%     +0.0%
     Geometric Mean          +0.0%     -0.0%
    ```
    
    Fixes #21717.
    
    - - - - -
    9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00
    implement proposal 106 (Define Kinds Without Promotion) (fixes #6024)
    
    includes corresponding changes to haddock submodule
    
    - - - - -
    c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00
    Apply some tricks to speed up core lint.
    
    Below are the noteworthy changes and if given their impact on compiler
    allocations for a type heavy module:
    
    * Use the oneShot trick on LintM
    * Use a unboxed tuple for the result of LintM: ~6% reduction
    * Avoid a thunk for the result of typeKind in lintType: ~5% reduction
    * lint_app: Don't allocate the error msg in the hot code path: ~4%
      reduction
    * lint_app: Eagerly force the in scope set: ~4%
    * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2%
    * lintM: Use a unboxed maybe for the `a` result: ~12%
    * lint_app: make go_app tail recursive to avoid allocating the go function
                as heap closure: ~7%
    * expandSynTyCon_maybe: Use a specialized data type
    
    For a less type heavy module like nofib/spectral/simple compiled with
    -O -dcore-lint allocations went down by ~24% and compile time by ~9%.
    
    -------------------------
    Metric Decrease:
        T1969
    -------------------------
    
    - - - - -
    b74b6191 by sheaf at 2022-09-28T15:08:10-04:00
    matchLocalInst: do domination analysis
    
    When multiple Given quantified constraints match a Wanted, and there is
    a quantified constraint that dominates all others, we now pick it
    to solve the Wanted.
    
    See Note [Use only the best matching quantified constraint].
    
    For example:
    
      [G] d1: forall a b. ( Eq a, Num b, C a b  ) => D a b
      [G] d2: forall a  .                C a Int  => D a Int
      [W] {w}: D a Int
    
    When solving the Wanted, we find that both Givens match, but we pick
    the second, because it has a weaker precondition, C a Int, compared
    to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1;
    see Note [When does a quantified instance dominate another?].
    
    This domination test is done purely in terms of superclass expansion,
    in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt
    to do a full round of constraint solving; this simple check suffices
    for now.
    
    Fixes #22216 and #22223
    
    - - - - -
    2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
    Improve aggressive specialisation
    
    This patch fixes #21286, by not unboxing dictionaries in
    worker/wrapper (ever). The main payload is tiny:
    
    * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox
      dictionaries in `get_dmd`.  See Note [Do not unbox class dictionaries]
      in that module
    
    * I also found that imported wrappers were being fruitlessly
      specialised, so I fixed that too, in canSpecImport.
      See Note [Specialising imported functions] point (2).
    
    In doing due diligence in the testsuite I fixed a number of
    other things:
    
    * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make,
      and Note [Inline specialisations] in GHC.Core.Opt.Specialise,
      and remove duplication between the two. The new Note describes
      how we specialise functions with an INLINABLE pragma.
    
      And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`.
    
    * Improve Note [Worker/wrapper for INLINABLE functions] in
      GHC.Core.Opt.WorkWrap.
    
      And (critially) make an actual change which is to propagate the
      user-written pragma from the original function to the wrapper; see
      `mkStrWrapperInlinePrag`.
    
    * Write new Note [Specialising imported functions] in
      GHC.Core.Opt.Specialise
    
    All this has a big effect on some compile times. This is
    compiler/perf, showing only changes over 1%:
    
    Metrics: compile_time/bytes allocated
    -------------------------------------
                    LargeRecord(normal)  -50.2% GOOD
               ManyConstructors(normal)   +1.0%
    MultiLayerModulesTH_OneShot(normal)   +2.6%
                      PmSeriesG(normal)   -1.1%
                         T10547(normal)   -1.2%
                         T11195(normal)   -1.2%
                         T11276(normal)   -1.0%
                        T11303b(normal)   -1.6%
                         T11545(normal)   -1.4%
                         T11822(normal)   -1.3%
                         T12150(optasm)   -1.0%
                         T12234(optasm)   -1.2%
                         T13056(optasm)   -9.3% GOOD
                         T13253(normal)   -3.8% GOOD
                         T15164(normal)   -3.6% GOOD
                         T16190(normal)   -2.1%
                         T16577(normal)   -2.8% GOOD
                         T16875(normal)   -1.6%
                         T17836(normal)   +2.2%
                        T17977b(normal)   -1.0%
                         T18223(normal)  -33.3% GOOD
                         T18282(normal)   -3.4% GOOD
                         T18304(normal)   -1.4%
                        T18698a(normal)   -1.4% GOOD
                        T18698b(normal)   -1.3% GOOD
                         T19695(normal)   -2.5% GOOD
                          T5837(normal)   -2.3%
                          T9630(normal)  -33.0% GOOD
                          WWRec(normal)   -9.7% GOOD
                 hard_hole_fits(normal)   -2.1% GOOD
                         hie002(normal)   +1.6%
    
                              geo. mean   -2.2%
                              minimum    -50.2%
                              maximum     +2.6%
    
    I diligently investigated some of the big drops.
    
    * Caused by not doing w/w for dictionaries:
        T13056, T15164, WWRec, T18223
    
    * Caused by not fruitlessly specialising wrappers
        LargeRecord, T9630
    
    For runtimes, here is perf/should+_run:
    
    Metrics: runtime/bytes allocated
    --------------------------------
                   T12990(normal)   -3.8%
                    T5205(normal)   -1.3%
                    T9203(normal)  -10.7% GOOD
            haddock.Cabal(normal)   +0.1%
             haddock.base(normal)   -1.1%
         haddock.compiler(normal)   -0.3%
            lazy-bs-alloc(normal)   -0.2%
    ------------------------------------------
                        geo. mean   -0.3%
                        minimum    -10.7%
                        maximum     +0.1%
    
    I did not investigate exactly what happens in T9203.
    
    Nofib is a wash:
    
    +-------------------------------++--+-----------+-----------+
    |                               ||  | tsv (rel) | std. err. |
    +===============================++==+===========+===========+
    |                     real/anna ||  |    -0.13% |      0.0% |
    |                      real/fem ||  |    +0.13% |      0.0% |
    |                   real/fulsom ||  |    -0.16% |      0.0% |
    |                     real/lift ||  |    -1.55% |      0.0% |
    |                  real/reptile ||  |    -0.11% |      0.0% |
    |                  real/smallpt ||  |    +0.51% |      0.0% |
    |          spectral/constraints ||  |    +0.20% |      0.0% |
    |               spectral/dom-lt ||  |    +1.80% |      0.0% |
    |               spectral/expert ||  |    +0.33% |      0.0% |
    +===============================++==+===========+===========+
    |                     geom mean ||  |           |           |
    +-------------------------------++--+-----------+-----------+
    
    I spent quite some time investigating dom-lt, but it's pretty
    complicated.  See my note on !7847.  Conclusion: it's just a delicate
    inlining interaction, and we have plenty of those.
    
    Metric Decrease:
        LargeRecord
        T13056
        T13253
        T15164
        T16577
        T18223
        T18282
        T18698a
        T18698b
        T19695
        T9630
        WWRec
        hard_hole_fits
        T9203
    
    - - - - -
    addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
    Refactor UnfoldingSource and IfaceUnfolding
    
    I finally got tired of the way that IfaceUnfolding reflected
    a previous structure of unfoldings, not the current one. This
    MR refactors UnfoldingSource and IfaceUnfolding to be simpler
    and more consistent.
    
    It's largely just a refactor, but in UnfoldingSource (which moves
    to GHC.Types.Basic, since it is now used in IfaceSyn too), I
    distinguish between /user-specified/ and /system-generated/ stable
    unfoldings.
    
        data UnfoldingSource
          = VanillaSrc
          | StableUserSrc   -- From a user-specified pragma
          | StableSystemSrc -- From a system-generated unfolding
          | CompulsorySrc
    
    This has a minor effect in CSE (see the use of isisStableUserUnfolding
    in GHC.Core.Opt.CSE), which I tripped over when working on
    specialisation, but it seems like a Good Thing to know anyway.
    
    - - - - -
    7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
    INLINE/INLINEABLE pragmas in Foreign.Marshal.Array
    
    Foreign.Marshal.Array contains many small functions, all of which are
    overloaded, and which are critical for performance. Yet none of them
    had pragmas, so it was a fluke whether or not they got inlined.
    
    This patch makes them all either INLINE (small ones) or
    INLINEABLE and hence specialisable (larger ones).
    
    See Note [Specialising array operations] in that module.
    
    - - - - -
    b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00
    Export OnOff from GHC.Driver.Session
    
    I was working on fixing an issue where HLS was trying to pass its
    DynFlags to HLint, but didn't pass any of the disabled language
    extensions, which HLint would then assume are on because of their
    default values.
    
    Currently it's not possible to get any of the "No" flags because the
    `DynFlags.extensions` field can't really be used since it is [OnOff
    Extension] and OnOff is not exported.
    
    So let's export it.
    
    - - - - -
    2f050687 by Andrew Lelechenko at 2022-09-28T17:50:28-04:00
    Avoid Data.List.group; prefer Data.List.NonEmpty.group
    
    This allows to avoid further partiality, e. g., map head . group is
    replaced by map NE.head . NE.group, and there are less panic calls.
    
    - - - - -
    bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00
    Clean up `findWiredInUnit`. In particular, avoid `head`.
    
    - - - - -
    6a2eec98 by Andrew Lelechenko at 2022-09-28T22:52:38-04:00
    Eliminate headFS, use unconsFS instead
    
    A small step towards #22185 to avoid partial functions + safe implementation
    of `startsWithUnderscore`.
    
    - - - - -
    5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00
    Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)
    
    Justification in #22231. Short form: In a demand like `1C1(C1(L))`
    it was too easy to confuse which `1` belongs to which `C`. Now
    that should be more obvious.
    
    Fixes #22231
    
    - - - - -
    ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00
    Revert "ci: enable parallel compression for xz"
    
    Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners.
    
    This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab.
    
    - - - - -
    f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00
    Boxity: Don't update Boxity unless worker/wrapper follows (#21754)
    
    A small refactoring in our Core Opt pipeline and some new functions for
    transfering argument boxities from one signature to another to facilitate
    `Note [Don't change boxity without worker/wrapper]`.
    
    Fixes #21754.
    
    - - - - -
    4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00
    Scrub various partiality involving empty lists.
    
    Avoids some uses of `head` and `tail`, and some panics when an argument is null.
    
    - - - - -
    95ead839 by Alexis King at 2022-10-01T00:37:43-04:00
    Fix a bug in continuation capture across multiple stack chunks
    
    - - - - -
    22096652 by Andrew Lelechenko at 2022-10-01T00:38:22-04:00
    Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc
    
    `viewCons` used to ignore `Many` constructor completely, returning `VNothing`.
    `viewSnoc` violated internal invariant of `Many` being a non-empty list.
    
    - - - - -
    48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00
    chore: extend `.editorconfig` for C files
    
    - - - - -
    b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00
    Fix docs for pattern synonyms
    - - - - -
    463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00
    Use sameByteArray# in sameByteArray
    
    - - - - -
    fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00
    Minor fixes following Unicode 15.0.0 update
    
    - Fix changelog for Unicode 15.0.0
    - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell".
    
    - - - - -
    8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00
    rts: don't enforce aligned((8)) on 32-bit targets
    
    We simply need to align to the word size for pointer tagging to work. On
    32-bit targets, aligned((8)) is wasteful.
    
    - - - - -
    532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00
    Export symbolSing, SSymbol, and friends (CLC#85)
    
    This implements this Core Libraries Proposal:
    https://github.com/haskell/core-libraries-committee/issues/85
    
    In particular, it:
    
    1. Exposes the `symbolSing` method of `KnownSymbol`,
    2. Exports the abstract `SSymbol` type used in `symbolSing`, and
    3. Defines an API for interacting with `SSymbol`.
    
    This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and
    `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2)
    of #21568.
    
    - - - - -
    d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00
    Remove mention of make from README.md
    
    - - - - -
    945e8e49 by Andrew Lelechenko at 2022-10-10T17:13:31-04:00
    Add a newline before since pragma in Data.Array.Byte
    
    - - - - -
    44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00
    Parser/PostProcess: rename failOp* functions
    
    There are three functions named failOp* in the parser:
    	failOpNotEnabledImportQualifiedPost
    	failOpImportQualifiedTwice
    	failOpFewArgs
    Only the last one has anything to do with operators. The other two
    were named this way either by mistake or due to a misunderstanding of
    what "op" stands for. This small patch corrects this.
    
    - - - - -
    96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00
    Make rewrite rules "win" over inlining
    
    If a rewrite rule and a rewrite rule compete in the simplifier, this
    patch makes sure that the rewrite rule "win".  That is, in general
    a bit fragile, but it's a huge help when making specialisation work
    reliably, as #21851 and #22097 showed.
    
    The change is fairly straightforwad, and documented in
       Note [Rewrite rules and inlining]
    in GHC.Core.Opt.Simplify.Iteration.
    
    Compile-times change, up and down a bit -- in some cases because
    we get better specialisation.  But the payoff (more reliable
    specialisation) is large.
    
    Metrics: compile_time/bytes allocated
    -----------------------------------------------
        T10421(normal)   +3.7% BAD
       T10421a(normal)   +5.5%
        T13253(normal)   +1.3%
          T14052(ghci)   +1.8%
        T15304(normal)   -1.4%
        T16577(normal)   +3.1% BAD
        T17516(normal)   +2.3%
        T17836(normal)   -1.9%
        T18223(normal)   -1.8%
         T8095(normal)   -1.3%
         T9961(normal)   +2.5% BAD
    
             geo. mean   +0.0%
             minimum     -1.9%
             maximum     +5.5%
    
    Nofib results are (bytes allocated)
    
    +-------------------------------++----------+
    |                               ||tsv (rel) |
    +===============================++==========+
    |           imaginary/paraffins ||   +0.27% |
    |                imaginary/rfib ||   -0.04% |
    |                     real/anna ||   +0.02% |
    |                      real/fem ||   -0.04% |
    |                    real/fluid ||   +1.68% |
    |                   real/gamteb ||   -0.34% |
    |                       real/gg ||   +1.54% |
    |                   real/hidden ||   -0.01% |
    |                      real/hpg ||   -0.03% |
    |                    real/infer ||   -0.03% |
    |                   real/prolog ||   +0.02% |
    |                  real/veritas ||   -0.47% |
    |       shootout/fannkuch-redux ||   -0.03% |
    |         shootout/k-nucleotide ||   -0.02% |
    |               shootout/n-body ||   -0.06% |
    |        shootout/spectral-norm ||   -0.01% |
    |         spectral/cryptarithm2 ||   +1.25% |
    |             spectral/fibheaps ||  +18.33% |
    |           spectral/last-piece ||   -0.34% |
    +===============================++==========+
    |                     geom mean ||   +0.17% |
    
    There are extensive notes in !8897 about the regressions.
    Briefly
    
    * fibheaps: there was a very delicately balanced inlining that
      tipped over the wrong way after this change.
    
    * cryptarithm2 and paraffins are caused by #22274, which is
      a separate issue really.  (I.e. the right fix is *not* to
      make inlining "win" over rules.)
    
    So I'm accepting these changes
    
    Metric Increase:
        T10421
        T16577
        T9961
    
    - - - - -
    ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00
    Utils.JSON: do not escapeJsonString in ToJson String instance
    
    as `escapeJsonString` is used in `renderJSON`, so the `JSString`
    constructor is meant to carry the unescaped string.
    
    - - - - -
    fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00
    Tidy implicit binds
    
    We want to put implicit binds into fat interface files, so the easiest
    thing to do seems to be to treat them uniformly with other binders.
    
    - - - - -
    e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00
    Interface Files with Core Definitions
    
    This commit adds three new flags
    
    * -fwrite-if-simplified-core: Writes the whole core program into an interface
      file
    * -fbyte-code-and-object-code: Generate both byte code and object code
      when compiling a file
    * -fprefer-byte-code: Prefer to use byte-code if it's available when
      running TH splices.
    
    The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline
    at the point just after simplification and before code generation. Once compilation is
    restarted then code can be created for the byte code backend.
    This can significantly speed up
    start-times for projects in GHCi. HLS already implements its own version of these extended interface
    files for this reason.
    
    Preferring to use byte-code means that we can avoid some potentially
    expensive code generation steps (see #21700)
    
    * Producing object code is much slower than producing bytecode, and normally you
      need to compile with `-dynamic-too` to produce code in the static and dynamic way, the
      dynamic way just for Template Haskell execution when using a dynamically linked compiler.
    
    * Linking many large object files, which happens once per splice, can be quite
      expensive compared to linking bytecode.
    
    And you can get GHC to compile the necessary byte code so
    `-fprefer-byte-code` has access to it by using
    `-fbyte-code-and-object-code`.
    
    Fixes #21067
    
    - - - - -
    9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00
    Teach -fno-code about -fprefer-byte-code
    
    This patch teachs the code generation logic of -fno-code about
    -fprefer-byte-code, so that if we need to generate code for a module
    which prefers byte code, then we generate byte code rather than object
    code.
    
    We keep track separately which modules need object code and which byte
    code and then enable the relevant code generation for each. Typically
    the option will be enabled globally so one of these sets should be empty
    and we will just turn on byte code or object code generation.
    
    We also fix the bug where we would generate code for a module which
    enables Template Haskell despite the fact it was unecessary.
    
    Fixes #22016
    
    - - - - -
    caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00
    Don't keep exit join points so much
    
    We were religiously keeping exit join points throughout, which
    had some bad effects (#21148, #22084).
    
    This MR does two things:
    
    * Arranges that exit join points are inhibited from inlining
      only in /one/ Simplifier pass (right after Exitification).
    
      See Note [Be selective about not-inlining exit join points]
      in GHC.Core.Opt.Exitify
    
      It's not a big deal, but it shaves 0.1% off compile times.
    
    * Inline used-once non-recursive join points very aggressively
      Given join j x = rhs in
            joinrec k y = ....j x....
    
      where this is the only occurrence of `j`, we want to inline `j`.
      (Unless sm_keep_exits is on.)
    
      See Note [Inline used-once non-recursive join points] in
      GHC.Core.Opt.Simplify.Utils
    
      This is just a tidy-up really.  It doesn't change allocation, but
      getting rid of a binding is always good.
    
    Very effect on nofib -- some up and down.
    
    - - - - -
    284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00
    Make SpecConstr bale out less often
    
    When doing performance debugging on #22084 / !8901, I found that the
    algorithm in SpecConstr.decreaseSpecCount was so aggressive that if
    there were /more/ specialisations available for an outer function,
    that could more or less kill off specialisation for an /inner/
    function.  (An example was in nofib/spectral/fibheaps.)
    
    This patch makes it a bit more aggressive, by dividing by 2, rather
    than by the number of outer specialisations.
    
    This makes the program bigger, temporarily:
    
       T19695(normal) ghc/alloc   +11.3% BAD
    
    because we get more specialisation.  But lots of other programs
    compile a bit faster and the geometric mean in perf/compiler
    is 0.0%.
    
    Metric Increase:
        T19695
    
    - - - - -
    66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00
    CmmToC: emit explicit tail calls when the C compiler supports it
    
    Clang 13+ supports annotating a return statement using the musttail
    attribute, which guarantees that it lowers to a tail call if compilation
    succeeds.
    
    This patch takes advantage of that feature for the unregisterised code
    generator. The configure script tests availability of the musttail
    attribute, if it's available, the Cmm tail calls will become C tail
    calls that avoids the mini interpreter trampoline overhead. Nothing is
    affected if the musttail attribute is not supported.
    
    Clang documentation:
    https://clang.llvm.org/docs/AttributeReference.html#musttail
    
    - - - - -
    7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00
    Don't include BufPos in interface files
    
    Ticket #22162 pointed out that the build directory was leaking into the
    ABI hash of a module because the BufPos depended on the location of the
    build tree.
    
    BufPos is only used in GHC.Parser.PostProcess.Haddock, and the
    information doesn't need to be propagated outside the context of a
    module.
    
    Fixes #22162
    
    - - - - -
    dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00
    CLabel: fix isInfoTableLabel
    
    isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work.
    
    - - - - -
    da679f2e by Andrew Lelechenko at 2022-10-11T18:02:59-04:00
    Extend documentation for Data.List, mostly wrt infinite lists
    
    - - - - -
    9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00
    Expand comment for Data.List.permutations
    - - - - -
    d3863cb7 by Andrew Lelechenko at 2022-10-11T18:03:37-04:00
    ByteArray# is unlifted, not unboxed
    
    - - - - -
    f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00
    rts: Add missing declaration of stg_noDuplicate
    
    - - - - -
    69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00
    base: Move CString, CStringLen to GHC.Foreign
    
    - - - - -
    f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00
    base: Move IPE helpers to GHC.InfoProv
    
    - - - - -
    866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00
    rts: Refactor IPE tracing support
    
    - - - - -
    6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00
    Refactor IPE initialization
    
    Here we refactor the representation of info table provenance information
    in object code to significantly reduce its size and link-time impact.
    Specifically, we deduplicate strings and represent them as 32-bit
    offsets into a common string table.
    
    In addition, we rework the registration logic to eliminate allocation
    from the registration path, which is run from a static initializer where
    things like allocation are technically undefined behavior (although it
    did previously seem to work). For similar reasons we eliminate lock
    usage from registration path, instead relying on atomic CAS.
    
    Closes #22077.
    
    - - - - -
    9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00
    Separate IPE source file from span
    
    The source file name can very often be shared across many IPE entries
    whereas the source coordinates are generally unique. Separate the two to
    exploit sharing of the former.
    
    - - - - -
    27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00
    Make Cmm Lint messages use dump style
    
    Lint errors indicate an internal error in GHC, so it makes sense to use
    it instead of the user style. This is consistent with Core Lint and STG Lint:
    
    https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429
    
    https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144
    
    Fixes #22218.
    
    - - - - -
    64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00
    Mark T7919 as fragile
    
    On x86_64-linux, T7919 timed out ~30 times during July 2022.
    
    And again ~30 times in September 2022.
    
    - - - - -
    481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00
    rts: Don't hint inlining of appendToRunQueue
    
    These hints have resulted in compile-time warnings due to failed
    inlinings for quite some time. Moreover, it's quite unlikely that
    inlining them is all that beneficial given that they are rather sizeable
    functions.
    
    Resolves #22280.
    
    - - - - -
    81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00
    remove name shadowing
    
    - - - - -
    626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00
    winio: do not re-translate input when handle is uncooked
    
    - - - - -
    5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00
    Unrestricted OverloadedLabels (#11671)
    
    Implements GHC proposal:
    https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst
    
    - - - - -
    ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00
    Add a perf test for the generics code pattern from #21839.
    
    This code showed a strong shift between compile time (got worse) and
    run time (got a lot better) recently which is perfectly acceptable.
    
    However it wasn't clear why the compile time regression was happening
    initially so I'm adding this test to make it easier to track such changes
    in the future.
    
    - - - - -
    78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00
    rts/linker: Consolidate initializer/finalizer handling
    
    Here we extend our treatment of initializer/finalizer priorities to
    include ELF and in so doing refactor things to share the implementation
    with PEi386. As well, I fix a subtle misconception of the ordering
    behavior for `.ctors`.
    
    Fixes #21847.
    
    - - - - -
    44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00
    rts/linker: Add support for .fini sections
    
    - - - - -
    beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00
    Update phases.rst
    
    (the name of the original source file is $1, not $2)
    - - - - -
    eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00
    Clearer error msg for newtype GADTs with defaulted kind
    
    When a newtype introduces GADT eq_specs due to a defaulted
    RuntimeRep, we detect this and print the error message with
    explicit kinds.
    
    This also refactors newtype type checking to use the new
    diagnostic infra.
    
    Fixes #21447
    
    - - - - -
    43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00
    Add standard Unicode case predicates isUpperCase and isLowerCase.
    
    These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower.
    
    Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403.
    
    Fixes #14589
    
    - - - - -
    aec5a443 by Andrew Lelechenko at 2022-10-14T07:46:21-04:00
    Add type signatures in where-clause of Data.List.permutations
    
    The type of interleave' is very much revealing, otherwise it's extremely tough to decipher.
    
    - - - - -
    ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00
    rts: Use pthread_setname_np correctly on Darwin
    
    As noted in #22206, pthread_setname_np on Darwin only supports
    setting the name of the calling thread. Consequently we must introduce
    a trampoline which first sets the thread name before entering the thread
    entrypoint.
    - - - - -
    8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00
    testsuite: Add test for #22282
    
    This will complement mpickering's more general port of foundation's
    numerical testsuite, providing a test for the specific case found
    in #22282.
    
    - - - - -
    62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00
    ncg/aarch64: Fix sub-word sign extension yet again
    
    In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues
    to do with sign extension in the AArch64 NCG found by ghc/test-primops>.
    However, this patch made a critical error, assuming that getSomeReg
    would allocate a fresh register for the result of its evaluation.
    However, this is not the case as `getSomeReg (CmmReg r) == r`.
    Consequently, any mutation of the register returned by `getSomeReg` may
    have unwanted side-effects on other expressions also mentioning `r`. In
    the fix listed above, this manifested as the registers containing the
    operands of binary arithmetic operations being incorrectly
    sign-extended. This resulted in #22282.
    
    Sadly, the rather simple structure of the tests generated
    by `test-primops` meant that this particular case was not exercised.
    Even more surprisingly, none of our testsuite caught this case.
    
    Here we fix this by ensuring that intermediate sign extension is
    performed in a fresh register.
    
    Fixes #22282.
    
    - - - - -
    54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00
    rts: ensure we are below maxHeapSize after returning megablocks
    
    When the heap is heavily block fragmented the live byte size might be
    low while the memory usage is high. We want to ensure that heap overflow
    triggers in these cases.
    
    We do so by checking that we can return enough megablocks to
    under maxHeapSize at the end of GC.
    
    - - - - -
    29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00
    rts: trigger a major collection if megablock usage exceeds maxHeapSize
    
    When the heap is suffering from block fragmentation, live bytes might be
    low while megablock usage is high.
    
    If megablock usage exceeds maxHeapSize, we want to trigger a major GC to
    try to recover some memory otherwise we will die from a heapOverflow at
    the end of the GC.
    
    Fixes #21927
    
    - - - - -
    4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00
    Add realease note for #21927
    
    - - - - -
    c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00
    DmdAnal: Look through unfoldings of DataCon wrappers (#22241)
    
    Previously, the demand signature we computed upfront for a DataCon wrapper
    
    lacked boxity information and was much less precise than the demand transformer
    
    for the DataCon worker.
    
    In this patch we adopt the solution to look through unfoldings of DataCon
    
    wrappers during Demand Analysis, but still attach a demand signature for other
    
    passes such as the Simplifier.
    
    See `Note [DmdAnal for DataCon wrappers]` for more details.
    
    Fixes #22241.
    
    - - - - -
    8c72411d by Gergő Érdi at 2022-10-17T19:20:04-04:00
    Add `Enum (Down a)` instance that swaps `succ` and `pred`
    
    See https://github.com/haskell/core-libraries-committee/issues/51 for
    discussion. The key points driving the implementation are the following
    two ideas:
    
    * For the `Int` type, `comparing (complement @Int)` behaves exactly as
      an order-swapping `compare @Int`.
    * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`,
      if only the corner case of starting at the very end is handled specially
    
    - - - - -
    d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00
    Update the check-exact infrastructure to match ghc-exactprint
    
    GHC tests the exact print annotations using the contents of
    utils/check-exact.
    
    The same functionality is provided via
    https://github.com/alanz/ghc-exactprint
    
    The latter was updated to ensure it works with all of the files on
    hackage when 9.2 was released, as well as updated to ensure users of
    the library could work properly (apply-refact, retrie, etc).
    
    This commit brings the changes from ghc-exactprint into
    GHC/utils/check-exact, adapting for the changes to master.
    
    Once it lands, it will form the basis for the 9.4 version of
    ghc-exactprint.
    
    See also discussion around this process at #21355
    
    - - - - -
    08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00
    Avoid allocating intermediate lists for non recursive bindings.
    
    We do so by having an explicit folding function that doesn't need to
    allocate intermediate lists first.
    
    Fixes #22196
    
    - - - - -
    ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00
    Testsuite: Add a new tables_next_to_code predicate.
    
    And use it to avoid T21710a failing on non-tntc archs.
    
    Fixes #22169
    
    - - - - -
    abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00
    example rewrite
    - - - - -
    39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00
    remove redirect
    - - - - -
    0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00
    use heredoc
    - - - - -
    0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00
    testsuite: Fix typo when setting llvm_ways
    
    Since 2014 llvm_ways has been set to [] so none of the tests which use
    only_ways(llvm_ways) have worked as expected.
    
    Hopefully the tests still pass with this typo fix!
    
    - - - - -
    ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00
    Fix T15155l not getting -fllvm
    
    - - - - -
    0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00
    Fix GHCis interaction with tag inference.
    
    I had assumed that wrappers were not inlined in interactive mode.
    Meaning we would always execute the compiled wrapper which properly
    takes care of upholding the strict field invariant.
    This turned out to be wrong. So instead we now run tag inference even
    when we generate bytecode. In that case only for correctness not
    performance reasons although it will be still beneficial for runtime
    in some cases.
    
    I further fixed a bug where GHCi didn't tag nullary constructors
    properly when used as arguments. Which caused segfaults when calling
    into compiled functions which expect the strict field invariant to
    be upheld.
    
    Fixes #22042 and #21083
    
    -------------------------
    Metric Increase:
        T4801
    
    Metric Decrease:
        T13035
    -------------------------
    
    - - - - -
    9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00
    Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions.
    
    - - - - -
    f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00
    configure: Bump minimum bootstrap GHC version
    
    Fixes #22245
    
    - - - - -
    ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00
    Build System: Remove out-of-date comment about make build system
    
    Both make and hadrian interleave compilation of modules of different
    modules and don't respect the package boundaries. Therefore I just
    remove this comment which points out this "difference".
    
    Fixes #22253
    
    - - - - -
    e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00
    Allow configuration of error message printing
    
    This MR implements the idea of #21731 that the printing of a diagnostic
    method should be configurable at the printing time.
    
    The interface of the `Diagnostic` class is modified from:
    
    ```
    class Diagnostic a where
      diagnosticMessage :: a -> DecoratedSDoc
      diagnosticReason  :: a -> DiagnosticReason
      diagnosticHints   :: a -> [GhcHint]
    ```
    
    to
    
    ```
    class Diagnostic a where
      type DiagnosticOpts a
      defaultDiagnosticOpts :: DiagnosticOpts a
      diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
      diagnosticReason  :: a -> DiagnosticReason
      diagnosticHints   :: a -> [GhcHint]
    ```
    
    and so each `Diagnostic` can implement their own configuration record
    which can then be supplied by a client in order to dictate how to print
    out the error message.
    
    At the moment this only allows us to implement #21722 nicely but in
    future it is more natural to separate the configuration of how much
    information we put into an error message and how much we decide to print
    out of it.
    
    Updates Haddock submodule
    
    - - - - -
    99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00
    Add -fsuppress-error-contexts to disable printing error contexts in errors
    
    In many development environments, the source span is the primary means
    of seeing what an error message relates to, and the In the expression:
    and In an equation for: clauses are not particularly relevant. However,
    they can grow to be quite long, which can make the message itself both
    feel overwhelming and interact badly with limited-space areas.
    
    It's simple to implement this flag so we might as well do it and give
    the user control about how they see their messages.
    
    Fixes #21722
    
    - - - - -
    5b3a992f by Dai at 2022-10-19T10:45:45-04:00
    Add VecSlot for unboxed sums of SIMD vectors
    
    This patch adds the missing `VecRep` case to `primRepSlot` function and
    all the necessary machinery to carry this new `VecSlot` through code
    generation. This allows programs involving unboxed sums of SIMD vectors
    to be written and compiled.
    
    Fixes #22187
    
    - - - - -
    6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00
    Remove SIMD conversions
    
    This patch makes it so that packing/unpacking SIMD
    vectors always uses the right sized types, e.g.
    unpacking a Word16X4# will give a tuple of Word16#s.
    
    As a result, we can get rid of the conversion instructions
    that were previously required.
    
    Fixes #22296
    
    - - - - -
    3be48877 by sheaf at 2022-10-19T10:45:45-04:00
    Cmm Lint: relax SIMD register assignment check
    
    As noted in #22297, SIMD vector registers can be used
    to store different kinds of values, e.g. xmm1 can be used
    both to store integer and floating point values.
    The Cmm type system doesn't properly account for this, so
    we weaken the Cmm register assignment lint check to only
    compare widths when comparing a vector type with its
    allocated vector register.
    
    - - - - -
    f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00
    Disable some SIMD tests on non-X86 architectures
    
    - - - - -
    83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00
    Scrub various partiality involving lists (again).
    
    Lets us avoid some use of `head` and `tail`, and some panics.
    
    - - - - -
    c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00
    Enforce invariant of `ListBag` constructor.
    
    - - - - -
    488d3631 by Andrew Lelechenko at 2022-10-19T10:47:52-04:00
    More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg
    
    It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches`
    and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches`
    contains a single instance, but these invariants are immediately lost afterwards
    and not encoded in types. This patch enforces the invariants by pattern matching
    and makes types more precise, avoiding asserts and partial functions such as `head`.
    
    - - - - -
    607ce263 by sheaf at 2022-10-19T10:47:52-04:00
    Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap
    - - - - -
    1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00
    Add SpliceTypes test for hie files
    
    This test checks that typed splices and quotes get the right type
    information when used in hiefiles.
    
    See #21619
    
    - - - - -
    a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00
    Small language fixes in 'Using GHC'
    
    - - - - -
    1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00
    Fix typo in `Opt_WriteIfSimplifiedCore`'s name
    
    - - - - -
    b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00
    TyEq:N assertion: only for saturated applications
    
    The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly
    triggered in the case of an unsaturated newtype TyCon heading the RHS,
    even though we can't unwrap such an application. Now, we only trigger
    an assertion failure in case of a saturated application of a newtype
    TyCon.
    
    Fixes #22310
    
    - - - - -
    ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00
    CoreToStg: purge `DynFlags`.
    
    - - - - -
    1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00
    ci: Make fat014 test robust
    
    For some reason I implemented this as a makefile test rather than a
    ghci_script test. Hopefully making it a ghci_script test makes it more
    robust.
    
    Fixes #22313
    
    - - - - -
    8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00
    remove a no-warn directive from GHC.Cmm.ContFlowOpt
    
    This patch is motivated by the desire to remove the {-# OPTIONS_GHC
    -fno-warn-incomplete-patterns #-} directive at the top of
    GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I
    understand it's a goal of the project to remove such directives.) I
    chose this task because I'm a new contributor to GHC, and it seemed like
    a good way to get acquainted with the patching process.
    
    In order to address the warning that arose when I removed the no-warn
    directive, I added a case to removeUnreachableBlocksProc to handle the
    CmmData constructor. Clearly, since this partial function has not been
    erroring out in the wild, its inputs are always in practice wrapped by
    the CmmProc constructor. Therefore the CmmData case is handled by a
    precise panic (which is an improvement over the partial pattern match
    from before).
    
    - - - - -
    a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00
    build: get rid of `HAVE_TIME_H`
    
    As advertized by `autoreconf`:
    
    > All current systems provide time.h; it need not be checked for.
    
    Hence, remove the check for it in `configure.ac` and remove conditional
    inclusion of the header in `HAVE_TIME_H` blocks where applicable.
    
    The `time.h` header was being included in various source files without a
    `HAVE_TIME_H` guard already anyway.
    
    - - - - -
    25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00
    rts: remove use of `TIME_WITH_SYS_TIME`
    
    `autoreconf` will insert an `m4_warning` when the obsolescent
    `AC_HEADER_TIME` macro is used:
    
    > Update your code to rely only on HAVE_SYS_TIME_H,
    > then remove this warning and the obsolete code below it.
    > All current systems provide time.h; it need not be checked for.
    > Not all systems provide sys/time.h, but those that do, all allow
    > you to include it and time.h simultaneously.
    
    Presence of `sys/time.h` was already checked in an earlier
    `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and
    guards relying on `TIME_WITH_SYS_TIME` can be reworked to
    (unconditionally) include `time.h` and include `sys/time.h` based on
    `HAVE_SYS_TIME_H`.
    
    Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67
    says
    
    > This macro is obsolescent, as current systems can include both files
    > when they exist. New programs need not use this macro.
    
    - - - - -
    1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00
    runhaskell
    - - - - -
    e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00
    Document how to quote certain names with spaces
    
    Quoting a name for Template Haskell is a bit tricky if the second
    character of that name is a single quote. The User's Guide falsely
    claimed that it was impossible. Document how to do it.
    
    Fixes #22236
    - - - - -
    0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00
    Fix syntax
    - - - - -
    a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00
    Fix manifest filename when writing Windows .rc files
    
    As noted in #12971, we previously used `show` which resulted in
    inappropriate escaping of non-ASCII characters.
    
    - - - - -
    30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00
    Write response files in UTF-8 on Windows
    
    This reverts the workaround introduced in
    f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file
    logic to write response files with the `latin1` encoding to workaround
    `gcc`'s lacking Unicode support. This is now no longer necessary (and in
    fact actively unhelpful) since we rather use Clang.
    
    - - - - -
    b8304648 by Matthew Farkas-Dyck at 2022-10-21T09:11:56-04:00
    Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`.
    
    - - - - -
    09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00
    template-haskell: Improve documentation of strictness annotation types
    
    Before it was undocumentated that DecidedLazy can be returned by
    reifyConStrictness for strict fields. This can happen when a field has
    an unlifted type or its the single field of a newtype constructor.
    
    Fixes #21380
    
    - - - - -
    88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00
    Delete `eqExpr`, since GHC 9.4 has been released.
    
    - - - - -
    86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00
    Introduce a standard thunk for allocating strings
    
    Currently for a top-level closure in the form
    
        hey = unpackCString# x
    
    we generate code like this:
    
        Main.hey_entry() //  [R1]
                 { info_tbls: [(c2T4,
                                label: Main.hey_info
                                rep: HeapRep static { Thunk }
                                srt: Nothing)]
                   stack_info: arg_space: 8 updfr_space: Just 8
                 }
             {offset
               c2T4: // global
                   _rqm::P64 = R1;
                   if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6;
               c2T5: // global
                   R1 = _rqm::P64;
                   call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8;
               c2T6: // global
                   (_c2T1::I64) = call "ccall" arg hints:  [PtrHint,
                                                            PtrHint]  result hints:  [PtrHint] newCAF(BaseReg, _rqm::P64);
                   if (_c2T1::I64 == 0) goto c2T3; else goto c2T2;
               c2T3: // global
                   call (I64[_rqm::P64])() args: 8, res: 0, upd: 8;
               c2T2: // global
                   I64[Sp - 16] = stg_bh_upd_frame_info;
                   I64[Sp - 8] = _c2T1::I64;
                   R2 = hey1_r2Gg_bytes;
                   Sp = Sp - 16;
                   call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24;
             }
         }
    
    This code is generated for every string literal. Only difference between
    top-level closures like this is the argument for the bytes of the string
    (hey1_r2Gg_bytes in the code above).
    
    With this patch we introduce a standard thunk in the RTS, called
    stg_MK_STRING_info, that does what `unpackCString# x` does, except it
    gets the bytes address from the payload. Using this, for the closure
    above, we generate this:
    
        Main.hey_closure" {
            Main.hey_closure:
                const stg_MK_STRING_info;
                const 0; // padding for indirectee
                const 0; // static link
                const 0; // saved info
                const hey1_r1Gg_bytes; // the payload
        }
    
    This is much smaller in code.
    
    Metric Decrease:
        T10421
        T11195
        T12150
        T12425
        T16577
        T18282
        T18698a
        T18698b
    
    Co-Authored By: Ben Gamari <ben at well-typed.com>
    
    - - - - -
    1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00
    hadrian: Improve error for wrong key/value errors.
    
    - - - - -
    11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00
    Class layout info (#19623)
    
    Updates the haddock submodule.
    
    - - - - -
    f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00
    Pin used way for test cloneMyStack (#21977)
    
    cloneMyStack checks the order of closures on the cloned stack. This may
    change for different ways. Thus we limit this test to one way (normal).
    
    - - - - -
    0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00
    Convert Diagnostics in GHC.Tc.Gen.Splice (#20116)
    
    Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with
    structured diagnostics.
    
    closes #20116
    
    - - - - -
    8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00
    Improve stg lint for unboxed sums.
    
    It now properly lints cases where sums end up distributed
    over multiple args after unarise.
    
    Fixes #22026.
    
    - - - - -
    41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00
    Fix binder-swap bug
    
    This patch fixes #21229 properly, by avoiding doing a
    binder-swap on dictionary Ids.  This is pretty subtle, and explained
    in Note [Care with binder-swap on dictionaries].
    
    Test is already in simplCore/should_run/T21229
    
    This allows us to restore a feature to the specialiser that we had
    to revert: see Note [Specialising polymorphic dictionaries].
    (This is done in a separate patch.)
    
    I also modularised things, using a new function scrutBinderSwap_maybe
    in all the places where we are (effectively) doing a binder-swap,
    notably
    
    * Simplify.Iteration.addAltUnfoldings
    * SpecConstr.extendCaseBndrs
    
    In Simplify.Iteration.addAltUnfoldings I also eliminated a guard
        Many <- idMult case_bndr
    because we concluded, in #22123, that it was doing no good.
    
    - - - - -
    5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00
    Make the specialiser handle polymorphic specialisation
    
    Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a
    program run (a lot) slower, because less specialisation took place
    overall. It turned out that the specialiser was missing opportunities
    because of quantified type variables.
    
    It was quite easy to fix. The story is given in
        Note [Specialising polymorphic dictionaries]
    
    Two other minor fixes in the specialiser
    
    * There is no benefit in specialising data constructor /wrappers/.
      (They can appear overloaded because they are given a dictionary
      to store in the constructor.)  Small guard in canSpecImport.
    
    * There was a buglet in the UnspecArg case of specHeader, in the
      case where there is a dead binder. We need a LitRubbish filler
      for the specUnfolding stuff.  I expanded
      Note [Drop dead args from specialisations] to explain.
    
    There is a 4% increase in compile time for T15164, because we generate
    more specialised code.  This seems OK.
    
    Metric Increase:
        T15164
    
    - - - - -
    7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00
    Numeric exceptions: replace FFI calls with primops
    
    ghc-bignum needs a way to raise numerical exceptions defined in base
    package. At the time we used FFI calls into primops defined in the RTS.
    These FFI calls had to be wrapped into hacky bottoming functions because
    "foreign import prim" syntax doesn't support giving a bottoming demand
    to the foreign call (cf #16929).
    
    These hacky wrapper functions trip up the JavaScript backend (#21078)
    because they are polymorphic in their return type. This commit
    replaces them with primops very similar to raise# but raising predefined
    exceptions.
    
    - - - - -
    0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00
    Enable popcount rewrite rule when cross-compiling
    
    The comment applies only when host's word size < target's word size.
    So we can relax the guard.
    
    - - - - -
    a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00
    Add GHC.SysTools.Cpp module
    
    Move doCpp out of the driver to be able to use it in the upcoming JS backend.
    
    - - - - -
    1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00
    llvm-targets: Add datalayouts for big-endian AArch64 targets
    
    Fixes #22311.
    
    Thanks to @zeldin for the patch.
    
    - - - - -
    f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00
    Cleanup String/FastString conversions
    
    Remove unused mkPtrString and isUnderscoreFS.
    We no longer use mkPtrString since 1d03d8bef96.
    
    Remove unnecessary conversions between FastString and String and back.
    
    - - - - -
    f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00
    Broaden the in-scope sets for liftEnvSubst and composeTCvSubst
    
    This patch fixes two distinct (but closely related) buglets that were uncovered
    in #22235:
    
    * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover
      the variables in the range of the substitution. This patch fixes this by
      populating the in-scope set from the free variables in the range of the
      substitution.
    * `composeTCvSubst` applied the first substitution argument to the range of the
      second substitution argument, but the first substitution's in-scope set was
      not wide enough to cover the range of the second substutition. We similarly
      fix this issue in this patch by widening the first substitution's in-scope set
      before applying it.
    
    Fixes #22235.
    
    - - - - -
    0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00
    Introduce TcRnWithHsDocContext (#22346)
    
    Before this patch, GHC used withHsDocContext to attach an HsDocContext
    to an error message:
    
    	addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg)
    
    The problem with this approach is that it only works with
    TcRnUnknownMessage. But could we attach an HsDocContext to a
    structured error message in a generic way? This patch solves
    the problem by introducing a new constructor to TcRnMessage:
    
    	data TcRnMessage where
    	  ...
    	  TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage
    	  ...
    
    - - - - -
    9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00
    Testsuite: more precise test options
    
    Necessary for newer cross-compiling backends (JS, Wasm) that don't
    support TH yet.
    
    - - - - -
    f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00
    Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115)
    
    When faced with VDQ in the type of a term, GHC generates the following
    error message:
    
    	Illegal visible, dependent quantification in the type of a term
    	(GHC does not yet support this)
    
    Prior to this patch, there were two ways this message could have been
    generated and represented:
    
    	1. with the dedicated constructor TcRnVDQInTermType
    	    (see check_type in GHC.Tc.Validity)
    	2. with the transitional constructor TcRnUnknownMessage
    	    (see noNestedForallsContextsErr in GHC.Rename.Utils)
    
    Not only this led to duplication of code generating the final SDoc,
    it also made it tricky to track the origin of the error message.
    
    This patch fixes the problem by using TcRnVDQInTermType exclusively.
    
    - - - - -
    223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00
    Remove source location information from interface files
    
    This change aims to minimize source location information leaking
    into interface files, which makes ABI hashes dependent on the
    build location.
    
    The `Binary (Located a)` instance has been removed completely.
    
    It seems that the HIE interface still needs the ability to
    serialize SrcSpans, but by wrapping the instances, it should
    be a lot more difficult to inadvertently add source location
    information.
    
    - - - - -
    22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00
    Add missing dict binds to specialiser
    
    I had forgotten to add the auxiliary dict bindings to the
    /unfolding/ of a specialised function.  This caused #22358,
    which reports failures when compiling Hackage packages
         fixed-vector
         indexed-traversable
    
    Regression test T22357 is snarfed from indexed-traversable
    
    - - - - -
    a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00
    Fix broken link to `async` package
    
    - - - - -
    750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00
    Pass correct package db when testing stage1.
    
    It used to pick the db for stage-2 which obviously didn't work.
    
    - - - - -
    ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00
    Minor SDoc-related cleanup
    
    * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel
      for a function using CStyle (analogous to pprAsmLabel)
    * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable.
    * Move calls to 'text' right next to literals, to make sure the text/str
      rule is triggered.
    * Remove FastString/String roundtrip in Tc.Deriv.Generate
    * Introduce showSDocForUser', which abstracts over a pattern in
      GHCi.UI
    
    - - - - -
    c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00
    CI: Don't run lint-submods on nightly
    
    Fixes #22325
    
    - - - - -
    270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00
    Start the deprecation process for GHC.Pack
    
    - - - - -
    d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00
    Drop a kludge for binutils<2.17, which is now over 10 years old.
    
    - - - - -
    8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
    rts: `name` argument of `createOSThread` can be `const`
    
    Since we don't intend to ever change the incoming string, declare this
    to be true.
    
    Also, in the POSIX implementation, the argument is no longer `STG_UNUSED`
    (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path.
    
    See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080
    
    - - - - -
    13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
    rts: fix lifetime of `start_thread`s `name` value
    
    Since, unlike the code in ee0deb8054da2^, usage of the `name` value
    passed to `createOSThread` now outlives said function's lifetime, and
    could hence be released by the caller by the time the new thread runs
    `start_thread`, it needs to be copied.
    
    See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080
    See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066
    
    - - - - -
    edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
    rts: fix OS thread naming in ticker
    
    Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed
    when invoking `createOSThread`. However, the 'ticker' has some
    thread-creation code which doesn't rely on `createOSThread`, yet also
    uses `pthread_setname_np`.
    
    This patch enforces all thread creation to go through a single
    function, which uses the (correct) thread-naming code introduced in
    ee0deb805.
    
    See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206
    See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066
    
    - - - - -
    b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00
    Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core
    
    - - - - -
    30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00
    ThToHs: fix overzealous parenthesization
    
    Before this patch, when converting from TH.Exp to LHsExpr GhcPs,
    the compiler inserted more parentheses than required:
    
    	((f a) (b + c)) d
    
    This was happening because the LHS of the function application was
    parenthesized as if it was the RHS.
    
    Now we use funPrec and appPrec appropriately and produce sensibly
    parenthesized expressions:
    
    	f a (b + c) d
    
    I also took the opportunity to remove the special case for LamE,
    which was not special at all and simply duplicated code.
    
    - - - - -
    0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00
    Add accurate skolem info when quantifying
    
    Ticket #22379 revealed that skolemiseQuantifiedTyVar was
    dropping the passed-in skol_info on the floor when it encountered
    a SkolemTv.  Bad!  Several TyCons thereby share a single SkolemInfo
    on their binders, which lead to bogus error reports.
    
    - - - - -
    38d19668 by Fendor at 2022-11-01T12:50:25-04:00
    Expose UnitEnvGraphKey for user-code
    
    - - - - -
    77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00
    Shrink test case for #22357
    
    Ryan Scott offered a cut-down repro case
    (60 lines instead of more than 700 lines)
    
    - - - - -
    4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00
    Add two tests for #17366
    
    - - - - -
    6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: introduce (and use) `STG_NORETURN`
    
    Instead of sprinkling the codebase with
    `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for,
    basically, the same thing) similar to `STG_UNUSED` and others, and
    update the code to use this macro where applicable.
    
    - - - - -
    f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: consistently use `STG_UNUSED`
    
    - - - - -
    81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: introduce (and use) `STG_USED`
    
    Similar to `STG_UNUSED`, have a specific macro for
    `__attribute__(used)`.
    
    - - - - -
    41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: introduce (and use) `STG_MALLOC`
    
    Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC`
    macro definition and use it instead.
    
    - - - - -
    3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: use `STG_UNUSED`
    
    - - - - -
    9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: specify deallocator of allocating functions
    
    This patch adds a new `STG_MALLOC1` macro (and its counterpart
    `STG_MALLOC2` for completeness) which allows to specify the deallocation
    function to be used with allocations of allocating functions, and
    applies it to `stg*allocBytes`.
    
    It also fixes a case where `free` was used to free up an
    `stgMallocBytes` allocation, found by the above change.
    
    See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
    
    - - - - -
    81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: use `alloc_size` attribute
    
    This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which
    allow to set the `alloc_size` attribute on functions, when available.
    
    See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
    
    - - - - -
    99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: add and use `STG_RETURNS_NONNULL`
    
    See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
    
    - - - - -
    c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
    rts: tag `stgStrndup` as `STG_MALLOC`
    
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
    
    - - - - -
    ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00
    Move Symbol implementation note out of public haddock
    
    - - - - -
    284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00
    gen-dll: Drop it
    
    Currently it is only used by the make build system, which is soon to be
    retired, and it has not built since 41cf758b. We may need to reintroduce
    it when dynamic-linking support is introduced on Windows, but we will
    cross that bridge once we get there.
    
    Fixes #21753.
    
    - - - - -
    24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00
    Port foundation numeric tests to GHC testsuite
    
    This commit ports the numeric tests which found a regression in GHC-9.4.
    
    https://github.com/haskell-foundation/foundation/issues/571
    
    Included in the commit is a simple random number generator and
    simplified QuickCheck implementation. In future these could be factored
    out of this standalone file and reused as a general purpose library
    which could be used for other QuickCheck style tests in the testsuite.
    
    See #22282
    
    - - - - -
    d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00
    git: ignore HIE files.
    
    Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci.
    
    - - - - -
    a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00
    Clarify status of bindings in WholeCoreBindings
    
    Gergo points out that these bindings are tidied, rather than prepd as
    the variable claims. Therefore we update the name of the variable to
    reflect reality and add a comment to the data type to try to erase any
    future confusion.
    
    Fixes #22307
    
    - - - - -
    634da448 by Andrew Lelechenko at 2022-11-03T21:25:02+00:00
    Fix haddocks for GHC.IORef
    
    - - - - -
    31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00
    Export pprTrace and friends from GHC.Prelude.
    
    Introduces GHC.Prelude.Basic which can be used in modules which are a
    dependency of the ppr code.
    
    - - - - -
    bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00
    CI: Allow hadrian-ghc-in-ghci to run in nightlies
    
    Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs
    to mark it as "optional" so it can run if the job doesn't exist.
    
    Fixes #22396.
    
    - - - - -
    3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00
    Minor refactor around FastStrings
    
    Pass FastStrings to functions directly, to make sure the rule
    for fsLit "literal" fires.
    
    Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph.
    
    - - - - -
    e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00
    Bump unix submodule to 2.8.0.0
    
    Also bumps process and ghc-boot bounds on unix.
    
    For hadrian, when cross-compiling, we add -Wwarn=unused-imports
    -Wwarn=unused-top-binds to validation flavour. Further fixes in unix
    and/or hsc2hs is needed to make it completely free of warnings; for
    the time being, this change is needed to unblock other
    cross-compilation related work.
    
    - - - - -
    42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00
    Bump Win32 submodule to 2.13.4.0
    
    Fixes #22098
    
    - - - - -
    e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00
    Bump ci-images revision
    
    ci-images has recently been updated, including changes needed for wasm32-wasi CI.
    
    - - - - -
    88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00
    Bump gmp-tarballs submodule
    
    Includes a fix for wasm support, doesn't impact other targets.
    
    - - - - -
    69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00
    Bump haskeline submodule
    
    Includes a fix for wasm support, doesn't impact other targets.
    
    - - - - -
    5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00
    bump llvm upper bound
    - - - - -
    68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00
    Define `Infinite` list and use where appropriate.
    
    Also add perf test for infinite list fusion.
    
    In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names.
    
    Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists].
    
    - - - - -
    ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00
    Fix TypeData issues (fixes #22315 and #22332)
    
    There were two bugs here:
    
    1. Treating type-level constructors as PromotedDataCon doesn't always
       work, in particular because constructors promoted via DataKinds are
       called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b)
       Fix: guard these cases with isDataKindsPromotedDataCon.
    
    2. Type-level constructors were sent to the code generator, producing
       things like constructor wrappers. (Tests T22332a, T22332b)
       Fix: test for them in isDataTyCon.
    
    Other changes:
    
    * changed the marking of "type data" DataCon's as suggested by SPJ.
    
    * added a test TDGADT for a type-level GADT.
    
    * comment tweaks
    
    * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo
      is used only for pretty printing, not for typechecking. (SPJ)
    
    - - - - -
    132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00
    Clarify msum/asum documentation
    
    - - - - -
    bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00
    Add example for (<$)
    
    - - - - -
    080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00
    Document what Alternative/MonadPlus instances actually do
    
    - - - - -
    92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00
    Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117)
    
    The following `TcRnDiagnostic` messages have been introduced:
    
    TcRnWarnUnsatisfiedMinimalDefinition
    TcRnMisplacedInstSig
    TcRnBadBootFamInstDeclErr
    TcRnIllegalFamilyInstance
    TcRnAssocInClassErr
    TcRnBadFamInstDecl
    TcRnNotOpenFamily
    
    - - - - -
    90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00
    GHCi tags generation phase 2
    
    see #19884
    
    - - - - -
    f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00
    Fire RULES in the Specialiser
    
    The Specialiser has, for some time, fires class-op RULES in the
    specialiser itself: see
       Note [Specialisation modulo dictionary selectors]
    
    This MR beefs it up a bit, so that it fires /all/ RULES in the
    specialiser, not just class-op rules.  See
       Note [Fire rules in the specialiser]
    The result is a bit more specialisation; see test
       simplCore/should_compile/T21851_2
    
    This pushed me into a bit of refactoring.  I made a new data types
    GHC.Core.Rules.RuleEnv, which combines
      - the several source of rules (local, home-package, external)
      - the orphan-module dependencies
    
    in a single record for `getRules` to consult.  That drove a bunch of
    follow-on refactoring, including allowing me to remove
    cr_visible_orphan_mods from the CoreReader data type.
    
    I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule.
    
    The reorganisation in the Simplifier improve compile times a bit
    (geom mean -0.1%), but T9961 is an outlier
    
    Metric Decrease:
        T9961
    
    - - - - -
    2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00
    Make indexError work better
    
    The problem here is described at some length in
    Note [Boxity for bottoming functions] and
    Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal.
    
    This patch adds a SPECIALISE pragma for indexError, which
    makes it much less vulnerable to the problem described in
    these Notes.
    
    (This came up in another line of work, where a small change made
    indexError do reboxing (in nofib/spectral/simple/table_sort)
    that didn't happen before my change.  I've opened #22404
    to document the fagility.
    
    - - - - -
    399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00
    Fix DsUselessSpecialiseForClassMethodSelector msg
    
    The error message for DsUselessSpecialiseForClassMethodSelector
    was just wrong (a typo in some earlier work); trivial fix
    
    - - - - -
    dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00
    WorkWrap: Unboxing unboxed tuples is not always useful (#22388)
    
    See Note [Unboxing through unboxed tuples].
    
    Fixes #22388.
    
    - - - - -
    1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00
    Boxity: Handle argument budget of unboxed tuples correctly (#21737)
    
    Now Budget roughly tracks the combined width of all arguments after unarisation.
    See the changes to `Note [Worker argument budgets]`.
    
    Fixes #21737.
    
    - - - - -
    2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00
    autoconf: check getpid getuid raise
    
    This patch adds checks for getpid, getuid and raise in autoconf. These
    functions are absent in wasm32-wasi and thus needs to be checked.
    
    - - - - -
    f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00
    hadrian: add -Wwarn only for cross-compiling unix
    
    - - - - -
    2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00
    hadrian: add targetSupportsThreadedRts flag
    
    This patch adds a targetSupportsThreadedRts flag to indicate whether
    the target supports the threaded rts at all, different from existing
    targetSupportsSMP that checks whether -N is supported by the RTS. All
    existing flavours have also been updated accordingly to respect this
    flags.
    
    Some targets (e.g. wasm32-wasi) does not support the threaded rts,
    therefore this flag is needed for the default flavours to work. It
    makes more sense to have proper autoconf logic to check for threading
    support, but for the time being, we just set the flag to False iff the
    target is wasm32.
    
    - - - - -
    8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00
    Fix Cmm symbol kind
    
    - - - - -
    b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00
    add the two key graph modules from Martin Erwig's FGL
    
    Martin Erwig's FGL (Functional Graph Library) provides an "inductive"
    representation of graphs.  A general graph has labeled nodes and
    labeled edges.  The key operation on a graph is to decompose it by
    removing one node, together with the edges that connect the node to
    the rest of the graph.  There is also an inverse composition
    operation.
    
    The decomposition and composition operations make this representation
    of graphs exceptionally well suited to implement graph algorithms in
    which the graph is continually changing, as alluded to in #21259.
    
    This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the
    interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides
    an implementation.  Both modules are taken from `fgl-5.7.0.3` on
    Hackage, with these changes:
    
      - Copyright and license text have been copied into the files
        themselves, not stored separately.
    
      - Some calls to `error` have been replaced with calls to `panic`.
    
      - Conditional-compilation support for older versions of GHC,
        `containers`, and `base` has been removed.
    
    - - - - -
    3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00
    add new modules for reducibility and WebAssembly translation
    
    - - - - -
    df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00
    Add support for the wasm32-wasi target tuple
    
    This patch adds the wasm32-wasi tuple support to various places in the
    tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen
    logic will come in subsequent commits.
    
    - - - - -
    32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00
    deriveConstants: parse .ll output for wasm32 due to broken nm
    
    This patch makes deriveConstants emit and parse an .ll file when
    targeting wasm. It's a necessary workaround for broken llvm-nm on
    wasm, which isn't capable of reporting correct constant values when
    parsing an object.
    
    - - - - -
    07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking
    
    Unlike other targets, wasm requires the function signature of the call
    site and callee to strictly match. So in Cmm, when we call a C
    function that actually returns a value, we need to add an _unused
    local variable to receive it, otherwise type error awaits.
    
    An even bigger problem is calling variadic functions like barf() and
    such. Cmm doesn't support CAPI calling convention yet, so calls to
    variadic functions just happen to work in some cases with some
    target's ABI. But again, it doesn't work with wasm. Fortunately, the
    wasm C ABI lowers varargs to a stack pointer argument, and it can be
    passed NULL when no other arguments are expected to be passed. So we
    also add the additional unused NULL arguments to those functions, so
    to fix wasm, while not affecting behavior on other targets.
    
    - - - - -
    00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00
    testsuite: correct sleep() signature in T5611
    
    In libc, sleep() returns an integer. The ccall type signature should
    match the libc definition, otherwise it causes linker error on wasm.
    
    - - - - -
    d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: prefer ffi_type_void over FFI_TYPE_VOID
    
    This patch uses ffi_type_void instead of FFI_TYPE_VOID in the
    interpreter code, since the FFI_TYPE_* macros are not available in
    libffi-wasm32 yet. The libffi public documentation also only mentions
    the lower-case ffi_type_* symbols, so we should prefer the lower-case
    API here.
    
    - - - - -
    4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: don't define RTS_USER_SIGNALS when signal.h is not present
    
    In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related
    logic is guarded with RTS_USER_SIGNALS. This patch extends the range
    of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff
    signal.h is actually detected by autoconf. This is required for
    wasm32-wasi to work, which lacks signals.
    
    - - - - -
    3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: use HAVE_GETPID to guard subprocess related logic
    
    We've previously added detection of getpid() in autoconf. This patch
    uses HAVE_GETPID to guard some subprocess related logic in the RTS.
    This is required for certain targets like wasm32-wasi, where there
    isn't a process model at all.
    
    - - - - -
    50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined
    
    This patch adds the missing THREADED_RTS CPP guard to mutex logic in
    IPE.c.
    
    - - - - -
    ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: genericRaise: use exit() instead when not HAVE_RAISE
    
    We check existence of raise() in autoconf, and here, if not
    HAVE_RAISE, we should use exit() instead in genericRaise.
    
    - - - - -
    c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: checkSuid: don't do it when not HAVE_GETUID
    
    When getuid() is not present, don't do checkSuid since it doesn't make
    sense anyway on that target.
    
    - - - - -
    d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: wasm32 placeholder linker
    
    This patch adds minimal placeholder linker logic for wasm32, just
    enough to unblock compiling rts on wasm32. RTS linker functionality is
    not properly implemented yet for wasm32.
    
    - - - - -
    65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: RtsStartup: chdir to PWD on wasm32
    
    This patch adds a wasm32-specific behavior to RtsStartup logic. When
    the PWD environment variable is present, we chdir() to it first.
    
    The point is to workaround an issue in wasi-libc: it's currently not
    possible to specify the initial working directory, it always defaults
    to / (in the virtual filesystem mapped from some host directory). For
    some use cases this is sufficient, but there are some other cases
    (e.g. in the testsuite) where the program needs to access files
    outside.
    
    - - - - -
    65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: no timer for wasm32
    
    Due to the lack of threads, on wasm32 there can't be a background
    timer that periodically resets the context switch flag. This patch
    disables timer for wasm32, and also makes the scheduler default to -C0
    on wasm32 to avoid starving threads.
    
    - - - - -
    e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32
    
    The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32.
    
    - - - - -
    0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32
    
    On wasm32 there isn't a process model at all, so no
    FORKPROCESS_PRIMOP_SUPPORTED.
    
    - - - - -
    88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32
    
    libffi-wasm32 only supports non-standard libffi closure api via
    ffi_alloc_prep_closure(). This patch implements
    ffi_alloc_prep_closure() via standard libffi closure api on other
    targets, and uses it to implement adjustor functionality.
    
    - - - - -
    15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: don't return memory to OS on wasm32
    
    This patch makes the storage manager not return any memory on wasm32.
    The detailed reason is described in Note [Megablock allocator on
    wasm].
    
    - - - - -
    631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: make flushExec a no-op on wasm32
    
    This patch makes flushExec a no-op on wasm32, since there's no such
    thing as executable memory on wasm32 in the first place.
    
    - - - - -
    654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32
    
    This patch prevents resetTerminalSettings and freeThreadingResources
    to be called on wasm32, since there is no TTY or threading on wasm32
    at all.
    
    - - - - -
    f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: OSThreads.h: stub types for wasm32
    
    This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey
    types for wasm32, just enough to unblock compiling RTS. Any
    threading-related functionality has been patched to be disabled on
    wasm32.
    
    - - - - -
    a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00
    Add register mapping for wasm32
    
    This patch adds register mapping logic for wasm32. See Note [Register
    mapping on WebAssembly] in wasm32 NCG for more description.
    
    - - - - -
    d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00
    rts: wasm32 specific logic
    
    This patch adds the rest of wasm32 specific logic in rts.
    
    - - - - -
    7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00
    base: fall back to using monotonic clock to emulate cputime on wasm32
    
    On wasm32, we have to fall back to using monotonic clock to emulate
    cputime, since there's no native support for cputime as a clock id.
    
    - - - - -
    5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00
    base: more autoconf checks for wasm32
    
    This patch adds more autoconf checks to base, since those functions
    and headers may exist on other POSIX systems but don't exist on
    wasm32.
    
    - - - - -
    00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00
    base: avoid using unsupported posix functionality on wasm32
    
    This base patch avoids using unsupported posix functionality on
    wasm32.
    
    - - - - -
    34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00
    autoconf: set CrossCompiling=YES in cross bindist configure
    
    This patch fixes the bindist autoconf logic to properly set
    CrossCompiling=YES when it's a cross GHC bindist.
    
    - - - - -
    5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: add util functions for UniqFM and UniqMap
    
    This patch adds addToUFM_L (backed by insertLookupWithKey),
    addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util
    functions are used by the wasm32 NCG.
    
    - - - - -
    177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00
    driver: avoid -Wl,--no-as-needed for wasm32
    
    The driver used to pass -Wl,--no-as-needed for LLD linking. This is
    actually only supported for ELF targets, and must be avoided when
    linking for wasm32.
    
    - - - - -
    06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: allow big arith for wasm32
    
    This patch enables Cmm big arithmetic on wasm32, since 64-bit
    arithmetic can be efficiently lowered to wasm32 opcodes.
    
    - - - - -
    df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00
    driver: pass -Wa,--no-type-check for wasm32 when runAsPhase
    
    This patch passes -Wa,--no-type-check for wasm32 when compiling
    assembly. See the added note for more detailed explanation.
    
    - - - - -
    c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: enforce cmm switch planning for wasm32
    
    This patch forcibly enable Cmm switch planning for wasm32, since
    otherwise the switch tables we generate may exceed the br_table
    maximum allowed size.
    
    - - - - -
    a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: annotate CmmFileEmbed with blob length
    
    This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG
    needs to know the precise size of each data segment.
    
    - - - - -
    36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00
    compiler: wasm32 NCG
    
    This patch adds the wasm32 NCG.
    
    - - - - -
    435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00
    ci: add wasm32-wasi release bindist job
    
    - - - - -
    d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00
    ci: add a stronger test for cross bindists
    
    This commit adds a simple GHC API program that parses and reprints the
    original hello world program used for basic testing of cross bindists.
    Before there's full cross-compilation support in the test suite
    driver, this provides better coverage than the original test.
    
    - - - - -
    8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00
    CODEOWNERS: add wasm-specific maintainers
    
    - - - - -
    707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00
    Clarify that LLVM upper bound is non-inclusive during configure (#22411)
    
    - - - - -
    430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00
    rts: Check for program_invocation_short_name via autoconf
    
    Instead of assuming support on all Linuxes.
    
    - - - - -
    6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00
    driver: Fix -fdefer-diagnostics flag
    
    The `withDeferredDiagnostics` wrapper wasn't doing anything because the
    session it was modifying wasn't used in hsc_env. Therefore the fix is
    simple, just push the `getSession` call into the scope of
    `withDeferredDiagnostics`.
    
    Fixes #22391
    
    - - - - -
    d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00
    Add a fast path for data constructor workers
    
    See Note [Fast path for data constructors] in
    GHC.Core.Opt.Simplify.Iteration
    
    This bypasses lots of expensive logic, in the special case of
    applications of data constructors.  It is a surprisingly worthwhile
    improvement, as you can see in the figures below.
    
    Metrics: compile_time/bytes allocated
    ------------------------------------------------
              CoOpt_Read(normal)   -2.0%
        CoOpt_Singletons(normal)   -2.0%
        ManyConstructors(normal)   -1.3%
                  T10421(normal)   -1.9% GOOD
                 T10421a(normal)   -1.5%
                  T10858(normal)   -1.6%
                  T11545(normal)   -1.7%
                  T12234(optasm)   -1.3%
                  T12425(optasm)   -1.9% GOOD
                  T13035(normal)   -1.0% GOOD
                  T13056(optasm)   -1.8%
                  T13253(normal)   -3.3% GOOD
                  T15164(normal)   -1.7%
                  T15304(normal)   -3.4%
                  T15630(normal)   -2.8%
                  T16577(normal)   -4.3% GOOD
                  T17096(normal)   -1.1%
                  T17516(normal)   -3.1%
                  T18282(normal)   -1.9%
                  T18304(normal)   -1.2%
                 T18698a(normal)   -1.2% GOOD
                 T18698b(normal)   -1.5% GOOD
                  T18923(normal)   -1.3%
                   T1969(normal)   -1.3% GOOD
                  T19695(normal)   -4.4% GOOD
                 T21839c(normal)   -2.7% GOOD
                 T21839r(normal)   -2.7% GOOD
                   T4801(normal)   -3.8% GOOD
                   T5642(normal)   -3.1% GOOD
                   T6048(optasm)   -2.5% GOOD
                   T9020(optasm)   -2.7% GOOD
                   T9630(normal)   -2.1% GOOD
                   T9961(normal)  -11.7% GOOD
                   WWRec(normal)   -1.0%
    
                       geo. mean   -1.1%
                       minimum    -11.7%
                       maximum     +0.1%
    
    Metric Decrease:
        T10421
        T12425
        T13035
        T13253
        T16577
        T18698a
        T18698b
        T1969
        T19695
        T21839c
        T21839r
        T4801
        T5642
        T6048
        T9020
        T9630
        T9961
    
    - - - - -
    3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00
    Use a more efficient printer for code generation (#21853)
    
    The changes in `GHC.Utils.Outputable` are the bulk of the patch
    and drive the rest.
    The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc`
    and support printing directly to a handle with `bPutHDoc`.
    See Note [SDoc versus HDoc] and Note [HLine versus HDoc].
    
    The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic
    over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF
    and dependencies (printing module names, labels etc.).
    
    Co-authored-by: Alexis King <lexi.lambda at gmail.com>
    
    Metric Decrease:
        CoOpt_Read
        ManyAlternatives
        ManyConstructors
        T10421
        T12425
        T12707
        T13035
        T13056
        T13253
        T13379
        T18140
        T18282
        T18698a
        T18698b
        T1969
        T20049
        T21839c
        T21839r
        T3064
        T3294
        T4801
        T5321FD
        T5321Fun
        T5631
        T6048
        T783
        T9198
        T9233
    
    - - - - -
    6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00
    Weaken wrinkle 1 of Note [Scrutinee Constant Folding]
    
    Fixes #22375.
    
    Co-authored-by:  Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00
    Fix fragile RULE setup in GHC.Float
    
    In testing my type-vs-constraint patch I found that the handling
    of Natural literals was very fragile -- and I somehow tripped that
    fragility in my work.
    
    So this patch fixes the fragility.
    See Note [realToFrac natural-to-float]
    
    This made a big (9%) difference in one existing test in
    perf/should_run/T1-359
    
    Metric Decrease:
        T10359
    
    - - - - -
    778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00
    Type vs Constraint: finally nailed
    
    This big patch addresses the rats-nest of issues that have plagued
    us for years, about the relationship between Type and Constraint.
    See #11715/#21623.
    
    The main payload of the patch is:
    * To introduce CONSTRAINT :: RuntimeRep -> Type
    * To make TYPE and CONSTRAINT distinct throughout the compiler
    
    Two overview Notes in GHC.Builtin.Types.Prim
    
    * Note [TYPE and CONSTRAINT]
    
    * Note [Type and Constraint are not apart]
      This is the main complication.
    
    The specifics
    
    * New primitive types (GHC.Builtin.Types.Prim)
      - CONSTRAINT
      - ctArrowTyCon (=>)
      - tcArrowTyCon (-=>)
      - ccArrowTyCon (==>)
      - funTyCon     FUN     -- Not new
      See Note [Function type constructors and FunTy]
      and Note [TYPE and CONSTRAINT]
    
    * GHC.Builtin.Types:
      - New type Constraint = CONSTRAINT LiftedRep
      - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in
    
    * Exploit the fact that Type and Constraint are distinct throughout GHC
      - Get rid of tcView in favour of coreView.
      - Many tcXX functions become XX functions.
        e.g. tcGetCastedTyVar --> getCastedTyVar
    
    * Kill off Note [ForAllTy and typechecker equality], in (old)
      GHC.Tc.Solver.Canonical.  It said that typechecker-equality should ignore
      the specified/inferred distinction when comparein two ForAllTys.  But
      that wsa only weakly supported and (worse) implies that we need a separate
      typechecker equality, different from core equality. No no no.
    
    * GHC.Core.TyCon: kill off FunTyCon in data TyCon.  There was no need for it,
      and anyway now we have four of them!
    
    * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo
      See Note [FunCo] in that module.
    
    * GHC.Core.Type.  Lots and lots of changes driven by adding CONSTRAINT.
      The key new function is sORTKind_maybe; most other changes are built
      on top of that.
    
      See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`.
    
    * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in
      kinding ForAllTys.  See new tules (FORALL1) and (FORALL2) in GHC.Core.Type.
      (The bug was that before (forall (cv::t1 ~# t2). blah), where
      blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be
      (TYPE LiftedRep).  See Note [Kinding rules for types] in GHC.Core.Type.
    
    * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType.
      Of course, no tcEqType any more.
    
    * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module:
      tyConsOfType, visVarsOfType, and occCheckExpand.  Refactoring only.
    
    * GHC.Builtin.Types.  Compiletely re-engineer boxingDataCon_maybe to
      have one for each /RuntimeRep/, rather than one for each /Type/.
      This dramatically widens the range of types we can auto-box.
      See Note [Boxing constructors] in GHC.Builtin.Types
      The boxing types themselves are declared in library ghc-prim:GHC.Types.
    
      GHC.Core.Make.  Re-engineer the treatment of "big" tuples (mkBigCoreVarTup
      etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially)
      types of kind Constraint. That allows the desugaring for arrows to work;
      it gathers up free variables (including dictionaries) into tuples.
      See  Note [Big tuples] in GHC.Core.Make.
    
      There is still work to do here: #22336. But things are better than
      before.
    
    * GHC.Core.Make.  We need two absent-error Ids, aBSENT_ERROR_ID for types of
      kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint.
      Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make;
      see Note [inlineId magic].
    
    * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion.  It is now called
      SelCo, and its fields are much more descriptive than the single Int we used to
      have.  A great improvement.  See Note [SelCo] in GHC.Core.TyCo.Rep.
    
    * GHC.Core.RoughMap.roughMatchTyConName.  Collapse TYPE and CONSTRAINT to
      a single TyCon, so that the rough-map does not distinguish them.
    
    * GHC.Core.DataCon
      - Mainly just improve documentation
    
    * Some significant renamings:
      GHC.Core.Multiplicity: Many -->  ManyTy (easier to grep for)
                             One  -->  OneTy
      GHC.Core.TyCo.Rep TyCoBinder      -->   GHC.Core.Var.PiTyBinder
      GHC.Core.Var      TyCoVarBinder   -->   ForAllTyBinder
                        AnonArgFlag     -->   FunTyFlag
                        ArgFlag         -->   ForAllTyFlag
      GHC.Core.TyCon    TyConTyCoBinder --> TyConPiTyBinder
      Many functions are renamed in consequence
      e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc
    
    * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type
        data FunTyFlag
          = FTF_T_T           -- (->)  Type -> Type
          | FTF_T_C           -- (-=>) Type -> Constraint
          | FTF_C_T           -- (=>)  Constraint -> Type
          | FTF_C_C           -- (==>) Constraint -> Constraint
    
    * GHC.Tc.Errors.Ppr.  Some significant refactoring in the TypeEqMisMatch case
      of pprMismatchMsg.
    
    * I made the tyConUnique field of TyCon strict, because I
      saw code with lots of silly eval's.  That revealed that
      GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because
      we pack the sum tag into a 6-bit field.  (Lurking bug squashed.)
    
    Fixes
    * #21530
    
    Updates haddock submodule slightly.
    
    Performance changes
    ~~~~~~~~~~~~~~~~~~~
    I was worried that compile times would get worse, but after
    some careful profiling we are down to a geometric mean 0.1%
    increase in allocation (in perf/compiler).  That seems fine.
    
    There is a big runtime improvement in T10359
    
    Metric Decrease:
        LargeRecord
        MultiLayerModulesTH_OneShot
        T13386
        T13719
    Metric Increase:
        T8095
    
    - - - - -
    360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00
    Indent closing "#-}" to silence HLint
    
    - - - - -
    e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00
    Fix merge conflict in T18355.stderr
    
    Fixes #22446
    
    - - - - -
    294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00
    Fix a trivial typo in dataConNonlinearType
    
    Fixes #22416
    
    - - - - -
    268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00
    eventlog: Ensure that IPE output contains actual info table pointers
    
    The refactoring in 866c736e introduced a rather subtle change in the
    semantics of the IPE eventlog output, changing the eventlog field from
    encoding info table pointers to "TNTC pointers" (which point to entry
    code when tables-next-to-code is enabled). Fix this.
    
    Fixes #22452.
    
    - - - - -
    d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00
    testsuite: Add tests for T22347
    
    These are fixed in recent versions but might as well add regression
    tests.
    
    See #22347
    
    - - - - -
    8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00
    testsuite: Improve output from tests which have failing pre_cmd
    
    There are two changes:
    
    * If a pre_cmd fails, then don't attempt to run the test.
    * If a pre_cmd fails, then print the stdout and stderr from running that
      command (which hopefully has a nice error message).
    
    For example:
    
    ```
    =====> 1 of 1 [0, 0, 0]
    *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2
    ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}".
    stdout:
    stderr:
    DefaultLifted.hs:19:13: error: [GHC-76037]
        Not in scope: type constructor or class ‘Typ’
        Suggested fix:
          Perhaps use one of these:
            ‘Type’ (imported from GHC.Tc.Utils.TcType),
            data constructor ‘Type’ (imported from GHC.Plugins)
       |
    19 | instance Eq Typ where
       |             ^^^
    make: *** [Makefile:17: package.test-defaulting-plugin] Error 1
    
    Performance Metrics (test environment: local):
    ```
    
    Fixes #22329
    
    - - - - -
    2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00
    Implement UNPACK support for sum types.
    
    This is based on osa's unpack_sums PR from ages past.
    
    The meat of the patch is implemented in dataConArgUnpackSum
    and described in Note [UNPACK for sum types].
    
    - - - - -
    78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00
    Expand on the need to clone local binders.
    
    Fixes #22402.
    
    - - - - -
    65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00
    Fix :i Constraint printing "type Constraint = Constraint"
    
    Since Constraint became a synonym for CONSTRAINT 'LiftedRep,
    we need the same code for handling printing as for the synonym
    Type = TYPE 'LiftedRep.
    This addresses the same bug as #18594, so I'm reusing the test.
    
    - - - - -
    94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00
    configure: Don't check for an unsupported version of LLVM
    
    The upper bound is not inclusive.
    
    Fixes #22449
    
    - - - - -
    02d3511b by Andrew Lelechenko at 2022-11-15T21:36:41-05:00
    Fix capitalization in haddock for TestEquality
    
    - - - - -
    08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00
    base: make Foreign.Marshal.Pool use RTS internal arena for allocation
    
    `Foreign.Marshal.Pool` used to call `malloc` once for each allocation
    request. Each `Pool` maintained a list of allocated pointers, and
    traverses the list to `free` each one of those pointers. The extra O(n)
    overhead is apparently bad for a `Pool` that serves a lot of small
    allocation requests.
    
    This patch uses the RTS internal arena to implement `Pool`, with these
    benefits:
    
    - Gets rid of the extra O(n) overhead.
    - The RTS arena is simply a bump allocator backed by the block
      allocator, each allocation request is likely faster than a libc
      `malloc` call.
    
    Closes #14762 #18338.
    
    - - - - -
    37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00
    Misc cleanup
    
    * Replace catMaybes . map f with mapMaybe f
    * Use concatFS to concatenate multiple FastStrings
    * Fix documentation of -exclude-module
    * Cleanup getIgnoreCount in GHCi.UI
    
    - - - - -
    b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00
    Give better errors for code corrupted by Unicode smart quotes (#21843)
    
    Previously, we emitted a generic and potentially confusing error during lexical
    analysis on programs containing smart quotes (“/”/‘/’). This commit adds
    smart quote-aware lexer errors.
    
    - - - - -
    cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00
    Make OpaqueNo* tests less noisy to unrelated changes
    
    - - - - -
    b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00
    Simplifier: Consider `seq` as a `BoringCtxt` (#22317)
    
    See `Note [Seq is boring]` for the rationale.
    
    Fixes #22317.
    
    - - - - -
    9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00
    Make T21839c's ghc/max threshold more forgiving
    
    - - - - -
    4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00
    Be more careful when reporting unbound RULE binders
    
    See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds.
    
    Fixes #22471.
    
    - - - - -
    e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00
    PPC NCG: Fix generating assembler code
    
    Fixes #22479
    
    - - - - -
    f2f9ef07 by Andrew Lelechenko at 2022-11-20T18:39:30-05:00
    Extend documentation for Data.IORef
    
    - - - - -
    ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00
    Buglet in GHC.Tc.Module.checkBootTyCon
    
    This lurking bug used the wrong function to compare two
    types in GHC.Tc.Module.checkBootTyCon
    
    It's hard to trigger the bug, which only came up during
    !9343, so there's no regression test in this MR.
    
    - - - - -
    451aeac3 by Andrew Lelechenko at 2022-11-20T18:40:44-05:00
    Add since pragmas for c_interruptible_open and hostIsThreaded
    
    - - - - -
    8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00
    Introduce CapIOManager as the per-cap I/O mangager state
    
    Rather than each I/O manager adding things into the Capability structure
    ad-hoc, we should have a common CapIOManager iomgr member of the
    Capability structure, with a common interface to initialise etc.
    
    The content of the CapIOManager struct will be defined differently for
    each I/O manager implementation. Eventually we should be able to have
    the CapIOManager be opaque to the rest of the RTS, and known just to the
    I/O manager implementation. We plan for that by making the Capability
    contain a pointer to the CapIOManager rather than containing the
    structure directly.
    
    Initially just move the Unix threaded I/O manager's control FD.
    
    - - - - -
    8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Add hook markCapabilityIOManager
    
    To allow I/O managers to have GC roots in the Capability, within the
    CapIOManager structure.
    
    Not yet used in this patch.
    
    - - - - -
    5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Move APPEND_TO_BLOCKED_QUEUE from cmm to C
    
    The I/O and delay blocking primitives for the non-threaded way
    currently access the blocked_queue and sleeping_queue directly.
    
    We want to move where those queues are to make their ownership clearer:
    to have them clearly belong to the I/O manager impls rather than to the
    scheduler. Ultimately we will want to change their representation too.
    
    It's inconvenient to do that if these queues are accessed directly from
    cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a
    C version appendToIOBlockedQueue(), and replace the open-coded
    sleeping_queue insertion with insertIntoSleepingQueue().
    
    - - - - -
    ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager
    
    The blocked_queue_{hd,tl} and the sleeping_queue are currently
    cooperatively managed between the scheduler and (some but not all of)
    the non-threaded I/O manager implementations.
    
    They lived as global vars with the scheduler, but are poked by I/O
    primops and the I/O manager backends.
    
    This patch is a step on the path towards making the management of I/O or
    timer blocking belong to the I/O managers and not the scheduler.
    
    Specifically, this patch moves the {blocked,sleeping}_queue from being
    global vars in the scheduler to being members of the CapIOManager struct
    within each Capability. They are not yet exclusively used by the I/O
    managers: they are still poked from a couple other places, notably in
    the scheduler before calling awaitEvent.
    
    - - - - -
    0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Remove the now-unused markScheduler
    
    The global vars {blocked,sleeping}_queue are now in the Capability and
    so get marked there via markCapabilityIOManager.
    
    - - - - -
    39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Move macros for checking for pending IO or timers
    
    from Schedule.h to Schedule.c and IOManager.h
    
    This is just moving, the next step will be to rejig them slightly.
    
    For the non-threaded RTS the scheduler needs to be able to test for
    there being pending I/O operation or pending timers. The implementation
    of these tests should really be considered to be part of the I/O
    managers and not part of the scheduler.
    
    - - - - -
    664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function
    
    These are the macros originaly from Scheduler.h, previously moved to
    IOManager.h, and now replaced with a single inline function
    anyPendingTimeoutsOrIO(). We can use a single function since the two
    macros were always checked together.
    
    Note that since anyPendingTimeoutsOrIO is defined for all IO manager
    cases, including threaded, we do not need to guard its use by cpp
     #if !defined(THREADED_RTS)
    
    - - - - -
    32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Expand emptyThreadQueues inline for clarity
    
    It was not really adding anything. The name no longer meant anything
    since those I/O and timeout queues do not belong to the scheuler.
    
    In one of the two places it was used, the comments already had to
    explain what it did, whereas now the code matches the comment nicely.
    
    - - - - -
    9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Move the awaitEvent declaration into IOManager.h
    
    And add or adjust comments at the use sites of awaitEvent.
    
    - - - - -
    054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Pass the Capability *cap explicitly to awaitEvent
    
    It is currently only used in the non-threaded RTS so it works to use
    MainCapability, but it's a bit nicer to pass the cap anyway. It's
    certainly shorter.
    
    - - - - -
    667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Pass the Capability *cap explicitly to appendToIOBlockedQueue
    
    And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler
    though not strictly necessary given that these primops are currently
    only used in the non-threaded RTS.
    
    - - - - -
    7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00
    Reveiew feedback: improve one of the TODO comments
    
    The one about the nonsense (const False) test on WinIO for there being any IO
    or timers pending, leading to unnecessary complication later in the
    scheduler.
    
    - - - - -
    e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00
    Optimize getLevity.
    
    Avoid the intermediate data structures allocated by splitTyConApp.
    This avoids ~0.5% of allocations for a build using -O2.
    
    Fixes #22254
    
    - - - - -
    de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00
    hadrian:Set TNTC when running testsuite.
    
    - - - - -
    9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00
    Add unsafePtrEquality# restricted to UnliftedTypes
    
    - - - - -
    e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00
    utils/unlit: adjust parser to match Report spec
    
    The Haskell 2010 Report says that, for Latex-style Literate format,
    "Program code begins on the first line following a line that begins
    \begin{code}". (This is unchanged from the 98 Report)
    
    However the unlit.c implementation only matches a line that contains
    "\begin{code}" and nothing else. One consequence of this is that one
    cannot suffix Latex options to the code environment. I.e., this does
    not work:
    
    \begin{code}[label=foo,caption=Foo Code]
    
    Adjust the matcher to conform to the specification from the Report.
    
    The Haskell Wiki currently recommends suffixing a '%' to \begin{code}
    in order to deliberately hide a code block from Haskell. This is bad
    advice, as it's relying on an implementation quirk rather than specified
    behaviour. None-the-less, some people have tried to use it, c.f.
    <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html>
    
    An alternative solution is to define a separate, equivalent Latex
    environment to "code", that is functionally identical in Latex but
    ignored by unlit. This should not be a burden: users are required to
    manually define the code environment anyway, as it is not provided
    by the Latex verbatim or lstlistings packages usually used for
    presenting code in documents.
    
    Fixes #3549.
    
    - - - - -
    0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00
    Fix eventlog all option
    
    Previously it didn't enable/disable nonmoving_gc and ticky event types
    
    Fixes #21813
    
    - - - - -
    04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00
    Expand Note [Linear types] with the stance on linting linearity
    
    Per the discussion on #22123
    
    - - - - -
    e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00
    Add documentation on custom Prelude modules (#22228)
    
    Specifically, custom Prelude modules that are named `Prelude`.
    
    - - - - -
    b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00
    Don't let configure perform trivial substitutions (#21846)
    
    Hadrian now performs substitutions, especially to generate .cabal files
    from .cabal.in files. Two benefits:
    
    1. We won't have to re-configure when we modify thing.cabal.in. Hadrian
       will take care of this for us.
    
    2. It paves the way to allow the same package to be configured
       differently by Hadrian in the same session. This will be useful to
       fix #19174: we want to build a stage2 cross-compiler for the host
       platform and a stage1 compiler for the cross target platform in the
       same Hadrian session.
    
    - - - - -
    99aca26b by nineonine at 2022-11-23T12:47:11-05:00
    CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)
    
    Previously, when using `capi` calling convention in foreign declarations,
    code generator failed to handle const-cualified pointer return types.
    This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers`
    warning.
    
    `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases -
    special treatment was put in place to generate appropritetly qualified C
    wrapper that no longer triggers the above mentioned warning.
    
    Fixes #22043
    
    - - - - -
    040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00
    Scrub some no-warning pragmas.
    
    - - - - -
    178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00
    Check if the SDoc starts with a single quote (#22488)
    
    This patch fixes pretty-printing of character literals
    inside promoted lists and tuples.
    
    When we pretty-print a promoted list or tuple whose first element
    starts with a single quote, we want to add a space between the opening
    bracket and the element:
    
    	'[True]    -- ok
    	'[ 'True]  -- ok
    	'['True]   -- not ok
    
    If we don't add the space, we accidentally produce a character
    literal '['.
    
    Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST
    and tried to guess if it would be rendered with a single quote. However,
    it missed the case when the inner type was itself a character literal:
    
    	'[ 'x']  -- ok
    	'['x']   -- not ok
    
    Instead of adding this particular case, I opted for a more future-proof
    solution: check the SDoc directly. This way we can detect if the single
    quote is actually there instead of trying to predict it from the AST.
    The new function is called spaceIfSingleQuote.
    
    - - - - -
    11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00
    notes: Fix references to HPT space leak note
    
    Updating this note was missed when updating the HPT to the HUG.
    
    Fixes #22477
    
    - - - - -
    86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00
    Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115)
    
    Problem: avoid usage of TcRnMessageUnknown
    
    Solution:
    The following `TcRnMessage` messages has been introduced:
      TcRnNoRebindableSyntaxRecordDot
      TcRnNoFieldPunsRecordDot
      TcRnIllegalStaticExpression
      TcRnIllegalStaticFormInSplice
      TcRnListComprehensionDuplicateBinding
      TcRnEmptyStmtsGroup
      TcRnLastStmtNotExpr
      TcRnUnexpectedStatementInContext
      TcRnIllegalTupleSection
      TcRnIllegalImplicitParameterBindings
      TcRnSectionWithoutParentheses
    
    Co-authored-by: sheaf <sam.derbyshire at gmail.com>
    
    - - - - -
    d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00
    rts: fix missing Arena.h symbols in RtsSymbols.c
    
    It was an unfortunate oversight in !8961 and broke devel2 builds.
    
    - - - - -
    5943e739 by Andrew Lelechenko at 2022-11-25T04:38:28-05:00
    Assorted fixes to avoid Data.List.{head,tail}
    
    - - - - -
    1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00
    Review suggestions for assorted fixes to avoid Data.List.{head,tail}
    
    - - - - -
    13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00
    Print unticked promoted data constructors (#20531)
    
    Before this patch, GHC unconditionally printed ticks before promoted
    data constructors:
    
    	ghci> type T = True  -- unticked (user-written)
    	ghci> :kind! T
    	T :: Bool
    	= 'True              -- ticked (compiler output)
    
    After this patch, GHC prints ticks only when necessary:
    
    	ghci> type F = False    -- unticked (user-written)
    	ghci> :kind! F
    	F :: Bool
    	= False                 -- unticked (compiler output)
    
    	ghci> data False        -- introduce ambiguity
    	ghci> :kind! F
    	F :: Bool
    	= 'False                -- ticked by necessity (compiler output)
    
    The old behavior can be enabled by -fprint-redundant-promotion-ticks.
    
    Summary of changes:
    * Rename PrintUnqualified to NamePprCtx
    * Add QueryPromotionTick to it
    * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick)
    * Introduce -fprint-redundant-promotion-ticks
    
    Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht>
    
    - - - - -
    d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00
    Fix decomposition of TyConApps
    
    Ticket #22331 showed that we were being too eager to decompose
    a Wanted TyConApp, leading to incompleteness in the solver.
    
    To understand all this I ended up doing a substantial rewrite
    of the old Note [Decomposing equalities], now reborn as
    Note [Decomposing TyConApp equalities]. Plus rewrites of other
    related Notes.
    
    The actual fix is very minor and actually simplifies the code: in
    `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call
    `noMatchableIrreds`.  A closely related refactor: we stop trying to
    use the same "no matchable givens" function here as in
    `matchClassInst`.  Instead split into two much simpler functions.
    
    - - - - -
    2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00
    Redirect output of musttail attribute test
    
    Compilation output from test for support of musttail attribute leaked to
    the console.
    
    - - - - -
    0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00
    Move hs_mulIntMayOflo cbits to ghc-prim
    
    It's only used by wasm NCG at the moment, but ghc-prim is a more
    reasonable place for hosting out-of-line primops. Also, we only need a
    single version of hs_mulIntMayOflo.
    
    - - - - -
    36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00
    compiler: generate ccalls for clz/ctz/popcnt in wasm NCG
    
    We used to generate a single wasm clz/ctz/popcnt opcode, but it's
    wrong when it comes to subwords, so might as well generate ccalls for
    them. See #22470 for details.
    
    - - - - -
    d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00
    compiler: remove unused MO_U_MulMayOflo
    
    We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere.
    
    - - - - -
    8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00
    Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order
    
    Fixes: #217093
    Associated to #19415
    
    This change
    * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero;
    * Removes `cc_fundeps` in CDictCan as the check was incomplete;
    * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities
    * Adds 2 new tests for validating the change
       - testsuites/typecheck/should_compile/T21703.hs and
       - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs)
    * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors
    * Changes in Notes:
      - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances]
      - Added Note [Kind Equality Orientation] to visualize the kind flipping
      - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties]
    
    - - - - -
    646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00
    Change printing of sized literals to match the proposal
    
    Literals in Core were printed as e.g. 0xFF#16 :: Int16#.
    The proposal 451 now specifies syntax 0xFF#Int16.
    This change affects the Core printer only - more to be done later.
    
    Part of #21422.
    
    - - - - -
    02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00
    Be a bit more selective about floating bottoming expressions
    
    This MR arranges to float a bottoming expression to the top
    only if it escapes a value lambda.
    
    See #22494 and Note [Floating to the top] in SetLevels.
    
    This has a generally beneficial effect in nofib
    
    +-------------------------------++----------+
    |                               ||tsv (rel) |
    +===============================++==========+
    |           imaginary/paraffins ||   -0.93% |
    |                imaginary/rfib ||   -0.05% |
    |                      real/fem ||   -0.03% |
    |                    real/fluid ||   -0.01% |
    |                   real/fulsom ||   +0.05% |
    |                   real/gamteb ||   -0.27% |
    |                       real/gg ||   -0.10% |
    |                   real/hidden ||   -0.01% |
    |                      real/hpg ||   -0.03% |
    |                      real/scs ||  -11.13% |
    |         shootout/k-nucleotide ||   -0.01% |
    |               shootout/n-body ||   -0.08% |
    |   shootout/reverse-complement ||   -0.00% |
    |        shootout/spectral-norm ||   -0.02% |
    |             spectral/fibheaps ||   -0.20% |
    |           spectral/hartel/fft ||   -1.04% |
    |         spectral/hartel/solid ||   +0.33% |
    |     spectral/hartel/wave4main ||   -0.35% |
    |                 spectral/mate ||   +0.76% |
    +===============================++==========+
    |                     geom mean ||   -0.12% |
    
    The effect on compile time is generally slightly beneficial
    
    Metrics: compile_time/bytes allocated
    ----------------------------------------------
    MultiLayerModulesTH_OneShot(normal)  +0.3%
                      PmSeriesG(normal)  -0.2%
                      PmSeriesT(normal)  -0.1%
                         T10421(normal)  -0.1%
                        T10421a(normal)  -0.1%
                         T10858(normal)  -0.1%
                         T11276(normal)  -0.1%
                        T11303b(normal)  -0.2%
                         T11545(normal)  -0.1%
                         T11822(normal)  -0.1%
                         T12150(optasm)  -0.1%
                         T12234(optasm)  -0.3%
                         T13035(normal)  -0.2%
                         T16190(normal)  -0.1%
                         T16875(normal)  -0.4%
                        T17836b(normal)  -0.2%
                         T17977(normal)  -0.2%
                        T17977b(normal)  -0.2%
                         T18140(normal)  -0.1%
                         T18282(normal)  -0.1%
                         T18304(normal)  -0.2%
                        T18698a(normal)  -0.1%
                         T18923(normal)  -0.1%
                         T20049(normal)  -0.1%
                        T21839r(normal)  -0.1%
                          T5837(normal)  -0.4%
                          T6048(optasm)  +3.2% BAD
                          T9198(normal)  -0.2%
                          T9630(normal)  -0.1%
           TcPlugin_RewritePerf(normal)  -0.4%
                 hard_hole_fits(normal)  -0.1%
    
                              geo. mean  -0.0%
                              minimum    -0.4%
                              maximum    +3.2%
    
    The T6048 outlier is hard to pin down, but it may be the effect of
    reading in more interface files definitions. It's a small program for
    which compile time is very short, so I'm not bothered about it.
    
    Metric Increase:
        T6048
    
    - - - - -
    ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00
    testsuite: Mark unpack_sums_6 as fragile due to #22504
    
    This test is explicitly dependent upon runtime, which is generally not
    appropriate given that the testsuite is run in parallel and generally
    saturates the CPU.
    
    - - - - -
    def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00
    testsuite: Don't use grep -q in unpack_sums_7
    
    `grep -q` closes stdin as soon as it finds the pattern it is looking
    for, resulting in #22484.
    
    - - - - -
    cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00
    Add Javascript backend
    
    Add JS backend adapted from the GHCJS project by Luite Stegeman.
    
    Some features haven't been ported or implemented yet. Tests for these
    features have been disabled with an associated gitlab ticket.
    
    Bump array submodule
    
    Work funded by IOG.
    
    Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io>
    Co-authored-by: Luite Stegeman <stegeman at gmail.com>
    Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com>
    
    - - - - -
    68c966cd by sheaf at 2022-11-30T09:31:25-05:00
    Fix @since annotations on WithDict and Coercible
    
    Fixes #22453
    
    - - - - -
    a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00
    Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther
    
    We were failing to account for the cc_pend_sc flag in this
    important function, with the result that we expanded superclasses
    forever.
    
    Fixes #22516.
    
    - - - - -
    a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00
    Use mkNakedFunTy in tcPatSynSig
    
    As #22521 showed, in tcPatSynSig we make a "fake type" to
    kind-generalise; and that type has unzonked type variables in it. So
    we must not use `mkFunTy` (which checks FunTy's invariants) via
    `mkPhiTy` when building this type.  Instead we need to use
    `mkNakedFunTy`.
    
    Easy fix.
    
    - - - - -
    31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00
    Properly cast values when writing/reading unboxed sums.
    
    Unboxed sums might store a Int8# value as Int64#. This patch
    makes sure we keep track of the actual value type.
    
    See Note [Casting slot arguments] for the details.
    
    - - - - -
    10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00
    Move Void to GHC.Base...
    
    This change would allow `Void` to be used deeper in module graph.
    For example exported from `Prelude` (though that might be already
    possible).
    
    Also this change includes a change `stimes @Void _ x = x`,
    https://github.com/haskell/core-libraries-committee/issues/95
    
    While the above is not required, maintaining old stimes behavior
    would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`,
    which would require more hs-boot files.
    
    - - - - -
    b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00
    DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475)
    
    See the updated `Note [Data-con worker strictness]`
    and the new `Note [Demand transformer for data constructors]`.
    
    Fixes #22475.
    
    - - - - -
    d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00
    Make Functor a quantified superclass of Bifunctor.
    
    See https://github.com/haskell/core-libraries-committee/issues/91 for
    discussion.
    
    This change relates Bifunctor with Functor by requiring second = fmap.
    Moreover this change is a step towards unblocking the major version bump
    of bifunctors and profunctors to major version 6. This paves the way to
    move the Profunctor class into base. For that Functor first similarly
    becomes a superclass of Profunctor in the new major version 6.
    
    - - - - -
    72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00
    FastString: SAT bucket_match
    
    Metric Decrease:
        MultiLayerModulesTH_OneShot
    
    - - - - -
    afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00
    Add a missing varToCoreExpr in etaBodyForJoinPoint
    
    This subtle bug showed up when compiling a library with 9.4.
    See #22491.  The bug is present in master, but it is hard to
    trigger; the new regression test T22491 fails in 9.4.
    
    The fix was easy: just add a missing varToCoreExpr in
    etaBodyForJoinPoint.
    
    The fix is definitely right though!
    
    I also did some other minor refatoring:
    * Moved the preInlineUnconditionally test in simplExprF1 to
      before the call to joinPointBinding_maybe, to avoid fruitless
      eta-expansion.
    * Added a boolean from_lam flag to simplNonRecE, to avoid two
      fruitless tests, and commented it a bit better.
    
    These refactorings seem to save 0.1% on compile-time allocation in
    perf/compiler; with a max saving of 1.4% in T9961
    
    Metric Decrease:
        T9961
    
    - - - - -
    81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00
    CI: Forbid the fully static build on Alpine to fail.
    
    To do so, we mark some tests broken in this configuration.
    
    - - - - -
    c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00
    CI: Remove ARMv7 jobs
    
    These jobs fail (and are allowed to fail) nearly every time.
    
    Soon they won't even be able to run at all, as we won't currently have
    runners that can run them.
    
    Fixing the latter problem is tracked in #22409.
    
    I went ahead and removed all settings and configurations.
    
    - - - - -
    d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00
    CI: Fix CI lint
    
    Failure was introduced by conflicting changes to gen_ci.hs that did
    *not* trigger git conflicts.
    
    - - - - -
    ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00
    Refactor TyCon to have a top-level product
    
    This patch changes the representation of TyCon so that it has
    a top-level product type, with a field that gives the details
    (newtype, type family etc), #22458.
    
    Not much change in allocation, but execution seems to be a bit
    faster.
    
    Includes a change to the haddock submodule to adjust for API changes.
    
    - - - - -
    74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00
    ApplicativeDo: Set pattern location before running exhaustiveness checker
    
    This improves the error messages of the exhaustiveness checker when
    checking statements which have been moved around with ApplicativeDo.
    
    Before:
    
    Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns]
        Pattern match(es) are non-exhaustive
        In a pattern binding:
            Patterns of type ‘Maybe ()’ not matched: Nothing
      |
    2 |   let x = ()
      |   ^^^^^^^^^^
    
    After:
    
    Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns]
        Pattern match(es) are non-exhaustive
        In a pattern binding:
            Patterns of type ‘Maybe ()’ not matched: Nothing
      |
    4 |   ~(Just res1) <- seq x (pure $ Nothing @())
      |
    
    Fixes #22483
    
    - - - - -
    85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00
    Add special case for :Main module in `GHC.IfaceToCore.mk_top_id`
    
    See Note [Root-main Id]
    
    The `:Main` special binding is actually defined in the current module
    (hence don't go looking for it externally) but the module name is rOOT_MAIN
    rather than the current module so we need this special case.
    
    There was already some similar logic in `GHC.Rename.Env` for
    External Core, but now the "External Core" is in interface files it
    needs to be moved here instead.
    
    Fixes #22405
    
    - - - - -
    108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00
    Fix linearity checking in Lint
    
    Lint was not able to see that x*y <= x*y, because this inequality
    was decomposed to x <= x*y && y <= x*y, but there was no rule
    to see that x <= x*y.
    
    Fixes #22546.
    
    - - - - -
    bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00
    Mark T16916 fragile
    
    See https://gitlab.haskell.org/ghc/ghc/-/issues/16966
    
    - - - - -
    5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00
    Refactor: FreshOrReuse instead of addTyClTyVarBinds
    
    This is a refactoring that should have no effect on observable behavior.
    
    Prior to this change, GHC.HsToCore.Quote contained a few closely related
    functions to process type variable bindings: addSimpleTyVarBinds,
    addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds.
    
    We can classify them by their input type and name generation strategy:
    
                                  Fresh names only    Reuse bound names
                              +---------------------+-------------------+
                       [Name] | addSimpleTyVarBinds |                   |
    [LHsTyVarBndr flag GhcRn] |     addHsTyVarBinds |                   |
            LHsQTyVars GhcRn  |      addQTyVarBinds | addTyClTyVarBinds |
                              +---------------------+-------------------+
    
    Note how two functions are missing. Because of this omission, there were
    two places where a LHsQTyVars value was constructed just to be able to pass it
    to addTyClTyVarBinds:
    
    1. mk_qtvs in addHsOuterFamEqnTyVarBinds    -- bad
    2. mkHsQTvs in repFamilyDecl                -- bad
    
    This prevented me from making other changes to LHsQTyVars, so the main
    goal of this refactoring is to get rid of those workarounds.
    
    The most direct solution would be to define the missing functions.
    But that would lead to a certain amount of code duplication. To avoid
    code duplication, I factored out the name generation strategy into a
    function parameter:
    
    	data FreshOrReuse
    	  = FreshNamesOnly
    	  | ReuseBoundNames
    
    	addSimpleTyVarBinds :: FreshOrReuse -> ...
    	addHsTyVarBinds     :: FreshOrReuse -> ...
    	addQTyVarBinds      :: FreshOrReuse -> ...
    
    - - - - -
    c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00
    addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders
    
    Consider this example:
    
    	[d| instance forall a. C [a] where
    	      type forall b. G [a] b = Proxy b |]
    
    When we process "forall b." in the associated type instance, it is
    unambiguously the binding site for "b" and we want a fresh name for it.
    Therefore, FreshNamesOnly is more fitting than ReuseBoundNames.
    This should not have any observable effect but it avoids pointless
    lookups in the MetaEnv.
    
    - - - - -
    42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00
    Handle type data declarations in Template Haskell quotations and splices (fixes #22500)
    
    This adds a TypeDataD constructor to the Template Haskell Dec type,
    and ensures that the constructors it contains go in the TyCls namespace.
    
    - - - - -
    1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00
    Add BufSpan to EpaLocation (#22319, #22558)
    
    The key part of this patch is the change to mkTokenLocation:
    
    	- mkTokenLocation (RealSrcSpan r _)  = TokenLoc (EpaSpan r)
    	+ mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb)
    
    mkTokenLocation used to discard the BufSpan, but now it is saved and can
    be retrieved from LHsToken or LHsUniToken.
    
    This is made possible by the following change to EpaLocation:
    
    	- data EpaLocation = EpaSpan !RealSrcSpan
    	+ data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan)
    	                   | ...
    
    The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock.
    
    - - - - -
    cd31acad by sheaf at 2022-12-06T15:45:58-05:00
    Hadrian: fix ghcDebugAssertions off-by-one error
    
    Commit 6b2f7ffe changed the logic that decided whether to enable debug
    assertions. However, it had an off-by-one error, as the stage parameter
    to the function inconsistently referred to the stage of the compiler
    being used to build or the stage of the compiler we are building.
    
    This patch makes it consistent. Now the parameter always refers to the
    the compiler which is being built.
    
    In particular, this patch re-enables
    assertions in the stage 2 compiler when building with devel2 flavour,
    and disables assertions in the stage 2 compiler when building with
    validate flavour.
    
    Some extra performance tests are now run in the "validate" jobs because
    the stage2 compiler no longer contains assertions.
    
    -------------------------
    Metric Decrease:
        CoOpt_Singletons
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModulesTH_OneShot
        T11374
        T12227
        T12234
        T13253-spj
        T13701
        T14683
        T14697
        T15703
        T17096
        T17516
        T18304
        T18478
        T18923
        T5030
        T9872b
        TcPlugin_RewritePerf
    Metric Increase:
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModules
        MultiLayerModulesRecomp
        MultiLayerModulesTH_Make
        T13386
        T13719
        T3294
        T9233
        T9675
        parsing001
    -------------------------
    
    - - - - -
    21d66db1 by mrkun at 2022-12-06T15:46:38-05:00
    Push DynFlags out of runInstallNameTool
    
    - - - - -
    aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00
    Push DynFlags out of askOtool
    
    - - - - -
    4e28f49e by mrkun at 2022-12-06T15:46:38-05:00
    Push DynFlags out of runInjectRPaths
    
    - - - - -
    a7422580 by mrkun at 2022-12-06T15:46:38-05:00
    Push DynFlags out of Linker.MacOS
    
    - - - - -
    e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00
    Fix bounds-checking buglet in Data.Array.Byte
    
    ...another manifestation of #20851 which
    I unfortunately missed in my first pass.
    
    - - - - -
    8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00
    Remove copy-pasted definitions of `graphFromEdgedVertices*`
    
    - - - - -
    c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00
    Add version of `reachableGraph` that avoids loop for cyclic inputs
    by building its result connected component by component
    
    Fixes #22512
    
    - - - - -
    90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00
    Mark Type.Reflection.Unsafe as Unsafe
    
    This module can be used to construct ill-formed TypeReps, so it should
    be Unsafe.
    
    - - - - -
    2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00
    Truncate eventlog event for large payload (#20221)
    
    RTS eventlog events for postCapsetVecEvent are truncated if payload
    is larger than EVENT_PAYLOAD_SIZE_MAX
    Previously, postCapsetVecEvent records eventlog event with payload
    of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without
    any validation, resulting in corrupted data.
    For example, this happens when a Haskell binary is invoked with very
    long command line arguments exceeding 2^16 bytes (see #20221).
    Now we check the size of accumulated payload messages incrementally,
    and truncate the message just before the payload size exceeds
    EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing
    how many arguments are truncated.
    
    - - - - -
    9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00
    hadrian: don't add debug info to non-debug ways of rts
    
    Hadrian used to pass -g when building all ways of rts. It makes output
    binaries larger (especially so for wasm backend), and isn't needed by
    most users out there, so this patch removes that flag. In case the
    debug info is desired, we still pass -g3 when building the debug way,
    and there's also the debug_info flavour transformer which ensures -g3
    is passed for all rts ways.
    
    - - - - -
    7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00
    Restore show (typeRep @[]) == "[]"
    
    The Show instance for TypeRep [] has changed in 9.5 to output "List"
    because the name of the type constructor changed.
    This seems to be accidental and is inconsistent with TypeReps of saturated
    lists, which are printed as e.g. "[Int]".
    For now, I'm restoring the old behavior; in the future,
    maybe we should show TypeReps without puns (List, Tuple, Type).
    
    - - - - -
    216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00
    Add test for #22162
    
    - - - - -
    5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00
    ci: Add job to test interface file determinism guarantees
    
    In this job we can run on every commit we add a test which builds the
    Cabal library twice and checks that the ABI hash and interface hash is
    stable across the two builds.
    
    * We run the test 20 times to try to weed out any race conditions due to
      `-j`
    * We run the builds in different temporary directories to try to weed
      out anything related to build directory affecting ABI or interface
      file hash.
    
    Fixes #22180
    
    - - - - -
    0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00
    ci: Add job for testing interface stability across builds
    
    The idea is that both the bindists should product libraries with the
    same ABI and interface hash.
    So the job checks with ghc-pkg to make sure the computed ABI
    is the same.
    
    In future this job can be extended to check for the other facets of
    interface determinism.
    
    Fixes #22180
    
    - - - - -
    74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00
    backpack: Be more careful when adding together ImportAvails
    
    There was some code in the signature merging logic which added together
    the ImportAvails of the signature and the signature which was merged
    into it. This had the side-effect of making the merged signature depend
    on the signature (via a normal module dependency). The intention was to
    propagate orphan instances through the merge but this also messed up
    recompilation logic because we shouldn't be attempting to load B.hi when
    mergeing it.
    
    The fix is to just combine the part of ImportAvails that we intended to
    (transitive info, orphan instances and type family instances) rather
    than the whole thing.
    
    - - - - -
    d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00
    Fix mk_mod_usage_info if the interface file is not already loaded
    
    In #22217 it was observed that the order modules are compiled in affects
    the contents of an interface file. This was because a module dependended
    on another module indirectly, via a re-export but the interface file for
    this module was never loaded because the symbol was never used in the
    file.
    
    If we decide that we depend on a module then we jolly well ought to
    record this fact in the interface file! Otherwise it could lead to very
    subtle recompilation bugs if the dependency is not tracked and the
    module is updated.
    
    Therefore the best thing to do is just to make sure the file is loaded
    by calling the `loadSysInterface` function.  This first checks the
    caches (like we did before) but then actually goes to find the interface
    on disk if it wasn't loaded.
    
    Fixes #22217
    
    - - - - -
    ea25088d by lrzlin at 2022-12-08T22:46:06-05:00
    Add initial support for LoongArch Architecture.
    
    - - - - -
    9eb9d2f4 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
    Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD
    
    - - - - -
    08d8fe2a by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
    Allow mtl-2.3 in hadrian
    
    - - - - -
    3807a46c by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
    Support mtl-2.3 in check-exact
    
    - - - - -
    ef702a18 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
    Fix tests
    
    - - - - -
    3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00
    Make (^) INLINE (#22324)
    
    So that we get to cancel away the allocation for the lazily used base.
    
    We can move `powImpl` (which *is* strict in the base) to the top-level
    so that we don't duplicate too much code and move the SPECIALISATION
    pragmas onto `powImpl`.
    
    The net effect of this change is that `(^)` plays along much better with
    inlining thresholds and loopification (#22227), for example in `x2n1`.
    
    Fixes #22324.
    
    - - - - -
    1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00
    Typeable: Fix module locations of some definitions in GHC.Types
    
    There was some confusion in Data.Typeable about which module certain
    wired-in things were defined in. Just because something is wired-in
    doesn't mean it comes from GHC.Prim, in particular things like LiftedRep
    and RuntimeRep are defined in GHC.Types and that's the end of the story.
    
    Things like Int#, Float# etc are defined in GHC.Prim as they have no
    Haskell definition site at all so we need to generate type
    representations for them (which live in GHC.Types).
    
    Fixes #22510
    
    - - - - -
    0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00
    Make `drop` and `dropWhile` fuse (#18964)
    
    I copied the fusion framework we have in place for `take`.
    T18964 asserts that we regress neither when fusion fires nor when it doesn't.
    
    Fixes #18964.
    
    - - - - -
    26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00
    Do not strictify a DFun's parameter dictionaries (#22549)
    
    ... thus fixing #22549.
    
    The details are in the refurbished and no longer dead
    `Note [Do not strictify a DFun's parameter dictionaries]`.
    
    There's a regression test in T22549.
    
    - - - - -
    36093407 by John Ericson at 2022-12-08T22:49:45-05:00
    Delete `rts/package.conf.in`
    
    It is a relic of the Make build system. The RTS now uses a
    `package.conf` file generated the usual way by Cabal.
    
    - - - - -
    b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00
    Fixes around primitive literals
    
    * The SourceText of primitive characters 'a'# did not include
      the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#.
      We can now remove the function pp_st_suffix, which was a hack
      to add the # back.
    * Negative primitive literals shouldn't use parentheses, as described in
      Note [Printing of literals in Core]. Added a testcase to T14681.
    
    - - - - -
    aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00
    testsuite: Mark conc024 fragile on Windows
    
    - - - - -
    ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00
    Document TH splices' interaction with INCOHERENT instances
    
    Top-level declaration splices can having surprising interactions with
    `INCOHERENT` instances, as observed in #22492. This patch
    resolves #22492 by documenting this strange interaction in the GHC User's
    Guide.
    
    [ci skip]
    
    - - - - -
    1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00
    Fix #22300 Document GHC's extensions to valid whitespace
    
    - - - - -
    79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00
    Add support for environments that don't have setImmediate
    
    - - - - -
    5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00
    Fix bound thread status
    
    - - - - -
    65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00
    Update containers submodule
    
    This contains a fix necessary for the multi-repl to work on GHC's code
    base where we try to load containers and template-haskell into the same
    session.
    
    - - - - -
    4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00
    hadrian-multi: Put interface files in separate directories
    
    Before we were putting all the interface files in the same directory
    which was leading to collisions if the files were called the same thing.
    
    - - - - -
    8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00
    hadrian-toolargs: Add filepath to allowed repl targets
    
    - - - - -
    5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00
    driver: Set correct UnitId when rehydrating modules
    
    We were not setting the UnitId before rehydrating modules which just led
    to us attempting to find things in the wrong HPT. The test for this is
    the hadrian-multi command (which is now added as a CI job).
    
    Fixes #22222
    
    - - - - -
    ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00
    ci: Add job to test hadrian-multi command
    
    I am not sure this job is good because it requires booting HEAD with
    HEAD, but it should be fine.
    
    - - - - -
    fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00
    hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series.
    
    This updates the build plans for the most recent compiler versions, as
    well as fixing the hadrian-bootstrap-gen script to a specific GHC
    version.
    
    - - - - -
    195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00
    ci: Bump boot images to use ghc-9.4.3
    
    Also updates the bootstrap jobs to test booting 9.2 and 9.4.
    
    - - - - -
    c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00
    hlint: Removed redundant UnboxedSums pragmas
    
    UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just
    the way it is.
    
    See #22485
    
    - - - - -
    b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00
    Add heqT, a kind-heterogeneous variant of heq
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/99
    
    - - - - -
    bfd7c1e6 by Andrew Lelechenko at 2022-12-11T12:26:55-05:00
    Document that Bifunctor instances for tuples are lawful only up to laziness
    
    - - - - -
    5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00
    Mark T21336a fragile
    
    - - - - -
    c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00
    Add test for #21476
    
    This issues seems to have been fixed since the ticket was made, so let's
    add a test and move on.
    
    Fixes #21476
    
    - - - - -
    e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00
    Respect -XStrict in the pattern-match checker (#21761)
    
    We were missing a call to `decideBangHood` in the pattern-match checker.
    There is another call in `matchWrapper.mk_eqn_info` which seems redundant
    but really is not; see `Note [Desugaring -XStrict matches in Pmc]`.
    
    Fixes #21761.
    
    - - - - -
    884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00
    Fix loop in the interface representation of some `Unfolding` fields
    
    As discovered in #22272, dehydration of the unfolding info of a
    recursive definition used to involve a traversal of the definition
    itself, which in turn involves traversing the unfolding info. Hence,
    a loop.
    
    Instead, we now store enough data in the interface that we can produce
    the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot]
    for details.
    
    Fixes #22272
    
    Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00
    EPA: When splitting out header comments, keep ones for first decl
    
    Any comments immediately preceding the first declaration are no longer
    kept as header comments, but attach to the first declaration instead.
    
    - - - - -
    8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00
    JS: fix object file name comparison (#22578)
    
    - - - - -
    e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00
    configure: Bump min bootstrap GHC version to 9.2
    
    - - - - -
    75855643 by Ben Gamari at 2022-12-15T03:54:02-05:00
    hadrian: Don't enable TSAN in stage0 build
    
    - - - - -
    da7b51d8 by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm: Introduce blockConcat
    
    - - - - -
    34f6b09c by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm: Introduce MemoryOrderings
    
    - - - - -
    43beaa7b by Ben Gamari at 2022-12-15T03:54:02-05:00
    llvm: Respect memory specified orderings
    
    - - - - -
    8faf74fc by Ben Gamari at 2022-12-15T03:54:02-05:00
    Codegen/x86: Eliminate barrier for relaxed accesses
    
    - - - - -
    6cc3944a by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm/Parser: Reduce some repetition
    
    - - - - -
    6c9862c4 by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm/Parser: Add syntax for ordered loads and stores
    
    - - - - -
    748490d2 by Ben Gamari at 2022-12-15T03:54:02-05:00
    cmm/Parser: Atomic load syntax
    
    Originally I had thought I would just use the `prim` call syntax instead
    of introducing new syntax for atomic loads. However, it turns out that
    `prim` call syntax tends to make things quite unreadable. This new
    syntax seems quite natural.
    
    - - - - -
    28c6781a by Ben Gamari at 2022-12-15T03:54:02-05:00
    codeGen: Introduce ThreadSanitizer instrumentation
    
    This introduces a new Cmm pass which instruments the program with
    ThreadSanitizer annotations, allowing full tracking of mutator memory
    accesses via TSAN.
    
    - - - - -
    d97aa311 by Ben Gamari at 2022-12-15T03:54:02-05:00
    Hadrian: Drop TSAN_ENABLED define from flavour
    
    This is redundant since the TSANUtils.h already defines it.
    
    - - - - -
    86974ef1 by Ben Gamari at 2022-12-15T03:54:02-05:00
    hadrian: Enable Cmm instrumentation in TSAN flavour
    
    - - - - -
    93723290 by Ben Gamari at 2022-12-15T03:54:02-05:00
    rts: Ensure that global regs are never passed as fun call args
    
    This is in general unsafe as they may be clobbered if they are mapped to
    caller-saved machine registers. See Note [Register parameter passing].
    
    - - - - -
    2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-05:00
    Package Imports: Get candidate packages also from re-exported modules
    
    Previously we were just looking at the direct imports to try and work
    out what a package qualifier could apply to but #22333 pointed out we
    also needed to look for reexported modules.
    
    Fixes #22333
    
    - - - - -
    552b7908 by Ben Gamari at 2022-12-15T03:55:15-05:00
    compiler: Ensure that MutVar operations have necessary barriers
    
    Here we add acquire and release barriers in readMutVar# and
    writeMutVar#, which are necessary for soundness.
    
    Fixes #22468.
    
    - - - - -
    933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-05:00
    Fix bogus test in Lint
    
    The Lint check for branch compatiblity within an axiom, in
    GHC.Core.Lint.compatible_branches was subtly different to the
    check made when contructing an axiom, in
    GHC.Core.FamInstEnv.compatibleBranches.
    
    The latter is correct, so I killed the former and am now using the
    latter.
    
    On the way I did some improvements to pretty-printing and documentation.
    
    - - - - -
    03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-05:00
    checkValidInst: Don't expand synonyms when splitting sigma types
    
    Previously, the `checkValidInst` function (used when checking that an instance
    declaration is headed by an actual type class, not a type synonym) was using
    `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is
    incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause
    instances headed by quantified constraint type synonyms to be accepted
    erroneously.
    
    This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy`
    specialized for validity checking that does _not_ expand type synonyms, and
    uses it in `checkValidInst`.
    
    Fixes #22570.
    
    - - - - -
    ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts/Messages: Refactor
    
    This doesn't change behavior but makes the code a bit easier to follow.
    
    - - - - -
    7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts/ThreadPaused: Ordering fixes
    
    - - - - -
    914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00
    eventlog: Silence spurious data race
    
    - - - - -
    fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00
    Introduce SET_INFO_RELEASE for Cmm
    
    - - - - -
    821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts: Use fences instead of explicit barriers
    
    - - - - -
    2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts/stm: Fix memory ordering in readTVarIO#
    
    See #22421.
    
    - - - - -
    99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00
    Improve heap memory barrier Note
    
    Also introduce MUT_FIELD marker in Closures.h to document mutable
    fields.
    
    - - - - -
    70999283 by Ben Gamari at 2022-12-16T16:12:44-05:00
    rts: Introduce getNumCapabilities
    
    And ensure accesses to n_capabilities are atomic (although with relaxed
    ordering). This is necessary as RTS API callers may concurrently call
    into the RTS without holding a capability.
    
    - - - - -
    98689f77 by Ben Gamari at 2022-12-16T16:12:44-05:00
    ghc: Fix data race in dump file handling
    
    Previously the dump filename cache would use a non-atomic update which
    could potentially result in lost dump contents. Note that this is still
    a bit racy since the first writer may lag behind a later appending
    writer.
    
    - - - - -
    605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Always use atomics for context_switch and interrupt
    
    Since these are modified by the timer handler.
    
    - - - - -
    86f20258 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts/Timer: Always use atomic operations
    
    As noted in #22447, the existence of the pthread-based ITimer
    implementation means that we cannot assume that the program is
    single-threaded.
    
    - - - - -
    f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Encapsulate recent_activity access
    
    This makes it easier to ensure that it is accessed using the necessary
    atomic operations.
    
    - - - - -
    e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Encapsulate access to capabilities array
    
    - - - - -
    7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Encapsulate sched_state
    
    - - - - -
    1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00
    PrimOps: Fix benign MutVar race
    
    Relaxed ordering is fine here since the later CAS implies a release.
    
    - - - - -
    3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Style fix
    
    - - - - -
    82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00
    compiler: Use release store in eager blackholing
    
    - - - - -
    eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Fix ordering of makeStableName
    
    - - - - -
    ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Use ordered accesses instead of explicit barriers
    
    - - - - -
    a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Statically allocate capabilities
    
    This is a rather simplistic way of solving #17289.
    
    - - - - -
    287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Ensure that all accesses to pending_sync are atomic
    
    - - - - -
    351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00
    rts: Note race with wakeBlockingQueue
    
    - - - - -
    5acf33dd by Andrew Lelechenko at 2022-12-16T16:13:22-05:00
    Bump submodule directory to 1.3.8.0 and hpc to HEAD
    
    - - - - -
    0dd95421 by Andrew Lelechenko at 2022-12-16T16:13:22-05:00
    Accept allocations increase on Windows
    
    This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips
    between lists and ByteArray. See #22625 for discussion.
    
    Metric Increase:
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModules
        MultiLayerModulesRecomp
        T10421
        T10547
        T12150
        T12227
        T12234
        T12425
        T13035
        T13253
        T13253-spj
        T13701
        T13719
        T15703
        T16875
        T18140
        T18282
        T18304
        T18698a
        T18698b
        T18923
        T20049
        T21839c
        T21839r
        T5837
        T6048
        T9198
        T9961
        TcPlugin_RewritePerf
        hard_hole_fits
    
    - - - - -
    ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00
    testsuite: Mark T9405 as fragile instead of broken on Windows
    
    It's starting to pass again, and the unexpected pass blocks CI.
    
    - - - - -
    1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00
    compiler: remove obsolete commented code in wasm NCG
    
    It was just a temporary hack to workaround a bug in the relooper, that
    bug has been fixed long before the wasm backend is merged.
    
    - - - - -
    e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00
    compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm
    
    Also removes some unreachable code here.
    
    - - - - -
    1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00
    compiler: change fallback function signature to Cmm function signature in wasm NCG
    
    In the wasm NCG, when handling a `CLabel` of undefined function
    without knowing its function signature, we used to fallback to `() ->
    ()` which is accepted by `wasm-ld`. This patch changes it to the
    signature of Cmm functions, which equally works, but would be required
    when we emit tail call instructions.
    
    - - - - -
    8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00
    compiler: add optional tail-call support in wasm NCG
    
    When the `-mtail-call` clang flag is passed at configure time, wasm
    tail-call extension is enabled, and the wasm NCG will emit
    `return_call`/`return_call_indirect` instructions to take advantage of
    it and avoid the `StgRun` trampoline overhead.
    
    Closes #22461.
    
    - - - - -
    d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00
    base: add missing autoconf checks for waitpid/umask
    
    These are not present in wasi-libc. Required for fixing #22589
    
    - - - - -
    da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00
    compiler: make .wasm the default executable extension on wasm32
    
    Following convention as in other wasm toolchains. Fixes #22594.
    
    - - - - -
    ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00
    ci: support hello.wasm in ci.sh cross testing logic
    
    - - - - -
    6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00
    Correct `exitWith` Haddocks
    
    The `IOError`-specific `catch` in the Prelude is long gone.
    
    - - - - -
    b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-05:00
    rts: Drop racy assertion
    
    0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in
    `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean.
    However, this isn't necessarily the case since another thread may have
    raced us to dirty the object.
    
    - - - - -
    761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00
    rts/libdw: Silence uninitialized usage warnings
    
    As noted in #22538, previously some GCC versions warned that various
    locals in Libdw.c may be used uninitialized. Although this wasn't
    strictly true (since they were initialized in an inline assembler block)
    we fix this by providing explicit empty initializers.
    
    Fixes #22538
    - - - - -
    5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00
    testsuite: Mark T16392 as fragile on windows
    
    See #22649
    
    - - - - -
    703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00
    Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`.
    
    - - - - -
    9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05:00
    packaging: Fix upload_ghc_libs.py script
    
    This change reflects the changes where .cabal files are now generated by
    hadrian rather than ./configure.
    
    Fixes #22518
    
    - - - - -
    7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00
    configure: Drop uses of AC_PROG_CC_C99
    
    As noted in #22566, this macro is deprecated as of autoconf-2.70
    `AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself.
    
    Closes #22566.
    
    - - - - -
    36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00
    configure: Use AS_HELP_STRING instead of AC_HELP_STRING
    
    The latter has been deprecated.
    
    See #22566.
    
    - - - - -
    befe6ff8 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
    GHCi.UI: fix various usages of head and tail
    
    - - - - -
    666d0ba7 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
    GHCi.UI: avoid head and tail in parseCallEscape and around
    
    - - - - -
    5d96fd50 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
    Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty
    
    - - - - -
    3ce2ab94 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
    Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian
    
    - - - - -
    954de93a by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
    Update submodule haskeline to HEAD (to allow transformers-0.6)
    
    - - - - -
    cefbeec3 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
    Update submodule transformers to 0.6.0.4
    
    - - - - -
    b4730b62 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
    Fix tests
    
    T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations
    
    Metric Increase:
        T13253
    
    - - - - -
    0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05:00
    Abstract over the right free vars
    
    Fix #22459, in two ways:
    
    (1) Make the Specialiser not create a bogus specialisation if
        it is presented by strangely polymorphic dictionary.
        See Note [Weird special case in SpecDict] in
        GHC.Core.Opt.Specialise
    
    (2) Be more careful in abstractFloats
        See Note [Which type variables to abstract over]
        in GHC.Core.Opt.Simplify.Utils.
    
    So (2) stops creating the excessively polymorphic dictionary in
    abstractFloats, while (1) stops crashing if some other pass should
    nevertheless create a weirdly polymorphic dictionary.
    
    - - - - -
    df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00
    rts: explicitly store return value of ccall checkClosure to prevent type error (#22617)
    
    - - - - -
    e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00
    Fix shadowing lacuna in OccurAnal
    
    Issue #22623 demonstrated another lacuna in the implementation
    of wrinkle (BS3) in Note [The binder-swap substitution] in
    the occurrence analyser.
    
    I was failing to add TyVar lambda binders using
    addInScope/addOneInScope and that led to a totally bogus binder-swap
    transformation.
    
    Very easy to fix.
    
    - - - - -
    3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00
    Fix an assertion check in addToEqualCtList
    
    The old assertion saw that a constraint ct could rewrite itself
    (of course it can) and complained (stupid).
    
    Fixes #22645
    
    - - - - -
    ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00
    configure: Bump version to 9.6
    
    - - - - -
    fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00
    base: Bump version to 4.18
    
    Requires various submodule bumps.
    
    - - - - -
    93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00
    ghc-boot: Fix bootstrapping
    
    - - - - -
    fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00
    Bump GHC version to 9.7
    
    - - - - -
    914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05:00
    Don't consider large byte arrays/compact regions pinned.
    
    Workaround for #22255 which showed how treating large/compact regions
    as pinned could cause segfaults.
    
    - - - - -
    32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05:00
    hadrian bindist: Install manpages to share/man/man1/ghc.1
    
    When the installation makefile was copied over the manpages were no
    longer installed in the correct place. Now we install it into share/man/man1/ghc.1
    as the make build system did.
    
    Fixes #22371
    
    - - - - -
    b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00
    rts: Drop paths from configure from cabal file
    
    A long time ago we would rely on substitutions from the configure script
    to inject paths of the include and library directories of libffi and
    libdw. However, now these are instead handled inside Hadrian when
    calling Cabal's `configure` (see the uses of `cabalExtraDirs` in
    Hadrian's `Settings.Packages.packageArgs`).
    
    While the occurrences in the cabal file were redundant, they did no
    harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have
    no longer been interpolated. @mpickering noticed the suspicious
    uninterpolated occurrence of `@FFIIncludeDir@` in #22595,
    prompting this commit to finally remove them.
    
    - - - - -
    b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00
    Bump libffi-tarballs submodule
    
    We will now use libffi-3.4.4.
    
    - - - - -
    3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00
    EPA: Make EOF position part of AnnsModule
    
    Closes #20951
    Closes #19697
    
    - - - - -
    99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05:00
    JS: fix support for -outputdir (#22641)
    
    The `-outputdir` option wasn't correctly handled with the JS backend
    because the same code path was used to handle both objects produced by
    the JS backend and foreign .js files. Now we clearly distinguish the
    two in the pipeline, fixing the bug.
    
    - - - - -
    02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05:00
    Refactor mkRuntimeError
    
    This patch fixes #22634.  Because we don't have TYPE/CONSTRAINT
    polymorphism, we need two error functions rather than one.
    
    I took the opportunity to rname runtimeError to impossibleError,
    to line up with mkImpossibleExpr, and avoid confusion with the
    genuine runtime-error-constructing functions.
    
    - - - - -
    35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00
    base: Fix event manager shutdown race on non-Linux platforms
    
    During shutdown it's possible that we will attempt to use a closed fd
    to wakeup another capability's event manager. On the Linux eventfd path
    we were careful to handle this. However on the non-Linux path we failed
    to do so. Fix this.
    
    - - - - -
    317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00
    Fix unifier bug: failing to decompose over-saturated type family
    
    This simple patch fixes #22647
    
    - - - - -
    14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00
    rts/m32: Fix sanity checking
    
    Previously we would attempt to clear pages which were marked as
    read-only. Fix this.
    
    - - - - -
    16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00
    ci: Move wasm pipelines into nightly rather than master
    
    See #22664 for the changes which need to be made to bring one of these
    back to the validate pipeline.
    
    - - - - -
    18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix race in marking of blackholes
    
    We must use an acquire-fence when marking to ensure that the indirectee
    is visible.
    
    - - - - -
    11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix segment list races
    
    - - - - -
    602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Use atomic when looking at bd->gen
    
    Since it may have been mutated by a moving GC.
    
    - - - - -
    9d63b160 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Eliminate race in bump_static_flag
    
    To ensure that we don't race with a mutator entering a new CAF we take
    the SM mutex before touching static_flag. The other option here would be
    to instead modify newCAF to use a CAS but the present approach is a bit
    safer.
    
    - - - - -
    26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Ensure that mutable fields have acquire barrier
    
    - - - - -
    8093264a by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix races in collector status tracking
    
    Mark a number of accesses to do with tracking of the status of the
    concurrent collection thread as atomic. No interesting races here,
    merely necessary to satisfy TSAN.
    
    - - - - -
    387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Make segment state updates atomic
    
    - - - - -
    543cae00 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Refactor update remembered set initialization
    
    This avoids a lock inversion between the storage manager mutex and
    the stable pointer table mutex by not dropping the SM_MUTEX in
    nonmovingCollect. This requires quite a bit of rejiggering but it
    does seem like a better strategy.
    
    - - - - -
    c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Ensure that we aren't holding locks when closing them
    
    TSAN complains about this sort of thing.
    
    - - - - -
    0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Make bitmap accesses atomic
    
    This is a benign race on any sensible hard since these are byte
    accesses. Nevertheless, atomic accesses are necessary to satisfy
    TSAN.
    
    - - - - -
    d3fe110a by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix benign race in update remembered set check
    
    Relaxed load is fine here since we will take the lock before looking at
    the list.
    
    - - - - -
    ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Fix race in shortcutting
    
    We must use an acquire load to read the info table pointer since if we
    find an indirection we must be certain that we see the indirectee.
    
    - - - - -
    36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00
    nonmoving: Make free list counter accesses atomic
    
    Since these may race with the allocator(s).
    
    - - - - -
    aebef31c by doyougnu at 2022-12-23T19:10:09-05:00
    add GHC.Utils.Binary.foldGet' and use for Iface
    
    A minor optimization to remove lazy IO and a lazy accumulator
    
    strictify foldGet'
    
    IFace.Binary: use strict foldGet'
    
    remove superfluous bang
    
    - - - - -
    5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-05:00
    compiler: Ensure that GHC toolchain is first in search path
    
    As noted in #22561, it is important that GHC's toolchain look
    first for its own headers and libraries to ensure that the
    system's are not found instead. If this happens things can
    break in surprising ways (e.g. see #22561).
    
    - - - - -
    cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05:00
    head.hackage: Use slow-validate bindist for linting jobs
    
    This enables the SLOW_VALIDATE env var for the linting head.hackage
    jobs, namely the jobs enabled manually, by the label or on the nightly
    build now use the deb10-numa-slow-validate bindist which has assertions
    enabled.
    
    See #22623 for a ticket which was found by using this configuration
    already!
    
    The head.hackage jobs triggered by upstream CI are now thusly:
    
    hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build.
                  Runs head.hackage with -dlint and a slow-validate bindist
    
    hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate
                        head.hackage build with -dlint.
    
    nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config.
    
    nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled.
    
    release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist.
    
    - - - - -
    f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05:00
    ci: Don't run abi-test-nightly on release jobs
    
    The test is not configured to get the correct dependencies for the
    release pipelines (and indeed stops the release pipeline being run at
    all)
    
    - - - - -
    c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05:00
    ci: Run head.hackage jobs on upstream-testing branch rather than master
    
    This change allows less priviledged users to trigger head.hackage jobs
    because less permissions are needed to trigger jobs on the
    upstream-testing branch, which is not protected.
    
    There is a CI job which updates upstream-testing each hour to the state
    of the master branch so it should always be relatively up-to-date.
    
    - - - - -
    63b97430 by Ben Gamari at 2022-12-24T00:42:16-05:00
    llvmGen: Fix relaxed ordering
    
    Previously I used LLVM's `unordered` ordering for the C11 `relaxed`
    ordering. However, this is wrong and should rather use the LLVM
    `monotonic` ordering.
    
    Fixes #22640
    - - - - -
    f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00
    gitlab-ci: Introduce aarch64-linux-llvm job
    
    This nightly job will ensure that we don't break the LLVM backend on
    AArch64/Linux by bootstrapping GHC.
    
    This would have caught #22640.
    
    - - - - -
    6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05:00
    Store RdrName rather than OccName in Holes
    
    In #20472 it was pointed out that you couldn't defer out of scope but
    the implementation collapsed a RdrName into an OccName to stuff it into
    a Hole. This leads to the error message for a deferred qualified name
    dropping the qualification which affects the quality of the error
    message.
    
    This commit adds a bit more structure to a hole, so a hole can replace a
    RdrName without losing information about what that RdrName was. This is
    important when printing error messages.
    
    I also added a test which checks the Template Haskell deferral of out of
    scope qualified names works properly.
    
    Fixes #22130
    
    - - - - -
    3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00
    Drop support for kind constraints.
    
    This implements proposal 547 and closes ticket #22298.
    See the proposal and ticket for motivation.
    
    Compiler perf improves a bit
    
    Metrics: compile_time/bytes allocated
    -------------------------------------
      CoOpt_Singletons(normal)   -2.4% GOOD
                T12545(normal)   +1.0%
                T13035(normal)  -13.5% GOOD
                T18478(normal)   +0.9%
                T9872d(normal)   -2.2% GOOD
    
                     geo. mean   -0.2%
                     minimum    -13.5%
                     maximum     +1.0%
    
    Metric Decrease:
        CoOpt_Singletons
        T13035
        T9872d
    
    - - - - -
    6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05:00
    hadrian: Ensure that linker scripts are used when merging objects
    
    In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's
    implementation of the object merging rules: unlike the old `make` build
    system we utterly failed to pass the needed linker scripts. Fix this.
    
    - - - - -
    a5bd0eb8 by Andrew Lelechenko at 2022-12-24T21:10:34-05:00
    Document infelicities of instance Ord Double and workarounds
    
    - - - - -
    62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+00:00
    Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface
    
    Involves adding many new NFData instances.
    
    Without forcing Docs, references to the TcGblEnv for each module are retained
    by the Docs structure. Usually these are forced when the ModIface is serialised
    but not when we aren't writing the interface.
    
    - - - - -
    21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00
    Explain the auxiliary functions of permutations
    
    - - - - -
    32255d05 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    compiler: Add -f[no-]split-sections flags
    
    Here we add a `-fsplit-sections` flag which may some day replace
    `-split-sections`. This has the advantage of automatically providing a
    `-fno-split-sections` flag, which is useful for our packaging because we
    enable `-split-sections` by default but want to disable it in certain
    configurations.
    
    - - - - -
    e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00
    hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler
    
    This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b
    
    - - - - -
    15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    hadrian: Add test:all_deps to build just testsuite dependencies
    
    Fixes #22534
    
    - - - - -
    fec6638e by Matthew Pickering at 2023-01-04T11:58:42+00:00
    hadrian: Add no_split_sections tranformer
    
    This transformer reverts the effect of `split_sections`, which we intend
    to use for platforms which don't support split sections.
    
    In order to achieve this we have to modify the implemntation of the
    split_sections transformer to store whether we are enabling
    split_sections directly in the `Flavour` definition. This is because
    otherwise there's no convenient way to turn off split_sections due to
    having to pass additional linker scripts when merging objects.
    
    - - - - -
    3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    check-exact: Fix build with -Werror
    
    - - - - -
    53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+00:00
    ci: Build all test dependencies with in-tree compiler
    
    This means that these executables will honour flavour transformers such
    as "werror".
    
    Fixes #22555
    
    - - - - -
    32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    hadrian: Document using GHC environment variable to select boot compiler
    
    Fixes #22340
    
    - - - - -
    be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+00:00
    packaging: Build perf builds with -split-sections
    
    In 8f71d958 the make build system was made to use split-sections on
    linux systems but it appears this logic never made it to hadrian.
    There is the split_sections flavour transformer but this doesn't appear
    to be used for perf builds on linux.
    
    This is disbled on deb9 and windows due to #21670
    
    Closes #21135
    
    - - - - -
    00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05:00
    sphinx: Use modern syntax for extlinks
    
    This fixes the following build error:
    
    ```
      Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273
      ===> Command failed with error code: 2
    
      Exception occurred:
        File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role
          title = caption % part
                  ~~~~~~~~^~~~~~
      TypeError: not all arguments converted during string formatting
    ```
    
    I tested on Sphinx-5.1.1 and Sphinx-6.0.0
    
    Thanks for sterni for providing instructions about how to test using
    sphinx-6.0.0.
    
    Fixes #22690
    
    - - - - -
    541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00
    Misc cleanup
    
    - Remove unused uniques and hs-boot declarations
    - Fix types of seq and unsafeCoerce#
    - Remove FastString/String roundtrip in JS
    - Use TTG to enforce totality
    - Remove enumeration in Heap/Inspect; the 'otherwise' clause
      serves the primitive types well.
    
    - - - - -
    22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00
    EPA: Do not collect comments from end of file
    
    In Parser.y semis1 production triggers for the virtual semi at the end
    of the file. This is detected by it being zero length.
    
    In this case, do not extend the span being used to gather comments, so
    any final comments are allocated at the module level instead.
    
    - - - - -
    9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00
    HsToken in TypeArg (#19623)
    
    Updates the haddock submodule.
    
    - - - - -
    b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05:00
    Revert "configure: Drop uses of AC_PROG_CC_C99"
    
    This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6.
    
    Centos7 using a very old version of the toolchain (autotools-2.69) where
    the behaviour of these macros has not yet changed. I am reverting this
    without haste as it is blocking the 9.6 branch.
    
    Fixes #22704
    
    - - - - -
    28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09:00
    Add support for sized literals in the bytecode interpreter.
    
    The bytecode interpreter only has branching instructions for
    word-sized values. These are used for pattern matching.
    Branching instructions for other types (e.g. Int16# or Word8#)
    weren't needed, since unoptimized Core or STG never requires
    branching on types like this.
    
    It's now possible for optimized STG to reach the bytecode
    generator (e.g. fat interface files or certain compiler flag
    combinations), which requires dealing with various sized
    literals in branches.
    
    This patch improves support for generating bytecode from
    optimized STG by adding the following new bytecode
    instructions:
    
        TESTLT_I64
        TESTEQ_I64
        TESTLT_I32
        TESTEQ_I32
        TESTLT_I16
        TESTEQ_I16
        TESTLT_I8
        TESTEQ_I8
        TESTLT_W64
        TESTEQ_W64
        TESTLT_W32
        TESTEQ_W32
        TESTLT_W16
        TESTEQ_W16
        TESTLT_W8
        TESTEQ_W8
    
    Fixes #21945
    
    - - - - -
    ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-05:00
    Only store Name in FunRhs rather than Id with knot-tied fields
    
    All the issues here have been caused by #18758.
    The goal of the ticket is to be able to talk about things like
    `LTyClDecl GhcTc`. In the case of HsMatchContext,
    the correct "context" is whatever we want, and in fact storing just a
    `Name` is sufficient and correct context, even if the rest of the AST is
    storing typechecker Ids.
    
    So this reverts (#20415, !5579) which intended to get closed to #18758 but
    didn't really and introduced a few subtle bugs.
    
    Printing of an error message in #22695 would just hang, because we would
    attempt to print the `Id` in debug mode to assertain whether it was
    empty or not. Printing the Name is fine for the error message.
    
    Another consequence is that when `-dppr-debug` was enabled the compiler would
    hang because the debug printing of the Id would try and print fields
    which were not populated yet.
    
    This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add
    a workaround for the `checkArgs` function which was probably a very
    similar bug to #22695.
    
    Fixes #22695
    
    - - - - -
    c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00
    ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3
    
    Fixes #22599
    
    - - - - -
    0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05:00
    darwin ci: Explicitly pass desired build triple to configure
    
    On the zw3rk machines for some reason the build machine was inferred to
    be arm64. Setting the build triple appropiately resolve this confusion
    and we produce x86 binaries.
    
    - - - - -
    2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00
    rts: MUT_VAR is not a StgMutArrPtrs
    
    There was previously a comment claiming that the MUT_VAR closure type
    had the layout of StgMutArrPtrs.
    - - - - -
    6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-05:00
    Make FloatIn robust to shadowing
    
    This MR fixes #22622. See the new
      Note [Shadowing and name capture]
    
    I did a bit of refactoring in sepBindsByDropPoint too.
    
    The bug doesn't manifest in HEAD, but it did show up in 9.4,
    so we should backport this patch to 9.4
    
    - - - - -
    a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05:00
    T10955: Set DYLD_LIBRARY_PATH for darwin
    
    The correct path to direct the dynamic linker on darwin is
    DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX
    using LD_LIBRARY_PATH seems to have stopped working.
    
    For more reading see:
    
    https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s
    
    - - - - -
    73484710 by Matthew Pickering at 2023-01-07T12:15:15-05:00
    Skip T18623 on darwin (to add to the long list of OSs)
    
    On recent versions of OSX, running `ulimit -v` results in
    
    ```
    ulimit: setrlimit failed: invalid argument
    ```
    
    Time is too short to work out what random stuff Apple has been doing
    with ulimit, so just skip the test like we do for other platforms.
    
    - - - - -
    8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05:00
    Pass -Wl,-no_fixup_chains to ld64 when appropiate
    
    Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default.
    This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we
    explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on
    darwin. This results in a warning of the form:
    
    ld: warning: -undefined dynamic_lookup may not work with chained fixups
    
    The manual explains the incompatible nature of these two flags:
    
         -undefined treatment
                 Specifies how undefined symbols are to be treated. Options are: error, warning,
                 suppress, or dynamic_lookup.  The default is error. Note: dynamic_lookup that
                 depends on lazy binding will not work with chained fixups.
    
    A relevant ticket is #22429
    
    Here are also a few other links which are relevant to the issue:
    
    Official comment: https://developer.apple.com/forums/thread/719961
    
    More relevant links:
    
    https://openradar.appspot.com/radar?id=5536824084660224
    
    https://github.com/python/cpython/issues/97524
    
    Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas    e-notes
    
    - - - - -
    365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05:00
    Disable split sections on aarch64-deb10 build
    
    See #22722
    
    Failure on this job:
    
    https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852
    
    ```
    Unexpected failures:
       /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T10828.run  T10828 [exit code non-0] (ext-interp)
       /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T13123.run  T13123 [exit code non-0] (ext-interp)
       /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T20590.run  T20590 [exit code non-0] (ext-interp)
    Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv
    ```
    
    ```
    Compile failed (exit code 1) errors were:
    data family D_0 a_1 :: * -> *
    data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where
        DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool
    data E_3 where MkE_4 :: a_5 -> E_3
    data Foo_6 a_7 b_8 where
        MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12
    newtype Bar_13 :: * -> GHC.Types.Bool -> * where
        MkBar_14 :: a_15 -> Bar_13 a_15 b_16
    data T10828.T (a_0 :: *) where
        T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1
        T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2
                                                                   GHC.Types.Int => {T10828.foo :: a_2,
                                                                                     T10828.bar :: b_3} -> T10828.T GHC.Types.Int
    T10828.hs:1:1: error: [GHC-87897]
        Exception when trying to run compile-time code:
          ghc-iserv terminated (-4)
        Code: (do TyConI dec <- runQ $ reify (mkName "T")
                  runIO $ putStrLn (pprint dec) >> hFlush stdout
                  d <- runQ
                         $ [d| data T' a :: Type
                                 where
                                   MkT' :: a -> a -> T' a
                                   MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |]
                  runIO $ putStrLn (pprint d) >> hFlush stdout
                  ....)
    *** unexpected failure for T10828(ext-interp)
    =====> 7000 of 9215 [0, 1, 0]
    =====> 7000 of 9215 [0, 1, 0]
    =====> 7000 of 9215 [0, 1, 0]
    =====> 7000 of 9215 [0, 1, 0]
    Compile failed (exit code 1) errors were:
    T13123.hs:1:1: error: [GHC-87897]
        Exception when trying to run compile-time code:
          ghc-iserv terminated (-4)
        Code: ([d| data GADT
                     where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |])
    *** unexpected failure for T13123(ext-interp)
    =====> 7100 of 9215 [0, 2, 0]
    =====> 7100 of 9215 [0, 2, 0]
    =====> 7200 of 9215 [0, 2, 0]
    Compile failed (exit code 1) errors were:
    T20590.hs:1:1: error: [GHC-87897]
        Exception when trying to run compile-time code:
          ghc-iserv terminated (-4)
        Code: ([d| data T where MkT :: forall a. a -> T |])
    *** unexpected failure for T20590(ext-interp)
    ```
    
    Looks fairly worrying to me.
    
    - - - - -
    965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00
    EPA: exact print HsDocTy
    
    To match ghc-exactprint
    https://github.com/alanz/ghc-exactprint/pull/121
    
    - - - - -
    5d65773e by John Ericson at 2023-01-09T20:39:27-05:00
    Remove RTS hack for configuring
    
    See the brand new Note [Undefined symbols in the RTS] for additional
    details.
    
    - - - - -
    e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-05:00
    Handle shadowing in DmdAnal (#22718)
    
    Previously, when we had a shadowing situation like
    ```hs
    f x = ... -- demand signature <1L><1L>
    
    main = ... \f -> f 1 ...
    ```
    we'd happily use the shadowed demand signature at the call site inside the
    lambda. Of course, that's wrong and solution is simply to remove the demand
    signature from the `AnalEnv` when we enter the lambda.
    This patch does so for all binding constructs Core.
    
    In #22718 the issue was caused by LetUp not shadowing away the existing demand
    signature for the let binder in the let body. The resulting absent error is
    fickle to reproduce; hence no reproduction test case. #17478 would help.
    
    Fixes #22718.
    
    It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that
    DmdAnal was exploiting ill-scoped analysis results.
    
    Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate):
        TcPlugin_Rewrite
    
    - - - - -
    d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00
    Add safe list indexing operator: !?
    
    With Joachim's amendments.
    
    Implements https://github.com/haskell/core-libraries-committee/issues/110
    
    - - - - -
    cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00
    rts, tests: limit thread name length to 15 bytes
    
    On Linux, `pthread_setname_np` (or rather, the kernel) only allows for
    thread names up to 16 bytes, including the terminating null byte.
    
    This commit adds a note pointing this out in `createOSThread`, and fixes
    up two instances where a thread name of more than 15 characters long was
    used (in the RTS, and in a test-case).
    
    Fixes: #22366
    Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366
    See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796
    
    - - - - -
    64286132 by Matthew Pickering at 2023-01-09T21:11:03-05:00
    Store bootstrap_llvm_target and use it to set LlvmTarget in bindists
    
    This mirrors some existing logic for the bootstrap_target which
    influences how TargetPlatform is set.
    
    As described on #21970 not storing this led to `LlvmTarget` being set incorrectly
    and hence the wrong `--target` flag being passed to the C compiler.
    
    Towards #21970
    
    - - - - -
    4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05:00
    Check for FP_LD_NO_FIXUP_CHAINS in installation configure script
    
    Otherwise, when installing from a bindist the C flag isn't passed to the
    C compiler.
    
    This completes the fix for #22429
    
    - - - - -
    2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00
    Fix outdated link to Happy section on sequences
    
    - - - - -
    146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00
    Revert "NCG(x86): Compile add+shift as lea if possible."
    
    This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a.
    
    See #22666 and #21777
    
    - - - - -
    6e6adbe3 by Jade Lovelace at 2023-01-11T00:55:30-05:00
    Fix tcPluginRewrite example
    
    - - - - -
    faa57138 by Jade Lovelace at 2023-01-11T00:55:31-05:00
    fix missing haddock pipe
    
    - - - - -
    0470ea7c by Florian Weimer at 2023-01-11T00:56:10-05:00
    m4/fp_leading_underscore.m4: Avoid implicit exit function declaration
    
    And switch to a new-style function definition.
    
    Fixes build issues with compilers that do not accept implicit function
    declarations.
    
    - - - - -
    b2857df4 by HaskellMouse at 2023-01-11T00:56:52-05:00
    Added a new warning about compatibility with RequiredTypeArguments
    
    This commit introduces a new warning
    that indicates code incompatible with
    future extension: RequiredTypeArguments.
    
    Enabling this extension may break some code and the warning
    will help to make it compatible in advance.
    
    - - - - -
    5f17e21a by Ben Gamari at 2023-01-11T00:57:27-05:00
    testsuite: Drop testheapalloced.c
    
    As noted in #22414, this file (which appears to be a benchmark for
    characterising the one-step allocator's MBlock cache) is currently 
    unreferenced. Remove it.
    
    Closes #22414. 
    - - - - -
    bc125775 by Vladislav Zavialov at 2023-01-11T00:58:03-05:00
    Introduce the TypeAbstractions language flag
    
    GHC Proposals #448 "Modern scoped type variables"
    and #425 "Invisible binders in type declarations"
    introduce a new language extension flag: TypeAbstractions.
    
    Part of the functionality guarded by this flag has already been
    implemented, namely type abstractions in constructor patterns, but it
    was guarded by a combination of TypeApplications and ScopedTypeVariables
    instead of a dedicated language extension flag.
    
    This patch does the following:
    
    * introduces a new language extension flag TypeAbstractions
    * requires TypeAbstractions for @a-syntax in constructor patterns
      instead of TypeApplications and ScopedTypeVariables
    * creates a User's Guide page for TypeAbstractions and
      moves the "Type Applications in Patterns" section there
    
    To avoid a breaking change, the new flag is implied by
    ScopedTypeVariables and is retroactively added to GHC2021.
    
    Metric Decrease:
        MultiLayerModulesTH_OneShot
    
    - - - - -
    083f7015 by Krzysztof Gogolewski at 2023-01-11T00:58:38-05:00
    Misc cleanup
    
    - Remove unused mkWildEvBinder
    - Use typeTypeOrConstraint - more symmetric and asserts that
      that the type is Type or Constraint
    - Fix escape sequences in Python; they raise a deprecation warning
      with -Wdefault
    
    - - - - -
    aed1974e by Richard Eisenberg at 2023-01-11T08:30:42+00:00
    Refactor the treatment of loopy superclass dicts
    
    This patch completely re-engineers how we deal with loopy superclass
    dictionaries in instance declarations. It fixes #20666 and #19690
    
    The highlights are
    
    * Recognise that the loopy-superclass business should use precisely
      the Paterson conditions.  This is much much nicer.  See
      Note [Recursive superclasses] in GHC.Tc.TyCl.Instance
    
    * With that in mind, define "Paterson-smaller" in
      Note [Paterson conditions] in GHC.Tc.Validity, and the new
      data type `PatersonSize` in GHC.Tc.Utils.TcType, along with
      functions to compute and compare PatsonSizes
    
    * Use the new PatersonSize stuff when solving superclass constraints
      See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance
    
    * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to
      prohibitedSuperClassSolve.  This was the original cause of #20666.
    
    * Treat (TypeError "stuff") as having PatersonSize zero. See
      Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType.
    
    * Treat the head of a Wanted quantified constraint in the same way
      as the superclass of an instance decl; this is what fixes #19690.
      See GHC.Tc.Solver.Canonical Note [Solving a Wanted forall-constraint]
      (Thanks to Matthew Craven for this insight.)
    
      This entailed refactoring the GivenSc constructor of CtOrigin a bit,
      to say whether it comes from an instance decl or quantified constraint.
    
    * Some refactoring way in which redundant constraints are reported; we
      don't want to complain about the extra, apparently-redundant
      constraints that we must add to an instance decl because of the
      loopy-superclass thing.  I moved some work from GHC.Tc.Errors to
      GHC.Tc.Solver.
    
    * Add a new section to the user manual to describe the loopy
      superclass issue and what rules it follows.
    
    - - - - -
    300bcc15 by HaskellMouse at 2023-01-11T13:43:36-05:00
    Parse qualified terms in type signatures
    
    This commit allows qualified terms in type
    signatures to pass the parser and to be cathced by renamer
    with more informative error message. Adds a few tests.
    
    Fixes #21605
    
    - - - - -
    964284fc by Simon Peyton Jones at 2023-01-11T13:44:12-05:00
    Fix void-arg-adding mechanism for worker/wrapper
    
    As #22725 shows, in worker/wrapper we must add the void argument
    /last/, not first.  See GHC.Core.Opt.WorkWrap.Utils
    Note [Worker/wrapper needs to add void arg last].
    
    That led me to to study GHC.Core.Opt.SpecConstr
    Note [SpecConstr needs to add void args first] which suggests the
    opposite!  And indeed I think it's the other way round for SpecConstr
    -- or more precisely the void arg must precede the "extra_bndrs".
    
    That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo.
    
    - - - - -
    f7ceafc9 by Krzysztof Gogolewski at 2023-01-11T22:36:59-05:00
    Add 'docWithStyle' to improve codegen
    
    This new combinator
    
    docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc
    
    let us remove the need for code to be polymorphic in HDoc
    when not used in code style.
    
    Metric Decrease:
        ManyConstructors
        T13035
        T1969
    
    - - - - -
    b3be0d18 by Simon Peyton Jones at 2023-01-11T22:37:35-05:00
    Fix finaliseArgBoxities for OPAQUE function
    
    We never do worker wrapper for OPAQUE functions, so we must
    zap the unboxing info during strictness analysis.
    
    This patch fixes #22502
    
    - - - - -
    db11f358 by Ben Gamari at 2023-01-12T07:49:04-05:00
    Revert "rts: Drop racy assertion"
    
    The logic here was inverted. Reverting the commit to avoid confusion
    when examining the commit history.
    
    This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1.
    
    - - - - -
    3242139f by Ben Gamari at 2023-01-12T07:49:04-05:00
    rts: Drop racy assertion
    
    0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in
    `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean.
    However, this isn't necessarily the case since another thread may have
    raced us to dirty the object.
    
    - - - - -
    9ffd5d57 by Ben Gamari at 2023-01-12T07:49:41-05:00
    configure: Fix escaping of `$tooldir`
    
    In !9547 I introduced `$tooldir` directories into GHC's default link and
    compilation flags to ensure that our C toolchain finds its own headers
    and libraries before others on the system. However, the patch was subtly
    wrong in the escaping of `$tooldir`. Fix this.
    
    Fixes #22561.
    
    - - - - -
    905d0b6e by Sebastian Graf at 2023-01-12T15:51:47-05:00
    Fix contification with stable unfoldings (#22428)
    
    Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with
    a `JoinArity` that reflects the number of join point binders around the body
    for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by
    `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`.
    
    I adjusted `Note [Join points and unfoldings/rules]` and
    `Note [Adjusting right-hand sides]` to account for the new machinery.
    I also wrote a new `Note [Join arity prediction based on joinRhsArity]`
    and refer to it when we combine `TailUsageDetails` for a recursive RHS.
    
    I also renamed
    
      * `occAnalLam` to `occAnalLamTail`
      * `adjustRhsUsage` to `adjustTailUsage`
      * a few other less important functions
    
    and properly documented the that each call of `occAnalLamTail` must pair up with
    `adjustTailUsage`.
    
    I removed `Note [Unfoldings and join points]` because it was redundant with
    `Note [Occurrences in stable unfoldings]`.
    
    While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed
    `NodeDetails` called `SimpleNodeDetails`.
    
    Fixes #22428.
    
    The refactoring seems to have quite beneficial effect on ghc/alloc performance:
    
    ```
         CoOpt_Read(normal) ghc/alloc    784,778,420    768,091,176  -2.1% GOOD
             T12150(optasm) ghc/alloc     77,762,270     75,986,720  -2.3% GOOD
             T12425(optasm) ghc/alloc     85,740,186     84,641,712  -1.3% GOOD
             T13056(optasm) ghc/alloc    306,104,656    299,811,632  -2.1% GOOD
             T13253(normal) ghc/alloc    350,233,952    346,004,008  -1.2%
             T14683(normal) ghc/alloc  2,800,514,792  2,754,651,360  -1.6%
             T15304(normal) ghc/alloc  1,230,883,318  1,215,978,336  -1.2%
             T15630(normal) ghc/alloc    153,379,590    151,796,488  -1.0%
             T16577(normal) ghc/alloc  7,356,797,056  7,244,194,416  -1.5%
             T17516(normal) ghc/alloc  1,718,941,448  1,692,157,288  -1.6%
             T19695(normal) ghc/alloc  1,485,794,632  1,458,022,112  -1.9%
            T21839c(normal) ghc/alloc    437,562,314    431,295,896  -1.4% GOOD
            T21839r(normal) ghc/alloc    446,927,580    440,615,776  -1.4% GOOD
    
                  geo. mean                                          -0.6%
                  minimum                                            -2.4%
                  maximum                                            -0.0%
    ```
    
    Metric Decrease:
        CoOpt_Read
        T10421
        T12150
        T12425
        T13056
        T18698a
        T18698b
        T21839c
        T21839r
        T9961
    
    - - - - -
    a1491c87 by Andreas Klebinger at 2023-01-12T15:52:23-05:00
    Only gc sparks locally when we can ensure marking is done.
    
    When performing GC without work stealing there was no guarantee that
    spark pruning was happening after marking of the sparks. This could
    cause us to GC live sparks under certain circumstances.
    
    Fixes #22528.
    
    - - - - -
    8acfe930 by Cheng Shao at 2023-01-12T15:53:00-05:00
    Change MSYSTEM to CLANG64 uniformly
    
    - - - - -
    73bc162b by M Farkas-Dyck at 2023-01-12T15:53:42-05:00
    Make `GHC.Tc.Errors.Reporter` take `NonEmpty ErrorItem` rather than `[ErrorItem]`, which lets us drop some panics.
    
    Also use the `BasicMismatch` constructor rather than `mkBasicMismatchMsg`, which lets us drop the "-Wno-incomplete-record-updates" flag.
    
    - - - - -
    1b812b69 by Oleg Grenrus at 2023-01-12T15:54:21-05:00
    Fix #22728: Not all diagnostics in safe check are fatal
    
    Also add tests for the issue and -Winferred-safe-imports in general
    
    - - - - -
    c79b2b65 by Matthew Pickering at 2023-01-12T15:54:58-05:00
    Don't run hadrian-multi on fast-ci label
    
    Fixes #22667
    
    - - - - -
    9a3d6add by Andrew Lelechenko at 2023-01-13T00:46:36-05:00
    Bump submodule bytestring to 0.11.4.0
    
    Metric Decrease:
        T21839c
        T21839r
    
    - - - - -
    df33c13c by Ben Gamari at 2023-01-13T00:47:12-05:00
    gitlab-ci: Bump Darwin bootstrap toolchain
    
    This updates the bootstrap compiler on Darwin from 8.10.7 to 9.2.5,
    ensuring that we have the fix for #21964.
    
    - - - - -
    756a66ec by Ben Gamari at 2023-01-13T00:47:12-05:00
    gitlab-ci: Pass -w to cabal update
    
    Due to cabal#8447, cabal-install 3.8.1.0 requires a compiler to run
    `cabal update`.
    - - - - -
    1142f858 by Cheng Shao at 2023-01-13T11:04:00+00:00
    Bump hsc2hs submodule
    
    - - - - -
    d4686729 by Cheng Shao at 2023-01-13T11:04:00+00:00
    Bump process submodule
    
    - - - - -
    84ae6573 by Cheng Shao at 2023-01-13T11:06:58+00:00
    ci: Bump DOCKER_REV
    
    - - - - -
    d53598c5 by Cheng Shao at 2023-01-13T11:06:58+00:00
    ci: enable xz parallel compression for x64 jobs
    
    - - - - -
    d31fcbca by Cheng Shao at 2023-01-13T11:06:58+00:00
    ci: use in-image emsdk for js jobs
    
    - - - - -
    93b9bbc1 by Cheng Shao at 2023-01-13T11:47:17+00:00
    ci: improve nix-shell for gen_ci.hs and fix some ghc/hlint warnings
    
    - Add a ghc environment including prebuilt dependencies to the
      nix-shell. Get rid of the ad hoc cabal cache and all dependencies
      are now downloaded from the nixos binary cache.
    - Make gen_ci.hs a cabal package with HLS integration, to make future
      hacking of gen_ci.hs easier.
    - Fix some ghc/hlint warnings after I got HLS to work.
    - For the lint-ci-config job, do a shallow clone to save a few minutes
      of unnecessary git checkout time.
    
    - - - - -
    8acc56c7 by Cheng Shao at 2023-01-13T11:47:17+00:00
    ci: source the toolchain env file in wasm jobs
    
    - - - - -
    87194df0 by Cheng Shao at 2023-01-13T11:47:17+00:00
    ci: add wasm ci jobs via gen_ci.hs
    
    - There is one regular wasm job run in validate pipelines
    - Additionally, int-native/unreg wasm jobs run in nightly/release pipelines
    
    Also, remove the legacy handwritten wasm ci jobs in .gitlab-ci.yml.
    
    - - - - -
    b6eb9bcc by Matthew Pickering at 2023-01-13T11:52:16+00:00
    wasm ci: Remove wasm release jobs
    
    This removes the wasm release jobs, as we do not yet intend to
    distribute these binaries.
    
    - - - - -
    496607fd by Simon Peyton Jones at 2023-01-13T16:52:07-05:00
    Add a missing checkEscapingKind
    
    Ticket #22743 pointed out that there is a missing check,
    for type-inferred bindings, that the inferred type doesn't
    have an escaping kind.
    
    The fix is easy.
    
    - - - - -
    7a9a1042 by Andreas Klebinger at 2023-01-16T20:48:19-05:00
    Separate core inlining logic from `Unfolding` type.
    
    This seems like a good idea either way, but is mostly motivated by a
    patch where this avoids a module loop.
    
    - - - - -
    33b58f77 by sheaf at 2023-01-16T20:48:57-05:00
    Hadrian: generalise &%> to avoid warnings
    
    This patch introduces a more general version of &%> that works
    with general traversable shapes, instead of lists. This allows us
    to pass along the information that the length of the list of filepaths
    passed to the function exactly matches the length of the input list
    of filepath patterns, avoiding pattern match warnings.
    
    Fixes #22430
    
    - - - - -
    8c7a991c by Andreas Klebinger at 2023-01-16T20:49:34-05:00
    Add regression test for #22611.
    
    A case were a function used to fail to specialize, but now does.
    
    - - - - -
    6abea760 by Andreas Klebinger at 2023-01-16T20:50:10-05:00
    Mark maximumBy/minimumBy as INLINE.
    
    The RHS was too large to inline which often prevented the overhead of the Maybe
    from being optimized away. By marking it as INLINE we can eliminate the
    overhead of both the maybe and are able to unpack the accumulator when
    possible.
    
    Fixes #22609
    
    - - - - -
    99d151bb by Matthew Pickering at 2023-01-16T20:50:50-05:00
    ci: Bump CACHE_REV so that ghc-9.6 branch and HEAD have different caches
    
    Having the same CACHE_REV on both branches leads to issues where the
    darwin toolchain is different on ghc-9.6 and HEAD which leads to long
    darwin build times.
    
    In general we should ensure that each branch has a different CACHE_REV.
    
    - - - - -
    6a5845fb by Matthew Pickering at 2023-01-16T20:51:25-05:00
    ci: Change owner of files in source-tarball job
    
    This fixes errors of the form:
    
    ```
    fatal: detected dubious ownership in repository at '/builds/ghc/ghc'
    To add an exception for this directory, call:
    	git config --global --add safe.directory /builds/ghc/ghc
    inferred 9.7.20230113
    checking for GHC Git commit id... fatal: detected dubious ownership in repository at '/builds/ghc/ghc'
    To add an exception for this directory, call:
    	git config --global --add safe.directory /builds/ghc/ghc
    ```
    
    - - - - -
    4afb952c by Matthew Pickering at 2023-01-16T20:51:25-05:00
    ci: Don't build aarch64-deb10-llvm job on release pipelines
    
    Closes #22721
    
    - - - - -
    8039feb9 by Matthew Pickering at 2023-01-16T20:51:25-05:00
    ci: Change owner of files in test-bootstrap job
    
    - - - - -
    0b358d0c by Matthew Pickering at 2023-01-16T20:51:25-05:00
    rel_eng: Add release engineering scripts into ghc tree
    
    It is better to keep these scripts in the tree as they depend on the CI
    configuration and so on. By keeping them in tree we can keep them
    up-to-date as the CI config changes and also makes it easier to backport
    changes to the release script between release branches in future.
    
    The final motivation is that it makes generating GHCUp metadata
    possible.
    
    - - - - -
    28cb2ed0 by Matthew Pickering at 2023-01-16T20:51:25-05:00
    ci: Don't use complicated image or clone in not-interruptible job
    
    This job exists only for the meta-reason of not allowing nightly
    pipelines to be cancelled. It was taking two minutes to run as in order
    to run "true" we would also clone the whole GHC repo.
    
    - - - - -
    eeea59bb by Matthew Pickering at 2023-01-16T20:51:26-05:00
    Add scripts to generate ghcup metadata on nightly and release pipelines
    
    1. A python script in .gitlab/rel_eng/mk-ghcup-metadata which generates
       suitable metadata for consumption by GHCUp for the relevant
       pipelines.
    
      - The script generates the metadata just as the ghcup maintainers
        want, without taking into account platform/library combinations. It
        is updated manually when the mapping changes.
    
      - The script downloads the bindists which ghcup wants to distribute,
        calculates the hash and generates the yaml in the correct structure.
    
      - The script is documented in the .gitlab/rel_eng/mk-ghcup-metadata/README.mk file
    
    1a. The script requires us to understand the mapping from platform ->
        job. To choose the preferred bindist for each platform the
        .gitlab/gen_ci.hs script is modified to allow outputting a metadata
        file which answers the question about which job produces the
        bindist which we want to distribute to users for a specific
        platform.
    
    2. Pipelines to run on nightly and release jobs to generate metadata
    
      - ghcup-metadata-nightly: Generates metadata which points directly to
        artifacts in the nightly job.
    
      - ghcup-metadata-release: Generates metadata suitable for inclusion
        directly in ghcup by pointing to the downloads folder where the
        bindist will be uploaded to.
    
    2a. Trigger jobs which test the generated metadata in the downstream
        `ghccup-ci` repo. See that repo for documentation about what is
        tested and how but essentially we test in a variety of clean images
        that ghcup can download and install the bindists we say exist in our
        metadata.
    
    - - - - -
    97bd4d8c by Andrew Lelechenko at 2023-01-16T20:52:04-05:00
    Bump submodule parsec to 3.1.16.1
    
    - - - - -
    97ac8230 by Alan Zimmerman at 2023-01-16T20:52:39-05:00
    EPA: Add annotation for 'type' in DataDecl
    
    Closes #22765
    
    - - - - -
    dbbab95d by Ben Gamari at 2023-01-17T06:36:06-05:00
    compiler: Small optimisation of assertM
    
    In #22739 @AndreasK noticed that assertM performed the action to compute
    the asserted predicate regardless of whether DEBUG is enabled. This is
    inconsistent with the other assertion operations and general convention.
    Fix this.
    
    Closes #22739.
    
    - - - - -
    fc02f3bb by Viktor Dukhovni at 2023-01-17T06:36:47-05:00
    Avoid unnecessary printf warnings in EventLog.c
    
    Fixes #22778
    
    - - - - -
    003b6d44 by Simon Peyton Jones at 2023-01-17T16:33:05-05:00
    Document the semantics of pattern bindings a bit better
    
    This MR is in response to the discussion on #22719
    
    - - - - -
    f4d50baf by Vladislav Zavialov at 2023-01-17T16:33:41-05:00
    Hadrian: fix warnings (#22783)
    
    This change fixes the following warnings when building Hadrian:
    
    	src/Hadrian/Expression.hs:38:10: warning: [-Wredundant-constraints]
    	src/Hadrian/Expression.hs:84:13: warning: [-Wtype-equality-requires-operators]
    	src/Hadrian/Expression.hs:84:21: warning: [-Wtype-equality-requires-operators]
    	src/Hadrian/Haskell/Cabal/Parse.hs:67:1: warning: [-Wunused-imports]
    
    - - - - -
    06036d93 by Sylvain Henry at 2023-01-18T01:55:10-05:00
    testsuite: req_smp --> req_target_smp, req_ghc_smp
    
    See #22630 and !9552
    
    This commit:
     - splits req_smp into req_target_smp and req_ghc_smp
     - changes the testsuite driver to calculate req_ghc_smp
     - changes a handful of tests to use req_target_smp instead of req_smp
     - changes a handful of tests to use req_host_smp when needed
    
    The problem:
     - the problem this solves is the ambiguity surrounding req_smp
     - on master req_smp was used to express the constraint that the program
     being compiled supports smp _and_ that the host RTS (i.e., the RTS used
     to compile the program) supported smp. Normally that is fine, but in
     cross compilation this is not always the case as was discovered in #22630.
    
    The solution:
     - Differentiate the two constraints:
       - use req_target_smp to say the RTS the compiled program is linked
       with (and the platform) supports smp
       - use req_host_smp to say the RTS the host is linked with supports smp
    
    WIP: fix req_smp (target vs ghc)
    
    add flag to separate bootstrapper
    
    split req_smp -> req_target_smp and req_ghc_smp
    
    update tests smp flags
    
    cleanup and add some docstrings
    
    only set ghc_with_smp to bootstrapper on S1 or CC
    
    Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1
    and cross compiling
    
    test the RTS in config/ghc not hadrian
    
    re-add ghc_with_smp
    
    fix and align req names
    
    fix T11760 to use req_host_smp
    
    test the rts directly, avoid python 3.5 limitation
    
    test the compiler in a try block
    
    align out of tree and in tree withSMP flags
    
    mark failing tests as host req smp
    
    testsuite: req_host_smp --> req_ghc_smp
    
    Fix ghc vs host, fix ghc_with_smp leftover
    
    - - - - -
    ee9b78aa by Krzysztof Gogolewski at 2023-01-18T01:55:45-05:00
    Use -Wdefault when running Python testdriver (#22727)
    
    - - - - -
    e9c0537c by Vladislav Zavialov at 2023-01-18T01:56:22-05:00
    Enable -Wstar-is-type by default (#22759)
    
    Following the plan in GHC Proposal #143 "Remove the * kind syntax",
    which states:
    
    	In the next release (or 3 years in), enable -fwarn-star-is-type by default.
    
    The "next release" happens to be 9.6.1
    
    I also moved the T21583 test case from should_fail to should_compile,
    because the only reason it was failing was -Werror=compat in our test
    suite configuration.
    
    - - - - -
    4efee43d by Ryan Scott at 2023-01-18T01:56:59-05:00
    Add missing parenthesizeHsType in cvtSigTypeKind
    
    We need to ensure that the output of `cvtSigTypeKind` is parenthesized (at
    precedence `sigPrec`) so that any type signatures with an outermost, explicit
    kind signature can parse correctly.
    
    Fixes #22784.
    
    - - - - -
    f891a442 by Ben Gamari at 2023-01-18T07:28:00-05:00
    Bump ghc-tarballs to fix #22497
    
    It turns out that gmp 6.2.1 uses the platform-reserved `x18` register on
    AArch64/Darwin. This was fixed in upstream changeset 18164:5f32dbc41afc,
    which was merged in 2020. Here I backport this patch although I do hope
    that a new release is forthcoming soon.
    
    Bumps gmp-tarballs submodule.
    
    Fixes #22497.
    
    - - - - -
    b13c6ea5 by Ben Gamari at 2023-01-18T07:28:00-05:00
    Bump gmp-tarballs submodule
    
    This backports the upstream fix for CVE-2021-43618, fixing #22789.
    
    - - - - -
    c45a5fff by Cheng Shao at 2023-01-18T07:28:37-05:00
    Fix typo in recent darwin tests fix
    
    Corrects a typo in !9647. Otherwise T18623 will still fail on darwin
    and stall other people's work.
    
    - - - - -
    b4c14c4b by Luite Stegeman at 2023-01-18T14:21:42-05:00
    Add PrimCallConv support to GHCi
    
    This adds support for calling Cmm code from bytecode using the native
    calling convention, allowing modules that use `foreign import prim`
    to be loaded and debugged in GHCi.
    
    This patch introduces a new `PRIMCALL` bytecode instruction and
    a helper stack frame `stg_primcall`. The code is based on the
    existing functionality for dealing with unboxed tuples in bytecode,
    which has been generalised to handle arbitrary calls.
    
    Fixes #22051
    
    - - - - -
    d0a63ef8 by Adam Gundry at 2023-01-18T14:22:26-05:00
    Refactor warning flag parsing to add missing flags
    
    This adds `-Werror=<group>` and `-fwarn-<group>` flags for warning
    groups as well as individual warnings. Previously these were defined
    on an ad hoc basis so for example we had `-Werror=compat` but not
    `-Werror=unused-binds`, whereas we had `-fwarn-unused-binds` but not
    `-fwarn-compat`. Fixes #22182.
    
    - - - - -
    7ed1b8ef by Adam Gundry at 2023-01-18T14:22:26-05:00
    Minor corrections to comments
    
    - - - - -
    5389681e by Adam Gundry at 2023-01-18T14:22:26-05:00
    Revise warnings documentation in user's guide
    
    - - - - -
    ab0d5cda by Adam Gundry at 2023-01-18T14:22:26-05:00
    Move documentation of deferred type error flags out of warnings section
    
    - - - - -
    eb5a6b91 by John Ericson at 2023-01-18T22:24:10-05:00
    Give the RTS it's own configure script
    
    Currently it doesn't do much anything, we are just trying to introduce
    it without breaking the build. Later, we will move functionality from
    the top-level configure script over to it.
    
    We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to
    facilitate and existing hack of skipping some configure checks for the
    RTS we now need to skip just *part* not *all* of the "post configure"
    hook, as running the configure script (which we definitely want to do)
    is also implemented as part of the "post configure" hook. But doing this
    requires exposing functionality that wasn't exposed before.
    
    - - - - -
    32ab07bf by Andrew Lelechenko at 2023-01-18T22:24:51-05:00
    ghc package does not have to depend on terminfo
    
    - - - - -
    981ff7c4 by Andrew Lelechenko at 2023-01-18T22:24:51-05:00
    ghc-pkg does not have to depend on terminfo
    
    - - - - -
    f058e367 by Ben Gamari at 2023-01-18T22:25:27-05:00
    nativeGen/X86: MFENCE is unnecessary for release semantics
    
    In #22764 a user noticed that a program implementing a simple atomic
    counter via an STRef regressed significantly due to the introduction of
    necessary atomic operations in the MutVar# primops (#22468). This
    regression was caused by a bug in the NCG, which emitted an unnecessary
    MFENCE instruction for a release-ordered atomic write. MFENCE is rather
    only needed to achieve sequentially consistent ordering.
    
    Fixes #22764.
    
    - - - - -
    154889db by Ryan Scott at 2023-01-18T22:26:03-05:00
    Add regression test for #22151
    
    Issue #22151 was coincidentally fixed in commit
    aed1974e92366ab8e117734f308505684f70cddf (`Refactor the treatment of loopy
    superclass dicts`). This adds a regression test to ensure that the issue
    remains fixed.
    
    Fixes #22151.
    
    - - - - -
    14b5982a by Andrei Borzenkov at 2023-01-18T22:26:43-05:00
    Fix printing of promoted MkSolo datacon (#22785)
    
    Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo,
    and Solo was turned into a pattern synonym for backwards compatibility.
    Since pattern synonyms can not be promoted, the old code that pretty-printed
    promoted single-element tuples started producing ill-typed code:
       t :: Proxy ('Solo Int)
    This fails with "Pattern synonym ‘Solo’ used as a type"
    
    The solution is to track the distinction between type constructors and data
    constructors more carefully when printing single-element tuples.
    
    - - - - -
    1fe806d3 by Cheng Shao at 2023-01-23T04:48:47-05:00
    hadrian: add hi_core flavour transformer
    
    The hi_core flavour transformer enables -fwrite-if-simplified-core for
    stage1 libraries, which emit core into interface files to make it
    possible to restart code generation. Building boot libs with it makes
    it easier to use GHC API to prototype experimental backends that needs
    core/stg at link time.
    
    - - - - -
    317cad26 by Cheng Shao at 2023-01-23T04:48:47-05:00
    hadrian: add missing docs for recently added flavour transformers
    
    - - - - -
    658f4446 by Ben Gamari at 2023-01-23T04:49:23-05:00
    gitlab-ci: Add Rocky8 jobs
    
    Addresses #22268.
    
    - - - - -
    a83ec778 by Vladislav Zavialov at 2023-01-23T04:49:58-05:00
    Set "since: 9.8" for TypeAbstractions and -Wterm-variable-capture
    
    These flags did not make it into the 9.6 release series,
    so the "since" annotations must be corrected.
    
    - - - - -
    fec7c2ea by Alan Zimmerman at 2023-01-23T04:50:33-05:00
    EPA: Add SourceText to HsOverLabel
    
    To be able to capture string literals with possible escape codes as labels.
    
    Close #22771
    
    - - - - -
    3efd1e99 by Ben Gamari at 2023-01-23T04:51:08-05:00
    template-haskell: Bump version to 2.20.0.0
    
    Updates `text` and `exceptions` submodules for bounds bumps.
    
    Addresses #22767.
    
    - - - - -
    0900b584 by Cheng Shao at 2023-01-23T04:51:45-05:00
    hadrian: disable alloca for in-tree GMP on wasm32
    
    When building in-tree GMP for wasm32, disable its alloca usage, since
    it may potentially cause stack overflow (e.g. #22602).
    
    - - - - -
    db0f1bfd by Cheng Shao at 2023-01-23T04:52:21-05:00
    Bump process submodule
    
    Includes a critical fix for wasm32, see
    https://github.com/haskell/process/pull/272 for details. Also changes
    the existing cross test to include process stuff and avoid future
    regression here.
    
    - - - - -
    9222b167 by Matthew Pickering at 2023-01-23T04:52:57-05:00
    ghcup metadata: Fix subdir for windows bindist
    
    - - - - -
    9a9bec57 by Matthew Pickering at 2023-01-23T04:52:57-05:00
    ghcup metadata: Remove viPostRemove field from generated metadata
    
    This has been removed from the downstream metadata.
    
    - - - - -
    82884ce0 by Simon Peyton Jones at 2023-01-23T04:53:32-05:00
    Fix #22742
    
    runtimeRepLevity_maybe was panicing unnecessarily; and
    the error printing code made use of the case when it should
    return Nothing rather than panicing.
    
    For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime
    peak-megagbytes-used, on a single architecture (alpine). See !9753 for
    commentary, but I'm going to accept it.
    
    Metric Increase:
        T21839r
    
    - - - - -
    2c6deb18 by Bryan Richter at 2023-01-23T14:12:22+02:00
    codeowners: Add Ben, Matt, and Bryan to CI
    
    - - - - -
    eee3bf05 by Matthew Craven at 2023-01-23T21:46:41-05:00
    Do not collect compile-time metrics for T21839r
    
    ...the testsuite doesn't handle this properly since it
    also collects run-time metrics.  Compile-time metrics
    for this test are already tracked via T21839c.
    
    Metric Decrease:
        T21839r
    
    - - - - -
    1d1dd3fb by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Fix recompilation checking for multiple home units
    
    The key part of this change is to store a UnitId in the
    `UsageHomeModule` and `UsageHomeModuleInterface`.
    
    * Fine-grained dependency tracking is used if the dependency comes from
      any home unit.
    * We actually look up the right module when checking whether we need to
      recompile in the `UsageHomeModuleInterface` case.
    
    These scenarios are both checked by the new tests (
    multipleHomeUnits_recomp and multipleHomeUnits_recomp_th )
    
    Fixes #22675
    
    - - - - -
    7bfb30f9 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Augment target filepath by working directory when checking if module satisfies target
    
    This fixes a spurious warning in -Wmissing-home-modules.
    
    This is a simple oversight where when looking for the target in the
    first place we augment the search by the -working-directory flag but
    then fail to do so when checking this warning.
    
    Fixes #22676
    
    - - - - -
    69500dd4 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Use NodeKey rather than ModuleName in pruneCache
    
    The `pruneCache` function assumes that the list of `CachedInfo` all have unique `ModuleName`, this is not true:
    
    * In normal compilation, the same module name can appear for a file and it's boot file.
    * In multiple home unit compilation the same ModuleName can appear in different units
    
    The fix is to use a `NodeKey` as the actual key for the interfaces which includes `ModuleName`, `IsBoot` and `UnitId`.
    
    Fixes #22677
    
    - - - - -
    336b2b1c by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Recompilation checking: Don't try to find artefacts for Interactive & hs-boot combo
    
    In interactive mode we don't produce any linkables for hs-boot files. So
    we also need to not going looking for them when we check to see if we
    have all the right objects needed for recompilation.
    
    Ticket #22669
    
    - - - - -
    6469fea7 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Don't write o-boot files in Interactive mode
    
    We should not be producing object files when in interactive mode but we
    still produced the dummy o-boot files. These never made it into a
    `Linkable` but then confused the recompilation checker.
    
    Fixes #22669
    
    - - - - -
    06cc0a95 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Improve driver diagnostic messages by including UnitId in message
    
    Currently the driver diagnostics don't give any indication about which unit they correspond to.
    
    For example `-Wmissing-home-modules` can fire multiple times for each different home unit and gives no indication about which unit it's actually reporting about.
    
    Perhaps a longer term fix is to generalise the providence information away from a SrcSpan so that these kind of whole project errors can be reported with an accurate provenance. For now we can just include the `UnitId` in the error message.
    
    Fixes #22678
    
    - - - - -
    4fe9eaff by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Key ModSummary cache by UnitId as well as FilePath
    
    Multiple units can refer to the same files without any problem. Just
    another assumption which needs to be updated when we may have multiple
    home units.
    
    However, there is the invariant that within each unit each file only
    maps to one module, so as long as we also key the cache by UnitId then
    we are all good.
    
    This led to some confusing behaviour in GHCi when reloading,
    multipleHomeUnits_shared distils the essence of what can go wrong.
    
    Fixes #22679
    
    - - - - -
    ada29f5c by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Finder: Look in current unit before looking in any home package dependencies
    
    In order to preserve existing behaviour it's important to look within the current component before consideirng a module might come from an external component.
    
    This already happened by accident in `downsweep`, (because roots are used to repopulated the cache) but in the `Finder` the logic was the wrong way around.
    
    Fixes #22680
    
    -------------------------
    Metric Decrease:
        MultiComponentModules
        MultiComponentModulesRecomp
    -------------------------p
    
    - - - - -
    be701cc6 by Matthew Pickering at 2023-01-24T05:37:52-05:00
    Debug: Print full NodeKey when pretty printing ModuleGraphNode
    
    This is helpful when debugging multiple component issues.
    
    - - - - -
    34d2d463 by Krzysztof Gogolewski at 2023-01-24T05:38:32-05:00
    Fix Lint check for duplicate external names
    
    Lint was checking for duplicate external names by calling removeDups,
    which needs a comparison function that is passed to Data.List.sortBy.
    But the comparison was not a valid ordering - it returned LT
    if one of the names was not external.
    For example, the previous implementation won't find a duplicate in
    [M.x, y, M.x].
    Instead, we filter out non-external names before looking for duplicates.
    
    - - - - -
    1c050ed2 by Matthew Pickering at 2023-01-24T05:39:08-05:00
    Add test for T22671
    
    This was fixed by b13c6ea5
    
    Closes #22671
    
    - - - - -
    05e6a2d9 by Tom Ellis at 2023-01-24T12:10:52-05:00
    Clarify where `f` is defined
    
    - - - - -
    d151546e by Cheng Shao at 2023-01-24T12:11:29-05:00
    CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target
    
    We used to print the offset value to a platform word sized integer.
    This is incorrect when the offset is negative (e.g. output of cmm
    constant folding) and the register is 64-bit but on a 32-bit target,
    and may lead to incorrect runtime result (e.g. #22607).
    
    The fix is simple: just treat it as a proper MO_Add, with the correct
    width info inferred from the register itself.
    
    Metric Increase:
        T12707
        T13379
        T4801
        T5321FD
        T5321Fun
    
    - - - - -
    e5383a29 by Wander Hillen at 2023-01-24T20:02:26-05:00
    Allow waiting for timerfd to be interrupted during rts shutdown
    
    - - - - -
    1957eda1 by Ryan Scott at 2023-01-24T20:03:01-05:00
    Restore Compose's Read/Show behavior to match Read1/Show1 instances
    
    Fixes #22816.
    
    - - - - -
    30972827 by Matthew Pickering at 2023-01-25T03:54:14-05:00
    docs: Update INSTALL.md
    
    Removes references to make.
    
    Fixes #22480
    
    - - - - -
    bc038c3b by Cheng Shao at 2023-01-25T03:54:50-05:00
    compiler: fix handling of MO_F_Neg in wasm NCG
    
    In the wasm NCG, we used to compile MO_F_Neg to 0.0-x. It was an
    oversight, there actually exists f32.neg/f64.neg opcodes in the wasm
    spec and those should be used instead! The old behavior almost works,
    expect when GHC compiles the -0.0 literal, which will incorrectly
    become 0.0.
    
    - - - - -
    e987e345 by Sylvain Henry at 2023-01-25T14:47:41-05:00
    Hadrian: correctly detect AR at-file support
    
    Stage0's ar may not support at-files. Take it into account.
    
    Found while cross-compiling from Darwin to Windows.
    
    - - - - -
    48131ee2 by Sylvain Henry at 2023-01-25T14:47:41-05:00
    Hadrian: fix Windows cross-compilation
    
    Decision to build either unix or Win32 package must be stage specific
    for cross-compilation to be supported.
    
    - - - - -
    288fa017 by Sylvain Henry at 2023-01-25T14:47:41-05:00
    Fix RTS build on Windows
    
    This change fixes a cross-compilation issue from ArchLinux to Windows
    because these symbols weren't found.
    
    - - - - -
    2fdf22ae by Sylvain Henry at 2023-01-25T14:47:41-05:00
    configure: support "windows" as an OS
    
    - - - - -
    13a0566b by Simon Peyton Jones at 2023-01-25T14:48:16-05:00
    Fix in-scope set in specImports
    
    Nothing deep here; I had failed to bring some
    floated dictionary binders into scope.
    
    Exposed by -fspecialise-aggressively
    
    Fixes #22715.
    
    - - - - -
    b7efdb24 by Matthew Pickering at 2023-01-25T14:48:51-05:00
    ci: Disable HLint job due to excessive runtime
    
    The HLint jobs takes much longer to run (20 minutes) after "Give the RTS it's own configure script" eb5a6b91
    
    Now the CI job will build the stage0 compiler before it generates the necessary RTS headers.
    
    We either need to:
    
    * Fix the linting rules so they take much less time
    * Revert the commit
    * Remove the linting of base from the hlint job
    * Remove the hlint job
    
    This is highest priority as it is affecting all CI pipelines.
    
    For now I am just disabling the job because there are many more pressing
    matters at hand.
    
    Ticket #22830
    
    - - - - -
    1bd32a35 by Sylvain Henry at 2023-01-26T12:34:21-05:00
    Factorize hptModulesBelow
    
    Create and use moduleGraphModulesBelow in GHC.Unit.Module.Graph that
    doesn't need anything from the driver to be used.
    
    - - - - -
    1262d3f8 by Matthew Pickering at 2023-01-26T12:34:56-05:00
    Store dehydrated data structures in CgModBreaks
    
    This fixes a tricky leak in GHCi where we were retaining old copies of
    HscEnvs when reloading. If not all modules were recompiled then these
    hydrated fields in break points would retain a reference to the old
    HscEnv which could double memory usage.
    
    Fixes #22530
    
    - - - - -
    e27eb80c by Matthew Pickering at 2023-01-26T12:34:56-05:00
    Force more in NFData Name instance
    
    Doesn't force the lazy `OccName` field (#19619) which is already known
    as a really bad source of leaks.
    
    When we slam the hammer storing Names on disk (in interface files or the
    like), all this should be forced as otherwise a `Name` can easily retain
    an `Id` and hence the entire world.
    
    Fixes #22833
    
    - - - - -
    3d004d5a by Matthew Pickering at 2023-01-26T12:34:56-05:00
    Force OccName in tidyTopName
    
    This occname has just been derived from an `Id`, so need to force it
    promptly so we can release the Id back to the world.
    
    Another symptom of the bug caused by #19619
    
    - - - - -
    f2a0fea0 by Matthew Pickering at 2023-01-26T12:34:56-05:00
    Strict fields in ModNodeKey (otherwise retains HomeModInfo)
    
    Towards #22530
    
    - - - - -
    5640cb1d by Sylvain Henry at 2023-01-26T12:35:36-05:00
    Hadrian: fix doc generation
    
    Was missing dependencies on files generated by templates (e.g.
    ghc.cabal)
    
    - - - - -
    3e827c3f by Richard Eisenberg at 2023-01-26T20:06:53-05:00
    Do newtype unwrapping in the canonicaliser and rewriter
    
    See Note [Unwrap newtypes first], which has the details.
    
    Close #22519.
    
    - - - - -
    b3ef5c89 by doyougnu at 2023-01-26T20:07:48-05:00
    tryFillBuffer: strictify
    
    more speculative bangs
    
    - - - - -
    d0d7ba0f by Vladislav Zavialov at 2023-01-26T20:08:25-05:00
    base: NoImplicitPrelude in Data.Void and Data.Kind
    
    This change removes an unnecessary dependency on Prelude
    from two modules in the base package.
    
    - - - - -
    fa1db923 by Matthew Pickering at 2023-01-26T20:09:00-05:00
    ci: Add ubuntu18_04 nightly and release jobs
    
    This adds release jobs for ubuntu18_04 which uses glibc 2.27 which is
    older than the 2.28 which is used by Rocky8 bindists.
    
    Ticket #22268
    
    - - - - -
    807310a1 by Matthew Pickering at 2023-01-26T20:09:00-05:00
    rel-eng: Add missing rocky8 bindist
    
    We intend to release rocky8 bindist so the fetching script needs to know
    about them.
    
    - - - - -
    c7116b10 by Ben Gamari at 2023-01-26T20:09:35-05:00
    base: Make changelog proposal references more consistent
    
    Addresses #22773.
    
    - - - - -
    6932cfc7 by Sylvain Henry at 2023-01-26T20:10:27-05:00
    Fix spurious change from !9568
    
    - - - - -
    e480fbc2 by Ben Gamari at 2023-01-27T05:01:24-05:00
    rts: Use C11-compliant static assertion syntax
    
    Previously we used `static_assert` which is only available in C23. By
    contrast, C11 only provides `_Static_assert`.
    
    Fixes #22777
    
    - - - - -
    2648c09c by Andrei Borzenkov at 2023-01-27T05:02:07-05:00
    Replace errors from badOrigBinding with new one (#22839)
    
    Problem: in 02279a9c the type-level [] syntax was changed from a built-in name
    to an alias for the GHC.Types.List constructor. badOrigBinding assumes that if
    a name is not built-in then it must have come from TH quotation, but this is
    not necessarily the case with [].
    
    The outdated assumption in badOrigBinding leads to incorrect error messages.
    This code:
      data []
    Fails with "Cannot redefine a Name retrieved by a Template Haskell quote: []"
    
    Unfortunately, there is not enough information in RdrName to directly determine
    if the name was constructed via TH or by the parser, so this patch changes the
    error message instead.
    
    It unifies TcRnIllegalBindingOfBuiltIn and TcRnNameByTemplateHaskellQuote
    into a new error TcRnBindingOfExistingName and changes its wording to avoid
    guessing the origin of the name.
    
    - - - - -
    545bf8cf by Matthew Pickering at 2023-01-27T14:58:53+00:00
    Revert "base: NoImplicitPrelude in Data.Void and Data.Kind"
    
    Fixes CI errors of the form.
    
    ```
    ===> Command failed with error code: 1
    ghc: panic! (the 'impossible' happened)
      GHC version 9.7.20230127:
    	lookupGlobal
      Failed to load interface for ‘GHC.Num.BigNat’
      There are files missing in the ‘ghc-bignum’ package,
      try running 'ghc-pkg check'.
      Use -v (or `:set -v` in ghci) to see a list of the files searched for.
      Call stack:
          CallStack (from HasCallStack):
            callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic
            pprPanic, called at compiler/GHC/Tc/Utils/Env.hs:154:32 in ghc:GHC.Tc.Utils.Env
      CallStack (from HasCallStack):
        panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error
    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug
    ```
    
    This reverts commit d0d7ba0fb053ebe7f919a5932066fbc776301ccd.
    
    The module now lacks a dependency on GHC.Num.BigNat which it implicitly
    depends on. It is causing all CI jobs to fail so we revert without haste
    whilst the patch can be fixed.
    
    Fixes #22848
    
    - - - - -
    638277ba by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Detect family instance orphans correctly
    
    We were treating a type-family instance as a non-orphan if there
    was a type constructor on its /right-hand side/ that was local. Boo!
    Utterly wrong. With this patch, we correctly check the /left-hand side/
    instead!
    
    Fixes #22717
    
    - - - - -
    46a53bb2 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Report family instance orphans correctly
    
    This fixes the fact that we were not reporting orphan family instances
    at all. The fix here is easy, but touches a bit of code. I refactored
    the code to be much more similar to the way that class instances are done:
    
       - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst
       - Make newFamInst initialise this field, just like newClsInst
       - And make newFamInst report a warning for an orphan, just like newClsInst
       - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate,
         just like newClsInst.
       - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv
       - TcRnOrphanInstance and SuggestFixOrphanInstance are now parametrised
         over class instances vs type/data family instances.
    
    Fixes #19773
    
    - - - - -
    faa300fb by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Avoid orphans in STG
    
    This patch removes some orphan instances in the STG namespace
    by introducing the GHC.Stg.Lift.Types module, which allows various
    type family instances to be moved to GHC.Stg.Syntax, avoiding orphan
    instances.
    
    - - - - -
    0f25a13b by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Avoid orphans in the parser
    
    This moves Anno instances for PatBuilder from GHC.Parser.PostProcess
    to GHC.Parser.Types to avoid orphans.
    
    - - - - -
    15750d33 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
    Accept an orphan declaration (sadly)
    
    This accepts the orphan type family instance
    
      type instance DsForeignHook = ...
    
    in GHC.HsToCore.Types.
    
    See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks
    
    - - - - -
    c9967d13 by Zubin Duggal at 2023-01-27T23:55:31-05:00
    bindist configure: Fail if find not found (#22691)
    
    - - - - -
    ad8cfed4 by John Ericson at 2023-01-27T23:56:06-05:00
    Put hadrian bootstrap plans through `jq`
    
    This makes it possible to review changes with conventional diffing
    tools.
    
    - - - - -
    d0ddc01b by Ben Gamari at 2023-01-27T23:56:42-05:00
    testsuite: Introduce threaded2_sanity way
    
    Incredibly, we previously did not have a single way which would test the
    threaded RTS with multiple capabilities and the sanity-checker enabled.
    
    - - - - -
    38ad8351 by Ben Gamari at 2023-01-27T23:56:42-05:00
    rts: Relax Messages assertion
    
    `doneWithMsgThrowTo` was previously too strict in asserting that the
    `Message` is locked. Specifically, it failed to consider that the
    `Message` may not be locked if we are deleting all threads during RTS
    shutdown.
    
    - - - - -
    a9fe81af by Ben Gamari at 2023-01-27T23:56:42-05:00
    testsuite: Fix race in UnliftedTVar2
    
    Previously UnliftedTVar2 would fail when run with multiple capabilities
    (and possibly even with one capability) as it would assume that
    `killThread#` would immediately kill the "increment" thread.
    
    Also, refactor the the executable to now succeed with no output and
    fails with an exit code.
    
    - - - - -
    8519af60 by Ben Gamari at 2023-01-27T23:56:42-05:00
    testsuite: Make listThreads more robust
    
    Previously it was sensitive to the labels of threads which it did not
    create (e.g. the IO manager event loop threads). Fix this.
    
    - - - - -
    55a81995 by Ben Gamari at 2023-01-27T23:56:43-05:00
    rts: Fix non-atomic mutation of enabled_capabilities
    
    - - - - -
    b5c75f1d by Ben Gamari at 2023-01-27T23:56:43-05:00
    rts: Fix C++ compilation issues
    
    Make the RTS compilable with a C++ compiler by inserting necessary
    casts.
    
    - - - - -
    c261b62f by Ben Gamari at 2023-01-27T23:56:43-05:00
    rts: Fix typo
    
    "tracingAddCapabilities" was mis-named
    
    - - - - -
    77fdbd3f by Ben Gamari at 2023-01-27T23:56:43-05:00
    rts: Drop long-dead fallback definitions for INFINITY & NAN
    
    These are no longer necessary since we now compile as C99.
    
    - - - - -
    56c1bd98 by Ben Gamari at 2023-01-28T02:57:59-05:00
    Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)"
    
    This reverts commit 99aca26b652603bc62953157a48e419f737d352d.
    
    - - - - -
    b3a3534b by nineonine at 2023-01-28T02:57:59-05:00
    CApiFFI: add ConstPtr for encoding const-qualified pointer return types
    
    Previously, when using `capi` calling convention in foreign declarations,
    code generator failed to handle const-cualified pointer return types.
    This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers`
    warning.
    
    `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases -
    special treatment was put in place to generate appropritetly qualified C
    wrapper that no longer triggers the above mentioned warning.
    
    Fixes #22043.
    
    - - - - -
    082b7d43 by Oleg Grenrus at 2023-01-28T02:58:38-05:00
    Add Foldable1 Solo instance
    
    - - - - -
    50b1e2e8 by Andrei Borzenkov at 2023-01-28T02:59:18-05:00
    Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115)
    
    I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind
    module. Instead, these TcRnMessage messages were introduced:
      TcRnMultipleFixityDecls
      TcRnIllegalPatternSynonymDecl
      TcRnIllegalClassBiding
      TcRnOrphanCompletePragma
      TcRnEmptyCase
      TcRnNonStdGuards
      TcRnDuplicateSigDecl
      TcRnMisplacedSigDecl
      TcRnUnexpectedDefaultSig
      TcRnBindInBootFile
      TcRnDuplicateMinimalSig
    
    - - - - -
    3330b819 by Matthew Pickering at 2023-01-28T02:59:54-05:00
    hadrian: Fix library-dirs, dynamic-library-dirs and static-library-dirs in inplace .conf files
    
    Previously we were just throwing away the contents of the library-dirs
    fields but really we have to do the same thing as for include-dirs,
    relativise the paths into the current working directory and maintain any
    extra libraries the user has specified.
    
    Now the relevant section of the rts.conf file looks like:
    
    ```
    library-dirs:
        ${pkgroot}/../rts/build
        ${pkgroot}/../../..//_build/stage1/rts/build
        /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
        /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib
    
    library-dirs-static:
        ${pkgroot}/../rts/build
        ${pkgroot}/../../..//_build/stage1/rts/build
        /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
        /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib
    
    dynamic-library-dirs:
        ${pkgroot}/../rts/build
        ${pkgroot}/../../..//_build/stage1/rts/build
        /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
        /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib
    ```
    
    Fixes #22209
    
    - - - - -
    c9ad8852 by Andrew Lelechenko at 2023-01-28T03:00:33-05:00
    Document differences between Data.{Monoid,Semigroup}.{First,Last}
    
    - - - - -
    7e11c6dc by Cheng Shao at 2023-01-28T03:01:09-05:00
    compiler: fix subword literal narrowing logic in the wasm NCG
    
    This patch fixes the W8/W16 literal narrowing logic in the wasm NCG,
    which used to lower it to something like i32.const -1, without
    properly zeroing-out the unused higher bits. Fixes #22608.
    
    - - - - -
    6ea2aa02 by Cheng Shao at 2023-01-28T03:01:46-05:00
    compiler: fix lowering of CmmBlock in the wasm NCG
    
    The CmmBlock datacon was not handled in lower_CmmLit, since I thought
    it would have been eliminated after proc-point splitting. Turns out it
    still occurs in very rare occasions, and this patch is needed to fix
    T9329 for wasm.
    
    - - - - -
    2b62739d by Andrew Lelechenko at 2023-01-28T17:16:11-05:00
    Assorted changes to avoid Data.List.{head,tail}
    
    - - - - -
    78c07219 by Cheng Shao at 2023-01-28T17:16:48-05:00
    compiler: properly handle ForeignHints in the wasm NCG
    
    Properly handle ForeignHints of ccall arguments/return value, insert
    sign extends and truncations when handling signed subwords. Fixes #22852.
    
    - - - - -
    8bed166b by Ben Gamari at 2023-01-30T05:06:26-05:00
    nativeGen: Disable asm-shortcutting on Darwin
    
    Asm-shortcutting may produce relative references to symbols defined in
    other compilation units. This is not something that MachO relocations
    support (see #21972). For this reason we disable the optimisation on
    Darwin. We do so without a warning since this flag is enabled by `-O2`.
    
    Another way to address this issue would be to rather implement a
    PLT-relocatable jump-table strategy. However, this would only benefit
    Darwin and does not seem worth the effort.
    
    Closes #21972.
    
    - - - - -
    da468391 by Cheng Shao at 2023-01-30T05:07:03-05:00
    compiler: fix data section alignment in the wasm NCG
    
    Previously we tried to lower the alignment requirement as far as
    possible, based on the section kind inferred from the CLabel. For info
    tables, .p2align 1 was applied given the GC should only need the
    lowest bit to tag forwarding pointers. But this would lead to
    unaligned loads/stores, which has a performance penalty even if the
    wasm spec permits it. Furthermore, the test suite has shown memory
    corruption in a few cases when compacting gc is used.
    
    This patch takes a more conservative approach: all data sections
    except C strings align to word size.
    
    - - - - -
    08ba8720 by Andreas Klebinger at 2023-01-30T21:18:45-05:00
    ghc-the-library: Retain cafs in both static in dynamic builds.
    
    We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a
    __attribute__((constructor)) function.
    
    This broke for static builds where the linker discarded the object file
    since it was not reverenced from any exported code. We fix this by
    asserting that the flag is enabled using a function in the same module
    as the constructor. Which causes the object file to be retained by the
    linker, which in turn causes the constructor the be run in static builds.
    
    This changes nothing for dynamic builds using the ghc library. But causes
    static to also retain CAFs (as we expect them to).
    
    Fixes #22417.
    
    -------------------------
    Metric Decrease:
        T21839r
    -------------------------
    
    - - - - -
    20598ef6 by Ryan Scott at 2023-01-30T21:19:20-05:00
    Handle `type data` properly in tyThingParent_maybe
    
    Unlike most other data constructors, data constructors declared with `type data`
    are represented in `TyThing`s as `ATyCon` rather than `ADataCon`. The `ATyCon`
    case in `tyThingParent_maybe` previously did not consider the possibility of
    the underlying `TyCon` being a promoted data constructor, which led to the
    oddities observed in #22817. This patch adds a dedicated special case in
    `tyThingParent_maybe`'s `ATyCon` case for `type data` data constructors to fix
    these oddities.
    
    Fixes #22817.
    
    - - - - -
    2f145052 by Ryan Scott at 2023-01-30T21:19:56-05:00
    Fix two bugs in TypeData TH reification
    
    This patch fixes two issues in the way that `type data` declarations were
    reified with Template Haskell:
    
    * `type data` data constructors are now properly reified using `DataConI`.
      This is accomplished with a special case in `reifyTyCon`. Fixes #22818.
    
    * `type data` type constructors are now reified in `reifyTyCon` using
      `TypeDataD` instead of `DataD`. Fixes #22819.
    
    - - - - -
    d0f34f25 by Simon Peyton Jones at 2023-01-30T21:20:35-05:00
    Take account of loop breakers in specLookupRule
    
    The key change is that in GHC.Core.Opt.Specialise.specLookupRule
    we were using realIdUnfolding, which ignores the loop-breaker
    flag.  When given a loop breaker, rule matching therefore
    looped infinitely -- #22802.
    
    In fixing this I refactored a bit.
    
    * Define GHC.Core.InScopeEnv as a data type, and use it.
      (Previously it was a pair: hard to grep for.)
    
    * Put several functions returning an IdUnfoldingFun into
      GHC.Types.Id, namely
         idUnfolding
         alwaysActiveUnfoldingFun,
         whenActiveUnfoldingFun,
         noUnfoldingFun
      and use them.  (The are all loop-breaker aware.)
    
    - - - - -
    de963cb6 by Matthew Pickering at 2023-01-30T21:21:11-05:00
    ci: Remove FreeBSD job from release pipelines
    
    We no longer attempt to build or distribute this release
    
    - - - - -
    f26d27ec by Matthew Pickering at 2023-01-30T21:21:11-05:00
    rel_eng: Add check to make sure that release jobs are downloaded by fetch-gitlab
    
    This check makes sure that if a job is a prefixed by "release-" then the
    script downloads it and understands how to map the job name to the
    platform.
    
    - - - - -
    7619c0b4 by Matthew Pickering at 2023-01-30T21:21:11-05:00
    rel_eng: Fix the name of the ubuntu-* jobs
    
    These were not uploaded for alpha1
    
    Fixes #22844
    
    - - - - -
    68eb8877 by Matthew Pickering at 2023-01-30T21:21:11-05:00
    gen_ci: Only consider release jobs for job metadata
    
    In particular we do not have a release job for FreeBSD so the generation
    of the platform mapping was failing.
    
    - - - - -
    b69461a0 by Jason Shipman at 2023-01-30T21:21:50-05:00
    User's guide: Clarify overlapping instance candidate elimination
    
    This commit updates the user's guide section on overlapping instance candidate
    elimination to use "or" verbiage instead of "either/or" in regards to the
    current pair of candidates' being overlappable or overlapping. "Either IX is
    overlappable, or IY is overlapping" can cause confusion as it suggests "Either
    IX is overlappable, or IY is overlapping, but not both".
    
    This was initially discussed on this Discourse topic:
    
    https://discourse.haskell.org/t/clarification-on-overlapping-instance-candidate-elimination/5677
    
    - - - - -
    7cbdaad0 by Matthew Pickering at 2023-01-31T07:53:53-05:00
    Fixes for cabal-reinstall CI job
    
    * Allow filepath to be reinstalled
    * Bump some version bounds to allow newer versions of libraries
    * Rework testing logic to avoid "install --lib" and package env files
    
    Fixes #22344
    
    - - - - -
    fd8f32bf by Cheng Shao at 2023-01-31T07:54:29-05:00
    rts: prevent potential divide-by-zero when tickInterval=0
    
    This patch fixes a few places in RtsFlags.c that may result in
    divide-by-zero error when tickInterval=0, which is the default on
    wasm. Fixes #22603.
    
    - - - - -
    085a6db6 by Joachim Breitner at 2023-01-31T07:55:05-05:00
    Update note at beginning of GHC.Builtin.NAmes
    
    some things have been renamed since it was written, it seems.
    
    - - - - -
    7716cbe6 by Cheng Shao at 2023-01-31T07:55:41-05:00
    testsuite: use tgamma for cg007
    
    gamma is a glibc-only deprecated function, use tgamma instead. It's
    required for fixing cg007 when testing the wasm unregisterised
    codegen.
    
    - - - - -
    19c1fbcd by doyougnu at 2023-01-31T13:08:03-05:00
    InfoTableProv: ShortText --> ShortByteString
    
    - - - - -
    765fab98 by doyougnu at 2023-01-31T13:08:03-05:00
    FastString: add fastStringToShorText
    
    - - - - -
    a83c810d by Simon Peyton Jones at 2023-01-31T13:08:38-05:00
    Improve exprOkForSpeculation for classops
    
    This patch fixes #22745 and #15205, which are about GHC's
    failure to discard unnecessary superclass selections that
    yield coercions.  See
      GHC.Core.Utils Note [exprOkForSpeculation and type classes]
    
    The main changes are:
    
    * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and
      refer to it
    
    * Define new function isTerminatingType, to identify those
      guaranteed-terminating dictionary types.
    
    * exprOkForSpeculation has a new (very simple) case for ClassOpId
    
    * ClassOpId has a new field that says if the return type is
      an unlifted type, or a terminating type.
    
    This was surprisingly tricky to get right.  In particular note
    that unlifted types are not terminating types; you can write an
    expression of unlifted type, that diverges.  Not so for dictionaries
    (or, more precisely, for the dictionaries that GHC constructs).
    
    Metric Decrease:
        LargeRecord
    
    - - - - -
    f83374f8 by Krzysztof Gogolewski at 2023-01-31T13:09:14-05:00
    Support "unusable UNPACK pragma" warning with -O0
    
    Fixes #11270
    
    - - - - -
    a2d814dc by Ben Gamari at 2023-01-31T13:09:50-05:00
    configure: Always create the VERSION file
    
    Teach the `configure` script to create the `VERSION` file.
    This will serve as the stable interface to allow the user to determine
    the version number of a working tree.
    
    Fixes #22322.
    
    - - - - -
    5618fc21 by sheaf at 2023-01-31T15:51:06-05:00
    Cmm: track the type of global registers
    
    This patch tracks the type of Cmm global registers. This is needed
    in order to lint uses of polymorphic registers, such as SIMD vector
    registers that can be used both for floating-point and integer values.
    
    This changes allows us to refactor VanillaReg to not store VGcPtr,
    as that information is instead stored in the type of the usage of the
    register.
    
    Fixes #22297
    
    - - - - -
    78b99430 by sheaf at 2023-01-31T15:51:06-05:00
    Revert "Cmm Lint: relax SIMD register assignment check"
    
    This reverts commit 3be48877, which weakened a Cmm Lint check involving
    SIMD vectors. Now that we keep track of the type a global register is
    used at, we can restore the original stronger check.
    
    - - - - -
    be417a47 by Ben Gamari at 2023-01-31T15:51:45-05:00
    nativeGen/AArch64: Fix debugging output
    
    Previously various panics would rely on a half-written Show
    instance, leading to very unhelpful errors. Fix this.
    
    See #22798.
    
    - - - - -
    30989d13 by Ben Gamari at 2023-01-31T15:51:45-05:00
    nativeGen: Teach graph-colouring allocator that x18 is unusable
    
    Previously trivColourable for AArch64 claimed that at 18 registers were
    trivially-colourable. This is incorrect as x18 is reserved by the platform on
    AArch64/Darwin.
    
    See #22798.
    
    - - - - -
    7566fd9d by Ben Gamari at 2023-01-31T15:51:45-05:00
    nativeGen/AArch64: Fix graph-colouring allocator
    
    Previously various `Instr` queries used by the graph-colouring allocator
    failed to handle a few pseudo-instructions. This manifested in compiler
    panicks while compiling `SHA`, which uses `-fregs-graph`.
    
    Fixes #22798.
    
    - - - - -
    2cb500a5 by Ben Gamari at 2023-01-31T15:51:45-05:00
    testsuite: Add regression test for #22798
    
    - - - - -
    03d693b2 by Ben Gamari at 2023-01-31T15:52:32-05:00
    Revert "Hadrian: fix doc generation"
    
    This is too large of a hammer.
    
    This reverts commit 5640cb1d84d3cce4ce0a9e90d29b2b20d2b38c2f.
    
    - - - - -
    f838815c by Ben Gamari at 2023-01-31T15:52:32-05:00
    hadrian: Sphinx docs require templated cabal files
    
    The package-version discovery logic in
    `doc/users_guide/package_versions.py` uses packages' cabal files to
    determine package versions. Teach Sphinx about these dependencies in
    cases where the cabal files are generated by templates.
    
    - - - - -
    2e48c19a by Ben Gamari at 2023-01-31T15:52:32-05:00
    hadrian: Refactor templating logic
    
    This refactors Hadrian's autoconf-style templating logic to be explicit
    about which interpolation variables should be substituted in which
    files. This clears the way to fix #22714 without incurring rule cycles.
    
    - - - - -
    93f0e3c4 by Ben Gamari at 2023-01-31T15:52:33-05:00
    hadrian: Substitute LIBRARY_*_VERSION variables
    
    This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables
    in `libraries/prologue.txt`, fixing #22714.
    
    Fixes #22714.
    
    - - - - -
    22089f69 by Ben Gamari at 2023-01-31T20:46:27-05:00
    Bump transformers submodule to 0.6.0.6
    
    Fixes #22862.
    
    - - - - -
    f0eefa3c by Cheng Shao at 2023-01-31T20:47:03-05:00
    compiler: properly handle non-word-sized CmmSwitch scrutinees in the wasm NCG
    
    Currently, the wasm NCG has an implicit assumption: all CmmSwitch
    scrutinees are 32-bit integers. This is not always true; #22864 is one
    counter-example with a 64-bit scrutinee. This patch fixes the logic by
    explicitly converting the scrutinee to a word that can be used as a
    br_table operand. Fixes #22871. Also includes a regression test.
    
    - - - - -
    9f95db54 by Simon Peyton Jones at 2023-02-01T08:55:08+00:00
    Improve treatment of type applications in patterns
    
    This patch fixes a subtle bug in the typechecking of type
    applications in patterns, e.g.
       f (MkT @Int @a x y) = ...
    
    See Note [Type applications in patterns] in GHC.Tc.Gen.Pat.
    
    This fixes #19847, #22383, #19577, #21501
    
    - - - - -
    955a99ea by Simon Peyton Jones at 2023-02-01T12:31:23-05:00
    Treat existentials correctly in dubiousDataConInstArgTys
    
    Consider (#22849)
    
     data T a where
       MkT :: forall k (t::k->*) (ix::k). t ix -> T @k a
    
    Then dubiousDataConInstArgTys MkT [Type, Foo] should return
            [Foo (ix::Type)]
    NOT     [Foo (ix::k)]
    
    A bit of an obscure case, but it's an outright bug, and the fix is easy.
    
    - - - - -
    0cc16aaf by Matthew Pickering at 2023-02-01T12:31:58-05:00
    Bump supported LLVM range from 10 through 15 to 11 through 16
    
    LLVM 15 turns on the new pass manager by default, which we have yet to
    migrate to so for new we pass the `-enable-new-pm-0` flag in our
    llvm-passes flag.
    
    LLVM 11 was the first version to support the `-enable-new-pm` flag so we
    bump the lowest supported version to 11.
    
    Our CI jobs are using LLVM 12 so they should continue to work despite
    this bump to the lower bound.
    
    Fixes #21936
    
    - - - - -
    f94f1450 by Matthew Pickering at 2023-02-01T12:31:58-05:00
    Bump DOCKER_REV to use alpine image without LLVM installed
    
    alpine_3_12 only supports LLVM 10, which is now outside the supported
    version range.
    
    - - - - -
    083e26ed by Matthew Pickering at 2023-02-01T17:43:21-05:00
    Remove tracing OPTIONS_GHC
    
    These were accidentally left over from !9542
    
    - - - - -
    354aa47d by Teo Camarasu at 2023-02-01T17:44:00-05:00
    doc: fix gcdetails_block_fragmentation_bytes since annotation
    
    - - - - -
    61ce5bf6 by Jaro Reinders at 2023-02-02T00:15:30-05:00
    compiler: Implement higher order patterns in the rule matcher
    
    This implements proposal 555 and closes ticket #22465.
    See the proposal and ticket for motivation.
    
    The core changes of this patch are in the GHC.Core.Rules.match function
    and they are explained in the Note [Matching higher order patterns].
    
    - - - - -
    394b91ce by doyougnu at 2023-02-02T00:16:10-05:00
    CI: JavaScript backend runs testsuite
    
    This MR runs the testsuite for the JS backend. Note that this is a
    temporary solution until !9515 is merged.
    
    Key point: The CI runs hadrian on the built cross compiler _but not_ on
    the bindist.
    
    Other Highlights:
    
     - stm submodule gets a bump to mark tests as broken
     - several tests are marked as broken or are fixed by adding more
     - conditions to their test runner instance.
    
    List of working commit messages:
    
    CI: test cross target _and_ emulator
    
    CI: JS: Try run testsuite with hadrian
    
    JS.CI: cleanup and simplify hadrian invocation
    
    use single bracket, print info
    
    JS CI: remove call to test_compiler from hadrian
    
    don't build haddock
    
    JS: mark more tests as broken
    
    Tracked in https://gitlab.haskell.org/ghc/ghc/-/issues/22576
    
    JS testsuite: don't skip sum_mod test
    
    Its expected to fail, yet we skipped it which automatically makes it
    succeed leading to an unexpected success,
    
    JS testsuite: don't mark T12035j as skip
    
    leads to an unexpected pass
    
    JS testsuite: remove broken on T14075
    
    leads to unexpected pass
    
    JS testsuite: mark more tests as broken
    
    JS testsuite: mark T11760 in base as broken
    
    JS testsuite: mark ManyUnbSums broken
    
    submodules: bump process and hpc for JS tests
    
    Both submodules has needed tests skipped or marked broken for th JS
    backend. This commit now adds these changes to GHC.
    
    See:
    
    HPC: https://gitlab.haskell.org/hpc/hpc/-/merge_requests/21
    
    Process: https://github.com/haskell/process/pull/268
    
    remove js_broken on now passing tests
    
    separate wasm and js backend ci
    
    test: T11760: add threaded, non-moving only_ways
    
    test: T10296a add req_c
    
    T13894: skip for JS backend
    
    tests: jspace, T22333: mark as js_broken(22573)
    
    test: T22513i mark as req_th
    
    stm submodule: mark stm055, T16707 broken for JS
    
    tests: js_broken(22374) on unpack_sums_6, T12010
    
    dont run diff on JS CI, cleanup
    
    fixup: More CI cleanup
    
    fix: align text to master
    
    fix: align exceptions submodule to master
    
    CI: Bump DOCKER_REV
    
    Bump to ci-images commit that has a deb11 build with node. Required for
    !9552
    
    testsuite: mark T22669 as js_skip
    
    See #22669
    
    This test tests that .o-boot files aren't created when run in using the
    interpreter backend. Thus this is not relevant for the JS backend.
    
    testsuite: mark T22671 as broken on JS
    
    See #22835
    
    base.testsuite: mark Chan002 fragile for JS
    
    see #22836
    
    revert: submodule process bump
    
    bump stm submodule
    
    New hash includes skips for the JS backend.
    
    testsuite: mark RnPatternSynonymFail broken on JS
    
    Requires TH:
     - see !9779
     - and #22261
    
    compiler: GHC.hs ifdef import Utils.Panic.Plain
    
    - - - - -
    1ffe770c by Cheng Shao at 2023-02-02T09:40:38+00:00
    docs: 9.6 release notes for wasm backend
    
    - - - - -
    0ada4547 by Matthew Pickering at 2023-02-02T11:39:44-05:00
    Disable unfolding sharing for interface files with core definitions
    
    Ticket #22807 pointed out that the RHS sharing was not compatible with
    -fignore-interface-pragmas because the flag would remove unfoldings from
    identifiers before the `extra-decls` field was populated.
    
    For the 9.6 timescale the only solution is to disable this sharing,
    which will make interface files bigger but this is acceptable for the
    first release of `-fwrite-if-simplified-core`.
    
    For 9.8 it would be good to fix this by implementing #20056 due to the
    large number of other bugs that would fix.
    
    I also improved the error message in tc_iface_binding to avoid the "no match
    in record selector" error but it should never happen now as the entire
    sharing logic is disabled.
    
    Also added the currently broken test for #22807 which could be fixed by
    !6080
    
    Fixes #22807
    
    - - - - -
    7e2d3eb5 by lrzlin at 2023-02-03T05:23:27-05:00
    Enable tables next to code for LoongArch64
    
    - - - - -
    2931712a by Wander Hillen at 2023-02-03T05:24:06-05:00
    Move pthread and timerfd ticker implementations to separate files
    
    - - - - -
    41c4baf8 by Ben Gamari at 2023-02-03T05:24:44-05:00
    base: Fix Note references in GHC.IO.Handle.Types
    
    - - - - -
    31358198 by Andrew Lelechenko at 2023-02-03T05:25:22-05:00
    Bump submodule containers to 0.6.7
    
    Metric Decrease:
        ManyConstructors
        T10421
        T12425
        T12707
        T13035
        T13379
        T15164
        T1969
        T783
        T9198
        T9961
        WWRec
    
    - - - - -
    8feb9301 by Ben Gamari at 2023-02-03T05:25:59-05:00
    gitlab-ci: Eliminate redundant ghc --info output
    
    Previously ci.sh would emit the output of `ghc --info` every time it ran
    when using the nix toolchain. This produced a significant amount of
    noise.
    
    See #22861.
    - - - - -
    de1d1512 by Ryan Scott at 2023-02-03T14:07:30-05:00
    Windows: Remove mingwex dependency
    
    The clang based toolchain uses ucrt as its math library
    and so mingwex is no longer needed.  In fact using mingwex
    will cause incompatibilities as the default routines in both
    have differing ULPs and string formatting modifiers.
    
    ```
    $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe
    [1 of 2] Compiling Main             ( Bug.hs, Bug.o )
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info'
    ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info'
    ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above.
    
    <no location info>: error:
    
    GHC.ByteCode.Linker.lookupCE
    During interactive linking, GHCi couldn't find the following symbol:
      templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure
    This may be due to you not asking GHCi to load extra object files,
    archives or DLLs needed by your current session.  Restart GHCi, specifying
    the missing library using the -L/path/to/object/dir and -lmissinglibname
    flags, or simply by naming the relevant files on the GHCi command line.
    Alternatively, this link failure might indicate a bug in GHCi.
    If you suspect the latter, please report this as a GHC bug:
      https://www.haskell.org/ghc/reportabug
    ```
    
    - - - - -
    48e39195 by Tamar Christina at 2023-02-03T14:07:30-05:00
    linker: Fix BFD import libraries
    
    This commit fixes the BFD style import library support in the runtime
    linker.  This was accidentally broken during the refactoring to clang
    and went unnoticed because clang itself is unable to generate the BFD
    style import libraries.
    
    With this change we can not link against both GCC or Clang produced
    libraries again and intermix code produced by both compilers.
    
    - - - - -
    b2bb3e62 by Ben Gamari at 2023-02-03T14:07:30-05:00
    Bump Windows toolchain
    
    Updates to LLVM 14, hopefully fixing #21964.
    
    - - - - -
    bf3f88a1 by Andreas Klebinger at 2023-02-03T14:08:07-05:00
    Fix CallerCC potentially shadowing other cost centres.
    
    Add a CallerCC cost centre flavour for cost centres added by the
    CallerCC pass. This avoids potential accidental shadowing between
    CCs added by user annotations and ones added by CallerCC.
    
    - - - - -
    faea4bcd by j at 2023-02-03T14:08:47-05:00
    Disable several ignore-warning flags in genapply.
    - - - - -
    25537dfd by Ben Gamari at 2023-02-04T04:12:57-05:00
    Revert "Use fix-sized bit-fiddling primops for fixed size boxed types"
    
    This reverts commit 4512ad2d6a8e65ea43c86c816411cb13b822f674.
    
    This was never applied to master/9.6 originally.
    
    (cherry picked from commit a44bdc2720015c03d57f470b759ece7fab29a57a)
    
    - - - - -
    7612dc71 by Krzysztof Gogolewski at 2023-02-04T04:13:34-05:00
    Minor refactor
    
    * Introduce refactorDupsOn f = refactorDups (comparing f)
    * Make mkBigTupleCase and coreCaseTuple monadic.
      Every call to those functions was preceded by calling newUniqueSupply.
    * Use mkUserLocalOrCoVar, which is equivalent to combining
      mkLocalIdOrCoVar with mkInternalName.
    
    - - - - -
    5a54ac0b by Andrew Lelechenko at 2023-02-04T18:48:32-05:00
    Fix colors in emacs terminal
    
    - - - - -
    3c0f0c6d by Andrew Lelechenko at 2023-02-04T18:49:11-05:00
    base changelog: move entries which were not backported to ghc-9.6 to base-4.19 section
    
    - - - - -
    b18fbf52 by Josh Meredith at 2023-02-06T07:47:57+00:00
    Update JavaScript fileStat to match Emscripten layout
    
    - - - - -
    6636b670 by Sylvain Henry at 2023-02-06T09:43:21-05:00
    JS: replace "js" architecture with "javascript"
    
    Despite Cabal supporting any architecture name, `cabal --check` only
    supports a few built-in ones. Sadly `cabal --check` is used by Hackage
    hence using any non built-in name in a package (e.g. `arch(js)`) is
    rejected and the package is prevented from being uploaded on Hackage.
    
    Luckily built-in support for the `javascript` architecture was added for
    GHCJS a while ago. In order to allow newer `base` to be uploaded on
    Hackage we make the switch from `js` to `javascript` architecture.
    
    Fixes #22740.
    
    Co-authored-by: Ben Gamari <ben at smart-cactus.org>
    
    - - - - -
    77a8234c by Luite Stegeman at 2023-02-06T09:43:59-05:00
    Fix marking async exceptions in the JS backend
    
    Async exceptions are posted as a pair of the exception and
    the thread object. This fixes the marking pass to correctly
    follow the two elements of the pair.
    
    Potentially fixes #22836
    
    - - - - -
    3e09cf82 by Jan Hrček at 2023-02-06T09:44:38-05:00
    Remove extraneous word in Roles user guide
    
    - - - - -
    b17fb3d9 by sheaf at 2023-02-07T10:51:33-05:00
    Don't allow . in overloaded labels
    
    This patch removes . from the list of allowed characters in a non-quoted
    overloaded label, as it was realised this steals syntax, e.g. (#.).
    
    Users who want this functionality will have to add quotes around the
    label, e.g. `#"17.28"`.
    
    Fixes #22821
    
    - - - - -
    5dce04ee by romes at 2023-02-07T10:52:10-05:00
    Update kinds in comments in GHC.Core.TyCon
    
    Use `Type` instead of star kind (*)
    Fix comment with incorrect kind * to have kind `Constraint`
    
    - - - - -
    92916194 by Ben Gamari at 2023-02-07T10:52:48-05:00
    Revert "Use fix-sized equality primops for fixed size boxed types"
    
    This reverts commit 024020c38126f3ce326ff56906d53525bc71690c.
    
    This was never applied to master/9.6 originally.
    
    See #20405 for why using these primops is a bad idea.
    
    (cherry picked from commit b1d109ad542e4c37ae5af6ace71baf2cb509d865)
    
    - - - - -
    c1670c6b by Sylvain Henry at 2023-02-07T21:25:18-05:00
    JS: avoid head/tail and unpackFS
    
    - - - - -
    a9912de7 by Krzysztof Gogolewski at 2023-02-07T21:25:53-05:00
    testsuite: Fix Python warnings (#22856)
    
    - - - - -
    9ee761bf by sheaf at 2023-02-08T14:40:40-05:00
    Fix tyvar scoping within class SPECIALISE pragmas
    
    Type variables from class/instance headers scope over class/instance
    method type signatures, but DO NOT scope over the type signatures in
    SPECIALISE and SPECIALISE instance pragmas.
    
    The logic in GHC.Rename.Bind.rnMethodBinds correctly accounted for
    SPECIALISE inline pragmas, but forgot to apply the same treatment
    to method SPECIALISE pragmas, which lead to a Core Lint failure with
    an out-of-scope type variable. This patch makes sure we apply the same
    logic for both cases.
    
    Fixes #22913
    
    - - - - -
    7eac2468 by Matthew Pickering at 2023-02-08T14:41:17-05:00
    Revert "Don't keep exit join points so much"
    
    This reverts commit caced75765472a1a94453f2e5a439dba0d04a265.
    
    It seems the patch "Don't keep exit join points so much" is causing
    wide-spread regressions in the bytestring library benchmarks. If I
    revert it then the 9.6 numbers are better on average than 9.4.
    
    See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525
    
    -------------------------
    Metric Decrease:
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModules
        MultiLayerModulesRecomp
        MultiLayerModulesTH_Make
        T12150
        T13386
        T13719
        T21839c
        T3294
        parsing001
    -------------------------
    
    - - - - -
    633f2799 by Cheng Shao at 2023-02-08T18:42:16-05:00
    testsuite: remove config.use_threads
    
    This patch simplifies the testsuite driver by removing the use_threads
    config field. It's just a degenerate case of threads=1.
    
    - - - - -
    ca6673e3 by Cheng Shao at 2023-02-08T18:42:16-05:00
    testsuite: use concurrent.futures.ThreadPoolExecutor in the driver
    
    The testsuite driver used to create one thread per test case, and
    explicitly use semaphore and locks for rate limiting and
    synchronization. This is a bad practice in any language, and
    occasionally may result in livelock conditions (e.g. #22889). This
    patch uses concurrent.futures.ThreadPoolExecutor for scheduling test
    case runs, which is simpler and more robust.
    
    - - - - -
    f22cce70 by Alan Zimmerman at 2023-02-08T18:42:51-05:00
    EPA: Comment between module and where should be in header comments
    
    Do not apply the heuristic to associate a comment with a prior
    declaration for the first declaration in the file.
    
    Closes #22919
    
    - - - - -
    d69ecac2 by Josh Meredith at 2023-02-09T03:24:05-05:00
    JS generated refs: update testsuite conditions
    
    - - - - -
    2ea1a6bc by sheaf at 2023-02-09T03:24:44-05:00
    Bump transformers to 0.6.1.0
    
    This allows us to avoid orphans for Foldable1 instances,
    fixing #22898.
    
    Updates transformers submodule.
    
    - - - - -
    d9d0c28d by konsumlamm at 2023-02-09T14:07:48-05:00
    Update `Data.List.singleton` doc comment
    - - - - -
    fe9cd6ef by Ben Gamari at 2023-02-09T14:08:23-05:00
    gitlab-template: Emphasize `user facing` label
    
    My sense is that the current mention of the ~"user facing" label is
    overlooked by many MR authors.
    
    Let's move this point up in the list to make it more likely that it is
    seen. Also rephrase some of the points.
    
    - - - - -
    e45eb828 by Simon Peyton Jones at 2023-02-10T06:51:28-05:00
    Refactor the simplifier a bit to fix #22761
    
    The core change in this commit, which fixes #22761, is that
    
    * In a Core rule, ru_rhs is always occ-analysed.
    
    This means adding a couple of calls to occurAnalyseExpr when
    building a Rule, in
    * GHC.Core.Rules.mkRule
    * GHC.Core.Opt.Simplify.Iteration.simplRules
    
    But diagosing the bug made me stare carefully at the code of the
    Simplifier, and I ended up doing some only-loosely-related refactoring.
    
    * I think that RULES could be lost because not every code path
      did addBndrRules
    
    * The code around lambdas was very convoluted
    
    It's mainly moving deck chairs around, but I like it more now.
    
    - - - - -
    11e0cacb by Rebecca Turner at 2023-02-10T06:52:09-05:00
    Detect the `mold` linker
    
    Enables support for the `mold` linker by rui314.
    
    - - - - -
    59556235 by parsonsmatt at 2023-02-10T09:53:11-05:00
    Add Lift instance for Fixed
    
    - - - - -
    c44e5f30 by Sylvain Henry at 2023-02-10T09:53:51-05:00
    Testsuite: decrease length001 timeout for JS (#22921)
    
    - - - - -
    133516af by Zubin Duggal at 2023-02-10T09:54:27-05:00
    compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData`
    instances
    
    This is a minor refactor that makes it easy to add and remove fields from
    `ModIface_` and `ModIfaceBackend`.
    
    Also change the formatting to make it clear exactly which fields are
    fully forced with `rnf`
    
    - - - - -
    1e9eac1c by Matthew Pickering at 2023-02-13T11:36:41+01:00
    Refresh profiling docs
    
    I went through the whole of the profiling docs and tried to amend them
    to reflect current best practices and tooling. In particular I removed
    some old references to tools such as hp2any and replaced them with
    references to eventlog2html.
    
    - - - - -
    da208b9a by Matthew Pickering at 2023-02-13T11:36:41+01:00
    docs: Add section about profiling and foreign calls
    
    Previously there was no documentation for how foreign calls interacted
    with the profiler. This can be quite confusing for users so getting it
    into the user guide is the first step to a potentially better solution.
    See the ticket for more insightful discussion.
    
    Fixes #21764
    
    - - - - -
    081640f1 by Andrew Lelechenko at 2023-02-13T12:51:52-05:00
    Document that -fproc-alignment was introduced only in GHC 8.6
    
    - - - - -
    16adc349 by Sven Tennie at 2023-02-14T11:26:31-05:00
    Add clangd flag to include generated header files
    
    This enables clangd to correctly check C files that import Rts.h.
    (The added include directory contains ghcautoconf.h et. al.)
    
    - - - - -
    c399ccd9 by amesgen at 2023-02-14T11:27:14-05:00
    Mention new `Foreign.Marshal.Pool` implementation in User's Guide
    
    - - - - -
    b9282cf7 by Ben Gamari at 2023-02-14T11:27:50-05:00
    upload_ghc_libs: More control over which packages to operate on
    
    Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to
    limit which packages to upload. This is often necessary when one package
    is not uploadable (e.g. see #22740).
    
    - - - - -
    aa3a262d by PHO at 2023-02-14T11:28:29-05:00
    Assume platforms support rpaths if they use either ELF or Mach-O
    
    Not only Linux, Darwin, and FreeBSD support rpaths. Determine the usability
    of rpaths based on the object format, not on OS.
    
    - - - - -
    47716024 by PHO at 2023-02-14T11:29:09-05:00
    RTS linker: Improve compatibility with NetBSD
    
    1. Hint address to NetBSD mmap(2) has a different semantics from that of
       Linux. When a hint address is provided, mmap(2) searches for a free
       region at or below the hint but *never* above it. This means we can't
       reliably search for free regions incrementally on the userland,
       especially when ASLR is enabled. Let the kernel do it for us if we don't
       care where the mapped address is going to be.
    
    2. NetBSD not only hates to map pages as rwx, but also disallows to switch
       pages from rw- to r-x unless the intention is declared when pages are
       initially requested. This means we need a new MemoryAccess mode for
       pages that are going to be changed to r-x.
    
    - - - - -
    11de324a by Li-yao Xia at 2023-02-14T11:29:49-05:00
    base: Move changelog entry to its place
    
    - - - - -
    75930424 by Ben Gamari at 2023-02-14T11:30:27-05:00
    nativeGen/AArch64: Emit Atomic{Read,Write} inline
    
    Previously the AtomicRead and AtomicWrite operations were emitted as
    out-of-line calls. However, these tend to be very important for
    performance, especially the RELAXED case (which only exists for
    ThreadSanitizer checking).
    
    Fixes #22115.
    
    - - - - -
    d6411d6c by Andreas Klebinger at 2023-02-14T11:31:04-05:00
    Fix some correctness issues around tag inference when targeting the bytecode generator.
    
    * Let binders are now always assumed untagged for bytecode.
    * Imported referenced are now always assumed to be untagged for bytecode.
    
    Fixes #22840
    
    - - - - -
    9fb4ca89 by sheaf at 2023-02-14T11:31:49-05:00
    Introduce warning for loopy superclass solve
    
    Commit aed1974e completely re-engineered the treatment of loopy
    superclass dictionaries in instance declarations. Unfortunately,
    it has the potential to break (albeit in a rather minor way) user code.
    
    To alleviate migration concerns, this commit re-introduces the old
    behaviour. Any reliance on this old behaviour triggers a warning,
    controlled by `-Wloopy-superclass-solve`. The warning text explains
    that GHC might produce bottoming evidence, and provides a migration
    strategy.
    
    This allows us to provide a graceful migration period, alerting users
    when they are relying on this unsound behaviour.
    
    Fixes #22912 #22891 #20666 #22894 #22905
    
    - - - - -
    1928c7f3 by Cheng Shao at 2023-02-14T11:32:26-05:00
    rts: make it possible to change mblock size on 32-bit targets
    
    The MBLOCK_SHIFT macro must be the single source of truth for defining
    the mblock size, and changing it should only affect performance, not
    correctness. This patch makes it truly possible to reconfigure mblock
    size, at least on 32-bit targets, by fixing places which implicitly
    relied on the previous MBLOCK_SHIFT constant. Fixes #22901.
    
    - - - - -
    78aa3b39 by Simon Hengel at 2023-02-14T11:33:06-05:00
    Update outdated references to notes
    
    - - - - -
    e8baecd2 by meooow25 at 2023-02-14T11:33:49-05:00
    Documentation: Improve Foldable1 documentation
    
    * Explain foldrMap1, foldlMap1, foldlMap1', and foldrMap1' in greater
      detail, the text is mostly adapted from documentation of Foldable.
    * Describe foldr1, foldl1, foldl1' and foldr1' in terms of the above
      functions instead of redoing the full explanation.
    * Small updates to documentation of fold1, foldMap1 and toNonEmpty,
      again adapting from Foldable.
    * Update the foldMap1 example to lists instead of Sum since this is
      recommended for lazy right-associative folds.
    
    Fixes #22847
    
    - - - - -
    85a1a575 by romes at 2023-02-14T11:34:25-05:00
    fix: Mark ghci Prelude import as implicit
    
    Fixes #22829
    
    In GHCi, we were creating an import declaration for Prelude but we were
    not setting it as an implicit declaration. Therefore, ghci's import of
    Prelude triggered -Wmissing-import-lists.
    
    Adds regression test T22829 to testsuite
    
    - - - - -
    3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05:00
    compiler: fix generateCgIPEStub for no-tables-next-to-code builds
    
    generateCgIPEStub already correctly implements the CmmTick finding
    logic for when tables-next-to-code is on/off, but it used the wrong
    predicate to decide when to switch between the two. Previously it
    switches based on whether the codegen is unregisterised, but there do
    exist registerised builds that disable tables-next-to-code! This patch
    corrects that problem. Fixes #22896.
    
    - - - - -
    08c0822c by doyougnu at 2023-02-15T00:16:39-05:00
    docs: release notes, user guide: add js backend
    
    Follow up from #21078
    
    - - - - -
    79d8fd65 by Bryan Richter at 2023-02-15T00:17:15-05:00
    Allow failure in nightly-x86_64-linux-deb10-no_tntc-validate
    
    See #22343
    
    - - - - -
    9ca51f9e by Cheng Shao at 2023-02-15T00:17:53-05:00
    rts: add the rts_clearMemory function
    
    This patch adds the rts_clearMemory function that does its best to
    zero out unused RTS memory for a wasm backend use case. See the
    comment above rts_clearMemory() prototype declaration for more
    detailed explanation. Closes #22920.
    
    - - - - -
    26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00
    Add -single-threaded flag to force single threaded rts
    
    This is the small part of implementing
    https://github.com/ghc-proposals/ghc-proposals/pull/240
    
    - - - - -
    631c6c72 by Cheng Shao at 2023-02-16T06:43:09-05:00
    docs: add a section for the wasm backend
    
    Fixes #22658
    
    - - - - -
    1878e0bd by Bryan Richter at 2023-02-16T06:43:47-05:00
    tests: Mark T12903 fragile everywhere
    
    See #21184
    
    - - - - -
    b9420eac by Bryan Richter at 2023-02-16T06:43:47-05:00
    Mark all T5435 variants as fragile
    
    See #22970.
    
    - - - - -
    df3d94bd by Sylvain Henry at 2023-02-16T06:44:33-05:00
    Testsuite: mark T13167 as fragile for JS (#22921)
    
    - - - - -
    324e925b by Sylvain Henry at 2023-02-16T06:45:15-05:00
    JS: disable debugging info for heap objects
    
    - - - - -
    518af814 by Josh Meredith at 2023-02-16T10:16:32-05:00
    Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name caching
    
    - - - - -
    34cd308e by Ben Gamari at 2023-02-16T10:17:08-05:00
    base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog
    
    Fixes #22883.
    
    - - - - -
    12965aba by Simon Peyton Jones at 2023-02-16T10:17:46-05:00
    Narrow the dont-decompose-newtype test
    
    Following #22924 this patch narrows the test that stops
    us decomposing newtypes.  The key change is the use of
    noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp.
    
    We went to and fro on the solution, as you can see in #22924.
    The result is carefully documented in
      Note [Decomoposing newtype equalities]
    
    On the way I had revert most of
      commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90
      Author: Richard Eisenberg <rae at cs.brynmawr.edu>
      Date:   Mon Dec 5 10:14:02 2022 -0500
    
        Do newtype unwrapping in the canonicaliser and rewriter
    
        See Note [Unwrap newtypes first], which has the details.
    
    It turns out that
    
    (a) 3e827c3f makes GHC behave worse on some recursive newtypes
        (see one of the tests on this commit)
    (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders
        3e827c3f unnecessary
    
    - - - - -
    5b038888 by Andrew Lelechenko at 2023-02-16T10:18:24-05:00
    Documentation: add an example of SPEC usage
    
    - - - - -
    681e0e8c by sheaf at 2023-02-16T14:09:56-05:00
    No default finalizer exception handler
    
    Commit cfc8e2e2 introduced a mechanism for handling of exceptions
    that occur during Handle finalization, and 372cf730 set the default
    handler to print out the error to stderr.
    
    However, #21680 pointed out we might not want to set this by default,
    as it might pollute users' terminals with unwanted information.
    So, for the time being, the default handler discards the exception.
    
    Fixes #21680
    
    - - - - -
    b3ac17ad by Matthew Pickering at 2023-02-16T14:10:31-05:00
    unicode: Don't inline bitmap in generalCategory
    
    generalCategory contains a huge literal string but is marked INLINE,
    this will duplicate the string into any use site of generalCategory. In
    particular generalCategory is used in functions like isSpace and the
    literal gets inlined into this function which makes it massive.
    
    https://github.com/haskell/core-libraries-committee/issues/130
    
    Fixes #22949
    
    -------------------------
    Metric Decrease:
        T4029
        T18304
    -------------------------
    
    - - - - -
    8988eeef by sheaf at 2023-02-16T20:32:27-05:00
    Expand synonyms in RoughMap
    
    We were failing to expand type synonyms in the function
    GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the
    RoughMap infrastructure crucially relies on type synonym expansion
    to work.
    
    This patch adds the missing type-synonym expansion.
    
    Fixes #22985
    
    - - - - -
    3dd50e2f by Matthew Pickering at 2023-02-16T20:33:03-05:00
    ghcup-metadata: Add test artifact
    
    Add the released testsuite tarball to the generated ghcup metadata.
    
    - - - - -
    c6a967d9 by Matthew Pickering at 2023-02-16T20:33:03-05:00
    ghcup-metadata: Use Ubuntu and Rocky bindists
    
    Prefer to use the Ubuntu 20.04 and 18.04 binary distributions on Ubuntu
    and Linux Mint. Prefer to use the Rocky 8 binary distribution on
    unknown distributions.
    
    - - - - -
    be0b7209 by Matthew Pickering at 2023-02-17T09:37:16+00:00
    Add INLINABLE pragmas to `generic*` functions in Data.OldList
    
    These functions are
    
    * recursive
    * overloaded
    
    So it's important to add an `INLINABLE` pragma to each so that they can be
    specialised at the use site when the specific numeric type is known.
    Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020)
    
    https://github.com/haskell/core-libraries-committee/issues/129
    
    - - - - -
    a203ad85 by Sylvain Henry at 2023-02-17T15:59:16-05:00
    Merge libiserv with ghci
    
    `libiserv` serves no purpose. As it depends on `ghci` and doesn't have
    more dependencies than the `ghci` package, its code could live in the
    `ghci` package too.
    
    This commit also moves most of the code from the `iserv` program into
    the `ghci` package as well so that it can be reused. This is especially
    useful for the implementation of TH for the JS backend (#22261, !9779).
    
    - - - - -
    7080a93f by Simon Peyton Jones at 2023-02-20T12:06:32+01:00
    Improve GHC.Tc.Gen.App.tcInstFun
    
    It wasn't behaving right when inst_final=False, and the
    function had no type variables
       f :: Foo => Int
    
    Rather a corner case, but we might as well do it right.
    
    Fixes #22908
    
    Unexpectedly, three test cases (all using :type in GHCi) got
    slightly better output as a result:
      T17403, T14796, T12447
    
    - - - - -
    2592ab69 by Cheng Shao at 2023-02-20T10:35:30-05:00
    compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping
    
    The wasm NCG used to map CCCS to a wasm global, based on the
    observation that CCCS is a transient register that's already handled
    by thread state load/store logic, so it doesn't need to be backed by
    the rCCCS field in the register table.
    
    Unfortunately, this is wrong, since even when Cmm execution hasn't
    yielded back to the scheduler, the Cmm code may call enterFunCCS,
    which does use rCCCS.
    
    This breaks cost centre profiling in a subtle way, resulting in
    inaccurate stack traces in some test cases. The fix is simple though:
    just remove the CCCS mapping.
    
    - - - - -
    26243de1 by Alexis King at 2023-02-20T15:27:17-05:00
    Handle top-level Addr# literals in the bytecode compiler
    
    Fixes #22376.
    
    - - - - -
    0196cc2b by romes at 2023-02-20T15:27:52-05:00
    fix: Explicitly flush stdout on plugin
    
    Because of #20791, the plugins tests often fail.  This is a temporary
    fix to stop the tests from failing due to unflushed outputs on windows
    and the explicit flush should be removed when #20791 is fixed.
    
    - - - - -
    4327d635 by Ryan Scott at 2023-02-20T20:44:34-05:00
    Don't generate datacon wrappers for `type data` declarations
    
    Data constructor wrappers only make sense for _value_-level data constructors,
    but data constructors for `type data` declarations only exist at the _type_
    level. This patch does the following:
    
    * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data
      constructor receives a wrapper now consider whether or not its parent data
      type was declared with `type data`, omitting a wrapper if this is the case.
    
    * Now that `type data` data constructors no longer receive wrappers, there is a
      spot of code in `refineDefaultAlt` that panics when it encounters a value
      headed by a `type data` type constructor. I've fixed this with a special case
      in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]`
      to explain why we do this.
    
    Fixes #22948.
    
    - - - - -
    96dc58b9 by Ryan Scott at 2023-02-20T20:44:35-05:00
    Treat type data declarations as empty when checking pattern-matching coverage
    
    The data constructors for a `type data` declaration don't exist at the value
    level, so we don't want GHC to warn users to match on them.
    
    Fixes #22964.
    
    - - - - -
    ff8e99f6 by Ryan Scott at 2023-02-20T20:44:35-05:00
    Disallow `tagToEnum#` on `type data` types
    
    We don't want to allow users to conjure up values of a `type data` type using
    `tagToEnum#`, as these simply don't exist at the value level.
    
    - - - - -
    8e765aff by Andrew Lelechenko at 2023-02-21T12:03:24-05:00
    Bump submodule text to 2.0.2
    
    - - - - -
    172ff88f by Georgi Lyubenov at 2023-02-21T18:35:56-05:00
    GHC proposal 496 - Nullary record wildcards
    
    This patch implements GHC proposal 496, which allows record wildcards
    to be used for nullary constructors, e.g.
    
      data A = MkA1 | MkA2 { fld1 :: Int }
      f :: A -> Int
      f (MkA1 {..}) = 0
      f (MkA2 {..}) = fld1
    
    To achieve this, we add arity information to the record field
    environment, so that we can accept a constructor which has no fields
    while continuing to reject non-record constructors with more than 1
    field. See Note [Nullary constructors and empty record wildcards],
    as well as the more general overview in Note [Local constructor info in the renamer],
    both in the newly introduced GHC.Types.ConInfo module.
    
    Fixes #22161
    
    - - - - -
    f70a0239 by sheaf at 2023-02-21T18:36:35-05:00
    ghc-prim: levity-polymorphic array equality ops
    
    This patch changes the pointer-equality comparison operations in
    GHC.Prim.PtrEq to work with arrays of unlifted values, e.g.
    
      sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int#
    
    Fixes #22976
    
    - - - - -
    9296660b by Andreas Klebinger at 2023-02-21T23:58:05-05:00
    base: Correct @since annotation for FP<->Integral bit cast operations.
    
    Fixes #22708
    
    - - - - -
    f11d9c27 by romes at 2023-02-21T23:58:42-05:00
    fix: Update documentation links
    
    Closes #23008
    
    Additionally batches some fixes to pointers to the Note [Wired-in units],
    and a typo in said note.
    
    - - - - -
    fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00
    Propagate failure if unable to push notes
    
    - - - - -
    8e170f86 by Alexis King at 2023-02-23T16:59:22-05:00
    rts: Fix `prompt#` when profiling is enabled
    
    This commit also adds a new -Dk RTS option to the debug RTS to assist
    debugging continuation captures. Currently, the printed information is
    quite minimal, but more can be added in the future if it proves to be
    useful when debugging future issues.
    
    fixes #23001
    
    - - - - -
    e9e7a00d by sheaf at 2023-02-23T17:00:01-05:00
    Explicit migration timeline for loopy SC solving
    
    This patch updates the warning message introduced in commit
    9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit
    migration timeline: GHC will no longer support this constraint solving
    mechanism starting from GHC 9.10.
    
    Fixes #22912
    
    - - - - -
    4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00
    JS: make some arithmetic primops faster (#22835)
    
    Don't use BigInt for wordAdd2, mulWord32, and timesInt32.
    
    Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org>
    
    - - - - -
    92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump terminfo submodule to 0.4.1.6
    
    - - - - -
    f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump unix submodule to 2.8.1.0
    
    - - - - -
    47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump deepseq submodule to 1.4.8.1
    
    - - - - -
    d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump directory submodule to 1.3.8.1
    
    - - - - -
    df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump process submodule to v1.6.17.0
    
    - - - - -
    4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump hsc2hs submodule to 0.68.8
    
    - - - - -
    81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump array submodule to 0.5.4.0
    
    - - - - -
    6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump Cabal submodule to 3.9 pre-release
    
    - - - - -
    4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump filepath submodule to 1.4.100.1
    
    - - - - -
    2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00
    Bump haskeline submodule to 0.8.2.1
    
    - - - - -
    fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00
    gitlab-ci: Run nix-build with -v0
    
    This significantly cuts down on the amount of
    noise in the job log.
    
    Addresses #22861.
    - - - - -
    69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00
    Fix ParallelListComp out of scope suggestion
    
    This patch makes it so vars from one block of a parallel list
    comprehension are not in scope in a subsequent block during type
    checking. This was causing GHC to emit a faulty suggestion when an out
    of scope variable shared the occ name of a var from a different block.
    
    Fixes #22940
    
    - - - - -
    ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-05:00
    Fix shadowing bug in prepareAlts
    
    As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was
    using an OutType to construct an InAlt.  When shadowing is in play,
    this is outright wrong.
    
    See Note [Shadowing in prepareAlts].
    
    - - - - -
    7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00
    JS: Store CI perf results (fix #22923)
    
    - - - - -
    b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00
    Don't specialise incoherent instance applications
    
    Using incoherent instances, there can be situations where two
    occurrences of the same overloaded function at the same type use two
    different instances (see #22448). For incoherently resolved instances,
    we must mark them with `nospec` to avoid the specialiser rewriting one
    to the other. This marking is done during the desugaring of the
    `WpEvApp` wrapper.
    
    Fixes #22448
    
    Metric Increase:
        T15304
    
    - - - - -
    d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00
    Fix SCC grouping example
    
    - - - - -
    f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00
    Mark setnumcapabilities001 fragile
    
    - - - - -
    29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00
    Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail
    
    See #22520
    
    - - - - -
    9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00
    ghc-prim: fix hs_cmpxchg64 function prototype
    
    hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime
    results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised
    builds, which go unnoticed at compile-time due to C implicit casting
    in .hc files.
    
    - - - - -
    0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-05:00
    Account for local rules in specImports
    
    As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were
    generating specialisations (a locally-define function) for imported
    functions; and then generating specialisations for those
    locally-defined functions.  The RULE for the latter should be
    attached to the local Id, not put in the rules-for-imported-ids
    set.
    
    Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules
    
    - - - - -
    8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-05:00
    JS: fix for overlap with copyMutableByteArray# (#23033)
    
    The code wasn't taking into account some kind of overlap.
    
    cgrun070 has been extended to test the missing case.
    
    - - - - -
    239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00
    Testsuite: replace some js_skip with req_cmm
    
    req_cmm is more informative than js_skip
    
    - - - - -
    7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-05:00
    Take more care with unlifted bindings in the specialiser
    
    As #22998 showed, we were floating an unlifted binding to top
    level, which breaks a Core invariant.
    
    The fix is easy, albeit a little bit conservative.  See
    Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise
    
    - - - - -
    bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-05:00
    Account for TYPE vs CONSTRAINT in mkSelCo
    
    As #23018 showed, in mkRuntimeRepCo we need to account for coercions
    between TYPE and COERCION.
    
    See Note [mkRuntimeRepCo] in GHC.Core.Coercion.
    
    - - - - -
    79ffa170 by Ben Gamari at 2023-03-01T04:17:20-05:00
    hadrian: Add dependency from lib/settings to mk/config.mk
    
    In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253
    by adding logic to the bindist Makefile to regenerate the `settings`
    file from information gleaned by the bindist `configure` script.
    However, this fix had no effect as `lib/settings` is shipped in the
    binary distribution (to allow in-place use of the binary distribution).
    As `lib/settings` already existed and its rule declared no dependencies,
    `make` would fail to use the added rule to regenerate it.
    
    Fix this by explicitly declaring a dependency from `lib/settings` on
    `mk/config.mk`.
    
    Fixes #22982.
    
    - - - - -
    a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-05:00
    Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)"
    
    This reverts the bits affecting fusion of `drop` and `dropWhile` of commit
    0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring
    unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`.
    
    It also adds a new test for #23021 (which was the reason for reverting) as
    well as adds a clarifying comment to T18964.
    
    Fixes #23021, unfixes #18964.
    
    Metric Increase:
        T18964
    Metric Decrease:
        T18964
    
    - - - - -
    cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-05:00
    Refine the test for naughty record selectors
    
    The test for naughtiness in record selectors is surprisingly subtle.
    See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils.
    
    Fixes #23038.
    
    - - - - -
    86f240ca by romes at 2023-03-01T04:19:10-05:00
    fix: Consider strictness annotation in rep_bind
    
    Fixes #23036
    
    - - - - -
    1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00
    Don't suppress *all* Wanteds
    
    Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its
    rewriters have unfilled coercion holes; see
    Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint.
    
    But if we thereby suppress *all* errors that's really confusing,
    and as #22707 shows, GHC goes on without even realising that the
    program is broken. Disaster.
    
    This MR arranges to un-suppress them all if they all get suppressed.
    
    Close #22707
    
    - - - - -
    8919f341 by Luite Stegeman at 2023-03-02T22:42:45-05:00
    Check for platform support for JavaScript foreign imports
    
    GHC was accepting `foreign import javascript` declarations
    on non-JavaScript platforms. This adds a check so that these
    are only supported on an platform that supports the JavaScript
    calling convention.
    
    Fixes #22774
    
    - - - - -
    db83f8bb by Ben Gamari at 2023-03-02T22:43:22-05:00
    rts: Statically assert alignment of Capability
    
    In #22965 we noticed that changes in the size of `Capability` can result
    in unsound behavior due to the `align` pragma claiming an alignment
    which we don't in practice observe. Avoid this by statically asserting
    that the size is a multiple of the alignment.
    
    - - - - -
    5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00
    rts: Introduce stgMallocAlignedBytes
    
    - - - - -
    8a6f745d by Ben Gamari at 2023-03-02T22:43:22-05:00
    rts: Correctly align Capability allocations
    
    Previously we failed to tell the C allocator that `Capability`s needed
    to be aligned, resulting in #22965.
    
    Fixes #22965.
    Fixes #22975.
    
    - - - - -
    5464c73f by Ben Gamari at 2023-03-02T22:43:22-05:00
    rts: Drop no-alignment special case for Windows
    
    For reasons that aren't clear, we were previously not giving Capability
    the same favorable alignment on Windows that we provided on other
    platforms. Fix this.
    
    - - - - -
    a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-05:00
    constant folding: Correct type of decodeDouble_Int64 rule
    
    The first argument is Int64# unconditionally, so we better produce
    something of that type. This fixes a core lint error found in the ad
    package.
    
    Fixes #23019
    
    - - - - -
    68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-05:00
    ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs
    
    Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was
    incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and
    didn't completly fix the compiler panics when compiling with `-fregs-graph`.
    
    Fixes #23002
    
    - - - - -
    2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00
    Get the right in-scope set in etaBodyForJoinPoint
    
    Fixes #23026
    
    - - - - -
    45af8482 by David Feuer at 2023-03-03T11:40:47-05:00
    Export getSolo from Data.Tuple
    
    Proposed in
    [CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113)
    and
    [approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191)
    
    - - - - -
    0c694895 by David Feuer at 2023-03-03T11:40:47-05:00
    Document getSolo
    
    - - - - -
    bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00
    More fixes for `type data` declarations
    
    This MR fixes #23022 and #23023.  Specifically
    
    * Beef up Note [Type data declarations] in GHC.Rename.Module,
      to make invariant (I1) explicit, and to name the several
      wrinkles.
    
      And add references to these specific wrinkles.
    
    * Add a Lint check for invariant (I1) above.
      See GHC.Core.Lint.checkTypeDataConOcc
    
    * Disable the `caseRules` for dataToTag# for `type data` values.
      See Wrinkle (W2c) in the Note above.  Fixes #23023.
    
    * Refine the assertion in dataConRepArgTys, so that it does not
      complain about the absence of a wrapper for a `type data` constructor
      Fixes #23022.
    
    Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00
    Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT
    
    These all type-level equality decision procedures.
    
    Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98
    
    - - - - -
    bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00
    Add test for T22793
    
    - - - - -
    c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00
    Fix typo in docs referring to threadLabel
    
    - - - - -
    232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00
    Add regression test for #22328
    
    - - - - -
    5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Enable response files for linker if supported
    
    - - - - -
    1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Synchronize `configure.ac` and `distrib/configure.ac.in`
    
    - - - - -
    70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Fix `hadrian/bindist/config.mk.in`
    
    … as suggested by @bgamari
    
    - - - - -
    b042b125 by sheaf at 2023-03-06T17:06:50-05:00
    Apply 1 suggestion(s) to 1 file(s)
    - - - - -
    674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Try to create somewhat portable `ld` command
    
    I cannot figure out a good way to generate an `ld` command
    that works on both Linux and macOS.  Normally you'd use something
    like `AC_LINK_IFELSE` for this purpose (I think), but that won't
    let us test response file support.
    
    - - - - -
    83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Quote variables
    
    … as suggested by @bgamari
    
    - - - - -
    845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Fix configure failure on alpine linux
    
    - - - - -
    c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
    Small fixes to configure script
    
    - - - - -
    cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00
    Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115)
    
    I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module
    module into a proper TcRnMessage.
    Instead, these TcRnMessage messages were introduced:
      TcRnIllegalInstanceHeadDecl
      TcRnUnexpectedStandaloneDerivingDecl
      TcRnUnusedVariableInRuleDecl
      TcRnUnexpectedStandaloneKindSig
      TcRnIllegalRuleLhs
      TcRnBadAssocRhs
      TcRnDuplicateRoleAnnot
      TcRnDuplicateKindSig
      TcRnIllegalDerivStrategy
      TcRnIllegalMultipleDerivClauses
      TcRnNoDerivStratSpecified
      TcRnStupidThetaInGadt
      TcRnBadImplicitSplice
      TcRnShadowedTyVarNameInFamResult
      TcRnIncorrectTyVarOnLhsOfInjCond
      TcRnUnknownTyVarsOnRhsOfInjCond
    
    Was introduced one helper type:
      RuleLhsErrReason
    
    - - - - -
    c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00
    Constraint simplification loop now depends on `ExpansionFuel`
    instead of a boolean flag for `CDictCan.cc_pend_sc`.
    Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1.
    This helps pending given constraints to keep up with pending wanted constraints in case of
    `UndecidableSuperClasses` and superclass expansions while simplifying the infered type.
    
    Adds 3 dynamic flags for controlling the fuels for each type of constraints
    `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints
    
    Fixes #21909
    Added Tests T21909, T21909b
    Added Note [Expanding Recursive Superclasses and ExpansionFuel]
    
    - - - - -
    a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00
    Documentation: describe laziness of several function from Data.List
    
    - - - - -
    fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00
    Add `Data.Functor.unzip`
    
    This function is currently present in `Data.List.NonEmpty`, but `Data.Functor`
    is a better home for it. This change was discussed and approved by the CLC
    at https://github.com/haskell/core-libraries-committee/issues/88.
    
    - - - - -
    2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00
    Fix documentation for traceWith and friends
    
    - - - - -
    f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00
    Remove utils/hpc subdirectory and its contents
    
    - - - - -
    cf98e286 by David Binder at 2023-03-08T01:24:17-05:00
    Add git submodule for utils/hpc
    
    - - - - -
    605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00
    Update commit for utils/hpc git submodule
    
    - - - - -
    606793d4 by David Binder at 2023-03-08T01:24:18-05:00
    Update commit for utils/hpc git submodule
    
    - - - - -
    4158722a by Sylvain Henry at 2023-03-08T01:24:58-05:00
    linker: fix linking with aligned sections (#23066)
    
    Take section alignment into account instead of assuming 16 bytes (which
    is wrong when the section requires 32 bytes, cf #23066).
    
    - - - - -
    1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00
    Change hostSupportsRPaths to report False on OpenBSD
    
    OpenBSD does support -rpath but ghc build process relies on some
    related features that don't work there. See ghc/ghc#23011
    
    - - - - -
    bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00
    bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args
    
    fixes #23068
    
    - - - - -
    321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts: Drop redundant prototype
    
    - - - - -
    abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Fix style
    
    - - - - -
    be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Deduplicate assertion
    
    - - - - -
    b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts: Fix type issues in Sparks.h
    
    Adds explicit casts to satisfy a C++ compiler.
    
    - - - - -
    da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts: Use release ordering when storing thread labels
    
    Since this makes the ByteArray# visible from other cores.
    
    - - - - -
    5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts/BlockAlloc: Allow disabling of internal assertions
    
    These can be quite expensive and it is sometimes useful to compile a
    DEBUG RTS without them.
    
    - - - - -
    6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts/Sanity: Mark pinned_object_blocks
    
    - - - - -
    9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00
    rts/Sanity: Look at nonmoving saved_filled lists
    
    - - - - -
    0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00
    Evac: Squash data race in eval_selector_chain
    
    - - - - -
    7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Clarify implementation
    
    This makes the intent of this implementation a bit clearer.
    
    - - - - -
    532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Clarify comment
    
    - - - - -
    bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Add missing no-op in busy-wait loop
    
    - - - - -
    c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Don't push empty arrays to update remembered set
    
    Previously the write barrier of resizeSmallArray# incorrectly handled
    resizing of zero-sized arrays, pushing an invalid pointer to the update
    remembered set.
    
    Fixes #22931.
    
    - - - - -
    92227b60 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Fix handling of weak pointers
    
    This fixes an interaction between aging and weak pointer handling which
    prevented the finalization of some weak pointers. In particular, weak
    pointers could have their keys incorrectly marked by the preparatory
    collector, preventing their finalization by the subsequent concurrent
    collection.
    
    While in the area, we also significantly improve the assertions
    regarding weak pointers.
    
    Fixes #22327.
    
    - - - - -
    ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Sanity check nonmoving large objects and compacts
    
    - - - - -
    71b038a1 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Sanity check mutable list
    
    Assert that entries in the nonmoving generation's generational
    remembered set (a.k.a. mutable list) live in nonmoving generation.
    
    - - - - -
    99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Don't show occupancy if we didn't collect live words
    
    - - - - -
    81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Fix tracking of FILLED_SWEEPING segments
    
    Previously we only updated the state of the segment at the head of each
    allocator's filled list.
    
    - - - - -
    58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Assert state of swept segments
    
    - - - - -
    2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Handle new closures in nonmovingIsNowAlive
    
    We must conservatively assume that new closures are reachable since we
    are not guaranteed to mark such blocks.
    
    - - - - -
    e4c3249f by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Don't clobber update rem sets of old capabilities
    
    Previously `storageAddCapabilities` (called by `setNumCapabilities`) would
    clobber the update remembered sets of existing capabilities when
    increasing the capability count. Fix this by only initializing the
    update remembered sets of the newly-created capabilities.
    
    Fixes #22927.
    
    - - - - -
    1b069671 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Add missing write barriers in selector optimisation
    
    This fixes the selector optimisation, adding a few write barriers which
    are necessary for soundness. See the inline comments for details.
    
    Fixes #22930.
    
    - - - - -
    d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Post-sweep sanity checking
    
    - - - - -
    0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00
    nonmoving: Avoid n_caps race
    
    - - - - -
    5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Don't push if nonmoving collector isn't enabled
    
    - - - - -
    0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Be more paranoid in segment tracking
    
    Previously we left various segment link pointers dangling. None of this
    wrong per se, but it did make it harder than necessary to debug.
    
    - - - - -
    7c817c0a by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Sync-phase mark budgeting
    
    Here we significantly improve the bound on sync phase pause times by
    imposing a limit on the amount of work that we can perform during the
    sync. If we find that we have exceeded our marking budget then we allow
    the mutators to resume, return to concurrent marking, and try
    synchronizing again later.
    
    Fixes #22929.
    
    - - - - -
    ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Allow pinned gen0 objects to be WEAK keys
    
    - - - - -
    78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Reenable assertion
    
    - - - - -
    b500867a by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Move current segment array into Capability
    
    The current segments are conceptually owned by the mutator, not the
    collector. Consequently, it was quite tricky to prove that the mutator
    would not race with the collect due to this shared state. It turns out
    that such races are possible: when resizing the current segment array
    we may concurrently try to take a heap census. This will attempt to walk
    the current segment array, causing a data race.
    
    Fix this by moving the current segment array into `Capability`, where it
    belongs.
    
    Fixes #22926.
    
    - - - - -
    56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Fix Note references
    
    Some references to Note [Deadlock detection under the non-moving
    collector] were missing an article.
    
    - - - - -
    4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts/Sanity: Fix block count assertion with non-moving collector
    
    The nonmoving collector does not use `oldest_gen->blocks` to track its
    block list. However, it nevertheless updates `oldest_gen->n_blocks` to
    ensure that its size is accounted for by the storage manager.
    Consequently, we must not attempt to assert consistency between the two.
    
    - - - - -
    96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Don't call prepareUnloadCheck
    
    When the nonmoving GC is in use we do not call `checkUnload` (since we
    don't unload code) and therefore should not call `prepareUnloadCheck`,
    lest we run into assertions.
    
    - - - - -
    6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Encapsulate block allocator spinlock
    
    This makes it a bit easier to add instrumentation on this spinlock
    while debugging.
    
    - - - - -
    e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00
    testsuite: Skip some tests when sanity checking is enabled
    
    - - - - -
    3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Fix unregisterised build
    
    - - - - -
    4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Ensure that sanity checker accounts for saved_filled segments
    
    - - - - -
    f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00
    hadrian: Add +boot_nonmoving_gc flavour transformer
    
    For using GHC bootstrapping to validate the non-moving GC.
    
    - - - - -
    581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00
    gitlab-ci: Add job bootstrapping with nonmoving GC
    
    - - - - -
    487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Move allocator into new source file
    
    - - - - -
    8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Split out nonmovingAllocateGC
    
    - - - - -
    662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00
    testsuite: Only run T22795* in the normal way
    
    It doesn't make sense to run these in multiple ways as they merely test
    whether `-threaded`/`-single-threaded` flags.
    
    - - - - -
    0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Rename clear_segment(_free_blocks)?
    
    To reflect the fact that these are to do with the nonmoving collector,
    now since they are exposed no longer static.
    
    - - - - -
    7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Fix incorrect STATIC_INLINE
    
    This should be INLINE_HEADER lest we get unused declaration warnings.
    
    - - - - -
    f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00
    testsuite: Mark ffi023 as broken due to #23089
    
    - - - - -
    a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00
    testsuite: Skip T7160 in the nonmoving way
    
    Finalization order is different under the nonmoving collector.
    
    - - - - -
    f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00
    rts: Capture GC configuration in a struct
    
    The number of distinct arguments passed to GarbageCollect was getting a
    bit out of hand.
    
    - - - - -
    ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00
    nonmoving: Non-concurrent collection
    
    - - - - -
    7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00
    hadrian: Fix flavour compiler stage options off-by-one error
    
    !9193 pointed out that ghcDebugAssertions was supposed to be a predicate
    on the stage of the built compiler, but in practice it was a predicate
    on the stage of the compiler used to build. Unfortunately, while it
    fixed that issue for ghcDebugAssertions, it documented every other
    similar option as behaving the same way when in fact they all used the
    old behavior.
    
    The new behavior of ghcDebugAssertions seems more intuitive, so this
    commit changes the interpretation of every other option to match. It
    also improves the enableProfiledGhc and debugGhc flavour transformers by
    making them more selective about which stages in which they build
    additional library/RTS ways.
    
    - - - - -
    f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00
    Delete created temporary subdirectories at end of session.
    
    This patch adds temporary subdirectories to the list of
    paths do clean up at the end of the GHC session. This
    fixes warnings about non-empty temporary directories.
    
    Fixes #22952
    
    - - - - -
    9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00
    Fixes #19627.
    
    Previously the solver failed with an unhelpful "solver reached too may iterations" error.
    With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up.
    
    This commit adds:
    * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel]
    * Test `typecheck/should_fail/T19627.hs` for regression purposes
    
    - - - - -
    ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00
    DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997)
    
    We should not panic in `add_demands` (now `set_lam_dmds`), because that code
    path is legimitely taken for OPAQUE PAP bindings, as in T22997.
    
    Fixes #22997.
    
    - - - - -
    5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00
    JS: remove dead code for old integer-gmp
    
    - - - - -
    bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00
    JS: Fix implementation of MK_JSVAL
    
    - - - - -
    ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00
    Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check
    
    There is no need to run arity analysis and what not if we are not in a
    Simplifier phase that eta-expands or if we don't want to eta-expand the
    expression in the first place.
    
    Purely a refactoring with the goal of improving compiler perf.
    
    - - - - -
    047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00
    JS: fix implementation of forceBool to use JS backend syntax
    
    - - - - -
    559a4804 by Sebastian Graf at 2023-03-13T07:31:23-04:00
    Simplifier: `countValArgs` should not count Type args (#23102)
    
    I observed miscompilations while working on !10088 caused by this.
    
    Fixes #23102.
    
    Metric Decrease:
        T10421
    
    - - - - -
    536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00
    Bump Win32 to 2.13.4.0
    
    Updates Win32 submodule
    
    - - - - -
    ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00
    ghc-bignum: Drop redundant include-dirs field
    - - - - -
    c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00
    Fix BCO creation setting caps when -j > -N
    
    * Remove calls to 'setNumCapabilities' in 'createBCOs'
    These calls exist to ensure that 'createBCOs' can benefit from
    parallelism. But this is not the right place to call
    `setNumCapabilities`. Furthermore the logic differs from that in the
    driver causing the capability count to be raised and lowered at each TH
    call if -j > -N.
    
    * Remove 'BCOOpts'
    No longer needed as it was only used to thread the job count down to `createBCOs`
    
    Resolves #23049
    
    - - - - -
    5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00
    Add changelog entry for #23049
    
    - - - - -
    6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00
    configure: Fix FIND_CXX_STD_LIB test on Darwin
    
    Annoyingly, Darwin's <cstddef> includes <version> and APFS is
    case-insensitive. Consequently, it will end up #including the
    `VERSION` file generated by the `configure` script on the second
    and subsequent runs of the `configure` script.
    
    See #23116.
    - - - - -
    19d6d039 by sheaf at 2023-03-16T21:31:22+01:00
    ghci: only keep the GlobalRdrEnv in ModInfo
    
    The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo,
    which includes a TypeEnv. This can easily cause space leaks as we
    have no way of forcing everything in a type environment.
    
    In GHC, we only use the GlobalRdrEnv, which we can force completely.
    So we only store that instead of a fully-fledged ModuleInfo.
    
    - - - - -
    73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00
    Add structured error messages for GHC.Tc.Utils.Backpack
    
    Tracking ticket: #20119
    
    MR: !10127
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    One occurrence, when handing a nested error from the interface loading
    machinery, was omitted. It will be handled by a subsequent changeset
    that addresses interface errors.
    
    - - - - -
    a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00
    Rename () into Unit, (,,...,,) into Tuple<n> (#21294)
    
    This patch implements a part of GHC Proposal #475.
    The key change is in GHC.Tuple.Prim:
    
      - data () = ()
      - data (a,b) = (a,b)
      - data (a,b,c) = (a,b,c)
      ...
      + data Unit = ()
      + data Tuple2 a b = (a,b)
      + data Tuple3 a b c = (a,b,c)
      ...
    
    And the rest of the patch makes sure that Unit and Tuple<n>
    are pretty-printed as () and (,,...,,) in various contexts.
    
    Updates the haddock submodule.
    
    Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com>
    
    - - - - -
    23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: fix some wrongs in the eventlog format documentation
    
    - - - - -
    90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: explain the BLOCK_MARKER event
    
    - - - - -
    ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: add BlockedOnMVarRead thread status in eventlog encodings
    
    - - - - -
    898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: add TASK_DELETE event in eventlog encodings
    
    - - - - -
    bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
    docs: add WALL_CLOCK_TIME event in eventlog encodings
    
    - - - - -
    eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00
    Add structured error messages for GHC.Tc.Utils.Env
    
    Tracking ticket: #20119
    
    MR: !10129
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00
    Document pdep / pext primops
    
    - - - - -
    e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00
    Allow LLVM backend to use HDoc for faster file generation.
    
    Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement.
    
    Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045)
    
    - - - - -
    ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00
    Compute LambdaFormInfo when using JavaScript backend.
    
    CmmCgInfos is needed to write interface files, but the
    JavaScript backend does not generate it, causing
    "Name without LFInfo" warnings.
    
    This patch adds a conservative but always correct
    CmmCgInfos when the JavaScript backend is used.
    
    Fixes #23053
    
    - - - - -
    926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00
    Be more careful about quantification
    
    This MR is driven by #23051. It does several things:
    
    * It is guided by the generalisation plan described in #20686.
      But it is still far from a complete implementation of that plan.
    
    * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind.
      This explains that we don't (yet, pending #20686) directly
      prevent generalising over escaping kinds.
    
    * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep
      and Multiplicity variables, beause we don't want to quantify over
      them.  We want to do the same for a Concrete tyvar, but there is
      nothing sensible to default it to (unless it has kind RuntimeRep,
      in which case it'll be caught by an earlier case). So we promote
      instead.
    
    * Pure refactoring in GHC.Tc.Solver:
      * Rename decideMonoTyVars to decidePromotedTyVars, since that's
        what it does.
    
      * Move the actual promotion of the tyvars-to-promote from
        `defaultTyVarsAndSimplify` to `decidePromotedTyVars`.  This is a
        no-op; just tidies up the code.  E.g then we don't need to
        return the promoted tyvars from `decidePromotedTyVars`.
    
      * A little refactoring in `defaultTyVarsAndSimplify`, but no
        change in behaviour.
    
    * When making a TauTv unification variable into a ConcreteTv
      (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name
      of the type variable.  This just improves error messages.
    
    * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole
    
    - - - - -
    0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00
    Testsuite: use appropriate predicate for ManyUbxSums test (#22576)
    
    - - - - -
    048c881e by romes at 2023-03-22T01:04:24-04:00
    fix: Incorrect @since annotations in GHC.TypeError
    
    Fixes #23128
    
    - - - - -
    a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00
    Testsuite: use req_interp predicate for T16318 (#22370)
    
    - - - - -
    ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00
    Testsuite: use req_interp predicate for T20214
    
    - - - - -
    e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00
    Refactor the constraint solver pipeline
    
    The big change is to put the entire type-equality solver into
    GHC.Tc.Solver.Equality, rather than scattering it over Canonical
    and Interact.  Other changes
    
    * EqCt becomes its own data type, a bit like QCInst.  This is
      great because EqualCtList is then just [EqCt]
    
    * New module GHC.Tc.Solver.Dict has come of the class-contraint
      solver.  In due course it will be all.  One step at a time.
    
    This MR is intended to have zero change in behaviour: it is a
    pure refactor.  It opens the way to subsequent tidying up, we
    believe.
    
    - - - - -
    cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00
    Add structured error messages for GHC.Tc.Utils.TcMType
    
    Tracking ticket: #20119
    
    MR: !10138
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00
    Testsuite: use js_skip for T2615 (#22374)
    
    - - - - -
    8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00
    Optimized Foldable methods for Data.Functor.Compose
    
    Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose
    
    Implementation of https://github.com/haskell/core-libraries-committee/issues/57
    
    - - - - -
    bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00
    Additional optimized versions
    
    - - - - -
    80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00
    Simplify minimum/maximum in instance Foldable (Compose f g)
    
    - - - - -
    8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00
    Update changelog to mention changes to instance Foldable (Compose f g)
    
    - - - - -
    e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00
    Add structured error messages for GHC.Tc.TyCl.PatSyn
    
    Tracking ticket: #20117
    
    MR: !10158
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00
    Allow WARNING pragmas to be controlled with custom categories
    
    Closes #17209. This implements GHC Proposal 541, allowing a WARNING
    pragma to be annotated with a category like so:
    
        {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-}
    
    The user can then enable, disable and set the severity of such warnings
    using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on.  There
    is a new warning group `-Wextended-warnings` containing all these warnings.
    Warnings without a category are treated as if the category was `deprecations`,
    and are (still) controlled by the flags `-Wdeprecations`
    and `-Wwarnings-deprecations`.
    
    Updates Haddock submodule.
    
    - - - - -
    0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00
    Move mention of warning groups change to 9.8.1 release notes
    
    - - - - -
    b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-04:00
    nativeGen/AArch64: Fix bitmask immediate predicate
    
    Previously the predicate for determining whether a logical instruction
    operand could be encoded as a bitmask immediate was far too
    conservative. This meant that, e.g., pointer untagged required five
    instructions whereas it should only require one.
    
    Fixes #23030.
    
    - - - - -
    46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00
    User's guide: Improve docs for -Wall
    
    previously it would list the warnings _not_ enabled by -Wall. That’s
    unnecessary round-about and was out of date. So let's just name
    the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`).
    
    - - - - -
    509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00
    codeGen/tsan: Disable instrumentation of unaligned stores
    
    There is some disagreement regarding the prototype of
    `__tsan_unaligned_write` (specifically whether it takes just the written
    address, or the address and the value as an argument). Moreover, I have
    observed crashes which appear to be due to it. Disable instrumentation
    of unaligned stores as a temporary mitigation.
    
    Fixes #23096.
    
    - - - - -
    6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00
    base: Document GHC versions associated with past base versions in the changelog
    
    - - - - -
    43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00
    Add regression test for #17574
    
    This test currently fails in the nonmoving way
    
    - - - - -
    f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-04:00
    fix: account for large and compact object stats with nonmoving gc
    
    Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap.
    We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap.
    
    Resolves #17574
    
    - - - - -
    7131b705 by David Feuer at 2023-03-25T00:04:04-04:00
    Modify ThreadId documentation and comments
    
    For a long time, `GHC.Conc.Sync` has said
    
    ```haskell
    -- ToDo: data ThreadId = ThreadId (Weak ThreadId#)
    -- But since ThreadId# is unlifted, the Weak type must use open
    -- type variables.
    ```
    
    We are now actually capable of using `Weak# ThreadId#`, but the
    world has moved on. To support the `Show` and `Ord` instances, we'd
    need to store the thread ID number in the `ThreadId`. And it seems
    very difficult to continue to support `threadStatus` in that regime,
    since it needs to be able to explain how threads died. In addition,
    garbage collection of weak references can be quite expensive, and it
    would be hard to evaluate the cost over he whole ecosystem. As discussed
    in
    [this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125),
    it doesn't seem very likely that we'll actually switch to weak
    references here.
    
    - - - - -
    c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00
    rts: Fix barriers of IND and IND_STATIC
    
    Previously IND and IND_STATIC lacked the acquire barriers enjoyed by
    BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers],
    this barrier is critical to ensure that the indirectee is visible to the
    entering core.
    
    Fixes #22872.
    
    - - - - -
    62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00
    Improve documentation of atomicModifyMutVar2#
    
    - - - - -
    b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00
    rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023
    
    This patch does a few things:
    
    - Add the missing RtsSymbols.c entry of performBlockingMajorGC
    - Make hs_perform_gc call performBlockingMajorGC, which restores
      previous behavior
    - Use hs_perform_gc in ffi023
    - Remove rts_clearMemory() call in ffi023, it now works again in some
      test ways previously marked as broken. Fixes #23089
    
    - - - - -
    d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00
    testsuite: add the rts_clearMemory test case
    
    This patch adds a standalone test case for rts_clearMemory that mimics
    how it's typically used by wasm backend users and ensures this RTS API
    isn't broken by future RTS refactorings. Fixes #23901.
    
    - - - - -
    80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00
    Improve documentation for resizing of byte arrays
    
    - - - - -
    c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00
    rts: Don't rely on EXTERN_INLINE for slop-zeroing logic
    
    Previously we relied on calling EXTERN_INLINE functions defined in
    ClosureMacros.h from Cmm to zero slop. However, as far as I can tell,
    this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted
    in each compilation unit.
    
    Fix this by explicitly declaring a new set of non-inline functions in
    ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h
    definitions as INLINE_HEADER.
    
    In the future we should try to eliminate EXTERN_INLINE.
    
    - - - - -
    c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00
    rts: Fix capability-count check in zeroSlop
    
    Previously `zeroSlop` examined `RtsFlags` to determine whether the
    program was single-threaded. This is wrong; a program may be started
    with `+RTS -N1` yet the process may later increase the capability count
    with `setNumCapabilities`. This lead to quite subtle and rare crashes.
    
    Fixes #23088.
    
    - - - - -
    656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00
    Add Eq/Ord instances for SSymbol, SChar, and SNat
    
    This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148).
    
    - - - - -
    4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00
    Update and expand atomic modification Haddocks
    
    * The documentation for `atomicModifyIORef` and `atomicModifyIORef'`
      were incomplete, and the documentation for `atomicModifyIORef` was
      out of date. Update and expand.
    
    * Remove a useless lazy pattern match in the definition of
      `atomicModifyIORef`. The pair it claims to match lazily
      was already forced by `atomicModifyIORef2`.
    
    - - - - -
    e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00
    Document the constructor name for lists
    
    Derived `Data` instances use raw infix constructor names when applicable.
    The `Data.Data [a]` instance, if derived, would have a constructor name
    of `":"`. However, it actually uses constructor name `"(:)"`. Document this
    peculiarity.
    
    See https://github.com/haskell/core-libraries-committee/issues/147
    
    - - - - -
    c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00
    Make exprIsConApp_maybe a bit cleverer
    
    Addresses #23159.
    
    See Note Note [Exploit occ-info in exprIsConApp_maybe]
    in GHC.Core.SimpleOpt.
    
    Compile times go down very slightly, but always go down,
    never up.  Good!
    
    Metrics: compile_time/bytes allocated
    ------------------------------------------------
     CoOpt_Singletons(normal)   -1.8%
               T15703(normal)   -1.2% GOOD
    
                    geo. mean   -0.1%
                    minimum     -1.8%
                    maximum     +0.0%
    
    Metric Decrease:
        CoOpt_Singletons
        T15703
    
    - - - - -
    76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00
    Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat
    
    This implements
    [CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149).
    
    - - - - -
    3f374399 by sheaf at 2023-03-29T13:57:33+02:00
    Handle records in the renamer
    
    This patch moves the field-based logic for disambiguating record updates
    to the renamer. The type-directed logic, scheduled for removal, remains
    in the typechecker.
    
    To do this properly (and fix the myriad of bugs surrounding the treatment
    of duplicate record fields), we took the following main steps:
    
      1. Create GREInfo, a renamer-level equivalent to TyThing which stores
         information pertinent to the renamer.
         This allows us to uniformly treat imported and local Names in the
         renamer, as described in Note [GREInfo].
    
      2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which
         distinguished between normal names and field names, we now store
         simple Names in GlobalRdrElt, along with the new GREInfo information
         which allows us to recover the FieldLabel for record fields.
    
      3. Add namespacing for record fields, within the OccNames themselves.
         This allows us to remove the mangling of duplicate field selectors.
    
         This change ensures we don't print mangled names to the user in
         error messages, and allows us to handle duplicate record fields
         in Template Haskell.
    
      4. Move record disambiguation to the renamer, and operate on the
         level of data constructors instead, to handle #21443.
    
         The error message text for ambiguous record updates has also been
         changed to reflect that type-directed disambiguation is on the way
         out.
    
    (3) means that OccEnv is now a bit more complex: we first key on the
    textual name, which gives an inner map keyed on NameSpace:
    
      OccEnv a ~ FastStringEnv (UniqFM NameSpace a)
    
    Note that this change, along with (2), both increase the memory residency
    of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to
    regress somewhat in compile-time allocation.
    
    Even though (3) simplified a lot of code (in particular the treatment of
    field selectors within Template Haskell and in error messages), it came
    with one important wrinkle: in the situation of
    
      -- M.hs-boot
      module M where { data A; foo :: A -> Int }
      -- M.hs
      module M where { data A = MkA { foo :: Int } }
    
    we have that M.hs-boot exports a variable foo, which is supposed to match
    with the record field foo that M exports. To solve this issue, we add a
    new impedance-matching binding to M
    
      foo{var} = foo{fld}
    
    This mimics the logic that existed already for impedance-binding DFunIds,
    but getting it right was a bit tricky.
    See Note [Record field impedance matching] in GHC.Tc.Module.
    
    We also needed to be careful to avoid introducing space leaks in GHCi.
    So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in
    ModIface. This means stubbing out all the GREInfo fields, with the
    function forceGlobalRdrEnv.
    When we read it back in, we rehydrate with rehydrateGlobalRdrEnv.
    This robustly avoids any space leaks caused by retaining old type
    environments.
    
    Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063
    
    Updates haddock submodule
    
    -------------------------
    Metric Increase:
        MultiComponentModules
        MultiLayerModules
        MultiLayerModulesDefsGhci
        MultiLayerModulesNoCode
        T13701
        T14697
        hard_hole_fits
    -------------------------
    
    - - - - -
    4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00
    Avoid repeatedly shadowing in shadowNames
    
    This commit refactors GHC.Type.Name.Reader.shadowNames to first
    accumulate all the shadowing arising from the introduction of a new
    set of GREs, and then applies all the shadowing to the old GlobalRdrEnv
    in one go.
    
    - - - - -
    d246049c by sheaf at 2023-03-29T13:57:34+02:00
    igre_prompt_env: discard "only-qualified" names
    
    We were unnecessarily carrying around names only available qualified
    in igre_prompt_env, violating the icReaderEnv invariant.
    We now get rid of these, as they aren't needed for the shadowing
    computation that igre_prompt_env exists for.
    
    Fixes #23177
    
    -------------------------
    Metric Decrease:
        T14052
        T14052Type
    -------------------------
    
    - - - - -
    41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00
    hadrian: Fix path to HpcParser.y
    
    The source for this project has been moved into a src/ folder so we also
    need to update this path.
    
    Fixes #23187
    
    - - - - -
    b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00
    js: split JMacro into JS eDSL and JS syntax
    
    This commit:
    
    Splits JExpr and JStat into two nearly identical DSLs:
    - GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a
    value cannot be unsaturated, or, a value of this DSL is a witness that a
    value of GHC.JS.Unsat has been saturated
    - GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation.
    
    Then all binary and outputable instances are changed to use
    GHC.JS.Syntax.
    
    This moves us closer to closing out #22736 and #22352. See #22736 for
    roadmap.
    
    -------------------------
    Metric Increase:
        CoOpt_Read
        LargeRecord
        ManyAlternatives
        PmSeriesS
        PmSeriesT
        PmSeriesV
        T10421
        T10858
        T11195
        T11374
        T11822
        T12227
        T12707
        T13035
        T13253
        T13253-spj
        T13379
        T14683
        T15164
        T15703
        T16577
        T17096
        T17516
        T17836
        T18140
        T18282
        T18304
        T18478
        T18698a
        T18698b
        T18923
        T1969
        T19695
        T20049
        T21839c
        T3064
        T4801
        T5321FD
        T5321Fun
        T5631
        T5642
        T783
        T9198
        T9233
        T9630
        TcPlugin_RewritePerf
        WWRec
    -------------------------
    
    - - - - -
    f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00
    ghc-heap: remove wrong Addr# coercion (#23181)
    
    Conversion from Addr# to I# isn't correct with the JS backend.
    
    Also used the opportunity to reenable 64-bit Word/Int tests
    
    - - - - -
    a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00
    testsuite: Fix racing prints in T21465
    
    As noted in #23155, we previously failed to add flushes necessary to
    ensure predictable output.
    
    Fixes #23155.
    
    - - - - -
    98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00
    Revert "ghc-heap: remove wrong Addr# coercion (#23181)"
    
    This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02.
    
    This fails to build with GHC-9.2 as a boot compiler.
    
    See #23195 for tracking this issue.
    
    - - - - -
    61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
    Add {-# WARNING #-} to Data.List.{head,tail}
    
    - - - - -
    8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
    Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-}
    
    - - - - -
    7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
    Bump submodules
    
    - - - - -
    d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
    Fix tests
    
    - - - - -
    3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00
    Proxies for head and tail: review suggestions
    - - - - -
    930edcfd by sheaf at 2023-03-30T14:36:33-04:00
    docs: move RecordUpd changelog entry to 9.8
    
    This was accidentally included in the 9.6 changelog
    instead of the 9.6 changelog.
    - - - - -
    6f885e65 by sheaf at 2023-03-30T14:37:09-04:00
    Add LANGUAGE GADTs to GHC.Rename.Env
    
    We need to enable this extension for the file to compile with ghc 9.2,
    as we are pattern matching on a GADT and this required the GADT extension
    to be enabled until 9.4.
    - - - - -
    6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: make lint-ci-config job fast again
    
    We don't pin our nixpkgs revision and tracks the default
    nixpkgs-unstable channel anyway. Instead of using
    haskell.packages.ghc924, we should be using haskell.packages.ghc92 to
    maximize the binary cache hit rate and make lint-ci-config job fast
    again. Also bumps the nix docker image to the latest revision.
    
    - - - - -
    ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: ensure that all non-i386 pipelines do parallel xz compression
    
    We can safely enable parallel xz compression for non-i386 pipelines.
    However, previously we didn't export XZ_OPT, so the xz process won't
    see it if XZ_OPT hasn't already been set in the current job.
    
    - - - - -
    20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: unset CROSS_EMULATOR for js job
    
    - - - - -
    4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: fix lint-testsuite job
    
    The list_broken make target will transitively depend on the
    calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It
    really should be TEST_HC since that's what get passed in the gitlab CI
    config.
    
    - - - - -
    cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00
    ci: use alpine3_17-wasm image for wasm jobs
    
    Bump the ci-images dependency and use the new alpine3_17-wasm docker
    image for wasm jobs.
    
    - - - - -
    79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00
    testsuite/driver: Add basic support for testing cross-compilers
    
    - - - - -
    e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00
    testsuite/driver: Normalize away differences in ghc executable name
    
    - - - - -
    ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00
    hadrian: Pass CROSS_EMULATOR to runtests.py
    
    - - - - -
    30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: don't add optllvm way for wasm32
    
    - - - - -
    f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: normalize the .wasm extension
    
    - - - - -
    a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: strip the cross ghc prefix in output and error message
    
    - - - - -
    f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: handle target executable extension
    
    - - - - -
    8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: mypy typing error fixes
    
    This patch fixes some mypy typing errors which weren't caught in
    previous linting jobs.
    
    - - - - -
    0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: use context variable instead of thread-local variable
    
    This patch changes a thread-local variable to context variable
    instead, which works as intended when the testsuite transitions to use
    asyncio & coroutines instead of multi-threading to concurrently run
    test cases. Note that this also raises the minimum Python version to
    3.7.
    
    - - - - -
    ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00
    testsuite: asyncify the testsuite driver
    
    This patch refactors the testsuite driver, gets rid of multi-threading
    logic for running test cases concurrently, and uses asyncio &
    coroutines instead. This is not yak shaving for its own sake; the
    previous multi-threading logic is prone to livelock/deadlock
    conditions for some reason, even if the total number of threads is
    bounded to a thread pool's capacity.
    
    The asyncify change is an internal implementation detail of the
    testsuite driver and does not impact most GHC maintainers out there.
    The patch does not touch the .T files, test cases can be
    added/modified the exact same way as before.
    
    - - - - -
    0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00
    Add test for T23184
    
    There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch:
    
    ```
    commit 6656f0165a30fc2a22208532ba384fc8e2f11b46
    Author: Simon Peyton Jones <simonpj at microsoft.com>
    Date:   Fri Jul 23 23:57:01 2021 +0100
    
        A bunch of changes related to eta reduction
    
        This is a large collection of changes all relating to eta
        reduction, originally triggered by #18993, but there followed
        a long saga.
    
        Specifics:
    
    ...lots of lines omitted...
    
        Other incidental changes
    
        * Fix a fairly long-standing outright bug in the ApplyToVal case of
          GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the
          tail of 'dmds' in the recursive call, which meant the demands were All
          Wrong.  I have no idea why this has not caused problems before now.
    ```
    
    Note this "Fix a fairly longstanding outright bug".   This is the specific fix
    ```
    @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds
             --              let a = ...arg...
             --              in [...hole...] a
             -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable
    -    do  { let (dmd:_) = dmds   -- Never fails
    -        ; (floats1, cont') <- mkDupableContWithDmds env dmds cont
    +    do  { let (dmd:cont_dmds) = dmds   -- Never fails
    +        ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont
             ; let env' = env `setInScopeFromF` floats1
             ; (_, se', arg') <- simplArg env' dup se arg
             ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg'
    ```
    Ticket #23184 is a report of the bug that this diff fixes.
    
    - - - - -
    62d25071 by mangoiv at 2023-04-01T04:20:01-04:00
    [feat] make ($) representation polymorphic
    - this change was approved by the CLC in [1] following a CLC proposal [2]
    - make ($) representation polymorphic (adjust the type signature)
    - change ($) implementation to allow additional polymorphism
    - adjust the haddock of ($) to reflect these changes
    - add additional documentation to document these changes
    - add changelog entry
    - adjust tests (move now succeeding tests and adjust stdout of some
      tests)
    
    [1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854
    [2] https://github.com/haskell/core-libraries-committee/issues/132
    
    - - - - -
    77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00
    User Guide: update copyright year: 2020->2023
    
    - - - - -
    3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00
    driver: Unit State Data.Map -> GHC.Unique.UniqMap
    
    In pursuit of #22426. The driver and unit state are major contributors.
    
    This commit also bumps the haddock submodule to reflect the API changes in
    UniqMap.
    
    -------------------------
    Metric Decrease:
        MultiComponentModules
        MultiComponentModulesRecomp
        T10421
        T10547
        T12150
        T12234
        T12425
        T13035
        T16875
        T18140
        T18304
        T18698a
        T18698b
        T18923
        T20049
        T5837
        T6048
        T9198
    -------------------------
    
    - - - - -
    a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00
    Add structured error messages for GHC.Tc.TyCl
    
    Tracking ticket: #20117
    
    MR: !10183
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00
    JS: Linker: use saturated JExpr
    
    Follow on to MR!10142 in pursuit of #22736
    
    - - - - -
    3da69346 by sheaf at 2023-04-01T18:28:37-04:00
    Improve haddocks of template-haskell Con datatype
    
    This adds a bit more information, in particular about the lists of
    constructors in the GadtC and RecGadtC cases.
    
    - - - - -
    3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00
    TH: revert changes to GadtC & RecGadtC
    
    Commit 3f374399 included a breaking-change to the template-haskell
    library when it made the GadtC and RecGadtC constructors take non-empty
    lists of names. As this has the potential to break many users' packages,
    we decided to revert these changes for now.
    
    - - - - -
    f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00
    Rework documentation for data Char
    
    - - - - -
    43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00
    cmm: implement parsing of MO_AtomicRMW from hand-written CMM files
    
    Fixes #23206
    
    - - - - -
    ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00
    ghc-heap: remove wrong Addr# coercion (#23181)
    
    Conversion from Addr# to I# isn't correct with the JS backend.
    
    - - - - -
    2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00
    hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1
    
    Also fixes the ./generate_bootstrap_plans script which was recently
    broken
    
    We can hopefully drop the 9.2 plans soon but they still work so kept
    them around for now.
    
    - - - - -
    c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00
    ci: Add job to test 9.6 bootstrapping
    
    - - - - -
    53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00
    hadrian: Improve option parsing
    
    Several options in Hadrian had their argument marked as optional
    (`OptArg`), but if the argument wasn't there they were just giving an
    error. It's more idiomatic to mark the argument as required instead;
    the code uses less Maybes, the parser can enforce that the argument
    is present, --help gives better output.
    
    - - - - -
    a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00
    JS: fix issues with FD api support
    
    - Add missing implementations for fcntl_read/write/lock
    - Fix fdGetMode
    
    These were found while implementing TH in !9779. These functions must be
    used somehow by the external interpreter code.
    
    - - - - -
    8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00
    Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage
    
    I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType
    module into a proper TcRnMessage.
    Instead, these TcRnMessage messages were introduced:
    
    TcRnDataKindsError
    TcRnUnusedQuantifiedTypeVar
    TcRnIllegalKindSignature
    TcRnUnexpectedPatSigType
    TcRnSectionPrecedenceError
    TcRnPrecedenceParsingError
    TcRnIllegalKind
    TcRnNegativeNumTypeLiteral
    TcRnUnexpectedKindVar
    TcRnBindMultipleVariables
    TcRnBindVarAlreadyInScope
    
    - - - - -
    220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00
    Fixes around unsafeCoerce#
    
    1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul
    in 74ad75e87317, `unsafeCoerce#` is no longer defined there.
    I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module.
    
    2. The documentation of `unsafeCoerce#` stated that you should not
    cast a function to an algebraic type, even if you later cast it back
    before applying it. But ghci was doing that type of cast, as can be seen
    with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any
    following the documentation.
    
    - - - - -
    9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00
    Add a few more memcpy-ish primops
    
    * copyMutableByteArrayNonOverlapping#
    * copyAddrToAddr#
    * copyAddrToAddrNonOverlapping#
    * setAddrRange#
    
    The implementations of copyBytes, moveBytes, and fillBytes
    in base:Foreign.Marshal.Utils now use these new primops,
    which can cause us to work a bit harder generating code for them,
    resulting in the metric increase in T21839c observed by CI on
    some architectures.  But in exchange, we get better code!
    
    Metric Increase:
        T21839c
    
    - - - - -
    f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00
    StgToCmm: Upgrade -fcheck-prim-bounds behavior
    
    Fixes #21054. Additionally, we can now check for range overlap
    when generating Cmm for primops that use memcpy internally.
    
    - - - - -
    cd00e321 by sheaf at 2023-04-04T01:04:50-04:00
    Relax assertion in varToRecFieldOcc
    
    When using Template Haskell, it is possible to re-parent a field OccName
    belonging to one data constructor to another data constructor. The
    lsp-types package did this in order to "extend" a data constructor
    with additional fields.
    
    This ran into an assertion in 'varToRecFieldOcc'. This assertion
    can simply be relaxed, as the resulting splices are perfectly sound.
    
    Fixes #23220
    
    - - - - -
    eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00
    GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201)
    
    - - - - -
    071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00
    Make INLINE pragmas for pattern synonyms work with TH
    
    Previously, the code for converting `INLINE <name>` pragmas from TH splices
    used `vNameN`, which assumed that `<name>` must live in the variable namespace.
    Pattern synonyms, on the other hand, live in the constructor namespace. I've
    fixed the issue by switching to `vcNameN` instead, which works for both the
    variable and constructor namespaces.
    
    Fixes #23203.
    
    - - - - -
    7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-04:00
    Fix unification with oversaturated type families
    
    unify_ty was incorrectly saying that F x y ~ T x are surely apart,
    where F x y is an oversaturated type family and T x is a tyconapp.
    As a result, the simplifier dropped a live case alternative (#23134).
    
    - - - - -
    c165f079 by sheaf at 2023-04-04T17:13:40-04:00
    Add testcase for #23192
    
    This issue around solving of constraints arising from superclass
    expansion using other constraints also borned from superclass expansion
    was the topic of commit aed1974e. That commit made sure we don't emit
    a "redundant constraint" warning in a situation in which removing the
    constraint would cause errors.
    
    Fixes #23192
    
    - - - - -
    d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-04:00
    nonmoving: Disable slop-zeroing
    
    As noted in #23170, the nonmoving GC can race with a mutator zeroing the
    slop of an updated thunk (in much the same way that two mutators would
    race). Consequently, we must disable slop-zeroing when the nonmoving GC
    is in use.
    
    Closes #23170
    
    - - - - -
    04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00
    Fix reverse flag for -Wunsupported-llvm-version
    - - - - -
    0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00
    Add release note for GHC.Unicode refactor in base-4.18.
    
    Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in
    base-4.18 and add proper release date.
    
    - - - - -
    cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00
    Improve documentation for ($) (#22963)
    
    - - - - -
    5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00
    Remove trailing whitespace from ($) commentary
    
    - - - - -
    b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00
    Adjust wording wrt representation polymorphism of ($)
    - - - - -
    6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00
    Add structured error messages for GHC.Tc.TyCl.Utils
    
    Tracking ticket: #20117
    
    MR: !10251
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00
    Renamer: don't call addUsedGRE on an exact Name
    
    When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc,
    we could end up calling addUsedGRE on an exact Name, which would then
    lead to a panic in the bestImport function: it would be incapable of
    processing a GRE which is not local but also not brought into scope
    by any imports (as it is referred to by its unique instead).
    
    Fixes #23240
    
    - - - - -
    bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00
    Add support for -debug in the testsuite
    
    Confusingly, GhcDebugged referred to GhcDebugAssertions.
    
    - - - - -
    b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00
    Add missing cases in -Di prettyprinter
    
    Fixes #23142
    
    - - - - -
    6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00
    compiler: make WasmCodeGenM an instance of MonadUnique
    
    - - - - -
    05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00
    compiler: apply cmm node-splitting for wasm backend
    
    This patch applies cmm node-splitting for wasm32 NCG, which is
    required when handling irreducible CFGs. Fixes #23237.
    
    - - - - -
    f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00
    Set base 'maintainer' field to CLC
    
    - - - - -
    ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00
    Clarify a couple of Notes about 'nospec'
    
    - - - - -
    ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00
    Allow generation of TTH syntax with TH
    
    In other words allow generation of typed splices and brackets with
    Untyped Template Haskell.
    
    That is useful in cases where a library is build with TTH in mind,
    but we still want to generate some auxiliary declarations,
    where TTH cannot help us, but untyped TH can.
    Such example is e.g. `staged-sop` which works with TTH,
    but we would like to derive `Generic` declarations with TH.
    
    An alternative approach is to use `unsafeCodeCoerce`, but then the
    derived `Generic` instances would be type-checked only at use sites,
    i.e. much later. Also `-ddump-splices` output is quite ugly:
    user-written instances would use TTH brackets, not `unsafeCodeCoerce`.
    
    This commit doesn't allow generating of untyped template splices
    and brackets with untyped TH, as I don't know why one would want to do
    that (instead of merging the splices, e.g.)
    
    - - - - -
    690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00
    Add regression test for #23229
    
    - - - - -
    59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00
    Add quotRem rules (#22152)
    
      case quotRemInt# x y of
         (# q, _ #) -> body
      ====>
       case quotInt# x y of
         q -> body
    
      case quotRemInt# x y of
         (# _, r #) -> body
      ====>
       case remInt# x y of
         r -> body
    
    - - - - -
    4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00
    Add quot folding rule (#22152)
    
       (x / l1) / l2
       l1 and l2 /= 0
       l1*l2 doesn't overflow
       ==> x / (l1 * l2)
    
    - - - - -
    1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00
    Make Int64/Word64 division ok for speculation too.
    
    Only when the divisor is definitely non-zero.
    
    - - - - -
    8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00
    Make WordQuotRem2Op ok-for-speculation too
    
    - - - - -
    27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00
    Base/JS: GHC.JS.Foreign.Callback module (issue 23126)
    
    * Add the Callback module for "exporting" Haskell functions
    to be available to plain JavaScript code
    
    * Fix some primitives defined in GHC.JS.Prim
    
    * Add a JavaScript section to the user guide with instructions
    on how to use the JavaScript FFI, building up to using Callbacks
    to interact with the browser
    
    * Add tests for the JavaScript FFI and Callbacks
    
    - - - - -
    a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00
    rts: improve memory ordering and add some comments in the StablePtr implementation
    
    - - - - -
    d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-04:00
    docs: Generate docs/index.html with version number
    
    * Generate docs/index.html to include the version of the ghc library
    
    * This also fixes the packageVersions interpolations which were
      - Missing an interpolation for `LIBRARY_ghc_VERSION`
      - Double quoting the version so that "9.7" was being inserted.
    
    Fixes #23121
    
    - - - - -
    d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00
    Stop if type constructors have kind errors
    
    Otherwise we get knock-on errors, such as #23252.
    
    This makes GHC fail a bit sooner, and I have not attempted to add
    recovery code, to add a fake TyCon place of the erroneous one,
    in an attempt to get more type errors in one pass.  We could
    do that (perhaps) if there was a call for it.
    
    - - - - -
    2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
    Major refactor in the handling of equality constraints
    
    This MR substantially refactors the way in which the constraint
    solver deals with equality constraints.  The big thing is:
    
    * Intead of a pipeline in which we /first/ canonicalise and /then/
      interact (the latter including performing unification) the two steps
      are more closely integreated into one.  That avoids the current
      rather indirect communication between the two steps.
    
    The proximate cause for this refactoring is fixing #22194, which involve
    solving   [W] alpha[2] ~ Maybe (F beta[4])
    by doing this:
              alpha[2] := Maybe delta[2]
              [W] delta[2] ~ F beta[4]
    That is, we don't promote beta[4]!  This is very like introducing a cycle
    breaker, and was very awkward to do before, but now it is all nice.
    See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and
    Note [Family applications in canonical constraints].
    
    The big change is this:
    
    * Several canonicalisation checks (occurs-check, cycle-breaking,
      checking for concreteness) are combined into one new function:
         GHC.Tc.Utils.Unify.checkTyEqRhs
    
      This function is controlled by `TyEqFlags`, which says what to do
      for foralls, type families etc.
    
    * `canEqCanLHSFinish` now sees if unification is possible, and if so,
      actually does it: see `canEqCanLHSFinish_try_unification`.
    
    There are loads of smaller changes:
    
    * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a
      cheap-and-cheerful version of `checkTyEqRhs`, called
      `simpleUnifyCheck`.  If `simpleUnifyCheck` succeeds, it can unify,
      otherwise it defers by emitting a constraint. This is simpler than
      before.
    
    * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`.
      Especially the nasty stuff involving `swap_for_occurs` and
      `canEqTyVarFunEq`.  Much nicer now.  See
          Note [Orienting TyVarLHS/TyFamLHS]
          Note [Orienting TyFamLHS/TyFamLHS]
    
    * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the
      problems that can be discovered by `checkTyEqRhs`.
    
    * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to
      to accept both cases in #22194 rather than rejecting both.
    
    Yet smaller:
    
    * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`)
      to reduce the need for synonym expansion when checking concreteness.
      Use it in `isConcreteType`.
    
    * Renamed `isConcrete` to `isConcreteType`
    
    * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient
      way to find if a particular type variable is used injectively than
      finding all the injective variables.  It is called in
      `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a
      lot.
    
    * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the
      constraint solver.
    
    Fixes #22194, #23199
    
    Compile times decrease by an average of 0.1%; but there is a 7.4%
    drop in compiler allocation on T15703.
    
    Metric Decrease:
        T15703
    
    - - - - -
    99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
    Add some documentation about redundant constraints
    
    - - - - -
    3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
    Improve partial signatures
    
    This MR fixes #23223. The changes are in two places:
    
    * GHC.Tc.Bind.checkMonomorphismRestriction
      See the new `Note [When the MR applies]`
      We now no longer stupidly attempt to apply the MR when the user
      specifies a context, e.g.   f :: Eq a => _ -> _
    
    * GHC.Tc.Solver.decideQuantification
      See rewritten `Note [Constraints in partial type signatures]`
    
    Fixing this bug apparently breaks three tests:
    
    * partial-sigs/should_compile/T11192
    * partial-sigs/should_fail/Defaulting1MROff
    * partial-sigs/should_fail/T11122
    
    However they are all symptoms of #23232, so I'm marking them as
    expect_broken(23232).
    
    I feel happy about this MR. Nice.
    
    - - - - -
    23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
    Make approximateWC a bit cleverer
    
    This MR fixes #23224: making approximateWC more clever
    
    See the long `Note [ApproximateWC]` in GHC.Tc.Solver
    
    All this is delicate and ad-hoc -- but it /has/ to be: we are
    talking about inferring a type for a binding in the presence of
    GADTs, type families and whatnot: known difficult territory.
    We just try as hard as we can.
    
    - - - - -
    2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00
    docs: Update template-haskell docs to use Code Q a rather than Q (TExp a)
    
    Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a
    rather than Q (TExp a). The documentation in the `template-haskell`
    library wasn't updated to reflect this change.
    
    Fixes #23148
    
    - - - - -
    0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00
    Show an error when we cannot default a concrete tyvar
    
    Fixes #23153
    
    - - - - -
    bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00
    Handle ConcreteTvs in inferResultToType
    
    inferResultToType was discarding the ir_frr information, which meant
    some metavariables ended up being MetaTvs instead of ConcreteTvs.
    
    This function now creates new ConcreteTvs as necessary, instead of
    always creating MetaTvs.
    
    Fixes #23154
    
    - - - - -
    3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-04:00
    Transfer DFunId_ness onto specialised bindings
    
    Whether a binding is a DFunId or not has consequences for the `-fdicts-strict`
    flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does
    not apply because the constraint solver can create recursive groups of dictionaries.
    
    In #22549 this was fixed for the "normal" case, see
    Note [Do not strictify the argument dictionaries of a dfun].
    However the loop still existed if the DFunId was being specialised.
    
    The problem was that the specialiser would specialise a DFunId and
    turn it into a VanillaId and so the demand analyser didn't know to
    apply special treatment to the binding anymore and the whole recursive
    group was optimised to bottom.
    
    The solution is to transfer over the DFunId-ness of the binding in the specialiser so
    that the demand analyser knows not to apply the `-fstrict-dicts`.
    
    Fixes #22549
    
    - - - - -
    a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00
    Add import lists to few GHC.Driver.Session imports
    
    Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261.
    There are a lot of GHC.Driver.Session which only use DynFlags,
    but not the parsing code.
    
    - - - - -
    51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00
    Account for special GHC.Prim import in warnUnusedPackages
    
    The GHC.Prim import is treated quite specially primarily because there
    isn't an interface file for GHC.Prim. Therefore we record separately in
    the ModSummary if it's imported or not so we don't go looking for it.
    
    This logic hasn't made it's way to `-Wunused-packages` so if you
    imported GHC.Prim then the warning would complain you didn't use
    `-package ghc-prim`.
    
    Fixes #23212
    
    - - - - -
    1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00
    Add regression test for #23199
    
    - - - - -
    0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00
    validDerivPred: Reject exotic constraints in IrredPreds
    
    This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as
    described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely,
    we should reject `IrredPred`s that are inferred from `deriving` clauses whose
    arguments contain other type constructors, as described in `(VD2) Reject exotic
    constraints` of that Note.  This has the nice property that `deriving` clauses
    whose inferred instance context mention `TypeError` will now emit the type
    error in the resulting error message, which better matches existing intuitions
    about how `TypeError` should work.
    
    While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]`
    was duplicated in a separate `Note [Exotic derived instance contexts]` in
    `GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that
    there is a single authority on describing the conditions under which an
    inferred `deriving` constraint can be considered valid.
    
    This changes the behavior of `deriving` in a way that existing code might
    break, so I have made a mention of this in the GHC User's Guide. It seems very,
    very unlikely that much code is relying on this strange behavior, however, and
    even if there is, there is a clear, backwards-compatible migration path using
    `StandaloneDeriving`.
    
    Fixes #22696.
    
    - - - - -
    10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00
    Misc cleanup
    
    - Use dedicated list functions
    - Make cloneBndrs and cloneRecIdBndrs monadic
    - Fix invalid haddock comments in libraries/base
    
    - - - - -
    5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00
    Convert interface file loading errors into proper diagnostics
    
    This patch converts all the errors to do with loading interface files
    into proper structured diagnostics.
    
    * DriverMessage: Sometimes in the driver we attempt to load an interface
      file so we embed the IfaceMessage into the DriverMessage.
    * TcRnMessage: Most the time we are loading interface files during
      typechecking, so we embed the IfaceMessage
    
    This patch also removes the TcRnInterfaceLookupError constructor which
    is superceded by the IfaceMessage, which is now structured compared to
    just storing an SDoc before.
    
    - - - - -
    df1a5811 by sheaf at 2023-04-18T10:31:43-04:00
    Don't panic in ltPatersonSize
    
    The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it
    encountered a type family on the RHS, as usually these are not allowed
    (type families are not allowed on the RHS of class instances or of
    quantified constraints). However, it is possible to still encounter
    type families on the RHS after doing a bit of constraint solving, as
    seen in test case T23171. This could trigger the panic in the call to
    ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which
    is involved in avoiding loopy superclass constraints.
    
    This patch simply changes ltPatersonSize to return "I don't know, because
    there's a type family involved" in these cases.
    
    Fixes #23171
    
    - - - - -
    d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00
    JS: fix thread-related primops
    
    - - - - -
    7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00
    CI: Disable abi-test-nightly
    
    See #23269
    
    - - - - -
    ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00
    Testsuite: don't use obsolescent egrep (#22351)
    
    Recent egrep displays the following message, breaking golden tests:
    
      egrep: warning: egrep is obsolescent; using grep -E
    
    Switch to using "grep -E" instead
    
    - - - - -
    f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00
    hadrian: Pass haddock file arguments in a response file
    
    In !10119 CI was failing on windows because the command line was too
    long. We can mitigate this by passing the file arguments to haddock in a
    response file.
    
    We can't easily pass all the arguments in a response file because the
    `+RTS` arguments can't be placed in the response file.
    
    Fixes #23273
    
    - - - - -
    7012ec2f by tocic at 2023-04-20T11:01:42-04:00
    Fix doc typo in GHC.Read.readList
    
    - - - - -
    5c873124 by sheaf at 2023-04-20T18:33:34-04:00
    Implement -jsem: parallelism controlled by semaphores
    
    See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a
    complete description for the motivation for this feature.
    
    The `-jsem` option allows a build tool to pass a semaphore to GHC which
    GHC can use in order to control how much parallelism it requests.
    
    GHC itself acts as a client in the GHC jobserver protocol.
    
    ```
    GHC Jobserver Protocol
    ~~~~~~~~~~~~~~~~~~~~~~
    
    This proposal introduces the GHC Jobserver Protocol. This protocol allows
    a server to dynamically invoke many instances of a client process,
    while restricting all of those instances to use no more than <n> capabilities.
    This is achieved by coordination over a system semaphore (either a POSIX
    semaphore [6]_  in the case of Linux and Darwin, or a Win32 semaphore [7]_
    in the case of Windows platforms).
    
    There are two kinds of participants in the GHC Jobserver protocol:
    
    - The *jobserver* creates a system semaphore with a certain number of
      available tokens.
    
      Each time the jobserver wants to spawn a new jobclient subprocess, it **must**
      first acquire a single token from the semaphore, before spawning
      the subprocess. This token **must** be released once the subprocess terminates.
    
      Once work is finished, the jobserver **must** destroy the semaphore it created.
    
    - A *jobclient* is a subprocess spawned by the jobserver or another jobclient.
    
      Each jobclient starts with one available token (its *implicit token*,
      which was acquired by the parent which spawned it), and can request more
      tokens through the Jobserver Protocol by waiting on the semaphore.
    
      Each time a jobclient wants to spawn a new jobclient subprocess, it **must**
      pass on a single token to the child jobclient. This token can either be the
      jobclient's implicit token, or another token which the jobclient acquired
      from the semaphore.
    
      Each jobclient **must** release exactly as many tokens as it has acquired from
      the semaphore (this does not include the implicit tokens).
    ```
    
    Build tools such as cabal act as jobservers in the protocol and are
    responsibile for correctly creating, cleaning up and managing the
    semaphore.
    
    Adds a new submodule (semaphore-compat) for managing and interacting
    with semaphores in a cross-platform way.
    
    Fixes #19349
    
    - - - - -
    52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-04:00
    rts: Initialize Array# header in listThreads#
    
    Previously the implementation of listThreads# failed to initialize the
    header of the created array, leading to various nastiness.
    
    Fixes #23071
    
    - - - - -
    1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00
    testsuite: Add test for #23071
    
    - - - - -
    dae514f9 by tocic at 2023-04-21T13:31:21-04:00
    Fix doc typos in libraries/base/GHC
    
    - - - - -
    113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00
    Testsuite: replace some js_broken/js_skip predicates with req_c
    
    Using req_c is more precise.
    
    - - - - -
    038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00
    Minor doc fixes
    
    - Add docs/index.html to .gitignore.
      It is created by ./hadrian/build docs, and it was the only file
      in Hadrian's templateRules not present in .gitignore.
    - Mention that MultiWayIf supports non-boolean guards
    - Remove documentation of optdll - removed in 2007, 763daed95
    - Fix markdown syntax
    
    - - - - -
    e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00
    User's guide: DeepSubsumption is implied by Haskell{98,2010}
    
    - - - - -
    499a1c20 by PHO at 2023-04-23T13:39:32-04:00
    Implement executablePath for Solaris and make getBaseDir less platform-dependent
    
    Use base-4.17 executablePath when possible, and fall back on
    getExecutablePath when it's not available. The sole reason why getBaseDir
    had #ifdef's was apparently that getExecutablePath wasn't reliable, and we
    could reduce the number of CPP conditionals by making use of
    executablePath instead.
    
    Also export executablePath on js_HOST_ARCH.
    
    - - - - -
    97a6f7bc by tocic at 2023-04-23T13:40:08-04:00
    Fix doc typos in libraries/base
    
    - - - - -
    787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00
    testsuite/T20137: Avoid impl.-defined behavior
    
    Previously we would cast pointers to uint64_t. However, implementations
    are allowed to either zero- or sign-extend such casts. Instead cast to
    uintptr_t to avoid this.
    
    Fixes #23247.
    
    - - - - -
    87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00
    rts: always build 64-bit atomic ops
    
    This patch does a few things:
    
    - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit
      platforms
    - Remove legacy "64bit" cabal flag of rts package
    - Fix hs_xchg64 function prototype for 32-bit platforms
    - Fix AtomicFetch test for wasm32
    
    - - - - -
    2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00
    compiler: don't install signal handlers when the host platform doesn't have signals
    
    Previously, large parts of GHC API will transitively invoke
    withSignalHandlers, which doesn't work on host platforms without
    signal functionality at all (e.g. wasm32-wasi). By making
    withSignalHandlers a no-op on those platforms, we can make more parts
    of GHC API work out of the box when signals aren't supported.
    
    - - - - -
    1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00
    hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC
    
    - - - - -
    1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00
    Add since pragma to Data.Functor.unzip
    
    - - - - -
    0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00
    More informative errors for bad imports (#21826)
    
    - - - - -
    ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00
    JS/base: provide implementation for mkdir (issue 22374)
    
    - - - - -
    8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00
    JS: Fix h$base_access implementation (issue 22576)
    
    - - - - -
    74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00
    Give more guarntees about ImplicitParams (#23289)
    
    - Added new section in the GHC user's guide that legends behavior of
    nested implicit parameter bindings in these two cases:
    
      let ?f = 1 in let ?f = 2 in ?f
    
    and
    
      data T where MkT :: (?f :: Int) => T
    
      f :: T -> T -> Int
      f MkT MkT = ?f
    
    - Added new test case to examine this behavior.
    
    - - - - -
    c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00
    DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208)
    
    In #23208 we observed that the demand signature of a binder occuring in a RULE
    wasn't unleashed, leading to a transitively used binder being discarded as
    absent. The solution was to use the same code path that we already use for
    handling exported bindings.
    
    See the changes to `Note [Absence analysis for stable unfoldings and RULES]`
    for more details.
    
    I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a
    `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our
    existing framework. As a result, I had to touch quite a few places in the code.
    
    This refactoring exposed a few small bugs around correct handling of bottoming
    demand environments. As a result, some strictness signatures now mention uniques
    that weren't there before which caused test output changes to T13143, T19969 and
    T22112. But these tests compared whole -ddump-simpl listings which is a very
    fragile thing to begin with. I changed what exactly they test for based on the
    symptoms in the corresponding issues.
    
    There is a single regression in T18894 because we are more conservative around
    stable unfoldings now. Unfortunately it is not easily fixed; let's wait until
    there is a concrete motivation before invest more time.
    
    Fixes #23208.
    
    - - - - -
    77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00
    Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364)
    
    Carry the actual type of an expression through the PreStgRhs and into GenStgRhs
    for use in later stages. Currently this is used in the JavaScript backend to fix
    some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2,
    T13822, T14749.
    
    - - - - -
    052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00
    EPA: Use ExplicitBraces only in HsModule
    
    !9018 brought in exact print annotations in LayoutInfo for open and
    close braces at the top level.
    
    But it retained them in the HsModule annotations too.
    
    Remove the originals, so exact printing uses LayoutInfo
    
    - - - - -
    d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00
    ci: update ci.sh to actually run the entire testsuite for wasm backend
    
    For the time being, we still need to use in-tree mode and can't test
    the bindist yet.
    
    - - - - -
    533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00
    ci: additional wasm32 manual jobs in validate pipelines
    
    This patch enables bignum native & unregisterised wasm32 jobs as
    manual jobs in validate pipelines, which can be useful to prevent
    breakage when working on wasm32 related patches.
    
    - - - - -
    b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: fix cross prefix stripping
    
    This patch fixes cross prefix stripping in the testsuite driver. The
    normalization logic used to only handle prefixes of the triple form
    <arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens
    in the prefix tuple, so the cross prefix stripping logic would work
    when ghc is configured with something like --target=wasm32-wasi.
    
    - - - - -
    6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: include target exe extension in heap profile filenames
    
    This patch fixes hp2ps related framework failures when testing the
    wasm backend by including target exe extension in heap profile
    filenames.
    
    - - - - -
    e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: exclude ghci ways if no rts linker is present
    
    This patch implements logic to automatically exclude ghci ways when
    there is no rts linker. It's way better than having to annotate
    individual test cases.
    
    - - - - -
    791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: fix permission bits in copy_files
    
    When the testsuite driver copy files instead of symlinking them, it
    should also copy the permission bits, otherwise there'll be permission
    denied errors. Also, enforce file copying when testing wasm32, since
    wasmtime doesn't handle host symlinks quite well
    (https://github.com/bytecodealliance/wasmtime/issues/6227).
    
    - - - - -
    aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: add the req_ghc_with_threaded_rts predicate
    
    This patch adds the req_ghc_with_threaded_rts predicate to the
    testsuite to assert the platform has threaded RTS, and mark some tests
    as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a
    config field instead of a global variable.
    
    - - - - -
    ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: add the req_process predicate
    
    This patch adds the req_process predicate to the testsuite to assert
    the platform has a process model, also marking tests that involve
    spawning processes as req_process. Also bumps hpc & process submodule.
    
    - - - - -
    cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: add the req_host_target_ghc predicate
    
    This patch adds the req_host_target_ghc predicate to the testsuite to
    assert the ghc compiler being tested can compile both host/target
    code. When testing cross GHCs this is not supported yet, but it may
    change in the future.
    
    - - - - -
    b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: add missing annotations for some tests
    
    This patch adds missing annotations (req_th, req_dynamic_lib_support,
    req_rts_linker) to some tests. They were discovered when testing
    wasm32, though it's better to be explicit about what features they
    require, rather than simply adding when(arch('wasm32'), skip).
    
    - - - - -
    bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00
    testsuite: wasm32-specific fixes
    
    This patch includes all wasm32-specific testsuite fixes.
    
    - - - - -
    4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00
    JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304)
    
    - - - - -
    57277662 by sheaf at 2023-04-29T20:23:06+02:00
    Add the Unsatisfiable class
    
    This commit implements GHC proposal #433, adding the Unsatisfiable
    class to the GHC.TypeError module. This provides an alternative to
    TypeError for which error reporting is more predictable: we report it
    when we are reporting unsolved Wanted constraints.
    
    Fixes #14983 #16249 #16906 #18310 #20835
    
    - - - - -
    00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00
    Add structured error messages for GHC.Rename.Names
    
    Tracking ticket: #20115
    
    MR: !10336
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00
    Add sized primitive literal syntax
    
    Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining
    unboxed numeric literals such as `0xFF#Word8 :: Word8#`.
    
    Implements GHC proposal 0451:
    https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst
    
    Fixes #21422.
    
    Bumps haddock submodule.
    
    Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io>
    
    - - - - -
    f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00
    Document instances of Double
    
    - - - - -
    1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00
    Bump Cabal submodule (#22356)
    
    - - - - -
    4eafb52a by sheaf at 2023-05-03T20:18:16-04:00
    Don't forget to check the parent in an export list
    
    Commit 3f374399 introduced a bug which caused us to forget to include
    the parent of an export item of the form T(..) (that is, IEThingAll)
    when checking for duplicate exports.
    
    Fixes #23318
    
    - - - - -
    8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00
    Fix unlit path in cross bindists
    
    - - - - -
    8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00
    hadrian: Flavour: Change args -> extraArgs
    
    Previously in a flavour definition you could override all the flags
    which were passed to GHC. This causes issues when needed to compute a
    package hash because we need to know what these extra arguments are
    going to be before computing the hash. The solution is to modify flavour
    so that the arguments you pass here are just extra ones rather than all
    the arguments that you need to compile something.
    
    This makes things work more like how cabal.project files work when you
    give extra arguments to a package and also means that flavour
    transformers correctly affect the hash.
    
    - - - - -
    3fdb18f8 by romes at 2023-05-04T14:58:14-04:00
    Hardwire a better unit-id for ghc
    
    Previously, the unit-id of ghc-the-library was fixed as `ghc`.
    This was done primarily because the compiler must know the unit-id of
    some packages (including ghc) a-priori to define wired-in names.
    
    However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed
    to `ghc` might result in subtle bugs when different ghc's interact.
    
    A good example of this is having GHC_A load a plugin compiled by GHC_B,
    where GHC_A and GHC_B are linked to ghc-libraries that are ABI
    incompatible. Without a distinction between the unit-id of the ghc library
    GHC_A is linked against and the ghc library the plugin it is loading was
    compiled against, we can't check compatibility.
    
    This patch gives a slightly better unit-id to ghc (ghc-version) by
    (1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0)
    (2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id.
        (2.1) `GHC.Settings.Config` is generated by Hadrian
        (2.2) and also by cabal through `compiler/Setup.hs`
    This unit-id definition is imported by `GHC.Unit.Types` and used to
    set the wired-in unit-id of "ghc", which was previously fixed to "ghc"
    
    The commits following this one will improve the unit-id with a
    cabal-style package hash and check compatibility when loading plugins.
    
    Note that we also ensure that ghc's unit key matches unit id both when
    hadrian or cabal builds ghc, and in this way we no longer need to add
    `ghc` to the WiringMap.
    
    - - - - -
    6689c9c6 by romes at 2023-05-04T14:58:14-04:00
    Validate compatibility of ghcs when loading plugins
    
    Ensure, when loading plugins, that the ghc the plugin depends on is the
    ghc loading the plugin -- otherwise fail to load the plugin.
    
    Progress towards #20742.
    
    - - - - -
    db4be339 by romes at 2023-05-04T14:58:14-04:00
    Add hashes to unit-ids created by hadrian
    
    This commit adds support for computing an inputs hash for packages
    compiled by hadrian. The result is that ABI incompatible packages should
    be given different hashes and therefore be distinct in a cabal store.
    
    Hashing is enabled by the `--flag`, and is off by default as the hash
    contains a hash of the source files. We enable it when we produce
    release builds so that the artifacts we distribute have the right unit
    ids.
    
    - - - - -
    944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00
    Use hash-unit-ids in release jobs
    
    Includes fix upload_ghc_libs glob
    
    - - - - -
    116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00
    JS: fix bounds checking (Issue 23123)
    
    * For ByteArray-based bounds-checking, the JavaScript backend must use the
    `len` field, instead of the inbuild JavaScript `length` field.
    
    * Range-based operations must also check both the start and end of the range
    for bounds
    
    * All indicies are valid for ranges of size zero, since they are essentially no-ops
    
    * For cases of ByteArray accesses (e.g. read as Int), the end index is
    (i * sizeof(type) + sizeof(type) - 1), while the previous implementation
    uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3)
    
    * IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike
    the previous point), but now check both start and end indicies
    
    * Byte array copies now check if the arrays are the same by identity and
    then if the ranges overlap.
    
    - - - - -
    2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00
    Fix remaining issues with bound checking (#23123)
    
    While fixing these I've also changed the way we store addresses into
    ByteArray#. Addr# are composed of two parts: a JavaScript array and an
    offset (32-bit number).
    
    Suppose we want to store an Addr# in a ByteArray# foo at offset i.
    Before this patch, we were storing both fields as a tuple in the "arr"
    array field:
    
      foo.arr[i] = [addr_arr, addr_offset];
    
    Now we only store the array part in the "arr" field and the offset
    directly in the array:
    
      foo.dv.setInt32(i, addr_offset):
      foo.arr[i] = addr_arr;
    
    It avoids wasting space for the tuple.
    
    - - - - -
    98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00
    JavaScript: Correct arguments to h$appendToHsStringA
    
    fixes #23278
    
    - - - - -
    ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00
    base/encoding: add an allocations performance test (#22946)
    
    - - - - -
    e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00
    linear types: Don't add external names to the usage env
    
    This has no observable effect, but avoids storing useless data.
    
    - - - - -
    b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00
    Improved documentation for the Data.OldList.nub function
    
    There was recomentation to use map head . group . sort instead of nub
    function, but containers library has more suitable and efficient
    analogue
    
    - - - - -
    e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-04:00
    Fix type variable substitution in gen_Newtype_fam_insts
    
    Previously, `gen_Newtype_fam_insts` was substituting the type variable binders
    of a type family instance using `substTyVars`, which failed to take type
    variable dependencies into account. There is similar code in
    `GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly,
    so this patch:
    
    1. Factors out this code into a top-level `substATBndrs` function, and
    2. Uses `substATBndrs` in `gen_Newtype_fam_insts`.
    
    Fixes #23329.
    
    - - - - -
    275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00
    Add structured error messages for GHC.Rename.Utils
    
    Tracking ticket: #20115
    
    MR: !10350
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00
    Use TemplateHaskellQuotes in TH.Syntax to construct Names
    
    - - - - -
    a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04:00
    driver: Use hooks from plugin_hsc_env
    
    This fixes a bug in oneshot mode where hooks modified in a plugin
    wouldn't be used in oneshot mode because we neglected to use the right
    hsc_env. This was observed by @csabahruska.
    
    - - - - -
    18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04:00
    Rework plugin initialisation points
    
    In general this patch pushes plugin initialisation points to earlier in
    the pipeline. As plugins can modify the `HscEnv`, it's imperative that
    the plugins are initialised as soon as possible and used thereafter.
    
    For example, there are some new tests which modify hsc_logger and other
    hooks which failed to fire before (and now do)
    
    One consequence of this change is that the error for specifying the
    usage of a HPT plugin from the command line has changed, because it's
    now attempted to be loaded at initialisation rather than causing a
    cyclic module import.
    
    Closes #21279
    
    Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00
    docs: Add Note [Timing of plugin initialization]
    
    - - - - -
    e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00
    Incrementally update ghcup metadata in ghc/ghcup-metadata
    
    This job paves the way for distributing nightly builds
    
    * A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the
      metadata on the "updates" branch.
    * Each night this metadata is downloaded and the nightly builds are
      appended to the end of the metadata.
    * The update job only runs on the scheduled nightly pipeline, not just
      when NIGHTLY=1.
    
    Things which are not done yet
    
    * Modify the retention policy for nightly jobs
    * Think about building release flavour compilers to distribute nightly.
    
    Fixes #23334
    
    - - - - -
    8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00
    docs: Remove mentions of ArrayArray# from unlifted FFI section
    
    Fixes #23277
    
    - - - - -
    994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00
    Add structured error messages for GHC.Rename.Module
    
    Tracking ticket: #20115
    
    MR: !10361
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    Only addresses the single warning missing from the previous MR.
    
    - - - - -
    3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00
    rts: Fix data-race in hs_init_ghc
    
    As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic
    increment/decrement on the RTS's initialization count. This may go wrong
    in a multithreaded program which initializes the runtime multiple times.
    
    Closes #22756.
    
    - - - - -
    78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00
    Add structured error messages for GHC.IfaceToCore
    
    Tracking ticket: #20114
    
    MR: !10390
    
    This converts uses of `mkTcRnUnknownMessage` to newly added constructors
    of `TcRnMessage`.
    
    - - - - -
    0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00
    Fix up rules for ghcup-metadata-nightly-push
    
    - - - - -
    b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00
    testsuite: Add test for atomicSwapIORef
    
    - - - - -
    81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00
    compiler: Implement atomicSwapIORef with xchg
    
    As requested by @treeowl in CLC#139.
    
    - - - - -
    6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00
    Make atomicSwapMutVar# an inline primop
    
    - - - - -
    64064cfe by doyougnu at 2023-05-09T18:40:01-04:00
    JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt
    
    This MR changes some simple optimizations and is a first step in re-architecting
    the JS backend pipeline to add the optimizer. In particular it:
    
    - removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module
    - adds module `GHC.JS.Optimizer`
    - defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations
    - hooks the optimizer into code gen
    - adds FuncStat and ForStat constructors to the backend.
    
    Working Ticket:
    - #22736
    
    Related MRs:
    - MR !10142
    - MR !10000
    
    -------------------------
    Metric Decrease:
        CoOpt_Read
        ManyAlternatives
        PmSeriesS
        PmSeriesT
        PmSeriesV
        T10421
        T12707
        T13253
        T13253-spj
        T15164
        T17516
        T18140
        T18282
        T18698a
        T18698b
        T18923
        T1969
        T19695
        T20049
        T3064
        T5321FD
        T5321Fun
        T783
        T9198
        T9233
        T9630
    -------------------------
    
    - - - - -
    6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00
    Add a regression test for #21050
    
    - - - - -
    b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-04:00
    nonmoving: Account for mutator allocations in bytes_allocated
    
    Previously we failed to account direct mutator allocations into the
    nonmoving heap against the mutator's allocation limit and
    `cap->total_allocated`. This only manifests during CAF evaluation (since
    we allocate the CAF's blackhole directly into the nonmoving heap).
    
    Fixes #23312.
    
    - - - - -
    0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00
    Adjust AArch64 stackFrameHeaderSize
    
    The prologue of each stack frame are the saved LR and FP registers, 8
    byte each. I.e. the size of the stack frame header is 2 * 8 byte.
    
    - - - - -
    7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00
    Make `(&)` representation polymorphic in the return type
    
    - - - - -
    b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00
    ghc-prim: Generalize keepAlive#/touch# in state token type
    
    Closes #23163.
    
    - - - - -
    1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00
    Bump hsc2hs submodule
    
    Fixes #22981.
    
    - - - - -
    0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00
    base: Export GHC.Conc.Sync.fromThreadId
    
    Closes #22706.
    
    - - - - -
    29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00
    Build vanilla alpine bindists
    
    We currently attempt to build and distribute fully static alpine
    bindists (ones which could be used on any linux platform) but most
    people who use the alpine bindists want to use alpine to build their own
    static applications (for which a fully static bindist is not necessary).
    We should build and distribute these bindists for these users whilst the
    fully-static bindist is still unusable.
    
    Fixes #23349
    
    - - - - -
    40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00
    Look both ways when looking for quantified equalities
    
    When looking up (t1 ~# t2) in the quantified constraints,
    check both orientations.  Forgetting this led to #23333.
    
    - - - - -
    c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00
    Move "target has RTS linker" out of settings
    
    We move the "target has RTS linker" information out of configure into a
    predicate in GHC, and remove this option from the settings file where it
    is unnecessary -- it's information statically known from the platform.
    
    Note that previously we would consider `powerpc`s and `s390x`s other
    than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker,
    but the RTS linker supports neither platform.
    
    Closes #23361
    
    - - - - -
    bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00
    Add a test for #17284
    
    Since !10123 we now reject this program.
    
    - - - - -
    630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00
    Document unlawfulness of instance Num Fixed
    
    Fixes #22712
    
    - - - - -
    87eebf98 by sheaf at 2023-05-11T11:55:22-04:00
    Add fused multiply-add instructions
    
    This patch adds eight new primops that fuse a multiplication and an
    addition or subtraction:
    
      - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#`
    
    fmadd x y z is x * y + z, computed with a single rounding step.
    
    This patch implements code generation for these primops in the following
    backends:
    
      - X86, AArch64 and PowerPC NCG,
      - LLVM
      - C
    
    WASM uses the C implementation. The primops are unsupported in the
    JavaScript backend.
    
    The following constant folding rules are also provided:
    
      - compute a * b + c when a, b, c are all literals,
      - x * y + 0 ==> x * y,
      - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x.
    
    NB: the constant folding rules incorrectly handle signed zero.
    This is a known limitation with GHC's floating-point constant folding
    rules (#21227), which we hope to resolve in the future.
    
    - - - - -
    ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00
    Add a test for #21278
    
    - - - - -
    05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00
    rts: Refine memory retention behaviour to account for pinned/compacted objects
    
    When using the copying collector there is still a lot of data which
    isn't copied (such as pinned, compacted, large objects etc). The logic
    to decide how much memory to retain didn't take into account that these
    wouldn't be copied. Therefore we pessimistically retained 2* the amount
    of memory for these blocks even though they wouldn't be copied by the
    collector.
    
    The solution is to split up the heap into two parts, the parts which
    will be copied and the parts which won't be copied. Then the appropiate
    factor is applied to each part individually (2 * for copying and 1.2 *
    for not copying).
    
    The T23221 test demonstrates this improvement with a program which first
    allocates many unpinned ByteArray# followed by many pinned ByteArray#
    and observes the difference in the ultimate memory baseline between the
    two.
    
    There are some charts on #23221.
    
    Fixes #23221
    
    - - - - -
    1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00
    hadrian: fix no_dynamic_libs flavour transformer
    
    This patch fixes the no_dynamic_libs flavour transformer and make
    fully_static reuse it. Previously building with no_dynamic_libs fails
    since ghc program is still dynamic and transitively brings in dyn ways
    of rts which are produced by no rules.
    
    - - - - -
    0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00
    JS: refactor jsSaturate to return a saturated JStat (#23328)
    
    - - - - -
    a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00
    Doc: Fix out-of-sync using-optimisation page
    
    - Make explicit that default flag values correspond to their -O0 value.
    - Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction,
      -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper.
    
    - - - - -
    c176ad18 by sheaf at 2023-05-12T06:10:57-04:00
    Don't panic in mkNewTyConRhs
    
    This function could come across invalid newtype constructors, as we
    only perform validity checking of newtypes once we are outside the
    knot-tied typechecking loop.
    This patch changes this function to fake up a stub type in the case of
    an invalid newtype, instead of panicking.
    
    This patch also changes "checkNewDataCon" so that it reports as many
    errors as possible at once.
    
    Fixes #23308
    
    - - - - -
    ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00
    Allow Core optimizations when interpreting bytecode
    
    Tracking ticket: #23056
    
    MR: !10399
    
    This adds the flag `-funoptimized-core-for-interpreter`, permitting use
    of the `-O` flag to enable optimizations when compiling with the
    interpreter backend, like in ghci.
    
    - - - - -
    c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-04:00
    hadrian: Fix mention of non-existent removeFiles function
    
    Previously Hadrian's bindist Makefile referred to a `removeFiles`
    function that was previously defined by the `make` build system. Since
    the `make` build system is no longer around, this function is now
    undefined. Naturally, make being make, this appears to be silently
    ignored instead of producing an error.
    
    Fix this by rewriting it to `rm -f`.
    
    Closes #23373.
    
    - - - - -
    eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00
    Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog
    
    - - - - -
    aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00
    rts: Ensure non-moving gc is not running when pausing
    
    - - - - -
    5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00
    rts: Teach listAllBlocks about nonmoving heap
    
    List all blocks on the non-moving heap.
    
    Resolves #22627
    
    - - - - -
    d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-04:00
    Fix coercion optimisation for SelCo (#23362)
    
    setNominalRole_maybe is supposed to output a nominal coercion.
    In the SelCo case, it was not updating the stored role to Nominal,
    causing #23362.
    
    - - - - -
    59aa4676 by Alexis King at 2023-05-12T19:28:47-04:00
    hadrian: Fix linker script flag for MergeObjects builder
    
    This fixes what appears to have been a typo in !9530. The `-t` flag just
    enables tracing on all versions of `ld` I’ve looked at, while `-T` is
    used to specify a linker script. It seems that this worked anyway for
    some reason on some `ld` implementations (perhaps because they
    automatically detect linker scripts), but the missing `-T` argument
    causes `gold` to complain.
    
    - - - - -
    4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00
    Less coercion optimization for non-newtype axioms
    
    See Note [Push transitivity inside newtype axioms only] for an explanation
    of the change here.  This change substantially improves the performance of
    coercion optimization for programs involving transitive type family reductions.
    
    -------------------------
    Metric Decrease:
        CoOpt_Singletons
        LargeRecord
        T12227
        T12545
        T13386
        T15703
        T5030
        T8095
    -------------------------
    
    - - - - -
    dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00
    Move checkAxInstCo to GHC.Core.Lint
    
    A consequence of the previous change is that checkAxInstCo is no longer
    called during coercion optimization, so it can be moved back where it belongs.
    
    Also includes some edits to Note [Conflict checking with AxiomInstCo] as
    suggested by @simonpj.
    
    - - - - -
    8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00
    Use the eager unifier in the constraint solver
    
    This patch continues the refactoring of the constraint solver
    described in #23070.
    
    The Big Deal in this patch is to call the regular, eager unifier from the
    constraint solver, when we want to create new equalities. This
    replaces the existing, unifyWanted which amounted to
    yet-another-unifier, so it reduces duplication of a rather subtle
    piece of technology. See
    
      * Note [The eager unifier] in GHC.Tc.Utils.Unify
      * GHC.Tc.Solver.Monad.wrapUnifierTcS
    
    I did lots of other refactoring along the way
    
    * I simplified the treatment of right hand sides that contain CoercionHoles.
      Now, a constraint that contains a hetero-kind CoercionHole is non-canonical,
      and cannot be used for rewriting or unification alike.  This required me
      to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on
      effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in
      GHC.Tc.Solver.Equality.
    
    * I refactored the StopOrContinue type to add StartAgain, so that after a
      fundep improvement (for example) we can simply start the pipeline again.
    
    * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions.
      With Richard I concluded that they are never needed.
    
    * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in
      GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities.
    
    Quite a few error messages change, I think always for the better.
    
    Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836
    
    Metric Decrease:
        T17836
        T18223
    
    - - - - -
    5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00
    Cleanup of dynflags override in export renaming
    The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean.
    
    - - - - -
    d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00
    Use a uniform return convention in bytecode for unary results
    
    fixes #22958
    
    - - - - -
    8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00
    Add more instances for Compose: Enum, Bounded, Num, Real, Integral
    
    See https://github.com/haskell/core-libraries-committee/issues/160 for discussion
    
    - - - - -
    902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-04:00
    Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever
    
    As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the
    table, failing to unpack arguments that are perfectly unpackable.
    
    The fix is pretty easy; see Note [Recursive unboxing]
    
    - - - - -
    a5451438 by sheaf at 2023-05-13T14:59:13-04:00
    Fix bad multiplicity role in tyConAppFunCo_maybe
    
    The function tyConAppFunCo_maybe produces a multiplicity coercion
    for the multiplicity argument of the function arrow, except that
    it could be at the wrong role if asked to produce a representational
    coercion. We fix this by using the 'funRole' function, which computes
    the right roles for arguments to the function arrow TyCon.
    
    Fixes #23386
    
    - - - - -
    5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00
    Turn "ambiguous import" error into a panic
    
    This error should never occur, as a lookup of a type or data constructor
    should never be ambiguous. This is because a single module cannot export
    multiple Names with the same OccName, as per item (1) of
    Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export.
    
    This code path was intended to handle duplicate record fields, but the
    rest of the code had since been refactored to handle those in a
    different way.
    
    We also remove the AmbiguousImport constructor of IELookupError, as
    it is no longer used.
    
    Fixes #23302
    
    - - - - -
    e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00
    Unbreak some tests with latest GNU grep, which now warns about stray '\'.
    
    Confusingly, the testsuite mangled the error to say "stray /".
    
    We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex.
    
    Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default).
    
    - - - - -
    5ae81842 by sheaf at 2023-05-15T14:49:17-04:00
    Improve "ambiguous occurrence" error messages
    
    This error was sometimes a bit confusing, especially when data families
    were involved. This commit improves the general presentation of the
    "ambiguous occurrence" error, and adds a bit of extra context in the
    case of data families.
    
    Fixes #23301
    
    - - - - -
    2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00
    Fix GHCJS OS platform (fix #23346)
    
    - - - - -
    86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00
    Split DynFlags structure into own module
    
    This will allow to make command line parsing to depend on
    diagnostic system (which depends on dynflags)
    
    - - - - -
    fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00
    Replace the implementation of CodeBuffers with unboxed types
    
    - - - - -
    21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00
    Use unboxed codebuffers in base
    
    Metric Decrease:
        encodingAllocations
    
    - - - - -
    18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Weak pointer cleanups
    
    Various stylistic cleanups. No functional changes.
    
    - - - - -
    c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Don't force debug output to stderr
    
    Previously `+RTS -Dw -l` would emit debug output to the eventlog while
    `+RTS -l -Dw` would emit it to stderr. This was because the parser for
    `-D` would unconditionally override the debug output target. Now we
    instead only do so if no it is currently `TRACE_NONE`.
    
    - - - - -
    a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Forcibly flush eventlog on barf
    
    Previously we would attempt to flush via `endEventLogging` which can
    easily deadlock, e.g., if `barf` fails during GC.
    
    Using `flushEventLog` directly may result in slightly less consistent
    eventlog output (since we don't take all capabilities before flushing)
    but avoids deadlocking.
    
    - - - - -
    73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Assert that pointers aren't cleared by -DZ
    
    This turns many segmentation faults into much easier-to-debug assertion
    failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns
    produced by `+RTS -DZ` clearing as invalid pointers.
    
    This is a bit ad-hoc but this is the debug runtime.
    
    - - - - -
    37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Introduce printGlobalThreads
    
    - - - - -
    451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00
    rts: Don't sanity-check StgTSO.global_link
    
    See Note [Avoid dangling global_link pointers].
    
    Fixes #19146.
    
    - - - - -
    d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00
    Split up tyThingToIfaceDecl from GHC.Iface.Make
    
    This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl
    from GHC.Iface.Make into GHC.Iface.Decl.
    This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl,
    transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad.
    
    - - - - -
    4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00
    Migrate errors to diagnostics in GHC.Tc.Module
    
    This commit migrates the errors in GHC.Tc.Module to use the new
    diagnostic infrastructure.
    
    It required a significant overhaul of the compatibility checks between
    an hs-boot or signature module and its implementation; we now use
    a Writer monad to accumulate errors; see the BootMismatch datatype
    in GHC.Tc.Errors.Types, with its panoply of subtypes.
    For the sake of readability, several local functions inside the
    'checkBootTyCon' function were split off into top-level functions.
    
    We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file"
    datatype, as this mirrors the logic in several other places where we
    want to treat hs-boot and hsig files in a similar fashion.
    
    This commit also refactors the Backpack checks for type synonyms
    implementing abstract data, to correctly reject implementations that
    contain qualified or quantified types (this fixes #23342 and #23344).
    
    - - - - -
    d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00
    configure: Drop unused AC_PROG_CPP
    
    In configure, we were calling `AC_PROG_CPP` but never making use of the
    $CPP variable it sets or reads.
    
    The issue is $CPP will show up in the --help output of configure,
    falsely advertising a configuration option that does nothing.
    
    The reason we don't use the $CPP variable is because HS_CPP_CMD is
    expected to be a single command (without flags), but AC_PROG_CPP, when
    CPP is unset, will set said variable to something like `/usr/bin/gcc -E`.
    Instead, we configure HS_CPP_CMD through $CC.
    
    - - - - -
    a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00
    rts: fix --disable-large-address-space
    
    This patch moves
    ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from
    Storage.h to HeapAlloc.h. When --disable-large-address-space is passed
    to configure, the code in HeapAlloc.h makes use of these two macros.
    Fixes #23385.
    
    - - - - -
    bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00
    Add -Wmissing-role-annotations
    
    Implements #22702
    
    - - - - -
    41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00
    base: Export {get,set}ExceptionFinalizer from System.Mem.Weak
    
    As proposed in CLC Proposal #126 [1].
    
    [1]: https://github.com/haskell/core-libraries-committee/issues/126
    
    - - - - -
    67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00
    base: Introduce printToHandleFinalizerExceptionHandler
    
    - - - - -
    5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00
    JS: Implement h$clock_gettime in the JavaScript RTS (#23360)
    
    - - - - -
    90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00
    compiler: Use compact representation for SourceText
    
    SourceText is serialized along with INLINE pragmas into interface files. Many of
    these SourceTexts are identical, for example "{-# INLINE#". When deserialized,
    each such SourceText was previously expanded out into a [Char], which is highly
    wasteful of memory, and each such instance of the text would allocate an
    independent list with its contents as deserializing breaks any sharing that might
    have existed.
    
    Instead, we use a `FastString` to represent these, so that each instance unique
    text will be interned and stored in a memory efficient manner.
    
    - - - - -
    b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00
    compiler: Use compact representation/FastStrings for `SourceNote`s
    
    `SourceNote`s should not be stored as [Char] as this is highly wasteful
    and in certain scenarios can be highly duplicated.
    
    Metric Decrease:
      hard_hole_fits
    
    - - - - -
    6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00
    compiler: Use compact representation for UsageFile (#22744)
    
    Use FastString to store filepaths in interface files, as this data is
    highly redundant so we want to share all instances of filepaths in the
    compiler session.
    
    - - - - -
    47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00
    testsuite: add test for T22744
    
    This test checks for #22744 by compiling 100 modules which each have
    a dependency on 1000 distinct external files.
    
    Previously, when loading these interfaces from disk, each individual instance
    of a filepath in the interface will would be allocated as an individual object
    on the heap, meaning we have heap objects for 100*1000 files, when there are
    only 1000 distinct files we care about.
    
    This test checks this by first compiling the module normally, then measuring
    the peak memory usage in a no-op recompile, as the recompilation checking will
    force the allocation of all these filepaths.
    
    - - - - -
    0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00
    users guide: Add glossary
    
    Currently this merely explains the meaning of "technology preview" in
    the context of released features.
    
    - - - - -
    0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00
    Update glossary.rst
    - - - - -
    3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00
    Use glossary directive
    - - - - -
    2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00
    JS: fix getpid (fix #23399)
    
    - - - - -
    5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00
    Use setSrcSpan rather than setLclEnv in solveForAll
    
    In subsequent MRs (#23409) we want to remove the TcLclEnv argument from
    a CtLoc. This MR prepares us for that by removing the one place where
    the entire TcLclEnv is used, by using it more precisely to just set the
    contexts source location.
    
    Fixes #23390
    
    - - - - -
    385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00
    Update the users guide paragraph on -O in GHCi
    
    In relation to #23056
    
    - - - - -
    87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Add test for #13660
    
    - - - - -
    9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Move implementation of GHC.Foreign to GHC.Internal
    
    - - - - -
    174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Introduce {new,with}CStringLen0
    
    These are useful helpers for implementing the internal-NUL code unit
    check needed to fix #13660.
    
    - - - - -
    a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Clean up documentation
    
    - - - - -
    b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00
    base: Ensure that FilePaths don't contain NULs
    
    POSIX filepaths may not contain the NUL octet but previously we did not
    reject such paths. This could be exploited by untrusted input to cause
    discrepancies between various `FilePath` queries and the opened
    filename. For instance, `readFile "hello.so\x00.txt"` would open the
    file `"hello.so"` yet `takeFileExtension` would return `".txt"`.
    
    The same argument applies to Windows FilePaths
    
    Fixes #13660.
    
    - - - - -
    7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00
    Allow the demand analyser to unpack tuple and equality dictionaries
    
    Addresses #23398. The demand analyser usually does not unpack class
    dictionaries: see Note [Do not unbox class dictionaries] in
    GHC.Core.Opt.DmdAnal.
    
    This patch makes an exception for tuple dictionaries and equality
    dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of
    the above Note.
    
    Compile times fall by 0.1% for some reason (max 0.7% on T18698b).
    
    - - - - -
    b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00
    Use a simpler and more portable construct in ld.ldd check
    
    printf '%q\n' is a bash extension which led to incorrectly
    failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh
    
    - - - - -
    dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00
    Update the warning about interpreter optimizations
    
    to reflect that they're not incompatible anymore, but guarded by a flag
    
    - - - - -
    4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00
    Remove stray dump flags in GHC.Rename.Names
    
    - - - - -
    4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00
    Make Warn = Located DriverMessage
    
    This change makes command line argument parsing use diagnostic
    framework for producing warnings.
    
    - - - - -
    525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00
    Type inference for data family newtype instances
    
    This patch addresses #23408, a tricky case with data family
    newtype instances.  Consider
    
      type family TF a where TF Char = Bool
      data family DF a
      newtype instance DF Bool = MkDF Int
    
    and [W] Int ~R# DF (TF a), with a Given (a ~# Char).   We must fully
    rewrite the Wanted so the tpye family can fire; that wasn't happening.
    
    - - - - -
    c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00
    testsuite: fix predicate on rdynamic test
    
    Test rdynamic requires dynamic linking support, which is
    orthogonal to RTS linker support. Change the predicate accordingly.
    
    Fixes #23316
    
    - - - - -
    735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00
    docs: Use ghc-ticket directive where appropiate in users guide
    
    Using the directive automatically formats and links the ticket
    appropiately.
    
    - - - - -
    b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00
    NCG: remove useless .align directive (#20758)
    
    - - - - -
    15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00
    Add test for #23156
    
    This program had exponential typechecking time in GHC 9.4 and 9.6
    
    - - - - -
    2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00
    Revert "Change hostSupportsRPaths to report False on OpenBSD"
    
    This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2.
    
    - - - - -
    882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00
    Disable T17414 on OpenBSD
    
    Like on other systems it's not guaranteed that there's sufficient
    space in /tmp to write 2G out.
    
    - - - - -
    9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00
    Bring back getExecutablePath to getBaseDir on OpenBSD
    
    Fix #18173
    
    - - - - -
    9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00
    Add an error origin for impedance matching (#23427)
    
    - - - - -
    33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00
    testsuite: Add tests for #23146
    
    Both lifted and unlifted variants.
    
    - - - - -
    76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00
    codeGen: Fix some Haddocks
    
    - - - - -
    33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00
    codeGen: Give proper LFInfo to datacon wrappers
    
    As noted in `Note [Conveying CAF-info and LFInfo between modules]`,
    when importing a binding from another module we must ensure that it gets
    the appropriate `LambdaFormInfo` if it is in WHNF to ensure that
    references to it are tagged correctly.
    
    However, the implementation responsible for doing this,
    `GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and
    not wrappers. This lead to the crash of this program in #23146:
    
        module B where
    
        type NP :: [UnliftedType] -> UnliftedType
        data NP xs where
          UNil :: NP '[]
    
        module A where
        import B
    
        fieldsSam :: NP xs -> NP xs -> Bool
        fieldsSam UNil UNil = True
    
        x = fieldsSam UNil UNil
    
    Due to its GADT nature, `UNil` produces a trivial wrapper
    
        $WUNil :: NP '[]
        $WUNil = UNil @'[] @~(<co:1>)
    
    which is referenced in the RHS of `A.x`. Due to the above-mentioned bug
    in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were
    not tagged. This is problematic as `fieldsSam` expected its arguments to
    be tagged as they are unlifted.
    
    The fix is straightforward: extend the logic in `mkLFImported` to cover
    (nullary) datacon wrappers as well as workers. This is safe because we
    know that the wrapper of a nullary datacon will be in WHNF, even if it
    includes equalities evidence (since such equalities are not runtime
    relevant).
    
    Thanks to @MangoIV for the great ticket and @alt-romes for his
    minimization and help debugging.
    
    Fixes #23146.
    
    - - - - -
    2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    codeGen: Fix LFInfo of imported datacon wrappers
    
    As noted in #23231 and in the previous commit, we were failing to give a
    an LFInfo of LFCon to a nullary datacon wrapper from another module,
    failing to properly tag pointers which ultimately led to the
    segmentation fault in #23146.
    
    On top of the previous commit which now considers wrappers where we
    previously only considered workers, we change the order of the guards so
    that we check for the arity of the binding before we check whether it is
    a constructor. This allows us to
    (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was
    nullary, which we previously would fail to do
    (2) Remove the `isNullaryRepDataCon` predicate:
        (a) which was previously wrong, since it considered wrappers whose
        workers had zero-width arguments to be non-nullary and would fail to
        give `LFCon` to them
        (b) is now unnecessary, since arity == 0 guarantees
            - that the worker takes no arguments at all
            - and the wrapper takes no arguments and its RHS must be an
              application of the worker to zero-width-args only.
            - we lint these two items with an assertion that the datacon
              `hasNoNonZeroWidthArgs`
    
    We also update `isTagged` to use the new logic in determining the
    LFInfos of imported Ids.
    
    The creation of LFInfos for imported Ids and this detail are explained
    in Note [The LFInfo of Imported Ids].
    
    Note that before the patch to those issues we would already consider these
    nullary wrappers to have `LFCon` lambda form info; but failed to re-construct
    that information in `mkLFImported`
    
    Closes #23231, #23146
    
    (I've additionally batched some fixes to documentation I found while
    investigating this issue)
    
    - - - - -
    0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Make LFInfos for DataCons on construction
    
    As a result of the discussion in !10165, we decided to amend the
    previous commit which fixed the logic of `mkLFImported` with regard to
    datacon workers and wrappers.
    
    Instead of having the logic for the LFInfo of datacons be in
    `mkLFImported`, we now construct an LFInfo for all data constructors on
    GHC.Types.Id.Make and store it in the `lfInfo` field.
    
    See the new Note [LFInfo of DataCon workers and wrappers] and
    ammendments to Note [The LFInfo of Imported Ids]
    
    - - - - -
    12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Update Note [Core letrec invariant]
    
    Authored by @simonpj
    
    - - - - -
    e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Rename mkLFImported to importedIdLFInfo
    
    The `mkLFImported` sounded too much like a constructor of sorts, when
    really it got the `LFInfo` of an imported Id from its `lf_info` field
    when this existed, and otherwise returned a conservative estimate of
    that imported Id's LFInfo. This in contrast to functions such as
    `mkLFReEntrant` which really are about constructing an `LFInfo`.
    
    - - - - -
    e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Enforce invariant on typePrimRepArgs in the types
    
    As part of the documentation effort in !10165 I came across this
    invariant on 'typePrimRepArgs' which is easily expressed at the
    type-level through a NonEmpty list.
    
    It allowed us to remove one panic.
    
    - - - - -
    b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
    Merge outdated Note [Data con representation] into Note [Data constructor representation]
    
    Introduce new Note [Constructor applications in STG] to better support
    the merge, and reference it from the relevant bits in the STG syntax.
    
    - - - - -
    e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00
    Add the SolverStage monad
    
    This refactoring makes a substantial improvement in the
    structure of the type-checker's constraint solver: #23070.
    
    Specifically:
    
    * Introduced the SolverStage monad.   See GHC.Tc.Solver.Monad
      Note [The SolverStage monad]
    
    * Make each solver pipeline (equalities, dictionaries, irreds etc)
      deal with updating the inert set, as a separate SolverStage.  There
      is sometimes special stuff to do, and it means that each full
      pipeline can have type SolverStage Void, indicating that they never
      return anything.
    
    * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage.  Much nicer.
    
    * Combined the remnants of GHC.Tc.Solver.Canonical and
      GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve.
      (Interact and Canonical are removed.)
    
    * Gave the same treatment to dictionary and irred constraints
      as I have already done for equality constraints:
        * New types (akin to EqCt): IrredCt and DictCt
        * Ct is now just a simple sum type
              data Ct
                = CDictCan      DictCt
                | CIrredCan     IrredCt
                | CEqCan        EqCt
                | CQuantCan     QCInst
                | CNonCanonical CtEvidence
        * inert_dicts can now have the better type DictMap DictCt, instead of
          DictMap Ct; and similarly inert_irreds.
    
    * Significantly simplified the treatment of implicit parameters.
      Previously we had a number of special cases
        * interactGivenIP, an entire function
        * special case in maybeKickOut
        * special case in findDict, when looking up dictionaries
      But actually it's simpler than that. When adding a new Given, implicit
      parameter constraint to the InertSet, we just need to kick out any
      existing inert constraints that mention that implicit parameter.
    
      The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with
      its auxiliary GHC.Core.Predicate.mentionsIP.
    
      See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict.
    
    * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit.
      See Note [Fast path for tcCheckHoleFit].  This is a big win in some cases:
      test hard_hole_fits gets nearly 40% faster (at compile time).
    
    * Add a new fast-path for solving /boxed/ equality constraints
      (t1 ~ t2).  See Note [Solving equality classes] in GHC.Tc.Solver.Dict.
      This makes a big difference too: test T17836 compiles 40% faster.
    
    * Implement the PermissivePlan of #23413, which concerns what happens with
      insoluble Givens.   Our previous treatment was wildly inconsistent as that
      ticket pointed out.
    
      A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply
      don't run the ambiguity check at all if -XAllowAmbiguousTypes is on.
    
    Smaller points:
    
    * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for
      insoluble /occurs/ checks, broaden in to all insouluble constraints.
      Just generally better. See Note [Insoluble mis-match] in that module.
    
    As noted above, compile time perf gets better.  Here are the changes
    over 0.5% on Fedora.  (The figures are slightly larger on Windows for
    some reason.)
    
    Metrics: compile_time/bytes allocated
    -------------------------------------
                    LargeRecord(normal)   -0.9%
    MultiLayerModulesTH_OneShot(normal)   +0.5%
                         T11822(normal)   -0.6%
                         T12227(normal)   -1.8% GOOD
                         T12545(normal)   -0.5%
                         T13035(normal)   -0.6%
                         T15703(normal)   -1.4% GOOD
                         T16875(normal)   -0.5%
                         T17836(normal)  -40.7% GOOD
                        T17836b(normal)  -12.3% GOOD
                        T17977b(normal)   -0.5%
                          T5837(normal)   -1.1%
                          T8095(normal)   -2.7% GOOD
                          T9020(optasm)   -1.1%
                 hard_hole_fits(normal)  -37.0% GOOD
    
                              geo. mean   -1.3%
                              minimum    -40.7%
                              maximum     +0.5%
    
    Metric Decrease:
        T12227
        T15703
        T17836
        T17836b
        T8095
        hard_hole_fits
        LargeRecord
        T9198
        T13035
    
    - - - - -
    6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00
    Avoid an assertion failure in abstractFloats
    
    The function GHC.Core.Opt.Simplify.Utils.abstractFloats
    was carelessly calling lookupIdSubst_maybe on a CoVar;
    but a precondition of the latter is being given an Id.
    
    In fact it's harmless to call it on a CoVar, but still, the
    precondition on lookupIdSubst_maybe makes sense, so I added
    a test for CoVars.
    
    This avoids a crash in a DEBUG compiler, but otherwise has
    no effect. Fixes #23426.
    
    - - - - -
    838aaf4b by hainq at 2023-05-24T12:41:19-04:00
    Migrate errors in GHC.Tc.Validity
    
    This patch migrates the error messages in GHC.Tc.Validity to use
    the new diagnostic infrastructure.
    
    It adds the constructors:
    
      - TcRnSimplifiableConstraint
      - TcRnArityMismatch
      - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors
        and fundep coverage condition errors.
    
    - - - - -
    8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00
    linear lint: Add missing processing of DEFAULT
    
    In this correct program
    
    f :: a %1 -> a
    f x = case x of x { _DEFAULT -> x }
    
    after checking the alternative we weren't popping the case binder 'x'
    from the usage environment, which meant that the lambda-bound 'x'
    was counted twice: in the scrutinee and (incorrectly) in the alternative.
    In fact, we weren't checking the usage of 'x' at all.
    Now the code for handling _DEFAULT is similar to the one handling
    data constructors.
    
    Fixes #23025.
    
    - - - - -
    ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00
    Remove outdated "Don't check hs-boot type family instances too early" note
    
    This note was introduced in 25b70a29f623 which delayed performing some
    consistency checks for type families. However, the change was reverted
    later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not
    removed.
    
    I found it confusing when reading to code to try and work out what
    special behaviour there was for hs-boot files (when in-fact there isn't
    any).
    
    - - - - -
    44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00
    rts: Define ticky macro stubs
    
    These macros have long been undefined which has meant we were missing
    reporting these allocations in ticky profiles.
    
    The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was
    missing all the RTS calls to allocate, this leads to a the overall
    ALLOC_RTS_tot number to be severaly underreported.
    
    Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot
    counters which are useful to tracking stack allocations.
    
    Fixes #23421
    
    - - - - -
    b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00
    rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS
    
    This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes
    more sense to name it after that rather than the suffix NOCTR, whose
    meaning has been lost to the mists of time.
    
    - - - - -
    eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00
    users guide: A few small mark-up fixes
    
    - - - - -
    a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00
    configure: Fix support check for response files.
    
    In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument
    to printf, the writing of the arguments response file always failed.
    
    The fix is to pass the arguments after `--` so that they are treated
    positional arguments rather than flags to printf.
    
    Closes #23435
    
    - - - - -
    f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00
    [feat] add .direnv to the .gitignore file
    
    - - - - -
    36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00
    Add Data.List.unsnoc
    
    See https://github.com/haskell/core-libraries-committee/issues/165 for discussion
    
    - - - - -
    c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00
    Fix crash in backpack signature merging with -ddump-rn-trace
    
    In some cases, backpack signature merging could crash in addUsedGRE
    when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause
    unavailable interfaces to be loaded.
    This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE
    when -ddump-rn-trace is enabled.
    
    Fixes #23424
    
    Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>
    
    - - - - -
    5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00
    Add a regression test for #13981
    
    The panic was fixed by 6998772043a7f0b. Fixes #13981.
    
    - - - - -
    182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00
    Add a test for #23355
    
    It was fixed by !10061, so I'm adding it in the same group.
    
    - - - - -
    1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00
    Migrate errors in GHC.Rename.Splice GHC.Rename.Pat
    
    This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat
    to use the new diagnostic infrastructure.
    
    - - - - -
    56abe494 by sheaf at 2023-05-25T12:09:55+02:00
    Common up Template Haskell errors in TcRnMessage
    
    This commit commons up the various Template Haskell errors into a
    single constructor, TcRnTHError, of TcRnMessage.
    
    - - - - -
    a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00
    Enable ghci tests for unboxed tuples
    
    The tests were originally skipped because ghci used not to support
    unboxed tuples/sums.
    
    - - - - -
    dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00
    rts: Build ticky GHC with single-threaded RTS
    
    The threaded RTS allows you to use ticky profiling but only for the
    counters in the generated code. The counters used in the C portion of
    the RTS are disabled. Updating the counters is also racy using the
    threaded RTS which can lead to misleading or incorrect ticky results.
    
    Therefore we change the hadrian flavour to build using the
    single-threaded RTS (mainly in order to get accurate C code counter
    increments)
    
    Fixes #23430
    
    - - - - -
    fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00
    Propagate long-distance info in generated code
    
    When desugaring generated pattern matches, we skip pattern match checks.
    However, this ended up also discarding long-distance information, which
    might be needed for user-written sub-expressions.
    
    Example:
    
    ```haskell
    okay (GADT di) cd =
      let sr_field :: ()
          sr_field = case getFooBar di of { Foo -> () }
      in case cd of { SomeRec _ -> SomeRec sr_field }
    ```
    
    With sr_field a generated FunBind, we still want to propagate the outer
    long-distance information from the GADT pattern match into the checks
    for the user-written RHS of sr_field.
    
    Fixes #23445
    
    - - - - -
    f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00
    Introduce GHCiMessage to wrap GhcMessage
    
    By introducing a wrapped message type we can control how certain
    messages are printed in GHCi (to add extra information for example)
    
    - - - - -
    58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00
    Generalise UnknownDiagnostic to allow embedded diagnostics to access
    parent diagnostic options.
    
    * Split default diagnostic options from Diagnostic class into
      HasDefaultDiagnosticOpts class.
    * Generalise UnknownDiagnostic to allow embedded diagnostics to access
      options.
    
    The principle idea here is that when wrapping an error message (such as
    GHCMessage to make GHCiMessage) then we need to also be able to lift the
    configuration when overriding how messages are printed (see load' for an
    example).
    
    - - - - -
    b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00
    Allow API users to wrap error messages created during 'load'
    
    This allows API users to configure how messages are rendered when they
    are emitted from the load function. For an example see how
    'loadWithCache' is used in GHCi.
    
    - - - - -
    2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00
    Abstract cantFindError and turn Opt_BuildingCabal into a print-time option
    
    * cantFindError is abstracted so that the parts which mention specific
      things about ghc/ghci are parameters. The intention being that
      GHC/GHCi can specify the right values to put here but otherwise
      display the same error message.
    * The BuildingCabalPackage argument from GenericMissing is removed and
      turned into a print-time option. The reason for the error is not
      dependent on whether `-fbuilding-cabal-package` is passed, so we don't
      want to store that in the error message.
    
    - - - - -
    34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00
    error messages: Don't display ghci specific hints for missing packages
    
    Tickets like #22884 suggest that it is confusing that GHC used on the
    command line can suggest options which only work in GHCi.
    
    This ticket uses the error message infrastructure to override certain
    error messages which displayed GHCi specific information so that this
    information is only showed when using GHCi.
    
    The main annoyance is that we mostly want to display errors in the same
    way as before, but with some additional information. This means that the
    error rendering code has to be exported from the Iface/Errors/Ppr.hs
    module.
    
    I am unsure about whether the approach taken here is the best or most
    maintainable solution.
    
    Fixes #22884
    
    - - - - -
    05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Don't override existing metadata if version already exists.
    
    If a nightly pipeline runs twice for some reason for the same version
    then we really don't want to override an existing entry with new
    bindists. This could cause ABI compatability issues for users or break
    ghcup's caching logic.
    
    - - - - -
    fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Use proper API url for bindist download
    
    Previously we were using links from the web interface, but it's more
    robust and future-proof to use the documented links to the artifacts.
    
    https://docs.gitlab.com/ee/api/job_artifacts.html
    
    - - - - -
    5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Set Nightly and LatestNightly tags
    
    The latest nightly release needs the LatestNightly tag, and all other
    nightly releases need the Nightly tag. Therefore when the metadata is
    updated we need to replace all LatestNightly with Nightly.`
    
    - - - - -
    914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Download nightly metadata for correct date
    
    The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata
    with one metadata file per year. When we update the metadata we download
    and update the right file for the current year.
    
    - - - - -
    16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Download metadata and update for correct year
    
    something about pipeline date
    
    - - - - -
    14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00
    ghcup-metadata: Don't skip CI
    
    On a push we now have a CI job which updates gitlab pages with the
    metadata files.
    
    - - - - -
    1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00
    ghcup-metadata: Add --date flag to specify the release date
    
    The ghcup-metadata now has a viReleaseDay field which needs to be
    populated with the day of the release.
    
    - - - - -
    bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00
    ghcup-metadata: Add dlOutput field
    
    ghcup now requires us to add this field which specifies where it should
    download the bindist to. See
    https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more
    discussion.
    
    - - - - -
    2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00
    JS: Convert rendering to use HLine instead of SDoc (#22455)
    
    - - - - -
    abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00
    testsuite: add WasmControlFlow test
    
    This patch adds the WasmControlFlow test to test the wasm backend's
    relooper component.
    
    - - - - -
    07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00
    Factorize getLinkDeps
    
    Prepare reuse of getLinkDeps for TH implementation in the JS backend
    (cf #22261 and review of !9779).
    
    - - - - -
    fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00
    Change GHC.Driver.Session import to .DynFlags
    
    Also move targetPlatform selector
    
    Plenty of GHC needs just DynFlags.
    Even more can be made to use .DynFlags if more selectors is migrated.
    This is a low hanging fruit.
    
    - - - - -
    69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00
    EPA: Better fix for #22919
    
    The original fix for #22919 simply removed the ability to match up
    prior comments with the first declaration in the file.
    
    Restore it, but add a check that the comment is on a single line, by
    ensuring that it comes immediately prior to the next thing (comment or
    start of declaration), and that the token preceding it is not on the
    same line.
    
    closes #22919
    
    - - - - -
    0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00
    Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214)
    
    - - - - -
    b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00
    testsuite: Pass -kb16k -kc128k for performance tests
    
    Setting a larger stack chunk size gives a greater protection
    from stack thrashing (where the repeated overflow/underflow allocates a lot of
    stack chunks which sigificantly impact allocations). This
    stabilises some tests against differences cause by more things being
    pushed onto the stack.
    
    The performance tests are generally testing work done by the compiler,
    using allocation as a proxy, so removing/stabilising the allocations due
    to the stack gives us more stable tests which are also more sensitive
    to actual changes in compiler performance.
    
    The tests which increase are ones where we compile a lot of modules, and
    for each module we spawn a thread to compile the module in. Therefore
    increasing these numbers has a multiplying effect on these tests because
    there are many more stacks which we can increase in size.
    
    The most significant improvements though are cases such as T8095 which
    reduce significantly in allocations (30%). This isn't a performance
    improvement really but just helps stabilise the test against this
    threshold set by the defaults.
    
    Fixes #23439
    
    -------------------------
    Metric Decrease:
        InstanceMatching
        T14683
        T8095
        T9872b_defer
        T9872d
        T9961
        hie002
        T19695
        T3064
    Metric Increase:
        MultiLayerModules
        T13701
        T14697
    -------------------------
    
    - - - - -
    6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00
    Move via-C flags into GHC
    
    These were previously hardcoded in configure (with no option for
    overriding them) and simply passed onto ghc through the settings file.
    
    Since configure already guarantees gcc supports those flags, we simply
    move them into GHC.
    
    - - - - -
    981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00
    Allow CPR on unrestricted constructors
    
    Per the new `Note [Linting linearity]`, we want optimisations over
    trying to preserve linearity. This will allow CPR to handle `Ur`, in
    particular.
    
    - - - - -
    bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00
    Push coercions across multiplicity boundaries
    
    Per the new `Note [Linting linearity]`, we want optimisations over
    trying to preserve linearity. This will avoid preventing inlinings and
    reductions and make linear programs more efficient.
    
    - - - - -
    d56dd695 by sheaf at 2023-05-31T11:37:12-04:00
    Data.Bag: add INLINEABLE to polymorphic functions
    
    This commit allows polymorphic methods in GHC.Data.Bag to be
    specialised, avoiding having to pass explicit dictionaries when they
    are instantiated with e.g. a known monad.
    
    - - - - -
    5366cd35 by sheaf at 2023-05-31T11:37:12-04:00
    Split off TcBinderStack into its own module
    
    This commit splits off TcBinderStack into its own module,
    to avoid module cycles: we might want to refer to it without also
    pulling in the TcM monad.
    
    - - - - -
    09d4d307 by sheaf at 2023-05-31T11:37:12-04:00
    Split off TcRef into its own module
    
    This helps avoid pull in the full TcM monad when we just want access
    to mutable references in the typechecker. This facilitates later patches
    which introduce a slimmed down TcM monad for zonking.
    
    - - - - -
    88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00
    Introduce Codensity monad
    
    The Codensity monad is useful to write state-passing computations in
    continuation-passing style, e.g. to implement a State monad as
    continuation-passing style over a Reader monad.
    
    - - - - -
    f62d8195 by sheaf at 2023-05-31T11:37:12-04:00
    Restructure the zonker
    
    This commit splits up the zonker into a few separate components, described
    in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`.
    
    1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`,
         which has enough information for zonking types.
         This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`,
         which guarantees we don't throw an error while reporting an error.
    
    2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines
        two zonking monad transformers, `ZonkT` and `ZonkBndrT`.
        `ZonkT` is a reader monad transformer over `ZonkEnv`.
        `ZonkBndrT m` is the codensity monad over `ZonkT m`.
    
         `ZonkBndrT` is used for computations that accumulate binders
         in the `ZonkEnv`.
    
    3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use
        in the typechecker. It uses the `ZonkM` monad.
    
    4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`,
        which has been refactored to use `ZonkTcM = ZonkT TcM` and
        `ZonkBndrTcM = ZonkBndrT TcM`.
    
    Allocations slightly decrease on the whole due to using
    continuation-passing style instead of manual state passing of ZonkEnv
    in the final zonking to Type.
    
    -------------------------
    Metric Decrease:
        T4029
        T8095
        T14766
        T15304
        hard_hole_fits
        RecordUpdPerf
    Metric Increase:
        T10421
    -------------------------
    
    - - - - -
    70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00
    Update rdt-theme to latest upstream version
    
    Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444
    
    - - - - -
    f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Restructure IPE buffer layout
    
    Reference ticket #21766
    
    This commit restructures IPE buffer list entries to not contain
    references to their corresponding info tables. IPE buffer list nodes now
    point to two lists of equal length, one holding the list of info table
    pointers and one holding the corresponding entries for each info table.
    This will allow the entry data to be compressed without losing the
    references to the info tables.
    
    - - - - -
    5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Add IPE compression to configure
    
    Reference ticket #21766
    
    Adds an `--enable-ipe-data-compreesion` flag to the configure script
    which will check for libzstd and set the appropriate flags to allow for
    IPE data compression in the compiler
    
    - - - - -
    b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    IPE data compression
    
    Reference ticket #21766
    
    When IPE data compression is enabled, compress the emitted IPE buffer
    entries and decompress them in the RTS.
    
    - - - - -
    5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Fix libzstd detection in configure and RTS
    
    Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases
    and properly check that before IPE data decompression in the RTS. See
    ticket #21766.
    
    - - - - -
    69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Add note describing IPE data compression
    
    See ticket #21766
    
    - - - - -
    7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Fix byte order of IPE data, fix IPE tests
    
    Make sure byte order of written IPE buffer entries matches target.
    
    Make sure the IPE-related tests properly access the fields of IPE buffer
    entry nodes with the new IPE layout.
    
    This commit also introduces checks to avoid importing modules if IPE
    compression is not enabled.
    
    See ticket #21766.
    
    - - - - -
    0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Fix IPE data decompression buffer allocation
    
    Capacity of buffers allocated for decompressed IPE data was
    incorrect due to a misuse of the `ZSTD_findFrameCompressedSize`
    function. Fix by always storing decompressed size of IPE data in IPE
    buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine
    the size of the compressed data.
    
    See ticket #21766
    
    - - - - -
    a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Add optional dependencies to ./configure output
    
    Changes the configure script to indicate whether libnuma, libzstd, or
    libdw are being used as dependencies due to their optional features
    being enabled.
    
    - - - - -
    09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Add IPE-enabled builds to CI
    
    - Adds an IPE job to the CI pipeline which is triggered by the ~IPE label
    - Introduces CI logic to enable IPE data compression
    - Enables uncompressed IPE data on debug CI job
    - Regenerates jobs.yaml
    
    MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the
    images repository is meant to ensure that the proper images have
    libzstd-dev installed.
    
    - - - - -
    3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Update user's guide and release notes, small fixes
    
    Add mention of IPE data compression to user's guide and the release
    notes for 9.8.1. Also note the impact compression has on binary size in
    both places.
    
    Change IpeBufferListNode compression check so only the value `1`
    indicates compression.
    
    See ticket #21766
    
    - - - - -
    41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
    Remove IPE enabled builds from CI
    
    We don't need to explicitly specify the +ipe transformer to test IPE data
    since there are tests which manually enable IPE information. This commit does
    leave zstd IPE data compression enabled on the debian CI jobs.
    
    - - - - -
    982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00
    Fix build with 9.2
    
    GHC.Tc.Zonk.Type uses an equality constraint.
    ghc.nix currently provides 9.2.
    
    - - - - -
    1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00
    Output Lint errors to stderr instead of stdout
    
    This is a continuation of 7b095b99, which fixed warnings but not errors.
    
    Refs #13342
    
    - - - - -
    8e81f140 by sheaf at 2023-06-01T10:56:51-04:00
    Refactor lookupExactOrOrig & friends
    
    This refactors the panoply of renamer lookup functions relating to
    lookupExactOrOrig to more graciously handle Exact and Orig names.
    
    In particular, we avoid the situation in which we would add Exact/Orig
    GREs to the tcg_used_gres field, which could cause a panic in bestImport
    like in #23240.
    
    Fixes #23428
    
    - - - - -
    5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00
    Use the one-shot trick for UM and RewriteM functors
    
    As described in Note [The one-shot state monad trick],
    we shouldn't use derived Functor instances for monads using
    one-shot. This was done for most of them, but UM and RewriteM
    were missed.
    
    - - - - -
    2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00
    Fix testsuite skipping Lint
    
    setTestOpts() is used to modify the test options for an entire .T file,
    rather than a single test.
    If there was a test using collect_compiler_stats, all of the tests
    in the same file had lint disabled.
    
    Fixes #21247
    
    - - - - -
    00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00
    Add testcases for already fixed #16432
    
    They were fixed by 40c7daed0.
    
    Fixes #16432
    
    - - - - -
    f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00
    cleanup: Remove unused field from SelfBoot
    
    It is no longer needed since Note [Extra dependencies from .hs-boot files]
    was deleted in 6998772043.
    
    I've also added tildes to Note headers, otherwise they're not detected
    by the linter.
    
    - - - - -
    82eacab6 by sheaf at 2023-06-02T09:08:01-04:00
    Delete GHC.Tc.Utils.Zonk
    
    This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType
    in commit f62d8195, but I forgot to delete the original module
    - - - - -
    4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00
    base: Add build-order import of GHC.Types in GHC.IO.Handle.Types
    
    For reasons similar to those described in Note [Depend on
    GHC.Num.Integer].
    
    Fixes #23411.
    
    - - - - -
    f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00
    JS: fix and enhance non-minimized code generation (#22455)
    
    Flag -ddisable-js-minimizer was producing invalid code. Fix that and
    also a few other things to generate nicer JS code for debugging.
    
    The added test checks that we don't regress when using the flag.
    
    - - - - -
    f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00
    [hadrian] Fix multiline synopsis rendering
    
    - - - - -
    b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00
    Elaborate on performance properties of Data.List.++
    
    - - - - -
    7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00
    Big TcLclEnv and CtLoc refactoring
    
    The overall goal of this refactoring is to reduce the dependency
    footprint of the parser and syntax tree. Good reasons include:
    
    - Better module graph parallelisability
    - Make it easier to migrate error messages without introducing module loops
    - Philosophically, there's not reason for the AST to depend on half the
      compiler.
    
    One of the key edges which added this dependency was
    
    > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv)
    
    As this in turn depending on TcM which depends on HscEnv and so on.
    
    Therefore the goal of this patch is to move `TcLclEnv` out of
    `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without
    incurring a huge dependency chain.
    
    The changes in this patch are:
    
    * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv
    * Create new smaller modules for the types used in TcLclEnv
      New Modules:
      - GHC.Tc.Types.ErrCtxt
      - GHC.Tc.Types.BasicTypes
      - GHC.Tc.Types.TH
      - GHC.Tc.Types.LclEnv
      - GHC.Tc.Types.CtLocEnv
      - GHC.Tc.Errors.Types.PromotionErr
    
      Removed Boot File:
      - {-# SOURCE #-} GHC.Tc.Types
    
    * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't
      participate in restoreLclEnv.
    
    * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in
      GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the
      location of the implication and constraint.
    
    By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no
    longer depend on the TcM monad and all that entails.
    
    Fixes #23389 #23409
    
    - - - - -
    3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00
    Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session
    
    This removes the usage of DynFlags from Tc.Utils.TcType  so that it no
    longer depends on GHC.Driver.Session. In general we don't want anything
    which is a dependency of Language.Haskell.Syntax to depend on
    GHC.Driver.Session and removing this edge gets us closer to that goal.
    
    - - - - -
    18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00
    Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn
    
    This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes
    Language.Haskell.Syntax end up depending on GHC.Driver.Session.
    
    - - - - -
    12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00
    Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session
    
    - - - - -
    eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00
    hole fit plugins: Split definition into own module
    
    The hole fit plugins are defined in terms of TcM, a type we want to
    avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own
    module we can remove this dependency. It also simplifies the necessary
    boot file.
    
    - - - - -
    9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00
    Move GHC.Core.Opt.CallerCC Types into separate module
    
    This allows `GHC.Driver.DynFlags` to depend on these types without
    depending on CoreM and hence the entire simplifier pipeline.
    
    We can also remove a hs-boot file with this change.
    
    - - - - -
    52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00
    Remove unecessary SOURCE import
    
    - - - - -
    698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00
    testsuite: Accept new output for CountDepsAst and CountDepsParser tests
    
    These are in a separate commit as the improvement to these tests is the
    cumulative effect of the previous set of patches rather than just the
    responsibility of the last one in the patchset.
    
    - - - - -
    58ccf02e by sheaf at 2023-06-05T16:00:47-04:00
    TTG: only allow VarBind at GhcTc
    
    The VarBind constructor of HsBind is only used at the GhcTc stage.
    This commit makes that explicit by setting the extension field of
    VarBind to be DataConCantHappen at all other stages.
    
    This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind,
    and remove some panics.
    
    - - - - -
    54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00
    Generate Addr# access ops programmatically
    
    The existing utils/genprimopcode/gen_bytearray_ops.py was
    relocated and extended for this purpose.  Additionally, hadrian
    now knows about this script and uses it when generating primops.txt
    
    - - - - -
    ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00
    ghcup-metadata: Only add Nightly tag when replacing LatestNightly
    
    Previously we were always adding the Nightly tag, but this led to all
    the previous builds getting an increasing number of nightly tags over
    time. Now we just add it once, when we remove the LatestNightly tag.
    
    - - - - -
    4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00
    Invisible binders in type declarations (#22560)
    
    This patch implements @k-binders introduced in GHC Proposal #425
    and guarded behind the TypeAbstractions extension:
    
    	type D :: forall k j. k -> j -> Type
    	data D @k @j a b = ...
    	       ^^ ^^
    
    To represent the new syntax, we modify LHsQTyVars as follows:
    
    	-  hsq_explicit :: [LHsTyVarBndr () pass]
    	+  hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass]
    
    HsBndrVis is a new data type that records the distinction between
    type variable binders written with and without the @ sign:
    
    	data HsBndrVis pass
    	  = HsBndrRequired
    	  | HsBndrInvisible (LHsToken "@" pass)
    
    The rest of the patch updates GHC, template-haskell, and haddock
    to handle the new syntax.
    
    Parser:
      The PsErrUnexpectedTypeAppInDecl error message is removed.
      The syntax it used to reject is now permitted.
    
    Renamer:
      The @ sign does not affect the scope of a binder, so the changes to
      the renamer are minimal.  See rnLHsTyVarBndrVisFlag.
    
    Type checker:
      There are three code paths that were updated to deal with the newly
      introduced invisible type variable binders:
    
        1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl
        2. checking CUSK: see kcCheckDeclHeader_cusk
        3. inference: see kcInferDeclHeader, rejectInvisibleBinders
    
      Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv
      are generalized to work with HsBndrVis.
    
    Updates the haddock submodule.
    
    Metric Increase:
        MultiLayerModulesTH_OneShot
    
    Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00
    JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481)
    
    - - - - -
    e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00
    Update CODEOWNERS
    - - - - -
    960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Remove IPE enabled builds from CI"
    
    This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951.
    
    - - - - -
    bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Update user's guide and release notes, small fixes"
    
    This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7.
    
    - - - - -
    12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Add IPE-enabled builds to CI"
    
    This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f.
    
    - - - - -
    dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Add optional dependencies to ./configure output"
    
    This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58.
    
    - - - - -
    240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Fix IPE data decompression buffer allocation"
    
    This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a.
    
    - - - - -
    9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Fix byte order of IPE data, fix IPE tests"
    
    This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327.
    
    - - - - -
    3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Add note describing IPE data compression"
    
    This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0.
    
    - - - - -
    fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Fix libzstd detection in configure and RTS"
    
    This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0.
    
    - - - - -
    1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "IPE data compression"
    
    This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553.
    
    - - - - -
    fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Add IPE compression to configure"
    
    This reverts commit 5d1f2411f4becea8650d12d168e989241edee186.
    
    - - - - -
    2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00
    Revert "Restructure IPE buffer layout"
    
    This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91.
    
    - - - - -
    2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00
    Don't report redundant Givens from quantified constraints
    
    This fixes #23323
    
    See (RC4) in Note [Tracking redundant constraints]
    
    - - - - -
    567b32e1 by David Binder at 2023-06-08T18:41:29-04:00
    Update the outdated instructions in HACKING.md on how to compile GHC
    
    - - - - -
    2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00
    Restore mingwex dependency on Windows
    
    This partially reverts some of the changes in !9475 to make `base` and
    `ghc-prim` depend on the `mingwex` library on Windows. It also restores the
    RTS's stubs for `mingwex`-specific symbols such as `_lock_file`.
    
    This is done because the C runtime provides `libmingwex` nowadays, and
    moreoever, not linking against `mingwex` requires downstream users to link
    against it explicitly in difficult-to-predict circumstances. Better to always
    link against `mingwex` and prevent users from having to do the guesswork
    themselves.
    
    See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for
    the discussion that led to this.
    
    - - - - -
    28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00
    RtsSymbols.c: Remove mingwex symbol stubs
    
    As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows,
    which means that the RTS no longer needs to declare stubs for the `__mingw_*`
    family of symbols. Let's remove these stubs to avoid confusion.
    
    Fixes #23309.
    
    - - - - -
    3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00
    Consistently use validity checks for TH conversion of data constructors
    
    We were checking that TH-spliced data declarations do not look like this:
    
    ```hs
    data D :: Type = MkD Int
    ```
    
    But we were only doing so for `data` declarations' data constructors, not for
    `newtype`s, `data instance`s, or `newtype instance`s. This patch factors out
    the necessary validity checks into its own `cvtDataDefnCons` function and uses
    it in all of the places where it needs to be.
    
    Fixes #22559.
    
    - - - - -
    a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00
    Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma
    
    This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC
    pragma for files with module level scope.
    
    Instead of simple not deleting the files, we also need to remove them
    from the TmpFs so they are not deleted later on when all the other files
    are deleted.
    
    There are additional complications because you also need to remove the
    directory where these files live from the TmpFs so we don't try to
    delete those later either.
    
    I added two tests.
    
    1. Tests simply that -keep-tmp-files works at all with a single module
       and --make mode.
    2. The other tests that temporary files are deleted for other modules
       which don't enable -keep-tmp-files.
    
    Fixes #23339
    
    - - - - -
    dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00
    withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free.
    
    Ticket #23305 reports an error where we were attempting to use the
    logger which was created by withDeferredDiagnostics after its scope had
    ended.
    
    This problem would have been caught by this patch and a validate build:
    
    ```
    +*** Exception: Use after free
    +CallStack (from HasCallStack):
    +  error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make
    ```
    
    This general issue is tracked by #20981
    
    - - - - -
    432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00
    Don't return complete HscEnv from upsweep
    
    By returning a complete HscEnv from upsweep the logger (as introduced by
    withDeferredDiagnostics) was escaping the scope of
    withDeferredDiagnostics and hence we were losing error messages.
    
    This is reminiscent of #20981, which also talks about writing errors
    into messages after their scope has ended.
    
    See #23305 for details.
    
    - - - - -
    26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00
    Dump `SpecConstr` specialisations separately
    
    Introduce a `-ddump-spec-constr` flag which debugs specialisations from
    `SpecConstr`. These are no longer shown when you use `-ddump-spec`.
    
    - - - - -
    4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00
    Add role annotations to SNat, SSymbol and SChar
    
    Ticket #23454 explained it was possible to implement unsafeCoerce
    because SNat was lacking a role annotation.
    
    As these are supposed to be singleton types but backed by an efficient
    representation the correct annotation is nominal to ensure these kinds
    of coerces are forbidden.
    
    These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85
    which was implemented in 532de36870ed9e880d5f146a478453701e9db25d.
    
    CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170
    
    Fixes #23454
    
    - - - - -
    9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00
    Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in
    
    This broke the sdist generation.
    
    Fixes #23489
    
    - - - - -
    273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00
    Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver.
    
    - - - - -
    b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00
    Fix -Wterm-variable-capture scope (#23434)
    
    -Wterm-variable-capture wasn't accordant with type variable
    scoping in associated types, in type classes. For example,
    this code produced the warning:
      k = 12
    
      class C k a where
        type AT a :: k -> Type
    
    I solved this issue by reusing machinery of newTyVarNameRn function
    that is accordand with associated types: it does lookup for each free type
    variable when we are in the type class context. And in this patch I
    use result of this work to make sure that -Wterm-variable-capture warns
    only on implicitly quantified type variables.
    
    - - - - -
    9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00
    Remove redundant case statement in rts/js/mem.js.
    - - - - -
    a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00
    Change WarningWithFlag to plural WarningWithFlags
    
    Resolves #22825
    
    Now each diagnostic can name multiple different warning flags for its reason.
    
    There is currently one use case: missing signatures.
    Currently we need to check which warning flags are enabled when
    generating the diagnostic, which is against the declarative nature of
    the diagnostic framework.
    
    This patch allows a warning diagnostic to have multiple warning flags,
    which makes setup more declarative.
    
    The WarningWithFlag pattern synonym is added for backwards compatibility
    
    The 'msgEnvReason' field is added to MsgEnvelope to store the
    `ResolvedDiagnosticReason`, which accounts for the enabled flags, and
    then that is used for pretty printing the diagnostic.
    
    - - - - -
    ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00
    Add a test Way for running ghci with Core optimizations
    
    Tracking ticket: #23059
    
    This runs compile_and_run tests with optimised code with bytecode
    interpreter
    
    Changed submodules: hpc, process
    
    Co-authored-by: Torsten Schmits <git at tryp.io>
    
    - - - - -
    c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00
    Configure -Qunused-arguments instead of hardcoding it
    
    When GHC invokes clang, it currently passes -Qunused-arguments to
    discard warnings resulting from GHC using multiple options that aren't
    used.
    
    In this commit, we configure -Qunused-arguments into the Cc options
    instead of checking if the compiler is clang at runtime and hardcoding
    the flag into GHC.
    
    This is part of the effort to centralise toolchain information in
    toolchain target files at configure time with the end goal of a runtime
    retargetable GHC.
    
    This also means we don't need to call getCompilerInfo ever, which
    improves performance considerably (see !10589).
    
    Metric Decrease:
        PmSeriesG
        T10421
        T11303b
        T12150
        T12227
        T12234
        T12425
        T13035
        T13253-spj
        T13386
        T15703
        T16875
        T17836b
        T17977
        T17977b
        T18140
        T18282
        T18304
        T18698a
        T18698b
        T18923
        T20049
        T21839c
        T3064
        T5030
        T5321FD
        T5321Fun
        T5837
        T6048
        T9020
        T9198
        T9872d
        T9961
    
    - - - - -
    0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00
    Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion
    between different precisions.
    
    - - - - -
    95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00
    Add regression test for #23143
    
    !10541, the fix for #23323, also fixes #23143. Let's add a regression test to
    ensure that it stays fixed.
    
    Fixes #23143.
    
    - - - - -
    ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00
    delete GHCi.UI.Tags module and remove remaining references
    
    Co-authored-by: Tilde Rose <t1lde at protonmail.com>
    
    - - - - -
    c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00
    Add regression test for 17328
    
    - - - - -
    de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00
    Skip checking whether constructors are in scope when deriving
    newtype instances.
    
    Fixes #17328
    
    - - - - -
    5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00
    Don't suggest `DeriveAnyClass` when instance can't be derived.
    
    Fixes #19692.
    
    Prototypical cases:
    
        class C1 a where
          x1 :: a -> Int
        data G1 = G1 deriving C1
    
        class C2 a where
          x2 :: a -> Int
          x2 _ = 0
        data G2 = G2 deriving C2
    
    Both of these used to give this suggestion, but for C1 the suggestion
    would have failed (generated code with undefined methods, which compiles
    but warns). Now C2 still gives the suggestion but C1 doesn't.
    
    - - - - -
    80a0b099 by David Binder at 2023-06-13T09:47:49-04:00
    Add testcase for error GHC-00711 to testsuite
    
    - - - - -
    e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00
    Add -Wmissing-poly-kind-signatures
    
    Implements #22826
    
    This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types.
    
    - - - - -
    f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00
    ci: special case in req_host_target_ghc for JS
    
    - - - - -
    b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00
    When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions
    
    Fixes #23486
    
    - - - - -
    c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00
    Add a testcase for #20076
    
    Remove 'recursive' in the error message, since the error
    can arise without recursion.
    
    - - - - -
    b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00
    Use tcInferFRR to prevent bad generalisation
    
    Fixes #23176
    
    - - - - -
    bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00
    ci: Add dependenices on necessary aarch64 jobs for head.hackage ci
    
    These need to be added since we started testing aarch64 on head.hackage
    CI. The jobs will sometimes fail because they will start before the
    relevant aarch64 job has finished.
    
    Fixes #23511
    
    - - - - -
    a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00
    Add standalone kind signatures for Code and TExp
    
    CodeQ and TExpQ already had standalone kind signatures
    even before this change:
    
    	type TExpQ :: TYPE r -> Kind.Type
    	type CodeQ :: TYPE r -> Kind.Type
    
    Now Code and TExp have signatures too:
    
    	type TExp :: TYPE r -> Kind.Type
    	type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type
    
    This is a stylistic change.
    
    - - - - -
    e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00
    Warn that GHC.TypeLits.Internal should not be used
    
    - - - - -
    100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00
    Warn that GHC.TypeNats.Internal should not be used
    
    - - - - -
    078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00
    Add more flags for dumping core passes (#23491)
    
    - - - - -
    1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00
    Add tests for dumping flags (#23491)
    
    - - - - -
    42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00
    Provide a demand signature for atomicModifyMutVar.# (#23047)
    
    Fixes #23047
    
    - - - - -
    8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00
    compiler: Cross-reference Note [StgToJS design]
    
    In particular, the numeric representations are quite useful context in a
    few places.
    
    - - - - -
    a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00
    Implement the -Wimplicit-rhs-quantification warning (#23510)
    
    GHC Proposal #425 "Invisible binders in type declarations" forbids
    implicit quantification of type variables that occur free on the
    right-hand side of a type synonym but are not mentioned on the left-hand side.
    The users are expected to rewrite this using invisible binders:
    
        type T1 :: forall a . Maybe a
        type T1    = 'Nothing :: Maybe a      -- old
        type T1 @a = 'Nothing :: Maybe a      -- new
    
    Since the @k-binders are a new feature, we need to wait for three releases
    before we require the use of the new syntax. In the meantime, we ought to
    provide users with a new warning, -Wimplicit-rhs-quantification, that would
    detect when such implicit quantification takes place, and include it in -Wcompat.
    
    - - - - -
    0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00
    Minor refactorings to mkSpillInstr and mkLoadInstr
    
    Better error messages. And, use the existing `off` constant to reduce
    duplication.
    
    - - - - -
    1792b57a by doyougnu at 2023-06-15T03:12:17-04:00
    JS: merge util modules
    
    Merge Core and StgUtil modules for StgToJS pass.
    Closes: #23473
    
    - - - - -
    469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00
    Check visibility of nested foralls in can_eq_nc (#18863)
    
    Prior to this change, `can_eq_nc` checked the visibility of the
    outermost layer of foralls:
    
    	forall a. forall b. forall c. phi1
    	forall x. forall y. forall z. phi2
    	        ^^
    	     up to here
    
    Then it delegated the rest of the work to `can_eq_nc_forall`, which
    split off all foralls:
    
    	forall a. forall b. forall c. phi1
    	forall x. forall y. forall z. phi2
    	                            ^^
    	                         up to here
    
    This meant that some visibility flags were completely ignored.
    We fix this oversight by moving the check to `can_eq_nc_forall`.
    
    - - - - -
    59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00
    JS: use regular mask for blocking IO
    
    Blocking IO used uninterruptibleMask which should make any thread
    blocked on IO unreachable by async exceptions (such as those from
    timeout). This changes it to a regular mask.
    
    It's important to note that the nodejs runtime does not actually
    interrupt the blocking IO when the Haskell thread receives an
    async exception, and that file positions may be updated and buffers
    may be written after the Haskell thread has already resumed.
    
    Any file descriptor affected by an async exception interruption
    should therefore be used with caution.
    
    - - - - -
    907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00
    JS: nodejs: do not set 'readable' handler on stdin at startup
    
    The Haskell runtime used to install a 'readable' handler on stdin
    at startup in nodejs. This would cause the nodejs system to start
    buffering the stream, causing data loss if the stdin file
    descriptor is passed to another process.
    
    This change delays installation of the 'readable' handler until
    the first read of stdin by Haskell code.
    
    - - - - -
    a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00
    JS: reserve one more virtual (negative) file descriptor
    
    This is needed for upcoming support of the process package
    
    - - - - -
    78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00
    Report scoped kind variables at the type-checking phase (#16635)
    
    This patch modifies the renamer to respect ScopedTypeVariables in kind
    signatures. This means that kind variables bound by the outermost
    `forall` now scope over the type:
    
      type F = '[Right @a @() () :: forall a. Either a ()]
      --         ^^^^^^^^^^^^^^^          ^^^
      --          in scope here        bound here
    
    However, any use of such variables is a type error, because we don't
    have type-level lambdas to bind them in Core. This is described in the
    new Note [Type variable scoping errors during type check] in GHC.Tc.Types.
    
    - - - - -
    4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00
    JS: testsuite: use correct ticket number
    
    Replace #22356 with #22349 for these tests because #22356 has been fixed
    but now these tests fail because of #22349.
    
    - - - - -
    15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00
    JS: testsuite: update ticket numbers
    
    - - - - -
    08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00
    JS: more triage
    
    - - - - -
    e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00
    Fix test T18522-deb-ppr
    
    Fixes #23509
    
    - - - - -
    62c56416 by Ben Price at 2023-06-16T05:52:39-04:00
    Lint: more details on "Occurrence is GlobalId, but binding is LocalId"
    
    This is helpful when debugging a pass which accidentally shadowed a
    binder.
    
    - - - - -
    d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00
    Clean a stray bit of text in user guide
    
    - - - - -
    93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00
    testsuite: Add forall visibility test cases
    
    The added tests ensure that the type checker does not confuse
    visible and invisible foralls.
    
    VisFlag1:    kind-checking type applications and inferred type variable instantiations
    VisFlag1_ql: kind-checking Quick Look instantiations
    VisFlag2:    kind-checking type family instances
    VisFlag3:    checking kind annotations on type parameters of associated type families
    VisFlag4:    checking kind annotations on type parameters in type declarations with SAKS
    VisFlag5:    checking the result kind annotation of data family instances
    
    - - - - -
    a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00
    JS: factorize SaneDouble into its own module
    
    Follow-up of b159e0e9 whose ticket is #22736
    
    - - - - -
    0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00
    Add tests for #21973
    
    - - - - -
    640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00
    Update documentation for `<**>`
    
    - - - - -
    2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00
    Update text
    
    - - - - -
    1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00
    Update examples
    
    - - - - -
    7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00
    Update documentation to actually display code correctly
    
    - - - - -
    800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00
    Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512)
    
    GHC Proposal #425 "Invisible binders in type declarations" restricts the
    scope of type and data family instances as follows:
    
      In type family and data family instances, require that every variable
      mentioned on the RHS must also occur on the LHS.
    
    For example, here are three equivalent type instance definitions accepted before this patch:
    
      type family F1 a :: k
      type instance F1 Int = Any :: j -> j
    
      type family F2 a :: k
      type instance F2 @(j -> j) Int = Any :: j -> j
    
      type family F3 a :: k
      type instance forall j. F3 Int = Any :: j -> j
    
    - In F1, j is implicitly quantified and it occurs only on the RHS;
    - In F2, j is implicitly quantified and it occurs both on the LHS and the RHS;
    - In F3, j is explicitly quantified.
    
    Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted.
    
    - - - - -
    9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00
    JS: testsuite: use correct ticket numbers
    
    - - - - -
    c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00
    JS: don't dump eventlog to stderr by default
    
    Fix T16707
    
    Bump stm submodule
    
    - - - - -
    89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00
    Fix TH name lookup for symbolic tycons (#23525)
    
    - - - - -
    cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00
    IPE data compression
    
    IPE data resulting from the `-finfo-table-map` flag may now be
    compressed by configuring the GHC build with the
    `--enable-ipe-data-compression` flag. This results in about a 20%
    reduction in the size of IPE-enabled build results.
    
    The compression library, zstd, may optionally be statically linked by
    configuring with the `--enabled-static-libzstd` flag (on non-darwin
    platforms)
    
    libzstd version 1.4.0 or greater is required.
    
    - - - - -
    0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00
    Add `IfaceWarnings` to represent the `ModIface`-storable parts
    of a `Warnings GhcRn`.
    
    Fixes #23516
    
    - - - - -
    3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00
    Avoid desugaring non-recursive lets into recursive lets
    
    This prepares for having linear let expressions in the frontend.
    
    When desugaring lets, SPECIALISE statements create more copies of a
    let binding. Because of the rewrite rules attached to the bindings,
    there are dependencies between the generated binds.
    
    Before this commit, we simply wrapped all these in a mutually
    recursive let block, and left it to the simplified to sort it out.
    
    With this commit: we are careful to generate the bindings in
    dependency order, so that we can wrap them in consecutive lets (if the
    source is non-recursive).
    
    - - - - -
    9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00
    rts: Do not call exit() from SIGINT handler
    
    Previously `shutdown_handler` would call `stg_exit` if the scheduler was
    Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However,
    `stg_exit` is not signal-safe as it calls `exit` (which calls `atexit`
    handlers). The only safe thing to do in this situation is to call
    `_exit`, which terminates with minimal cleanup.
    
    Fixes #23417.
    
    - - - - -
    7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00
    Bump Cabal submodule
    
    This requires changing the recomp007 test because now cabal passes
    `this-unit-id` to executable components, and that unit-id contains a
    hash which includes the ABI of the dependencies. Therefore changing the
    dependencies means that -this-unit-id changes and recompilation is
    triggered.
    
    The spririt of the test is to test GHC's recompilation logic assuming
    that `-this-unit-id` is constant, so we explicitly pass `-ipid` to
    `./configure` rather than letting `Cabal` work it out.
    
    - - - - -
    1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00
    [feat] add a hint to `HasField` error message
    - add a hint that indicates that the record that the record dot is used
      on might just be missing a field
    - as the intention of the programmer is not entirely clear, it is only
      shown if the type is known
    - This addresses in part issue #22382
    
    - - - - -
    b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00
    rts/ipe: Fix unused lock warning
    
    - - - - -
    6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts/ProfilerReportJson: Fix memory leak
    
    - - - - -
    1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Various warnings fixes
    
    - - - - -
    471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix printf format mismatch
    
    - - - - -
    80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix incorrect #include <sys/poll.h>
    
    According to Alpine's warnings and poll(2), <poll.h> should be
    preferred.
    
    - - - - -
    ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00
    nonmoving: Fix unused definition warrnings
    
    - - - - -
    6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00
    Disable futimens on Darwin.
    
    See #22938
    
    - - - - -
    b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix incorrect CPP guard
    
    - - - - -
    94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00
    hadrian: Ensure that -Werror is passed when compiling the RTS.
    
    Previously the `+werror` transformer would only pass `-Werror` to GHC,
    which does not ensure that the same is passed to the C compiler when
    building the RTS. Arguably this is itself a bug but for now we will just
    work around this by passing `-optc-Werror` to GHC.
    
    I tried to enable `-Werror` in all C compilations but the boot libraries
    are something of a portability nightmare.
    
    - - - - -
    5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Disable `#pragma GCC`s on clang compilers
    
    Otherwise the build fails due to warnings. See #23530.
    
    - - - - -
    cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix capitalization of prototype
    
    - - - - -
    17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00
    rts: Fix incorrect format specifier
    
    - - - - -
    0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00
    JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576)
    
    - - - - -
    3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00
    Memory usage fixes for Haddock
    
    - Do not include `mi_globals` in the `NoBackend` backend. It was only included
      for Haddock, but Haddock does not actually need it. This causes a 200MB
      reduction in max residency when generating haddocks on the Agda codebase
      (roughly 1GB to 800MB).
    
    - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to
      be written to interface files using `-fwrite-interface`
    
    Bumps haddock submodule.
    
    Metric Decrease:
        haddock.base
    
    - - - - -
    8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00
    Fix associated data family doc structure items
    
    Associated data families were being given their own export DocStructureItems,
    which resulted in them being documented separately from their classes in
    haddocks. This commit fixes it.
    
    - - - - -
    4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    JS: implement TH support
    
    - Add ghc-interp.js bootstrap script for the JS interpreter
    - Interactively link and execute iserv code from the ghci package
    - Incrementally load and run JS code for splices into the running iserv
    
    Co-authored-by: Luite Stegeman <stegeman at gmail.com>
    
    - - - - -
    3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    Don't use getKey
    
    - - - - -
    f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    Stg: return imported FVs
    
    This is used to determine what to link when using the interpreter.
    For now it's only used by the JS interpreter but it could easily be used
    by the native interpreter too (instead of extracting names from compiled BCOs).
    
    - - - - -
    fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    Fix some recompilation avoidance tests
    
    - - - - -
    a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    TH_import_loop is now broken as expected
    
    - - - - -
    dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00
    JS: always recompile when TH is enabled (cf #23013)
    
    - - - - -
    711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00
    Add support for deprecating exported items (proposal #134)
    
    This is an implementation of the deprecated exports proposal #134.
    The proposal introduces an ability to introduce warnings to exports.
    This allows for deprecating a name only when it is exported from a specific
    module, rather than always depreacting its usage. In this example:
    
        module A ({-# DEPRECATED "do not use" #-} x) where
        x = undefined
        ---
        module B where
        import A(x)
    
    `x` will emit a warning when it is explicitly imported.
    
    Like the declaration warnings, export warnings are first accumulated within
    the `Warnings` struct, then passed into the ModIface, from which they are
    then looked up and warned about in the importing module in the `lookup_ie`
    helpers of the `filterImports` function (for the explicitly imported names)
    and in the `addUsedGRE(s)` functions where they warn about regular usages
    of the imported name.
    
    In terms of the AST information, the custom warning is stored in the
    extension field of the variants of the `IE` type (see Trees that Grow for
    more information).
    
    The commit includes a bump to the haddock submodule added in MR #28
    
    Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>
    
    - - - - -
    c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00
    configure: Bump version to 9.8
    
    Bumps Haddock submodule
    
    - - - - -
    4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00
    configure: Bump version to 9.9
    
    Bumps haddock submodule.
    
    - - - - -
    5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00
    rts: Work around missing prototypes errors
    
    Darwin's toolchain inexpliciably claims that `write_barrier` and friends
    have declarations without prototypes, despite the fact that (a) they are
    definitions, and (b) the prototypes appear only a few lines above. Work
    around this by making the definitions proper prototypes.
    
    - - - - -
    43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00
    ghcup-metadata: Fix date modifier (M = minutes, m = month)
    
    Fixes #23552
    
    - - - - -
    564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00
    Support large stack frames/offsets in GHCi bytecode interpreter
    
    Bytecode instructions like PUSH_L (push a local variable) contain
    an operand that refers to the stack slot. Before this patch, the
    operand type was SmallOp (Word16), limiting the maximum stack
    offset to 65535 words. This could cause compiler panics in some
    cases (See #22888).
    
    This patch changes the operand type for stack offsets from
    SmallOp to Op, removing the stack offset limit.
    
    Fixes #22888
    
    - - - - -
    8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00
    JS: support levity-polymorphic datatypes (#22360,#22291)
    
    - thread knowledge about levity into PrimRep instead of panicking
    - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.)
    
    Doing this also fixes #22291 (test added).
    
    There is a small performance hit (~1% more allocations).
    
    Metric Increase:
        T18698a
        T18698b
    
    - - - - -
    5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00
    MR Review Template: Mention "Blocked on Review" label
    
    In order to improve our MR review processes we now have the label
    "Blocked on Review" which allows people to signal that a MR is waiting
    on a review to happen.
    
    See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html
    
    - - - - -
    4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00
    Move MR template to Default.md
    
    This makes it more obvious what you have to modify to affect the default
    template rather than looking in the project settings.
    
    - - - - -
    522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00
    Revert "Avoid desugaring non-recursive lets into recursive lets"
    
    This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef.
    
    Fixes #23550
    
    - - - - -
    c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00
    Propagate breakpoint information when inlining across modules
    
    Tracking ticket: #23394
    
    MR: !10448
    
    * Add constructor `IfaceBreakpoint` to `IfaceTickish`
    * Store breakpoint data in interface files
    * Store `BreakArray` for the breakpoint's module, not the current module, in BCOs
    * Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's
      state
    * Allocate module name in `ModBreaks`, like `BreakArray`
    * Lookup breakpoint by module name in GHCi
    * Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the
      linker when breakpoints are enabled, and panicking when `ModBreaks` is missing
    
    - - - - -
    6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00
    Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's
    
    - - - - -
    e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00
    Remove arity inference in type declarations (#23514)
    
    Arity inference in type declarations was introduced
    as a workaround for the lack of @k-binders.
    
    They were added in 4aea0a72040, so I simplified all
    of this by simply removing arity inference altogether.
    
    This is part of GHC Proposal #425 "Invisible binders in type
    declarations".
    
    - - - - -
    459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00
    Relax defaulting of RuntimeRep/Levity when printing
    
    Fixes #16468
    
    MR: !10702
    
    Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall
    
    - - - - -
    151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00
    Remove duplicate link label in linear types docs
    
    - - - - -
    ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00
    Stop configuring unused Ld command in `settings`
    
    GHC has no direct dependence on the linker. Rather, we depend upon the C
    compiler for linking and an object-merging program (which is typically
    `ld`) for production of GHCi objects and merging of C stubs into final
    object files.
    
    Despite this, for historical reasons we still recorded information about
    the linker into `settings`. Remove these entries from `settings`,
    `hadrian/cfg/system.config`, as well as the `configure` logic
    responsible for this information.
    
    Closes #23566.
    
    - - - - -
    bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00
    Remove extraneous debug output
    
    - - - - -
    7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00
    Work with unset vars in -e mode
    
    - - - - -
    49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00
    Pass positional arguments in their positions
    
    By quoting $cmd, the default "bash -i" is a single argument to run, and
    no file named "bash -i" actually exists to be run.
    
    - - - - -
    887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00
    Handle unset value in -e context
    
    - - - - -
    5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00
    Configure CPP into settings
    
    There is a distinction to be made between the Haskell Preprocessor and
    the C preprocessor. The former is used to preprocess Haskell files,
    while the latter is used in C preprocessing such as Cmm files.
    
    In practice, they are both the same program (usually the C compiler) but
    invoked with different flags.
    
    Previously we would, at configure time, configure the haskell
    preprocessor and save the configuration in the settings file, but,
    instead of doing the same for CPP, we had hardcoded in GHC that the CPP
    program was either `cc -E` or `cpp`.
    
    This commit fixes that asymmetry by also configuring CPP at configure
    time, and tries to make more explicit the difference between HsCpp and
    Cpp (see Note [Preprocessing invocations]).
    
    Note that we don't use the standard CPP and CPPFLAGS to configure Cpp,
    but instead use the non-standard --with-cpp and --with-cpp-flags.
    The reason is that autoconf sets CPP to "$CC -E", whereas we expect the
    CPP command to be configured as a standalone executable rather than a
    command. These are symmetrical with --with-hs-cpp and
    --with-hs-cpp-flags.
    
    Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP
             to be C99 compatible through -optP, since we now configure that
             into settings.
    
    Closes #23422
    
    - - - - -
    5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00
    hadrian: Always canonicalize topDirectory
    
    Hadrian's `topDirectory` is intended to provide an absolute path to the
    root of the GHC tree. However, if the tree is reached via a symlink this
    
    One question here is whether the `canonicalizePath` call is expensive
    enough to warrant caching. In a quick microbenchmark I observed that
    `canonicalizePath "."` takes around 10us per call; this seems
    sufficiently low not to worry.
    
    Alternatively, another approach here would have been to rather move the
    canonicalization into `m4/fp_find_root.m4`. This would have avoided
    repeated canonicalization but sadly path canonicalization is a hard
    problem in POSIX shell.
    
    Addresses #22451.
    
    - - - - -
    b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00
    Optimise ELF linker (#23464)
    
    - cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF`
    - cache shndx table in ObjectCode
    - run `checkProddableBlock` only with debug rts
    
    - - - - -
    30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00
    compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE
    
    - - - - -
    b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00
    compiler: Drop MO_WriteBarrier
    
    rts: Drop write_barrier
    
    - - - - -
    7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00
    rts: Drop load_store_barrier()
    
    This is no longer used.
    
    - - - - -
    d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00
    rts: Drop last instances of prim_{write,read}_barrier
    
    - - - - -
    965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00
    rts: Eliminate remaining uses of load_load_barrier
    
    - - - - -
    0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00
    compiler: Drop MO_ReadBarrier
    
    - - - - -
    7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00
    rts: Drop load_load_barrier
    
    This is no longer used.
    
    - - - - -
    9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00
    Delete write_barrier function
    
    - - - - -
    bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00
    rts: Make collectFreshWeakPtrs definition a prototype
    
    x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs
    needs to be a prototype.
    
    - - - - -
    ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00
    Fix number of free double regs
    
    D1..D4 are defined for aarch64 and thus not free.
    
    - - - - -
    c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00
    Fix typechecking of promoted empty lists
    
    The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of
    `'[]` (see the newly added `T23543` test case for an example), but the `'[]`
    case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to
    invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type
    checker]`.
    
    There are some benign changes to test cases' expected output due to the new
    code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`.
    
    Fixes #23543.
    
    - - - - -
    fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00
    Configure MergeObjs supports response files rather than Ld
    
    The previous configuration script to test whether Ld supported response
    files was
    * Incorrect (see #23542)
    * Used, in practice, to check if the *merge objects tool* supported
      response files.
    
    This commit modifies the macro to run the merge objects tool (rather
    than Ld), using a response file, and checking the result with $NM
    
    Fixes #23542
    
    - - - - -
    78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00
    JS: fix JS stack printing (#23565)
    
    - - - - -
    9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00
    Add -fpolymorphic-specialisation flag (off by default at all optimisation levels)
    
    Polymorphic specialisation has led to a number of hard to diagnose
    incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so
    this commit introduces a flag `-fpolymorhphic-specialisation` which
    allows users to turn on this experimental optimisation if they are
    willing to buy into things going very wrong.
    
    Ticket #23469
    
    - - - - -
    b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00
    Rip out runtime linker/compiler checks
    
    We used to choose flags to pass to the toolchain at runtime based on the
    platform running GHC, and in this commit we drop all of those runtime
    linker checks
    
    Ultimately, this represents a change in policy: We no longer adapt at
    runtime to the toolchain being used, but rather make final decisions
    about the toolchain used at /configure time/
    (we have deleted Note [Run-time linker info] altogether!).
    
    This works towards the goal of having all toolchain configuration logic
    living in the same place, which facilities the work towards a
    runtime-retargetable GHC (see #19877).
    
    As of this commit, the runtime linker/compiler logic was moved to
    autoconf, but soon it, and the rest of the existing toolchain
    configuration logic, will live in the standalone ghc-toolchain program
    (see !9263)
    
    In particular, what used to be done at runtime is now as follows:
    * The flags -Wl,--no-as-needed for needed shared libs are configured
      into settings
    * The flag -fstack-check is configured into settings
    * The check for broken tables-next-to-code was outdated
    * We use the configured c compiler by default as the assembler program
    * We drop `asmOpts` because we already configure -Qunused-arguments flag
      into settings (see !10589)
    
    Fixes #23562
    
    Co-author: Rodrigo Mesquita (@alt-romes)
    
    - - - - -
    8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00
    Define FFI_GO_CLOSURES
    
    The libffi shipped with Apple's XCode toolchain does not contain a
    definition of the FFI_GO_CLOSURES macro, despite containing references
    to said macro. Work around this by defining the macro, following the
    model of a similar workaround in OpenJDK [1].
    
    [1] https://github.com/openjdk/jdk17u-dev/pull/741/files
    
    - - - - -
    d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00
    base: Fix incorrect CPP guard
    
    This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`.
    
    - - - - -
    7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00
    rts/Trace: Ensure that debugTrace arguments are used
    
    As debugTrace is a macro we must take care to ensure that
    the fact is clear to the compiler lest we see warnings.
    
    - - - - -
    cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00
    rts: Various warnings fixes
    
    - - - - -
    dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00
    hadrian: Ignore warnings in unix and semaphore-compat
    
    - - - - -
    d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00
    hadrian: Fix dependencies of docs:* rule
    
    For the docs:* rule we need to actually build the package rather than
    just the haddocks for the dependent packages. Therefore we depend on the
    .conf files of the packages we are trying to build documentation for as
    well as the .haddock files.
    
    Fixes #23472
    
    - - - - -
    cec90389 by sheaf at 2023-06-30T12:39:27-04:00
    Add tests for #22106
    
    Fixes #22106
    
    - - - - -
    083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00
    Add -fbreak-points to control breakpoint insertion
    
    Rather than statically enabling breakpoints only for the interpreter,
    this adds a new flag.
    
    Tracking ticket: #23057
    
    MR: !10466
    
    - - - - -
    fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-04:00
    rts: Ensure that pinned allocations respect block size
    
    Previously, it was possible for pinned, aligned allocation requests to
    allocate beyond the end of the pinned accumulator block. Specifically,
    we failed to account for the padding needed to achieve the requested
    alignment in the "large object" check. With large alignment requests,
    this can result in the allocator using the capability's pinned object
    accumulator block to service a request which is larger than
    `PINNED_EMPTY_SIZE`.
    
    To fix this we reorganize `allocatePinned` to consistently account for
    the alignment padding in all large object checks. This is a bit subtle
    as we must handle the case of a small allocation request filling the
    accumulator block, as well as large requests.
    
    Fixes #23400.
    
    - - - - -
    98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00
    testsuite: Add test for #23400
    
    - - - - -
    4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00
    ghc-heap: Support for BLOCKING_QUEUE closures
    
    - - - - -
    03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00
    Add some structured diagnostics in Tc/Validity.hs
    
    This addresses the work of ticket #20118
    Created the following constructors for TcRnMessage
     - TcRnInaccessibleCoAxBranch
     - TcRnPatersonCondFailure
    
    - - - - -
    6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00
    Add failing test case for #23492
    
    - - - - -
    356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
    Use generated src span for catch-all case of record selector functions
    
    This fixes #23492. The problem was that we used the real source span
    of the field declaration for the generated catch-all case in the
    selector function, in particular in the generated call to
    `recSelError`, which meant it was included in the HIE output. Using
    `generatedSrcSpan` instead means that it is not included.
    
    - - - - -
    3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
    Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils
    
    - - - - -
    dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
    Construct catch-all default case using helpers
    
    GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors
    
    - - - - -
    0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00
    Add regression test for #23549
    
    - - - - -
    32741743 by Alexis King at 2023-07-03T03:31:36-04:00
    perf tests: Increase default stack size for MultiLayerModules
    
    An unhelpfully small stack size appears to have been the real culprit
    behind the metric fluctuations in #19293. Debugging metric decreases
    triggered by !10729 helped to finally identify the problem.
    
    Metric Decrease:
        MultiLayerModules
        MultiLayerModulesTH_Make
        T13701
        T14697
    
    - - - - -
    82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00
    Add missing void prototypes to rts functions
    
    See #23561.
    
    - - - - -
    6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00
    gitlab-ci: Refactor compilation of gen_ci
    
    Flakify and document it, making it far less sensitive to the build
    environment.
    
    - - - - -
    aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00
    testsuite: Update documentation
    - - - - -
    924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00
    Better error for data deriving of type synonym/family. Closes #23522
    
    - - - - -
    4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00
    Fix some broken links and typos
    
    - - - - -
    de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00
    configure: Rip out Solaris dyld check
    
    Solaris 11 was released over a decade ago and, moreover, I doubt we have
    any Solaris users
    
    - - - - -
    59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00
    CI: add JS release and debug builds, regen CI jobs
    
    - - - - -
    679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00
    testsuite: Do not require CUSKs
    
    Numerous tests make use of CUSKs (complete user-supplied kinds),
    a legacy feature scheduled for deprecation. In order to proceed
    with the said deprecation, the tests have been updated to use SAKS
    instead (standalone kind signatures).
    
    This also allows us to remove the Haskell2010 language pragmas that
    were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021.
    
    - - - - -
    945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00
    gitlab: Drop backport-for-8.8 MR template
    
    Its usefulness has long passed.
    - - - - -
    66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00
    EPA: Simplify GHC/Parser.y comb2
    
    Use the HasLoc instance from Ast.hs to allow comb2 to work with
    anything with a SrcSpan
    
    This gets rid of the custom comb2A, comb2Al, comb2N functions, and
    removes various reLoc calls.
    
    - - - - -
    2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00
    Fix deprecation warning when deprecated identifier is from another module
    
    A stray 'Just' was being printed in the deprecation message.
    
    Fixes #23573
    
    - - - - -
    46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00
    rts: Don't rely on initializers for sigaction_t
    
    As noted in #23577, CentOS's ancient toolchain throws spurious
    missing-field-initializer warnings.
    
    - - - - -
    ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00
    hadrian: Don't treat -Winline warnings as fatal
    
    Such warnings are highly dependent upon the toolchain, platform, and
    build configuration. It's simply too fragile to rely on these.
    
    - - - - -
    3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00
    hadrian: Only pass -Wno-nonportable-include-path on Darwin
    
    This flag, which was introduced due to #17798, is only understood by
    Clang and consequently throws warnings on platforms using gcc. Sadly,
    there is no good way to treat such warnings as non-fatal with `-Werror`
    so for now we simply make this flag specific to platforms known to use
    Clang and case-insensitive filesystems (Darwin and Windows).
    
    See #23577.
    
    - - - - -
    4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00
    Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals
    
    - - - - -
    2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00
    compiler: Make OccSet opaque
    
    - - - - -
    cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00
    Add Note about why we need forall in Code to be on the right
    
    - - - - -
    fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00
    Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall.
    - - - - -
    9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00
    Improve the situation with the stimes cycle
    
    Currently the Semigroup stimes cycle is resolved in GHC.Base by
    importing stimes implementations from a hs-boot file. Resolve the cycle
    using hs-boot files for required classes (Num, Integral) instead. Now
    stimes can be defined directly in GHC.Base, making inlining and
    specialization possible.
    
    This leads to some new boot files for `GHC.Num` and `GHC.Real`, the
    methods for those are only used to implement `stimes` so it doesn't
    appear that these boot files will introduce any new performance traps.
    
    Metric Decrease:
        T13386
        T8095
    Metric Increase:
        T13253
        T13386
        T18698a
        T18698b
        T19695
        T8095
    
    - - - - -
    9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00
    Refactor Unique to be represented by Word64
    
    In #22010 we established that Int was not always sufficient to store all
    the uniques we generate during compilation on 32-bit platforms. This
    commit addresses that problem by using Word64 instead of Int for
    uniques.
    
    The core of the change is in GHC.Core.Types.Unique and
    GHC.Core.Types.Unique.Supply. However, the representation of uniques is
    used in many other places, so those needed changes too. Additionally, the RTS
    has been extended with an atomic_inc64 operation.
    
    One major change from this commit is the introduction of the Word64Set and
    Word64Map data types. These are adapted versions of IntSet and IntMap
    from the containers package. These are planned to be upstreamed in the
    future.
    
    As a natural consequence of these changes, the compiler will be a bit
    slower and take more space on 32-bit platforms. Our CI tests indicate
    around a 5% residency increase.
    
    Metric Increase:
        CoOpt_Read
        CoOpt_Singletons
        LargeRecord
        ManyAlternatives
        ManyConstructors
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModulesTH_OneShot
        RecordUpdPerf
        T10421
        T10547
        T12150
        T12227
        T12234
        T12425
        T12707
        T13035
        T13056
        T13253
        T13253-spj
        T13379
        T13386
        T13719
        T14683
        T14697
        T14766
        T15164
        T15703
        T16577
        T16875
        T17516
        T18140
        T18223
        T18282
        T18304
        T18698a
        T18698b
        T18923
        T1969
        T19695
        T20049
        T21839c
        T3064
        T3294
        T4801
        T5030
        T5321FD
        T5321Fun
        T5631
        T5642
        T5837
        T6048
        T783
        T8095
        T9020
        T9198
        T9233
        T9630
        T9675
        T9872a
        T9872b
        T9872b_defer
        T9872c
        T9872d
        T9961
        TcPlugin_RewritePerf
        UniqLoop
        WWRec
        hard_hole_fits
    
    - - - - -
    6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00
    Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro
    - - - - -
    40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00
    Substitute free variables captured by breakpoints in SpecConstr
    
    Fixes #23267
    
    - - - - -
    2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00
    Reinstate untouchable variable error messages
    
    This extra bit of information was accidentally being discarded after
    a refactoring of the way we reported problems when unifying a type
    variable with another type. This patch rectifies that.
    
    - - - - -
    53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00
    configure: Drop Clang command from settings
    
    Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the
    `runClang` function, and no longer need to configure into settings the
    Clang command. We used to determine options at runtime to pass clang when
    it was used as an assembler, but now that we configure at configure time
    we no longer need to.
    
    - - - - -
    6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00
    Filter out nontrivial substituted expressions in substTickish
    
    Fixes #23272
    
    - - - - -
    41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00
    JS: testsuite: use req_c predicate instead of js_broken
    
    - - - - -
    74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00
    JS: implement some file primitives (lstat,rmdir) (#22374)
    
    - Implement lstat and rmdir.
    - Implement base_c_s_is* functions (testing a file type)
    - Enable passing tests
    
    - - - - -
    7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00
    JS: cleanup utils (#23314)
    
    - Removed unused code
    - Don't export unused functions
    - Move toTypeList to Closure module
    
    - - - - -
    f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00
    JS: rename VarType/Vt into JSRep
    
    - - - - -
    19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00
    JS: remove custom PrimRep conversion (#23314)
    
    We use the usual conversion to PrimRep and then we convert these
    PrimReps to JSReps.
    
    - - - - -
    d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00
    JS: don't use isRuntimeRepKindedTy in JS FFI
    
    - - - - -
    8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00
    ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file
    
    Fixes #23600
    
    - - - - -
    e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00
    ghcup-metadata: Use dynamically linked alpine bindists
    
    In theory these will work much better on alpine to allow people to build
    statically linked applications there. We don't need to distribute a
    statically linked application ourselves in order to allow that.
    
    Fixes #23602
    
    - - - - -
    b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00
    Drop circle-ci-job.sh
    
    - - - - -
    9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00
    testsuite: Allow preservation of unexpected output
    
    Here we introduce a new flag to the testsuite driver,
    --unexpected-output-dir=<dir>, which allows the user to ask
    the driver to preserve unexpected output from tests. The intent is for
    this to be used in CI to allow users to more easily fix unexpected
    platform-dependent output.
    
    - - - - -
    48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00
    gitlab-ci: Preserve unexpected output
    
    Here we enable use of the testsuite driver's `--unexpected-output-dir`
    flag by CI, preserving the result as an artifact for use by users.
    
    - - - - -
    76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00
    driver: Fix -S with .cmm files
    
    There was an oversight in the driver which assumed that you would always
    produce a `.o` file when compiling a .cmm file.
    
    Fixes #23610
    
    - - - - -
    6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00
    Update Hadrian's stack.yaml
    - - - - -
    1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00
    compiler: Rework ShowSome
    
    Previously the field used to filter the sub-declarations to show
    was rather ad-hoc and was only able to show at most one sub-declaration.
    
    - - - - -
    8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00
    testsuite: Add test to catch changes in core libraries
    
    This adds testing infrastructure to ensure that changes in core
    libraries (e.g. `base` and `ghc-prim`) are caught in CI.
    
    - - - - -
    ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00
    Deprecate Data.List.NonEmpty.unzip
    
    - - - - -
    5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00
    Drop latent mentions of -split-objs
    
    Closes #21134.
    
    - - - - -
    a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00
    Add warn_and_run test kind
    
    This is a compile_and_run variant which also captures the GHC's
    stderr. The warn_and_run name is best I can come up with,
    as compile_and_run is taken.
    
    This is useful specifically for testing warnings.  We want to test that
    when warning triggers, and it's not a false positive, i.e. that the
    runtime behaviour is indeed "incorrect".
    
    As an example a single test is altered to use warn_and_run
    
    - - - - -
    c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00
    configure: Don't use ld.gold on i386
    
    ld.gold appears to produce invalid static constructor tables on i386.
    While ideally we would add an autoconf check to check for this
    brokenness, sadly such a check isn't easy to compose. Instead to
    summarily reject such linkers on i386.
    
    Somewhat hackily closes #23579.
    
    - - - - -
    054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00
    Add since annotations for Data.Foldable1
    
    - - - - -
    550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00
    JS: support -this-unit-id for programs in the linker (#23613)
    
    - - - - -
    d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00
    Bump text submodule
    
    - - - - -
    8e11630e by jade at 2023-07-10T16:58:40-04:00
    Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007)
    
    As suggested in #20007 and implemented in !8895, trying to import type operators
    will suggest a fix to use the 'type' keyword, without considering whether
    ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces
    is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled,
    alongside the suggestion of adding the 'type' keyword.
    
    - - - - -
    61b1932e by sheaf at 2023-07-10T16:59:26-04:00
    tyThingLocalGREs: include all DataCons for RecFlds
    
    The GREInfo for a record field should include the collection of all
    the data constructors of the parent TyCon that have this record field.
    This information was being incorrectly computed in the tyThingLocalGREs
    function for a DataCon, as we were not taking into account other
    DataCons with the same parent TyCon.
    
    Fixes #23546
    
    - - - - -
    e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00
    EPA: Simplify GHC/Parser.y comb3
    
    A follow up to !10743
    
    - - - - -
    ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00
    Document that compareByteArrays# is available since ghc-prim-0.5.2.0
    
    - - - - -
    4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00
    Revert "Bump text submodule"
    
    This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a.
    
    This commit requires that we bootstrap with ghc-9.4, which we do not
    require until #23195 has been completed.
    
    Subsequently this has broken nighty jobs such as the rocky8 job which in
    turn has broken nightly releases.
    
    - - - - -
    d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00
    compiler: Fingerprint more code generation flags
    
    Previously our recompilation check was quite inconsistent in its
    coverage of non-optimisation code generation flags. Specifically, we
    failed to account for most flags that would affect the behavior of
    generated code in ways that might affect the result of a program's
    execution (e.g. `-feager-blackholing`, `-fstrict-dicts`)
    
    Closes #23369.
    
    - - - - -
    eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00
    compiler: Record original thunk info tables on stack
    
    Here we introduce a new code generation option, `-forig-thunk-info`,
    which ensures that an `stg_orig_thunk_info` frame is pushed before every
    update frame. This can be invaluable when debugging thunk cycles and
    similar.
    
    See Note [Original thunk info table frames] for details.
    
    Closes #23255.
    
    - - - - -
    4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00
    Fix wrong MIN_VERSION_GLASGOW_HASKELL macros
    
    I forgot to change these after rebasing.
    
    - - - - -
    dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00
    Hadrian: enable GHCi support on riscv64
    
    - - - - -
    09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00
    JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628)
    
    - - - - -
    29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00
    Remove references to make build system in mk/build.mk
    
    Fixes #23636
    
    - - - - -
    630e3026 by sheaf at 2023-07-12T11:26:43-04:00
    Valid hole fits: don't panic on a Given
    
    The function GHC.Tc.Errors.validHoleFits would end up panicking when
    encountering a Given constraint. To fix this, it suffices to filter out
    the Givens before continuing.
    
    Fixes #22684
    
    - - - - -
    c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00
    Use deb10 for i386 bindists
    
    deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10
    
    Fixes #23585
    
    - - - - -
    bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00
    Fix #23567, a specializer bug
    
    Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834
    
    The testcase isn't ideal because it doesn't detect the bug in master,
    unless doNotUnbox is removed as in
    https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692.
    But I have confirmed that with that modification, it fails before
    and passes afterwards.
    
    - - - - -
    84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
    Comments
    
    - - - - -
    b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
    updates to comments
    
    - - - - -
    2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
    changes
    
    - - - - -
    6143838a by sheaf at 2023-07-13T08:02:17-04:00
    Fix deprecation of record fields
    
    Commit 3f374399 inadvertently broke the deprecation/warning mechanism
    for record fields due to its introduction of record field namespaces.
    
    This patch ensures that, when a top-level deprecation is applied to
    an identifier, it applies to all the record fields as well.
    This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and
    GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of
    NameSpaces but to look up all NameSpaces and filter out the irrelevant
    ones.
    
    - - - - -
    6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00
    Introduce greInfo, greParent
    
    These are simple helper functions that wrap the internal
    field names gre_info, gre_par.
    
    - - - - -
    7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00
    Refactor lookupGRE_... functions
    
    This commit consolidates all the logic for looking up something in
    the Global Reader Environment into the single function lookupGRE.
    This allows us to declaratively specify all the different modes of
    looking up in the GlobalRdrEnv, and avoids manually passing around
    filtering functions as was the case in e.g. the function
    GHC.Rename.Env.lookupSubBndrOcc_helper.
    
    -------------------------
    Metric Decrease:
        T8095
    -------------------------
    -------------------------
    Metric Increase:
        T8095
    -------------------------
    
    - - - - -
    5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00
    configure: Drop DllWrap command
    
    We used to configure into settings a DllWrap command for windows
    builds and distributions, however, we no longer do, and dllwrap is
    effectively unused.
    
    This simplification is motivated in part by the larger
    toolchain-selection project (#19877, !9263)
    
    - - - - -
    e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00
    base: fix haddock syntax in GHC.Profiling
    
    - - - - -
    0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00
    Revert "CI: add JS release and debug builds, regen CI jobs"
    
    This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af.
    
    This commit added two duplicate jobs on all validate pipelines, so we
    are reverting for now whilst we work out what the best way forward is.
    
    Ticket #23618
    
    - - - - -
    54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00
    EPA: Simplify GHC/Parser.y sLL
    
    Follow up to !10743
    
    - - - - -
    c8863828 by sheaf at 2023-07-15T03:24:06-04:00
    Configure: canonicalise PythonCmd on Windows
    
    This change makes PythonCmd resolve to a canonical absolute path on
    Windows, which prevents HLS getting confused (now that we have a
    build-time dependency on python).
    
    fixes #23652
    
    - - - - -
    ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00
    Improve Note [Binder-swap during float-out]
    
    - - - - -
    cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00
    Equality of forall-types is visibility aware
    
    This patch finally (I hope) nails the question of whether
       (forall a. ty) and (forall a -> ty)
    are `eqType`: they aren't!
    
    There is a long discussion in #22762, plus useful Notes:
    
    * Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare
    * Note [Comparing visiblities] in GHC.Core.TyCo.Compare
    * Note [ForAllCo] in GHC.Core.TyCo.Rep
    
    It also establishes a helpful new invariant for ForAllCo,
    and ForAllTy, when the bound variable is a CoVar:in that
    case the visibility must be coreTyLamForAllTyFlag.
    
    All this is well documented in revised Notes.
    
    - - - - -
    7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00
    List and Tuple<n>: update documentation
    
    Add the missing changelog.md entries and @since-annotations.
    
    - - - - -
    2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00
    Type patterns (#22478, #18986)
    
    Improved name resolution and type checking of type patterns in constructors:
    
    1. HsTyPat: a new dedicated data type that represents type patterns in
       HsConPatDetails instead of reusing HsPatSigType
    
    2. rnHsTyPat: a new function that renames a type
       pattern and collects its binders into three groups:
        - explicitly bound type variables, excluding locally bound
          variables
        - implicitly bound type variables from kind signatures
          (only if ScopedTypeVariables are enabled)
        - named wildcards (only from kind signatures)
    2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat
    2b. rnImplcitTvBndrs: removed because no longer needed
    
    3. collect_pat: updated to collect type variable binders from type patterns
       (this means that types and terms use the same infrastructure to detect
       conflicting bindings, unused variables and name shadowing)
    3a. CollVarTyVarBinders: a new CollectFlag constructor that enables
        collection of type variables
    
    4. tcHsTyPat: a new function that typechecks type patterns, capable of
       handling polymorphic kinds.
       See Note [Type patterns: binders and unifiers]
    
    Examples of code that is now accepted:
    
       f = \(P @a) -> \(P @a) -> ...  -- triggers -Wname-shadowing
    
       g :: forall a. Proxy a -> ...
       g (P @a) = ...                 -- also triggers -Wname-shadowing
    
       h (P @($(TH.varT (TH.mkName "t")))) = ...
                                      -- t is bound at splice time
    
       j (P @(a :: (x,x))) = ...      -- (x,x) is no longer rejected
    
       data T where
         MkT :: forall (f :: forall k. k -> Type).
           f Int -> f Maybe -> T
       k :: T -> ()
       k (MkT @f (x :: f Int) (y :: f Maybe)) = ()
                                      -- f :: forall k. k -> Type
    
    Examples of code that is rejected with better error messages:
    
      f (Left @a @a _) = ...
      -- new message:
      --     • Conflicting definitions for ‘a’
      --       Bound at: Test.hs:1:11
      --                 Test.hs:1:14
    
    Examples of code that is now rejected:
    
      {-# OPTIONS_GHC -Werror=unused-matches #-}
      f (P @a) = ()
      -- Defined but not used: type variable ‘a’
    
    - - - - -
    eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00
    Don't use substTyUnchecked in newMetaTyVar
    
    There were some comments that explained that we needed to use an
    unchecked substitution function because of issue #12931, but that
    has since been fixed, so we should be able to use substTy instead now.
    
    - - - - -
    c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00
    rnImports: var shouldn't import NoFldSelectors
    
    In an import declaration such as
    
      import M ( var )
    
    the import of the variable "var" should **not** bring into scope record
    fields named "var" which are defined with NoFieldSelectors.
    Doing so can cause spurious "unused import" warnings, as reported in
    ticket #23557.
    
    Fixes #23557
    
    - - - - -
    1af2e773 by sheaf at 2023-07-17T02:48:19-04:00
    Suggest similar names in imports
    
    This commit adds similar name suggestions when importing. For example
    
      module A where { spelling = 'o' }
      module B where { import B ( speling ) }
    
    will give rise to the error message:
    
      Module ‘A’ does not export ‘speling’.
      Suggested fix: Perhaps use ‘spelling’
    
    This also provides hints when users try to import record fields defined
    with NoFieldSelectors.
    
    - - - - -
    654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00
    EPA: Store leading AnnSemi for decllist in al_rest
    
    This simplifies the markAnnListA implementation in ExactPrint
    
    - - - - -
    22565506 by sheaf at 2023-07-17T21:12:59-04:00
    base: add COMPLETE pragma to BufferCodec PatSyn
    
    This implements CLC proposal #178, rectifying an oversight in the
    implementation of CLC proposal #134 which could lead to spurious
    pattern match warnings.
    
    https://github.com/haskell/core-libraries-committee/issues/178
    https://github.com/haskell/core-libraries-committee/issues/134
    
    - - - - -
    860f6269 by sheaf at 2023-07-17T21:13:00-04:00
    exactprint: silence incomplete record update warnings
    
    - - - - -
    df706de3 by sheaf at 2023-07-17T21:13:00-04:00
    Re-instate -Wincomplete-record-updates
    
    Commit e74fc066 refactored the handling of record updates to use
    the HsExpanded mechanism. This meant that the pattern matching inherent
    to a record update was considered to be "generated code", and thus we
    stopped emitting "incomplete record update" warnings entirely.
    
    This commit changes the "data Origin = Source | Generated" datatype,
    adding a field to the Generated constructor to indicate whether we
    still want to perform pattern-match checking. We also have to do a bit
    of plumbing with HsCase, to record that the HsCase arose from an
    HsExpansion of a RecUpd, so that the error message continues to mention
    record updates as opposed to a generic "incomplete pattern matches in case"
    error.
    
    Finally, this patch also changes the way we handle inaccessible code
    warnings. Commit e74fc066 was also a regression in this regard, as we
    were emitting "inaccessible code" warnings for case statements spuriously
    generated when desugaring a record update (remember: the desugaring mechanism
    happens before typechecking; it thus can't take into account e.g. GADT information
    in order to decide which constructors to include in the RHS of the desugaring
    of the record update).
    We fix this by changing the mechanism through which we disable inaccessible
    code warnings: we now check whether we are in generated code in
    GHC.Tc.Utils.TcMType.newImplication in order to determine whether to
    emit inaccessible code warnings.
    
    Fixes #23520
    Updates haddock submodule, to avoid incomplete record update warnings
    
    - - - - -
    1d05971e by sheaf at 2023-07-17T21:13:00-04:00
    Propagate long-distance information in do-notation
    
    The preceding commit re-enabled pattern-match checking inside record
    updates. This revealed that #21360 was in fact NOT fixed by e74fc066.
    
    This commit makes sure we correctly propagate long-distance information
    in do blocks, e.g. in
    
    ```haskell
    data T = A { fld :: Int } | B
    
    f :: T -> Maybe T
    f r = do
      a at A{} <- Just r
      Just $ case a of { A _ -> A 9 }
    ```
    
    we need to propagate the fact that "a" is headed by the constructor "A"
    to see that the case expression "case a of { A _ -> A 9 }" cannot fail.
    
    Fixes #21360
    
    - - - - -
    bea0e323 by sheaf at 2023-07-17T21:13:00-04:00
    Skip PMC for boring patterns
    
    Some patterns introduce no new information to the pattern-match
    checker (such as plain variable or wildcard patterns). We can thus
    skip doing any pattern-match checking on them when the sole purpose
    for doing so was introducing new long-distance information.
    
    See Note [Boring patterns] in GHC.Hs.Pat.
    
    Doing this avoids regressing in performance now that we do additional
    pattern-match checking inside do notation.
    
    - - - - -
    ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00
    Split GHC.Platform.ArchOS from ghc-boot into ghc-platform
    
    Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package
    into this reinstallable standalone package which abides by the PVP, in
    part motivated by the ongoing work on `ghc-toolchain` towards runtime
    retargetability.
    
    - - - - -
    b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00
    JS: better implementation for plusWord64 (#23597)
    
    - - - - -
    889c2bbb by sheaf at 2023-07-18T06:37:32-04:00
    Do primop rep-poly checks when instantiating
    
    This patch changes how we perform representation-polymorphism checking
    for primops (and other wired-in Ids such as coerce).
    When instantiating the primop, we check whether each type variable
    is required to instantiated to a concrete type, and if so we create a
    new concrete metavariable (a ConcreteTv) instead of a simple MetaTv.
    (A little subtlety is the need to apply the substitution obtained from
    instantiating to the ConcreteTvOrigins, see
    Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.)
    
    This allows us to prevent representation-polymorphism in non-argument
    position, as that is required for some of these primops.
    
    We can also remove the logic in tcRemainingValArgs, except for
    the part concerning representation-polymorphic unlifted newtypes.
    The function has been renamed rejectRepPolyNewtypes; all it does now
    is reject unsaturated occurrences of representation-polymorphic newtype
    constructors when the representation of its argument isn't a concrete
    RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check).
    The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head
    gives more explanation about a possible path to PHASE 2, which would be
    in line with the treatment for primops taken in this patch.
    
    We also update the Core Lint check to handle this new framework. This
    means Core Lint now checks representation-polymorphism in continuation
    position like needed for catch#.
    
    Fixes #21906
    
    -------------------------
    Metric Increase:
        LargeRecord
    -------------------------
    
    - - - - -
    00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00
    Core Lint: distinguish let and letrec in locations
    
    Lint messages were saying "in the body of letrec" even for non-recursive
    let.
    
    I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no
    separate letrec.
    
    - - - - -
    787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00
    Use extended literals when deriving Show
    
    This implements GHC proposal
    https://github.com/ghc-proposals/ghc-proposals/pull/596
    
    Also add support for Int64# and Word64#; see testcase ShowPrim.
    
    - - - - -
    257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00
    Add StgFromCore and StgCodeGen linting
    
    - - - - -
    34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00
    Reg.Liveness: Strictness
    
    - - - - -
    c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00
    Reg.Liveness: Don't repeatedly construct UniqSets
    
    - - - - -
    b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00
    compiler/Types: Ensure that fromList-type operations can fuse
    
    In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing
    it to do so makes a considerable difference in allocations due to the
    backend.
    
    Metric Decrease:
        T12707
        T13379
        T3294
        T4801
        T5321FD
        T5321Fun
        T783
    
    - - - - -
    6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00
    x86 Codegen: Implement MO_S_MulMayOflo for W16
    
    - - - - -
    5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00
    x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64
    
    It's useful to see which value made the pattern match fail. (If it ever
    occurs.)
    
    - - - - -
    e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00
    x86 CodeGen: Implement MO_S_MulMayOflo for W8
    
    This case wasn't handled before. But, the test-primops test suite showed
    that it actually might appear.
    
    - - - - -
    a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00
    Add test for %mulmayoflo primop
    
    The test expects a perfect implementation with no false positives.
    
    - - - - -
    38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00
    lint-ci-config: Generate jobs-metadata.json
    
    We also now save the jobs-metadata.json and jobs.yaml file as artifacts
    as:
    
    * It might be useful for someone who is modifying CI to copy jobs.yaml
      if they are having trouble regenerating locally.
    * jobs-metadata.json is very useful for downstream pipelines to work out
      the right job to download.
    
    Fixes #23654
    
    - - - - -
    1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00
    Initialize 9.10.1-notes.rst
    
    Create new release notes for the next GHC release (GHC 9.10)
    
    - - - - -
    3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00
    Prioritise Parent when looking up class sub-binder
    
    When we look up children GlobalRdrElts of a given Parent, we sometimes
    would rather prioritise those GlobalRdrElts which have the right Parent,
    and sometimes prioritise those that have the right NameSpace:
    
      - in export lists, we should prioritise NameSpace
      - for class/instance binders, we should prioritise Parent
    
    See Note [childGREPriority] in GHC.Types.Name.Reader.
    
    fixes #23664
    
    - - - - -
    9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00
    EPA: Improve annotation management in getMonoBind
    
    Ensure the LHsDecl for a FunBind has the correct leading comments and
    trailing annotations.
    
    See the added note for details.
    
    - - - - -
    ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00
    Remove unused files in .gitlab
    
    These were left over after 6078b429
    
    - - - - -
    29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00
    gen_ci: Add hie.yaml file
    
    This allows you to load `gen_ci.hs` into HLS, and now it is a huge
    module, that is quite useful.
    
    - - - - -
    808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00
    ci: Make "fast-ci" the default validate configuration
    
    We are trying out a lighter weight validation pipeline where by default
    we just test on 5 platforms:
    
    * x86_64-deb10-slow-validate
    * windows
    * x86_64-fedora33-release
    * aarch64-darwin
    * aarch64-linux-deb10
    
    In order to enable the "full" validation pipeline you can apply the
    `full-ci` label which will enable all the validation pipelines.
    
    All the validation jobs are still run on a marge batch.
    
    The goal is to reduce the overall CI capacity so that pipelines start
    faster for MRs and marge bot batches are faster.
    
    Fixes #23694
    
    - - - - -
    0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00
    EPA: Simplify GHC/Parser.y sL1
    
    This is the next patch in a series simplifying location management in
    GHC/Parser.y
    
    This one simplifies sL1, to use the HasLoc instances introduced in
    !10743 (closed)
    
    - - - - -
    3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00
    nativeGen: Explicitly set flags of text sections on Windows
    
    The binutils documentation (for COFF) claims,
    
    > If no flags are specified, the default flags depend upon the section
    > name. If the section name is not recognized, the default will be for the
    > section to be loaded and writable.
    
    We previously assumed that this would do the right thing for split
    sections (e.g. a section named `.text$foo` would be correctly inferred
    to be a text section). However, we have observed that this is not the
    case (at least under the clang toolchain used on Windows): when
    split-sections is enabled, text sections are treated by the assembler as
    data (matching the "default" behavior specified by the documentation).
    
    Avoid this by setting section flags explicitly. This should fix split
    sections on Windows.
    
    Fixes #22834.
    
    - - - - -
    db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00
    nativeGen: Set explicit section types on all platforms
    
    - - - - -
    b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00
    Insert documentation into parsed signature modules
    
    Causes haddock comments in signature modules to be properly
    inserted into the AST (just as they are for regular modules)
    if the `-haddock` flag is given.
    
    Also adds a test that compares `-ddump-parsed-ast` output
    for a signature module to prevent further regressions.
    
    Fixes #23315
    
    - - - - -
    c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00
    primops: Introduce unsafeThawByteArray#
    
    This addresses an odd asymmetry in the ByteArray# primops, which
    previously provided unsafeFreezeByteArray# but no corresponding
    thaw operation.
    
    Closes #22710
    
    - - - - -
    87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00
    testsuite: Elaborate in interface stability README
    
    This discussion didn't make it into the original MR.
    
    - - - - -
    e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00
    Allow users to override non-essential haddock options in a Flavour
    
    We now supply the non-essential options to haddock using the `extraArgs`
    field, which can be specified in a Flavour so that if an advanced user
    wants to change how documentation is generated then they can use
    something other than the `defaultHaddockExtraArgs`.
    
    This does have the potential to regress some packaging if a user has
    overridden `extraArgs` themselves, because now they also need to add
    the haddock options to extraArgs. This can easily be done by appending
    `defaultHaddockExtraArgs` to their extraArgs invocation but someone
    might not notice this behaviour has changed.
    
    In any case, I think passing the non-essential options in this manner is
    the right thing to do and matches what we do for the "ghc" builder,
    which by default doesn't pass any optmisation levels, and would likewise
    be very bad if someone didn't pass suitable `-O` levels for builds.
    
    Fixes #23625
    
    - - - - -
    fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00
    ghc-prim: Link against libatomic
    
    Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures.
    Unfortunately this made GHC to fail to build on armel, since armel needs
    libatomic to support atomic operations on 64-bit word sizes.
    
    Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic,
    the same way as we do in rts/rts.cabal.
    
    - - - - -
    4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00
    simplifier: Correct InScopeSet in rule matching
    
    The in-scope set passedto the `exprIsLambda_maybe` call lacked all the
    in-scope binders. @simonpj suggests this fix where we augment the
    in-scope set with the free variables of expression which fixes this
    failure mode in quite a direct way.
    
    Fixes #23630
    
    - - - - -
    5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00
    Add a test for #23413
    
    It was fixed by commit e1590ddc661d6: Add the SolverStage monad.
    
    - - - - -
    7e05f6df by sheaf at 2023-07-21T23:26:56-04:00
    Finish migration of diagnostics in GHC.Tc.Validity
    
    This patch finishes migrating the error messages in GHC.Tc.Validity
    to use the new diagnostic infrastructure.
    
    It also refactors the error message datatypes for class and family
    instances, to common them up under a single datatype as much as possible.
    
    - - - - -
    4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00
    ci: Enable some more jobs to run in a marge batch
    
    In !10907 I made the majority of jobs not run on a validate pipeline but
    then forgot to renable a select few jobs on the marge batch MR.
    
    - - - - -
    026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00
    user_guide/flags.py: python-3.12 no longer includes distutils
    
    packaging.version seems able to handle this fine
    
    - - - - -
    b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00
    ci: Mention ~full-ci label in MR template
    
    We mention that if you need a full validation pipeline then you can
    apply the ~full-ci label to your MR in order to test against the full
    validation pipeline (like we do for marge).
    
    - - - - -
    42b05e9b by sheaf at 2023-07-22T12:36:00-04:00
    RTS: declare setKeepCAFs symbol
    
    Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on
    the symbol setKeepCAFs in the RTS, which led to undefined symbol errors
    on Windows, as exhibited by the testcase frontend001.
    
    Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix.
    
    Fixes #22961
    
    - - - - -
    a72015d6 by sheaf at 2023-07-22T12:36:01-04:00
    Mark plugins-external as broken on Windows
    
    This test is broken on Windows, so we explicitly mark it as such now
    that we stop skipping plugin tests on Windows.
    
    - - - - -
    cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00
    Stop marking plugin tests as fragile on Windows
    
    Now that b2bb3e62 has landed we are in a better situation with
    regards to plugins on Windows, allowing us to unmark many plugin tests
    as fragile.
    
    Fixes #16405
    
    - - - - -
    a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00
    Misc cleanup
    
    - Remove unused RDR names
    - Fix typos in comments
    - Deriving: simplify boxConTbl and remove unused litConTbl
    - chmod -x GHC/Exts.hs, this seems accidental
    
    - - - - -
    33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00
    Visible forall in types of terms: Part 1 (#22326)
    
    This patch implements part 1 of GHC Proposal #281,
    introducing explicit `type` patterns and `type` arguments.
    
    Summary of the changes:
    
    1. New extension flag:
         RequiredTypeArguments
    
    2. New user-facing syntax:
         `type p` patterns    (represented by EmbTyPat)
         `type e` expressions (represented by HsEmbTy)
    
    3. Functions with required type arguments (visible forall)
       can now be defined and applied:
          idv :: forall a -> a -> a    -- signature   (relevant change: checkVdqOK in GHC/Tc/Validity.hs)
          idv (type a) (x :: a) = x    -- definition  (relevant change: tcPats in GHC/Tc/Gen/Pat.hs)
          x = idv (type Int) 42        -- usage       (relevant change: tcInstFun in GHC/Tc/Gen/App.hs)
    
    4. template-haskell support:
          TH.TypeE corresponds to HsEmbTy
          TH.TypeP corresponds to EmbTyPat
    
    5. Test cases and a new User's Guide section
    
    Changes *not* included here are the t2t (term-to-type) transformation
    and term variable capture; those belong to part 2.
    
    - - - - -
    73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00
    Add test for #22424
    
    This is a simple Template Haskell test in which we refer to
    record selectors by their exact Names, in two different ways.
    
    Fixes #22424
    
    - - - - -
    83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00
    ghc-toolchain: Initial commit
    
    - - - - -
    31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
    ghc-toolchain: Toolchain Selection
    
    This commit integrates ghc-toolchain, the brand new way of configuring
    toolchains for GHC, with the Hadrian build system, with configure, and
    extends and improves the first iteration of ghc-toolchain.
    
    The general overview is
    
    * We introduce a program invoked `ghc-toolchain --triple=...` which, when run,
      produces a file with a `Target`. A `GHC.Toolchain.Target.Target`
      describes the properties of a target and the toolchain (executables
      and configured flags) to produce code for that target
    
    * Hadrian was modified to read Target files, and will both
      * Invoke the toolchain configured in the Target file as needed
      * Produce a `settings` file for GHC based on the Target file for that stage
    
    * `./configure` will invoke ghc-toolchain to generate target files, but
      it will also generate target files based on the flags configure itself
      configured (through `.in` files that are substituted)
    
      * By default, the Targets generated by configure are still (for now) the ones used by Hadrian
    
      * But we additionally validate the Target files generated by
        ghc-toolchain against the ones generated by configure, to get a head
        start on catching configuration bugs before we transition
        completely.
    
      * When we make that transition, we will want to drop a lot of the
        toolchain configuration logic from configure, but keep it otherwise.
    
    * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine)
      * We just have a HOST target file, which we use as the target for stage0
      * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling)
      * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST
      * (for more details on cross-compilation see discussion on !9263)
    
    See also
    * Note [How we configure the bundled windows toolchain]
    * Note [ghc-toolchain consistency checking]
    * Note [ghc-toolchain overview]
    
    Ticket: #19877
    MR: !9263
    
    - - - - -
    a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
    Add flag to enable/disable ghc-toolchain based configurations
    
    This flag is disabled by default, and we'll use the
    configure-generated-toolchains by default until we remove the toolchain
    configuration logic from configure.
    
    - - - - -
    61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
    Split ghc-toolchain executable to new packge
    
    In light of #23690, we split the ghc-toolchain executable out of the
    library package to be able to ship it in the bindist using Hadrian.
    
    Ideally, we eventually revert this commit.
    
    - - - - -
    38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
    Ship ghc-toolchain in the bindist
    
    Add the ghc-toolchain binary to the binary distribution we ship to
    users, and teach the bindist configure to use the existing ghc-toolchain.
    
    - - - - -
    32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00
    Kill off gen_bytearray_addr_access_ops.py
    
    The relevant primop descriptions are now
    generated directly by genprimopcode.
    
    This makes progress toward fixing #23490, but it is not
    a complete fix since there is more than one way in which
    cabal-reinstall (hadrian/build build-cabal) is broken.
    
    - - - - -
    02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00
    compiler: Remove unused `containers.h` include
    
    Fixes #23712
    
    - - - - -
    822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00
    Fix pretty printing of WARNING pragmas
    
    There is still something quite unsavoury going on with WARNING pragma
    printing because the printing relies on the fact that for decl
    deprecations the SourceText of WarningTxt is empty. However, I let that
    lion sleep and just fixed things directly.
    
    Fixes #23465
    
    - - - - -
    e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00
    ci-images: Bump to commit which has 9.6 image
    
    The test-bootstrap job has been failing for 9.6 because we accidentally
    used a non-master commit.
    
    - - - - -
    bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00
    Update bootstrap plans for 9.6.2 and 9.4.5
    
    - - - - -
    355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00
    EPA: Simplify GHC/Parser.y comb4/comb5
    
    Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with
    anything with a SrcSpan
    
    Also get rid of some more now unnecessary reLoc calls.
    
    - - - - -
    9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00
    compiler: make -ddump-asm work with wasm backend NCG
    
    Fixes #23503.
    
    Now the `-ddump-asm` flag is respected in the wasm backend
    NCG, so developers can directly view the generated ASM instead of
    needing to pass `-S` or `-keep-tmp-files` and manually find & open
    the assembly file.
    
    Ideally, we should be able to output the assembly files in smaller
    chunks like in other NCG backends. This would also make dumping assembly
    stats easier. However, this would require a large refactoring, so for
    short-term debugging purposes I think the current approach works fine.
    
    Signed-off-by: Gavin Zhao <git at gzgz.dev>
    
    - - - - -
    79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00
    llvm: Restore accidentally deleted code in 0fc5cb97
    
    Fixes #23711
    
    - - - - -
    20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00
    configure: Default missing options to False when preparing ghc-toolchain Targets
    
    This commit fixes building ghc with 9.2 as the boostrap compiler.
    
    The ghc-toolchain patch assumed all _STAGE0 options were available, and
    forgot to account for this missing information in 9.2.
    
    Ghc 9.2 does not have in settings whether ar supports -l, hence can't
    report it with --info (unliked 9.4 upwards).
    
    The fix is to default the missing information (we default "ar supports
    -l" and other missing options to False)
    
    - - - - -
    fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00
    docs: Fix typo
    - - - - -
    503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00
    This MR is an implementation of the proposal #516.
    
    It adds a warning -Wincomplete-record-selectors for usages of a record
    field access function (either a record selector or getField @"rec"),
    while trying to silence the warning whenever it can be sure that a constructor
    without the record field would not be invoked (which would otherwise cause
    the program to fail). For example:
    
        data T = T1 | T2 {x :: Bool}
    
        f a = x a -- this would throw an error
    
        g T1 = True
        g a = x a -- this would not throw an error
    
        h :: HasField "x" r Bool => r -> Bool
        h = getField @"x"
    
        j :: T -> Bool
        j = h -- this would throw an error because of the `HasField`
              -- constraint being solved
    
    See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning.
    See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details
    
    - - - - -
    af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00
    Fix user-facing label in MR template
    
    - - - - -
    5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00
    ci: Test bootstrapping configurations with full-ci and on marge batches
    
    There have been two incidents recently where bootstrapping has been
    broken by removing support for building with 9.2.*.
    
    The process for bumping the minimum required version starts with bumping
    the configure version and then other CI jobs such as the bootstrap jobs
    have to be updated. We must not silently bump the minimum required
    version.
    
    Now we are running a slimmed down validate pipeline it seems worthwile
    to test these bootstrap configurations in the full-ci pipeline.
    
    - - - - -
    25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00
    bootstrap: Remove ghc-9_2_* plans
    
    We are anticipating shortly making it necessary to use ghc-9.4 to boot
    the compiler.
    
    - - - - -
    2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00
    Update bootstrap plans for ghc-platform and ghc-toolchain dependencies
    
    Fixes #23735
    
    - - - - -
    c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00
    bootstrap: Disable -selftest flag from bootstrap plans
    
    This saves on building one dependency (QuickCheck) which is unecessary
    for bootstrapping.
    
    - - - - -
    a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00
    Link reference paper and package from System.Mem.{StableName,Weak}
    
    - - - - -
    a5319358 by David Knothe at 2023-07-28T13:13:10-04:00
    Update Match Datatype
    
    EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation.
    All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list.
    We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows:
    
    data EquationInfo
        = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo }
        | EqnDone { eqn_rhs = MatchResult CoreExpr }
    
    An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated.
    
    - - - - -
    86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00
    Improve documentation for Data.Fixed
    
    - - - - -
    f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00
    ghc-prim: Use C11 atomics
    
    Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*`
    family of C builtins. Here we refactor these to rather use the
    appropriate C11 atomic equivalents, allowing us to be more explicit
    about the expected ordering semantics.
    
    - - - - -
    0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00
    Include -haddock in DynFlags fingerprint
    
    The -haddock flag determines whether or not the resulting .hi files
    contain haddock documentation strings. If the existing .hi files do
    not contain haddock documentation strings and the user requests them,
    we should recompile.
    
    - - - - -
    40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00
    Bump filepath submodule to 1.4.100.4
    
    Resolves #23741
    
    Metric Decrease:
        MultiComponentModules
        MultiComponentModulesRecomp
        MultiLayerModules
        MultiLayerModulesRecomp
        T10421
        T12234
        T12425
        T13035
        T13701
        T13719
        T16875
        T18304
        T18698a
        T18698b
        T21839c
        T9198
        TcPlugin_RewritePerf
        hard_hole_fits
    
    Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183
    
    - - - - -
    ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00
    Add since pragmas to GHC.IO.Handle.FD
    
    - - - - -
    d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00
    Make the occurrence analyser smarter about join points
    
    This MR addresses #22404.  There is a big Note
    
       Note [Occurrence analysis for join points]
    
    that explains it all.  Significant changes
    
    * New field occ_join_points in OccEnv
    
    * The NonRec case of occAnalBind splits into two cases:
      one for existing join points (which does the special magic for
      Note [Occurrence analysis for join points], and one for other
      bindings.
    
    * mkOneOcc adds in info from occ_join_points.
    
    * All "bring into scope" activity is centralised in the
      new function `addInScope`.
    
    * I made a local data type LocalOcc for use inside the occurrence analyser
      It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn
      makes computationns over it simpler and more efficient.
    
    * I found quite a bit of allocation in GHC.Core.Rules.getRules
      so I optimised it a bit.
    
    More minor changes
    
    * I found I was using (Maybe Arity) a lot, so I defined a new data
      type JoinPointHood and used it everwhere.  This touches a lot of
      non-occ-anal files, but it makes everything more perspicuous.
    
    * Renamed data constructor WithUsageDetails to WUD, and
      WithTailUsageDetails to WTUD
    
    This also fixes #21128, on the way.
    
    --------- Compiler perf -----------
    I spent quite a time on performance tuning, so even though it
    does more than before, the occurrence analyser runs slightly faster
    on average.  Here are the compile-time allocation changes over 0.5%
    
          CoOpt_Read(normal) ghc/alloc    766,025,520    754,561,992  -1.5%
    CoOpt_Singletons(normal) ghc/alloc    759,436,840    762,925,512  +0.5%
         LargeRecord(normal) ghc/alloc  1,814,482,440  1,799,530,456  -0.8%
           PmSeriesT(normal) ghc/alloc     68,159,272     67,519,720  -0.9%
              T10858(normal) ghc/alloc    120,805,224    118,746,968  -1.7%
              T11374(normal) ghc/alloc    164,901,104    164,070,624  -0.5%
              T11545(normal) ghc/alloc     79,851,808     78,964,704  -1.1%
              T12150(optasm) ghc/alloc     73,903,664     71,237,544  -3.6% GOOD
              T12227(normal) ghc/alloc    333,663,200    331,625,864  -0.6%
              T12234(optasm) ghc/alloc     52,583,224     52,340,344  -0.5%
              T12425(optasm) ghc/alloc     81,943,216     81,566,720  -0.5%
              T13056(optasm) ghc/alloc    294,517,928    289,642,512  -1.7%
          T13253-spj(normal) ghc/alloc    118,271,264     59,859,040 -49.4% GOOD
              T15164(normal) ghc/alloc  1,102,630,352  1,091,841,296  -1.0%
              T15304(normal) ghc/alloc  1,196,084,000  1,166,733,000  -2.5%
              T15630(normal) ghc/alloc    148,729,632    147,261,064  -1.0%
              T15703(normal) ghc/alloc    379,366,664    377,600,008  -0.5%
              T16875(normal) ghc/alloc     32,907,120     32,670,976  -0.7%
              T17516(normal) ghc/alloc  1,658,001,888  1,627,863,848  -1.8%
              T17836(normal) ghc/alloc    395,329,400    393,080,248  -0.6%
              T18140(normal) ghc/alloc     71,968,824     73,243,040  +1.8%
              T18223(normal) ghc/alloc    456,852,568    453,059,088  -0.8%
              T18282(normal) ghc/alloc    129,105,576    131,397,064  +1.8%
              T18304(normal) ghc/alloc     71,311,712     70,722,720  -0.8%
             T18698a(normal) ghc/alloc    208,795,112    210,102,904  +0.6%
             T18698b(normal) ghc/alloc    230,320,736    232,697,976  +1.0%  BAD
              T19695(normal) ghc/alloc  1,483,648,128  1,504,702,976  +1.4%
              T20049(normal) ghc/alloc     85,612,024     85,114,376  -0.6%
             T21839c(normal) ghc/alloc    415,080,992    410,906,216  -1.0% GOOD
               T4801(normal) ghc/alloc    247,590,920    250,726,272  +1.3%
               T6048(optasm) ghc/alloc     95,699,416     95,080,680  -0.6%
                T783(normal) ghc/alloc    335,323,384    332,988,120  -0.7%
               T9233(normal) ghc/alloc    709,641,224    685,947,008  -3.3% GOOD
               T9630(normal) ghc/alloc    965,635,712    948,356,120  -1.8%
               T9675(optasm) ghc/alloc    444,604,152    428,987,216  -3.5% GOOD
               T9961(normal) ghc/alloc    303,064,592    308,798,800  +1.9%  BAD
               WWRec(normal) ghc/alloc    503,728,832    498,102,272  -1.1%
    
                   geo. mean                                          -1.0%
                   minimum                                           -49.4%
                   maximum                                            +1.9%
    
    In fact these figures seem to vary between platforms; generally worse
    on i386 for some reason.  The Windows numbers vary by 1% espec in
    benchmarks where the total allocation is low. But the geom mean stays
    solidly negative, which is good.  The "increase/decrease" list below
    covers all platforms.
    
    The big win on T13253-spj comes because it has a big nest of join
    points, each occurring twice in the next one.  The new occ-anal takes
    only one iteration of the simplifier to do the inlining; the old one
    took four.  Moreover, we get much smaller code with the new one:
    
      New: Result size of Tidy Core
        = {terms: 429, types: 84, coercions: 0, joins: 14/14}
    
      Old: Result size of Tidy Core
        = {terms: 2,437, types: 304, coercions: 0, joins: 10/10}
    
    --------- Runtime perf -----------
    No significant changes in nofib results, except a 1% reduction in
    compiler allocation.
    
    Metric Decrease:
        CoOpt_Read
        T13253-spj
        T9233
        T9630
        T9675
        T12150
        T21839c
        LargeRecord
        MultiComponentModulesRecomp
        T10421
        T13701
        T10421
        T13701
        T12425
    
    Metric Increase:
        T18140
        T9961
        T18282
        T18698a
        T18698b
        T19695
    
    - - - - -
    42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00
    Improve documentation around IOException and ioe_filename
    
    See:
    
    * https://github.com/haskell/core-libraries-committee/issues/189
    * https://github.com/haskell/unix/pull/279
    * https://github.com/haskell/unix/pull/289
    
    - - - - -
    33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00
    JS: implement getMonotonicTime (fix #23687)
    
    - - - - -
    d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00
    Implementation of the Deprecated Instances proposal #575
    
    This commit implements the ability to deprecate certain instances,
    which causes the compiler to emit the desired deprecation message
    whenever they are instantiated. For example:
    
      module A where
      class C t where
      instance {-# DEPRECATED "dont use" #-} C Int where
    
      module B where
      import A
      f :: C t => t
      f = undefined
      g :: Int
      g = f -- "dont use" emitted here
    
    The implementation is as follows:
      - In the parser, we parse deprecations/warnings attached to instances:
    
          instance {-# DEPRECATED "msg" #-} Show X
          deriving instance {-# WARNING "msg2" #-} Eq Y
    
        (Note that non-standalone deriving instance declarations do not support
        this mechanism.)
    
      - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`).
        In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`),
        we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too).
    
      - Finally, when we solve a constraint using such an instance, in
        `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning
        that was stored in `ClsInst`.
        Note that we only emit a warning when the instance is used in a different module
        than it is defined, which keeps the behaviour in line with the deprecation of
        top-level identifiers.
    
    Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>
    
    - - - - -
    d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00
    compiler: Style fixes
    
    - - - - -
    7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Fix implicit cast
    
    This ensures that Task.h can be built with a C++ compiler.
    
    - - - - -
    d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00
    testsuite: Fix warning in hs_try_putmvar001
    
    - - - - -
    d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00
    testsuite: Add AtomicModifyIORef test
    
    - - - - -
    f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Introduce NO_WARN macro
    
    This allows fine-grained ignoring of warnings.
    
    - - - - -
    497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Simplify atomicModifyMutVar2# implementation
    
    Previously we would perform a redundant load in the non-threaded RTS in
    atomicModifyMutVar2# implementation for the benefit of the non-moving
    GC's write barrier. Eliminate this.
    
    - - - - -
    52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Introduce more principled fence operations
    
    - - - - -
    cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Introduce SET_INFO_RELAXED
    
    - - - - -
    6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00
    rts: Style fixes
    
    - - - - -
    4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00
    codeGen/tsan: Rework handling of spilling
    
    - - - - -
    f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00
    hadrian: More debug information
    
    - - - - -
    df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00
    Improve TSAN documentation
    
    - - - - -
    fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00
    hadrian: More selective TSAN instrumentation
    
    - - - - -
    465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00
    EPA: Provide correct annotation span for ImportDecl
    
    Use the whole declaration, rather than just the span of the 'import'
    keyword.
    
    Metric Decrease:
       T9961
       T5205
    Metric Increase:
      T13035
    
    - - - - -
    ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00
    Add cases to T23279: HasField for deprecated record fields
    
    This commit adds additional tests from ticket #23279 to ensure that we don't
    regress on reporting deprecated record fields in conjunction with HasField,
    either when using overloaded record dot syntax or directly through `getField`.
    
    Fixes #23279
    
    - - - - -
    00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00
    AArch NCG: Pure refactor
    
    Combine some alternatives. Add some line breaks for overly long lines
    
    - - - - -
    8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    74a882dc by MorrowM at 2023-08-02T06:00:03-04:00
    Add a RULE to make lookup fuse
    
    See https://github.com/haskell/core-libraries-committee/issues/175
    
    Metric Increase:
        T18282
    
    - - - - -
    cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00
    hadrian: Ensure that way-flags are passed to CC
    
    Previously the way-specific compilation flags (e.g. `-DDEBUG`,
    `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant
    that C dependency files would not correctly reflect
    dependencies predicated on the way, resulting in the rather
    painful #23554.
    
    Closes #23554.
    
    - - - - -
    622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00
    Native 32-bit Enum Int64/Word64 instances
    
    This commits adds more performant Enum Int64 and Enum Word64 instances
    for 32-bit platforms, replacing the Integer-based implementation.
    
    These instances are a copy of the Enum Int and Enum Word instances with
    minimal changes to manipulate Int64 and Word64 instead.
    
    On i386 this yields a 1.5x performance increase and for the JavaScript
    back end it even yields a 5.6x speedup.
    
    Metric Decrease:
        T18964
    
    - - - - -
    c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00
    JS: fix typos in constants (#23650)
    
    - - - - -
    b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00
    JavaScript: update MK_TUP macros to use current tuple constructors (#23659)
    
    - - - - -
    28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00
    ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job
    
    Warnings when building Hadrian can end up cluttering the output of HLS,
    and we've had bug reports in the past about these warnings when building
    Hadrian. It would be nice to turn on -Werror on at least one build of
    Hadrian in CI to avoid a patch introducing warnings when building
    Hadrian.
    
    Fixes #23638
    
    - - - - -
    aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00
    codeGen: Ensure that TSAN is aware of writeArray# write barriers
    
    By using a proper release store instead of a fence.
    
    - - - - -
    453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00
    codeGen: Ensure that array reads have necessary barriers
    
    This was the cause of #23541.
    
    - - - - -
    93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00
    Add test for #23550
    
    - - - - -
    6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00
    Desugar non-recursive lets to non-recursive lets (take 2)
    
    This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And
    takes care of the case that I missed in my previous attempt. Namely
    the case of an AbsBinds with no type variables and no dictionary
    variable.
    
    Ironically, the comment explaining why non-recursive lets were
    desugared to recursive lets were pointing specifically at this case
    as the reason. I just failed to understand that it was until Simon PJ
    pointed it out to me.
    
    See #23550 for more discussion.
    
    - - - - -
    ff81d53f by jade at 2023-08-02T06:05:20-04:00
    Expand documentation of List & Data.List
    
    This commit aims to improve the documentation and examples
    of symbols exported from Data.List
    
    - - - - -
    fa4e5913 by Jade at 2023-08-02T06:06:03-04:00
    Improve documentation of Semigroup & Monoid
    
    This commit aims to improve the documentation of various symbols
    exported from Data.Semigroup and Data.Monoid
    
    - - - - -
    e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00
    Desugar bindings in the context of their evidence
    
    Closes #23172
    
    - - - - -
    481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00
    Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of
    incoherent instances
    
    Fixes #23287
    
    - - - - -
    d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00
    base: Improve String & IsString documentation
    
    - - - - -
    01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00
    rts/win32: Ensure reliability of IO manager shutdown
    
    When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an
    `IO_MANAGER_DIE` event to the IO manager thread using the
    `io_manager_event` event object. Finally, it will closes the event object,
    and invalidate `io_manager_event`.
    
    Previously, `readIOManagerEvent` would see that `io_manager_event` is
    invalid and return `0`, suggesting that everything is right with the
    world. This meant that if `ioManagerDie` invalidated the handle before
    the event manager was blocked on the event we would end up in a
    situation where the event manager would never realize it was asked to
    shut down.
    
    Fix this by ensuring that `readIOManagerEvent` instead returns
    `IO_MANAGER_DIE` when we detect that the event object has been
    invalidated by `ioManagerDie`.
    
    Fixes #23691.
    
    - - - - -
    fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00
    Look through TH splices in splitHsApps
    
    This modifies `splitHsApps` (a key function used in typechecking function
    applications) to look through untyped TH splices and quasiquotes. Not doing so
    was the cause of #21077. This builds on !7821 by making `splitHsApps` match on
    `HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as
    part of invoking the TH splice. See the new `Note [Looking through Template
    Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`.
    
    Along the way, I needed to make the type of `splitHsApps.set` slightly more
    general to accommodate the fact that the location attached to a quasiquote is
    a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`.
    
    Fixes #21077.
    
    - - - - -
    e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00
    Bump deepseq submodule to 1.5.
    
    And bump bounds
    
    (cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b)
    
    - - - - -
    cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00
    configure: Bump minimal boot GHC version to 9.4
    
    (cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e)
    
    - - - - -
    83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00
    template-haskell: Bump version to 2.21.0.0
    
    Bumps exceptions submodule.
    
    (cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb)
    
    - - - - -
    1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00
    base: Bump version to 4.19
    
    Updates all boot library submodules.
    
    (cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143)
    
    - - - - -
    3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00
    testsuite: Normalise versions more aggressively
    
    In backpack hashes can contain `+` characters.
    
    (cherry picked from commit 024861af51aee807d800e01e122897166a65ea93)
    
    - - - - -
    d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00
    testsuite: Declare bkpcabal08 as fragile
    
    Due to spurious output changes described in #23648.
    
    (cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b)
    
    - - - - -
    e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00
    gitlab-ci: Only mark linker_unload_native as broken in static jobs
    
    This test passes on dynamically-linked Alpine.
    
    (cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87)
    
    - - - - -
    8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00
    testsuite: Update base-exports
    
    - - - - -
    4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00
    testsuite/interface-stability: normalise versions
    
    This eliminates spurious changes from version bumps.
    
    - - - - -
    0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00
    linker/PEi386: Don't sign-extend symbol section number
    
    Previously we incorrectly interpreted PE section numbers as signed
    values. However, this isn't the case; rather, it's an unsigned 16-bit number
    with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941
    as the linker would conclude that the sections were invalid.
    
    Fixing this required quite a bit of refactoring.
    
    Closes #22941.
    
    - - - - -
    fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00
    testsuite: Mark MulMayOflo_full as broken rather than skipping
    
    To ensure that we don't accidentally fix it.
    
    See #23742.
    
    - - - - -
    824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00
    nativeGen/AArch64: Fix sign extension in MulMayOflo
    
    Previously the 32-bit implementations of MulMayOflo would use the
    a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11
    produces. Also similarly rework the 16- and 8-bit cases.
    
    This now passes the MulMayOflo tests in ghc/test-primops> in all four
    widths, including the precision tests.
    
    Fixes #23721.
    
    - - - - -
    1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00
    Fix haddock markup in code example for coerce
    
    - - - - -
    46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00
    Fix (~) and (@) infix operators in TH splices (#23748)
    
    8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept
    the following infix operators:
    
    	a ~ b = ()
    	a @ b = ()
    
    But not if TH is used to generate those declarations:
    
    	$([d| a ~ b = ()
    	      a @ b = ()
    	    |])
    
    	-- Test.hs:5:2: error: [GHC-55017]
    	--    Illegal variable name: ‘~’
    	--    When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.()
    
    This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme
    
    - - - - -
    a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00
    [#23663] Show Flag Suggestions in GHCi
    
    Makes suggestions when using `:set` in GHCi with a misspelled flag. This
    mirrors how invalid flags are handled when passed to GHC directly. Logic
    for producing flag suggestions was moved to GHC.Driver.Sesssion so it
    can be shared.
    
    resolves #23663
    
    - - - - -
    03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00
    Improve ghc-toolchain validation configure warning
    
    Fixes the layout of the ghc-toolchain validation warning produced by
    configure.
    
    - - - - -
    de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00
    EPA make getLocA a synonym for getHasLoc
    
    This is basically a no-op change, but allows us to make future changes
    that can rely on the HasLoc instances
    
    And I presume this means we can use more precise functions based on
    class resolution, so the Windows CI build reports
    
    Metric Decrease:
        T12234
        T13035
    
    - - - - -
    3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00
    ghc-platform: Add upper bound on base
    
    Hackage upload requires this.
    - - - - -
    8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00
    Adjust and clarify handling of primop effects
    
    Fixes #17900; fixes #20195.
    
    The existing "can_fail" and "has_side_effects" primop attributes
    that previously governed this were used in inconsistent and
    confusingly-documented ways, especially with regard to raising
    exceptions.  This patch replaces them with a single "effect"
    attribute, which has four possible values: NoEffect, CanFail,
    ThrowsException, and ReadWriteEffect.  These are described in
    Note [Classifying primop effects].
    
    A substantial amount of related documentation has been re-drafted
    for clarity and accuracy.
    
    In the process of making this attribute format change for literally
    every primop, several existing mis-classifications were detected and
    corrected.  One of these mis-classifications was tagToEnum#, which
    is now considered CanFail; this particular fix is known to cause a
    regression in performance for derived Enum instances.  (See #23782.)
    Fixing this is left as future work.
    
    New primop attributes "cheap" and "work_free" were also added,
    and used in the corresponding parts of GHC.Core.Utils.
    
    In view of their actual meaning and uses, `primOpOkForSideEffects`
    and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard`
    and `exprOkToDiscard`, respectively.
    
    Metric Increase:
        T21839c
    
    - - - - -
    41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00
    Update inert_solved_dicts for ImplicitParams
    
    When adding an implicit parameter dictionary to the inert set, we must
    make sure that it replaces any previous implicit parameter dictionaries
    that overlap, in order to get the appropriate shadowing behaviour, as in
    
      let ?x = 1 in let ?x = 2 in ?x
    
    We were already doing this for inert_cans, but we weren't doing the same
    thing for inert_solved_dicts, which lead to the bug reported in #23761.
    
    The fix is thus to make sure that, when handling an implicit parameter
    dictionary in updInertDicts, we update **both** inert_cans and
    inert_solved_dicts to ensure a new implicit parameter dictionary
    correctly shadows old ones.
    
    Fixes #23761
    
    - - - - -
    43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00
    Bump bytestring submodule to 0.11.5.1
    
    - - - - -
    91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00
    Initial commit of Note [Thunks, blackholes, and indirections]
    
    This Note attempts to summarize the treatment of thunks, thunk update,
    and indirections.
    
    This fell out of work on #23185.
    
    - - - - -
    8d686854 by sheaf at 2023-08-05T01:06:54-04:00
    Remove zonk in tcVTA
    
    This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its
    accompanying Note [Visible type application zonk]. Indeed, this zonk
    is no longer necessary, as we no longer maintain the invariant that
    types are well-kinded without zonking; only that typeKind does not
    crash; see Note [The Purely Kinded Type Invariant (PKTI)].
    
    This commit removes this zonking step (as well as a secondary zonk),
    and replaces the aforementioned Note with the explanatory
    Note [Type application substitution], which justifies why the
    substitution performed in tc_inst_forall_arg remains valid without
    this zonking step.
    
    Fixes #23661
    
    - - - - -
    19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00
    Bump nofib submodule
    
    Ensuring that nofib can be build using the same range of bootstrap
    compilers as GHC itself.
    
    - - - - -
    aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00
    JS: Improve compatibility with recent emsdk
    
    The JavaScript code in libraries/base/jsbits/base.js had some
    hardcoded offsets for fields in structs, because we expected
    the layout of the data structures to remain unchanged. Emsdk
    3.1.42 changed the layout of the stat struct, breaking this
    assumption, and causing code in .hsc files accessing the
    stat struct to fail.
    
    This patch improves compatibility with recent emsdk by
    removing the assumption that data layouts stay unchanged:
    
        1. offsets of fields in structs used by JavaScript code are
           now computed by the configure script, so both the .js and
           .hsc files will automatically use the new layout if anything
           changes.
        2. the distrib/configure script checks that the emsdk version
           on a user's system is the same version that a bindist was
           booted with, to avoid data layout inconsistencies
    
    See #23641
    
    - - - - -
    b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00
    JS: Fix missing local variable declarations
    
    This fixes some missing local variable declarations that were
    found by running the testsuite in strict mode.
    
    Fixes #23775
    
    - - - - -
    6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00
    Update Haddock submodule to fix #23368
    
    This submodule update adds the following three commits:
    
    bbf1c8ae - Check for puns
    0550694e - Remove fake exports for (~), List, and Tuple<n>
    5877bceb - Fix pretty-printing of Solo and MkSolo
    
    These commits fix the issues with Haddock HTML rendering reported in
    ticket #23368.
    
    Fixes #23368
    
    - - - - -
    5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00
    Revert "Bump bytestring submodule to 0.11.5.1"
    
    This reverts commit 43578d60bfc478e7277dcd892463cec305400025.
    
    Fixes #23789
    
    - - - - -
    01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00
    configure: Derive library version from ghc-prim.cabal.in
    
    Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon
    it.
    
    Closes #23726.
    
    - - - - -
    3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00
    tcExpr: Push expected types for untyped TH splices inwards
    
    In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much
    simpler case that simply delegates to `tcApp`. Although this passed the test
    suite at the time, this was actually an error, as the previous `tcExpr` case
    was critically pushing the expected type inwards. This actually matters for
    programs like the one in #23796, which GHC would not accept with type inference
    alone—we need full-blown type _checking_ to accept these.
    
    I have added back the previous `tcExpr` case for `HsUntypedSplice` and now
    explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and
    another in `splitHsApps`) in `Note [Looking through Template Haskell splices in
    splitHsApps]` in `GHC.Tc.Gen.Head`.
    
    Fixes #23796.
    
    - - - - -
    0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00
    Compute all emitted diagnostic codes
    
    This commit introduces in GHC.Types.Error.Codes the function
    
      constructorCodes :: forall diag. (...) => Map DiagnosticCode String
    
    which computes a collection of all the diagnostic codes that correspond
    to a particular type. In particular, we can compute the collection of
    all diagnostic codes emitted by GHC using the invocation
    
      constructorCodes @GhcMessage
    
    We then make use of this functionality in the new "codes" test which
    checks consistency and coverage of GHC diagnostic codes.
    It performs three checks:
    
      - check 1: all non-outdated GhcDiagnosticCode equations
        are statically used.
      - check 2: all outdated GhcDiagnosticCode equations
        are statically unused.
      - check 3: all statically used diagnostic codes are covered by
        the testsuite (modulo accepted exceptions).
    
    - - - - -
    4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00
    numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int)
    
    Currently a negative exponent less than `minBound :: Int` results in
    Infinity, which is very surprising and obviously wrong.
    
    ```
    λ> read "1e-9223372036854775808" :: Double
    0.0
    λ> read "1e-9223372036854775809" :: Double
    Infinity
    ```
    
    There is a further edge case where the exponent can overflow when
    increased by the number of tens places in the integer part, or
    underflow when decreased by the number of leading zeros in the
    fractional part if the integer part is zero:
    
    ```
    λ> read "10e9223372036854775807" :: Double
    0.0
    λ> read "0.01e-9223372036854775808" :: Double
    Infinity
    ```
    
    To resolve both of these issues, perform all arithmetic and
    comparisons involving the exponent in type `Integer`.  This approach
    also eliminates the need to explicitly check the exponent against
    `maxBound :: Int` and `minBound :: Int`, because the allowed range
    of the exponent (i.e. the result of `floatRange` for the target
    floating point type) is certainly within those bounds.
    
    This change implements CLC proposal 192:
    https://github.com/haskell/core-libraries-committee/issues/192
    
    - - - - -
    6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00
    EPA: Remove Location from WarningTxt source
    
    This is not needed.
    
    - - - - -
    1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00
    Cleanup a TODO introduced in 1f94e0f7
    
    The change must have slipped through review of !4412
    
    - - - - -
    2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00
    More explicit strictness in GHC.Real
    
    - - - - -
    ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00
    exprIsTrivial: Factor out shared implementation
    
    The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has
    been bugging me for a long time.
    
    This patch introduces an inlinable worker function `trivial_expr_fold` acting
    as the single, shared decision procedure of triviality. It "returns" a
    Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar
    code as before.
    (Better code, even, in the case of `getIdFromTrivialExpr` which presently
    allocates a `Just` constructor that cancels away after this patch.)
    
    - - - - -
    d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Simplify: Simplification of arguments in a single function
    
    The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`,
    which seems to be the main way to simplify args. Hence I consolidated the code
    path to call `simplArg`, too, renaming to `simplLazyArg`.
    
    - - - - -
    8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Core.Ppr: Omit case binder for empty case alternatives
    
    A minor improvement to pretty-printing
    
    - - - - -
    d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend
    
    ... because those coerce between incompatible/unknown PrimReps.
    
    - - - - -
    f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Inlining literals into boring contexts is OK
    
    - - - - -
    4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Clarify floating of unsafeEqualityProofs (#23754)
    
    - - - - -
    b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Kill SetLevel.notWorthFloating.is_triv (#23270)
    
    We have had it since b84ba676034, when it operated on annotated expressions.
    Nowadays it operates on vanilla `CoreExpr` though, so we should just call
    `exprIsTrivial`; thus handling empty cases and string literals correctly.
    
    - - - - -
    7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00
    ANFise string literal arguments (#23270)
    
    This instates the invariant that a trivial CoreExpr translates to an atomic
    StgExpr. Nice.
    
    Annoyingly, in -O0 we sometimes generate
    ```
    foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat }
    ```
    which makes it a bit harder to spot that we can emit a standard
    `stg_unpack_cstring` thunk.
    
    Fixes #23270.
    
    - - - - -
    357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345)
    
    - - - - -
    59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead
    
    We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now.
    The main reason is that it plays far better in conjunction with eta expansion
    (as we aim to do for arguments in CorePrep, #23083), because we can discard
    any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta`
    it's impossible to discard the argument.
    
    We do also give the same treatment to unsafeCoerce proofs and treat them as
    trivial iff their RHS is trivial.
    
    It is also both much simpler to describe than the previous mechanism of emitting
    an unsafe coercion and simpler to implement, removing quite a bit of commentary
    and `CorePrepProv`.
    
    In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier
    iteration due to #17910. E.g., FloatOut produces a binding
    ```
    lvl_s6uK [Occ=Once1] :: GHC.Types.Int
    [LclId]
    lvl_s6uK = GHC.Types.I# 2#
    
    lvl_s6uL [Occ=Once1] :: GHC.Types.Any
    [LclId]
    lvl_s6uL
      = case Unsafe.Coerce.unsafeEqualityProof ... of
        { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...)
        }
    ```
    That occurs once and hence is pre-inlined unconditionally in the next Simplifier
    pass. It's non-trivial to find a way around that, but not really harmful
    otherwise. Hence we accept a 1.2% increase on some architectures.
    
    Metric Increase:
        LargeRecord
    
    - - - - -
    00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00
    CorePrep: Eta expand arguments (#23083)
    
    Previously, we'd only eta expand let bindings and lambdas,
    now we'll also eta expand arguments such as in T23083:
    ```hs
    g f h = f (h `seq` (h $))
    ```
    Unless `-fpedantic-bottoms` is set, we'll now transform to
    ```hs
    g f h = f (\eta -> h eta)
    ```
    in CorePrep.
    
    See the new `Note [Eta expansion of arguments in CorePrep]` for the details.
    
    We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions
    in T4801 and T5321FD.
    
    Fixes #23083.
    
    - - - - -
    bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00
    Bump bytestring submodule to 0.11.5, again
    
    Fixes #23789.
    
    The bytestring commit used here is unreleased;
    a release can be made when necessary.
    
    - - - - -
    7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00
    Serialize CmmRetInfo in .rodata
    
    The handling of case was missing.
    
    - - - - -
    0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Reference StgRetFun payload by its struct field address
    
    This is easier to grasp than relative pointer offsets.
    
    - - - - -
    f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Better variable name: u -> frame
    
    The 'u' was likely introduced by copy'n'paste.
    
    - - - - -
    0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00
    Make checkSTACK() public
    
    Such that it can also be used in tests.
    
    - - - - -
    7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Publish stack related fields in DerivedConstants.h
    
    These will be used in ghc-heap to decode these parts of the stack.
    
    - - - - -
    907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00
    ghc-heap: Decode StgStack and its stack frames
    
    Previously, ghc-heap could only decode heap closures.
    
    The approach is explained in detail in note
    [Decoding the stack].
    
    - - - - -
    6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Remove RetFunType from RetFun stack frame representation
    
    It's a technical detail. The single usage is replaced by a predicate.
    
    - - - - -
    006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Better parameter name
    
    The call-site uses the term "offset", too.
    
    - - - - -
    d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00
    Make closure boxing pure
    
    There seems to be no need to do something complicated. However, the
    strictness of the closure pointer matters, otherwise a thunk gets
    decoded.
    
    - - - - -
    8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00
    Document entertainGC in test
    
    It wasn't obvious why it's there and what its role is.
    
    Also, increase the "entertainment level" a bit.
    
    I checked in STG and Cmm dumps that this really generates closures (and
    is not e.g. constant folded away.)
    
    - - - - -
    cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00
    Add -dipe-stats flag
    
    This is useful for seeing which info tables have information.
    
    - - - - -
    261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00
    Add -finfo-table-map-with-fallback -finfo-table-map-with-stack
    
    The -fno-info-table-map-with-stack flag omits STACK info tables from the info
    table map, and the -fno-info-table-map-with-fallback flag omits info tables
    with defaulted source locations from the map. In a test on the Agda codebase
    the build results were about 7% smaller when both of those types of tables
    were omitted.
    
    Adds a test that verifies that passing each combination of these flags
    results in the correct output for -dipe-stats, which is disabled for the js
    backend since profiling is not implemented.
    
    This commit also refactors a lot of the logic around extracting info tables
    from the Cmm results and building the info table map.
    
    This commit also fixes some issues in the users guide rst source to fix
    warnings that were noticed while debugging the documentation for these flags.
    
    Fixes #23702
    
    - - - - -
    d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00
    Add changelog entry for specialised Enum Int64/Word64 instances
    
    - - - - -
    52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00
    Fix -ddump-to-file and -ddump-timings interaction (#20316)
    
    - - - - -
    1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00
    Update release notes (#20316)
    
    - - - - -
    8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00
    base: Add changelog entry for CLC #188
    
    This proposal modified the implementations of copyBytes, moveBytes and
    fillBytes (as detailed in the proposal)
    
    https://github.com/haskell/core-libraries-committee/issues/188
    
    - - - - -
    026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00
    packaging: Build manpage in separate directory to other documentation
    
    We were installing two copies of the manpage:
    
    * One useless one in the `share/doc` folder, because we copy the doc/
      folder into share/
    * The one we deliberately installed into `share/man` etc
    
    The solution is to build the manpage into the `manpage` directory when
    building the bindist, and then just install it separately.
    
    Fixes #23707
    
    - - - - -
    524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00
    Report deprecated fields bound by record wildcards when used
    
    This commit ensures that we emit the appropriate warnings when
    a deprecated record field bound by a record wildcard is used.
    
    For example:
    
        module A where
        data Foo = Foo {x :: Int, y :: Bool, z :: Char}
    
        {-# DEPRECATED x "Don't use x" #-}
        {-# WARNING y "Don't use y" #-}
    
        module B where
        import A
    
        foo (Foo {..}) = x
    
    This will cause us to emit a "Don't use x" warning, with location the
    location of the record wildcard. Note that we don't warn about `y`,
    because it is unused in the RHS of `foo`.
    
    Fixes #23382
    
    - - - - -
    d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00
    Add zstd suffix to jobs which rely on zstd
    
    This was causing some confusion as the job was named simply
    "x86_64-linux-deb10-validate", which implies a standard configuration
    rather than any dependency on libzstd.
    
    - - - - -
    e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00
    ci: Always run project-version job
    
    This is needed for the downstream test-primops pipeline to workout what
    the version of a bindist produced by a pipeline is.
    
    - - - - -
    f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00
    gen_ci: Rework how jobs-metadata.json is generated
    
    * We now represent a job group a triple of Maybes, which makes it easier
      to work out when jobs are enabled/disabled on certain pipelines.
    
    ```
    data JobGroup a = StandardTriple { v :: Maybe (NamedJob a)
                                     , n :: Maybe (NamedJob a)
                                     , r :: Maybe (NamedJob a) }
    ```
    
    * `jobs-metadata.json`  generation is reworked using the following
      algorithm.
      - For each pipeline type, find all the platforms we are doing builds
        for.
      - Select one build per platform
      - Zip together the results
    
    This way we can choose different pipelines for validate/nightly/release
    which makes the metadata also useful for validate pipelines. This
    feature is used by the test-primops downstream CI in order to select the
    right bindist for testing validate pipelines.
    
    This makes it easier to inspect which jobs are going to be enabled on a
    particular pipeline.
    
    - - - - -
    f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00
    gen_ci: Rules rework
    
    In particular we now distinguish between whether we are dealing with a
    Nightly/Release pipeline (which labels don't matter for) and a validate
    pipeline where labels do matter.
    
    The overall goal here is to allow a disjunction of labels for validate
    pipelines, for example,
    
    > Run a job if we have the full-ci label or test-primops label
    
    Therefore the "ValidateOnly" rules are treated as a set of disjunctions
    rather than conjunctions like before.
    
    What this means in particular is that if we want to ONLY run a job if a
    label is set, for example, "FreeBSD" label then we have to override the
    whole label set.
    
    Fixes #23772
    
    - - - - -
    d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00
    ci: set -e for lint-ci-config scripts
    
    - - - - -
    994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00
    ci: Fix job metadata generation
    
    - - - - -
    e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00
    users-guide: Note that GHC2021 doesn't include ExplicitNamespaces
    
    As noted in #23801.
    
    - - - - -
    d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00
    users-guide: Support both distutils and packaging
    
    As noted in #23818, some old distributions (e.g. Debian 9) only include
    `distutils` while newer distributions only include `packaging`.
    
    Fixes #23818.
    
    - - - - -
    1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00
    users-guide: Ensure extlinks is compatible with Sphinx <4
    
    The semantics of the `extlinks` attribute annoyingly changed in Sphinx
    4. Reflect this in our configuration. See #22690.
    
    Fixes #23807.
    
    - - - - -
    173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00
    ci: Run full-ci on master and release branches
    
    Fixes #23737
    
    - - - - -
    bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00
    Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp
    
    - - - - -
    662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00
    ghc-toolchain: Match CPP args with configure script
    
    At the moment we need ghc-toolchain to precisely match the output as
    provided by the normal configure script. The normal configure script
    (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc
    so we match that logic exactly in ghc-toolchain.
    
    The old implementation (which checks if certain flags are supported) is
    better but for now we have to match to catch any potential errors in the
    configuration.
    
    Ticket: #23720
    
    - - - - -
    09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00
    configure: Fix `-Wl,--no-as-needed` check
    
    The check was failing because the args supplied by $$1 were quoted which
    failed because then the C compiler thought they were an input file.
    
    Fixes #23720
    
    - - - - -
    2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00
    configure: Add flag which turns ghc-toolchain check into error
    
    We want to catch these errors in CI, but first we need to a flag which
    turns this check into an error.
    
    - - - - -
    6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs
    
    This will cause any CI job to fail if we have a mismatch between what
    ghc-toolchain reports and what ./configure natively reports. Fixing
    these kinds of issues is highest priority for 9.10 release.
    
    - - - - -
    12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
    Pass user-specified options to ghc-toolchain
    
    The current user interface to configuring target toolchains is `./configure`.
    
    In !9263 we added a new tool to configure target toolchains called
    `ghc-toolchain`, but the blessed way of creating these toolchains is
    still through configure.
    
    However, we were not passing the user-specified options given with the
    `./configure` invocation to the ghc-toolchain tool.
    
    This commit remedies that by storing the user options and environment
    variables in USER_* variables, which then get passed to GHC-toolchain.
    
    The exception to the rule is the windows bundled toolchain, which
    overrides the USER_* variables with whatever flags the windows bundled
    toolchain requires to work.
    We consider the bundled toolchain to be effectively the user specifying
    options, since the actual user delegated that configuration work.
    
    Closes #23678
    
    - - - - -
    f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
    ghc-toolchain: Parse javascript and ghcjs as a Arch and OS
    
    - - - - -
    8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
    ghc-toolchain: Fix ranlib option
    
    - - - - -
    31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
    Check Link Works with -Werror
    
    - - - - -
    bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    Only check for no_compact_unwind support on darwin
    
    While writing ghc-toolchain we noticed that the
    FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we
    pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as
    -n o_compact_unwind, which is a valid argument.
    
    Fixes #23676
    
    - - - - -
    0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00
    Add some javascript special cases to ghc-toolchain
    
    On javascript there isn't a choice of toolchain but some of the
    configure checks were not accurately providing the correct answer.
    
    1. The linker was reported as gnu LD because the --version output
       mentioned gnu LD.
    2. The --target flag makes no sense on javascript but it was just
       ignored by the linker, so we add a special case to stop ghc-toolchain
       thinking that emcc supports --target when used as a linker.
    
    - - - - -
    a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    check for emcc in gnu_LD check
    
    - - - - -
    50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    Add ldOverrideWhitelist to only default to ldOverride on windows/linux
    
    On some platforms - ie darwin, javascript etc we really do not want to
    allow the user to use any linker other than the default one as this
    leads to all kinds of bugs. Therefore it is a bit more prudant to add a
    whitelist which specifies on which platforms it might be possible to use
    a different linker.
    
    - - - - -
    a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00
    Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS
    
    A normal triple may look like
    
    x86_64-unknown-linux
    
    but when cross-compiling you get $target set to a quad such as..
    
    aarch64-unknown-linux-gnu
    
    Which should also match this check.
    
    - - - - -
    c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00
    ghc-toolchain: Pass ld-override onto ghc-toolchain
    
    - - - - -
    039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00
    ld override: Make whitelist override user given option
    
    - - - - -
    d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00
    ghc-toolchain: Add format mode to normalise differences before diffing.
    
    The "format" mode takes an "--input" and "--ouput" target file and
    formats it.
    
    This is intended to be useful on windows where the
    configure/ghc-toolchain target files can't be diffed very easily because
    the path separators are different.
    
    - - - - -
    f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00
    ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta
    
    We needed to remove -Wno-unused-command-line-argument from the arguments
    passed in order for the configure check to report correctly.
    
    See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335
    
    - - - - -
    92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00
    configure: MergeObjsCmd - distinguish between empty string and unset variable
    
    If `MergeObjsCmd` is explicitly set to the empty string then we should
    assume that MergeObjs is just not supported.
    
    This is especially important for windows where we set MergeObjsCmd to ""
    in m4/fp_setup_windows_toolchain.m4.
    
    - - - - -
    3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00
    configure: Add proper check to see if object merging works
    
    - - - - -
    08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00
    ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing
    
    If the user explicitly chooses to not set a MergeObjsCmd then it is
    correct to use Nothing for tgtMergeObjs field in the Target file.
    
    - - - - -
    c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00
    HsCppArgs: Augment the HsCppOptions
    
    This is important when we pass -I when setting up the windows toolchain.
    
    - - - - -
    294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00
    Set USER_CPP_ARGS when setting up windows toolchain
    
    - - - - -
    bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00
    Improve handling of Cc as a fallback
    
    - - - - -
    f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00
    ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags
    
    In ghc-toolchain, we were only /not/ configuring required flags when the
    user specified any flags at all for the  of the HsCpp and Cpp tools.
    
    Otherwise, the linker takes into consideration the user specified flags
    to determine whether to search for a better linker implementation, but
    already configured the remaining GHC and platform-specific flags
    regardless of the user options.
    
    Other Tools consider the user options as a baseline for further
    configuration (see `findProgram`), so #23689 is not applicable.
    
    Closes #23689
    
    - - - - -
    bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00
    CPP_ARGS: Put new options after user specified options
    
    This matches up with the behaviour of ghc-toolchain, so that the output
    of both matches.
    
    - - - - -
    a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00
    If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting
    
    Fixes #23821.
    
    - - - - -
    e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00
    JS: implement openat(AT_FDCWD...) (#23697)
    
    Use `openSync` to implement `openat(AT_FDCWD...)`.
    
    - - - - -
    a975c663 by sheaf at 2023-08-17T07:54:47-04:00
    Use unsatisfiable for missing methods w/ defaults
    
    When a class instance has an Unsatisfiable constraint in its context
    and the user has not explicitly provided an implementation of a method,
    we now always provide a RHS of the form `unsatisfiable @msg`, even
    if the method has a default definition available. This ensures that,
    when deferring type errors, users get the appropriate error message
    instead of a possible runtime loop, if class default methods were
    defined recursively.
    
    Fixes #23816
    
    - - - - -
    45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00
    ghc-internal: Initial commit of the skeleton
    
    - - - - -
    88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00
    ghc-experimental: Initial commit
    
    - - - - -
    664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00
    testsuite/cloneStackLib: Fix incorrect format specifiers
    
    - - - - -
    eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00
    rts/ipe: Fix const-correctness of IpeBufferListNode
    
    Both info tables and the string table should be `const`
    
    - - - - -
    78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00
    nonmoving: Drop dead debugging utilities
    
    These are largely superceded by support in the ghc-utils GDB extension.
    
    - - - - -
    3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00
    nonmoving: Refactor management of mark thread
    
    Here we refactor that treatment of the worker thread used by the
    nonmoving GC for concurrent marking, avoiding creating a new thread with
    every major GC cycle. As well, the new scheme is considerably easier to
    reason about, consolidating all state in one place, accessed via a small
    set of accessors with clear semantics.
    
    - - - - -
    88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00
    testsuite: Skip T23221 in nonmoving GC ways
    
    This test is very dependent upon GC behavior.
    
    - - - - -
    381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00
    ghc-heap: Don't expose stack dirty and marking fields
    
    These are GC metadata and are not relevant to the end-user. Moreover,
    they are unstable which makes ghc-heap harder to test than necessary.
    
    - - - - -
    16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00
    bump process submodule to include macOS fix and JS support
    
    - - - - -
    b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00
    ci: Add support for triggering test-primops pipelines
    
    This commit adds 4 ways to trigger testing with test-primops.
    
    1. Applying the ~test-primops label to a validate pipeline.
    2. A manually triggered job on a validate pipeline
    3. A nightly pipeline job
    4. A release pipeline job
    
    Fixes #23695
    
    - - - - -
    32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00
    Add test-primops label support
    
    The test-primops CI job requires some additional builds in the
    validation pipeline, so we make sure to enable these jobs when
    test-primops label is set.
    
    - - - - -
    73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00
    Revert "Aarch ncg: Optimize immediate use for address calculations"
    
    This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631.
    
    See #23793
    
    - - - - -
    5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00
    Revert "AArch NCG: Pure refactor"
    
    This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d.
    
    See #23793
    
    - - - - -
    02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00
    Revert "Aarch64 NCG: Use encoded immediates for literals."
    
    This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c.
    
    See #23793
    
    -------------------------
    Metric Increase:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00
    ci: Remove manually triggered test-ci job
    
    This doesn't work on slimmed down pipelines as the needed jobs don't
    exist.
    
    If you want to run test-primops then apply the label.
    
    - - - - -
    76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00
    Remove Ptr example from roles docs
    
    - - - - -
    069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00
    Guard against duplicate pipelines in forks
    
    - - - - -
    f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00
    dump-decls: fix "Ambiguous module name"-error
    
    Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package.
    
    ```
    dump-decls: <no location info>: error:
        Ambiguous module name `System.Console.ANSI.Types':
          it was found in multiple packages:
          ansi-terminal-0.11.4 ansi-terminal-types-0.11.5
    ```
    
    - - - - -
    edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00
    Fix MultiWayIf linearity checking (#23814)
    
    Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io>
    
    - - - - -
    4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00
    Update `Control.Concurrent.*` documentation
    
    - - - - -
    015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00
    Support 128-bit SIMD on AArch64 via LLVM backend
    
    - - - - -
    52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00
    Testsuite cleanup
    
    - Remove misleading help text in perf_notes, ways are not metrics
    - Remove no_print_summary - this was used for Phabricator
    - In linters tests, run 'git ls-files' just once.
      Previously, it was called on each has_ls_files()
    - Add ghc-prim.cabal to gitignore, noticed in #23726
    - Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd
    
    - - - - -
    ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00
    EPA: Use Introduce [DeclTag] in AnnSortKey
    
    The AnnSortKey is used to keep track of the order of declarations for
    printing when the container has split them apart.
    
    This applies to HsValBinds and ClassDecl, ClsInstDecl.
    
    When making modifications to the list of declarations, the new order
    must be captured for when it must be printed. For each list of
    declarations (binds and sigs for a HsValBind) we can just store the
    list in order.
    
    To recreate the list when printing, we must merge them, and this is
    what the AnnSortKey records. It used to be indexed by SrcSpan, we now
    simply index by a marker as to which list to take the next item from.
    
    - - - - -
    e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00
    Don't attempt pattern synonym error recovery
    
    This commit gets rid of the pattern synonym error recovery mechanism
    (recoverPSB). The rationale is that the fake pattern synonym binding
    that the recovery mechanism introduced could lead to undesirable
    knock-on errors, and it isn't really feasible to conjure up a
    satisfactory binding as pattern synonyms can be used both in expressions
    and patterns.
    See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn.
    
    It isn't such a big deal to eagerly fail compilation on a pattern synonym
    that doesn't typecheck anyway.
    
    Fixes #23467
    
    - - - - -
    6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00
    base: Don't use Data.ByteString.Internals.memcpy
    
    This function is now deprecated from `bytestring`. Use
    `Foreign.Marshal.Utils.copyBytes` instead.
    
    Fixes #23880.
    
    - - - - -
    0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    hadrian: Uniformly pass buildOptions to all builders in runBuilder
    
    In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo.
    
    This leads to hard to diagnose bugs as any build options you pass with
    runBuilderWithCmdOptions are ignored for many builders.
    
    Solution: Uniformly pass buildOptions to the invocation of cmd.
    
    Fixes #23845
    
    - - - - -
    9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    Abstract windows toolchain setup
    
    This commit splits up the windows toolchain setup logic into two
    functions.
    
    * FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if
      it isn't already downloaded
    * FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point
      to the correct place
    
    FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw
    toolchain and also the eventual location where we will install the
    toolchain in the installed bindist.
    
    This is the first step towards #23608
    
    - - - - -
    6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    Generate build.mk for bindists
    
    The config.mk.in script was relying on some variables which were
    supposed to be set by build.mk but therefore never were when used to
    install a bindist.
    
    Specifically
    
    * BUILD_PROF_LIBS to determine whether we had profiled libraries or not
    * DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or
      not
    
    Not only were these never set but also not really accurate because you
    could have shared libaries but still statically linked ghc executable.
    
    In addition variables like GhcLibWays were just never used, so those
    have been deleted from the script.
    
    Now instead we generate a build.mk file which just directly specifies
    which RtsWays we have supplied in the bindist and whether we have
    DYNAMIC_GHC_PROGRAMS.
    
    - - - - -
    fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00
    hadrian: Add reloc-binary-dist-* targets
    
    This adds a command line option to build a "relocatable" bindist.
    
    The bindist is created by first creating a normal bindist and then
    installing it using the `RelocatableBuild=YES` option. This creates a
    bindist without any wrapper scripts pointing to the libdir.
    
    The motivation for this feature is that we want to ship relocatable
    bindists on windows and this method is more uniform than the ad-hoc
    method which lead to bugs such as #23608 and #23476
    
    The relocatable bindist can be built with the "reloc-binary-dist" target
    and supports the same suffixes as the normal "binary-dist" command to
    specify the compression style.
    
    - - - - -
    41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    packaging: Fix installation scripts on windows/RelocatableBuild case
    
    This includes quite a lot of small fixes which fix the installation
    makefile to work on windows properly. This also required fixing the
    RelocatableBuild variable which seemed to have been broken for a long
    while.
    
    Sam helped me a lot writing this patch by providing a windows machine to
    test the changes. Without him it would have taken ages to tweak
    everything.
    
    Co-authored-by: sheaf <sam.derbyshire at gmail.com>
    
    - - - - -
    03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    ci: Build relocatable bindist on windows
    
    We now build the relocatable bindist target on windows, which means we
    test and distribute the new method of creating a relocatable bindist.
    
    - - - - -
    d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    hadrian: Add error when trying to build binary-dist target on windows
    
    The binary dist produced by `binary-dist` target doesn't work on windows
    because of the wrapper script the makefile installs. In order to not
    surprise any packagers we just give an error if someone tries to build
    the old binary-dist target rather than the reloc-binary-dist target.
    
    - - - - -
    7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00
    hadrian: Remove query' logic to use tooldir
    
    - - - - -
    03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00
    configure: Set WindresCmd directly and removed unused variables
    
    For some reason there was an indirection via the Windres variable before
    setting WindresCmd. That indirection led to #23855.
    
    I then also noticed that these other variables were just not used
    anywhere when trying to work out what the correct condition was for this
    bit of the configure script.
    
    - - - - -
    c82770f5 by sheaf at 2023-08-23T13:43:48-04:00
    Apply shellcheck suggestion to SUBST_TOOLDIR
    - - - - -
    896e35e5 by sheaf at 2023-08-23T13:44:34-04:00
    Compute hints from TcSolverReportMsg
    
    This commit changes how hints are handled in conjunction with
    constraint solver report messages.
    
    Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor,
    we compute the hints depending on the underlying TcSolverReportMsg.
    This disentangles the logic and makes it easier to add new hints for
    certain errors.
    
    - - - - -
    a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00
    users-guide: remove note about fatal Haddock parse failures
    
    - - - - -
    4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Introduce Data.Enum
    
    - - - - -
    f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Num.Integer
    
    - - - - -
    b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Num
    
    - - - - -
    6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Num.Natural
    
    - - - - -
    2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Float
    
    - - - - -
    f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add export list to GHC.Real
    
    - - - - -
    94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Eliminate module reexport in GHC.Exception
    
    The metric increase here isn't strictly due to this commit but it's a
    rather small, incidental change.
    
    Metric Increase:
        T8095
        T13386
    
    Metric Decrease:
        T8095
        T13386
        T18304
    
    - - - - -
    be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00
    base: Add disclaimers in internal modules
    
    To warn users that these modules are internal and their interfaces may
    change with little warning.
    
    As proposed in Core Libraries Committee #146 [CLC146].
    
    [CLC146]: https://github.com/haskell/core-libraries-committee/issues/146
    
    - - - - -
    0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00
    Bump Cabal submodule
    
    We need to bump the Cabal submodule to include commit ec75950
    which fixes an issue with a dodgy import Rep(..) which relied
    on GHC bug #23570
    
    - - - - -
    0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00
    Fix typos in the documentation of Data.OldList.permutations
    - - - - -
    1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00
    Be more eager in TyCon boot validity checking
    
    This commit performs boot-file consistency checking for TyCons into
    checkValidTyCl. This ensures that we eagerly catch any mismatches,
    which prevents the compiler from seeing these inconsistencies and
    panicking as a result.
    
    See Note [TyCon boot consistency checking] in GHC.Tc.TyCl.
    
    Fixes #16127
    
    - - - - -
    d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00
    Refactor estimation of stack info table provenance
    
    This commit greatly refactors the way we compute estimated provenance for stack
    info tables. Previously, this process was done using an entirely separate traversal
    of the whole Cmm code stream to build the map from info tables to source locations.
    The separate traversal is now fused with the Cmm code generation pipeline in
    GHC.Driver.Main.
    
    This results in very significant code generation speed ups when -finfo-table-map is
    enabled. In testing, this patch reduces code generation times by almost 30% with
    -finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 .
    
    Fixes #23103
    
    - - - - -
    d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00
    Add a test checking overhead of -finfo-table-map
    
    We want to make sure we don't end up with poor codegen performance resulting from
    -finfo-table-map again as in #23103. This test adds a performance test tracking
    total allocations while compiling ExactPrint with -finfo-table-map.
    
    - - - - -
    fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00
    llvmGen: Add export list to GHC.Llvm.MetaData
    
    - - - - -
    5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00
    llvmGen: Allow LlvmLits in MetaExprs
    
    This omission appears to be an oversight.
    
    - - - - -
    86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00
    compiler: Move platform feature predicates to GHC.Driver.DynFlags
    
    These are useful in `GHC.Driver.Config.*`.
    
    - - - - -
    a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00
    llvmGen: Introduce infrastructure for module flag metadata
    
    - - - - -
    e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00
    llvmGen: Don't pass stack alignment via command line
    
    As of https://reviews.llvm.org/D103048 LLVM no longer supports the
    `-stack-alignment=...` flag. Instead this information is passed via a
    module flag metadata node.
    
    This requires dropping support for LLVM 11 and 12.
    
    Fixes #23870
    
    - - - - -
    a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00
    EPA: Keep track of "in" token for WarningTxt category
    
    A warning can now be written with a category, e.g.
    
        {-# WARNInG in "x-c" e "d" #-}
    
    Keep track of the location of the 'in' keyword and string, as well as
    the original SourceText of the label, in case it uses character escapes.
    
    - - - - -
    3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00
    Remove redundant import in InfoTableProv
    
    The copyBytes function is provided by the import of Foreign.
    
    Fixes #23889
    
    - - - - -
    d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00
    gitlab/issue-template: Mention report-a-bug
    - - - - -
    50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30
    Added StandaloneKindSignature examples to replace CUSKs ones
    
    - - - - -
    2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00
    Remove outdated CPP in compiler/* and template-haskell/*
    
    The boot compiler was bumped to 9.4 in cebb5819b43.
    There is no point supporting older GHC versions with CPP.
    
    - - - - -
    5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30
    testsuite: Add regression test for #23861
    
    Simon says this was fixed by
    
    commit 8d68685468d0b6e922332a3ee8c7541efbe46137
    Author: sheaf <sam.derbyshire at gmail.com>
    Date:   Fri Aug 4 15:28:45 2023 +0200
    
        Remove zonk in tcVTA
    
    - - - - -
    b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00
    testsuite: Add regression test for #23864
    
    Simon says this was fixed by
    
    commit 59202c800f2c97c16906120ab2561f6e1556e4af
    Author: Sebastian Graf <sebastian.graf at kit.edu>
    Date:   Fri Mar 31 17:35:22 2023 +0200
    
        CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead
    
        We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now.
        The main reason is that it plays far better in conjunction with eta expansion
        (as we aim to do for arguments in CorePrep, #23083), because we can discard
        any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta`
        it's impossible to discard the argument.
    
    - - - - -
    9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00
    Remove ScopedTypeVariables => TypeAbstractions
    
    This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/)
    to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448)
    by removing the implication of language extensions
    
      ScopedTypeVariables => TypeAbstractions
    
    To limit breakage, we now allow type arguments in constructor patterns
    when both ScopedTypeVariables and TypeApplications are enabled, but
    we emit a warning notifying the user that this is deprecated behaviour
    that will go away starting in GHC 9.12.
    
    Fixes #23776
    
    - - - - -
    fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00
    .stderr: ScopedTypeVariables =/> TypeAbstractions
    
    This commit accepts testsuite changes for the changes in the previous
    commit, which mean that TypeAbstractions is no longer implied by
    ScopedTypeVariables.
    
    - - - - -
    4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00
    Repair `codes` test on OpenBSD by explicitly requesting extended RE
    
    - - - - -
    6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
    Add test for #23540
    
    `T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so
    `explainEv` has been moved to `TestUtils.hs`.
    
    - - - - -
    257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
    Add test for #23120
    
    - - - - -
    4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
    Make some evidence uses reachable by toHie
    
    Resolves #23540, #23120
    
    This adds spans to certain expressions in the typechecker and renamer,
    and lets 'toHie' make use of those spans. Therefore the relevant
    evidence uses for the following syntax will now show up under the
    expected nodes in 'HieAst's:
    
    - Overloaded literals ('IsString', 'Num', 'Fractional')
    
    - Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the
      overloaded literals being matched on)
    
    - Arithmetic sequences ('Enum')
    
    - Monadic bind statements ('Monad')
    
    - Monadic body statements ('Monad', 'Alternative')
    
    - ApplicativeDo ('Applicative', 'Functor')
    
    - Overloaded lists ('IsList')
    
    Also see Note [Source locations for implicit function calls]
    
    In the process of handling overloaded lists I added an extra 'SrcSpan'
    field to 'VAExpansion' - this allows us to more accurately reconstruct
    the locations from the renamer in 'rebuildHsApps'. This also happens to
    fix #23120.
    
    See the additions to Note [Looking through HsExpanded]
    
    - - - - -
    fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00
    ghc-heap: rename C file (fix #23898)
    
    - - - - -
    b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00
    Misc cleanup
    
    - Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples.
      Rename to ReturnsTuple.
    - Builtin.Utils: use SDoc for a panic message.
      The comment about <<details unavailable>> was obsoleted by e8d356773b56.
    - TagCheck: fix wrong logic. It was zipping a list 'args' with its
      version 'args_cmm' after filtering.
    - Core.Type: remove an outdated 1999 comment about unlifted polymorphic types
    - hadrian: remove leftover debugging print
    
    - - - - -
    3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00
    Add a regression test for #23903
    
    The bug has been fixed by commit bad2f8b8aa8424.
    
    - - - - -
    21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00
    README: Refer to ghc-hq repository for contributor and governance information
    
    - - - - -
    e542d590 by sheaf at 2023-08-29T19:52:40-04:00
    Export setInertSet from GHC.Tc.Solver.Monad
    
    We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad.
    These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed
    the export of setInertSet, but that function is useful for the GHC API.
    
    - - - - -
    694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00
    Don't bundle children for non-parent Avails
    
    We used to bundle all children of the parent Avail with things that
    aren't the parent, e.g. with
    
      class C a where
        type T a
        meth :: ..
    
    we would bundle the whole Avail (C, T, meth) with all of C, T and meth,
    instead of only with C.
    
    Avoiding this fixes #23570
    
    - - - - -
    d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00
    Fix typos
    
    - - - - -
    d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00
    JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806)
    
    - - - - -
    e2940272 by David Binder at 2023-08-30T19:43:08-04:00
    Bump submodules of hpc and hpc-bin to version 0.7.0.0
    
    hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify
    compatibility with newer versions of the directory package which
    dropped all SafeHaskell guarantees.
    
    - - - - -
    5d56d05c by David Binder at 2023-08-30T19:43:08-04:00
    Bump hpc bound in ghc.cabal.in
    
    - - - - -
    99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
    ghc classes documentation: rm redundant comment
    
    - - - - -
    fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00
    prelude documentation: various nits
    
    - - - - -
    48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
    integer documentation: minor corrections
    
    - - - - -
    20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
    real documentation: nits
    
    - - - - -
    dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00
    Add a test for #21765
    
    This issue (of reporting a constraint as being redundant even though
    removing it causes typechecking to fail) was fixed in aed1974e.
    This commit simply adds a regression test.
    
    Fixes #21765
    
    - - - - -
    f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00
    Export foldl' from Prelude and bump submodules
    
    See https://github.com/haskell/core-libraries-committee/issues/167 for discussion
    
    Metric Decrease:
        T8095
        T13386
    Metric Increase:
        T13386
        T8095
    
    T8095 ghc/alloc decreased on x86_64, but increased on aarch64.
    T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms.
    Neither has anything to do with `foldl'`, so I conclude that both are flaky.
    
    - - - - -
    3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00
    Allow cross-tyvar defaulting proposals from plugins
    
    Fixes #23832.
    
    - - - - -
    e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00
    Clarify Note [GlobalId/LocalId] after CorePrep (#23797)
    
    Fixes #23797.
    
    - - - - -
    ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00
    Fix warning with UNPACK on sum type (#23921)
    
    - - - - -
    9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00
    hadrian: track python dependencies in doc rules
    
    - - - - -
    1578215f by sheaf at 2023-09-05T00:38:26-04:00
    Bump Haddock to fix #23616
    
    This commit updates the Haddock submodule to include
    the fix to #23616.
    
    Fixes #23616
    
    - - - - -
    5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00
    Fix example in GHC user guide in SafeHaskell section
    
    The example given in the SafeHaskell section uses an implementation of
    Monad which no longer works. This MR removes the non-canonical return
    instance and adds the necessary instances of Functor and Applicative.
    
    - - - - -
    291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00
    driver: Check transitive closure of haskell package dependencies when deciding whether to relink
    
    We were previously just checking whether direct package dependencies had
    been modified. This caused issues when compiling without optimisations
    as we wouldn't relink the direct dependency if one of its dependenices
    changed.
    
    Fixes #23724
    
    - - - - -
    35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00
    Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic
    
    Fixes #23930
    
    - - - - -
    3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00
    Make STG rewriter produce updatable closures
    
    - - - - -
    0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00
    configure: update message to use hadrian (#22616)
    
    - - - - -
    b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00
    EPA: Incorrect locations for UserTyVar with '@'
    
    In T13343.hs, the location for the @ is not within the span of the
    surrounding UserTyVar.
    
      type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v
    
    Widen it so it is captured.
    
    Closes #23887
    
    - - - - -
    8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00
    Bump haddock submodule to fix #23920
    
    Removes the fake export of `FUN` from Prelude. Fixes #23920.
    
    Bumps haddock submodule.
    
    - - - - -
    e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00
    Fix wrong role in mkSelCo_maybe
    
    In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a,
    and call mkSelCo (SelTyCon 1 nominal) Refl.
    The function incorrectly returned Refl :: a ~R a. The returned role
    should be nominal, according to the SelCo rule:
    
          co : (T s1..sn) ~r0 (T t1..tn)
          r = tyConRole tc r0 i
          ----------------------------------
          SelCo (SelTyCon i r) : si ~r ti
    
    In this test case, r is nominal while r0 is representational.
    
    - - - - -
    1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00
    If we have multiple defaulting plugins, then we should zonk in between them
    
    after any defaulting has taken place, to avoid a defaulting plugin seeing
    a metavariable that has already been filled.
    
    Fixes #23821.
    
    - - - - -
    eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00
    Improvements to the documentation of defaulting plugins
    
    Based on @simonpj's draft and comments in !11117
    
    - - - - -
    ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00
    EPA: Incorrect span for LWarnDec GhcPs
    
    The code (from T23465.hs)
    
        {-# WARNInG in "x-c" e "d" #-}
        e = e
    
    gives an incorrect span for the LWarnDecl GhcPs
    
    Closes #23892
    
    It also fixes the Test23465/Test23464 mixup
    
    - - - - -
    a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00
    Valid hole fits: don't suggest unsafeCoerce (#17940)
    
    - - - - -
    88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00
    Add warning for badly staged types.
    
    Resolves #23829.
    
    The stage violation results in out-of-bound names in splices.
    Technically this is an error, but someone might rely on this!?
    
    Internal changes:
    - we now track stages for TyVars.
    - thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does
      in fact rename its argument type, and it can contain variables.
    
    - - - - -
    9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00
    rts: Fix invalid symbol type
    
    I suspect this code is dead since we haven't observed this failing
    despite the obviously incorrect macro name.
    
    - - - - -
    03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00
    testsuite: Add simple test exercising C11 atomics in GHCi
    
    See #22012.
    
    - - - - -
    1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00
    rts/RtsSymbols: Add AArch64 outline atomic operations
    
    Fixes #22012 by adding the symbols described in
    https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic.
    
    Ultimately this would be better addressed by #22011, but this is a first
    step in the right direction and fixes the immediate symptom.
    
    Note that we dropped the `__arch64_cas16` operations as these provided
    by all platforms's compilers. Also, we don't link directly against the
    libgcc/compiler-rt definitions but rather provide our own wrappers to
    work around broken toolchains (e.g. https://bugs.gentoo.org/868018).
    
    Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733.
    
    - - - - -
    8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00
    ci: Build debian12 and fedora38 bindists
    
    This adds builds for the latest releases for fedora and debian
    
    We build these bindists in nightly and release pipelines.
    
    - - - - -
    a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00
    Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods.
    
    - - - - -
    98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00
    docs: move -xn flag beside --nonmoving-gc
    
    It makes sense to have these beside each other as they are aliases.
    
    - - - - -
    f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00
    nonmoving: introduce a family of dense allocators
    
    Supplement the existing power 2 sized nonmoving allocators with a family
    of dense allocators up to a configurable threshold.
    
    This should reduce waste from rounding up block sizes while keeping the
    amount of allocator sizes manageable.
    
    This patch:
      - Adds a new configuration option `--nonmoving-dense-allocator-count`
        to control the amount of these new dense allocators.
      - Adds some constants to `NonmovingAllocator` in order to keep
        marking fast with the new allocators.
    
    Resolves #23340
    
    - - - - -
    2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00
    Add changelog entry for #23340
    
    - - - - -
    f96fe681 by sheaf at 2023-09-12T04:31:44-04:00
    Use printGhciException in run{Stmt, Decls}
    
    When evaluating statements in GHCi, we need to use printGhciException
    instead of the printException function that GHC provides in order to
    get the appropriate error messages that are customised for ghci use.
    
    - - - - -
    d09b932b by psilospore at 2023-09-12T04:31:44-04:00
    T23686: Suggest how to enable Language Extension when in ghci
    Fixes #23686
    
    - - - - -
    da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00
    Unarise: Split Rubbish literals in function args
    
    Fixes #23914.  Also adds a check to STG lint that
    these args are properly unary or nullary after unarisation
    
    - - - - -
    261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00
    darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13
    
    This bumps the minumum supported version to 10.13 (High Sierra) which is
    6 years old at this point.
    
    Fixes #22938
    
    - - - - -
    f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00
    Fix TH pretty-printing of nested GADTs, issue #23937
    
    This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly
    pretty-prints GADTs declarations contained within data family instances.
    
    Fixes #23937
    
    - - - - -
    d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00
    Put hadrian non-bootstrap plans through `jq`
    
    This makes it possible to review changes with conventional diffing
    tools.
    
    This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left
    off.
    
    - - - - -
    ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00
    JS: fix some tests
    
    - Tests using Setup programs need to pass --with-hc-pkg
    - Several other fixes
    
    See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage
    for the current status
    
    - - - - -
    fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00
    Fix in-scope set assertion failure (#23918)
    
    Patch by Simon
    
    - - - - -
    21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00
    Add -Winconsistent-flags warning
    
    The warning fires when inconsistent command line flags are passed.
    
    For example:
    
    * -dynamic-too and -dynamic
    * -dynamic-too on windows
    * -O and --interactive
    * etc
    
    This is on by default and allows users to control whether the warning is
    displayed and whether it should be an error or not.
    
    Fixes #22572
    
    - - - - -
    dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00
    Avoid serializing BCOs with the internal interpreter
    
    Refs #23919
    
    - - - - -
    9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00
    Fix numa auto configure
    
    - - - - -
    98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00
    Add -fno-cse to T15426 and T18964
    
    This -fno-cse change is to avoid these performance tests depending on
    flukey CSE stuff.  Each contains several independent tests, and we don't
    want them to interact.
    
    See #23925.
    
    By killing CSE we expect a 400% increase in T15426, and 100% in T18964.
    
    Metric Increase:
        T15426
        T18964
    
    - - - - -
    236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00
    Tiny refactor
    
    canEtaReduceToArity was only called internally, and always with
    two arguments equal to zero.  This patch just specialises the
    function, and renames it to cantEtaReduceFun.
    
    No change in behaviour.
    
    - - - - -
    56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00
    spec-constr: Lift argument limit for SPEC-marked functions
    
    When the user adds a SPEC argument to a function, they are informing us
    that they expect the function to be specialised. However, previously
    this instruction could be preempted by the specialised-argument limit
    (sc_max_args). Fix this.
    
    This fixes #14003.
    
    - - - - -
    6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00
    Fix eta reduction
    
    Issue #23922 showed that GHC was bogusly eta-reducing a join point.
    We should never eta-reduce (\x -> j x) to j, if j is a join point.
    
    It is extremly difficult to trigger this bug.  It took me 45 mins of
    trying to make a small tests case, here immortalised as T23922a.
    
    - - - - -
    e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00
    Profiling: Properly escape characters when using `-pj`.
    
    There are some ways in which unusual characters like quotes or others
    can make it into cost centre names. So properly escape these.
    
    Fixes #23924
    
    - - - - -
    ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00
    Use clearer example variable names for bool eliminator
    
    - - - - -
    5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00
    Add missing int64/word64-to-double/float rules (#23907)
    
    CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203
    
    - - - - -
    566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00
    Fix and test TH pretty-printing of type operator role declarations
    
    This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it
    correctly pretty-prints `type role` declarations for operator names.
    
    Fixes #23954
    
    - - - - -
    8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00
    Use correct FunTyFlag in adjustJoinPointType
    
    As the Lint error in #23952 showed, the function adjustJoinPointType
    was failing to adjust the FunTyFlag when adjusting the type.
    
    I don't think this caused the seg-fault reported in the ticket,
    but it is definitely.  This patch fixes it.
    
    It is tricky to come up a small test case; Krzysztof came up with
    this one, but it only triggers a failure in GHC 9.6.
    
    - - - - -
    778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00
    Update to Unicode 15.1.0
    
    See: https://www.unicode.org/versions/Unicode15.1.0/
    
    - - - - -
    f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00
    EPA: track unicode version for unrestrictedFunTyCon
    
    Closes #23885
    
    Updates haddock submodule
    
    - - - - -
    9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00
    Bump parsec submodule to allow text-2.1 and bytestring-0.12
    
    - - - - -
    7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00
    base: Advertise linear time of readFloat
    
    As noted in #23538, `readFloat` has runtime that scales nonlinearly in
    the size of its input. Consequently, its use on untrusted input can
    be exploited as a denial-of-service vector. Point this out and suggest
    use of `read` instead.
    
    See #23538.
    
    - - - - -
    f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00
    Remove dead code GHC.CoreToStg.Prep.canFloat
    
    This function never fires, so we can delete it: #23965.
    
    - - - - -
    ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00
    base/changelog: Move fix for #23907 to 9.8.1 section
    
    Since the fix was backported to 9.8.1
    
    - - - - -
    51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00
    Add aarch64 alpine bindist
    
    This is dynamically linked and makes creating statically linked
    executables more straightforward.
    
    Fixes #23482
    
    - - - - -
    02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00
    Add aarch64-deb11 bindist
    
    This adds a debian 11 release job for aarch64.
    
    Fixes #22005
    
    - - - - -
    8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00
    Don’t store the async exception masking state in CATCH frames
    
    - - - - -
    86d2971e by doyougnu at 2023-09-19T19:08:19-04:00
    compiler,ghci: error codes link to HF error index
    
    closes: #23259
    
    - adds -fprint-error-index-links={auto|always|never} flag
    
    - - - - -
    5f826c18 by sheaf at 2023-09-19T19:09:03-04:00
    Pass quantified tyvars in tcDefaultAssocDecl
    
    This commit passes the correct set of quantified type variables written
    by the user in associated type default declarations for validity
    checking. This ensures that validity checking of associated type defaults
    mirrors that of standalone type family instances.
    
    Fixes #23768 (see testcase T23734 in subsequent commit)
    
    - - - - -
    aba18424 by sheaf at 2023-09-19T19:09:03-04:00
    Avoid panic in mkGADTVars
    
    This commit avoids panicking in mkGADTVars when we encounter
    a type variable as in #23784 that is bound by a user-written
    forall but not actually used.
    
    Fixes #23784
    
    - - - - -
    a525a92a by sheaf at 2023-09-19T19:09:03-04:00
    Adjust reporting of unused tyvars in data FamInsts
    
    This commit adjusts the validity checking of data family
    instances to improve the reporting of unused type variables.
    
    See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity.
    
    The problem was that, in a situation such as
    
      data family D :: Type
      data instance forall (d :: Type). D = MkD
    
    the RHS passed to 'checkFamPatBinders' would be the TyCon app
    
      R:D d
    
    which mentions the type variable 'd' quantified in the user-written
    forall. Thus, when computing the set of unused type variables in
    the RHS of the data family instance, we would find that 'd' is used,
    and report a strange error message that would say that 'd' is not
    bound on the LHS.
    
    To fix this, we special-case the data-family instance case,
    manually extracting all the type variables that appear in the
    arguments of all the data constructores of the data family instance.
    
    Fixes #23778
    
    - - - - -
    28dd52ee by sheaf at 2023-09-19T19:09:03-04:00
    Unused tyvars in FamInst: only report user tyvars
    
    This commit changes how we perform some validity checking for
    coercion axioms to mirror how we handle default declarations for
    associated type families. This allows us to keep track of whether
    type variables in type and data family instances were user-written
    or not, in order to only report the user-written ones in
    "unused type variable" error messages.
    
    Consider for example:
    
      {-# LANGUAGE PolyKinds #-}
      type family F
      type instance forall a. F = ()
    
    In this case, we get two quantified type variables,
    (k :: Type) and (a :: k); the second being user-written, but the first
    is introduced by the typechecker. We should only report 'a' as being
    unused, as the user has no idea what 'k' is.
    
    Fixes #23734
    
    - - - - -
    1eed645c by sheaf at 2023-09-19T19:09:03-04:00
    Validity: refactor treatment of data families
    
    This commit refactors the reporting of unused type variables in type
    and data family instances to be more principled. This avoids ad-hoc
    logic in the treatment of data family instances.
    
    - - - - -
    35bc506b by John Ericson at 2023-09-19T19:09:40-04:00
    Remove `ghc-cabal`
    
    It is dead code since the Make build system was removed.
    
    I tried to go over every match of `git grep -i ghc-cabal` to find other
    stray bits. Some of those might be workarounds that can be further
    removed.
    
    - - - - -
    665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00
    Re-add unregisterised build support for sparc and sparc64
    
    Closes #23959
    
    - - - - -
    142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00
    Bump ci-images to use updated version of Alex
    
    Fixes #23977
    
    - - - - -
    fa977034 by John Ericson at 2023-09-21T12:55:25-04:00
    Use Cabal 3.10 for Hadrian
    
    We need the newer version for `CABAL_FLAG_*` env vars for #17191.
    
    - - - - -
    a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: `need` any `configure` script we will call
    
    When the script is changed, we should reconfigure.
    
    - - - - -
    db882b57 by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: Make it easier to debug Cabal configure
    
    Right now, output is squashed. This make per-package configure scripts
    extremely hard to maintain, because we get vague "library is missing"
    errors when the actually probably is usually completely unrelated except
    for also involving the C/C++ toolchain.
    
    (I can always pass `-VVV` to Hadrian locally, but these errors are
    subtle and I often cannot reproduce them locally!)
    
    `--disable-option-checking` was added back in
    75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill;
    if other flags are passed that are not recognized behind the two from
    Cabal mentioned in the former comment, we *do* want to know about it.
    
    - - - - -
    7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00
    hadrian: Increase verbosity of certain cabal commands
    
    This is a hack to get around the cabal function we're calling
    *decreasing* the verbosity it passes to another function, which is the
    stuff we often actually care about. Sigh.
    
    Keeping this a separate commit so if this makes things too verbose it is
    easy to revert.
    
    - - - - -
    a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00
    rts: Move most external symbols logic to the configure script
    
    This is much more terse because we are programmatically handling the
    leading underscore.
    
    `findPtr` however is still handled in the Cabal file because we need a
    newer Cabal to pass flags to the configure script automatically.
    
    Co-Authored-By: Ben Gamari <ben at well-typed.com>
    
    - - - - -
    56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00
    Bump Cabal submodule to allow text-2.1 and bytestring-0.12
    
    - - - - -
    0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00
    hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist
    
    - - - - -
    b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00
    Bump hadrian's index-state to upgrade alex at least to 3.2.7.3
    
    - - - - -
    11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00
    JS: correct file size and times
    
    Programs produced by the JavaScript backend were returning
    incorrect file sizes and modification times, causing cabal
    related tests to fail.
    
    This fixes the problem and adds an additional test that verifies
    basic file information operations.
    
    fixes #23980
    
    - - - - -
    b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00
    gitlab-ci: Drop libiserv from upload_ghc_libs
    
    libiserv has been merged into the ghci package.
    
    - - - - -
    37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00
    testsuite: Fix Windows line endings
    
    - - - - -
    5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00
    testsuite: Use makefile_test
    
    - - - - -
    15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00
    system-cxx-std-lib: Add license and description
    - - - - -
    0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00
    gitlab/issue-templates: Rename bug.md -> default.md
    
    So that it is visible by default.
    
    - - - - -
    23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00
    Bump submodule text to 2.1
    
    - - - - -
    b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00
    Bump submodule unix to 2.8.2.1
    
    - - - - -
    54b2016e by John Ericson at 2023-09-23T11:40:41-04:00
    Move lib{numa,dw} defines to RTS configure
    
    Clean up the m4 to handle the auto case always and be more consistent.
    Also simplify the CPP --- we should always have both headers if we are
    using libnuma.
    
    "side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to
    better separate searching from actions taken based on search results.
    This might seem overkill now, but will make shuffling logic between
    configure scripts easier later.
    
    The macro comments are converted from `dnl` to `#` following the
    recomendation in
    https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html
    
    - - - - -
    d51b601b by John Ericson at 2023-09-23T11:40:50-04:00
    Shuffle libzstd configuring between scripts
    
    Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS
    configure, `AC_SUBST` goes to the top-level configure script, and the
    documentation of the m4 macro is improved.
    
    - - - - -
    d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00
    Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure
    
    It is just `AC_DEFINE` it belongs there instead.
    
    - - - - -
    18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00
    Move mmap in the runtime linker check to the RTS configure
    
    `AC_DEFINE` should go there instead.
    
    - - - - -
    74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00
    Elaborate comment on GHC_NO_UNICODE
    
    - - - - -
    de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00
    gitlab-ci: Mark T22012 as broken on CentOS 7
    
    Due to #23979.
    
    - - - - -
    6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00
    hadrian: better error for failing to find file's dependencies
    
    Resolves #24004
    
    - - - - -
    d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Refactor uses of `partitionEithers . map`
    
    This patch changes occurences of the idiom
    `partitionEithers (map f xs)` by the simpler form
    `partitionWith f xs` where `partitionWith` is the utility function
    defined in `GHC.Utils.Misc`.
    
    Resolves: #23953
    
    - - - - -
    8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Refactor uses of `partitionEithers <$> mapM f xs`
    
    This patch changes occurences of the idiom
    `partitionEithers <$> mapM f xs` by the simpler form
    `partitionWithM f xs` where `partitionWithM` is a utility function
    newly added to `GHC.Utils.Misc`.
    
    - - - - -
    6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
    Mark `GHC.Utils.Misc.partitionWithM` as inlineable
    
    This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure
    that the right-hand side of the definition of this function remains
    available for specialisation at call sites.
    
    - - - - -
    f1e5245a by David Binder at 2023-09-27T01:19:00-04:00
    Add RTS option to supress tix file
    
    - - - - -
    1f43124f by David Binder at 2023-09-27T01:19:00-04:00
    Add expected output to testsuite in test interface-stability/base-exports
    
    - - - - -
    b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00
    Expose HpcFlags and getHpcFlags from GHC.RTS.Flags
    
    - - - - -
    345675c6 by David Binder at 2023-09-27T01:19:00-04:00
    Fix expected output of interface-stability test
    
    - - - - -
    146e1c39 by David Binder at 2023-09-27T01:19:00-04:00
    Implement getHpcFlags
    
    - - - - -
    61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00
    Add section in user guide
    
    - - - - -
    ea05f890 by David Binder at 2023-09-27T01:19:01-04:00
    Rename --emit-tix-file to --write-tix-file
    
    - - - - -
    cabce2ce by David Binder at 2023-09-27T01:19:01-04:00
    Update the golden files for interface stability
    
    - - - - -
    1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00
    Refactor: introduce stgArgRep
    
    The function 'stgArgType' returns the type in STG. But this violates
    the abstraction: in STG we're supposed to operate on PrimReps.
    
    This introduces
    stgArgRep ty = typePrimRep (stgArgType ty)
    stgArgRep1 ty = typePrimRep1 (stgArgType ty)
    stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty)
    
    stgArgType is still directly used for unboxed tuples (should be fixable), FFI
    and in ticky.
    
    - - - - -
    b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00
    Fix TH pretty-printer's parenthesization
    
    This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed.
    
    Fixes #23962, #23968, #23971, and #23986
    
    - - - - -
    79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00
    Add a testcase for #17564
    
    The code in the ticket relied on the behaviour of Derived constraints.
    Derived constraints were removed in GHC 9.4 and now the code works
    as expected.
    
    - - - - -
    d7a80143 by sheaf at 2023-09-28T03:25:53-04:00
    lint-codes: add new modes of operation
    
    This commit adds two new modes of operation to the lint-codes
    utility:
    
      list - list all statically used diagnostic codes
      outdated - list all outdated diagnostic codes
    
    The previous behaviour is now:
    
      test - test consistency and coverage of diagnostic codes
    
    - - - - -
    477d223c by sheaf at 2023-09-28T03:25:53-04:00
    lint codes: avoid using git-grep
    
    We manually traverse through the filesystem to find the diagnostic codes
    embedded in .stdout and .stderr files, to avoid any issues with old
    versions of grep.
    
    Fixes #23843
    
    - - - - -
    a38ae69a by sheaf at 2023-09-28T03:25:53-04:00
    lint-codes: add Hadrian targets
    
    This commit adds new Hadrian targets:
    
      codes, codes:used - list all used diagnostic codes
      codes:outdated - list outdated diagnostic codes
    
    This allows users to easily query GHC for used and outdated
    diagnostic codes, e.g.
    
      hadrian/build -j --flavour=<..> codes
    
    will list all used diagnostic codes in the command line by running
    the lint-codes utility in the "list codes" mode of operation.
    
    The diagnostic code consistency and coverage test is still run as usual,
    through the testsuite:
    
      hadrian/build test --only="codes"
    
    - - - - -
    9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00
    hadrian: Install LICENSE files in bindists
    
    Fixes #23548.
    
    - - - - -
    b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00
    Fix visibility when eta-reducing a type lambda
    
    Fixes #24014.
    
    - - - - -
    d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00
    Fix several mistakes around free variables in iface breakpoints
    
    Fixes #23612 , #23607, #23998 and #23666.
    
    MR: !11026
    
    The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons:
    
    * IfaceBreakpoint created binders for free variables instead of expressions
    
    * When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped
    
    - - - - -
    ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00
    Refactor to combine HsLam and HsLamCase
    
    This MR is pure refactoring (#23916):
    * Combine `HsLam` and `HsLamCase`
    * Combine `HsCmdLam` and `HsCmdLamCase`
    
    This just arranges to treat uniformly
       \x -> e
       \case pi -> ei
       \cases pis -> ie
    
    In the exising code base the first is treated differently
    to the latter two.
    
    No change in behaviour.
    
    More specifics:
    
    * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering
      * Lambda
      * `\case`
      * `\cases`
    
    * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases.
    
    * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one.
    
    * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.)
    
    * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument.
    
    * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument.
    
    * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
    
    * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
    
    * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one.
    
    * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one.
    
    p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one.
    
    Phew!
    
    - - - - -
    b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
    Arm: Make ppr methods easier to use by not requiring NCGConfig
    
    - - - - -
    2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
    AArch64: Fix broken conditional jumps for offsets >= 1MB
    
    Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps
    to avoid overflowing the immediate.
    
    Fixes #23746
    
    - - - - -
    1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00
    EPA: Replace Monoid with NoAnn
    
    We currently use the Monoid class as a constraint on Exact Print
    Annotation functions, so we can use mempty. But this leads to
    requiring Semigroup instances too, which do not always make sense.
    
    Instead, introduce a class NoAnn, with a function noAnn analogous to
    mempty.
    
    Closes #20372
    
    Updates haddock submodule
    
    - - - - -
    c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00
    users-guide: Refactor handling of :base-ref: et al.
    
    - - - - -
    bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00
    Simplify and correct nasty case in coercion opt
    
    This fixes #21062.
    
    No test case, because triggering this code seems challenging.
    
    - - - - -
    9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Bump bytestring submodule to 0.12.0.2
    
    - - - - -
    4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
    Inline bucket_match
    
    - - - - -
    f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00
    configure: Fix #21712 again
    
    This is a bit of a shot in the dark to fix #24033, which appears to be
    another instance of #21712. For some reason the ld-override logic
    *still* appears to be active on Darwin targets (or at least one).
    Consequently, on misconfigured systems we may choose a non-`ld64`
    linker.
    
    It's a bit unclear exactly what happened in #24033 but ultimately the
    check added for #21712 was not quite right, checking for the
    `ghc_host_os` (the value of which depends upon the bootstrap compiler)
    instead of the target platform. Fix this.
    
    Fixes #24033.
    
    - - - - -
    2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00
    Add a regression test for #24029
    
    - - - - -
    8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00
    Fix non-symbolic children lookup of fixity decl
    
    The fix for #23664 did not correctly account for non-symbolic names
    when looking up children of a given parent. This one-line fix changes
    that.
    
    Fixes #24037
    
    - - - - -
    a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00
    rts: fix incorrect ticket reference
    
    - - - - -
    e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00
    users-guide: Fix discussion of -Wpartial-fields
    
     * fix a few typos
     * add a new example showing when the warning fires
     * clarify the existing example
     * point out -Wincomplete-record-selects
    
    Fixes #24049.
    
    - - - - -
    8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00
    Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"
    
    This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.
    
    `-optP` should pass options to the preprocessor, that might be a very
    different program to the C compiler, so passing the options to the C
    compiler is likely to result in `-optP` being useless.
    
    Fixes #17185 and #21291
    
    - - - - -
    8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00
    rts/nonmoving: Fix on LLP64 platforms
    
    Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL`
    size suffix. However, this is wrong on LLP64 platforms like Windows,
    where `long` is 32-bits.
    
    Fixes #23003.
    Fixes #24042.
    
    - - - - -
    f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00
    Fix isAArch64Bitmask for 32bit immediates.
    
    Fixes #23802
    
    - - - - -
    63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00
    Work around perf note fetch failure
    
    Addresses #24055.
    
    - - - - -
    242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00
    Add a test for #21348
    
    - - - - -
    7d390bce by Rewbert at 2023-10-05T05:38:08-04:00
    Fixes #24046
    
    - - - - -
    69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00
    Ensure unconstrained instance dictionaries get IPE info
    
    In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up
    with an initial source span based on the span of the binder, which was causing
    instance dictionaries without dynamic superclass constraints to not have source
    locations in their IPE info. Now they do.
    
    Resolves #24005
    
    - - - - -
    390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00
    rts: Split up rts/include/stg/MachRegs.h by arch
    
    - - - - -
    3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00
    Actually set hackage index state
    
    Or at least, use a version of the cabal command that *claims* to set the
    index state.
    
    Time will tell.
    
    - - - - -
    46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00
    Update hackage index state
    
    - - - - -
    d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00
    Ensure hadrian uses CI's hackage index state
    
    - - - - -
    e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00
    Do not use O_NONBLOCK on regular files or block devices
    
    CLC proposal https://github.com/haskell/core-libraries-committee/issues/166
    
    - - - - -
    a06197c4 by David Binder at 2023-10-08T15:06:55-04:00
    Update hpc-bin submodule to 0.69
    
    - - - - -
    ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00
    Update Hadrian with correct path to happy file for hpc-bin
    
    - - - - -
    94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00
    EPA: Introduce HasAnnotation class
    
    The class is defined as
    
        class HasAnnotation e where
          noAnnSrcSpan :: SrcSpan -> e
    
    This generalises noAnnSrcSpan, and allows
    
        noLocA :: (HasAnnotation e) => a -> GenLocated e a
        noLocA = L (noAnnSrcSpan noSrcSpan)
    
    - - - - -
    8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00
    Bump unix submodule to v2.8.3.0
    
    - - - - -
    e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00
    Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.
    
    The motivation for the flag is given in #21917.
    
    - - - - -
    3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Add ghcToolchain to tool args list
    
    This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.
    
    - - - - -
    476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Normalise triple via config.sub
    
    We were not normalising the target triple anymore like we did with the
    old make build system.
    
    Fixes #23856
    
    - - - - -
    303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add missing vendor normalisation
    
    This is copied from m4/ghc_convert_vendor.m4
    
    Towards #23868
    
    - - - - -
    838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add loongarch64 to parseArch
    
    Towards #23868
    
    - - - - -
    1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Add same LD hack to ghc-toolchain
    
    In the ./configure script, if you pass the `LD` variable then this has
    the effect of stopping use searching for a linker and hence passing
    `-fuse-ld=...`.
    
    We want to emulate this logic in ghc-toolchain, if a use explicilty
    specifies `LD` variable then don't add `-fuse-ld=..` with the goal of
    making ./configure and ghc-toolchain agree on which flags to use when
    using the C compiler as a linker.
    
    This is quite unsavoury as we don't bake the choice of LD into the
    configuration anywhere but what's important for now is making
    ghc-toolchain and ./configure agree as much as possible.
    
    See #23857 for more discussion
    
    - - - - -
    42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check for C99 support with -std=c99
    
    Previously we failed to try enabling C99 support with `-std=c99`, as
    `autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which
    don't enable C99 by default.
    
    Fixes #23879.
    
    - - - - -
    da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro
    
    In very old toolchains the BYTE_ORDER macro is not set but thankfully
    the __BYTE_ORDER__ macro can be used instead.
    
    - - - - -
    d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: AC_PATH_TARGET_TOOL for LD
    
    We want to make sure that LD is set to an absolute path in order to be
    consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL
    macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which
    might use a relative path.
    
    - - - - -
    171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Check whether we need -std=gnu99 for CPP as well
    
    In ./configure the C99 flag is passed to the C compiler when used as a C
    preprocessor. So we also check the same thing in ghc-toolchain.
    
    - - - - -
    89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Check for --target linker flag separately to C compiler
    
    There are situations where the C compiler doesn't accept `--target` but
    when used as a linker it does (but doesn't do anything most likely)
    
    In particular with old gcc toolchains, the C compiler doesn't support
    --target but when used as a linker it does.
    
    - - - - -
    37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    Use Cc to compile test file in nopie check
    
    We were attempting to use the C compiler, as a linker, to compile a file
    in the nopie check, but that won't work in general as the flags we pass
    to the linker might not be compatible with the ones we pass when using
    the C compiler.
    
    - - - - -
    9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Error when ghc-toolchain fails to compile
    
    This is a small QOL change as if you are working on ghc-toolchain and it
    fails to compile then configure will continue and can give you outdated
    results.
    
    - - - - -
    1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00
    configure: Check whether -no-pie works when the C compiler is used as a linker
    
    `-no-pie` is a flag we pass when using the C compiler as a linker (see
    pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
    compiler used as a linker supports the flag, rather than just the C
    compiler.
    
    - - - - -
    62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00
    ghc-toolchain: Remove javascript special case for --target detection
    
    emcc when used as a linker seems to ignore the --target flag, and for
    consistency with configure which now tests for --target, we remove this
    special case.
    
    - - - - -
    0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00
    toolchain: Don't pass --target to emscripten toolchain
    
    As noted in `Note [Don't pass --target to emscripten toolchain]`,
    emscripten's `emcc` is rather inconsistent with respect to its treatment
    of the `--target` flag. Avoid this by special-casing this toolchain
    in the `configure` script and `ghc-toolchain`.
    
    Fixes on aspect of #23744.
    
    - - - - -
    6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00
    hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure
    
    Stop passing -gcc-options which mixed together linker flags and
    non-linker flags. There's no guarantee the C compiler will accept both
    of these in each mode.
    
    - - - - -
    c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00
    configure: Probe stage0 link flags
    
    For consistency with later stages and CC.
    
    - - - - -
    1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00
    Stricter Binary.get in GHC.Types.Unit (#23964)
    
    I noticed some thunking while looking at Core.
    This change has very modest, but throughout positive ghc/alloc effect:
    
    ```
     hard_hole_fits(normal) ghc/alloc    283,057,664    281,620,872  -0.5%
    
                  geo. mean                                          -0.1%
                  minimum                                            -0.5%
                  maximum                                            +0.0%
    ```
    
    Fixes #23964.
    
    - - - - -
    a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00
    rel_eng/upload.sh cleanups
    
    - - - - -
    80705335 by doyougnu at 2023-10-10T19:03:18-04:00
    ci: add javascript label rule
    
    This adds a rule which triggers the javascript job when the "javascript"
    label is assigned to an MR.
    
    - - - - -
    a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00
    Make 'wWarningFlagsDeps' include every WarningFlag
    
    Fixes #24071.
    
    - - - - -
    d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00
    Fix pretty printing of overlap pragmas in TH splices (fixes #24074)
    
    - - - - -
    0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch64 NCG: Use encoded immediates for literals.
    
    Try to generate
    
        instr x2, <imm>
    
    instead of
    
        mov x1, lit
        instr x2, x1
    
    When possible. This get's rid if quite a few redundant
    mov instructions.
    
    I believe this causes a metric decrease for LargeRecords as
    we reduce register pressure.
    
    -------------------------
    Metric Decrease:
        LargeRecord
    -------------------------
    
    - - - - -
    739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    AArch NCG: Refactor getRegister'
    
    Remove some special cases which can be handled just as well by the
    generic case.
    
    This increases code re-use while also fixing #23749. Since some of the
    special case wasn't upholding Note [Signed arithmetic on AArch64].
    
    - - - - -
    1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
    Aarch ncg: Optimize immediate use for address calculations
    
    When the offset doesn't fit into the immediate we now just reuse the
    general getRegister' code path which is well optimized to compute the
    offset into a register instead of a special case for CmmRegOff.
    
    This means we generate a lot less code under certain conditions which is
    why performance metrics for these improve.
    
    -------------------------
    Metric Decrease:
        T4801
        T5321FD
        T5321Fun
    -------------------------
    
    - - - - -
    b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over mem management checks
    
    These are for heap allocation, a strictly RTS concern.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    The RTS configure one has a new
    ```
    AC_CHECK_SIZEOF([void *])
    ```
    that the top-level configure version didn't have, so that
    `ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
    commits, that can go away.
    
    Progress towards #17191
    
    - - - - -
    41130a65 by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `__thread` check
    
    This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over misc function checks
    
    These are for general use in the RTS.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00
    RTS configure: Move over `eventfd` check
    
    This check is for the RTS part of the event manager and has a
    corresponding part in `base`.
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    58f3babf by John Ericson at 2023-10-11T16:02:48-04:00
    Split `FP_CHECK_PTHREADS` and move part to RTS configure
    
    `NEED_PTHREAD_LIB` is unused since
    3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
    system), and so is no longer defined.
    
    Progress towards #17191
    
    - - - - -
    e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00
    nativeGen: section flags for .text$foo only
    
    Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
    #22834 in !9810.
    
    It does however add "xr" indiscriminatly to .text sections
    even if splitSections is disabled. This leads to the assembler saying:
    
    ghc_1.s:7849:0: error:
         Warning: Ignoring changed section attributes for .text
         |
    7849 | .section .text,"xr"
         | ^
    
    - - - - -
    f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00
    Modularity: pass TempDir instead of DynFlags (#17957)
    
    - - - - -
    34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00
    Test that functions from `mingwex` are available
    
    Ryan wrote these two minimizations, but they never got added to the test
    suite.
    
    See #23309, #23378
    
    Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com>
    Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com>
    
    - - - - -
    bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00
    Do not check for the `mingwex` library in `/configure`
    
    See the recent discussion in !10360 --- Cabal will itself check for the
    library for the packages that need it, and while the autoconf check
    additionally does some other things like define a `HAS_LIBMINGWEX` C
    Preprocessor macro, those other things are also unused and unneeded.
    
    Progress towards #17191, which aims to get rid of `/configure` entirely.
    
    - - - - -
    43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00
    base: Introduce move modules into src
    
    The only non-move changes here are whitespace changes to pass the
    `whitespace` test and a few testsuite adaptations.
    
    - - - - -
    df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00
    [PEi386 linker] Bounds check and null-deref guard
    
    We should resonably be able to expect that we won't exceed the number of
    sections if we assume to be dealing with legal object files. We can however
    not guarantee that we get some negative values, and while we try to
    special case most, we should exclude negative indexing into the sections
    array.
    
    We also need to ensure that we do not try to derefences targetSection,
    if it is NULL, due to the switch statement.
    
    - - - - -
    c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
    Move apple compat check to RTS configure
    
    - - - - -
    c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
    Move clock/timer fun checks to RTS configure
    
    Actual library check (which will set the Cabal flag) is left in the
    top-level configure for now.
    
    Progress towards #17191
    
    - - - - -
    7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
    Move visibility and "musttail" annotation checks to the RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    Progress towards #17191
    
    - - - - -
    ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
    Move leading underscore checks to RTS configure
    
    `CabalLeadingUnderscore` is done via Hadrian already, so we can stop
    `AC_SUBST`ing it completely.
    
    - - - - -
    25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
    Move alloca, fork, const, and big endian checks to RTS configure
    
    All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
    belongs in the RTS configure and should be safe to move without
    modification.
    
    - - - - -
    5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
    Move libdl check to RTS configure
    
    - - - - -
    ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
    Adjust `FP_FIND_LIBFFI`
    
    Just set vars, and `AC_SUBST` in top-level configure.
    
    Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
    be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
    make build system).
    
    - - - - -
    f399812c by John Ericson at 2023-10-12T10:31:13-04:00
    Split BFD support to RTS configure
    
    The flag is still in the top-level configure, but the other checks
    (which define various macros --- important) are in the RTS configure.
    
    - - - - -
    f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
    Split libm check between top level and RTS
    
    - - - - -
    dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
    CgUtils.fixStgRegStmt respect register width
    
    This change ensure that the reg + offset computation is always of the
    same size.  Before this we could end up with a 64bit register, and then
    add a 32bit offset (on 32bit platforms).  This not only would fail type
    sanity checking, but also incorrectly truncate 64bit values into 32bit
    values silently on 32bit architectures.
    
    - - - - -
    9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
    hadrian: Decrease verbosity of cabal commands
    
    In Normal, most tools do not produce output to stdout unless there are
    error conditions.
    
    Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217
    
    - - - - -
    08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
    Do not substitute `@...@` for stage-specific values in cabal files
    
    `rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
    defaults; instead manual choices are passed to configure in the usual
    way.
    
    The old way was fundamentally broken, because it meant we were baking
    these Cabal files for a specific stage. Now we only do stage-agnostic
    @...@ substitution in cabal files (the GHC version), and so all
    stage-specific configuration is properly confined to `_build` and the
    right stage dir.
    
    Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
    (it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
    rid of it.
    
    Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>
    
    - - - - -
    a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00
    Fix restarts in .ghcid
    
    Using the whole of `hadrian/` restarted in a loop for me.
    
    - - - - -
    fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    NoFib results (omitted = 0.0%):
    ```
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             pretty           0.0%     -1.6%
                scc           0.0%     -1.7%
    --------------------------------------------------------------------------------
                Min           0.0%     -1.7%
                Max           0.0%     -0.0%
     Geometric Mean          -0.0%     -0.0%
    ```
    
    - - - - -
    32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00
    hadrian: Move ghcBinDeps into ghcLibDeps
    
    This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the
    `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc`
    library so need to make sure they are present in the libdir even if we
    are not going to build `ghc-bin`.
    
    This also fixes things for cross compilers because the stage2
    cross-compiler requires the ghc-usage.txt file, but we are using
    the stage2 lib folder but not building stage3:exe:ghc-bin so
    ghc-usage.txt was not being generated.
    
    - - - - -
    ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00
    Combine GREs when combining in mkImportOccEnv
    
    In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import
    item in favour of another, as explained in Note [Dealing with imports]
    in `GHC.Rename.Names`. However, this can cause us to lose track of
    important parent information.
    
    Consider for example #24084:
    
      module M1 where { class C a where { type T a } }
      module M2 ( module M1 ) where { import M1 }
      module M3 where { import M2 ( C, T ); instance C () where T () = () }
    
    When processing the import list of `M3`, we start off (for reasons that
    are not relevant right now) with two `Avail`s attached to `T`, namely
    `C(C, T)` and `T(T)`. We combine them in the `combine` function of
    `mkImportOccEnv`; as described in Note [Dealing with imports] we discard
    `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not**
    discard the information want that `C` is the parent of `T`. Indeed,
    losing track of this information can cause errors when importing,
    as we could get an error of the form
    
      ‘T’ is not a (visible) associated type of class ‘C’
    
    We fix this by combining the two GREs for `T` using `plusGRE`.
    
    Fixes #24084
    
    - - - - -
    257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00
    hadrian: Pass -DNOSMP to C compiler when needed
    
    Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
    SMP, but doesn't pass it to CC as well, leading to the following
    compilation error on mips64el:
    
    | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
    Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
    ===> Command failed with error code: 1
    In file included from rts/include/Stg.h:348,
                     from rts/include/Rts.h:38,
                     from rts/hooks/FlagDefaults.c:8:
    rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
      416 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
      440 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
      464 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    
    The old make system correctly passed this flag to both GHC and CC [1].
    
    Fix this error by passing -DNOSMP to CC as well.
    
    [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
    
    Closes #24082
    
    - - - - -
    13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00
    Users Guide: Drop dead code for Haddock refs to `parallel`
    
    I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was
    not substituted. It is dead code -- there is no `parallel-ref` usages
    and it doesn't look like there ever was (going back to
    3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it.
    
    - - - - -
    fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)
    
    bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".
    
    - - - - -
    cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Bignum: fix right shift of negative BigNat with native backend
    
    - - - - -
    cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Rts: expose rtsOutOfBoundsAccess symbol
    
    - - - - -
    72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Hadrian: enable `-fcheck-prim-bounds` in validate flavour
    
    This allows T24066 to fail when the bug is present.
    
    Otherwise the out-of-bound access isn't detected as it happens in
    ghc-bignum which wasn't compiled with the bounds check.
    
    - - - - -
    f9436990 by John Ericson at 2023-10-18T19:41:01-04:00
    Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in`
    
    Fixes #24091
    Progress on #23966
    
    Issue #24091 reports that `@ProjectVersion@` is no longer being
    substituted in the GHC user's guide. I assume this is a recent issue,
    but I am not sure how it's worked since
    c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and
    configure are trying to substitute the same `.in` file!
    
    Now only Hadrian does. That is better anyways; already something that
    issue #23966 requested.
    
    It seems like we were missing some dependencies in Hadrian. (I really,
    really hate that this is possible!) Hopefully it is fixed now.
    
    - - - - -
    b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00
    `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`
    
    Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
    be defined. (Guaranteed including a test in the testsuite.)
    
    - - - - -
    0295375a by John Ericson at 2023-10-18T19:41:37-04:00
    Generate `ghcversion.h` from a `.in` file
    
    Now that there are no conditional sections (see the previous commit), we
    can just a do simple substitution rather than pasting it together line
    by line.
    
    Progress on #23966
    
    - - - - -
    740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00
    Add a regression test for #24064
    
    - - - - -
    921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00
    CLC Proposal #182: Export List from Data.List
    
    Proposal link: https://github.com/haskell/core-libraries-committee/issues/182
    
    - - - - -
    4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
    rts: fix small argument passing on big-endian arch (fix #23387)
    
    - - - - -
    b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
    Interpreter: fix literal alignment on big-endian architectures (fix #19261)
    
    Literals weren't correctly aligned on big-endian, despite what the
    comment said.
    
    - - - - -
    a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
    Testsuite: recomp011 and recomp015 are fixed on powerpc
    
    These tests have been fixed but not tested and re-enabled on big-endian
    powerpc (see comments in #11260 and #11323)
    
    - - - - -
    fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
    CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
    - - - - -
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    19b5daef by Ben Gamari at 2023-10-27T16:00:56-04:00
    testsuite: Add test for #20424
    
    - - - - -
    
    
    21 changed files:
    
    - − .appveyor.sh
    - .editorconfig
    - .ghcid
    - .gitignore
    - .gitlab-ci.yml
    - .gitlab/ci.sh
    - − .gitlab/circle-ci-job.sh
    - .gitlab/darwin/nix/sources.json
    - .gitlab/darwin/toolchain.nix
    - + .gitlab/generate-ci/LICENSE
    - + .gitlab/generate-ci/README.mkd
    - + .gitlab/generate-ci/flake.lock
    - + .gitlab/generate-ci/flake.nix
    - .gitlab/gen_ci.hs → .gitlab/generate-ci/gen_ci.hs
    - + .gitlab/generate-ci/generate-ci.cabal
    - + .gitlab/generate-ci/generate-job-metadata
    - + .gitlab/generate-ci/generate-jobs
    - + .gitlab/generate-ci/hie.yaml
    - − .gitlab/generate_jobs
    - + .gitlab/hello.hs
    - .gitlab/issue_templates/bug.md → .gitlab/issue_templates/default.md
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41d99f09e14b703b8bd864d32889a80c4110c559...19b5daef66507a7512ee95a2553ced0ee99078d3
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/41d99f09e14b703b8bd864d32889a80c4110c559...19b5daef66507a7512ee95a2553ced0ee99078d3
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 20:14:47 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Fri, 27 Oct 2023 16:14:47 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Teach
     tag-inference about SeqOp/seq#
    Message-ID: <653c1a37345b7_1f7b0db4e8f3008363e2@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    01e3e59b by Matthew Craven at 2023-10-27T16:14:22-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    3b7e5c8c by Moritz Angermann at 2023-10-27T16:14:23-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    47c6da44 by Mario Blažević at 2023-10-27T16:14:25-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    
    
    18 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    - rts/linker/PEi386.c
    - + testsuite/tests/simplStg/should_compile/T15226b.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.stderr
    - testsuite/tests/simplStg/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/inferTags003.hs
    - + testsuite/tests/simplStg/should_compile/inferTags003.stderr
    - + testsuite/tests/simplStg/should_compile/inferTags004.hs
    - + testsuite/tests/simplStg/should_compile/inferTags004.stderr
    - + testsuite/tests/th/T24111.hs
    - + testsuite/tests/th/T24111.stdout
    - testsuite/tests/th/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -3640,7 +3640,7 @@ primop SparkOp "spark#" GenPrimOp
        with effect = ReadWriteEffect
        code_size = { primOpCodeSizeForeignCall }
     
    --- See Note [seq# magic] in GHC.Core.Op.ConstantFold
    +-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
     primop SeqOp "seq#" GenPrimOp
        a -> State# s -> (# State# s, a #)
        with
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2108,6 +2108,9 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a
    +  properly-tagged pointer inside of its unboxed-tuple result.
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/Stg/InferTags.hs
    =====================================
    @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) )
     import GHC.Types.Unique.Supply (mkSplitUniqSupply)
     import GHC.Types.RepType (dataConRuntimeRepStrictness)
     import GHC.Core (AltCon(..))
    +import GHC.Builtin.PrimOps ( PrimOp(..) )
     import Data.List (mapAccumL)
     import GHC.Utils.Outputable
     import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull )
    @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args)
              | otherwise
              = --pprTrace "inferAppUnknown" (ppr fun) $
                TagDunno
    --- TODO:
    --- If we have something like:
    ---   let x = thunk in
    ---   f g = case g of g' -> (# x, g' #)
    --- then we *do* know that g' will be properly tagged,
    --- so we should return TagTagged [TagDunno,TagProper] but currently we infer
    --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr.
    --- Seems not to matter much but should be changed eventually.
     
     inferTagExpr env (StgConApp con cn args tys)
       = (inferConTag env con args, StgConApp con cn args tys)
    @@ -340,9 +333,21 @@ inferTagExpr env (StgTick tick body)
         (info, body') = inferTagExpr env body
     
     inferTagExpr _ (StgOpApp op args ty)
    -  = -- Do any primops guarantee to return a properly tagged value?
    -    -- I think not.  Ditto foreign calls.
    -    (TagDunno, StgOpApp op args ty)
    +  | StgPrimOp SeqOp <- op
    +  -- Recall seq# :: a -> State# s -> (# State# s, a #)
    +  -- However the output State# token has been unarised away,
    +  -- so we now effectively have
    +  --    seq# :: a -> State# s -> (# a #)
    +  -- The key point is the result of `seq#` is guaranteed evaluated and properly
    +  -- tagged (because that result comes directly from evaluating the arg),
    +  -- and we want tag inference to reflect that knowledge (#15226).
    +  -- Hence `TagTuple [TagProper]`.
    +  -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
    +  = (TagTuple [TagProper], StgOpApp op args ty)
    +  -- Do any other primops guarantee to return a properly tagged value?
    +  -- Probably not, and that is the conservative assumption anyway.
    +  -- (And foreign calls definitely need not make promises.)
    +  | otherwise = (TagDunno, StgOpApp op args ty)
     
     inferTagExpr env (StgLet ext bind body)
       = (info, StgLet ext bind' body')
    
    
    =====================================
    compiler/GHC/Stg/InferTags/Rewrite.hs
    =====================================
    @@ -217,7 +217,7 @@ withLcl fv act = do
     When compiling bytecode we call myCoreToStg to get STG code first.
     myCoreToStg in turn calls out to stg2stg which runs the STG to STG
     passes followed by free variables analysis and the tag inference pass including
    -it's rewriting phase at the end.
    +its rewriting phase at the end.
     Running tag inference is important as it upholds Note [Strict Field Invariant].
     While code executed by GHCi doesn't take advantage of the SFI it can call into
     compiled code which does. So it must still make sure that the SFI is upheld.
    @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr
     rewriteExpr (e at StgCase {})          = rewriteCase e
     rewriteExpr (e at StgLet {})           = rewriteLet e
     rewriteExpr (e at StgLetNoEscape {})   = rewriteLetNoEscape e
    -rewriteExpr (StgTick t e)     = StgTick t <$!> rewriteExpr e
    +rewriteExpr (StgTick t e)           = StgTick t <$!> rewriteExpr e
     rewriteExpr e@(StgConApp {})        = rewriteConApp e
    -rewriteExpr e@(StgApp {})     = rewriteApp e
    -rewriteExpr (StgLit lit)           = return $! (StgLit lit)
    -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do
    -        (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty)
    +rewriteExpr e@(StgOpApp {})         = rewriteOpApp e
    +rewriteExpr e@(StgApp {})           = rewriteApp e
    +rewriteExpr (StgLit lit)            = return $! (StgLit lit)
     
     
     rewriteCase :: InferStgExpr -> RM TgStgExpr
    @@ -488,6 +486,33 @@ rewriteApp (StgApp f args)
     rewriteApp (StgApp f args) = return $ StgApp f args
     rewriteApp _ = panic "Impossible"
     
    +{-
    +Note [Rewriting primop arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Given an application `op# x y`, is it worth applying `rewriteArg` to
    +`x` and `y`?  All that will do will be to set the `tagSig` for that
    +occurrence of `x` and `y` to record whether it is evaluated and
    +properly tagged. For the vast majority of primops that's a waste of
    +time: the argument is an `Int#` or something.
    +
    +But code generation for `seq#` and `dataToTag#` /does/ consult that
    +tag, to statically avoid generating an eval:
    +* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig`
    +* `dataToTag#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`.
    +
    +So for these we should call `rewriteArgs`.
    +
    +-}
    +
    +rewriteOpApp :: InferStgExpr -> RM TgStgExpr
    +rewriteOpApp (StgOpApp op args res_ty) = case op of
    +  op@(StgPrimOp primOp)
    +    | primOp == SeqOp || primOp == DataToTagOp
    +    -- see Note [Rewriting primop arguments]
    +    -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    +  _ -> pure $! StgOpApp op args res_ty
    +rewriteOpApp _ = panic "Impossible"
    +
     -- `mkSeq` x x' e generates `case x of x' -> e`
     -- We could also substitute x' for x in e but that's so rarely beneficial
     -- that we don't bother.
    
    
    =====================================
    compiler/GHC/Stg/InferTags/TagSig.hs
    =====================================
    @@ -5,7 +5,7 @@
     -- We export this type from this module instead of GHC.Stg.InferTags.Types
     -- because it's used by more than the analysis itself. For example in interface
     -- files where we record a tag signature for bindings.
    --- By putting the sig into it's own module we can avoid module loops.
    +-- By putting the sig into its own module we can avoid module loops.
     module GHC.Stg.InferTags.TagSig
     
     where
    @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> ()
     seqTagInfo TagTagged      = ()
     seqTagInfo TagDunno       = ()
     seqTagInfo TagProper      = ()
    -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    \ No newline at end of file
    +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of
     --
     -- In more complex cases, there is a foreign call (out of line) fallback. This
     -- might happen e.g. if there's enough static information, such as statically
    --- know arguments.
    +-- known arguments.
     emitPrimOp
       :: StgToCmmConfig
       -> PrimOp            -- ^ The primop
    
    
    =====================================
    libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    =====================================
    @@ -14,7 +14,7 @@ import Language.Haskell.TH.Syntax
     import Data.Word ( Word8 )
     import Data.Char ( toLower, chr)
     import GHC.Show  ( showMultiLineString )
    -import GHC.Lexeme( startsVarSym )
    +import GHC.Lexeme( isVarSymChar )
     import Data.Ratio ( numerator, denominator )
     import Data.Foldable ( toList )
     import Prelude hiding ((<>))
    @@ -122,8 +122,8 @@ isSymOcc :: Name -> Bool
     isSymOcc n
       = case nameBase n of
           []    -> True  -- Empty name; weird
    -      (c:_) -> startsVarSym c
    -                   -- c.f. OccName.startsVarSym in GHC itself
    +      (c:_) -> isVarSymChar c
    +                   -- c.f. isVarSymChar in GHC itself
     
     pprInfixExp :: Exp -> Doc
     pprInfixExp (VarE v) = pprName' Infix v
    @@ -471,7 +471,8 @@ ppr_dec _ (PatSynD name args dir pat)
         pprNameArgs | InfixPatSyn a1 a2 <- args = ppr a1 <+> pprName' Infix name <+> ppr a2
                     | otherwise                 = pprName' Applied name <+> ppr args
         pprPatRHS   | ExplBidir cls <- dir = hang (ppr pat <+> text "where")
    -                                           nestDepth (pprName' Applied name <+> ppr cls)
    +                                              nestDepth
    +                                              (vcat $ (pprName' Applied name <+>) . ppr <$> cls)
                     | otherwise            = ppr pat
     ppr_dec _ (PatSynSigD name ty)
       = pprPatSynSig name ty
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -1939,29 +1939,32 @@ static size_t
     makeSymbolExtra_PEi386( ObjectCode* oc, uint64_t index STG_UNUSED, size_t s, char* symbol STG_UNUSED, SymType type )
     {
         SymbolExtra *extra;
    -
    -    if (type == SYM_TYPE_CODE) {
    -        // jmp *-14(%rip)
    -        extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    -        memcpy(extra->jumpIsland, jmp, 6);
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    -        return (size_t)&extra->jumpIsland;
    -    } else if (type == SYM_TYPE_INDIRECT_DATA) {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        void *v = *(void**) s;
    -        extra->addr = (uint64_t)v;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    -    } else {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    +    switch(type & ~SYM_TYPE_DUP_DISCARD) {
    +        case SYM_TYPE_CODE: {
    +            // jmp *-14(%rip)
    +            extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    +            memcpy(extra->jumpIsland, jmp, 6);
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    +            return (size_t)&extra->jumpIsland;
    +        }
    +        case SYM_TYPE_INDIRECT_DATA: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            void *v = *(void**) s;
    +            extra->addr = (uint64_t)v;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
    +        default: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
         }
     }
     
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T15226b where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- tag inference should not insert an eval for x' in making the strict pair
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -0,0 +1,48 @@
    +
    +==================== Final STG: ====================
    +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
    +    {} \r [conrep conrep1]
    +        case conrep of conrep2 [Occ=Once1] {
    +        __DEFAULT ->
    +        case conrep1 of conrep3 [Occ=Once1] {
    +        __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
    +        };
    +        };
    +
    +T15226b.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [x y void]
    +        case seq# [x GHC.Prim.void#] of {
    +        Solo# ipv1 [Occ=Once1] ->
    +        let {
    +          sat [Occ=Once1] :: T15226b.StrictPair a b
    +          [LclId] =
    +              {ipv1, y} \u []
    +                  case y of conrep [Occ=Once1] {
    +                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    +                  };
    +        } in  seq# [sat GHC.Prim.void#];
    +        };
    +
    +T15226b.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#;
    +
    +T15226b.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
    +    {} \r [eta eta]
    +        case eta of eta {
    +        __DEFAULT ->
    +        case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; };
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/all.T
    =====================================
    @@ -18,3 +18,8 @@ test('T22840', [extra_files(
             [ 'T22840A.hs'
             , 'T22840B.hs'
             ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks'])
    +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds'])
    +test('inferTags003', [ only_ways(['optasm']),
    +                       grep_errmsg(r'(call stg\_ap\_0)', [1])
    +                     ], compile, ['-ddump-cmm -dno-typeable-binds -O'])
    +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques'])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE MagicHash #-}
    +module M where
    +
    +import GHC.Exts
    +import GHC.IO
    +
    +data T a = MkT !Bool !a
    +
    +fun :: T a -> IO a
    +{-# OPAQUE fun #-}
    +fun (MkT _ x) = IO $ \s -> noinline seq# x s
    +-- evaluate/seq# should not produce its own eval for x
    +-- since it is properly tagged (from a strict field)
    +
    +-- uses noinline to prevent caseRules from eliding the seq# in Core
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.stderr
    =====================================
    @@ -0,0 +1,177 @@
    +
    +==================== Output Cmm ====================
    +[M.$WMkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cEx,
    +                        label: block_cEx_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cEA,
    +                        label: M.$WMkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cED,
    +                        label: block_cED_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEA: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH;   // CmmCondBranch
    +       cEG: // global
    +           R1 = M.$WMkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cEH: // global
    +           I64[Sp - 16] = cEx;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEx; else goto cEy;   // CmmCondBranch
    +       cEy: // global
    +           call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEx: // global
    +           // slowCall
    +           I64[Sp] = cED;   // CmmStore
    +           _sEi::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _sEi::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cED: // global
    +           // slow_call for _sEh::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cEL; else goto cEK;   // CmmCondBranch
    +       cEL: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEK: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.$WMkT_closure" {
    +     M.$WMkT_closure:
    +         const M.$WMkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.fun_entry() { //  [R2]
    +         { info_tbls: [(cEV,
    +                        label: block_cEV_info
    +                        rep: StackRep []
    +                        srt: Nothing),
    +                       (cEY,
    +                        label: M.fun_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEY: // global
    +           if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0;   // CmmCondBranch
    +       cEZ: // global
    +           R1 = M.fun_closure;   // CmmAssign
    +           call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cF0: // global
    +           I64[Sp - 8] = cEV;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           Sp = Sp - 8;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEV; else goto cEW;   // CmmCondBranch
    +       cEW: // global
    +           call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEV: // global
    +           R1 = P64[R1 + 15];   // CmmAssign
    +           Sp = Sp + 8;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.fun_closure" {
    +     M.fun_closure:
    +         const M.fun_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cFc,
    +                        label: block_cFc_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cFf,
    +                        label: M.MkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cFi,
    +                        label: block_cFi_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFf: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm;   // CmmCondBranch
    +       cFl: // global
    +           R1 = M.MkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cFm: // global
    +           I64[Sp - 16] = cFc;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cFc; else goto cFd;   // CmmCondBranch
    +       cFd: // global
    +           call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFc: // global
    +           // slowCall
    +           I64[Sp] = cFi;   // CmmStore
    +           _tEq::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _tEq::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFi: // global
    +           // slow_call for _B1::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cFq; else goto cFp;   // CmmCondBranch
    +       cFq: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFp: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.MkT_closure" {
    +     M.MkT_closure:
    +         const M.MkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_con_entry() { //  []
    +         { info_tbls: [(cFw,
    +                        label: M.MkT_con_info
    +                        rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFw: // global
    +           R1 = R1 + 1;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + }]
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.hs
    =====================================
    @@ -0,0 +1,11 @@
    +{-# LANGUAGE BangPatterns, UnboxedTuples #-}
    +module InferTags004 where
    +
    +x :: Int
    +x = x
    +
    +f :: a -> (# Int, a #)
    +-- Adapted from a TODO in InferTags.
    +-- f's tag signature should indicate that the second component
    +-- of its result is properly tagged: TagTuple[TagDunno,TagProper]
    +f g = case g of !g' -> (# x, g' #)
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.stderr
    =====================================
    @@ -0,0 +1,13 @@
    +
    +==================== CodeGenAnal STG: ====================
    +Rec {
    +(InferTags004.x, ) = {} \u [] InferTags004.x;
    +end Rec }
    +
    +(InferTags004.f, ) =
    +    {} \r [(g, )]
    +        case g of (g', ) {
    +        __DEFAULT -> (#,#) [InferTags004.x g'];
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/th/T24111.hs
    =====================================
    @@ -0,0 +1,12 @@
    +{-# LANGUAGE Haskell2010, PatternSynonyms, TemplateHaskell, ViewPatterns #-}
    +
    +import Language.Haskell.TH (runQ)
    +import Language.Haskell.TH.Ppr (pprint)
    +
    +main = do
    +  runQ [d|pattern (:+) :: Int -> Int -> (Int, Int);
    +          pattern x :+ y = (x, y)|] >>= putStrLn . pprint
    +  runQ [d|pattern A :: Int -> String;
    +          pattern A n <- (read -> n) where {
    +            A 0 = "hi";
    +            A 1 = "bye"}|] >>= putStrLn . pprint
    
    
    =====================================
    testsuite/tests/th/T24111.stdout
    =====================================
    @@ -0,0 +1,7 @@
    +pattern (:+_0) :: GHC.Types.Int ->
    +                  GHC.Types.Int -> (GHC.Types.Int, GHC.Types.Int)
    +pattern x_1 :+_0 y_2 = (x_1, y_2)
    +pattern A_0 :: GHC.Types.Int -> GHC.Base.String
    +pattern A_0 n_1 <- (Text.Read.read -> n_1) where
    +                       A_0 0 = "hi"
    +                       A_0 1 = "bye"
    
    
    =====================================
    testsuite/tests/th/all.T
    =====================================
    @@ -597,3 +597,4 @@ test('T23962', normal, compile_and_run, [''])
     test('T23968', normal, compile_and_run, [''])
     test('T23971', normal, compile_and_run, [''])
     test('T23986', normal, compile_and_run, [''])
    +test('T24111', normal, compile_and_run, [''])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a199418fcb0413b650b1eeada15c285c5477b91c...47c6da44744b01b7cbee782958e43b9617ff11f0
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a199418fcb0413b650b1eeada15c285c5477b91c...47c6da44744b01b7cbee782958e43b9617ff11f0
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 20:31:40 2023
    From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott))
    Date: Fri, 27 Oct 2023 16:31:40 -0400
    Subject: [Git][ghc/ghc][wip/T22141] 37 commits: Fix restarts in .ghcid
    Message-ID: <653c1e2c101d7_1f7b0db58292a88469e2@gitlab.mail>
    
    
    
    Ryan Scott pushed to branch wip/T22141 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00
    Fix restarts in .ghcid
    
    Using the whole of `hadrian/` restarted in a loop for me.
    
    - - - - -
    fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00
    CorePrep: Refactor FloatingBind (#23442)
    
    A drastically improved architecture for local floating in CorePrep
    that decouples the decision of whether a float is going to be let- or case-bound
    from how far it can float (out of strict contexts, out of lazy contexts, to
    top-level).
    
    There are a couple of new Notes describing the effort:
    
      * `Note [Floating in CorePrep]` for the overview
      * `Note [BindInfo and FloatInfo]` for the new classification of floats
      * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
        floating decisions
    
    This is necessary ground work for proper treatment of Strict fields and
    unlifted values at top-level.
    
    Fixes #23442.
    
    NoFib results (omitted = 0.0%):
    ```
    --------------------------------------------------------------------------------
            Program         Allocs    Instrs
    --------------------------------------------------------------------------------
             pretty           0.0%     -1.6%
                scc           0.0%     -1.7%
    --------------------------------------------------------------------------------
                Min           0.0%     -1.7%
                Max           0.0%     -0.0%
     Geometric Mean          -0.0%     -0.0%
    ```
    
    - - - - -
    32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00
    hadrian: Move ghcBinDeps into ghcLibDeps
    
    This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the
    `ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc`
    library so need to make sure they are present in the libdir even if we
    are not going to build `ghc-bin`.
    
    This also fixes things for cross compilers because the stage2
    cross-compiler requires the ghc-usage.txt file, but we are using
    the stage2 lib folder but not building stage3:exe:ghc-bin so
    ghc-usage.txt was not being generated.
    
    - - - - -
    ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00
    Combine GREs when combining in mkImportOccEnv
    
    In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import
    item in favour of another, as explained in Note [Dealing with imports]
    in `GHC.Rename.Names`. However, this can cause us to lose track of
    important parent information.
    
    Consider for example #24084:
    
      module M1 where { class C a where { type T a } }
      module M2 ( module M1 ) where { import M1 }
      module M3 where { import M2 ( C, T ); instance C () where T () = () }
    
    When processing the import list of `M3`, we start off (for reasons that
    are not relevant right now) with two `Avail`s attached to `T`, namely
    `C(C, T)` and `T(T)`. We combine them in the `combine` function of
    `mkImportOccEnv`; as described in Note [Dealing with imports] we discard
    `C(C, T)` in favour of `T(T)`. However, in doing so, we **must not**
    discard the information want that `C` is the parent of `T`. Indeed,
    losing track of this information can cause errors when importing,
    as we could get an error of the form
    
      ‘T’ is not a (visible) associated type of class ‘C’
    
    We fix this by combining the two GREs for `T` using `plusGRE`.
    
    Fixes #24084
    
    - - - - -
    257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00
    hadrian: Pass -DNOSMP to C compiler when needed
    
    Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
    SMP, but doesn't pass it to CC as well, leading to the following
    compilation error on mips64el:
    
    | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
    Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
    ===> Command failed with error code: 1
    In file included from rts/include/Stg.h:348,
                     from rts/include/Rts.h:38,
                     from rts/hooks/FlagDefaults.c:8:
    rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
      416 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
      440 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
      464 | #error memory barriers unimplemented on this architecture
          |  ^~~~~
    
    The old make system correctly passed this flag to both GHC and CC [1].
    
    Fix this error by passing -DNOSMP to CC as well.
    
    [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
    
    Closes #24082
    
    - - - - -
    13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00
    Users Guide: Drop dead code for Haddock refs to `parallel`
    
    I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was
    not substituted. It is dead code -- there is no `parallel-ref` usages
    and it doesn't look like there ever was (going back to
    3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it.
    
    - - - - -
    fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)
    
    bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".
    
    - - - - -
    cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Bignum: fix right shift of negative BigNat with native backend
    
    - - - - -
    cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Rts: expose rtsOutOfBoundsAccess symbol
    
    - - - - -
    72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00
    Hadrian: enable `-fcheck-prim-bounds` in validate flavour
    
    This allows T24066 to fail when the bug is present.
    
    Otherwise the out-of-bound access isn't detected as it happens in
    ghc-bignum which wasn't compiled with the bounds check.
    
    - - - - -
    f9436990 by John Ericson at 2023-10-18T19:41:01-04:00
    Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in`
    
    Fixes #24091
    Progress on #23966
    
    Issue #24091 reports that `@ProjectVersion@` is no longer being
    substituted in the GHC user's guide. I assume this is a recent issue,
    but I am not sure how it's worked since
    c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and
    configure are trying to substitute the same `.in` file!
    
    Now only Hadrian does. That is better anyways; already something that
    issue #23966 requested.
    
    It seems like we were missing some dependencies in Hadrian. (I really,
    really hate that this is possible!) Hopefully it is fixed now.
    
    - - - - -
    b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00
    `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`
    
    Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
    be defined. (Guaranteed including a test in the testsuite.)
    
    - - - - -
    0295375a by John Ericson at 2023-10-18T19:41:37-04:00
    Generate `ghcversion.h` from a `.in` file
    
    Now that there are no conditional sections (see the previous commit), we
    can just a do simple substitution rather than pasting it together line
    by line.
    
    Progress on #23966
    
    - - - - -
    740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00
    Add a regression test for #24064
    
    - - - - -
    921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00
    CLC Proposal #182: Export List from Data.List
    
    Proposal link: https://github.com/haskell/core-libraries-committee/issues/182
    
    - - - - -
    4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
    rts: fix small argument passing on big-endian arch (fix #23387)
    
    - - - - -
    b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
    Interpreter: fix literal alignment on big-endian architectures (fix #19261)
    
    Literals weren't correctly aligned on big-endian, despite what the
    comment said.
    
    - - - - -
    a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
    Testsuite: recomp011 and recomp015 are fixed on powerpc
    
    These tests have been fixed but not tested and re-enabled on big-endian
    powerpc (see comments in #11260 and #11323)
    
    - - - - -
    fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
    CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
    - - - - -
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    e01576f0 by Ryan Scott at 2023-10-27T20:31:36+00:00
    More robust checking for DataKinds
    
    As observed in #22141, GHC was not doing its due diligence in catching code
    that should require `DataKinds` in order to use. Most notably, it was allowing
    the use of arbitrary data types in kind contexts without `DataKinds`, e.g.,
    
    ```hs
    data Vector :: Nat -> Type -> Type where
    ```
    
    This patch revamps how GHC tracks `DataKinds`. The full specification is
    written out in the `DataKinds` section of the GHC User's Guide, and the
    implementation thereof is described in `Note [Checking for DataKinds]` in
    `GHC.Tc.Validity`. In brief:
    
    * We catch _type_-level `DataKinds` violations in the renamer. See
      `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in
      `GHC.Rename.Pat`.
    
    * We catch _kind_-level `DataKinds` violations in the typechecker, as this
      allows us to catch things that appear beneath type synonyms. (We do *not*
      want to do this in type-level contexts, as it is perfectly fine for a type
      synonym to mention something that requires DataKinds while still using the
      type synonym in a module that doesn't enable DataKinds.) See `checkValidType`
      in `GHC.Tc.Validity`.
    
    * There is now a single `TcRnDataKindsError` that classifies all manner of
      `DataKinds` violations, both in the renamer and the typechecker. The
      `NoDataKindsDC` error has been removed, as it has been subsumed by
      `TcRnDataKindsError`.
    
    * I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit
      uses of data types at the kind level without `DataKinds`. Previously,
      `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is
      inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`.
      Moreover, it thwarted the implementation of the `DataKinds` check in
      `checkValidType`, since we would expand `Constraint` (which was OK without
      `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and
      reject it. Now both are allowed.
    
    * I have added a flurry of additional test cases that test various corners of
      `DataKinds` checking.
    
    Fixes #22141.
    
    - - - - -
    
    
    25 changed files:
    
    - .ghcid
    - .gitignore
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/ByteCode/Asm.hs
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/Core/TyCon.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Data/OrdList.hs
    - compiler/GHC/Driver/Config/Linker.hs
    - compiler/GHC/Driver/Flags.hs
    - compiler/GHC/Driver/Session.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/Linker/Config.hs
    - compiler/GHC/Linker/Dynamic.hs
    - + compiler/GHC/Linker/External.hs
    - compiler/GHC/Linker/Static.hs
    - compiler/GHC/Parser.y
    - compiler/GHC/Parser/Annotation.hs
    - compiler/GHC/Parser/PostProcess.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed5215cd4cd2d3263e6c307c23d7d7dd9c2db6dc...e01576f0897de1007374e6c51c1d441054340c7d
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed5215cd4cd2d3263e6c307c23d7d7dd9c2db6dc...e01576f0897de1007374e6c51c1d441054340c7d
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Fri Oct 27 20:46:21 2023
    From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari))
    Date: Fri, 27 Oct 2023 16:46:21 -0400
    Subject: [Git][ghc/ghc][wip/sym-type] rts/linker: Clearly define SymType
    Message-ID: <653c219d52fc7_1f7b0db5814e488496ec@gitlab.mail>
    
    
    
    Ben Gamari pushed to branch wip/sym-type at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    a168f39b by Ben Gamari at 2023-10-27T16:46:04-04:00
    rts/linker: Clearly define SymType
    
    Previously SymType was both an enumeration of three symbol types *and*
    an orthogonal flag (`DUP_DISCARD`, introduced in !9475). This was quite
    fragile as it meant that to extract the symbol type one had to careful
    mask out the flag. Naturally this wasn't done consistently.
    
    Fix this by renaming the field to `flags` and adding an accessor.
    
    Fixes #24117.
    
    - - - - -
    
    
    5 changed files:
    
    - rts/Linker.c
    - rts/LinkerInternals.h
    - rts/linker/Elf.c
    - rts/linker/MachO.c
    - rts/linker/PEi386.c
    
    
    Changes:
    
    =====================================
    rts/Linker.c
    =====================================
    @@ -226,7 +226,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key,
     static const char *
     symbolTypeString (SymType type)
     {
    -    switch (type & ~SYM_TYPE_DUP_DISCARD) {
    +    switch (type) {
             case SYM_TYPE_CODE: return "code";
             case SYM_TYPE_DATA: return "data";
             case SYM_TYPE_INDIRECT_DATA: return "indirect-data";
    @@ -262,6 +262,7 @@ int ghciInsertSymbolTable(
        SymbolAddr* data,
        SymStrength strength,
        SymType type,
    +   SymDuplicable duplicable,
        ObjectCode *owner)
     {
        RtsSymbolInfo *pinfo = lookupStrHashTable(table, key);
    @@ -272,13 +273,14 @@ int ghciInsertSymbolTable(
           pinfo->owner = owner;
           pinfo->strength = strength;
           pinfo->type = type;
    +      pinfo->duplicable = duplicable;
           insertStrHashTable(table, key, pinfo);
           return 1;
        }
    -   else if (pinfo->type ^ type)
    +   else if (pinfo->type != type)
        {
            /* We were asked to discard the symbol on duplicates, do so quietly.  */
    -       if (!(type & SYM_TYPE_DUP_DISCARD))
    +       if (duplicable != SYM_DISCARD_ON_DUPLICATE)
            {
              debugBelch("Symbol type mismatch.\n");
              debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n",
    @@ -466,7 +468,7 @@ initLinker_ (int retain_cafs)
         for (const RtsSymbolVal *sym = rtsSyms; sym->lbl != NULL; sym++) {
             if (! ghciInsertSymbolTable(WSTR("(GHCi built-in symbols)"),
                                         symhash, sym->lbl, sym->addr,
    -                                    sym->strength, sym->type, NULL)) {
    +                                    sym->strength, sym->type, SYM_ERROR_ON_DUPLICATE, NULL)) {
                 barf("ghciInsertSymbolTable failed");
             }
             IF_DEBUG(linker, debugBelch("initLinker: inserting rts symbol %s, %p\n", sym->lbl, sym->addr));
    @@ -476,7 +478,7 @@ initLinker_ (int retain_cafs)
         if (! ghciInsertSymbolTable(WSTR("(GHCi built-in symbols)"), symhash,
                                     MAYBE_LEADING_UNDERSCORE_STR("newCAF"),
                                     retain_cafs ? newRetainedCAF : newGCdCAF,
    -                                HS_BOOL_FALSE, SYM_TYPE_CODE, NULL)) {
    +                                HS_BOOL_FALSE, SYM_TYPE_CODE, SYM_ERROR_ON_DUPLICATE, NULL)) {
             barf("ghciInsertSymbolTable failed");
         }
     
    @@ -864,7 +866,7 @@ HsBool removeLibrarySearchPath(HsPtr dll_path_index)
     HsInt insertSymbol(pathchar* obj_name, SymbolName* key, SymbolAddr* data)
     {
         return ghciInsertSymbolTable(obj_name, symhash, key, data, HS_BOOL_FALSE,
    -                                 SYM_TYPE_CODE, NULL);
    +                                 SYM_TYPE_CODE, SYM_ERROR_ON_DUPLICATE, NULL);
     }
     
     /* -----------------------------------------------------------------------------
    @@ -1696,7 +1698,7 @@ int ocTryLoad (ObjectCode* oc) {
                 && !ghciInsertSymbolTable(oc->fileName, symhash, symbol.name,
                                           symbol.addr,
                                           isSymbolWeak(oc, symbol.name),
    -                                      symbol.type, oc)) {
    +                                      symbol.type, SYM_ERROR_ON_DUPLICATE, oc)) {
                 return 0;
             }
         }
    
    
    =====================================
    rts/LinkerInternals.h
    =====================================
    @@ -55,17 +55,24 @@ typedef struct _Section    Section;
     
     /* What kind of thing a symbol identifies. We need to know this to determine how
      * to process overflowing relocations. See Note [Processing overflowed relocations].
    - * This is bitfield however only the option SYM_TYPE_DUP_DISCARD can be combined
    - * with the other values. */
    + * Be sure to update the width of RtsSymbolInfo.type if you add variants
    + * to this enumeration.
    + */
     typedef enum _SymType {
         SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */
         SYM_TYPE_DATA = 1 << 1, /* the symbol is data */
         SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */
    -    SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library
    -                                      however if a duplicate is found with a mismatching
    -                                      SymType then discard this one.  */
     } SymType;
     
    +/* How to handle duplicate symbols. */
    +typedef enum {
    +    // Throw an error if a duplicate symbol of different SymType is found
    +    SYM_ERROR_ON_DUPLICATE = 0;
    +    // Discard if a duplicate symbol of different SymType is found. This
    +    // is necessary on PE platforms for symbols defined in BFD import
    +    // libraries.
    +    SYM_DISCARD_ON_DUPLICATE = 1
    +} SymDuplicable;
     
     #if defined(OBJFORMAT_ELF)
     #  include "linker/ElfTypes.h"
    @@ -438,7 +445,8 @@ typedef struct _RtsSymbolInfo {
         SymbolAddr* value;
         ObjectCode *owner;
         SymStrength strength;
    -    SymType type;
    +    SymType type: 16;
    +    SymDuplicable duplicable: 1;
     } RtsSymbolInfo;
     
     #include "BeginPrivate.h"
    @@ -466,6 +474,8 @@ int ghciInsertSymbolTable(
         SymbolAddr* data,
         SymStrength weak,
         SymType type,
    +    // One of SYM_FLAG_*
    +    uint16_t flags,
         ObjectCode *owner);
     
     /* Lock-free version of lookupSymbol. When 'dependent' is not NULL, adds it as a
    
    
    =====================================
    rts/linker/Elf.c
    =====================================
    @@ -1083,7 +1083,7 @@ ocGetNames_ELF ( ObjectCode* oc )
                                setWeakSymbol(oc, nm);
                            }
                            if (!ghciInsertSymbolTable(oc->fileName, symhash,
    -                                                  nm, symbol->addr, isWeak, sym_type, oc)
    +                                                  nm, symbol->addr, isWeak, sym_type, SYM_ERROR_ON_DUPLICATE, oc)
                                ) {
                                goto fail;
                            }
    
    
    =====================================
    rts/linker/MachO.c
    =====================================
    @@ -1390,14 +1390,15 @@ ocGetNames_MachO(ObjectCode* oc)
                         {
                                 IF_DEBUG(linker_verbose, debugBelch("ocGetNames_MachO: inserting %s\n", nm));
                                 SymbolAddr* addr = oc->info->macho_symbols[i].addr;
    -                            // TODO: Make figure out how to determine this from the object file
    -                            SymType sym_type = SYM_TYPE_CODE;
    +                            // TODO: Figure out how to determine this from the object file
    +                            const SymType sym_type = SYM_TYPE_CODE;
                                 ghciInsertSymbolTable( oc->fileName
                                                      , symhash
                                                      , nm
                                                      , addr
                                                      , HS_BOOL_FALSE
                                                      , sym_type
    +                                                 , SYM_ERROR_ON_DUPLICATE
                                                      , oc);
     
                                 oc->symbols[curSymbol].name = nm;
    @@ -1440,7 +1441,7 @@ ocGetNames_MachO(ObjectCode* oc)
     
                     IF_DEBUG(linker_verbose, debugBelch("ocGetNames_MachO: inserting common symbol: %s\n", nm));
                     ghciInsertSymbolTable(oc->fileName, symhash, nm,
    -                                       (void*)commonCounter, HS_BOOL_FALSE, sym_type, oc);
    +                                       (void*)commonCounter, HS_BOOL_FALSE, sym_type, SYM_ERROR_ON_DUPLICATE, oc);
                     oc->symbols[curSymbol].name = nm;
                     oc->symbols[curSymbol].addr = oc->info->macho_symbols[i].addr;
                     curSymbol++;
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -299,7 +299,7 @@
        These two issues mean that for GHC we need to take a different approach
        to handling import libraries.  For normal C libraries we have proper
        differentiation between CODE and DATA.   For GHC produced import libraries
    -   we do not.   As such the SYM_TYPE_DUP_DISCARD tells the linker that if a
    +   we do not.  As such the dup_discard flag tells the linker that if a
        duplicate symbol is found, and we were going to discard it anyway, just do
        so quitely.  This works because the RTS symbols themselves are provided by
        the currently loaded RTS as built-in symbols.
    @@ -438,7 +438,7 @@ void initLinker_PEi386(void)
         if (!ghciInsertSymbolTable(WSTR("(GHCi/Ld special symbols)"),
                                    symhash, "__image_base__",
                                    GetModuleHandleW (NULL), HS_BOOL_TRUE,
    -                               SYM_TYPE_CODE, NULL)) {
    +                               SYM_TYPE_CODE, SYM_ERROR_ON_DUPLICATE, NULL)) {
             barf("ghciInsertSymbolTable failed");
         }
     
    @@ -1814,9 +1814,8 @@ ocGetNames_PEi386 ( ObjectCode* oc )
               sname = strdup (sname);
               addr  = strdup (addr);
               type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA;
    -          type |= SYM_TYPE_DUP_DISCARD;
               if (!ghciInsertSymbolTable(oc->fileName, symhash, sname,
    -                                     addr, false, type, oc)) {
    +                                     addr, false, type, SYM_DISCARD_ON_DUPLICATE, oc)) {
                  releaseOcInfo (oc);
                  stgFree (oc->image);
                  oc->image = NULL;
    @@ -1895,7 +1894,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
               stgFree(tmp);
               sname = strdup (sname);
               if (!ghciInsertSymbolTable(oc->fileName, symhash, sname,
    -                                     addr, false, type, oc))
    +                                     addr, false, type, SYM_ERROR_ON_DUPLICATE, oc))
                    return false;
     
               break;
    @@ -1918,7 +1917,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
              }
     
              if (! ghciInsertSymbolTable(oc->fileName, symhash, sname, addr,
    -                                     isWeak, type, oc))
    +                                     isWeak, type, SYM_ERROR_ON_DUPLICATE, oc))
                  return false;
           } else {
               /* We're skipping the symbol, but if we ever load this
    @@ -2321,7 +2320,9 @@ SymbolAddr *lookupSymbol_PEi386(SymbolName *lbl, ObjectCode *dependent, SymType
             sym = lookupSymbolInDLLs(lbl, dependent);
             return sym; // might be NULL if not found
         } else {
    -        if (type) *type = pinfo->type;
    +        if (type) {
    +            *type = pinfo->type;
    +        }
     
             if (pinfo && pinfo->owner && isSymbolImport (pinfo->owner, lbl))
             {
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a168f39b172d2907011dd7e44d66514745ee100a
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a168f39b172d2907011dd7e44d66514745ee100a
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 00:56:00 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Fri, 27 Oct 2023 20:56:00 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Teach
     tag-inference about SeqOp/seq#
    Message-ID: <653c5c2046d6_1f7b0dbbfd6cfc87306d@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    e33d1905 by Matthew Craven at 2023-10-27T20:55:04-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    5d209bd7 by Moritz Angermann at 2023-10-27T20:55:05-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    ac40814b by Mario Blažević at 2023-10-27T20:55:07-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    
    
    18 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    - rts/linker/PEi386.c
    - + testsuite/tests/simplStg/should_compile/T15226b.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.stderr
    - testsuite/tests/simplStg/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/inferTags003.hs
    - + testsuite/tests/simplStg/should_compile/inferTags003.stderr
    - + testsuite/tests/simplStg/should_compile/inferTags004.hs
    - + testsuite/tests/simplStg/should_compile/inferTags004.stderr
    - + testsuite/tests/th/T24111.hs
    - + testsuite/tests/th/T24111.stdout
    - testsuite/tests/th/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -3640,7 +3640,7 @@ primop SparkOp "spark#" GenPrimOp
        with effect = ReadWriteEffect
        code_size = { primOpCodeSizeForeignCall }
     
    --- See Note [seq# magic] in GHC.Core.Op.ConstantFold
    +-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
     primop SeqOp "seq#" GenPrimOp
        a -> State# s -> (# State# s, a #)
        with
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2108,6 +2108,9 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a
    +  properly-tagged pointer inside of its unboxed-tuple result.
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/Stg/InferTags.hs
    =====================================
    @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) )
     import GHC.Types.Unique.Supply (mkSplitUniqSupply)
     import GHC.Types.RepType (dataConRuntimeRepStrictness)
     import GHC.Core (AltCon(..))
    +import GHC.Builtin.PrimOps ( PrimOp(..) )
     import Data.List (mapAccumL)
     import GHC.Utils.Outputable
     import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull )
    @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args)
              | otherwise
              = --pprTrace "inferAppUnknown" (ppr fun) $
                TagDunno
    --- TODO:
    --- If we have something like:
    ---   let x = thunk in
    ---   f g = case g of g' -> (# x, g' #)
    --- then we *do* know that g' will be properly tagged,
    --- so we should return TagTagged [TagDunno,TagProper] but currently we infer
    --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr.
    --- Seems not to matter much but should be changed eventually.
     
     inferTagExpr env (StgConApp con cn args tys)
       = (inferConTag env con args, StgConApp con cn args tys)
    @@ -340,9 +333,21 @@ inferTagExpr env (StgTick tick body)
         (info, body') = inferTagExpr env body
     
     inferTagExpr _ (StgOpApp op args ty)
    -  = -- Do any primops guarantee to return a properly tagged value?
    -    -- I think not.  Ditto foreign calls.
    -    (TagDunno, StgOpApp op args ty)
    +  | StgPrimOp SeqOp <- op
    +  -- Recall seq# :: a -> State# s -> (# State# s, a #)
    +  -- However the output State# token has been unarised away,
    +  -- so we now effectively have
    +  --    seq# :: a -> State# s -> (# a #)
    +  -- The key point is the result of `seq#` is guaranteed evaluated and properly
    +  -- tagged (because that result comes directly from evaluating the arg),
    +  -- and we want tag inference to reflect that knowledge (#15226).
    +  -- Hence `TagTuple [TagProper]`.
    +  -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
    +  = (TagTuple [TagProper], StgOpApp op args ty)
    +  -- Do any other primops guarantee to return a properly tagged value?
    +  -- Probably not, and that is the conservative assumption anyway.
    +  -- (And foreign calls definitely need not make promises.)
    +  | otherwise = (TagDunno, StgOpApp op args ty)
     
     inferTagExpr env (StgLet ext bind body)
       = (info, StgLet ext bind' body')
    
    
    =====================================
    compiler/GHC/Stg/InferTags/Rewrite.hs
    =====================================
    @@ -217,7 +217,7 @@ withLcl fv act = do
     When compiling bytecode we call myCoreToStg to get STG code first.
     myCoreToStg in turn calls out to stg2stg which runs the STG to STG
     passes followed by free variables analysis and the tag inference pass including
    -it's rewriting phase at the end.
    +its rewriting phase at the end.
     Running tag inference is important as it upholds Note [Strict Field Invariant].
     While code executed by GHCi doesn't take advantage of the SFI it can call into
     compiled code which does. So it must still make sure that the SFI is upheld.
    @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr
     rewriteExpr (e at StgCase {})          = rewriteCase e
     rewriteExpr (e at StgLet {})           = rewriteLet e
     rewriteExpr (e at StgLetNoEscape {})   = rewriteLetNoEscape e
    -rewriteExpr (StgTick t e)     = StgTick t <$!> rewriteExpr e
    +rewriteExpr (StgTick t e)           = StgTick t <$!> rewriteExpr e
     rewriteExpr e@(StgConApp {})        = rewriteConApp e
    -rewriteExpr e@(StgApp {})     = rewriteApp e
    -rewriteExpr (StgLit lit)           = return $! (StgLit lit)
    -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do
    -        (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty)
    +rewriteExpr e@(StgOpApp {})         = rewriteOpApp e
    +rewriteExpr e@(StgApp {})           = rewriteApp e
    +rewriteExpr (StgLit lit)            = return $! (StgLit lit)
     
     
     rewriteCase :: InferStgExpr -> RM TgStgExpr
    @@ -488,6 +486,33 @@ rewriteApp (StgApp f args)
     rewriteApp (StgApp f args) = return $ StgApp f args
     rewriteApp _ = panic "Impossible"
     
    +{-
    +Note [Rewriting primop arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Given an application `op# x y`, is it worth applying `rewriteArg` to
    +`x` and `y`?  All that will do will be to set the `tagSig` for that
    +occurrence of `x` and `y` to record whether it is evaluated and
    +properly tagged. For the vast majority of primops that's a waste of
    +time: the argument is an `Int#` or something.
    +
    +But code generation for `seq#` and `dataToTag#` /does/ consult that
    +tag, to statically avoid generating an eval:
    +* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig`
    +* `dataToTag#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`.
    +
    +So for these we should call `rewriteArgs`.
    +
    +-}
    +
    +rewriteOpApp :: InferStgExpr -> RM TgStgExpr
    +rewriteOpApp (StgOpApp op args res_ty) = case op of
    +  op@(StgPrimOp primOp)
    +    | primOp == SeqOp || primOp == DataToTagOp
    +    -- see Note [Rewriting primop arguments]
    +    -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    +  _ -> pure $! StgOpApp op args res_ty
    +rewriteOpApp _ = panic "Impossible"
    +
     -- `mkSeq` x x' e generates `case x of x' -> e`
     -- We could also substitute x' for x in e but that's so rarely beneficial
     -- that we don't bother.
    
    
    =====================================
    compiler/GHC/Stg/InferTags/TagSig.hs
    =====================================
    @@ -5,7 +5,7 @@
     -- We export this type from this module instead of GHC.Stg.InferTags.Types
     -- because it's used by more than the analysis itself. For example in interface
     -- files where we record a tag signature for bindings.
    --- By putting the sig into it's own module we can avoid module loops.
    +-- By putting the sig into its own module we can avoid module loops.
     module GHC.Stg.InferTags.TagSig
     
     where
    @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> ()
     seqTagInfo TagTagged      = ()
     seqTagInfo TagDunno       = ()
     seqTagInfo TagProper      = ()
    -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    \ No newline at end of file
    +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of
     --
     -- In more complex cases, there is a foreign call (out of line) fallback. This
     -- might happen e.g. if there's enough static information, such as statically
    --- know arguments.
    +-- known arguments.
     emitPrimOp
       :: StgToCmmConfig
       -> PrimOp            -- ^ The primop
    
    
    =====================================
    libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    =====================================
    @@ -14,7 +14,7 @@ import Language.Haskell.TH.Syntax
     import Data.Word ( Word8 )
     import Data.Char ( toLower, chr)
     import GHC.Show  ( showMultiLineString )
    -import GHC.Lexeme( startsVarSym )
    +import GHC.Lexeme( isVarSymChar )
     import Data.Ratio ( numerator, denominator )
     import Data.Foldable ( toList )
     import Prelude hiding ((<>))
    @@ -122,8 +122,8 @@ isSymOcc :: Name -> Bool
     isSymOcc n
       = case nameBase n of
           []    -> True  -- Empty name; weird
    -      (c:_) -> startsVarSym c
    -                   -- c.f. OccName.startsVarSym in GHC itself
    +      (c:_) -> isVarSymChar c
    +                   -- c.f. isVarSymChar in GHC itself
     
     pprInfixExp :: Exp -> Doc
     pprInfixExp (VarE v) = pprName' Infix v
    @@ -471,7 +471,8 @@ ppr_dec _ (PatSynD name args dir pat)
         pprNameArgs | InfixPatSyn a1 a2 <- args = ppr a1 <+> pprName' Infix name <+> ppr a2
                     | otherwise                 = pprName' Applied name <+> ppr args
         pprPatRHS   | ExplBidir cls <- dir = hang (ppr pat <+> text "where")
    -                                           nestDepth (pprName' Applied name <+> ppr cls)
    +                                              nestDepth
    +                                              (vcat $ (pprName' Applied name <+>) . ppr <$> cls)
                     | otherwise            = ppr pat
     ppr_dec _ (PatSynSigD name ty)
       = pprPatSynSig name ty
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -1939,29 +1939,32 @@ static size_t
     makeSymbolExtra_PEi386( ObjectCode* oc, uint64_t index STG_UNUSED, size_t s, char* symbol STG_UNUSED, SymType type )
     {
         SymbolExtra *extra;
    -
    -    if (type == SYM_TYPE_CODE) {
    -        // jmp *-14(%rip)
    -        extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    -        memcpy(extra->jumpIsland, jmp, 6);
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    -        return (size_t)&extra->jumpIsland;
    -    } else if (type == SYM_TYPE_INDIRECT_DATA) {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        void *v = *(void**) s;
    -        extra->addr = (uint64_t)v;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    -    } else {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    +    switch(type & ~SYM_TYPE_DUP_DISCARD) {
    +        case SYM_TYPE_CODE: {
    +            // jmp *-14(%rip)
    +            extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    +            memcpy(extra->jumpIsland, jmp, 6);
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    +            return (size_t)&extra->jumpIsland;
    +        }
    +        case SYM_TYPE_INDIRECT_DATA: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            void *v = *(void**) s;
    +            extra->addr = (uint64_t)v;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
    +        default: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
         }
     }
     
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T15226b where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- tag inference should not insert an eval for x' in making the strict pair
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -0,0 +1,48 @@
    +
    +==================== Final STG: ====================
    +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
    +    {} \r [conrep conrep1]
    +        case conrep of conrep2 [Occ=Once1] {
    +        __DEFAULT ->
    +        case conrep1 of conrep3 [Occ=Once1] {
    +        __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
    +        };
    +        };
    +
    +T15226b.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [x y void]
    +        case seq# [x GHC.Prim.void#] of {
    +        Solo# ipv1 [Occ=Once1] ->
    +        let {
    +          sat [Occ=Once1] :: T15226b.StrictPair a b
    +          [LclId] =
    +              {ipv1, y} \u []
    +                  case y of conrep [Occ=Once1] {
    +                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    +                  };
    +        } in  seq# [sat GHC.Prim.void#];
    +        };
    +
    +T15226b.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#;
    +
    +T15226b.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
    +    {} \r [eta eta]
    +        case eta of eta {
    +        __DEFAULT ->
    +        case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; };
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/all.T
    =====================================
    @@ -18,3 +18,8 @@ test('T22840', [extra_files(
             [ 'T22840A.hs'
             , 'T22840B.hs'
             ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks'])
    +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds'])
    +test('inferTags003', [ only_ways(['optasm']),
    +                       grep_errmsg(r'(call stg\_ap\_0)', [1])
    +                     ], compile, ['-ddump-cmm -dno-typeable-binds -O'])
    +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques'])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE MagicHash #-}
    +module M where
    +
    +import GHC.Exts
    +import GHC.IO
    +
    +data T a = MkT !Bool !a
    +
    +fun :: T a -> IO a
    +{-# OPAQUE fun #-}
    +fun (MkT _ x) = IO $ \s -> noinline seq# x s
    +-- evaluate/seq# should not produce its own eval for x
    +-- since it is properly tagged (from a strict field)
    +
    +-- uses noinline to prevent caseRules from eliding the seq# in Core
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.stderr
    =====================================
    @@ -0,0 +1,177 @@
    +
    +==================== Output Cmm ====================
    +[M.$WMkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cEx,
    +                        label: block_cEx_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cEA,
    +                        label: M.$WMkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cED,
    +                        label: block_cED_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEA: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH;   // CmmCondBranch
    +       cEG: // global
    +           R1 = M.$WMkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cEH: // global
    +           I64[Sp - 16] = cEx;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEx; else goto cEy;   // CmmCondBranch
    +       cEy: // global
    +           call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEx: // global
    +           // slowCall
    +           I64[Sp] = cED;   // CmmStore
    +           _sEi::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _sEi::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cED: // global
    +           // slow_call for _sEh::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cEL; else goto cEK;   // CmmCondBranch
    +       cEL: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEK: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.$WMkT_closure" {
    +     M.$WMkT_closure:
    +         const M.$WMkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.fun_entry() { //  [R2]
    +         { info_tbls: [(cEV,
    +                        label: block_cEV_info
    +                        rep: StackRep []
    +                        srt: Nothing),
    +                       (cEY,
    +                        label: M.fun_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEY: // global
    +           if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0;   // CmmCondBranch
    +       cEZ: // global
    +           R1 = M.fun_closure;   // CmmAssign
    +           call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cF0: // global
    +           I64[Sp - 8] = cEV;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           Sp = Sp - 8;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEV; else goto cEW;   // CmmCondBranch
    +       cEW: // global
    +           call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEV: // global
    +           R1 = P64[R1 + 15];   // CmmAssign
    +           Sp = Sp + 8;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.fun_closure" {
    +     M.fun_closure:
    +         const M.fun_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cFc,
    +                        label: block_cFc_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cFf,
    +                        label: M.MkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cFi,
    +                        label: block_cFi_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFf: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm;   // CmmCondBranch
    +       cFl: // global
    +           R1 = M.MkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cFm: // global
    +           I64[Sp - 16] = cFc;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cFc; else goto cFd;   // CmmCondBranch
    +       cFd: // global
    +           call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFc: // global
    +           // slowCall
    +           I64[Sp] = cFi;   // CmmStore
    +           _tEq::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _tEq::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFi: // global
    +           // slow_call for _B1::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cFq; else goto cFp;   // CmmCondBranch
    +       cFq: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFp: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.MkT_closure" {
    +     M.MkT_closure:
    +         const M.MkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_con_entry() { //  []
    +         { info_tbls: [(cFw,
    +                        label: M.MkT_con_info
    +                        rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFw: // global
    +           R1 = R1 + 1;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + }]
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.hs
    =====================================
    @@ -0,0 +1,11 @@
    +{-# LANGUAGE BangPatterns, UnboxedTuples #-}
    +module InferTags004 where
    +
    +x :: Int
    +x = x
    +
    +f :: a -> (# Int, a #)
    +-- Adapted from a TODO in InferTags.
    +-- f's tag signature should indicate that the second component
    +-- of its result is properly tagged: TagTuple[TagDunno,TagProper]
    +f g = case g of !g' -> (# x, g' #)
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.stderr
    =====================================
    @@ -0,0 +1,13 @@
    +
    +==================== CodeGenAnal STG: ====================
    +Rec {
    +(InferTags004.x, ) = {} \u [] InferTags004.x;
    +end Rec }
    +
    +(InferTags004.f, ) =
    +    {} \r [(g, )]
    +        case g of (g', ) {
    +        __DEFAULT -> (#,#) [InferTags004.x g'];
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/th/T24111.hs
    =====================================
    @@ -0,0 +1,12 @@
    +{-# LANGUAGE Haskell2010, PatternSynonyms, TemplateHaskell, ViewPatterns #-}
    +
    +import Language.Haskell.TH (runQ)
    +import Language.Haskell.TH.Ppr (pprint)
    +
    +main = do
    +  runQ [d|pattern (:+) :: Int -> Int -> (Int, Int);
    +          pattern x :+ y = (x, y)|] >>= putStrLn . pprint
    +  runQ [d|pattern A :: Int -> String;
    +          pattern A n <- (read -> n) where {
    +            A 0 = "hi";
    +            A 1 = "bye"}|] >>= putStrLn . pprint
    
    
    =====================================
    testsuite/tests/th/T24111.stdout
    =====================================
    @@ -0,0 +1,7 @@
    +pattern (:+_0) :: GHC.Types.Int ->
    +                  GHC.Types.Int -> (GHC.Types.Int, GHC.Types.Int)
    +pattern x_1 :+_0 y_2 = (x_1, y_2)
    +pattern A_0 :: GHC.Types.Int -> GHC.Base.String
    +pattern A_0 n_1 <- (Text.Read.read -> n_1) where
    +                       A_0 0 = "hi"
    +                       A_0 1 = "bye"
    
    
    =====================================
    testsuite/tests/th/all.T
    =====================================
    @@ -597,3 +597,4 @@ test('T23962', normal, compile_and_run, [''])
     test('T23968', normal, compile_and_run, [''])
     test('T23971', normal, compile_and_run, [''])
     test('T23986', normal, compile_and_run, [''])
    +test('T24111', normal, compile_and_run, [''])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47c6da44744b01b7cbee782958e43b9617ff11f0...ac40814b803b54d1b274ab8d35e7892956ebe028
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47c6da44744b01b7cbee782958e43b9617ff11f0...ac40814b803b54d1b274ab8d35e7892956ebe028
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 05:26:07 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Sat, 28 Oct 2023 01:26:07 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Teach
     tag-inference about SeqOp/seq#
    Message-ID: <653c9b6f7cc50_1f7b0dc22d6c1c881162@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9eee10df by Matthew Craven at 2023-10-28T01:25:49-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    90c1dbce by Moritz Angermann at 2023-10-28T01:25:50-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    84fd1054 by Mario Blažević at 2023-10-28T01:25:52-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    
    
    18 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    - rts/linker/PEi386.c
    - + testsuite/tests/simplStg/should_compile/T15226b.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.stderr
    - testsuite/tests/simplStg/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/inferTags003.hs
    - + testsuite/tests/simplStg/should_compile/inferTags003.stderr
    - + testsuite/tests/simplStg/should_compile/inferTags004.hs
    - + testsuite/tests/simplStg/should_compile/inferTags004.stderr
    - + testsuite/tests/th/T24111.hs
    - + testsuite/tests/th/T24111.stdout
    - testsuite/tests/th/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -3640,7 +3640,7 @@ primop SparkOp "spark#" GenPrimOp
        with effect = ReadWriteEffect
        code_size = { primOpCodeSizeForeignCall }
     
    --- See Note [seq# magic] in GHC.Core.Op.ConstantFold
    +-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
     primop SeqOp "seq#" GenPrimOp
        a -> State# s -> (# State# s, a #)
        with
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2108,6 +2108,9 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a
    +  properly-tagged pointer inside of its unboxed-tuple result.
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/Stg/InferTags.hs
    =====================================
    @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) )
     import GHC.Types.Unique.Supply (mkSplitUniqSupply)
     import GHC.Types.RepType (dataConRuntimeRepStrictness)
     import GHC.Core (AltCon(..))
    +import GHC.Builtin.PrimOps ( PrimOp(..) )
     import Data.List (mapAccumL)
     import GHC.Utils.Outputable
     import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull )
    @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args)
              | otherwise
              = --pprTrace "inferAppUnknown" (ppr fun) $
                TagDunno
    --- TODO:
    --- If we have something like:
    ---   let x = thunk in
    ---   f g = case g of g' -> (# x, g' #)
    --- then we *do* know that g' will be properly tagged,
    --- so we should return TagTagged [TagDunno,TagProper] but currently we infer
    --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr.
    --- Seems not to matter much but should be changed eventually.
     
     inferTagExpr env (StgConApp con cn args tys)
       = (inferConTag env con args, StgConApp con cn args tys)
    @@ -340,9 +333,21 @@ inferTagExpr env (StgTick tick body)
         (info, body') = inferTagExpr env body
     
     inferTagExpr _ (StgOpApp op args ty)
    -  = -- Do any primops guarantee to return a properly tagged value?
    -    -- I think not.  Ditto foreign calls.
    -    (TagDunno, StgOpApp op args ty)
    +  | StgPrimOp SeqOp <- op
    +  -- Recall seq# :: a -> State# s -> (# State# s, a #)
    +  -- However the output State# token has been unarised away,
    +  -- so we now effectively have
    +  --    seq# :: a -> State# s -> (# a #)
    +  -- The key point is the result of `seq#` is guaranteed evaluated and properly
    +  -- tagged (because that result comes directly from evaluating the arg),
    +  -- and we want tag inference to reflect that knowledge (#15226).
    +  -- Hence `TagTuple [TagProper]`.
    +  -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
    +  = (TagTuple [TagProper], StgOpApp op args ty)
    +  -- Do any other primops guarantee to return a properly tagged value?
    +  -- Probably not, and that is the conservative assumption anyway.
    +  -- (And foreign calls definitely need not make promises.)
    +  | otherwise = (TagDunno, StgOpApp op args ty)
     
     inferTagExpr env (StgLet ext bind body)
       = (info, StgLet ext bind' body')
    
    
    =====================================
    compiler/GHC/Stg/InferTags/Rewrite.hs
    =====================================
    @@ -217,7 +217,7 @@ withLcl fv act = do
     When compiling bytecode we call myCoreToStg to get STG code first.
     myCoreToStg in turn calls out to stg2stg which runs the STG to STG
     passes followed by free variables analysis and the tag inference pass including
    -it's rewriting phase at the end.
    +its rewriting phase at the end.
     Running tag inference is important as it upholds Note [Strict Field Invariant].
     While code executed by GHCi doesn't take advantage of the SFI it can call into
     compiled code which does. So it must still make sure that the SFI is upheld.
    @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr
     rewriteExpr (e at StgCase {})          = rewriteCase e
     rewriteExpr (e at StgLet {})           = rewriteLet e
     rewriteExpr (e at StgLetNoEscape {})   = rewriteLetNoEscape e
    -rewriteExpr (StgTick t e)     = StgTick t <$!> rewriteExpr e
    +rewriteExpr (StgTick t e)           = StgTick t <$!> rewriteExpr e
     rewriteExpr e@(StgConApp {})        = rewriteConApp e
    -rewriteExpr e@(StgApp {})     = rewriteApp e
    -rewriteExpr (StgLit lit)           = return $! (StgLit lit)
    -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do
    -        (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty)
    +rewriteExpr e@(StgOpApp {})         = rewriteOpApp e
    +rewriteExpr e@(StgApp {})           = rewriteApp e
    +rewriteExpr (StgLit lit)            = return $! (StgLit lit)
     
     
     rewriteCase :: InferStgExpr -> RM TgStgExpr
    @@ -488,6 +486,33 @@ rewriteApp (StgApp f args)
     rewriteApp (StgApp f args) = return $ StgApp f args
     rewriteApp _ = panic "Impossible"
     
    +{-
    +Note [Rewriting primop arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Given an application `op# x y`, is it worth applying `rewriteArg` to
    +`x` and `y`?  All that will do will be to set the `tagSig` for that
    +occurrence of `x` and `y` to record whether it is evaluated and
    +properly tagged. For the vast majority of primops that's a waste of
    +time: the argument is an `Int#` or something.
    +
    +But code generation for `seq#` and `dataToTag#` /does/ consult that
    +tag, to statically avoid generating an eval:
    +* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig`
    +* `dataToTag#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`.
    +
    +So for these we should call `rewriteArgs`.
    +
    +-}
    +
    +rewriteOpApp :: InferStgExpr -> RM TgStgExpr
    +rewriteOpApp (StgOpApp op args res_ty) = case op of
    +  op@(StgPrimOp primOp)
    +    | primOp == SeqOp || primOp == DataToTagOp
    +    -- see Note [Rewriting primop arguments]
    +    -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    +  _ -> pure $! StgOpApp op args res_ty
    +rewriteOpApp _ = panic "Impossible"
    +
     -- `mkSeq` x x' e generates `case x of x' -> e`
     -- We could also substitute x' for x in e but that's so rarely beneficial
     -- that we don't bother.
    
    
    =====================================
    compiler/GHC/Stg/InferTags/TagSig.hs
    =====================================
    @@ -5,7 +5,7 @@
     -- We export this type from this module instead of GHC.Stg.InferTags.Types
     -- because it's used by more than the analysis itself. For example in interface
     -- files where we record a tag signature for bindings.
    --- By putting the sig into it's own module we can avoid module loops.
    +-- By putting the sig into its own module we can avoid module loops.
     module GHC.Stg.InferTags.TagSig
     
     where
    @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> ()
     seqTagInfo TagTagged      = ()
     seqTagInfo TagDunno       = ()
     seqTagInfo TagProper      = ()
    -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    \ No newline at end of file
    +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of
     --
     -- In more complex cases, there is a foreign call (out of line) fallback. This
     -- might happen e.g. if there's enough static information, such as statically
    --- know arguments.
    +-- known arguments.
     emitPrimOp
       :: StgToCmmConfig
       -> PrimOp            -- ^ The primop
    
    
    =====================================
    libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    =====================================
    @@ -14,7 +14,7 @@ import Language.Haskell.TH.Syntax
     import Data.Word ( Word8 )
     import Data.Char ( toLower, chr)
     import GHC.Show  ( showMultiLineString )
    -import GHC.Lexeme( startsVarSym )
    +import GHC.Lexeme( isVarSymChar )
     import Data.Ratio ( numerator, denominator )
     import Data.Foldable ( toList )
     import Prelude hiding ((<>))
    @@ -122,8 +122,8 @@ isSymOcc :: Name -> Bool
     isSymOcc n
       = case nameBase n of
           []    -> True  -- Empty name; weird
    -      (c:_) -> startsVarSym c
    -                   -- c.f. OccName.startsVarSym in GHC itself
    +      (c:_) -> isVarSymChar c
    +                   -- c.f. isVarSymChar in GHC itself
     
     pprInfixExp :: Exp -> Doc
     pprInfixExp (VarE v) = pprName' Infix v
    @@ -471,7 +471,8 @@ ppr_dec _ (PatSynD name args dir pat)
         pprNameArgs | InfixPatSyn a1 a2 <- args = ppr a1 <+> pprName' Infix name <+> ppr a2
                     | otherwise                 = pprName' Applied name <+> ppr args
         pprPatRHS   | ExplBidir cls <- dir = hang (ppr pat <+> text "where")
    -                                           nestDepth (pprName' Applied name <+> ppr cls)
    +                                              nestDepth
    +                                              (vcat $ (pprName' Applied name <+>) . ppr <$> cls)
                     | otherwise            = ppr pat
     ppr_dec _ (PatSynSigD name ty)
       = pprPatSynSig name ty
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -1939,29 +1939,32 @@ static size_t
     makeSymbolExtra_PEi386( ObjectCode* oc, uint64_t index STG_UNUSED, size_t s, char* symbol STG_UNUSED, SymType type )
     {
         SymbolExtra *extra;
    -
    -    if (type == SYM_TYPE_CODE) {
    -        // jmp *-14(%rip)
    -        extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    -        memcpy(extra->jumpIsland, jmp, 6);
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    -        return (size_t)&extra->jumpIsland;
    -    } else if (type == SYM_TYPE_INDIRECT_DATA) {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        void *v = *(void**) s;
    -        extra->addr = (uint64_t)v;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    -    } else {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    +    switch(type & ~SYM_TYPE_DUP_DISCARD) {
    +        case SYM_TYPE_CODE: {
    +            // jmp *-14(%rip)
    +            extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    +            memcpy(extra->jumpIsland, jmp, 6);
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    +            return (size_t)&extra->jumpIsland;
    +        }
    +        case SYM_TYPE_INDIRECT_DATA: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            void *v = *(void**) s;
    +            extra->addr = (uint64_t)v;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
    +        default: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
         }
     }
     
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T15226b where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- tag inference should not insert an eval for x' in making the strict pair
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -0,0 +1,48 @@
    +
    +==================== Final STG: ====================
    +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
    +    {} \r [conrep conrep1]
    +        case conrep of conrep2 [Occ=Once1] {
    +        __DEFAULT ->
    +        case conrep1 of conrep3 [Occ=Once1] {
    +        __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
    +        };
    +        };
    +
    +T15226b.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [x y void]
    +        case seq# [x GHC.Prim.void#] of {
    +        Solo# ipv1 [Occ=Once1] ->
    +        let {
    +          sat [Occ=Once1] :: T15226b.StrictPair a b
    +          [LclId] =
    +              {ipv1, y} \u []
    +                  case y of conrep [Occ=Once1] {
    +                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    +                  };
    +        } in  seq# [sat GHC.Prim.void#];
    +        };
    +
    +T15226b.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#;
    +
    +T15226b.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
    +    {} \r [eta eta]
    +        case eta of eta {
    +        __DEFAULT ->
    +        case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; };
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/all.T
    =====================================
    @@ -18,3 +18,8 @@ test('T22840', [extra_files(
             [ 'T22840A.hs'
             , 'T22840B.hs'
             ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks'])
    +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds'])
    +test('inferTags003', [ only_ways(['optasm']),
    +                       grep_errmsg(r'(call stg\_ap\_0)', [1])
    +                     ], compile, ['-ddump-cmm -dno-typeable-binds -O'])
    +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques'])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE MagicHash #-}
    +module M where
    +
    +import GHC.Exts
    +import GHC.IO
    +
    +data T a = MkT !Bool !a
    +
    +fun :: T a -> IO a
    +{-# OPAQUE fun #-}
    +fun (MkT _ x) = IO $ \s -> noinline seq# x s
    +-- evaluate/seq# should not produce its own eval for x
    +-- since it is properly tagged (from a strict field)
    +
    +-- uses noinline to prevent caseRules from eliding the seq# in Core
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.stderr
    =====================================
    @@ -0,0 +1,177 @@
    +
    +==================== Output Cmm ====================
    +[M.$WMkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cEx,
    +                        label: block_cEx_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cEA,
    +                        label: M.$WMkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cED,
    +                        label: block_cED_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEA: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH;   // CmmCondBranch
    +       cEG: // global
    +           R1 = M.$WMkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cEH: // global
    +           I64[Sp - 16] = cEx;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEx; else goto cEy;   // CmmCondBranch
    +       cEy: // global
    +           call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEx: // global
    +           // slowCall
    +           I64[Sp] = cED;   // CmmStore
    +           _sEi::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _sEi::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cED: // global
    +           // slow_call for _sEh::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cEL; else goto cEK;   // CmmCondBranch
    +       cEL: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEK: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.$WMkT_closure" {
    +     M.$WMkT_closure:
    +         const M.$WMkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.fun_entry() { //  [R2]
    +         { info_tbls: [(cEV,
    +                        label: block_cEV_info
    +                        rep: StackRep []
    +                        srt: Nothing),
    +                       (cEY,
    +                        label: M.fun_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEY: // global
    +           if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0;   // CmmCondBranch
    +       cEZ: // global
    +           R1 = M.fun_closure;   // CmmAssign
    +           call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cF0: // global
    +           I64[Sp - 8] = cEV;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           Sp = Sp - 8;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEV; else goto cEW;   // CmmCondBranch
    +       cEW: // global
    +           call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEV: // global
    +           R1 = P64[R1 + 15];   // CmmAssign
    +           Sp = Sp + 8;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.fun_closure" {
    +     M.fun_closure:
    +         const M.fun_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cFc,
    +                        label: block_cFc_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cFf,
    +                        label: M.MkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cFi,
    +                        label: block_cFi_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFf: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm;   // CmmCondBranch
    +       cFl: // global
    +           R1 = M.MkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cFm: // global
    +           I64[Sp - 16] = cFc;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cFc; else goto cFd;   // CmmCondBranch
    +       cFd: // global
    +           call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFc: // global
    +           // slowCall
    +           I64[Sp] = cFi;   // CmmStore
    +           _tEq::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _tEq::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFi: // global
    +           // slow_call for _B1::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cFq; else goto cFp;   // CmmCondBranch
    +       cFq: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFp: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.MkT_closure" {
    +     M.MkT_closure:
    +         const M.MkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_con_entry() { //  []
    +         { info_tbls: [(cFw,
    +                        label: M.MkT_con_info
    +                        rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFw: // global
    +           R1 = R1 + 1;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + }]
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.hs
    =====================================
    @@ -0,0 +1,11 @@
    +{-# LANGUAGE BangPatterns, UnboxedTuples #-}
    +module InferTags004 where
    +
    +x :: Int
    +x = x
    +
    +f :: a -> (# Int, a #)
    +-- Adapted from a TODO in InferTags.
    +-- f's tag signature should indicate that the second component
    +-- of its result is properly tagged: TagTuple[TagDunno,TagProper]
    +f g = case g of !g' -> (# x, g' #)
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.stderr
    =====================================
    @@ -0,0 +1,13 @@
    +
    +==================== CodeGenAnal STG: ====================
    +Rec {
    +(InferTags004.x, ) = {} \u [] InferTags004.x;
    +end Rec }
    +
    +(InferTags004.f, ) =
    +    {} \r [(g, )]
    +        case g of (g', ) {
    +        __DEFAULT -> (#,#) [InferTags004.x g'];
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/th/T24111.hs
    =====================================
    @@ -0,0 +1,12 @@
    +{-# LANGUAGE Haskell2010, PatternSynonyms, TemplateHaskell, ViewPatterns #-}
    +
    +import Language.Haskell.TH (runQ)
    +import Language.Haskell.TH.Ppr (pprint)
    +
    +main = do
    +  runQ [d|pattern (:+) :: Int -> Int -> (Int, Int);
    +          pattern x :+ y = (x, y)|] >>= putStrLn . pprint
    +  runQ [d|pattern A :: Int -> String;
    +          pattern A n <- (read -> n) where {
    +            A 0 = "hi";
    +            A 1 = "bye"}|] >>= putStrLn . pprint
    
    
    =====================================
    testsuite/tests/th/T24111.stdout
    =====================================
    @@ -0,0 +1,7 @@
    +pattern (:+_0) :: GHC.Types.Int ->
    +                  GHC.Types.Int -> (GHC.Types.Int, GHC.Types.Int)
    +pattern x_1 :+_0 y_2 = (x_1, y_2)
    +pattern A_0 :: GHC.Types.Int -> GHC.Base.String
    +pattern A_0 n_1 <- (Text.Read.read -> n_1) where
    +                       A_0 0 = "hi"
    +                       A_0 1 = "bye"
    
    
    =====================================
    testsuite/tests/th/all.T
    =====================================
    @@ -597,3 +597,4 @@ test('T23962', normal, compile_and_run, [''])
     test('T23968', normal, compile_and_run, [''])
     test('T23971', normal, compile_and_run, [''])
     test('T23986', normal, compile_and_run, [''])
    +test('T24111', normal, compile_and_run, [''])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac40814b803b54d1b274ab8d35e7892956ebe028...84fd105440a80bfb224c3566cc4f8060c4d6bacc
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac40814b803b54d1b274ab8d35e7892956ebe028...84fd105440a80bfb224c3566cc4f8060c4d6bacc
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 08:46:26 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Sat, 28 Oct 2023 04:46:26 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Teach
     tag-inference about SeqOp/seq#
    Message-ID: <653cca6245d25_1f7b0dc6a89f009092f3@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    82af4235 by Matthew Craven at 2023-10-28T04:46:09-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    8ff6bf97 by Moritz Angermann at 2023-10-28T04:46:09-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    f6930dc9 by Mario Blažević at 2023-10-28T04:46:11-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    
    
    18 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    - rts/linker/PEi386.c
    - + testsuite/tests/simplStg/should_compile/T15226b.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.stderr
    - testsuite/tests/simplStg/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/inferTags003.hs
    - + testsuite/tests/simplStg/should_compile/inferTags003.stderr
    - + testsuite/tests/simplStg/should_compile/inferTags004.hs
    - + testsuite/tests/simplStg/should_compile/inferTags004.stderr
    - + testsuite/tests/th/T24111.hs
    - + testsuite/tests/th/T24111.stdout
    - testsuite/tests/th/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -3640,7 +3640,7 @@ primop SparkOp "spark#" GenPrimOp
        with effect = ReadWriteEffect
        code_size = { primOpCodeSizeForeignCall }
     
    --- See Note [seq# magic] in GHC.Core.Op.ConstantFold
    +-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
     primop SeqOp "seq#" GenPrimOp
        a -> State# s -> (# State# s, a #)
        with
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2108,6 +2108,9 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a
    +  properly-tagged pointer inside of its unboxed-tuple result.
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/Stg/InferTags.hs
    =====================================
    @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) )
     import GHC.Types.Unique.Supply (mkSplitUniqSupply)
     import GHC.Types.RepType (dataConRuntimeRepStrictness)
     import GHC.Core (AltCon(..))
    +import GHC.Builtin.PrimOps ( PrimOp(..) )
     import Data.List (mapAccumL)
     import GHC.Utils.Outputable
     import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull )
    @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args)
              | otherwise
              = --pprTrace "inferAppUnknown" (ppr fun) $
                TagDunno
    --- TODO:
    --- If we have something like:
    ---   let x = thunk in
    ---   f g = case g of g' -> (# x, g' #)
    --- then we *do* know that g' will be properly tagged,
    --- so we should return TagTagged [TagDunno,TagProper] but currently we infer
    --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr.
    --- Seems not to matter much but should be changed eventually.
     
     inferTagExpr env (StgConApp con cn args tys)
       = (inferConTag env con args, StgConApp con cn args tys)
    @@ -340,9 +333,21 @@ inferTagExpr env (StgTick tick body)
         (info, body') = inferTagExpr env body
     
     inferTagExpr _ (StgOpApp op args ty)
    -  = -- Do any primops guarantee to return a properly tagged value?
    -    -- I think not.  Ditto foreign calls.
    -    (TagDunno, StgOpApp op args ty)
    +  | StgPrimOp SeqOp <- op
    +  -- Recall seq# :: a -> State# s -> (# State# s, a #)
    +  -- However the output State# token has been unarised away,
    +  -- so we now effectively have
    +  --    seq# :: a -> State# s -> (# a #)
    +  -- The key point is the result of `seq#` is guaranteed evaluated and properly
    +  -- tagged (because that result comes directly from evaluating the arg),
    +  -- and we want tag inference to reflect that knowledge (#15226).
    +  -- Hence `TagTuple [TagProper]`.
    +  -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
    +  = (TagTuple [TagProper], StgOpApp op args ty)
    +  -- Do any other primops guarantee to return a properly tagged value?
    +  -- Probably not, and that is the conservative assumption anyway.
    +  -- (And foreign calls definitely need not make promises.)
    +  | otherwise = (TagDunno, StgOpApp op args ty)
     
     inferTagExpr env (StgLet ext bind body)
       = (info, StgLet ext bind' body')
    
    
    =====================================
    compiler/GHC/Stg/InferTags/Rewrite.hs
    =====================================
    @@ -217,7 +217,7 @@ withLcl fv act = do
     When compiling bytecode we call myCoreToStg to get STG code first.
     myCoreToStg in turn calls out to stg2stg which runs the STG to STG
     passes followed by free variables analysis and the tag inference pass including
    -it's rewriting phase at the end.
    +its rewriting phase at the end.
     Running tag inference is important as it upholds Note [Strict Field Invariant].
     While code executed by GHCi doesn't take advantage of the SFI it can call into
     compiled code which does. So it must still make sure that the SFI is upheld.
    @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr
     rewriteExpr (e at StgCase {})          = rewriteCase e
     rewriteExpr (e at StgLet {})           = rewriteLet e
     rewriteExpr (e at StgLetNoEscape {})   = rewriteLetNoEscape e
    -rewriteExpr (StgTick t e)     = StgTick t <$!> rewriteExpr e
    +rewriteExpr (StgTick t e)           = StgTick t <$!> rewriteExpr e
     rewriteExpr e@(StgConApp {})        = rewriteConApp e
    -rewriteExpr e@(StgApp {})     = rewriteApp e
    -rewriteExpr (StgLit lit)           = return $! (StgLit lit)
    -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do
    -        (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty)
    +rewriteExpr e@(StgOpApp {})         = rewriteOpApp e
    +rewriteExpr e@(StgApp {})           = rewriteApp e
    +rewriteExpr (StgLit lit)            = return $! (StgLit lit)
     
     
     rewriteCase :: InferStgExpr -> RM TgStgExpr
    @@ -488,6 +486,33 @@ rewriteApp (StgApp f args)
     rewriteApp (StgApp f args) = return $ StgApp f args
     rewriteApp _ = panic "Impossible"
     
    +{-
    +Note [Rewriting primop arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Given an application `op# x y`, is it worth applying `rewriteArg` to
    +`x` and `y`?  All that will do will be to set the `tagSig` for that
    +occurrence of `x` and `y` to record whether it is evaluated and
    +properly tagged. For the vast majority of primops that's a waste of
    +time: the argument is an `Int#` or something.
    +
    +But code generation for `seq#` and `dataToTag#` /does/ consult that
    +tag, to statically avoid generating an eval:
    +* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig`
    +* `dataToTag#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`.
    +
    +So for these we should call `rewriteArgs`.
    +
    +-}
    +
    +rewriteOpApp :: InferStgExpr -> RM TgStgExpr
    +rewriteOpApp (StgOpApp op args res_ty) = case op of
    +  op@(StgPrimOp primOp)
    +    | primOp == SeqOp || primOp == DataToTagOp
    +    -- see Note [Rewriting primop arguments]
    +    -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    +  _ -> pure $! StgOpApp op args res_ty
    +rewriteOpApp _ = panic "Impossible"
    +
     -- `mkSeq` x x' e generates `case x of x' -> e`
     -- We could also substitute x' for x in e but that's so rarely beneficial
     -- that we don't bother.
    
    
    =====================================
    compiler/GHC/Stg/InferTags/TagSig.hs
    =====================================
    @@ -5,7 +5,7 @@
     -- We export this type from this module instead of GHC.Stg.InferTags.Types
     -- because it's used by more than the analysis itself. For example in interface
     -- files where we record a tag signature for bindings.
    --- By putting the sig into it's own module we can avoid module loops.
    +-- By putting the sig into its own module we can avoid module loops.
     module GHC.Stg.InferTags.TagSig
     
     where
    @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> ()
     seqTagInfo TagTagged      = ()
     seqTagInfo TagDunno       = ()
     seqTagInfo TagProper      = ()
    -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    \ No newline at end of file
    +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of
     --
     -- In more complex cases, there is a foreign call (out of line) fallback. This
     -- might happen e.g. if there's enough static information, such as statically
    --- know arguments.
    +-- known arguments.
     emitPrimOp
       :: StgToCmmConfig
       -> PrimOp            -- ^ The primop
    
    
    =====================================
    libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    =====================================
    @@ -14,7 +14,7 @@ import Language.Haskell.TH.Syntax
     import Data.Word ( Word8 )
     import Data.Char ( toLower, chr)
     import GHC.Show  ( showMultiLineString )
    -import GHC.Lexeme( startsVarSym )
    +import GHC.Lexeme( isVarSymChar )
     import Data.Ratio ( numerator, denominator )
     import Data.Foldable ( toList )
     import Prelude hiding ((<>))
    @@ -122,8 +122,8 @@ isSymOcc :: Name -> Bool
     isSymOcc n
       = case nameBase n of
           []    -> True  -- Empty name; weird
    -      (c:_) -> startsVarSym c
    -                   -- c.f. OccName.startsVarSym in GHC itself
    +      (c:_) -> isVarSymChar c
    +                   -- c.f. isVarSymChar in GHC itself
     
     pprInfixExp :: Exp -> Doc
     pprInfixExp (VarE v) = pprName' Infix v
    @@ -471,7 +471,8 @@ ppr_dec _ (PatSynD name args dir pat)
         pprNameArgs | InfixPatSyn a1 a2 <- args = ppr a1 <+> pprName' Infix name <+> ppr a2
                     | otherwise                 = pprName' Applied name <+> ppr args
         pprPatRHS   | ExplBidir cls <- dir = hang (ppr pat <+> text "where")
    -                                           nestDepth (pprName' Applied name <+> ppr cls)
    +                                              nestDepth
    +                                              (vcat $ (pprName' Applied name <+>) . ppr <$> cls)
                     | otherwise            = ppr pat
     ppr_dec _ (PatSynSigD name ty)
       = pprPatSynSig name ty
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -1939,29 +1939,32 @@ static size_t
     makeSymbolExtra_PEi386( ObjectCode* oc, uint64_t index STG_UNUSED, size_t s, char* symbol STG_UNUSED, SymType type )
     {
         SymbolExtra *extra;
    -
    -    if (type == SYM_TYPE_CODE) {
    -        // jmp *-14(%rip)
    -        extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    -        memcpy(extra->jumpIsland, jmp, 6);
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    -        return (size_t)&extra->jumpIsland;
    -    } else if (type == SYM_TYPE_INDIRECT_DATA) {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        void *v = *(void**) s;
    -        extra->addr = (uint64_t)v;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    -    } else {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    +    switch(type & ~SYM_TYPE_DUP_DISCARD) {
    +        case SYM_TYPE_CODE: {
    +            // jmp *-14(%rip)
    +            extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    +            memcpy(extra->jumpIsland, jmp, 6);
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    +            return (size_t)&extra->jumpIsland;
    +        }
    +        case SYM_TYPE_INDIRECT_DATA: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            void *v = *(void**) s;
    +            extra->addr = (uint64_t)v;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
    +        default: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
         }
     }
     
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T15226b where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- tag inference should not insert an eval for x' in making the strict pair
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -0,0 +1,48 @@
    +
    +==================== Final STG: ====================
    +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
    +    {} \r [conrep conrep1]
    +        case conrep of conrep2 [Occ=Once1] {
    +        __DEFAULT ->
    +        case conrep1 of conrep3 [Occ=Once1] {
    +        __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
    +        };
    +        };
    +
    +T15226b.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [x y void]
    +        case seq# [x GHC.Prim.void#] of {
    +        Solo# ipv1 [Occ=Once1] ->
    +        let {
    +          sat [Occ=Once1] :: T15226b.StrictPair a b
    +          [LclId] =
    +              {ipv1, y} \u []
    +                  case y of conrep [Occ=Once1] {
    +                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    +                  };
    +        } in  seq# [sat GHC.Prim.void#];
    +        };
    +
    +T15226b.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#;
    +
    +T15226b.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
    +    {} \r [eta eta]
    +        case eta of eta {
    +        __DEFAULT ->
    +        case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; };
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/all.T
    =====================================
    @@ -18,3 +18,8 @@ test('T22840', [extra_files(
             [ 'T22840A.hs'
             , 'T22840B.hs'
             ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks'])
    +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds'])
    +test('inferTags003', [ only_ways(['optasm']),
    +                       grep_errmsg(r'(call stg\_ap\_0)', [1])
    +                     ], compile, ['-ddump-cmm -dno-typeable-binds -O'])
    +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques'])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE MagicHash #-}
    +module M where
    +
    +import GHC.Exts
    +import GHC.IO
    +
    +data T a = MkT !Bool !a
    +
    +fun :: T a -> IO a
    +{-# OPAQUE fun #-}
    +fun (MkT _ x) = IO $ \s -> noinline seq# x s
    +-- evaluate/seq# should not produce its own eval for x
    +-- since it is properly tagged (from a strict field)
    +
    +-- uses noinline to prevent caseRules from eliding the seq# in Core
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.stderr
    =====================================
    @@ -0,0 +1,177 @@
    +
    +==================== Output Cmm ====================
    +[M.$WMkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cEx,
    +                        label: block_cEx_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cEA,
    +                        label: M.$WMkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cED,
    +                        label: block_cED_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEA: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH;   // CmmCondBranch
    +       cEG: // global
    +           R1 = M.$WMkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cEH: // global
    +           I64[Sp - 16] = cEx;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEx; else goto cEy;   // CmmCondBranch
    +       cEy: // global
    +           call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEx: // global
    +           // slowCall
    +           I64[Sp] = cED;   // CmmStore
    +           _sEi::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _sEi::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cED: // global
    +           // slow_call for _sEh::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cEL; else goto cEK;   // CmmCondBranch
    +       cEL: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEK: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.$WMkT_closure" {
    +     M.$WMkT_closure:
    +         const M.$WMkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.fun_entry() { //  [R2]
    +         { info_tbls: [(cEV,
    +                        label: block_cEV_info
    +                        rep: StackRep []
    +                        srt: Nothing),
    +                       (cEY,
    +                        label: M.fun_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEY: // global
    +           if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0;   // CmmCondBranch
    +       cEZ: // global
    +           R1 = M.fun_closure;   // CmmAssign
    +           call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cF0: // global
    +           I64[Sp - 8] = cEV;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           Sp = Sp - 8;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEV; else goto cEW;   // CmmCondBranch
    +       cEW: // global
    +           call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEV: // global
    +           R1 = P64[R1 + 15];   // CmmAssign
    +           Sp = Sp + 8;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.fun_closure" {
    +     M.fun_closure:
    +         const M.fun_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cFc,
    +                        label: block_cFc_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cFf,
    +                        label: M.MkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cFi,
    +                        label: block_cFi_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFf: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm;   // CmmCondBranch
    +       cFl: // global
    +           R1 = M.MkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cFm: // global
    +           I64[Sp - 16] = cFc;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cFc; else goto cFd;   // CmmCondBranch
    +       cFd: // global
    +           call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFc: // global
    +           // slowCall
    +           I64[Sp] = cFi;   // CmmStore
    +           _tEq::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _tEq::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFi: // global
    +           // slow_call for _B1::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cFq; else goto cFp;   // CmmCondBranch
    +       cFq: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFp: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.MkT_closure" {
    +     M.MkT_closure:
    +         const M.MkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_con_entry() { //  []
    +         { info_tbls: [(cFw,
    +                        label: M.MkT_con_info
    +                        rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFw: // global
    +           R1 = R1 + 1;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + }]
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.hs
    =====================================
    @@ -0,0 +1,11 @@
    +{-# LANGUAGE BangPatterns, UnboxedTuples #-}
    +module InferTags004 where
    +
    +x :: Int
    +x = x
    +
    +f :: a -> (# Int, a #)
    +-- Adapted from a TODO in InferTags.
    +-- f's tag signature should indicate that the second component
    +-- of its result is properly tagged: TagTuple[TagDunno,TagProper]
    +f g = case g of !g' -> (# x, g' #)
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.stderr
    =====================================
    @@ -0,0 +1,13 @@
    +
    +==================== CodeGenAnal STG: ====================
    +Rec {
    +(InferTags004.x, ) = {} \u [] InferTags004.x;
    +end Rec }
    +
    +(InferTags004.f, ) =
    +    {} \r [(g, )]
    +        case g of (g', ) {
    +        __DEFAULT -> (#,#) [InferTags004.x g'];
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/th/T24111.hs
    =====================================
    @@ -0,0 +1,12 @@
    +{-# LANGUAGE Haskell2010, PatternSynonyms, TemplateHaskell, ViewPatterns #-}
    +
    +import Language.Haskell.TH (runQ)
    +import Language.Haskell.TH.Ppr (pprint)
    +
    +main = do
    +  runQ [d|pattern (:+) :: Int -> Int -> (Int, Int);
    +          pattern x :+ y = (x, y)|] >>= putStrLn . pprint
    +  runQ [d|pattern A :: Int -> String;
    +          pattern A n <- (read -> n) where {
    +            A 0 = "hi";
    +            A 1 = "bye"}|] >>= putStrLn . pprint
    
    
    =====================================
    testsuite/tests/th/T24111.stdout
    =====================================
    @@ -0,0 +1,7 @@
    +pattern (:+_0) :: GHC.Types.Int ->
    +                  GHC.Types.Int -> (GHC.Types.Int, GHC.Types.Int)
    +pattern x_1 :+_0 y_2 = (x_1, y_2)
    +pattern A_0 :: GHC.Types.Int -> GHC.Base.String
    +pattern A_0 n_1 <- (Text.Read.read -> n_1) where
    +                       A_0 0 = "hi"
    +                       A_0 1 = "bye"
    
    
    =====================================
    testsuite/tests/th/all.T
    =====================================
    @@ -597,3 +597,4 @@ test('T23962', normal, compile_and_run, [''])
     test('T23968', normal, compile_and_run, [''])
     test('T23971', normal, compile_and_run, [''])
     test('T23986', normal, compile_and_run, [''])
    +test('T24111', normal, compile_and_run, [''])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/84fd105440a80bfb224c3566cc4f8060c4d6bacc...f6930dc9193ed6916815c9597a693a5379b2563a
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/84fd105440a80bfb224c3566cc4f8060c4d6bacc...f6930dc9193ed6916815c9597a693a5379b2563a
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 09:46:28 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Sat, 28 Oct 2023 05:46:28 -0400
    Subject: [Git][ghc/ghc][wip/T24124] CorePrep: Treat seq# and dataToTag# as
     strict functions (#24124)
    Message-ID: <653cd8741069d_1f7b0dc8b9ef38917933@gitlab.mail>
    
    
    
    Sebastian Graf pushed to branch wip/T24124 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    a919e319 by Sebastian Graf at 2023-10-28T11:46:19+02:00
    CorePrep: Treat seq# and dataToTag# as strict functions (#24124)
    
    See the new `Note [seq# magic]`.
    I also implemented a new `Note [Flatten case-bind]`.
    
    Fixes #24124.
    
    - - - - -
    
    
    5 changed files:
    
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - + testsuite/tests/core-to-stg/T24124.hs
    - + testsuite/tests/core-to-stg/T24124.stderr
    - testsuite/tests/core-to-stg/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2028,6 +2028,9 @@ is:
          case e of 
       by GHC.Core.Opt.ConstantFold.caseRules; see Note [caseRules for dataToTag]
     
    +* Similar to Note [seq# magic], we case-bind the arg of dataToTag# in
    +  GHC.CoreToStg.Prep.
    +
     See #15696 for a long saga.
     -}
     
    @@ -2108,6 +2111,19 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- GHC.CoreToStg.Prep: Finally case-bind the arg of seq#, e.g.,
    +
    +    case seq# (f 13) s of (# r, s' #) -> ...
    +    ==>
    +    case f 13 of sat of __DEFAULT ->
    +    case seq# sat s of (# r, s' #) -> ...,
    +
    +  encoding its call-by-value nature. Note that strictness analysis and the
    +  Simplifier will never see this case binding, so #5129 as above is not an
    +  issue. Plus, CorePrep never case-binds an argument variable anyway.
    +  (Exploiting CbV-ness for argument vars is a job for tag inference, see
    +  #15226.)
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/CoreToStg/Prep.hs
    =====================================
    @@ -70,6 +70,7 @@ import GHC.Types.Unique.Supply
     
     import Data.List        ( unfoldr )
     import Control.Monad
    +import GHC.Builtin.PrimOps
     
     {-
     Note [CorePrep Overview]
    @@ -850,7 +851,12 @@ cpeRhsE env (Case scrut bndr ty alts)
                    where err = mkImpossibleExpr ty "cpeRhsE: missing case alternative"
            ; alts'' <- mapM (sat_alt env') alts'
     
    -       ; return (floats, Case scrut' bndr2 ty alts'') }
    +       ; case alts'' of
    +           [Alt DEFAULT _ rhs] -- See Note [Flatten case-binds]
    +             | float <- mkNonRecFloat env evalDmd True bndr2 scrut'
    +                 -- True: is_unlifted, so that we don't float to top-level
    +             -> return (snocFloat floats float, rhs)
    +           _ -> return (floats, Case scrut' bndr2 ty alts'') }
       where
         sat_alt env (Alt con bs rhs)
            = do { (env2, bs') <- cpCloneBndrs env bs
    @@ -1089,16 +1095,24 @@ cpeApp top_env expr
                ; mb_saturate hd app floats unsat_ticks depth }
             where
               depth = val_args args
    -          stricts = case idDmdSig v of
    -                            DmdSig (DmdType _ demands)
    -                              | listLengthCmp demands depth /= GT -> demands
    -                                    -- length demands <= depth
    -                              | otherwise                         -> []
    -                -- If depth < length demands, then we have too few args to
    -                -- satisfy strictness  info so we have to  ignore all the
    -                -- strictness info, e.g. + (error "urk")
    -                -- Here, we can't evaluate the arg strictly, because this
    -                -- partial application might be seq'd
    +          stricts
    +            | PrimOpId op _ <- idDetails v
    +            , Just demands <- case op of
    +                SeqOp       -> Just [evalDmd,topDmd] -- See Note [seq# magic]
    +                DataToTagOp -> Just [evalDmd]        -- See Note [dataToTag# magic]
    +                _           -> Nothing
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = pprTrace "here" (ppr op $$ ppr args) demands
    +
    +            | DmdSig (DmdType _ demands) <- idDmdSig v
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = demands
    +            | otherwise
    +            = [] -- If depth < length demands, then we have too few args to
    +                 -- satisfy strictness  info so we have to  ignore all the
    +                 -- strictness info, e.g. + (error "urk")
    +                 -- Here, we can't evaluate the arg strictly, because this
    +                 -- partial application might be seq'd
     
             -- We inlined into something that's not a var and has no args.
             -- Bounce it back up to cpeRhsE.
    @@ -1719,12 +1733,13 @@ During ANFisation, we will `mkNonRecFloat` for `e`, binding it to a
     fresh binder `sat`.
     Now there are two interesting cases:
     
    - 1. When `e` is a value, we will float `sat=e` as far as possible, even to
    -    top-level. It is important that we mark `sat` as evaluated (via setting its
    -    unfolding to `evaldUnfolding`), otherwise we get a superfluous thunk to
    -    carry out the field set on T's field, because `exprIsHNF sat == False`:
    + 1. When `e=Just y` is a value, we will float `sat=Just y` as far as possible,
    +    to top-level, even. It is important that we mark `sat` as evaluated (via
    +    setting its unfolding to `evaldUnfolding`), otherwise we get a superfluous
    +    thunk to carry out the field seq on T's field, because
    +    `exprIsHNF sat == False`:
     
    -      let sat = e in
    +      let sat = Just y in
           let sat2 = case sat of x { __DEFAULT } -> T x in
             -- NONONO, want just `sat2 = T x`
           f sat2
    @@ -1763,6 +1778,25 @@ an `evaldUnfolding` if either
      1. `e` is a value, or
      2. `sat=e` is case-bound, but won't float to top-level.
     
    +Note [Flatten case-binds]
    +~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider the following program involving seq#:
    +
    +  data T a = T !a
    +  ... seq# (case x of y { __DEFAULT -> T y }) s ...
    +  ==> {ANFise, exploiting CbV-ness as in Note [seq# magic] and cpe_app}
    +  ... case (case x of y { __DEFAULT -> T y }) of sat { __DEFAULT -> seq# sat s }
    +
    +(Why didn't the Simplifier float out `case x of y`? Because `seq#` is lazy;
    +see Note [seq# magic].)
    +Note the case-of-case. This is not bad per sé, but we can easily flatten
    +this situation by calling `mkNonRecFloat` to create strict binding `y=x`:
    +
    +  ... case x of y { __DEFAULT -> let sat = T y in seq# sat s } ...
    +
    +where `T y` is simply let-bound, thus far less likely to confuse passes
    +downstream.
    +
     Note [Speculative evaluation]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Since call-by-value is much cheaper than call-by-need, we case-bind arguments
    
    
    =====================================
    testsuite/tests/core-to-stg/T24124.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T24124 where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- CorePrep should evaluate `MkStrictPair` and its fields strictly
    
    
    =====================================
    testsuite/tests/core-to-stg/T24124.stderr
    =====================================
    @@ -0,0 +1,193 @@
    +
    +==================== CorePrep ====================
    +Result size of CorePrep
    +  = {terms: 119, types: 108, coercions: 22, joins: 0/1}
    +
    +-- RHS size: {terms: 13, types: 8, coercions: 0, joins: 0/0}
    +T24124.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T24124.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []]
    +T24124.$WMkStrictPair
    +  = \ (@a)
    +      (@b)
    +      (conrep [Occ=Once1] :: a)
    +      (conrep1 [Occ=Once1] :: b) ->
    +      case conrep of conrep2 [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      case conrep1 of conrep3 [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      T24124.MkStrictPair @a @b conrep2 conrep3
    +      }
    +      }
    +
    +-- RHS size: {terms: 20, types: 27, coercions: 0, joins: 0/1}
    +T24124.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T24124.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []]
    +T24124.testFun1
    +  = \ (@a)
    +      (@b)
    +      (x [Occ=Once1] :: a)
    +      (y [Occ=Once1, OS=OneShot] :: b)
    +      (s [Occ=Once1, OS=OneShot]
    +         :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    +      case GHC.Prim.seq# @a @GHC.Prim.RealWorld x s of
    +      { (# ipv [Occ=Once1], ipv1 [Occ=Once1] #) ->
    +      case y of conrep [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      let {
    +        sat [Occ=Once1, Dmd=SL] :: T24124.StrictPair a b
    +        [LclId, Unf=OtherCon []]
    +        sat = T24124.MkStrictPair @a @b ipv1 conrep } in
    +      GHC.Prim.seq# @(T24124.StrictPair a b) @GHC.Prim.RealWorld sat ipv
    +      }
    +      }
    +
    +-- RHS size: {terms: 9, types: 8, coercions: 15, joins: 0/0}
    +T24124.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T24124.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []]
    +T24124.testFun
    +  = (\ (@a)
    +       (@b)
    +       (eta [Occ=Once1] :: a)
    +       (eta [Occ=Once1] :: b)
    +       (eta [Occ=Once1] :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    +       T24124.testFun1 @a @b eta eta eta)
    +    `cast` (forall (a :: <*>_N) (b :: <*>_N).
    +            _R
    +            %<'GHC.Types.Many>_N ->_R _R
    +            %<'GHC.Types.Many>_N ->_R Sym (GHC.Types.N:IO[0]
    +                                               _R)
    +            :: (forall a b.
    +                a
    +                -> b
    +                -> GHC.Prim.State# GHC.Prim.RealWorld
    +                -> (# GHC.Prim.State# GHC.Prim.RealWorld, T24124.StrictPair a b #))
    +               ~R# (forall a b. a -> b -> GHC.Types.IO (T24124.StrictPair a b)))
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule4 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule4 = "main"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule3 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule3 = GHC.Types.TrNameS T24124.$trModule4
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule2 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule2 = "T24124"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule1 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule1 = GHC.Types.TrNameS T24124.$trModule2
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule :: GHC.Types.Module
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule
    +  = GHC.Types.Module T24124.$trModule3 T24124.$trModule1
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +$krep :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep = GHC.Types.KindRepVar 1#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +$krep1 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep1 = GHC.Types.KindRepVar 0#
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair2 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair2 = "StrictPair"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair1 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair1 = GHC.Types.TrNameS T24124.$tcStrictPair2
    +
    +-- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair :: GHC.Types.TyCon
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair
    +  = GHC.Types.TyCon
    +      9300255393514929474#Word64
    +      9110283622559092784#Word64
    +      T24124.$trModule
    +      T24124.$tcStrictPair1
    +      0#
    +      GHC.Types.krep$*->*->*
    +
    +-- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0}
    +$krep2 :: [GHC.Types.KindRep]
    +[GblId, Unf=OtherCon []]
    +$krep2
    +  = GHC.Types.:
    +      @GHC.Types.KindRep $krep (GHC.Types.[] @GHC.Types.KindRep)
    +
    +-- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0}
    +$krep3 :: [GHC.Types.KindRep]
    +[GblId, Unf=OtherCon []]
    +$krep3 = GHC.Types.: @GHC.Types.KindRep $krep1 $krep2
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +$krep4 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep4 = GHC.Types.KindRepTyConApp T24124.$tcStrictPair $krep3
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +$krep5 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep5 = GHC.Types.KindRepFun $krep $krep4
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair1 [InlPrag=[~]] :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair1 = GHC.Types.KindRepFun $krep1 $krep5
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair3 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair3 = "'MkStrictPair"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair2 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair2
    +  = GHC.Types.TrNameS T24124.$tc'MkStrictPair3
    +
    +-- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair :: GHC.Types.TyCon
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair
    +  = GHC.Types.TyCon
    +      2381261223169708323#Word64
    +      3151447712495713176#Word64
    +      T24124.$trModule
    +      T24124.$tc'MkStrictPair2
    +      2#
    +      T24124.$tc'MkStrictPair1
    +
    +-- RHS size: {terms: 7, types: 6, coercions: 7, joins: 0/0}
    +T24124.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []]
    +T24124.MkStrictPair
    +  = (\ (@a[sk:1])
    +       (@b[sk:1])
    +       (eta [Occ=Once1] :: a)
    +       (eta [Occ=Once1] :: b) ->
    +       T24124.MkStrictPair @a[sk:1] @b[sk:1] eta eta)
    +    `cast` ( b %1 -> T24124.StrictPair a b>_R
    +            :: (forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b)
    +               ~R# (forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b))
    +
    +
    +
    
    
    =====================================
    testsuite/tests/core-to-stg/all.T
    =====================================
    @@ -3,3 +3,4 @@
     test('T19700', normal, compile, ['-O'])
     test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -ddump-prep'])
     test('T23914', normal, compile, ['-O'])
    +test('T24124', [grep_errmsg(r'= .*MkStrictPair.*in')], compile, ['-O -dsuppress-uniques -ddump-prep'])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a919e3194d0fc6e87ee20dcba1c586ab7aa84158
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a919e3194d0fc6e87ee20dcba1c586ab7aa84158
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 11:06:50 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Sat, 28 Oct 2023 07:06:50 -0400
    Subject: [Git][ghc/ghc][master] Teach tag-inference about SeqOp/seq#
    Message-ID: <653ceb4a214de_1f7b0dca8b6f6c92418f@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    
    
    13 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.stderr
    - testsuite/tests/simplStg/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/inferTags003.hs
    - + testsuite/tests/simplStg/should_compile/inferTags003.stderr
    - + testsuite/tests/simplStg/should_compile/inferTags004.hs
    - + testsuite/tests/simplStg/should_compile/inferTags004.stderr
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -3640,7 +3640,7 @@ primop SparkOp "spark#" GenPrimOp
        with effect = ReadWriteEffect
        code_size = { primOpCodeSizeForeignCall }
     
    --- See Note [seq# magic] in GHC.Core.Op.ConstantFold
    +-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
     primop SeqOp "seq#" GenPrimOp
        a -> State# s -> (# State# s, a #)
        with
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2108,6 +2108,9 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a
    +  properly-tagged pointer inside of its unboxed-tuple result.
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/Stg/InferTags.hs
    =====================================
    @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) )
     import GHC.Types.Unique.Supply (mkSplitUniqSupply)
     import GHC.Types.RepType (dataConRuntimeRepStrictness)
     import GHC.Core (AltCon(..))
    +import GHC.Builtin.PrimOps ( PrimOp(..) )
     import Data.List (mapAccumL)
     import GHC.Utils.Outputable
     import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull )
    @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args)
              | otherwise
              = --pprTrace "inferAppUnknown" (ppr fun) $
                TagDunno
    --- TODO:
    --- If we have something like:
    ---   let x = thunk in
    ---   f g = case g of g' -> (# x, g' #)
    --- then we *do* know that g' will be properly tagged,
    --- so we should return TagTagged [TagDunno,TagProper] but currently we infer
    --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr.
    --- Seems not to matter much but should be changed eventually.
     
     inferTagExpr env (StgConApp con cn args tys)
       = (inferConTag env con args, StgConApp con cn args tys)
    @@ -340,9 +333,21 @@ inferTagExpr env (StgTick tick body)
         (info, body') = inferTagExpr env body
     
     inferTagExpr _ (StgOpApp op args ty)
    -  = -- Do any primops guarantee to return a properly tagged value?
    -    -- I think not.  Ditto foreign calls.
    -    (TagDunno, StgOpApp op args ty)
    +  | StgPrimOp SeqOp <- op
    +  -- Recall seq# :: a -> State# s -> (# State# s, a #)
    +  -- However the output State# token has been unarised away,
    +  -- so we now effectively have
    +  --    seq# :: a -> State# s -> (# a #)
    +  -- The key point is the result of `seq#` is guaranteed evaluated and properly
    +  -- tagged (because that result comes directly from evaluating the arg),
    +  -- and we want tag inference to reflect that knowledge (#15226).
    +  -- Hence `TagTuple [TagProper]`.
    +  -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
    +  = (TagTuple [TagProper], StgOpApp op args ty)
    +  -- Do any other primops guarantee to return a properly tagged value?
    +  -- Probably not, and that is the conservative assumption anyway.
    +  -- (And foreign calls definitely need not make promises.)
    +  | otherwise = (TagDunno, StgOpApp op args ty)
     
     inferTagExpr env (StgLet ext bind body)
       = (info, StgLet ext bind' body')
    
    
    =====================================
    compiler/GHC/Stg/InferTags/Rewrite.hs
    =====================================
    @@ -217,7 +217,7 @@ withLcl fv act = do
     When compiling bytecode we call myCoreToStg to get STG code first.
     myCoreToStg in turn calls out to stg2stg which runs the STG to STG
     passes followed by free variables analysis and the tag inference pass including
    -it's rewriting phase at the end.
    +its rewriting phase at the end.
     Running tag inference is important as it upholds Note [Strict Field Invariant].
     While code executed by GHCi doesn't take advantage of the SFI it can call into
     compiled code which does. So it must still make sure that the SFI is upheld.
    @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr
     rewriteExpr (e at StgCase {})          = rewriteCase e
     rewriteExpr (e at StgLet {})           = rewriteLet e
     rewriteExpr (e at StgLetNoEscape {})   = rewriteLetNoEscape e
    -rewriteExpr (StgTick t e)     = StgTick t <$!> rewriteExpr e
    +rewriteExpr (StgTick t e)           = StgTick t <$!> rewriteExpr e
     rewriteExpr e@(StgConApp {})        = rewriteConApp e
    -rewriteExpr e@(StgApp {})     = rewriteApp e
    -rewriteExpr (StgLit lit)           = return $! (StgLit lit)
    -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do
    -        (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty)
    +rewriteExpr e@(StgOpApp {})         = rewriteOpApp e
    +rewriteExpr e@(StgApp {})           = rewriteApp e
    +rewriteExpr (StgLit lit)            = return $! (StgLit lit)
     
     
     rewriteCase :: InferStgExpr -> RM TgStgExpr
    @@ -488,6 +486,33 @@ rewriteApp (StgApp f args)
     rewriteApp (StgApp f args) = return $ StgApp f args
     rewriteApp _ = panic "Impossible"
     
    +{-
    +Note [Rewriting primop arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Given an application `op# x y`, is it worth applying `rewriteArg` to
    +`x` and `y`?  All that will do will be to set the `tagSig` for that
    +occurrence of `x` and `y` to record whether it is evaluated and
    +properly tagged. For the vast majority of primops that's a waste of
    +time: the argument is an `Int#` or something.
    +
    +But code generation for `seq#` and `dataToTag#` /does/ consult that
    +tag, to statically avoid generating an eval:
    +* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig`
    +* `dataToTag#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`.
    +
    +So for these we should call `rewriteArgs`.
    +
    +-}
    +
    +rewriteOpApp :: InferStgExpr -> RM TgStgExpr
    +rewriteOpApp (StgOpApp op args res_ty) = case op of
    +  op@(StgPrimOp primOp)
    +    | primOp == SeqOp || primOp == DataToTagOp
    +    -- see Note [Rewriting primop arguments]
    +    -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    +  _ -> pure $! StgOpApp op args res_ty
    +rewriteOpApp _ = panic "Impossible"
    +
     -- `mkSeq` x x' e generates `case x of x' -> e`
     -- We could also substitute x' for x in e but that's so rarely beneficial
     -- that we don't bother.
    
    
    =====================================
    compiler/GHC/Stg/InferTags/TagSig.hs
    =====================================
    @@ -5,7 +5,7 @@
     -- We export this type from this module instead of GHC.Stg.InferTags.Types
     -- because it's used by more than the analysis itself. For example in interface
     -- files where we record a tag signature for bindings.
    --- By putting the sig into it's own module we can avoid module loops.
    +-- By putting the sig into its own module we can avoid module loops.
     module GHC.Stg.InferTags.TagSig
     
     where
    @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> ()
     seqTagInfo TagTagged      = ()
     seqTagInfo TagDunno       = ()
     seqTagInfo TagProper      = ()
    -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    \ No newline at end of file
    +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of
     --
     -- In more complex cases, there is a foreign call (out of line) fallback. This
     -- might happen e.g. if there's enough static information, such as statically
    --- know arguments.
    +-- known arguments.
     emitPrimOp
       :: StgToCmmConfig
       -> PrimOp            -- ^ The primop
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T15226b where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- tag inference should not insert an eval for x' in making the strict pair
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -0,0 +1,48 @@
    +
    +==================== Final STG: ====================
    +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
    +    {} \r [conrep conrep1]
    +        case conrep of conrep2 [Occ=Once1] {
    +        __DEFAULT ->
    +        case conrep1 of conrep3 [Occ=Once1] {
    +        __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
    +        };
    +        };
    +
    +T15226b.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [x y void]
    +        case seq# [x GHC.Prim.void#] of {
    +        Solo# ipv1 [Occ=Once1] ->
    +        let {
    +          sat [Occ=Once1] :: T15226b.StrictPair a b
    +          [LclId] =
    +              {ipv1, y} \u []
    +                  case y of conrep [Occ=Once1] {
    +                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    +                  };
    +        } in  seq# [sat GHC.Prim.void#];
    +        };
    +
    +T15226b.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#;
    +
    +T15226b.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
    +    {} \r [eta eta]
    +        case eta of eta {
    +        __DEFAULT ->
    +        case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; };
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/all.T
    =====================================
    @@ -18,3 +18,8 @@ test('T22840', [extra_files(
             [ 'T22840A.hs'
             , 'T22840B.hs'
             ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks'])
    +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds'])
    +test('inferTags003', [ only_ways(['optasm']),
    +                       grep_errmsg(r'(call stg\_ap\_0)', [1])
    +                     ], compile, ['-ddump-cmm -dno-typeable-binds -O'])
    +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques'])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE MagicHash #-}
    +module M where
    +
    +import GHC.Exts
    +import GHC.IO
    +
    +data T a = MkT !Bool !a
    +
    +fun :: T a -> IO a
    +{-# OPAQUE fun #-}
    +fun (MkT _ x) = IO $ \s -> noinline seq# x s
    +-- evaluate/seq# should not produce its own eval for x
    +-- since it is properly tagged (from a strict field)
    +
    +-- uses noinline to prevent caseRules from eliding the seq# in Core
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.stderr
    =====================================
    @@ -0,0 +1,177 @@
    +
    +==================== Output Cmm ====================
    +[M.$WMkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cEx,
    +                        label: block_cEx_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cEA,
    +                        label: M.$WMkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cED,
    +                        label: block_cED_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEA: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH;   // CmmCondBranch
    +       cEG: // global
    +           R1 = M.$WMkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cEH: // global
    +           I64[Sp - 16] = cEx;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEx; else goto cEy;   // CmmCondBranch
    +       cEy: // global
    +           call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEx: // global
    +           // slowCall
    +           I64[Sp] = cED;   // CmmStore
    +           _sEi::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _sEi::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cED: // global
    +           // slow_call for _sEh::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cEL; else goto cEK;   // CmmCondBranch
    +       cEL: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEK: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.$WMkT_closure" {
    +     M.$WMkT_closure:
    +         const M.$WMkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.fun_entry() { //  [R2]
    +         { info_tbls: [(cEV,
    +                        label: block_cEV_info
    +                        rep: StackRep []
    +                        srt: Nothing),
    +                       (cEY,
    +                        label: M.fun_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEY: // global
    +           if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0;   // CmmCondBranch
    +       cEZ: // global
    +           R1 = M.fun_closure;   // CmmAssign
    +           call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cF0: // global
    +           I64[Sp - 8] = cEV;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           Sp = Sp - 8;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEV; else goto cEW;   // CmmCondBranch
    +       cEW: // global
    +           call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEV: // global
    +           R1 = P64[R1 + 15];   // CmmAssign
    +           Sp = Sp + 8;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.fun_closure" {
    +     M.fun_closure:
    +         const M.fun_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cFc,
    +                        label: block_cFc_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cFf,
    +                        label: M.MkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cFi,
    +                        label: block_cFi_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFf: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm;   // CmmCondBranch
    +       cFl: // global
    +           R1 = M.MkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cFm: // global
    +           I64[Sp - 16] = cFc;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cFc; else goto cFd;   // CmmCondBranch
    +       cFd: // global
    +           call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFc: // global
    +           // slowCall
    +           I64[Sp] = cFi;   // CmmStore
    +           _tEq::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _tEq::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFi: // global
    +           // slow_call for _B1::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cFq; else goto cFp;   // CmmCondBranch
    +       cFq: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFp: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.MkT_closure" {
    +     M.MkT_closure:
    +         const M.MkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_con_entry() { //  []
    +         { info_tbls: [(cFw,
    +                        label: M.MkT_con_info
    +                        rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFw: // global
    +           R1 = R1 + 1;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + }]
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.hs
    =====================================
    @@ -0,0 +1,11 @@
    +{-# LANGUAGE BangPatterns, UnboxedTuples #-}
    +module InferTags004 where
    +
    +x :: Int
    +x = x
    +
    +f :: a -> (# Int, a #)
    +-- Adapted from a TODO in InferTags.
    +-- f's tag signature should indicate that the second component
    +-- of its result is properly tagged: TagTuple[TagDunno,TagProper]
    +f g = case g of !g' -> (# x, g' #)
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.stderr
    =====================================
    @@ -0,0 +1,13 @@
    +
    +==================== CodeGenAnal STG: ====================
    +Rec {
    +(InferTags004.x, ) = {} \u [] InferTags004.x;
    +end Rec }
    +
    +(InferTags004.f, ) =
    +    {} \r [(g, )]
    +        case g of (g', ) {
    +        __DEFAULT -> (#,#) [InferTags004.x g'];
    +        };
    +
    +
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9bc5cb92ef166010e36f2ef2c187fb2df2310bdb
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9bc5cb92ef166010e36f2ef2c187fb2df2310bdb
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 11:07:25 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Sat, 28 Oct 2023 07:07:25 -0400
    Subject: [Git][ghc/ghc][master] [PEi386] Mask SYM_TYPE_DUP_DISCARD in
     makeSymbolExtra
    Message-ID: <653ceb6dae9e5_1f7b0dca582f309276f5@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    
    
    1 changed file:
    
    - rts/linker/PEi386.c
    
    
    Changes:
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -1939,29 +1939,32 @@ static size_t
     makeSymbolExtra_PEi386( ObjectCode* oc, uint64_t index STG_UNUSED, size_t s, char* symbol STG_UNUSED, SymType type )
     {
         SymbolExtra *extra;
    -
    -    if (type == SYM_TYPE_CODE) {
    -        // jmp *-14(%rip)
    -        extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    -        memcpy(extra->jumpIsland, jmp, 6);
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    -        return (size_t)&extra->jumpIsland;
    -    } else if (type == SYM_TYPE_INDIRECT_DATA) {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        void *v = *(void**) s;
    -        extra->addr = (uint64_t)v;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    -    } else {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    +    switch(type & ~SYM_TYPE_DUP_DISCARD) {
    +        case SYM_TYPE_CODE: {
    +            // jmp *-14(%rip)
    +            extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    +            memcpy(extra->jumpIsland, jmp, 6);
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    +            return (size_t)&extra->jumpIsland;
    +        }
    +        case SYM_TYPE_INDIRECT_DATA: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            void *v = *(void**) s;
    +            extra->addr = (uint64_t)v;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
    +        default: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
         }
     }
     
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34f06334025521c2440ebedb0237697fbcc3c6de
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34f06334025521c2440ebedb0237697fbcc3c6de
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 11:08:07 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Sat, 28 Oct 2023 07:08:07 -0400
    Subject: [Git][ghc/ghc][master] Fix and test for issue #24111, TH.Ppr output
     of pattern synonyms
    Message-ID: <653ceb97c5956_1f7b0dca8bd858931198@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    
    
    4 changed files:
    
    - libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    - + testsuite/tests/th/T24111.hs
    - + testsuite/tests/th/T24111.stdout
    - testsuite/tests/th/all.T
    
    
    Changes:
    
    =====================================
    libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    =====================================
    @@ -14,7 +14,7 @@ import Language.Haskell.TH.Syntax
     import Data.Word ( Word8 )
     import Data.Char ( toLower, chr)
     import GHC.Show  ( showMultiLineString )
    -import GHC.Lexeme( startsVarSym )
    +import GHC.Lexeme( isVarSymChar )
     import Data.Ratio ( numerator, denominator )
     import Data.Foldable ( toList )
     import Prelude hiding ((<>))
    @@ -122,8 +122,8 @@ isSymOcc :: Name -> Bool
     isSymOcc n
       = case nameBase n of
           []    -> True  -- Empty name; weird
    -      (c:_) -> startsVarSym c
    -                   -- c.f. OccName.startsVarSym in GHC itself
    +      (c:_) -> isVarSymChar c
    +                   -- c.f. isVarSymChar in GHC itself
     
     pprInfixExp :: Exp -> Doc
     pprInfixExp (VarE v) = pprName' Infix v
    @@ -471,7 +471,8 @@ ppr_dec _ (PatSynD name args dir pat)
         pprNameArgs | InfixPatSyn a1 a2 <- args = ppr a1 <+> pprName' Infix name <+> ppr a2
                     | otherwise                 = pprName' Applied name <+> ppr args
         pprPatRHS   | ExplBidir cls <- dir = hang (ppr pat <+> text "where")
    -                                           nestDepth (pprName' Applied name <+> ppr cls)
    +                                              nestDepth
    +                                              (vcat $ (pprName' Applied name <+>) . ppr <$> cls)
                     | otherwise            = ppr pat
     ppr_dec _ (PatSynSigD name ty)
       = pprPatSynSig name ty
    
    
    =====================================
    testsuite/tests/th/T24111.hs
    =====================================
    @@ -0,0 +1,12 @@
    +{-# LANGUAGE Haskell2010, PatternSynonyms, TemplateHaskell, ViewPatterns #-}
    +
    +import Language.Haskell.TH (runQ)
    +import Language.Haskell.TH.Ppr (pprint)
    +
    +main = do
    +  runQ [d|pattern (:+) :: Int -> Int -> (Int, Int);
    +          pattern x :+ y = (x, y)|] >>= putStrLn . pprint
    +  runQ [d|pattern A :: Int -> String;
    +          pattern A n <- (read -> n) where {
    +            A 0 = "hi";
    +            A 1 = "bye"}|] >>= putStrLn . pprint
    
    
    =====================================
    testsuite/tests/th/T24111.stdout
    =====================================
    @@ -0,0 +1,7 @@
    +pattern (:+_0) :: GHC.Types.Int ->
    +                  GHC.Types.Int -> (GHC.Types.Int, GHC.Types.Int)
    +pattern x_1 :+_0 y_2 = (x_1, y_2)
    +pattern A_0 :: GHC.Types.Int -> GHC.Base.String
    +pattern A_0 n_1 <- (Text.Read.read -> n_1) where
    +                       A_0 0 = "hi"
    +                       A_0 1 = "bye"
    
    
    =====================================
    testsuite/tests/th/all.T
    =====================================
    @@ -597,3 +597,4 @@ test('T23962', normal, compile_and_run, [''])
     test('T23968', normal, compile_and_run, [''])
     test('T23971', normal, compile_and_run, [''])
     test('T23986', normal, compile_and_run, [''])
    +test('T24111', normal, compile_and_run, [''])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5b51b2a24cbe69070a2f34efd93de55d807b836b
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5b51b2a24cbe69070a2f34efd93de55d807b836b
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 12:39:48 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Sat, 28 Oct 2023 08:39:48 -0400
    Subject: [Git][ghc/ghc][wip/T24124] 2 commits: CorePrep: Attach evaldUnfolding
     to floats to detect more values
    Message-ID: <653d0114b1e15_1f7b0dcd119a189346e@gitlab.mail>
    
    
    
    Sebastian Graf pushed to branch wip/T24124 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    f54967fa by Sebastian Graf at 2023-10-28T14:39:38+02:00
    CorePrep: Attach evaldUnfolding to floats to detect more values
    
    See `Note [Pin evaluatedness on floats]`.
    
    - - - - -
    5c80ed4a by Sebastian Graf at 2023-10-28T14:39:38+02:00
    CorePrep: Treat seq# and dataToTag# as strict functions (#24124)
    
    See the new `Note [seq# magic]`.
    I also implemented a new `Note [Flatten case-bind]`.
    
    Fixes #24124.
    
    - - - - -
    
    
    8 changed files:
    
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - + testsuite/tests/core-to-stg/T24124.hs
    - + testsuite/tests/core-to-stg/T24124.stderr
    - testsuite/tests/core-to-stg/all.T
    - testsuite/tests/ghci/should_run/T21052.stdout
    - testsuite/tests/simplCore/should_compile/T23083.stderr
    - testsuite/tests/simplStg/should_compile/T19717.stderr
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2028,6 +2028,9 @@ is:
          case e of 
       by GHC.Core.Opt.ConstantFold.caseRules; see Note [caseRules for dataToTag]
     
    +* Similar to Note [seq# magic], we case-bind the arg of dataToTag# in
    +  GHC.CoreToStg.Prep.
    +
     See #15696 for a long saga.
     -}
     
    @@ -2108,6 +2111,19 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- GHC.CoreToStg.Prep: Finally case-bind the arg of seq#, e.g.,
    +
    +    case seq# (f 13) s of (# r, s' #) -> ...
    +    ==>
    +    case f 13 of sat of __DEFAULT ->
    +    case seq# sat s of (# r, s' #) -> ...,
    +
    +  encoding its call-by-value nature. Note that strictness analysis and the
    +  Simplifier will never see this case binding, so #5129 as above is not an
    +  issue. Plus, CorePrep never case-binds an argument variable anyway.
    +  (Exploiting CbV-ness for argument vars is a job for tag inference, see
    +  #15226.)
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/CoreToStg/Prep.hs
    =====================================
    @@ -70,6 +70,7 @@ import GHC.Types.Unique.Supply
     
     import Data.List        ( unfoldr )
     import Control.Monad
    +import GHC.Builtin.PrimOps
     
     {-
     Note [CorePrep Overview]
    @@ -679,9 +680,11 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
                    else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $
                                    -- Note [Silly extra arguments]
                         (do { v <- newVar (idType bndr)
    -                        ; let float = mkNonRecFloat env topDmd False v rhs2
    +                        ; let float@(Float (NonRec v' _) _ _) =
    +                                mkNonRecFloat env topDmd False v rhs2
    +                        -- v' has demand info and possibly evaldUnfolding
                             ; return ( snocFloat floats2 float
    -                                 , cpeEtaExpand arity (Var v)) })
    +                                 , cpeEtaExpand arity (Var v')) })
     
             -- Wrap floating ticks
            ; let (floats4, rhs4) = wrapTicks floats3 rhs3
    @@ -848,7 +851,12 @@ cpeRhsE env (Case scrut bndr ty alts)
                    where err = mkImpossibleExpr ty "cpeRhsE: missing case alternative"
            ; alts'' <- mapM (sat_alt env') alts'
     
    -       ; return (floats, Case scrut' bndr2 ty alts'') }
    +       ; case alts'' of
    +           [Alt DEFAULT _ rhs] -- See Note [Flatten case-binds]
    +             | float <- mkNonRecFloat env evalDmd True bndr2 scrut'
    +                 -- True: is_unlifted, so that we don't float to top-level
    +             -> return (snocFloat floats float, rhs)
    +           _ -> return (floats, Case scrut' bndr2 ty alts'') }
       where
         sat_alt env (Alt con bs rhs)
            = do { (env2, bs') <- cpCloneBndrs env bs
    @@ -1087,16 +1095,24 @@ cpeApp top_env expr
                ; mb_saturate hd app floats unsat_ticks depth }
             where
               depth = val_args args
    -          stricts = case idDmdSig v of
    -                            DmdSig (DmdType _ demands)
    -                              | listLengthCmp demands depth /= GT -> demands
    -                                    -- length demands <= depth
    -                              | otherwise                         -> []
    -                -- If depth < length demands, then we have too few args to
    -                -- satisfy strictness  info so we have to  ignore all the
    -                -- strictness info, e.g. + (error "urk")
    -                -- Here, we can't evaluate the arg strictly, because this
    -                -- partial application might be seq'd
    +          stricts
    +            | PrimOpId op _ <- idDetails v
    +            , Just demands <- case op of
    +                SeqOp       -> Just [evalDmd,topDmd] -- See Note [seq# magic]
    +                DataToTagOp -> Just [evalDmd]        -- See Note [dataToTag# magic]
    +                _           -> Nothing
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = pprTrace "here" (ppr op $$ ppr args) demands
    +
    +            | DmdSig (DmdType _ demands) <- idDmdSig v
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = demands
    +            | otherwise
    +            = [] -- If depth < length demands, then we have too few args to
    +                 -- satisfy strictness  info so we have to  ignore all the
    +                 -- strictness info, e.g. + (error "urk")
    +                 -- Here, we can't evaluate the arg strictly, because this
    +                 -- partial application might be seq'd
     
             -- We inlined into something that's not a var and has no args.
             -- Bounce it back up to cpeRhsE.
    @@ -1484,8 +1500,10 @@ cpeArg env dmd arg
              else do { v <- newVar arg_ty
                      -- See Note [Eta expansion of arguments in CorePrep]
                      ; let arg3 = cpeEtaExpandArg env arg2
    -                       arg_float = mkNonRecFloat env dmd is_unlifted v arg3
    -                 ; return (snocFloat floats2 arg_float, varToCoreExpr v) }
    +                       arg_float@(Float (NonRec v' _) _ _) =
    +                         mkNonRecFloat env dmd is_unlifted v arg3
    +                       -- v' has demand info and possibly evaldUnfolding
    +                 ; return (snocFloat floats2 arg_float, varToCoreExpr v') }
            }
     
     cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg
    @@ -1704,6 +1722,81 @@ Note [Pin demand info on floats]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     We pin demand info on floated lets, so that we can see the one-shot thunks.
     
    +Note [Pin evaluatedness on floats]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider a call to a CBV function, such as a DataCon worker with strict fields:
    +
    +  data T a = T !a
    +  ... f (T e) ...
    +
    +During ANFisation, we will `mkNonRecFloat` for `e`, binding it to a
    +fresh binder `sat`.
    +Now there are two interesting cases:
    +
    + 1. When `e=Just y` is a value, we will float `sat=Just y` as far as possible,
    +    to top-level, even. It is important that we mark `sat` as evaluated (via
    +    setting its unfolding to `evaldUnfolding`), otherwise we get a superfluous
    +    thunk to carry out the field seq on T's field, because
    +    `exprIsHNF sat == False`:
    +
    +      let sat = Just y in
    +      let sat2 = case sat of x { __DEFAULT } -> T x in
    +        -- NONONO, want just `sat2 = T x`
    +      f sat2
    +
    +    This happened in $walexGetByte, where the thunk caused additional
    +    allocation.
    +
    + 2. Similarly, when `e` is not a value, we still know that it is strictly
    +    evaluated. Hence it is going to be case-bound, and we anticipate that `sat`
    +    will be a case binder which is *always* evaluated.
    +    Hence in this case, we also mark `sat` as evaluated via its unfolding.
    +    This happened in GHC.Linker.Deps.$wgetLinkDeps, where without
    +    `evaldUnfolding` we ended up with this:
    +
    +      Word64Map = ... | Bin ... ... !Word64Map !Word64Map
    +      case ... of { Word64Map.Bin a b l r ->
    +      case insert ... of sat { __DEFAULT ->
    +      case Word64Map.Bin a b l sat of sat2 { __DEFAULT ->
    +      f sat2
    +      }}}
    +
    +    Note that *the DataCon app `Bin a b l sat` was case-bound*, because it was
    +    not detected to be a value according to `exprIsHNF`.
    +    That is because the strict field `sat` lacked the `evaldUnfolding`,
    +    although it ended up being case-bound.
    +
    +    There is one small wrinkle: It could be that `sat=insert ...` floats to
    +    top-level, where it is not eagerly evaluated. In this case, we may not
    +    give `sat` an `evaldUnfolding`. We detect this case by looking at the
    +    `FloatInfo` of `sat=insert ...`: If it says `TopLvlFloatable`, we are
    +    conservative and will not give `sat` an `evaldUnfolding`.
    +
    +TLDR; when creating a new float `sat=e` in `mkNonRecFloat`, propagate `sat` with
    +an `evaldUnfolding` if either
    +
    + 1. `e` is a value, or
    + 2. `sat=e` is case-bound, but won't float to top-level.
    +
    +Note [Flatten case-binds]
    +~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider the following program involving seq#:
    +
    +  data T a = T !a
    +  ... seq# (case x of y { __DEFAULT -> T y }) s ...
    +  ==> {ANFise, exploiting CbV-ness as in Note [seq# magic] and cpe_app}
    +  ... case (case x of y { __DEFAULT -> T y }) of sat { __DEFAULT -> seq# sat s }
    +
    +(Why didn't the Simplifier float out `case x of y`? Because `seq#` is lazy;
    +see Note [seq# magic].)
    +Note the case-of-case. This is not bad per sé, but we can easily flatten
    +this situation by calling `mkNonRecFloat` to create strict binding `y=x`:
    +
    +  ... case x of y { __DEFAULT -> let sat = T y in seq# sat s } ...
    +
    +where `T y` is simply let-bound, thus far less likely to confuse passes
    +downstream.
    +
     Note [Speculative evaluation]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Since call-by-value is much cheaper than call-by-need, we case-bind arguments
    @@ -1984,9 +2077,8 @@ zipManyFloats = foldr zipFloats emptyFloats
     
     mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind
     mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $
    -  Float (NonRec bndr' rhs) bound info
    +  Float (NonRec bndr2 rhs) bound info
       where
    -    bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats]
         (bound,info)
           | is_lifted, is_hnf        = (LetBound, TopLvlFloatable)
               -- is_lifted: We currently don't allow unlifted values at the
    @@ -2017,6 +2109,14 @@ mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr
         is_rec_call = (`elemUnVarSet` cpe_rec_ids env)
         is_data_con = isJust . isDataConId_maybe
     
    +    bndr1 = bndr `setIdDemandInfo` dmd -- See Note [Pin demand info on floats]
    +    bndr2
    +      | is_hnf || (bound == CaseBound && info /= TopLvlFloatable)
    +        -- See Note [Pin evaluatedness on floats]
    +      = bndr1 `setIdUnfolding` evaldUnfolding
    +      | otherwise
    +      = bndr1
    +
     -- | Wrap floats around an expression
     wrapBinds :: Floats -> CpeBody -> CpeBody
     wrapBinds floats body
    
    
    =====================================
    testsuite/tests/core-to-stg/T24124.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T24124 where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- CorePrep should evaluate `MkStrictPair` and its fields strictly
    
    
    =====================================
    testsuite/tests/core-to-stg/T24124.stderr
    =====================================
    @@ -0,0 +1,193 @@
    +
    +==================== CorePrep ====================
    +Result size of CorePrep
    +  = {terms: 119, types: 108, coercions: 22, joins: 0/1}
    +
    +-- RHS size: {terms: 13, types: 8, coercions: 0, joins: 0/0}
    +T24124.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T24124.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []]
    +T24124.$WMkStrictPair
    +  = \ (@a)
    +      (@b)
    +      (conrep [Occ=Once1] :: a)
    +      (conrep1 [Occ=Once1] :: b) ->
    +      case conrep of conrep2 [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      case conrep1 of conrep3 [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      T24124.MkStrictPair @a @b conrep2 conrep3
    +      }
    +      }
    +
    +-- RHS size: {terms: 20, types: 27, coercions: 0, joins: 0/1}
    +T24124.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T24124.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []]
    +T24124.testFun1
    +  = \ (@a)
    +      (@b)
    +      (x [Occ=Once1] :: a)
    +      (y [Occ=Once1, OS=OneShot] :: b)
    +      (s [Occ=Once1, OS=OneShot]
    +         :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    +      case GHC.Prim.seq# @a @GHC.Prim.RealWorld x s of
    +      { (# ipv [Occ=Once1], ipv1 [Occ=Once1] #) ->
    +      case y of conrep [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      let {
    +        sat [Occ=Once1, Dmd=SL] :: T24124.StrictPair a b
    +        [LclId, Unf=OtherCon []]
    +        sat = T24124.MkStrictPair @a @b ipv1 conrep } in
    +      GHC.Prim.seq# @(T24124.StrictPair a b) @GHC.Prim.RealWorld sat ipv
    +      }
    +      }
    +
    +-- RHS size: {terms: 9, types: 8, coercions: 15, joins: 0/0}
    +T24124.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T24124.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []]
    +T24124.testFun
    +  = (\ (@a)
    +       (@b)
    +       (eta [Occ=Once1] :: a)
    +       (eta [Occ=Once1] :: b)
    +       (eta [Occ=Once1] :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    +       T24124.testFun1 @a @b eta eta eta)
    +    `cast` (forall (a :: <*>_N) (b :: <*>_N).
    +            _R
    +            %<'GHC.Types.Many>_N ->_R _R
    +            %<'GHC.Types.Many>_N ->_R Sym (GHC.Types.N:IO[0]
    +                                               _R)
    +            :: (forall a b.
    +                a
    +                -> b
    +                -> GHC.Prim.State# GHC.Prim.RealWorld
    +                -> (# GHC.Prim.State# GHC.Prim.RealWorld, T24124.StrictPair a b #))
    +               ~R# (forall a b. a -> b -> GHC.Types.IO (T24124.StrictPair a b)))
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule4 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule4 = "main"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule3 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule3 = GHC.Types.TrNameS T24124.$trModule4
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule2 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule2 = "T24124"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule1 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule1 = GHC.Types.TrNameS T24124.$trModule2
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule :: GHC.Types.Module
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule
    +  = GHC.Types.Module T24124.$trModule3 T24124.$trModule1
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +$krep :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep = GHC.Types.KindRepVar 1#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +$krep1 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep1 = GHC.Types.KindRepVar 0#
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair2 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair2 = "StrictPair"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair1 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair1 = GHC.Types.TrNameS T24124.$tcStrictPair2
    +
    +-- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair :: GHC.Types.TyCon
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair
    +  = GHC.Types.TyCon
    +      9300255393514929474#Word64
    +      9110283622559092784#Word64
    +      T24124.$trModule
    +      T24124.$tcStrictPair1
    +      0#
    +      GHC.Types.krep$*->*->*
    +
    +-- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0}
    +$krep2 :: [GHC.Types.KindRep]
    +[GblId, Unf=OtherCon []]
    +$krep2
    +  = GHC.Types.:
    +      @GHC.Types.KindRep $krep (GHC.Types.[] @GHC.Types.KindRep)
    +
    +-- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0}
    +$krep3 :: [GHC.Types.KindRep]
    +[GblId, Unf=OtherCon []]
    +$krep3 = GHC.Types.: @GHC.Types.KindRep $krep1 $krep2
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +$krep4 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep4 = GHC.Types.KindRepTyConApp T24124.$tcStrictPair $krep3
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +$krep5 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep5 = GHC.Types.KindRepFun $krep $krep4
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair1 [InlPrag=[~]] :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair1 = GHC.Types.KindRepFun $krep1 $krep5
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair3 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair3 = "'MkStrictPair"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair2 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair2
    +  = GHC.Types.TrNameS T24124.$tc'MkStrictPair3
    +
    +-- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair :: GHC.Types.TyCon
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair
    +  = GHC.Types.TyCon
    +      2381261223169708323#Word64
    +      3151447712495713176#Word64
    +      T24124.$trModule
    +      T24124.$tc'MkStrictPair2
    +      2#
    +      T24124.$tc'MkStrictPair1
    +
    +-- RHS size: {terms: 7, types: 6, coercions: 7, joins: 0/0}
    +T24124.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []]
    +T24124.MkStrictPair
    +  = (\ (@a[sk:1])
    +       (@b[sk:1])
    +       (eta [Occ=Once1] :: a)
    +       (eta [Occ=Once1] :: b) ->
    +       T24124.MkStrictPair @a[sk:1] @b[sk:1] eta eta)
    +    `cast` ( b %1 -> T24124.StrictPair a b>_R
    +            :: (forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b)
    +               ~R# (forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b))
    +
    +
    +
    
    
    =====================================
    testsuite/tests/core-to-stg/all.T
    =====================================
    @@ -3,3 +3,4 @@
     test('T19700', normal, compile, ['-O'])
     test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -ddump-prep'])
     test('T23914', normal, compile, ['-O'])
    +test('T24124', [grep_errmsg(r'= .*MkStrictPair.*in')], compile, ['-O -dsuppress-uniques -ddump-prep'])
    
    
    =====================================
    testsuite/tests/ghci/should_run/T21052.stdout
    =====================================
    @@ -5,7 +5,7 @@ BCO_toplevel :: GHC.Types.IO [GHC.Types.Any]
         {} \u []
             let {
               sat :: [GHC.Types.Any]
    -          [LclId] =
    +          [LclId, Unf=OtherCon []] =
                   :! [GHC.Tuple.Prim.() GHC.Types.[]];
             } in  GHC.Base.returnIO sat;
     
    
    
    =====================================
    testsuite/tests/simplCore/should_compile/T23083.stderr
    =====================================
    @@ -14,8 +14,8 @@ T23083.g
       = \ (f [Occ=Once1!] :: (GHC.Num.Integer.Integer -> GHC.Num.Integer.Integer) -> GHC.Num.Integer.Integer) (h [Occ=OnceL1] :: GHC.Num.Integer.Integer -> GHC.Num.Integer.Integer) ->
           let {
             sat [Occ=Once1] :: GHC.Num.Integer.Integer -> GHC.Num.Integer.Integer
    -        [LclId]
    -        sat = \ (eta [Occ=Once1] :: GHC.Num.Integer.Integer) -> case h of h1 [Occ=Once1] { __DEFAULT -> T23083.$$ @GHC.Num.Integer.Integer @GHC.Num.Integer.Integer h1 eta } } in
    +        [LclId, Unf=OtherCon []]
    +        sat = \ (eta [Occ=Once1] :: GHC.Num.Integer.Integer) -> case h of h1 [Occ=Once1, Dmd=SL] { __DEFAULT -> T23083.$$ @GHC.Num.Integer.Integer @GHC.Num.Integer.Integer h1 eta } } in
           f sat
     
     -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T19717.stderr
    =====================================
    @@ -3,15 +3,15 @@
     Foo.f :: forall {a}. a -> [GHC.Maybe.Maybe a]
     [GblId, Arity=1, Str=<1L>, Unf=OtherCon []] =
         {} \r [x]
    -        case x of x1 {
    +        case x of x1 [Dmd=SL] {
             __DEFAULT ->
             let {
               sat [Occ=Once1] :: GHC.Maybe.Maybe a
    -          [LclId] =
    +          [LclId, Unf=OtherCon []] =
                   GHC.Maybe.Just! [x1]; } in
             let {
               sat [Occ=Once1] :: [GHC.Maybe.Maybe a]
    -          [LclId] =
    +          [LclId, Unf=OtherCon []] =
                   :! [sat GHC.Types.[]];
             } in  : [sat sat];
             };
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a919e3194d0fc6e87ee20dcba1c586ab7aa84158...5c80ed4aae6ea2861b7a4eacb242ce103a0ea203
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a919e3194d0fc6e87ee20dcba1c586ab7aa84158...5c80ed4aae6ea2861b7a4eacb242ce103a0ea203
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 12:52:45 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Sat, 28 Oct 2023 08:52:45 -0400
    Subject: [Git][ghc/ghc][wip/T24124] 6 commits: Teach tag-inference about
     SeqOp/seq#
    Message-ID: <653d041d6c012_1f7b0dcda8e74c93496c@gitlab.mail>
    
    
    
    Sebastian Graf pushed to branch wip/T24124 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    92b6a902 by Sebastian Graf at 2023-10-28T14:40:47+02:00
    ghc-toolchain: build with `-package-env=-` (#24131)
    
    Otherwise globally installed libraries (via `cabal install --lib`)
    break the build.
    
    Fixes #24131.
    
    - - - - -
    aafbf775 by Sebastian Graf at 2023-10-28T14:40:47+02:00
    CorePrep: Attach evaldUnfolding to floats to detect more values
    
    See `Note [Pin evaluatedness on floats]`.
    
    - - - - -
    9690fdab by Sebastian Graf at 2023-10-28T14:52:25+02:00
    CorePrep: Treat seq# and dataToTag# as strict functions (#24124)
    
    See the new `Note [seq# magic]`.
    I also implemented a new `Note [Flatten case-bind]`.
    
    Fixes #24124.
    
    - - - - -
    
    
    26 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    - m4/ghc_toolchain.m4
    - rts/linker/PEi386.c
    - + testsuite/tests/core-to-stg/T24124.hs
    - + testsuite/tests/core-to-stg/T24124.stderr
    - testsuite/tests/core-to-stg/all.T
    - testsuite/tests/ghci/should_run/T21052.stdout
    - testsuite/tests/simplCore/should_compile/T23083.stderr
    - + testsuite/tests/simplStg/should_compile/T15226b.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.stderr
    - testsuite/tests/simplStg/should_compile/T19717.stderr
    - testsuite/tests/simplStg/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/inferTags003.hs
    - + testsuite/tests/simplStg/should_compile/inferTags003.stderr
    - + testsuite/tests/simplStg/should_compile/inferTags004.hs
    - + testsuite/tests/simplStg/should_compile/inferTags004.stderr
    - + testsuite/tests/th/T24111.hs
    - + testsuite/tests/th/T24111.stdout
    - testsuite/tests/th/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -3640,7 +3640,7 @@ primop SparkOp "spark#" GenPrimOp
        with effect = ReadWriteEffect
        code_size = { primOpCodeSizeForeignCall }
     
    --- See Note [seq# magic] in GHC.Core.Op.ConstantFold
    +-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
     primop SeqOp "seq#" GenPrimOp
        a -> State# s -> (# State# s, a #)
        with
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2028,6 +2028,9 @@ is:
          case e of 
       by GHC.Core.Opt.ConstantFold.caseRules; see Note [caseRules for dataToTag]
     
    +* Similar to Note [seq# magic], we case-bind the arg of dataToTag# in
    +  GHC.CoreToStg.Prep.
    +
     See #15696 for a long saga.
     -}
     
    @@ -2103,11 +2106,26 @@ Implementing seq#.  The compiler has magic for SeqOp in
     
     - GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq#  s)
     
    +- GHC.CoreToStg.Prep: Case-bind the arg of seq#, e.g.,
    +
    +    case seq# (f 13) s of (# r, s' #) -> ...
    +    ==>
    +    case f 13 of sat of __DEFAULT ->
    +    case seq# sat s of (# r, s' #) -> ...,
    +
    +  encoding its call-by-value nature (as implemented in StgToCmm below).
    +  Note that strictness analysis and the Simplifier will never see this case
    +  binding, so #5129 as above is not an issue. Plus, CorePrep never case-binds an
    +  argument variable anyway.
    +
     - GHC.StgToCmm.Expr.cgExpr, and cgCase: special case for seq#
     
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a
    +  properly-tagged pointer inside of its unboxed-tuple result.
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/CoreToStg/Prep.hs
    =====================================
    @@ -70,6 +70,7 @@ import GHC.Types.Unique.Supply
     
     import Data.List        ( unfoldr )
     import Control.Monad
    +import GHC.Builtin.PrimOps
     
     {-
     Note [CorePrep Overview]
    @@ -679,9 +680,11 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs
                    else warnPprTrace True "CorePrep: silly extra arguments:" (ppr bndr) $
                                    -- Note [Silly extra arguments]
                         (do { v <- newVar (idType bndr)
    -                        ; let float = mkNonRecFloat env topDmd False v rhs2
    +                        ; let float@(Float (NonRec v' _) _ _) =
    +                                mkNonRecFloat env topDmd False v rhs2
    +                        -- v' has demand info and possibly evaldUnfolding
                             ; return ( snocFloat floats2 float
    -                                 , cpeEtaExpand arity (Var v)) })
    +                                 , cpeEtaExpand arity (Var v')) })
     
             -- Wrap floating ticks
            ; let (floats4, rhs4) = wrapTicks floats3 rhs3
    @@ -848,7 +851,12 @@ cpeRhsE env (Case scrut bndr ty alts)
                    where err = mkImpossibleExpr ty "cpeRhsE: missing case alternative"
            ; alts'' <- mapM (sat_alt env') alts'
     
    -       ; return (floats, Case scrut' bndr2 ty alts'') }
    +       ; case alts'' of
    +           [Alt DEFAULT _ rhs] -- See Note [Flatten case-binds]
    +             | float <- mkNonRecFloat env evalDmd True bndr2 scrut'
    +                 -- True: is_unlifted, so that we don't float to top-level
    +             -> return (snocFloat floats float, rhs)
    +           _ -> return (floats, Case scrut' bndr2 ty alts'') }
       where
         sat_alt env (Alt con bs rhs)
            = do { (env2, bs') <- cpCloneBndrs env bs
    @@ -1087,16 +1095,24 @@ cpeApp top_env expr
                ; mb_saturate hd app floats unsat_ticks depth }
             where
               depth = val_args args
    -          stricts = case idDmdSig v of
    -                            DmdSig (DmdType _ demands)
    -                              | listLengthCmp demands depth /= GT -> demands
    -                                    -- length demands <= depth
    -                              | otherwise                         -> []
    -                -- If depth < length demands, then we have too few args to
    -                -- satisfy strictness  info so we have to  ignore all the
    -                -- strictness info, e.g. + (error "urk")
    -                -- Here, we can't evaluate the arg strictly, because this
    -                -- partial application might be seq'd
    +          stricts
    +            | PrimOpId op _ <- idDetails v
    +            , Just demands <- case op of
    +                SeqOp       -> Just [evalDmd,topDmd] -- See Note [seq# magic]
    +                DataToTagOp -> Just [evalDmd]        -- See Note [dataToTag# magic]
    +                _           -> Nothing
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = pprTrace "here" (ppr op $$ ppr args) demands
    +
    +            | DmdSig (DmdType _ demands) <- idDmdSig v
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = demands
    +            | otherwise
    +            = [] -- If depth < length demands, then we have too few args to
    +                 -- satisfy strictness  info so we have to  ignore all the
    +                 -- strictness info, e.g. + (error "urk")
    +                 -- Here, we can't evaluate the arg strictly, because this
    +                 -- partial application might be seq'd
     
             -- We inlined into something that's not a var and has no args.
             -- Bounce it back up to cpeRhsE.
    @@ -1484,8 +1500,10 @@ cpeArg env dmd arg
              else do { v <- newVar arg_ty
                      -- See Note [Eta expansion of arguments in CorePrep]
                      ; let arg3 = cpeEtaExpandArg env arg2
    -                       arg_float = mkNonRecFloat env dmd is_unlifted v arg3
    -                 ; return (snocFloat floats2 arg_float, varToCoreExpr v) }
    +                       arg_float@(Float (NonRec v' _) _ _) =
    +                         mkNonRecFloat env dmd is_unlifted v arg3
    +                       -- v' has demand info and possibly evaldUnfolding
    +                 ; return (snocFloat floats2 arg_float, varToCoreExpr v') }
            }
     
     cpeEtaExpandArg :: CorePrepEnv -> CoreArg -> CoreArg
    @@ -1704,6 +1722,81 @@ Note [Pin demand info on floats]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     We pin demand info on floated lets, so that we can see the one-shot thunks.
     
    +Note [Pin evaluatedness on floats]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider a call to a CBV function, such as a DataCon worker with strict fields:
    +
    +  data T a = T !a
    +  ... f (T e) ...
    +
    +During ANFisation, we will `mkNonRecFloat` for `e`, binding it to a
    +fresh binder `sat`.
    +Now there are two interesting cases:
    +
    + 1. When `e=Just y` is a value, we will float `sat=Just y` as far as possible,
    +    to top-level, even. It is important that we mark `sat` as evaluated (via
    +    setting its unfolding to `evaldUnfolding`), otherwise we get a superfluous
    +    thunk to carry out the field seq on T's field, because
    +    `exprIsHNF sat == False`:
    +
    +      let sat = Just y in
    +      let sat2 = case sat of x { __DEFAULT } -> T x in
    +        -- NONONO, want just `sat2 = T x`
    +      f sat2
    +
    +    This happened in $walexGetByte, where the thunk caused additional
    +    allocation.
    +
    + 2. Similarly, when `e` is not a value, we still know that it is strictly
    +    evaluated. Hence it is going to be case-bound, and we anticipate that `sat`
    +    will be a case binder which is *always* evaluated.
    +    Hence in this case, we also mark `sat` as evaluated via its unfolding.
    +    This happened in GHC.Linker.Deps.$wgetLinkDeps, where without
    +    `evaldUnfolding` we ended up with this:
    +
    +      Word64Map = ... | Bin ... ... !Word64Map !Word64Map
    +      case ... of { Word64Map.Bin a b l r ->
    +      case insert ... of sat { __DEFAULT ->
    +      case Word64Map.Bin a b l sat of sat2 { __DEFAULT ->
    +      f sat2
    +      }}}
    +
    +    Note that *the DataCon app `Bin a b l sat` was case-bound*, because it was
    +    not detected to be a value according to `exprIsHNF`.
    +    That is because the strict field `sat` lacked the `evaldUnfolding`,
    +    although it ended up being case-bound.
    +
    +    There is one small wrinkle: It could be that `sat=insert ...` floats to
    +    top-level, where it is not eagerly evaluated. In this case, we may not
    +    give `sat` an `evaldUnfolding`. We detect this case by looking at the
    +    `FloatInfo` of `sat=insert ...`: If it says `TopLvlFloatable`, we are
    +    conservative and will not give `sat` an `evaldUnfolding`.
    +
    +TLDR; when creating a new float `sat=e` in `mkNonRecFloat`, propagate `sat` with
    +an `evaldUnfolding` if either
    +
    + 1. `e` is a value, or
    + 2. `sat=e` is case-bound, but won't float to top-level.
    +
    +Note [Flatten case-binds]
    +~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider the following program involving seq#:
    +
    +  data T a = T !a
    +  ... seq# (case x of y { __DEFAULT -> T y }) s ...
    +  ==> {ANFise, exploiting CbV-ness as in Note [seq# magic] and cpe_app}
    +  ... case (case x of y { __DEFAULT -> T y }) of sat { __DEFAULT -> seq# sat s }
    +
    +(Why didn't the Simplifier float out `case x of y`? Because `seq#` is lazy;
    +see Note [seq# magic].)
    +Note the case-of-case. This is not bad per sé, but we can easily flatten
    +this situation by calling `mkNonRecFloat` to create strict binding `y=x`:
    +
    +  ... case x of y { __DEFAULT -> let sat = T y in seq# sat s } ...
    +
    +where `T y` is simply let-bound, thus far less likely to confuse passes
    +downstream.
    +
     Note [Speculative evaluation]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Since call-by-value is much cheaper than call-by-need, we case-bind arguments
    @@ -1984,9 +2077,8 @@ zipManyFloats = foldr zipFloats emptyFloats
     
     mkNonRecFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind
     mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr $
    -  Float (NonRec bndr' rhs) bound info
    +  Float (NonRec bndr2 rhs) bound info
       where
    -    bndr' = setIdDemandInfo bndr dmd -- See Note [Pin demand info on floats]
         (bound,info)
           | is_lifted, is_hnf        = (LetBound, TopLvlFloatable)
               -- is_lifted: We currently don't allow unlifted values at the
    @@ -2017,6 +2109,14 @@ mkNonRecFloat env dmd is_unlifted bndr rhs = -- pprTraceWith "mkNonRecFloat" ppr
         is_rec_call = (`elemUnVarSet` cpe_rec_ids env)
         is_data_con = isJust . isDataConId_maybe
     
    +    bndr1 = bndr `setIdDemandInfo` dmd -- See Note [Pin demand info on floats]
    +    bndr2
    +      | is_hnf || (bound == CaseBound && info /= TopLvlFloatable)
    +        -- See Note [Pin evaluatedness on floats]
    +      = bndr1 `setIdUnfolding` evaldUnfolding
    +      | otherwise
    +      = bndr1
    +
     -- | Wrap floats around an expression
     wrapBinds :: Floats -> CpeBody -> CpeBody
     wrapBinds floats body
    
    
    =====================================
    compiler/GHC/Stg/InferTags.hs
    =====================================
    @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) )
     import GHC.Types.Unique.Supply (mkSplitUniqSupply)
     import GHC.Types.RepType (dataConRuntimeRepStrictness)
     import GHC.Core (AltCon(..))
    +import GHC.Builtin.PrimOps ( PrimOp(..) )
     import Data.List (mapAccumL)
     import GHC.Utils.Outputable
     import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull )
    @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args)
              | otherwise
              = --pprTrace "inferAppUnknown" (ppr fun) $
                TagDunno
    --- TODO:
    --- If we have something like:
    ---   let x = thunk in
    ---   f g = case g of g' -> (# x, g' #)
    --- then we *do* know that g' will be properly tagged,
    --- so we should return TagTagged [TagDunno,TagProper] but currently we infer
    --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr.
    --- Seems not to matter much but should be changed eventually.
     
     inferTagExpr env (StgConApp con cn args tys)
       = (inferConTag env con args, StgConApp con cn args tys)
    @@ -340,9 +333,21 @@ inferTagExpr env (StgTick tick body)
         (info, body') = inferTagExpr env body
     
     inferTagExpr _ (StgOpApp op args ty)
    -  = -- Do any primops guarantee to return a properly tagged value?
    -    -- I think not.  Ditto foreign calls.
    -    (TagDunno, StgOpApp op args ty)
    +  | StgPrimOp SeqOp <- op
    +  -- Recall seq# :: a -> State# s -> (# State# s, a #)
    +  -- However the output State# token has been unarised away,
    +  -- so we now effectively have
    +  --    seq# :: a -> State# s -> (# a #)
    +  -- The key point is the result of `seq#` is guaranteed evaluated and properly
    +  -- tagged (because that result comes directly from evaluating the arg),
    +  -- and we want tag inference to reflect that knowledge (#15226).
    +  -- Hence `TagTuple [TagProper]`.
    +  -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
    +  = (TagTuple [TagProper], StgOpApp op args ty)
    +  -- Do any other primops guarantee to return a properly tagged value?
    +  -- Probably not, and that is the conservative assumption anyway.
    +  -- (And foreign calls definitely need not make promises.)
    +  | otherwise = (TagDunno, StgOpApp op args ty)
     
     inferTagExpr env (StgLet ext bind body)
       = (info, StgLet ext bind' body')
    
    
    =====================================
    compiler/GHC/Stg/InferTags/Rewrite.hs
    =====================================
    @@ -217,7 +217,7 @@ withLcl fv act = do
     When compiling bytecode we call myCoreToStg to get STG code first.
     myCoreToStg in turn calls out to stg2stg which runs the STG to STG
     passes followed by free variables analysis and the tag inference pass including
    -it's rewriting phase at the end.
    +its rewriting phase at the end.
     Running tag inference is important as it upholds Note [Strict Field Invariant].
     While code executed by GHCi doesn't take advantage of the SFI it can call into
     compiled code which does. So it must still make sure that the SFI is upheld.
    @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr
     rewriteExpr (e at StgCase {})          = rewriteCase e
     rewriteExpr (e at StgLet {})           = rewriteLet e
     rewriteExpr (e at StgLetNoEscape {})   = rewriteLetNoEscape e
    -rewriteExpr (StgTick t e)     = StgTick t <$!> rewriteExpr e
    +rewriteExpr (StgTick t e)           = StgTick t <$!> rewriteExpr e
     rewriteExpr e@(StgConApp {})        = rewriteConApp e
    -rewriteExpr e@(StgApp {})     = rewriteApp e
    -rewriteExpr (StgLit lit)           = return $! (StgLit lit)
    -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do
    -        (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty)
    +rewriteExpr e@(StgOpApp {})         = rewriteOpApp e
    +rewriteExpr e@(StgApp {})           = rewriteApp e
    +rewriteExpr (StgLit lit)            = return $! (StgLit lit)
     
     
     rewriteCase :: InferStgExpr -> RM TgStgExpr
    @@ -488,6 +486,33 @@ rewriteApp (StgApp f args)
     rewriteApp (StgApp f args) = return $ StgApp f args
     rewriteApp _ = panic "Impossible"
     
    +{-
    +Note [Rewriting primop arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Given an application `op# x y`, is it worth applying `rewriteArg` to
    +`x` and `y`?  All that will do will be to set the `tagSig` for that
    +occurrence of `x` and `y` to record whether it is evaluated and
    +properly tagged. For the vast majority of primops that's a waste of
    +time: the argument is an `Int#` or something.
    +
    +But code generation for `seq#` and `dataToTag#` /does/ consult that
    +tag, to statically avoid generating an eval:
    +* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig`
    +* `dataToTag#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`.
    +
    +So for these we should call `rewriteArgs`.
    +
    +-}
    +
    +rewriteOpApp :: InferStgExpr -> RM TgStgExpr
    +rewriteOpApp (StgOpApp op args res_ty) = case op of
    +  op@(StgPrimOp primOp)
    +    | primOp == SeqOp || primOp == DataToTagOp
    +    -- see Note [Rewriting primop arguments]
    +    -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    +  _ -> pure $! StgOpApp op args res_ty
    +rewriteOpApp _ = panic "Impossible"
    +
     -- `mkSeq` x x' e generates `case x of x' -> e`
     -- We could also substitute x' for x in e but that's so rarely beneficial
     -- that we don't bother.
    
    
    =====================================
    compiler/GHC/Stg/InferTags/TagSig.hs
    =====================================
    @@ -5,7 +5,7 @@
     -- We export this type from this module instead of GHC.Stg.InferTags.Types
     -- because it's used by more than the analysis itself. For example in interface
     -- files where we record a tag signature for bindings.
    --- By putting the sig into it's own module we can avoid module loops.
    +-- By putting the sig into its own module we can avoid module loops.
     module GHC.Stg.InferTags.TagSig
     
     where
    @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> ()
     seqTagInfo TagTagged      = ()
     seqTagInfo TagDunno       = ()
     seqTagInfo TagProper      = ()
    -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    \ No newline at end of file
    +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of
     --
     -- In more complex cases, there is a foreign call (out of line) fallback. This
     -- might happen e.g. if there's enough static information, such as statically
    --- know arguments.
    +-- known arguments.
     emitPrimOp
       :: StgToCmmConfig
       -> PrimOp            -- ^ The primop
    
    
    =====================================
    libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    =====================================
    @@ -14,7 +14,7 @@ import Language.Haskell.TH.Syntax
     import Data.Word ( Word8 )
     import Data.Char ( toLower, chr)
     import GHC.Show  ( showMultiLineString )
    -import GHC.Lexeme( startsVarSym )
    +import GHC.Lexeme( isVarSymChar )
     import Data.Ratio ( numerator, denominator )
     import Data.Foldable ( toList )
     import Prelude hiding ((<>))
    @@ -122,8 +122,8 @@ isSymOcc :: Name -> Bool
     isSymOcc n
       = case nameBase n of
           []    -> True  -- Empty name; weird
    -      (c:_) -> startsVarSym c
    -                   -- c.f. OccName.startsVarSym in GHC itself
    +      (c:_) -> isVarSymChar c
    +                   -- c.f. isVarSymChar in GHC itself
     
     pprInfixExp :: Exp -> Doc
     pprInfixExp (VarE v) = pprName' Infix v
    @@ -471,7 +471,8 @@ ppr_dec _ (PatSynD name args dir pat)
         pprNameArgs | InfixPatSyn a1 a2 <- args = ppr a1 <+> pprName' Infix name <+> ppr a2
                     | otherwise                 = pprName' Applied name <+> ppr args
         pprPatRHS   | ExplBidir cls <- dir = hang (ppr pat <+> text "where")
    -                                           nestDepth (pprName' Applied name <+> ppr cls)
    +                                              nestDepth
    +                                              (vcat $ (pprName' Applied name <+>) . ppr <$> cls)
                     | otherwise            = ppr pat
     ppr_dec _ (PatSynSigD name ty)
       = pprPatSynSig name ty
    
    
    =====================================
    m4/ghc_toolchain.m4
    =====================================
    @@ -148,6 +148,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN_BIN],[
                     -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \
                     -XNoImplicitPrelude \
                     -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
    +                -package-env=- \
                     utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain || AC_MSG_ERROR([Could not compile ghc-toolchain])
                 GHC_TOOLCHAIN_BIN="./acghc-toolchain"
                 ;;
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -1939,29 +1939,32 @@ static size_t
     makeSymbolExtra_PEi386( ObjectCode* oc, uint64_t index STG_UNUSED, size_t s, char* symbol STG_UNUSED, SymType type )
     {
         SymbolExtra *extra;
    -
    -    if (type == SYM_TYPE_CODE) {
    -        // jmp *-14(%rip)
    -        extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    -        memcpy(extra->jumpIsland, jmp, 6);
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    -        return (size_t)&extra->jumpIsland;
    -    } else if (type == SYM_TYPE_INDIRECT_DATA) {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        void *v = *(void**) s;
    -        extra->addr = (uint64_t)v;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    -    } else {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    +    switch(type & ~SYM_TYPE_DUP_DISCARD) {
    +        case SYM_TYPE_CODE: {
    +            // jmp *-14(%rip)
    +            extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    +            memcpy(extra->jumpIsland, jmp, 6);
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    +            return (size_t)&extra->jumpIsland;
    +        }
    +        case SYM_TYPE_INDIRECT_DATA: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            void *v = *(void**) s;
    +            extra->addr = (uint64_t)v;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
    +        default: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
         }
     }
     
    
    
    =====================================
    testsuite/tests/core-to-stg/T24124.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T24124 where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- CorePrep should evaluate `MkStrictPair` and its fields strictly
    
    
    =====================================
    testsuite/tests/core-to-stg/T24124.stderr
    =====================================
    @@ -0,0 +1,193 @@
    +
    +==================== CorePrep ====================
    +Result size of CorePrep
    +  = {terms: 119, types: 108, coercions: 22, joins: 0/1}
    +
    +-- RHS size: {terms: 13, types: 8, coercions: 0, joins: 0/0}
    +T24124.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T24124.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []]
    +T24124.$WMkStrictPair
    +  = \ (@a)
    +      (@b)
    +      (conrep [Occ=Once1] :: a)
    +      (conrep1 [Occ=Once1] :: b) ->
    +      case conrep of conrep2 [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      case conrep1 of conrep3 [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      T24124.MkStrictPair @a @b conrep2 conrep3
    +      }
    +      }
    +
    +-- RHS size: {terms: 20, types: 27, coercions: 0, joins: 0/1}
    +T24124.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T24124.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []]
    +T24124.testFun1
    +  = \ (@a)
    +      (@b)
    +      (x [Occ=Once1] :: a)
    +      (y [Occ=Once1, OS=OneShot] :: b)
    +      (s [Occ=Once1, OS=OneShot]
    +         :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    +      case GHC.Prim.seq# @a @GHC.Prim.RealWorld x s of
    +      { (# ipv [Occ=Once1], ipv1 [Occ=Once1] #) ->
    +      case y of conrep [Occ=Once1, Dmd=SL] { __DEFAULT ->
    +      let {
    +        sat [Occ=Once1, Dmd=SL] :: T24124.StrictPair a b
    +        [LclId, Unf=OtherCon []]
    +        sat = T24124.MkStrictPair @a @b ipv1 conrep } in
    +      GHC.Prim.seq# @(T24124.StrictPair a b) @GHC.Prim.RealWorld sat ipv
    +      }
    +      }
    +
    +-- RHS size: {terms: 9, types: 8, coercions: 15, joins: 0/0}
    +T24124.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T24124.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []]
    +T24124.testFun
    +  = (\ (@a)
    +       (@b)
    +       (eta [Occ=Once1] :: a)
    +       (eta [Occ=Once1] :: b)
    +       (eta [Occ=Once1] :: GHC.Prim.State# GHC.Prim.RealWorld) ->
    +       T24124.testFun1 @a @b eta eta eta)
    +    `cast` (forall (a :: <*>_N) (b :: <*>_N).
    +            _R
    +            %<'GHC.Types.Many>_N ->_R _R
    +            %<'GHC.Types.Many>_N ->_R Sym (GHC.Types.N:IO[0]
    +                                               _R)
    +            :: (forall a b.
    +                a
    +                -> b
    +                -> GHC.Prim.State# GHC.Prim.RealWorld
    +                -> (# GHC.Prim.State# GHC.Prim.RealWorld, T24124.StrictPair a b #))
    +               ~R# (forall a b. a -> b -> GHC.Types.IO (T24124.StrictPair a b)))
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule4 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule4 = "main"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule3 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule3 = GHC.Types.TrNameS T24124.$trModule4
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule2 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule2 = "T24124"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule1 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule1 = GHC.Types.TrNameS T24124.$trModule2
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +T24124.$trModule :: GHC.Types.Module
    +[GblId, Unf=OtherCon []]
    +T24124.$trModule
    +  = GHC.Types.Module T24124.$trModule3 T24124.$trModule1
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +$krep :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep = GHC.Types.KindRepVar 1#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +$krep1 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep1 = GHC.Types.KindRepVar 0#
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair2 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair2 = "StrictPair"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair1 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair1 = GHC.Types.TrNameS T24124.$tcStrictPair2
    +
    +-- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tcStrictPair :: GHC.Types.TyCon
    +[GblId, Unf=OtherCon []]
    +T24124.$tcStrictPair
    +  = GHC.Types.TyCon
    +      9300255393514929474#Word64
    +      9110283622559092784#Word64
    +      T24124.$trModule
    +      T24124.$tcStrictPair1
    +      0#
    +      GHC.Types.krep$*->*->*
    +
    +-- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0}
    +$krep2 :: [GHC.Types.KindRep]
    +[GblId, Unf=OtherCon []]
    +$krep2
    +  = GHC.Types.:
    +      @GHC.Types.KindRep $krep (GHC.Types.[] @GHC.Types.KindRep)
    +
    +-- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0}
    +$krep3 :: [GHC.Types.KindRep]
    +[GblId, Unf=OtherCon []]
    +$krep3 = GHC.Types.: @GHC.Types.KindRep $krep1 $krep2
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +$krep4 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep4 = GHC.Types.KindRepTyConApp T24124.$tcStrictPair $krep3
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +$krep5 :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +$krep5 = GHC.Types.KindRepFun $krep $krep4
    +
    +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair1 [InlPrag=[~]] :: GHC.Types.KindRep
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair1 = GHC.Types.KindRepFun $krep1 $krep5
    +
    +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair3 :: GHC.Prim.Addr#
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair3 = "'MkStrictPair"#
    +
    +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair2 :: GHC.Types.TrName
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair2
    +  = GHC.Types.TrNameS T24124.$tc'MkStrictPair3
    +
    +-- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0}
    +T24124.$tc'MkStrictPair :: GHC.Types.TyCon
    +[GblId, Unf=OtherCon []]
    +T24124.$tc'MkStrictPair
    +  = GHC.Types.TyCon
    +      2381261223169708323#Word64
    +      3151447712495713176#Word64
    +      T24124.$trModule
    +      T24124.$tc'MkStrictPair2
    +      2#
    +      T24124.$tc'MkStrictPair1
    +
    +-- RHS size: {terms: 7, types: 6, coercions: 7, joins: 0/0}
    +T24124.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []]
    +T24124.MkStrictPair
    +  = (\ (@a[sk:1])
    +       (@b[sk:1])
    +       (eta [Occ=Once1] :: a)
    +       (eta [Occ=Once1] :: b) ->
    +       T24124.MkStrictPair @a[sk:1] @b[sk:1] eta eta)
    +    `cast` ( b %1 -> T24124.StrictPair a b>_R
    +            :: (forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b)
    +               ~R# (forall {a} {b}. a %1 -> b %1 -> T24124.StrictPair a b))
    +
    +
    +
    
    
    =====================================
    testsuite/tests/core-to-stg/all.T
    =====================================
    @@ -3,3 +3,4 @@
     test('T19700', normal, compile, ['-O'])
     test('T23270', [grep_errmsg(r'patError')], compile, ['-O0 -dsuppress-uniques -ddump-prep'])
     test('T23914', normal, compile, ['-O'])
    +test('T24124', [grep_errmsg(r'= .*MkStrictPair.*in')], compile, ['-O -dsuppress-uniques -ddump-prep'])
    
    
    =====================================
    testsuite/tests/ghci/should_run/T21052.stdout
    =====================================
    @@ -5,7 +5,7 @@ BCO_toplevel :: GHC.Types.IO [GHC.Types.Any]
         {} \u []
             let {
               sat :: [GHC.Types.Any]
    -          [LclId] =
    +          [LclId, Unf=OtherCon []] =
                   :! [GHC.Tuple.Prim.() GHC.Types.[]];
             } in  GHC.Base.returnIO sat;
     
    
    
    =====================================
    testsuite/tests/simplCore/should_compile/T23083.stderr
    =====================================
    @@ -14,8 +14,8 @@ T23083.g
       = \ (f [Occ=Once1!] :: (GHC.Num.Integer.Integer -> GHC.Num.Integer.Integer) -> GHC.Num.Integer.Integer) (h [Occ=OnceL1] :: GHC.Num.Integer.Integer -> GHC.Num.Integer.Integer) ->
           let {
             sat [Occ=Once1] :: GHC.Num.Integer.Integer -> GHC.Num.Integer.Integer
    -        [LclId]
    -        sat = \ (eta [Occ=Once1] :: GHC.Num.Integer.Integer) -> case h of h1 [Occ=Once1] { __DEFAULT -> T23083.$$ @GHC.Num.Integer.Integer @GHC.Num.Integer.Integer h1 eta } } in
    +        [LclId, Unf=OtherCon []]
    +        sat = \ (eta [Occ=Once1] :: GHC.Num.Integer.Integer) -> case h of h1 [Occ=Once1, Dmd=SL] { __DEFAULT -> T23083.$$ @GHC.Num.Integer.Integer @GHC.Num.Integer.Integer h1 eta } } in
           f sat
     
     -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T15226b where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- tag inference should not insert an eval for x' in making the strict pair
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -0,0 +1,48 @@
    +
    +==================== Final STG: ====================
    +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
    +    {} \r [conrep conrep1]
    +        case conrep of conrep2 [Occ=Once1] {
    +        __DEFAULT ->
    +        case conrep1 of conrep3 [Occ=Once1] {
    +        __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
    +        };
    +        };
    +
    +T15226b.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [x y void]
    +        case seq# [x GHC.Prim.void#] of {
    +        Solo# ipv1 [Occ=Once1] ->
    +        let {
    +          sat [Occ=Once1] :: T15226b.StrictPair a b
    +          [LclId] =
    +              {ipv1, y} \u []
    +                  case y of conrep [Occ=Once1] {
    +                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    +                  };
    +        } in  seq# [sat GHC.Prim.void#];
    +        };
    +
    +T15226b.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#;
    +
    +T15226b.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
    +    {} \r [eta eta]
    +        case eta of eta {
    +        __DEFAULT ->
    +        case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; };
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T19717.stderr
    =====================================
    @@ -3,15 +3,15 @@
     Foo.f :: forall {a}. a -> [GHC.Maybe.Maybe a]
     [GblId, Arity=1, Str=<1L>, Unf=OtherCon []] =
         {} \r [x]
    -        case x of x1 {
    +        case x of x1 [Dmd=SL] {
             __DEFAULT ->
             let {
               sat [Occ=Once1] :: GHC.Maybe.Maybe a
    -          [LclId] =
    +          [LclId, Unf=OtherCon []] =
                   GHC.Maybe.Just! [x1]; } in
             let {
               sat [Occ=Once1] :: [GHC.Maybe.Maybe a]
    -          [LclId] =
    +          [LclId, Unf=OtherCon []] =
                   :! [sat GHC.Types.[]];
             } in  : [sat sat];
             };
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/all.T
    =====================================
    @@ -18,3 +18,8 @@ test('T22840', [extra_files(
             [ 'T22840A.hs'
             , 'T22840B.hs'
             ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks'])
    +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds'])
    +test('inferTags003', [ only_ways(['optasm']),
    +                       grep_errmsg(r'(call stg\_ap\_0)', [1])
    +                     ], compile, ['-ddump-cmm -dno-typeable-binds -O'])
    +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques'])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE MagicHash #-}
    +module M where
    +
    +import GHC.Exts
    +import GHC.IO
    +
    +data T a = MkT !Bool !a
    +
    +fun :: T a -> IO a
    +{-# OPAQUE fun #-}
    +fun (MkT _ x) = IO $ \s -> noinline seq# x s
    +-- evaluate/seq# should not produce its own eval for x
    +-- since it is properly tagged (from a strict field)
    +
    +-- uses noinline to prevent caseRules from eliding the seq# in Core
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.stderr
    =====================================
    @@ -0,0 +1,177 @@
    +
    +==================== Output Cmm ====================
    +[M.$WMkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cEx,
    +                        label: block_cEx_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cEA,
    +                        label: M.$WMkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cED,
    +                        label: block_cED_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEA: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH;   // CmmCondBranch
    +       cEG: // global
    +           R1 = M.$WMkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cEH: // global
    +           I64[Sp - 16] = cEx;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEx; else goto cEy;   // CmmCondBranch
    +       cEy: // global
    +           call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEx: // global
    +           // slowCall
    +           I64[Sp] = cED;   // CmmStore
    +           _sEi::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _sEi::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cED: // global
    +           // slow_call for _sEh::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cEL; else goto cEK;   // CmmCondBranch
    +       cEL: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEK: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.$WMkT_closure" {
    +     M.$WMkT_closure:
    +         const M.$WMkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.fun_entry() { //  [R2]
    +         { info_tbls: [(cEV,
    +                        label: block_cEV_info
    +                        rep: StackRep []
    +                        srt: Nothing),
    +                       (cEY,
    +                        label: M.fun_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEY: // global
    +           if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0;   // CmmCondBranch
    +       cEZ: // global
    +           R1 = M.fun_closure;   // CmmAssign
    +           call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cF0: // global
    +           I64[Sp - 8] = cEV;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           Sp = Sp - 8;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEV; else goto cEW;   // CmmCondBranch
    +       cEW: // global
    +           call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEV: // global
    +           R1 = P64[R1 + 15];   // CmmAssign
    +           Sp = Sp + 8;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.fun_closure" {
    +     M.fun_closure:
    +         const M.fun_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cFc,
    +                        label: block_cFc_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cFf,
    +                        label: M.MkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cFi,
    +                        label: block_cFi_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFf: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm;   // CmmCondBranch
    +       cFl: // global
    +           R1 = M.MkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cFm: // global
    +           I64[Sp - 16] = cFc;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cFc; else goto cFd;   // CmmCondBranch
    +       cFd: // global
    +           call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFc: // global
    +           // slowCall
    +           I64[Sp] = cFi;   // CmmStore
    +           _tEq::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _tEq::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFi: // global
    +           // slow_call for _B1::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cFq; else goto cFp;   // CmmCondBranch
    +       cFq: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFp: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.MkT_closure" {
    +     M.MkT_closure:
    +         const M.MkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_con_entry() { //  []
    +         { info_tbls: [(cFw,
    +                        label: M.MkT_con_info
    +                        rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFw: // global
    +           R1 = R1 + 1;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + }]
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.hs
    =====================================
    @@ -0,0 +1,11 @@
    +{-# LANGUAGE BangPatterns, UnboxedTuples #-}
    +module InferTags004 where
    +
    +x :: Int
    +x = x
    +
    +f :: a -> (# Int, a #)
    +-- Adapted from a TODO in InferTags.
    +-- f's tag signature should indicate that the second component
    +-- of its result is properly tagged: TagTuple[TagDunno,TagProper]
    +f g = case g of !g' -> (# x, g' #)
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.stderr
    =====================================
    @@ -0,0 +1,13 @@
    +
    +==================== CodeGenAnal STG: ====================
    +Rec {
    +(InferTags004.x, ) = {} \u [] InferTags004.x;
    +end Rec }
    +
    +(InferTags004.f, ) =
    +    {} \r [(g, )]
    +        case g of (g', ) {
    +        __DEFAULT -> (#,#) [InferTags004.x g'];
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/th/T24111.hs
    =====================================
    @@ -0,0 +1,12 @@
    +{-# LANGUAGE Haskell2010, PatternSynonyms, TemplateHaskell, ViewPatterns #-}
    +
    +import Language.Haskell.TH (runQ)
    +import Language.Haskell.TH.Ppr (pprint)
    +
    +main = do
    +  runQ [d|pattern (:+) :: Int -> Int -> (Int, Int);
    +          pattern x :+ y = (x, y)|] >>= putStrLn . pprint
    +  runQ [d|pattern A :: Int -> String;
    +          pattern A n <- (read -> n) where {
    +            A 0 = "hi";
    +            A 1 = "bye"}|] >>= putStrLn . pprint
    
    
    =====================================
    testsuite/tests/th/T24111.stdout
    =====================================
    @@ -0,0 +1,7 @@
    +pattern (:+_0) :: GHC.Types.Int ->
    +                  GHC.Types.Int -> (GHC.Types.Int, GHC.Types.Int)
    +pattern x_1 :+_0 y_2 = (x_1, y_2)
    +pattern A_0 :: GHC.Types.Int -> GHC.Base.String
    +pattern A_0 n_1 <- (Text.Read.read -> n_1) where
    +                       A_0 0 = "hi"
    +                       A_0 1 = "bye"
    
    
    =====================================
    testsuite/tests/th/all.T
    =====================================
    @@ -597,3 +597,4 @@ test('T23962', normal, compile_and_run, [''])
     test('T23968', normal, compile_and_run, [''])
     test('T23971', normal, compile_and_run, [''])
     test('T23986', normal, compile_and_run, [''])
    +test('T24111', normal, compile_and_run, [''])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c80ed4aae6ea2861b7a4eacb242ce103a0ea203...9690fdab0f8572af03de952e2656ecb45b74faed
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c80ed4aae6ea2861b7a4eacb242ce103a0ea203...9690fdab0f8572af03de952e2656ecb45b74faed
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 18:01:51 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Sat, 28 Oct 2023 14:01:51 -0400
    Subject: [Git][ghc/ghc][wip/T24124] CorePrep: Treat seq# and dataToTag# as
     strict functions (#24124)
    Message-ID: <653d4c8fd98af_1f7b0dd480e3bc95259e@gitlab.mail>
    
    
    
    Sebastian Graf pushed to branch wip/T24124 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    c500dcf8 by Sebastian Graf at 2023-10-28T20:00:16+02:00
    CorePrep: Treat seq# and dataToTag# as strict functions (#24124)
    
    See the new `Note [seq# magic]`.
    I also implemented a new `Note [Flatten case-bind]`.
    
    Fixes #24124.
    
    - - - - -
    
    
    3 changed files:
    
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - testsuite/tests/simplStg/should_compile/T15226b.stderr
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2028,6 +2028,9 @@ is:
          case e of 
       by GHC.Core.Opt.ConstantFold.caseRules; see Note [caseRules for dataToTag]
     
    +* Similar to Note [seq# magic], we case-bind the arg of dataToTag# in
    +  GHC.CoreToStg.Prep.
    +
     See #15696 for a long saga.
     -}
     
    @@ -2103,6 +2106,18 @@ Implementing seq#.  The compiler has magic for SeqOp in
     
     - GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq#  s)
     
    +- GHC.CoreToStg.Prep: Case-bind the arg of seq#, e.g.,
    +
    +    case seq# (f 13) s of (# r, s' #) -> ...
    +    ==>
    +    case f 13 of sat of __DEFAULT ->
    +    case seq# sat s of (# r, s' #) -> ...,
    +
    +  encoding its call-by-value nature (as implemented in StgToCmm below).
    +  Note that strictness analysis and the Simplifier will never see this case
    +  binding, so #5129 as above is not an issue. Plus, CorePrep never case-binds an
    +  argument variable anyway.
    +
     - GHC.StgToCmm.Expr.cgExpr, and cgCase: special case for seq#
     
     - Simplify.addEvals records evaluated-ness for the result; see
    
    
    =====================================
    compiler/GHC/CoreToStg/Prep.hs
    =====================================
    @@ -70,6 +70,7 @@ import GHC.Types.Unique.Supply
     
     import Data.List        ( unfoldr )
     import Control.Monad
    +import GHC.Builtin.PrimOps
     
     {-
     Note [CorePrep Overview]
    @@ -850,7 +851,12 @@ cpeRhsE env (Case scrut bndr ty alts)
                    where err = mkImpossibleExpr ty "cpeRhsE: missing case alternative"
            ; alts'' <- mapM (sat_alt env') alts'
     
    -       ; return (floats, Case scrut' bndr2 ty alts'') }
    +       ; case alts'' of
    +           [Alt DEFAULT _ rhs] -- See Note [Flatten case-binds]
    +             | float <- mkNonRecFloat env evalDmd True bndr2 scrut'
    +                 -- True: is_unlifted, so that we don't float to top-level
    +             -> return (snocFloat floats float, rhs)
    +           _ -> return (floats, Case scrut' bndr2 ty alts'') }
       where
         sat_alt env (Alt con bs rhs)
            = do { (env2, bs') <- cpCloneBndrs env bs
    @@ -1089,16 +1095,24 @@ cpeApp top_env expr
                ; mb_saturate hd app floats unsat_ticks depth }
             where
               depth = val_args args
    -          stricts = case idDmdSig v of
    -                            DmdSig (DmdType _ demands)
    -                              | listLengthCmp demands depth /= GT -> demands
    -                                    -- length demands <= depth
    -                              | otherwise                         -> []
    -                -- If depth < length demands, then we have too few args to
    -                -- satisfy strictness  info so we have to  ignore all the
    -                -- strictness info, e.g. + (error "urk")
    -                -- Here, we can't evaluate the arg strictly, because this
    -                -- partial application might be seq'd
    +          stricts
    +            | PrimOpId op _ <- idDetails v
    +            , Just demands <- case op of
    +                SeqOp       -> Just [evalDmd,topDmd] -- See Note [seq# magic]
    +                DataToTagOp -> Just [evalDmd]        -- See Note [dataToTag# magic]
    +                _           -> Nothing
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = pprTrace "here" (ppr op $$ ppr args) demands
    +
    +            | DmdSig (DmdType _ demands) <- idDmdSig v
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = demands
    +            | otherwise
    +            = [] -- If depth < length demands, then we have too few args to
    +                 -- satisfy strictness  info so we have to  ignore all the
    +                 -- strictness info, e.g. + (error "urk")
    +                 -- Here, we can't evaluate the arg strictly, because this
    +                 -- partial application might be seq'd
     
             -- We inlined into something that's not a var and has no args.
             -- Bounce it back up to cpeRhsE.
    @@ -1719,12 +1733,13 @@ During ANFisation, we will `mkNonRecFloat` for `e`, binding it to a
     fresh binder `sat`.
     Now there are two interesting cases:
     
    - 1. When `e` is a value, we will float `sat=e` as far as possible, even to
    -    top-level. It is important that we mark `sat` as evaluated (via setting its
    -    unfolding to `evaldUnfolding`), otherwise we get a superfluous thunk to
    -    carry out the field set on T's field, because `exprIsHNF sat == False`:
    + 1. When `e=Just y` is a value, we will float `sat=Just y` as far as possible,
    +    to top-level, even. It is important that we mark `sat` as evaluated (via
    +    setting its unfolding to `evaldUnfolding`), otherwise we get a superfluous
    +    thunk to carry out the field seq on T's field, because
    +    `exprIsHNF sat == False`:
     
    -      let sat = e in
    +      let sat = Just y in
           let sat2 = case sat of x { __DEFAULT } -> T x in
             -- NONONO, want just `sat2 = T x`
           f sat2
    @@ -1763,6 +1778,25 @@ an `evaldUnfolding` if either
      1. `e` is a value, or
      2. `sat=e` is case-bound, but won't float to top-level.
     
    +Note [Flatten case-binds]
    +~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider the following program involving seq#:
    +
    +  data T a = T !a
    +  ... seq# (case x of y { __DEFAULT -> T y }) s ...
    +  ==> {ANFise, exploiting CbV-ness as in Note [seq# magic] and cpe_app}
    +  ... case (case x of y { __DEFAULT -> T y }) of sat { __DEFAULT -> seq# sat s }
    +
    +(Why didn't the Simplifier float out `case x of y`? Because `seq#` is lazy;
    +see Note [seq# magic].)
    +Note the case-of-case. This is not bad per sé, but we can easily flatten
    +this situation by calling `mkNonRecFloat` to create strict binding `y=x`:
    +
    +  ... case x of y { __DEFAULT -> let sat = T y in seq# sat s } ...
    +
    +where `T y` is simply let-bound, thus far less likely to confuse passes
    +downstream.
    +
     Note [Speculative evaluation]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Since call-by-value is much cheaper than call-by-need, we case-bind arguments
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -4,9 +4,9 @@ T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
       :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
     [GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
         {} \r [conrep conrep1]
    -        case conrep of conrep2 [Occ=Once1] {
    +        case conrep of conrep2 [Occ=Once1, Dmd=SL] {
             __DEFAULT ->
    -        case conrep1 of conrep3 [Occ=Once1] {
    +        case conrep1 of conrep3 [Occ=Once1, Dmd=SL] {
             __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
             };
             };
    @@ -21,15 +21,15 @@ T15226b.testFun1
         {} \r [x y void]
             case seq# [x GHC.Prim.void#] of {
             Solo# ipv1 [Occ=Once1] ->
    +        case y of conrep [Occ=Once1, Dmd=SL] {
    +        __DEFAULT ->
             let {
    -          sat [Occ=Once1] :: T15226b.StrictPair a b
    -          [LclId] =
    -              {ipv1, y} \u []
    -                  case y of conrep [Occ=Once1] {
    -                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    -                  };
    +          sat [Occ=Once1, Dmd=SL] :: T15226b.StrictPair a b
    +          [LclId, Unf=OtherCon []] =
    +              T15226b.MkStrictPair! [ipv1 conrep];
             } in  seq# [sat GHC.Prim.void#];
             };
    +        };
     
     T15226b.testFun
       :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c500dcf84e88e64facf81d62cba05a0250c86716
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c500dcf84e88e64facf81d62cba05a0250c86716
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 20:59:06 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sat, 28 Oct 2023 16:59:06 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/romes/egraphs-pmc-2
    Message-ID: <653d761a7f253_1f7b0dd8948a1c960147@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed new branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/egraphs-pmc-2
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 21:02:48 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sat, 28 Oct 2023 17:02:48 -0400
    Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] WIP.;
    Message-ID: <653d76f8b348c_1f7b0dd865704c96208a@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    21e38c31 by Rodrigo Mesquita at 2023-10-28T22:02:40+01:00
    WIP.;
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/HsToCore/Pmc/Solver.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver.hs
    =====================================
    @@ -849,7 +849,7 @@ addConCt nabla0 x alt tvs args = do
       mergeVarIds xid kid nabla3
     
     mergeConCt :: VarInfo -> PmAltConApp -> StateT TyState (MaybeT DsM) VarInfo
    -mergeConCt vi@(VI _ pos neg _bot _) (PACA alt tvs _args) = StateT $ \tyst -> do
    +mergeConCt vi@(VI _ pos neg _bot _) paca@(PACA alt tvs _args) = StateT $ \tyst -> do
       -- First try to refute with a negative fact
       guard (not (elemPmAltConSet alt neg))
       -- Then see if any of the other solutions (remember: each of them is an
    @@ -870,8 +870,8 @@ mergeConCt vi@(VI _ pos neg _bot _) (PACA alt tvs _args) = StateT $ \tyst -> do
           tyst' <- MaybeT (tyOracle tyst (listToBag $ map (\case (PhiTyCt pred) -> pred; _ -> error "impossible") ty_cts))
           return (vi, tyst') -- All good, and we get no new information.
         Nothing -> do
    -      -- No new information to merge, all done.
    -      return (vi, tyst)
    +      -- Add new con info
    +      return (vi{vi_pos = paca:pos}, tyst)
     
     equateTys :: [Type] -> [Type] -> [PhiCt]
     equateTys ts us =
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21e38c314c16ed82bb4460b7cf987ac64cafd998
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21e38c314c16ed82bb4460b7cf987ac64cafd998
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 21:10:36 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Sat, 28 Oct 2023 17:10:36 -0400
    Subject: [Git][ghc/ghc][wip/T24124] CorePrep: Treat seq# and dataToTag# as
     strict functions (#24124)
    Message-ID: <653d78cc511ce_1f7b0dd901e864962350@gitlab.mail>
    
    
    
    Sebastian Graf pushed to branch wip/T24124 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    3229473c by Sebastian Graf at 2023-10-28T23:10:29+02:00
    CorePrep: Treat seq# and dataToTag# as strict functions (#24124)
    
    See the new `Note [seq# magic]`.
    I also implemented a new `Note [Flatten case-bind]`.
    
    Fixes #24124.
    
    - - - - -
    
    
    3 changed files:
    
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - testsuite/tests/simplStg/should_compile/T15226b.stderr
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2028,6 +2028,9 @@ is:
          case e of 
       by GHC.Core.Opt.ConstantFold.caseRules; see Note [caseRules for dataToTag]
     
    +* Similar to Note [seq# magic], we case-bind the arg of dataToTag# in
    +  GHC.CoreToStg.Prep.
    +
     See #15696 for a long saga.
     -}
     
    @@ -2103,6 +2106,18 @@ Implementing seq#.  The compiler has magic for SeqOp in
     
     - GHC.Core.Opt.ConstantFold.seqRule: eliminate (seq#  s)
     
    +- GHC.CoreToStg.Prep: Case-bind the arg of seq#, e.g.,
    +
    +    case seq# (f 13) s of (# r, s' #) -> ...
    +    ==>
    +    case f 13 of sat of __DEFAULT ->
    +    case seq# sat s of (# r, s' #) -> ...,
    +
    +  encoding its call-by-value nature (as implemented in StgToCmm below).
    +  Note that strictness analysis and the Simplifier will never see this case
    +  binding, so #5129 as above is not an issue. Plus, CorePrep never case-binds an
    +  argument variable anyway.
    +
     - GHC.StgToCmm.Expr.cgExpr, and cgCase: special case for seq#
     
     - Simplify.addEvals records evaluated-ness for the result; see
    
    
    =====================================
    compiler/GHC/CoreToStg/Prep.hs
    =====================================
    @@ -70,6 +70,7 @@ import GHC.Types.Unique.Supply
     
     import Data.List        ( unfoldr )
     import Control.Monad
    +import GHC.Builtin.PrimOps
     
     {-
     Note [CorePrep Overview]
    @@ -850,7 +851,12 @@ cpeRhsE env (Case scrut bndr ty alts)
                    where err = mkImpossibleExpr ty "cpeRhsE: missing case alternative"
            ; alts'' <- mapM (sat_alt env') alts'
     
    -       ; return (floats, Case scrut' bndr2 ty alts'') }
    +       ; case alts'' of
    +           [Alt DEFAULT _ rhs] -- See Note [Flatten case-binds]
    +             | float <- mkNonRecFloat env evalDmd True bndr2 scrut'
    +                 -- True: is_unlifted, so that we don't float to top-level
    +             -> return (snocFloat floats float, rhs)
    +           _ -> return (floats, Case scrut' bndr2 ty alts'') }
       where
         sat_alt env (Alt con bs rhs)
            = do { (env2, bs') <- cpCloneBndrs env bs
    @@ -1089,16 +1095,24 @@ cpeApp top_env expr
                ; mb_saturate hd app floats unsat_ticks depth }
             where
               depth = val_args args
    -          stricts = case idDmdSig v of
    -                            DmdSig (DmdType _ demands)
    -                              | listLengthCmp demands depth /= GT -> demands
    -                                    -- length demands <= depth
    -                              | otherwise                         -> []
    -                -- If depth < length demands, then we have too few args to
    -                -- satisfy strictness  info so we have to  ignore all the
    -                -- strictness info, e.g. + (error "urk")
    -                -- Here, we can't evaluate the arg strictly, because this
    -                -- partial application might be seq'd
    +          stricts
    +            | PrimOpId op _ <- idDetails v
    +            , Just demands <- case op of
    +                SeqOp       -> Just [evalDmd,topDmd] -- See Note [seq# magic]
    +                DataToTagOp -> Just [evalDmd]        -- See Note [dataToTag# magic]
    +                _           -> Nothing
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = demands
    +
    +            | DmdSig (DmdType _ demands) <- idDmdSig v
    +            , listLengthCmp demands depth /= GT -- length demands <= depth
    +            = demands
    +            | otherwise
    +            = [] -- If depth < length demands, then we have too few args to
    +                 -- satisfy strictness  info so we have to  ignore all the
    +                 -- strictness info, e.g. + (error "urk")
    +                 -- Here, we can't evaluate the arg strictly, because this
    +                 -- partial application might be seq'd
     
             -- We inlined into something that's not a var and has no args.
             -- Bounce it back up to cpeRhsE.
    @@ -1719,12 +1733,13 @@ During ANFisation, we will `mkNonRecFloat` for `e`, binding it to a
     fresh binder `sat`.
     Now there are two interesting cases:
     
    - 1. When `e` is a value, we will float `sat=e` as far as possible, even to
    -    top-level. It is important that we mark `sat` as evaluated (via setting its
    -    unfolding to `evaldUnfolding`), otherwise we get a superfluous thunk to
    -    carry out the field set on T's field, because `exprIsHNF sat == False`:
    + 1. When `e=Just y` is a value, we will float `sat=Just y` as far as possible,
    +    to top-level, even. It is important that we mark `sat` as evaluated (via
    +    setting its unfolding to `evaldUnfolding`), otherwise we get a superfluous
    +    thunk to carry out the field seq on T's field, because
    +    `exprIsHNF sat == False`:
     
    -      let sat = e in
    +      let sat = Just y in
           let sat2 = case sat of x { __DEFAULT } -> T x in
             -- NONONO, want just `sat2 = T x`
           f sat2
    @@ -1763,6 +1778,25 @@ an `evaldUnfolding` if either
      1. `e` is a value, or
      2. `sat=e` is case-bound, but won't float to top-level.
     
    +Note [Flatten case-binds]
    +~~~~~~~~~~~~~~~~~~~~~~~~~
    +Consider the following program involving seq#:
    +
    +  data T a = T !a
    +  ... seq# (case x of y { __DEFAULT -> T y }) s ...
    +  ==> {ANFise, exploiting CbV-ness as in Note [seq# magic] and cpe_app}
    +  ... case (case x of y { __DEFAULT -> T y }) of sat { __DEFAULT -> seq# sat s }
    +
    +(Why didn't the Simplifier float out `case x of y`? Because `seq#` is lazy;
    +see Note [seq# magic].)
    +Note the case-of-case. This is not bad per sé, but we can easily flatten
    +this situation by calling `mkNonRecFloat` to create strict binding `y=x`:
    +
    +  ... case x of y { __DEFAULT -> let sat = T y in seq# sat s } ...
    +
    +where `T y` is simply let-bound, thus far less likely to confuse passes
    +downstream.
    +
     Note [Speculative evaluation]
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Since call-by-value is much cheaper than call-by-need, we case-bind arguments
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -4,9 +4,9 @@ T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
       :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
     [GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
         {} \r [conrep conrep1]
    -        case conrep of conrep2 [Occ=Once1] {
    +        case conrep of conrep2 [Occ=Once1, Dmd=SL] {
             __DEFAULT ->
    -        case conrep1 of conrep3 [Occ=Once1] {
    +        case conrep1 of conrep3 [Occ=Once1, Dmd=SL] {
             __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
             };
             };
    @@ -21,15 +21,15 @@ T15226b.testFun1
         {} \r [x y void]
             case seq# [x GHC.Prim.void#] of {
             Solo# ipv1 [Occ=Once1] ->
    +        case y of conrep [Occ=Once1, Dmd=SL] {
    +        __DEFAULT ->
             let {
    -          sat [Occ=Once1] :: T15226b.StrictPair a b
    -          [LclId] =
    -              {ipv1, y} \u []
    -                  case y of conrep [Occ=Once1] {
    -                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    -                  };
    +          sat [Occ=Once1, Dmd=SL] :: T15226b.StrictPair a b
    +          [LclId, Unf=OtherCon []] =
    +              T15226b.MkStrictPair! [ipv1 conrep];
             } in  seq# [sat GHC.Prim.void#];
             };
    +        };
     
     T15226b.testFun
       :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3229473c482e8348c69cd0b241611408d8ae5849
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3229473c482e8348c69cd0b241611408d8ae5849
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 21:12:17 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sat, 28 Oct 2023 17:12:17 -0400
    Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] whitsepac
    Message-ID: <653d79316e45b_1f7b0dd901e864962683@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9a5a6b99 by Rodrigo Mesquita at 2023-10-28T22:12:08+01:00
    whitsepac
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/HsToCore/Pmc/Solver.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver.hs
    =====================================
    @@ -731,7 +731,7 @@ addNotBotCt nabla0 at MkNabla{ nabla_tm_st = ts0 } x = do
     
     mergeBots :: Type
               -- ^ The type of the pattern whose 'BotInfo's are being merged
    -          -> BotInfo 
    +          -> BotInfo
               -> BotInfo
               -> MaybeT DsM BotInfo
     -- There already is x ~ ⊥. Nothing left to do
    @@ -743,7 +743,7 @@ mergeBots t IsBot MaybeBot
       | definitelyUnliftedType t
       -- Case (3) in Note [Strict fields and variables of unlifted type]
       -- (unlifted vars can never be ⊥)
    -  = mzero 
    +  = mzero
       | otherwise
       = pure IsBot
     -- There was x ~ ⊥. Contradiction!
    @@ -837,6 +837,12 @@ addConCt nabla0 x alt tvs args = do
           pure (nabla3 & nabla_egr._class kid._data .~ Just k_vi)
     
           -- If the merging y and N y thing works, we won't need this.
    +      -- (UPDT: It didn't work (looped, i Think. Try uncommenting that line above).
    +      -- That means we're not currently moving the strictness information from the NT pattern to the underlying variable.
    +      -- We need to.)
    +      -- Also, if we do that manually here, that means we won't add strictness
    +      -- annotations to underlying NT representatives if merging is done by
    +      -- congruence instead of by manually calling 'addConCt'
           -- case bot of
             -- MaybeBot -> pure (nabla_with MaybeBot)
             -- IsBot    -> addBotCt (nabla_with IsBot) y
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9a5a6b9907a1dfa3c7d36cd8d4c513159ea3c2cc
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9a5a6b9907a1dfa3c7d36cd8d4c513159ea3c2cc
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sat Oct 28 21:13:00 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sat, 28 Oct 2023 17:13:00 -0400
    Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] Ww
    Message-ID: <653d795c60679_1f7b0dd928aecc963226@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    a9f1335e by Rodrigo Mesquita at 2023-10-28T22:12:54+01:00
    Ww
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/HsToCore/Pmc/Solver.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver.hs
    =====================================
    @@ -828,7 +828,7 @@ addConCt nabla0 x alt tvs args = do
     
       nabla3 <- case (alt, args) of
         (PmAltConLike (RealDataCon dc), [y]) | isNewDataCon dc -> do
    -      (yid, nabla3) <- representId y nabla2
    +      (_yid, nabla3) <- representId y nabla2
     
           -- A newtype con and the underlying var are in the same e-class
           -- nabla4 <- mergeVarIds xid yid nabla3
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9f1335eb73340eb8b69544ee04c6763c8d8708a
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9f1335eb73340eb8b69544ee04c6763c8d8708a
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 29 10:33:43 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sun, 29 Oct 2023 06:33:43 -0400
    Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] Better Outputable instance
    Message-ID: <653e350762d21_1f7b0deb0df41c97382@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    ecccae24 by Rodrigo Mesquita at 2023-10-29T10:33:37+00:00
    Better Outputable instance
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/HsToCore/Pmc/Solver/Types.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver/Types.hs
    =====================================
    @@ -1,4 +1,5 @@
     {-# LANGUAGE ApplicativeDo       #-}
    +{-# LANGUAGE FlexibleInstances   #-}
     {-# LANGUAGE ScopedTypeVariables #-}
     {-# LANGUAGE ViewPatterns        #-}
     {-# LANGUAGE MultiWayIf          #-}
    @@ -79,6 +80,7 @@ import GHC.Real (Ratio(..))
     import qualified Data.Semigroup as Semi
     
     import GHC.Core.Equality
    +import Data.Functor.Const
     import Data.Functor.Compose
     import Data.Equality.Graph (EGraph, ClassId)
     import Data.Equality.Graph.Lens
    @@ -240,11 +242,15 @@ instance Outputable BotInfo where
     
     -- | Not user-facing.
     instance Outputable TmState where
    -  -- TODO: Proper outputable instance for e-graphs?
    -  ppr (TmSt state _dirty) = text (show state) -- $$ ppr dirty
    --- ROMES:TODO: Don't leave this here, it's just for debug
    --- instance Outputable IntSet where
    ---   ppr = text . show
    +  ppr (TmSt state _dirty) =
    +    -- $$ text (show dirty)
    +    vcat $ getConst $ _iclasses (\(i,cl) -> Const [ppr i <> text ":" <+> ppr cl]) state
    +
    +instance Outputable (EG.EClass (Maybe VarInfo) CoreExprF) where
    +  ppr cl = ppr (cl^._nodes) $$ ppr (cl^._data)
    +
    +instance Outputable (EG.ENode CoreExprF) where
    +  ppr (EG.Node n) = text (show n)
     
     -- | Not user-facing.
     instance Outputable VarInfo where
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ecccae248111160477266bed963d68f335b31f83
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ecccae248111160477266bed963d68f335b31f83
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 29 11:12:49 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sun, 29 Oct 2023 07:12:49 -0400
    Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] mergeNotConCt can't use
     implications only now...?
    Message-ID: <653e3e314c35_1f7b0debd2fa509760a1@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    ca137708 by Rodrigo Mesquita at 2023-10-29T11:12:43+00:00
    mergeNotConCt can't use implications only now...?
    
    - - - - -
    
    
    3 changed files:
    
    - compiler/GHC/Core/Equality.hs
    - compiler/GHC/HsToCore/Pmc/Solver.hs
    - compiler/GHC/HsToCore/Pmc/Solver/Types.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Equality.hs
    =====================================
    @@ -141,6 +141,9 @@ type CoreExprF = ExprF
     type CoreAltF = AltF
     type CoreBindF = BindF
     
    +instance Outputable (EG.ENode CoreExprF) where
    +  ppr (EG.Node n) = text (show n)
    +
     -- cmpDeBruijnTickish :: DeBruijn CoreTickish -> DeBruijn CoreTickish -> Ordering
     -- cmpDeBruijnTickish (D env1 t1) (D env2 t2) = go t1 t2 where
     --     go (Breakpoint lext lid lids _) (Breakpoint rext rid rids _)
    
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver.hs
    =====================================
    @@ -779,21 +779,30 @@ addNotConCt nabla0 x nalt = do
     -- where `x'` is the representative of `x`.
     mergeNotConCt :: VarInfo -> PmAltCon -> MaybeT DsM (Maybe Id, VarInfo)
     mergeNotConCt vi@(VI x' pos neg _ rcm) nalt = do
    +  lift $ tracePm "mergeNotConCt vi nalt" (ppr vi <+> ppr nalt)
       -- 1. Bail out quickly when nalt contradicts a solution
       let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal
       guard (not (any (contradicts nalt) pos))
       -- 2. Only record the new fact when it's not already implied by one of the
       -- solutions
    -  let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint
    -  let neg'
    -        | any (implies nalt) pos = neg
    -        -- See Note [Completeness checking with required Thetas]
    -        | hasRequiredTheta nalt  = neg
    -        | otherwise              = extendPmAltConSet neg nalt
    +  --
    +  -- ROMES:TODO
    +  -- Unfortunately, I think the egraph backend makes this implication works in
    +  -- places where it previously didn't (I think), so not adding the neg info to the neg info makes checking fail.
    +  -- We need to look much closer to figure out why, but the traces help out.
    +  -- let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint
    +  -- let neg'
    +  --       | any (implies nalt) pos = neg
    +  --       -- See Note [Completeness checking with required Thetas]
    +  --       | hasRequiredTheta nalt  = neg
    +  --       | otherwise              = extendPmAltConSet neg nalt
    +  --
    +  let neg' = extendPmAltConSet neg nalt
       massert (isPmAltConMatchStrict nalt)
       let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot }
       -- 3. Make sure there's at least one other possible constructor
       mb_rcm' <- lift (markMatched nalt rcm)
    +  lift $ tracePm "mergeNotConCt vi' (no upd. rcm)" (ppr vi')
       pure $ case mb_rcm' of
         -- If nalt could be removed from a COMPLETE set, we'll get back Just and
         -- have to mark x dirty, by returning Just x'.
    @@ -874,7 +883,7 @@ mergeConCt vi@(VI _ pos neg _bot _) paca@(PACA alt tvs _args) = StateT $ \tyst -
           -- So we treat the ty vars:
           let ty_cts = equateTys (map mkTyVarTy tvs) (map mkTyVarTy other_tvs)
           tyst' <- MaybeT (tyOracle tyst (listToBag $ map (\case (PhiTyCt pred) -> pred; _ -> error "impossible") ty_cts))
    -      return (vi, tyst') -- All good, and we get no new information.
    +      return (vi, tyst') -- All good, and we get no new term information.
         Nothing -> do
           -- Add new con info
           return (vi{vi_pos = paca:pos}, tyst)
    @@ -2253,6 +2262,8 @@ instance Analysis (StateT TyState (MaybeT DsM)) (Maybe VarInfo) ExprF where
       -- Also, the Eq instance for DeBruijn Vars will ensure that two free
       -- variables with the same Id are equal and so they will be represented in
       -- the same e-class
    +  --
    +  -- It would be good if we didn't do this always... It might be a bit expensive
       makeA (FreeVarF x) = pure $ Just $ emptyVarInfo x
       makeA _ = pure $ Nothing
     
    @@ -2261,13 +2272,14 @@ instance Analysis (StateT TyState (MaybeT DsM)) (Maybe VarInfo) ExprF where
       joinA (Just a) Nothing = pure $ Just a
     
       -- Merge the 'VarInfo's from @x@ and @y@
    -  joinA (Just VI{ vi_id=_id_x
    -                , vi_pos=pos_x
    -                , vi_neg=neg_x
    -                , vi_bot=bot_x
    -                , vi_rcm=_rcm_x
    -                })
    +  joinA (Just vi_x at VI{ vi_id=_id_x
    +                     , vi_pos=pos_x
    +                     , vi_neg=neg_x
    +                     , vi_bot=bot_x
    +                     , vi_rcm=_rcm_x
    +                     })
             (Just vi_y) = do
    +    lift . lift $ tracePm "merging vi_x and vi_y" (ppr vi_x <+> ppr vi_y)
         -- If we can merge x ~ N y with y too, then we no longer need to worry
         -- about propagating the bottomness information, since it will always be
         -- right... though I'm not sure if that would be correct
    @@ -2290,6 +2302,7 @@ instance Analysis (StateT TyState (MaybeT DsM)) (Maybe VarInfo) ExprF where
                              bot_x (vi_bot vi_y)
         let vi_res3 = vi_res2{vi_bot = bot_res}
     
    +    lift . lift $ tracePm "result of merging vi_x and vi_y" (ppr vi_res3)
         return (Just vi_res3)
     
     
    
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver/Types.hs
    =====================================
    @@ -249,9 +249,6 @@ instance Outputable TmState where
     instance Outputable (EG.EClass (Maybe VarInfo) CoreExprF) where
       ppr cl = ppr (cl^._nodes) $$ ppr (cl^._data)
     
    -instance Outputable (EG.ENode CoreExprF) where
    -  ppr (EG.Node n) = text (show n)
    -
     -- | Not user-facing.
     instance Outputable VarInfo where
       ppr (VI x pos neg bot cache)
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca1377087c03c68721da7c72ca237282c500684f
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca1377087c03c68721da7c72ca237282c500684f
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 29 11:21:38 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sun, 29 Oct 2023 07:21:38 -0400
    Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] Sometimes we can omit implied
     nalts
    Message-ID: <653e4042282fb_1f7b0dec59d534976499@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    0f5470e7 by Rodrigo Mesquita at 2023-10-29T11:21:32+00:00
    Sometimes we can omit implied nalts
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/HsToCore/Pmc/Solver.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver.hs
    =====================================
    @@ -769,7 +769,7 @@ addNotConCt _     _ (PmAltConLike (RealDataCon dc))
       | isNewDataCon dc = mzero -- (3) in Note [Coverage checking Newtype matches]
     addNotConCt nabla0 x nalt = do
       (xid, nabla1) <- representId x nabla0
    -  (mb_mark_dirty, nabla2) <- trvVarInfo (`mergeNotConCt` nalt) nabla1 (xid, x)
    +  (mb_mark_dirty, nabla2) <- trvVarInfo (\v -> mergeNotConCt True v nalt) nabla1 (xid, x)
       pure $ case mb_mark_dirty of
         Just x  -> markDirty x nabla2
         Nothing -> nabla2
    @@ -777,8 +777,12 @@ addNotConCt nabla0 x nalt = do
     -- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction,
     -- otherwise return updated entry and `Just x'` if `x` should be marked dirty,
     -- where `x'` is the representative of `x`.
    -mergeNotConCt :: VarInfo -> PmAltCon -> MaybeT DsM (Maybe Id, VarInfo)
    -mergeNotConCt vi@(VI x' pos neg _ rcm) nalt = do
    +mergeNotConCt :: Bool
    +              -- ^ Whether we can omit negative alts that are implied by current info
    +              -- This will be true when called from 'addNotConCt', but false
    +              -- when called from the analysis join
    +              -> VarInfo -> PmAltCon -> MaybeT DsM (Maybe Id, VarInfo)
    +mergeNotConCt omitImpliedNalts vi@(VI x' pos neg _ rcm) nalt = do
       lift $ tracePm "mergeNotConCt vi nalt" (ppr vi <+> ppr nalt)
       -- 1. Bail out quickly when nalt contradicts a solution
       let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal
    @@ -786,18 +790,20 @@ mergeNotConCt vi@(VI x' pos neg _ rcm) nalt = do
       -- 2. Only record the new fact when it's not already implied by one of the
       -- solutions
       --
    -  -- ROMES:TODO
    -  -- Unfortunately, I think the egraph backend makes this implication works in
    -  -- places where it previously didn't (I think), so not adding the neg info to the neg info makes checking fail.
    -  -- We need to look much closer to figure out why, but the traces help out.
    -  -- let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint
    -  -- let neg'
    -  --       | any (implies nalt) pos = neg
    -  --       -- See Note [Completeness checking with required Thetas]
    -  --       | hasRequiredTheta nalt  = neg
    -  --       | otherwise              = extendPmAltConSet neg nalt
    -  --
    -  let neg' = extendPmAltConSet neg nalt
    +  -- 'mergeNotConCt' used to be called only by 'addNotConCt', at which point it
    +  -- was fine to omit negative alts that were implied by the 'VarInfo'.
    +  -- However, we now reuse this function to merge var infos in the e-graph
    +  -- analysis join operation, which requires all negative info to be merged
    +  -- regardless of the implication?
    +  -- (Or is it because we don't check, when checking uncovered alternatives,
    +  -- whether the negative info is implied by the rest?)
    +  let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint
    +  let neg'
    +        | omitImpliedNalts
    +        , any (implies nalt) pos = neg
    +        -- See Note [Completeness checking with required Thetas]
    +        | hasRequiredTheta nalt  = neg
    +        | otherwise              = extendPmAltConSet neg nalt
       massert (isPmAltConMatchStrict nalt)
       let vi' = vi{ vi_neg = neg', vi_bot = IsNotBot }
       -- 3. Make sure there's at least one other possible constructor
    @@ -2290,7 +2296,7 @@ instance Analysis (StateT TyState (MaybeT DsM)) (Maybe VarInfo) ExprF where
         vi_res1 <- foldlM mergeConCt vi_y pos_x
     
         -- Do the same for negative info
    -    let add_neg vi nalt = lift $ snd <$> mergeNotConCt vi nalt
    +    let add_neg vi nalt = lift $ snd <$> mergeNotConCt False vi nalt
         vi_res2 <- foldlM add_neg vi_res1 (pmAltConSetElems neg_x)
     
         -- We previously were not merging the bottom information, but now we do.
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f5470e70e38e59b6262f4e77425c270b5547f1c
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f5470e70e38e59b6262f4e77425c270b5547f1c
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 29 11:22:05 2023
    From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz))
    Date: Sun, 29 Oct 2023 07:22:05 -0400
    Subject: [Git][ghc/ghc][wip/az/T23459-haddock-option-a] 7 commits:
     JS/userguide: add explanation of writing jsbits
    Message-ID: <653e405dda831_1f7b0dec597d00976890@gitlab.mail>
    
    
    
    Alan Zimmerman pushed to branch wip/az/T23459-haddock-option-a at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    d60460b3 by Alan Zimmerman at 2023-10-29T11:21:53+00:00
    EPA: print doc comments as normal comments
    
    And ignore the ones allocated in haddock processing.
    
    It does not guarantee that every original haddock-like comment appears
    in the output, as it discards ones that have no legal attachment point.
    
    closes #23459
    
    - - - - -
    
    
    16 changed files:
    
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/Driver/Config/Linker.hs
    - compiler/GHC/Hs/DocString.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/Linker/Config.hs
    - compiler/GHC/Linker/Dynamic.hs
    - + compiler/GHC/Linker/External.hs
    - compiler/GHC/Linker/Static.hs
    - compiler/GHC/StgToJS/Apply.hs
    - compiler/GHC/StgToJS/Arg.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/20026163a5b3b17ec0a354c96afddda3ad7b5d01...d60460b3f6fdcfde0b48ec6e8149e15c06f9d2b9
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/20026163a5b3b17ec0a354c96afddda3ad7b5d01...d60460b3f6fdcfde0b48ec6e8149e15c06f9d2b9
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 29 21:38:15 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Sun, 29 Oct 2023 17:38:15 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/T24134
    Message-ID: <653ed0c78267_1f7b0dfa39401898957@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed new branch wip/T24134 at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24134
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 29 21:43:14 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sun, 29 Oct 2023 17:43:14 -0400
    Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] Fixes + debugging
    Message-ID: <653ed1f210fe7_1f7b0dfa5e946c9914e1@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    4b9d8860 by Rodrigo Mesquita at 2023-10-29T21:43:01+00:00
    Fixes + debugging
    
    - - - - -
    
    
    2 changed files:
    
    - compiler/GHC/HsToCore/Pmc/Solver.hs
    - compiler/GHC/HsToCore/Pmc/Solver/Types.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver.hs
    =====================================
    @@ -617,8 +617,10 @@ addPhiCts :: Nabla -> PhiCts -> DsM (Maybe Nabla)
     -- See Note [TmState invariants].
     addPhiCts nabla cts = runMaybeT $ do
       let (ty_cts, tm_cts) = partitionPhiCts cts
    -  nabla' <- addTyCts nabla (listToBag ty_cts)
    +  nabla'  <- addTyCts nabla (listToBag ty_cts)
       nabla'' <- foldlM addPhiTmCt nabla' (listToBag tm_cts)
    +  lift $ tracePm "addPhiCts, doing inhabitationTest" (ppr nabla'')
    +  -- ROMES:TODO: Should the ty_st be nabla' or nabla'' !?
       inhabitationTest initFuel (nabla_ty_st nabla) nabla''
     
     partitionPhiCts :: PhiCts -> ([PredType], [PhiCt])
    @@ -769,7 +771,7 @@ addNotConCt _     _ (PmAltConLike (RealDataCon dc))
       | isNewDataCon dc = mzero -- (3) in Note [Coverage checking Newtype matches]
     addNotConCt nabla0 x nalt = do
       (xid, nabla1) <- representId x nabla0
    -  (mb_mark_dirty, nabla2) <- trvVarInfo (\v -> mergeNotConCt True v nalt) nabla1 (xid, x)
    +  (mb_mark_dirty, nabla2) <- trvVarInfo (`mergeNotConCt` nalt) nabla1 (xid, x)
       pure $ case mb_mark_dirty of
         Just x  -> markDirty x nabla2
         Nothing -> nabla2
    @@ -777,30 +779,17 @@ addNotConCt nabla0 x nalt = do
     -- Update `x`'s 'VarInfo' entry. Fail ('MaybeT') if contradiction,
     -- otherwise return updated entry and `Just x'` if `x` should be marked dirty,
     -- where `x'` is the representative of `x`.
    -mergeNotConCt :: Bool
    -              -- ^ Whether we can omit negative alts that are implied by current info
    -              -- This will be true when called from 'addNotConCt', but false
    -              -- when called from the analysis join
    -              -> VarInfo -> PmAltCon -> MaybeT DsM (Maybe Id, VarInfo)
    -mergeNotConCt omitImpliedNalts vi@(VI x' pos neg _ rcm) nalt = do
    +mergeNotConCt :: VarInfo -> PmAltCon -> MaybeT DsM (Maybe Id, VarInfo)
    +mergeNotConCt vi@(VI x' pos neg _ rcm) nalt = do
       lift $ tracePm "mergeNotConCt vi nalt" (ppr vi <+> ppr nalt)
       -- 1. Bail out quickly when nalt contradicts a solution
       let contradicts nalt sol = eqPmAltCon (paca_con sol) nalt == Equal
       guard (not (any (contradicts nalt) pos))
       -- 2. Only record the new fact when it's not already implied by one of the
       -- solutions
    -  --
    -  -- 'mergeNotConCt' used to be called only by 'addNotConCt', at which point it
    -  -- was fine to omit negative alts that were implied by the 'VarInfo'.
    -  -- However, we now reuse this function to merge var infos in the e-graph
    -  -- analysis join operation, which requires all negative info to be merged
    -  -- regardless of the implication?
    -  -- (Or is it because we don't check, when checking uncovered alternatives,
    -  -- whether the negative info is implied by the rest?)
       let implies nalt sol = eqPmAltCon (paca_con sol) nalt == Disjoint
       let neg'
    -        | omitImpliedNalts
    -        , any (implies nalt) pos = neg
    +        | any (implies nalt) pos = neg
             -- See Note [Completeness checking with required Thetas]
             | hasRequiredTheta nalt  = neg
             | otherwise              = extendPmAltConSet neg nalt
    @@ -838,7 +827,8 @@ nabla_egr f (MkNabla tyst ts at TmSt{ts_facts=egr}) = (\egr' -> MkNabla tyst ts{ts_
     addConCt :: Nabla -> Id -> PmAltCon -> [TyVar] -> [Id] -> MaybeT DsM Nabla
     addConCt nabla0 x alt tvs args = do
       (xid, nabla1) <- representId x nabla0
    -  (kid, nabla2) <- fromMaybe (xid, nabla1) <$> representPattern alt tvs args nabla1 -- VarInfo contains K data in pos info
    +  let vi_x = lookupVarInfo (nabla_tm_st nabla1) x
    +  (kid, nabla2) <- fromMaybe (xid, nabla1) <$> representPattern vi_x alt tvs args nabla1 -- VarInfo contains K data in pos info
       let k_vi = (emptyVarInfo x){vi_pos=[PACA alt tvs args]}
     
       nabla3 <- case (alt, args) of
    @@ -1409,12 +1399,12 @@ traverseAll f ts at TmSt{ts_facts = env} = do
     inhabitationTest :: Int -> TyState -> Nabla -> MaybeT DsM Nabla
     inhabitationTest 0     _         nabla             = pure nabla
     inhabitationTest fuel  old_ty_st nabla at MkNabla{ nabla_tm_st = ts } = {-# SCC "inhabitationTest" #-} do
    -  -- lift $ tracePm "inhabitation test" $ vcat
    -  --   [ ppr fuel
    -  --   , ppr old_ty_st
    -  --   , ppr nabla
    -  --   , text "tyStateRefined:" <+> ppr (tyStateRefined old_ty_st (nabla_ty_st nabla))
    -  --   ]
    +  lift $ tracePm "inhabitation test" $ vcat
    +    [ ppr fuel
    +    , ppr old_ty_st
    +    , ppr nabla
    +    , text "tyStateRefined:" <+> ppr (tyStateRefined old_ty_st (nabla_ty_st nabla))
    +    ]
       -- When type state didn't change, we only need to traverse dirty VarInfos
       ts' <- if tyStateRefined old_ty_st (nabla_ty_st nabla)
                 then traverseAll   test_one ts
    @@ -1423,14 +1413,16 @@ inhabitationTest fuel  old_ty_st nabla at MkNabla{ nabla_tm_st = ts } = {-# SCC "in
       where
         nabla_not_dirty = nabla{ nabla_tm_st = ts{ts_dirty=IS.empty} }
         test_one :: VarInfo -> MaybeT DsM VarInfo
    -    test_one vi =
    +    test_one vi = do
           lift (varNeedsTesting old_ty_st nabla vi) >>= \case
             True -> do
    -          -- lift $ tracePm "test_one" (ppr vi)
    +          lift $ tracePm "test_one" (ppr vi)
               -- No solution yet and needs testing
               -- We have to test with a Nabla where all dirty bits are cleared
               instantiate (fuel-1) nabla_not_dirty vi
    -        _ -> pure vi
    +        _ -> do
    +          lift $ tracePm "test_one needs no testing" (ppr vi)
    +          pure vi
     
     -- | Checks whether the given 'VarInfo' needs to be tested for inhabitants.
     -- Returns `False` when we can skip the inhabitation test, presuming it would
    @@ -1439,7 +1431,7 @@ varNeedsTesting :: TyState -> Nabla -> VarInfo -> DsM Bool
     varNeedsTesting old_ty_st n at MkNabla{nabla_ty_st=new_ty_st,nabla_tm_st=tm_st} vi
       = do
         Just (xid, _) <- runMaybeT $ representId (vi_id vi) n
    -    if | IS.member xid (ts_dirty tm_st) -> pure True
    +    if | IS.member xid (IS.map (`EG.find` ts_facts tm_st) $ ts_dirty tm_st) -> pure True
            | notNull (vi_pos vi)            -> pure False
            -- Same type state => still inhabited
            | not (tyStateRefined old_ty_st new_ty_st) -> pure False
    @@ -2199,7 +2191,12 @@ the -XEmptyCase case in 'reportWarnings' by looking for 'ReportEmptyCase'.
     ------------------------------------------------
     -- * E-graphs for pattern match checking
     
    -representPattern :: PmAltCon -> [TyVar] -> [Id] -> Nabla -> MaybeT DsM (Maybe (ClassId, Nabla))
    +representPattern :: VarInfo
    +                 -- ^ Var info of e-class in which this pattern is going to be represented...
    +                 -- The things we are doing with this should rather be done as
    +                 -- an e-graph analysis modify to "downwards" merge in the e-graph the sub-nodes
    +                 -- A bit weird that the e-graph doesn't do this, but it seems like it doesn't... (see egraphs zulip discussion)
    +                 -> PmAltCon -> [TyVar] -> [Id] -> Nabla -> MaybeT DsM (Maybe (ClassId, Nabla))
     -- We don't need to do anything in the case of PmAltLit.
     -- The Constructor information is recorded in the positive info e-class
     -- it is represented in, so when we merge we take care of handling this
    @@ -2208,10 +2205,20 @@ representPattern :: PmAltCon -> [TyVar] -> [Id] -> Nabla -> MaybeT DsM (Maybe (C
     -- Wait, is it even safe to edit the e-class? Won't that *NOT* trigger the merging??
     -- Here I suppose we're creating the e-class. So we can add information at will. When we eventually merge this class with another one, we can do things.
     -- But we could definitely check whether the information we're adding isn't colliding with the existing one.
    -representPattern (PmAltLit _) _ _ _ = return Nothing
    +representPattern _ (PmAltLit _) _ _ _ = return Nothing
                      -- We might need represent patterns alongside expressions -- then we can use the "real" equality instances for the patterns (e.g. eqPmLit)
    -representPattern (PmAltConLike conLike) tvs args nab00 = do
    -  (args', MkNabla tyst0 ts at TmSt{ts_facts=egr0}) <- representIds args nab00
    +representPattern (VI _ pos _ _ _) alt@(PmAltConLike conLike) tvs args nab00 = do
    +  (args', nab01) <- representIds args nab00
    +
    +  -- rOMES: It is very akward that this is being done here... perhaps it would be best as a modify method in the analysis
    +  -- it certainly won't work for things we learn by congruence...
    +  MkNabla tyst0 ts at TmSt{ts_facts=egr0} <-
    +    case find ((== Equal) . eqPmAltCon alt . paca_con) pos of
    +      Just (PACA _con _other_tvs other_args) -> do
    +        let add_var_ct nabla (a, b) = addVarCt nabla a b
    +        foldlM add_var_ct nab01 $ zipEqual "addConCt" args other_args
    +      Nothing -> pure nab01
    +
       ((cid, egr1), tyst1) <- (`runStateT` tyst0) $ EGM.runEGraphMT egr0 $ do
         -- We must represent the constructor application in the e-graph to make
         -- sure the children are recursively merged against other children of
    @@ -2296,7 +2303,7 @@ instance Analysis (StateT TyState (MaybeT DsM)) (Maybe VarInfo) ExprF where
         vi_res1 <- foldlM mergeConCt vi_y pos_x
     
         -- Do the same for negative info
    -    let add_neg vi nalt = lift $ snd <$> mergeNotConCt False vi nalt
    +    let add_neg vi nalt = lift $ snd <$> mergeNotConCt vi nalt
         vi_res2 <- foldlM add_neg vi_res1 (pmAltConSetElems neg_x)
     
         -- We previously were not merging the bottom information, but now we do.
    
    
    =====================================
    compiler/GHC/HsToCore/Pmc/Solver/Types.hs
    =====================================
    @@ -88,7 +88,7 @@ import qualified Data.Equality.Graph.Nodes as EGN
     import qualified Data.Equality.Graph as EG
     import qualified Data.Equality.Graph.Internal as EGI
     import Data.IntSet (IntSet)
    -import qualified Data.IntSet as IS (empty)
    +import qualified Data.IntSet as IS (empty, toList)
     import Data.Bifunctor (second)
     
     -- import GHC.Driver.Ppr
    @@ -242,9 +242,10 @@ instance Outputable BotInfo where
     
     -- | Not user-facing.
     instance Outputable TmState where
    -  ppr (TmSt state _dirty) =
    -    -- $$ text (show dirty)
    -    vcat $ getConst $ _iclasses (\(i,cl) -> Const [ppr i <> text ":" <+> ppr cl]) state
    +  ppr (TmSt state dirty) =
    +    (vcat $ getConst $ _iclasses (\(i,cl) -> Const [ppr i <> text ":" <+> ppr cl]) state)
    +      $$ ppr (IS.toList dirty)
    +
     
     instance Outputable (EG.EClass (Maybe VarInfo) CoreExprF) where
       ppr cl = ppr (cl^._nodes) $$ ppr (cl^._data)
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b9d8860b615a8f26399c4a01284b94257094beb
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b9d8860b615a8f26399c4a01284b94257094beb
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Sun Oct 29 22:02:22 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Sun, 29 Oct 2023 18:02:22 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] More improvements
    Message-ID: <653ed66e3dc5c_1f7b0dfad85ea0995629@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    007ec0b8 by Simon Peyton Jones at 2023-10-29T22:01:35+00:00
    More improvements
    
    Rename et_tot to et_wc_tot (for "worst case")
    
    Fix size bug in etCaseOf
    
    - - - - -
    
    
    5 changed files:
    
    - compiler/GHC/Core.hs
    - compiler/GHC/Core/Ppr.hs
    - compiler/GHC/Core/Seq.hs
    - compiler/GHC/Core/Subst.hs
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core.hs
    =====================================
    @@ -1401,10 +1401,10 @@ type Size     = Int
     type Discount = Int
     
     data ExprTree
    -  = ExprTree { et_tot   :: {-# UNPACK #-} !Size      -- ^ Size of whole tree
    -             , et_size  :: {-# UNPACK #-} !Size      -- ^ Size of the bit apart from et_cases
    -             , et_ret   :: {-# UNPACK #-} !Discount  -- ^ Discount when result is scrutinised
    -             , et_cases :: Bag CaseTree
    +  = ExprTree { et_wc_tot :: {-# UNPACK #-} !Size      -- ^ Worst-case size of whole tree
    +             , et_size   :: {-# UNPACK #-} !Size      -- ^ Size of the bit apart from et_cases
    +             , et_ret    :: {-# UNPACK #-} !Discount  -- ^ Discount when result is scrutinised
    +             , et_cases  :: Bag CaseTree
         }
     
     data CaseTree
    
    
    =====================================
    compiler/GHC/Core/Ppr.hs
    =====================================
    @@ -628,7 +628,7 @@ instance Outputable UnfoldingGuidance where
                    ppr et ]
     
     instance Outputable ExprTree where
    -  ppr (ExprTree { et_tot = tot, et_size = size, et_ret = ret, et_cases = cases })
    +  ppr (ExprTree { et_wc_tot = tot, et_size = size, et_ret = ret, et_cases = cases })
         = int tot <> char '/' <> int size <> char '/' <> int ret
            <> brackets (sep (map ppr (bagToList cases)))
     
    
    
    =====================================
    compiler/GHC/Core/Seq.hs
    =====================================
    @@ -126,7 +126,7 @@ seqGuidance (UnfIfGoodArgs bs et) = seqBndrs bs `seq` seqET et
     seqGuidance _                     = ()
     
     seqET :: ExprTree -> ()
    -seqET (ExprTree { et_tot = tot, et_size = size, et_cases = cases, et_ret = ret })
    +seqET (ExprTree { et_wc_tot = tot, et_size = size, et_cases = cases, et_ret = ret })
       = tot `seq` size `seq` ret `seq` seqBag seqCT cases
     
     seqCT :: CaseTree -> ()
    
    
    =====================================
    compiler/GHC/Core/Subst.hs
    =====================================
    @@ -544,14 +544,8 @@ substExprTree :: IdSubstEnv -> ExprTree -> ExprTree
     -- We might be substituting a big tree in place of a variable
     -- but we don't account for that in the size: I think it doesn't
     -- matter, and the ExprTree will be refreshed soon enough.
    -substExprTree id_env (ExprTree { et_tot = tot
    -                               , et_size  = size
    -                               , et_cases = cases
    -                               , et_ret   = ret_discount })
    -   = ExprTree { et_tot   = tot
    -              , et_size  = size + extra_size
    -              , et_cases = cases'
    -              , et_ret   = ret_discount }
    +substExprTree id_env et@(ExprTree { et_size = size, et_cases = cases })
    +   = et { et_size = size + extra_size , et_cases = cases' }
        where
          (extra_size, cases') = foldr subst_ct (0, emptyBag) cases
          -- The extra_size is just in case we substitute a non-variable for
    
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -278,7 +278,7 @@ calcUnfoldingGuidance opts is_top_bottoming (Tick t expr)
     calcUnfoldingGuidance opts is_top_bottoming expr
       = case exprTree opts val_bndrs body of
           Nothing -> UnfNever
    -      Just et@(ExprTree { et_tot = tot })
    +      Just et@(ExprTree { et_wc_tot = tot })
             | uncondInline expr n_val_bndrs tot
             -> UnfWhen { ug_unsat_ok  = unSaturatedOk
                        , ug_boring_ok =  boringCxtOk
    @@ -523,39 +523,30 @@ exprTree opts args expr
         et_add_alt = metAddAlt bOMB_OUT_SIZE
     
         go :: Int -> ETVars -> CoreExpr -> Maybe ExprTree
    -          -- cd is the /unused/ case depth; decreases toward zero
    +          -- rcd is the /unused/ case depth; decreases toward zero
               -- (avs,lvs): see Note [Constructing an ExprTree]
    -    go cd vs (Cast e _)      = go cd vs e
    -    go cd vs (Tick _ e)      = go cd vs e
    -    go _  _  (Type _)        = Just (exprTreeN 0)
    -    go _  _  (Coercion _)    = Just (exprTreeN 0)
    -    go _  _  (Lit lit)       = Just (exprTreeN (litSize lit))
    -    go cd vs (Case e b _ as) = go_case cd vs e b as
    -    go cd vs (Let bind body) = go_let cd vs bind body
    -    go cd vs (Lam b e)       = go_lam cd vs b e
    -    go cd vs e@(App {})      = go_app cd vs e
    -    go _  vs (Var f)         = Just (callTree opts vs f [] 0)
    -                               -- Use callTree to ensure we get constructor
    -                               -- discounts even on nullary constructors
    -    -------------------
    -    go_lam cd vs bndr body
    -      | isId bndr, not (isZeroBitId bndr) = go cd vs' body `et_add` Just (lamSize opts)
    -      | otherwise                         = go cd vs' body
    +    go rcd vs (Cast e _)      = go rcd vs e
    +    go rcd vs (Tick _ e)      = go rcd vs e
    +    go _   _  (Type _)        = Just (exprTreeN 0)
    +    go _   _  (Coercion _)    = Just (exprTreeN 0)
    +    go _   _  (Lit lit)       = Just (exprTreeN (litSize lit))
    +    go rcd vs (Case e b _ as) = go_case rcd vs e b as
    +    go rcd vs (Let bind body) = go_let rcd vs bind body
    +    go rcd vs (Lam b e)       = go_lam rcd vs b e
    +    go rcd vs e@(App {})      = go_app rcd vs e
    +    go _   vs (Var f)         = Just (callTree opts vs f [] 0)
    +                                -- Use callTree to ensure we get constructor
    +                                -- discounts even on nullary constructors
    +
    +    ----------- Lambdas ------------------
    +    go_lam rcd vs bndr body
    +      | isId bndr, not (isZeroBitId bndr) = go rcd vs' body `et_add` Just (lamSize opts)
    +      | otherwise                         = go rcd vs' body
           where
             vs' = vs `add_lv` bndr
     
    -    -------------------
    -    go_let cd vs (NonRec binder rhs) body
    -      = go_bind cd vs (binder, rhs)  `et_add`
    -        go cd (vs `add_lv` binder) body
    -
    -    go_let cd vs (Rec pairs) body
    -      = foldr (et_add . go_bind cd vs') (go cd vs' body) pairs
    -      where
    -        vs' = vs `add_lvs` map fst pairs
    -
    -    -------------------
    -    go_app cd vs e = lgo e [] 0
    +    ----------- Applications ------------------
    +    go_app rcd vs e = lgo e [] 0
           where
              lgo :: CoreExpr -> [CoreExpr] -> Int -> Maybe ExprTree
                  -- args:  all the value args
    @@ -565,25 +556,34 @@ exprTree opts args expr
              lgo (App fun arg) args voids
                         | isTypeArg arg    = lgo fun args voids
                         | isZeroBitArg arg = lgo fun (arg:args) (voids+1)
    -                    | otherwise        = go cd vs arg `et_add`
    +                    | otherwise        = go rcd vs arg `et_add`
                                              lgo fun (arg:args) voids
              lgo (Var fun)     args voids  = Just (callTree opts vs fun args voids)
              lgo (Tick _ expr) args voids  = lgo expr args voids
              lgo (Cast expr _) args voids  = lgo expr args voids
              lgo other         args voids  = vanillaCallSize (length args) voids
    -                                         `metAddN` go cd vs other
    +                                         `metAddN` go rcd vs other
              -- if the lhs is not an App or a Var, or an invisible thing like a
              -- Tick or Cast, then we should charge for a complete call plus the
              -- size of the lhs itself.
     
    -    -----------------------------
    -    go_bind cd vs (bndr, rhs)
    +    ----------- Let-expressions ------------------
    +    go_let rcd vs (NonRec binder rhs) body
    +      = go_bind rcd vs (binder, rhs)  `et_add`
    +        go rcd (vs `add_lv` binder) body
    +
    +    go_let rcd vs (Rec pairs) body
    +      = foldr (et_add . go_bind rcd vs') (go rcd vs' body) pairs
    +      where
    +        vs' = vs `add_lvs` map fst pairs
    +
    +    go_bind rcd vs (bndr, rhs)
           | JoinPoint join_arity <- idJoinPointHood bndr
           , (bndrs, body) <- collectNBinders join_arity rhs
                               -- Skip arguments to join point
    -      = go cd (vs `add_lvs` bndrs) body
    +      = go rcd (vs `add_lvs` bndrs) body
           | otherwise
    -      = size_up_alloc bndr `metAddN` go cd vs rhs
    +      = size_up_alloc bndr `metAddN` go rcd vs rhs
     
         -- Cost to allocate binding with given binder
         size_up_alloc bndr
    @@ -594,28 +594,34 @@ exprTree opts args expr
           | otherwise
           = 10
     
    -    -----------------------------
    +    -----------Case expressions ------------------
         go_case :: Int -> ETVars -> CoreExpr -> Id -> [CoreAlt] -> Maybe ExprTree
         -- Empty case
    -    go_case cd vs scrut _ [] = go cd vs scrut
    +    go_case rcd vs scrut _ [] = go rcd vs scrut
              -- case e of {} never returns, so take size of scrutinee
     
         -- Record a CaseOf
    -    go_case cd vs@(avs,lvs) scrut b alts
    +    go_case remaining_case_depth vs@(avs,lvs) scrut b alts
           | Just v <- interestingVarScrut vs scrut
    -      = go cd vs scrut `et_add`
    -        (if   record_case cd n_alts
    +      = go remaining_case_depth vs scrut `et_add`
    +        (if   record_case
              then do { alts' <- mapM (alt_alt_tree v) alts
                      ; etCaseOf bOMB_OUT_SIZE v b alts' }
              else Just (etScrutOf v caseElimDiscount) `et_add`
                   -- When this scrutinee has structure, we expect to eliminate the case
    -              go_alts cd vs b alts)
    +              go_alts rcd1 vs b alts)
           where
    -        cd1 = cd - 1
    -        n_alts = length alts
    +        rcd1 = remaining_case_depth - 1
    +
    +        record_case :: Bool
    +        -- True  <=> record CaseOf: case is not too deep, nor too wide
    +        -- False <=> record ScrutOf
    +        record_case = (remaining_case_depth > 0) &&
    +                      (alts `lengthAtMost` max_width)
    +
             alt_alt_tree :: Id -> Alt Var -> Maybe AltTree
             alt_alt_tree v (Alt con bs rhs)
    -          = do { rhs <- go cd1 (add_alt_bndrs v val_bs) rhs
    +          = do { rhs <- go rcd1 (add_alt_bndrs v val_bs) rhs
                    ; return (AltTree con val_bs rhs) }
               where
                 val_bs = filter isId bs
    @@ -626,30 +632,23 @@ exprTree opts args expr
               | otherwise = vs
     
         -- Don't record a CaseOf
    -    go_case cd vs scrut b alts    -- alts is non-empty
    +    go_case rcd vs scrut b alts    -- alts is non-empty
           = caseSize scrut alts     `metAddN`   -- A bit odd that this is only in one branch
             (altSize * length alts) `metAddN`
                 -- IMPORTANT: charge `altSize` for each alternative, else we
                 -- find that giant case nests are treated as practically free
                 -- A good example is Foreign.C.Error.errnoToIOError
    -        go cd vs scrut `et_add` go_alts cd vs b alts
    -
    -    record_case :: Int -> Int -> Bool
    -    -- True <=> record CaseOf; False <=> record ScrutOf
    -    record_case case_depth n_alts  -- Case is not too deep, nor too wide
    -      = case_depth > 0 && n_alts <= max_width
    +        go rcd vs scrut `et_add` go_alts (rcd-1) vs b alts
     
         go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> Maybe ExprTree
         -- Add up the sizes of all RHSs
    -    go_alts cd vs b alts = foldr1 et_add_alt (map alt_expr_tree alts)
    +    go_alts rcd vs b alts = foldr1 et_add_alt (map alt_expr_tree alts)
           where
    -        cd1 = cd - 1
             alt_expr_tree :: Alt Var -> Maybe ExprTree
    -        alt_expr_tree (Alt _con bs rhs) = go cd1 (vs `add_lvs` (b:bs)) rhs
    +        alt_expr_tree (Alt _con bs rhs) = go rcd (vs `add_lvs` (b:bs)) rhs
                 -- Don't charge for bndrs, so that wrappers look cheap
                 -- (See comments about wrappers with Case)
                 -- Don't forget to add the case binder, b, to lvs.
    -            --
     
     caseSize :: CoreExpr -> [CoreAlt] -> Size
     caseSize scrut alts
    @@ -778,7 +777,7 @@ funSize :: UnfoldingOpts -> ETVars -> Id -> Int -> Int -> ExprTree
     funSize opts (avs,_) fun n_val_args voids
       | fun `hasKey` buildIdKey   = etZero  -- Wwant to inline applications of build/augment
       | fun `hasKey` augmentIdKey = etZero  -- so we give size zero to the whole call
    -  | otherwise = ExprTree { et_tot = size, et_size  = size
    +  | otherwise = ExprTree { et_wc_tot = size, et_size  = size
                              , et_cases = cases
                              , et_ret   = res_discount }
       where
    @@ -800,7 +799,7 @@ funSize opts (avs,_) fun n_val_args voids
     
     lamSize :: UnfoldingOpts -> ExprTree
     -- Does not include the size of the body, just the lambda itself
    -lamSize opts = ExprTree { et_size = 10, et_tot = 10
    +lamSize opts = ExprTree { et_size = 10, et_wc_tot = 10
                             , et_cases = emptyBag
                             , et_ret = unfoldingFunAppDiscount opts }
     
    @@ -810,7 +809,7 @@ conSize dc n_val_args
       | isUnboxedTupleDataCon dc
       = etZero     -- See Note [Unboxed tuple size and result discount]
       | otherwise  -- See Note [Constructor size and result discount]
    -  = ExprTree { et_size = size, et_tot = size
    +  = ExprTree { et_size = size, et_wc_tot = size
                  , et_cases = emptyBag, et_ret = 10 }
       where
         size | n_val_args == 0 = 0  -- Like variables
    @@ -999,70 +998,70 @@ metAddN _ Nothing = Nothing
     metAddN n (Just et) = Just (n `etAddN` et)
     
     etAddN :: Size -> ExprTree -> ExprTree
    --- Does not account for et_tot geting too big, but that doesn't
    +-- Does not account for et_wc_tot geting too big, but that doesn't
     -- matter; the extra increment is always small, and we never get
     -- a long cascade of etAddNs
    -etAddN n1 (ExprTree { et_tot = t2, et_size = n2, et_cases = c2, et_ret = ret2 })
    -  = ExprTree { et_tot = n1+t2, et_size = n1+n2, et_cases = c2, et_ret = ret2 }
    +etAddN n1 (ExprTree { et_wc_tot = t2, et_size = n2, et_cases = c2, et_ret = ret2 })
    +  = ExprTree { et_wc_tot = n1+t2, et_size = n1+n2, et_cases = c2, et_ret = ret2 }
     
     metAdd :: Size -> Maybe ExprTree -> Maybe ExprTree -> Maybe ExprTree
     -- Takes return value from the right hand argument
     metAdd _ Nothing _ = Nothing
     metAdd _ _ Nothing = Nothing
     metAdd bOMB_OUT_SIZE (Just et1) (Just et2)
    -  | ExprTree { et_tot = t1, et_size = n1, et_cases = c1, et_ret = _ret1 } <- et1
    -  , ExprTree { et_tot = t2, et_size = n2, et_cases = c2, et_ret =  ret2 } <- et2
    +  | ExprTree { et_wc_tot = t1, et_size = n1, et_cases = c1, et_ret = _ret1 } <- et1
    +  , ExprTree { et_wc_tot = t2, et_size = n2, et_cases = c2, et_ret =  ret2 } <- et2
       , let t12 = t1 + t2
       = if   t12 >= bOMB_OUT_SIZE
         then Nothing
    -    else Just (ExprTree { et_tot   = t12
    -                        , et_size  = n1 + n2
    -                        , et_cases = c1 `unionBags` c2
    -                        , et_ret   = ret2 })
    +    else Just (ExprTree { et_wc_tot = t12
    +                        , et_size   = n1 + n2
    +                        , et_cases  = c1 `unionBags` c2
    +                        , et_ret    = ret2 })
     
     metAddAlt :: Size -> Maybe ExprTree -> Maybe ExprTree -> Maybe ExprTree
     -- Adds return discounts from both args
     metAddAlt _ Nothing _ = Nothing
     metAddAlt _ _ Nothing = Nothing
     metAddAlt bOMB_OUT_SIZE (Just et1) (Just et2)
    -  | ExprTree { et_tot = t1, et_size = n1, et_cases = c1, et_ret = ret1 } <- et1
    -  , ExprTree { et_tot = t2, et_size = n2, et_cases = c2, et_ret = ret2 } <- et2
    +  | ExprTree { et_wc_tot = t1, et_size = n1, et_cases = c1, et_ret = ret1 } <- et1
    +  , ExprTree { et_wc_tot = t2, et_size = n2, et_cases = c2, et_ret = ret2 } <- et2
       , let t12 = t1 + t2
       = if   t12 >= bOMB_OUT_SIZE
         then Nothing
    -    else Just (ExprTree { et_tot   = t12
    -                        , et_size  = n1 + n2
    -                        , et_cases = c1 `unionBags` c2
    -                        , et_ret   = ret1 + ret2 })
    +    else Just (ExprTree { et_wc_tot = t12
    +                        , et_size   = n1 + n2
    +                        , et_cases  = c1 `unionBags` c2
    +                        , et_ret    = ret1 + ret2 })
     
     
     -- | The "expression tree"; an abstraction of the RHS of the function
     exprTreeN :: Size -> ExprTree
    -exprTreeN n = ExprTree { et_size = n, et_tot = n, et_cases = emptyBag, et_ret = 0 }
    +exprTreeN n = ExprTree { et_size = n, et_wc_tot = n, et_cases = emptyBag, et_ret = 0 }
     
     etZero :: ExprTree
    -etZero = ExprTree { et_tot = 0, et_size = 0, et_cases = emptyBag, et_ret = 0 }
    +etZero = ExprTree { et_wc_tot = 0, et_size = 0, et_cases = emptyBag, et_ret = 0 }
     
     etCaseOf :: Size -> Id -> Id -> [AltTree] -> Maybe ExprTree
    --- We make the case itself free, but charge for each alternative
    --- If there are no alternatives (case e of {}), we get just the size of the scrutinee
    +-- We make the case itself free (remember that in this case the scrutinee
    +-- is a variable) but charge for each alternative (included in `altTreesSize`)
     etCaseOf bOMB_OUT_SIZE scrut case_bndr alts
       | tot >= bOMB_OUT_SIZE = Nothing
    -  | otherwise            = Just (ExprTree { et_tot = tot, et_size = 0, et_ret = 0
    +  | otherwise            = Just (ExprTree { et_wc_tot = tot, et_size = 0, et_ret = 0
                                               , et_cases = unitBag case_tree })
       where
         case_tree = CaseOf scrut case_bndr alts
         tot       = altTreesSize alts
     
     altTreesSize :: [AltTree] -> Size
    --- Total aize of a [AltTree]
    +-- Total worst-case size of a [AltTree], including the per-alternative cost of altSize
     altTreesSize alts = foldl' add_alt 0 alts
       where
    -    add_alt n (AltTree _ _ (ExprTree { et_tot = tot })) = n+tot
    +    add_alt n (AltTree _ _ (ExprTree { et_wc_tot = alt_tot }))
    +       = n + alt_tot + altSize
     
     etScrutOf :: Id -> Discount -> ExprTree
    -etScrutOf v d = ExprTree { et_tot = 0, et_size = 0, et_ret = 0
    -                         , et_cases = unitBag (ScrutOf v d) }
    +etScrutOf v d = etZero { et_cases = unitBag (ScrutOf v d) }
     
     {- *********************************************************************
     *                                                                      *
    @@ -1099,7 +1098,7 @@ exprTreeWillInline :: Size -> ExprTree -> Bool
     -- (cheapExprTreeSize limit et) takes an upper bound `n` on the
     -- size of et; i.e. without discounts etc.
     -- Return True if (s <= limit), False otherwise
    -exprTreeWillInline limit (ExprTree { et_tot = tot }) = tot <= limit
    +exprTreeWillInline limit (ExprTree { et_wc_tot = tot }) = tot <= limit
     
     -------------------------
     exprTreeSize :: InlineContext -> ExprTree -> Size
    @@ -1123,9 +1122,18 @@ caseTreeSize ic (ScrutOf bndr disc)
     
     caseTreeSize ic (CaseOf scrut_var case_bndr alts)
       = case lookupBndr ic scrut_var of
    -      ArgNoInfo     -> keptCaseSize ic case_bndr alts
    -      ArgIsLam      -> keptCaseSize ic case_bndr alts
    -      ArgIsNot cons -> keptCaseSize ic case_bndr (trim_alts cons alts)
    +      ArgNoInfo     -> altsSize ic case_bndr alts + case_size
    +
    +      ArgIsNot cons -> altsSize ic case_bndr (trim_alts cons alts)
    +         -- The case-expression may not disappear, but it scrutinises
    +         -- a variable bound to something with structure; may lead to
    +         -- avoiding a thunk, or other benefits.  So we give a discount
    +         -- compared to ArgNoInfo.  How much?  Rather a guess, but simply
    +         -- not adding case_size is convenient.
    +         --
    +         -- The function 'radiance' in nofib/real/smallpt benefits a lot from this
    +
    +      ArgIsLam -> altsSize ic case_bndr alts  -- Case will disappear altogether
     
           arg_summ@(ArgIsCon con args)
              | Just at@(AltTree alt_con bndrs rhs) <- find_alt con alts
    @@ -1134,12 +1142,19 @@ caseTreeSize ic (CaseOf scrut_var case_bndr alts)
                       -- Don't forget to add a summary for the case binder!
                    ic' = ic { ic_bound = ic_bound ic `extendVarEnvList` new_summaries }
                          -- In DEFAULT case, bs is empty, so extending is a no-op
    -         -> assertPpr ((alt_con == DEFAULT) || (bndrs `equalLength` args)) (ppr arg_summ $$ ppr at) $
    +         -> assertPpr ((alt_con == DEFAULT) || (bndrs `equalLength` args))
    +                      (ppr arg_summ $$ ppr at) $
                 exprTreeSize ic' rhs - caseElimDiscount
    -              -- Take off a discount for eliminating the case expression itself
    +              -- Take off an extra discount for eliminating the case expression itself
     
              | otherwise  -- Happens for empty alternatives
    -         -> keptCaseSize ic case_bndr alts
    +         -> altsSize ic case_bndr alts
    +  where
    +    case_size = altSize * length alts
    +      -- We make the case itself free, but charge for each alternatives
    +      -- (the latter is already included in the AltTrees)
    +      -- If there are no alternatives (case e of {}), we get zero
    +
     
     find_alt :: AltCon -> [AltTree] -> Maybe AltTree
     find_alt _   []                     = Nothing
    @@ -1158,9 +1173,9 @@ trim_alts acs (alt:alts)
       | AltTree con _ _ <- alt, con `elem` acs = trim_alts acs alts
       | otherwise                              = alt : trim_alts acs alts
     
    -keptCaseSize :: InlineContext -> Id -> [AltTree] -> Size
    +altsSize :: InlineContext -> Id -> [AltTree] -> Size
     -- Size of a (retained) case expression
    -keptCaseSize ic case_bndr alts = foldr ((+) . size_alt) case_size alts
    +altsSize ic case_bndr alts = foldr ((+) . size_alt) 0 alts
       -- Just add up the  sizes of the alternatives
       -- We recurse in case we have
       --    args = [a,b], expr_tree = [CaseOf a [ X -> CaseOf b [...]
    @@ -1168,11 +1183,6 @@ keptCaseSize ic case_bndr alts = foldr ((+) . size_alt) case_size alts
       -- Then for a call with ArgInfo for `b`, but not `a`, we want to get
       -- the trimmed trees in the X and Y branches
       where
    -    case_size = altSize * length alts
    -      -- We make the case itself free, but charge for each alternatives
    -      -- (the latter is already included in the AltTrees)
    -      -- If there are no alternatives (case e of {}), we get zero
    -
         size_alt :: AltTree -> Size
         size_alt (AltTree _ bndrs rhs) = exprTreeSize ic' rhs
             -- Cost for the alternative is already in `rhs`
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/007ec0b89788333ca610f991bd7bcc250d3ad72e
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/007ec0b89788333ca610f991bd7bcc250d3ad72e
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 01:06:37 2023
    From: gitlab at gitlab.haskell.org (Rodrigo Mesquita (@alt-romes))
    Date: Sun, 29 Oct 2023 21:06:37 -0400
    Subject: [Git][ghc/ghc][wip/romes/egraphs-pmc-2] 3 commits: STAGE 1 BUILDS
     WITHOUT FAILURES.
    Message-ID: <653f019d54143_1f7b0dff4143a810084c0@gitlab.mail>
    
    
    
    Rodrigo Mesquita pushed to branch wip/romes/egraphs-pmc-2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    a8dea067 by Rodrigo Mesquita at 2023-10-29T21:59:01+00:00
    STAGE 1 BUILDS WITHOUT FAILURES.
    
    - - - - -
    646d8885 by Rodrigo Mesquita at 2023-10-29T22:45:35+00:00
    update submodl
    
    - - - - -
    1917b37f by Rodrigo Mesquita at 2023-10-30T01:06:30+00:00
    depstest
    
    - - - - -
    
    
    3 changed files:
    
    - + TODO
    - libraries/hegg
    - testsuite/tests/count-deps/CountDepsParser.stdout
    
    
    Changes:
    
    =====================================
    TODO
    =====================================
    @@ -0,0 +1,9 @@
    +The current failures might be because congruence isn't being maintained properly downwards, I think...?
    +Instead, we might do this manually for merging positive constructor info in the e-graphs analysis modify function?
    +
    +If this works, the major todos are
    +* Propagating strictness annotations to underlying newtypes (likely modify analysis)
    +* Clean up equality
    +    * How to do Ord Type?
    +* Clean up solver
    +    * Merge args of data cons when merging by congruence (likely modify analysis as well)
    
    
    =====================================
    libraries/hegg
    =====================================
    @@ -1 +1 @@
    -Subproject commit 1d849142a21977d15c0be7943f1ad4f494054663
    +Subproject commit ae48ade5696e61382f49e03726cedc2cb30d5389
    
    
    =====================================
    testsuite/tests/count-deps/CountDepsParser.stdout
    =====================================
    @@ -21,11 +21,11 @@ GHC.Core.Coercion.Axiom
     GHC.Core.Coercion.Opt
     GHC.Core.ConLike
     GHC.Core.DataCon
    +GHC.Core.Equality
     GHC.Core.FVs
     GHC.Core.FamInstEnv
     GHC.Core.InstEnv
     GHC.Core.Make
    -GHC.Core.Map.Expr
     GHC.Core.Map.Type
     GHC.Core.Multiplicity
     GHC.Core.Opt.Arity
    @@ -194,7 +194,6 @@ GHC.Types.Unique.DFM
     GHC.Types.Unique.DSet
     GHC.Types.Unique.FM
     GHC.Types.Unique.Map
    -GHC.Types.Unique.SDFM
     GHC.Types.Unique.Set
     GHC.Types.Unique.Supply
     GHC.Types.Var
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b9d8860b615a8f26399c4a01284b94257094beb...1917b37fc1df990caf61fbda0a05dddfc9775914
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b9d8860b615a8f26399c4a01284b94257094beb...1917b37fc1df990caf61fbda0a05dddfc9775914
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 10:00:22 2023
    From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering))
    Date: Mon, 30 Oct 2023 06:00:22 -0400
    Subject: [Git][ghc/ghc][wip/T24056] 9 commits: Explicitly require RLIMIT_AS
     before use in OSMem.c
    Message-ID: <653f7eb6992e7_1baa28b839fe0629d0@gitlab.mail>
    
    
    
    Matthew Pickering pushed to branch wip/T24056 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    d9b35036 by Ben Gamari at 2023-10-30T09:46:34+00:00
    gitlab-ci: Bump LLVM bootstrap jobs to Debian 12
    
    As the Debian 10 images have too old an LLVM.
    
    Addresses #24056.
    
    - - - - -
    cfd18d39 by Matthew Pickering at 2023-10-30T09:59:12+00:00
    ci: Run aarch64 llvm backend job with "LLVM backend" label
    
    This brings it into line with the x86 LLVM backend job.
    
    - - - - -
    
    
    21 changed files:
    
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/Driver/Config/Linker.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/Linker/Config.hs
    - compiler/GHC/Linker/Dynamic.hs
    - + compiler/GHC/Linker/External.hs
    - compiler/GHC/Linker/Static.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb5ac6ae60504df2a477ffe1440cca1ee33dbe70...cfd18d3958008e1de9e06c91135c35f388dc6677
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb5ac6ae60504df2a477ffe1440cca1ee33dbe70...cfd18d3958008e1de9e06c91135c35f388dc6677
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 10:41:33 2023
    From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812))
    Date: Mon, 30 Oct 2023 06:41:33 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/T24131
    Message-ID: <653f885dd1d7b_1baa28c8282d072478@gitlab.mail>
    
    
    
    Sebastian Graf pushed new branch wip/T24131 at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T24131
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 11:20:19 2023
    From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering))
    Date: Mon, 30 Oct 2023 07:20:19 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/late-cost-expr-is-work
    Message-ID: <653f9173b2d7b_1baa28da6bc589118e@gitlab.mail>
    
    
    
    Matthew Pickering pushed new branch wip/late-cost-expr-is-work at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/late-cost-expr-is-work
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 12:18:28 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 30 Oct 2023 08:18:28 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Bale out altogether on very wide
     cases
    Message-ID: <653f9f1492bc9_1baa28f2845b01043cc@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    e0cdbe65 by Simon Peyton Jones at 2023-10-30T12:18:05+00:00
    Bale out altogether on very wide cases
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -156,7 +156,7 @@ data UnfoldingOpts = UnfoldingOpts
           -- ^ Penalize depth with 1/x
     
        , exprTreeCaseWidth :: !Int
    -      -- ^ Don't make ExprTrees with a case width greater than this
    +      -- ^ Bale out entirely with a case width greater than this
     
        , exprTreeCaseDepth :: !Int
           -- ^ Don't make ExprTrees with a case depth greater than this
    @@ -198,7 +198,11 @@ defaultUnfoldingOpts = UnfoldingOpts
           -- Don't filter inlining decision reports
        , unfoldingReportPrefix = Nothing
     
    -   , exprTreeCaseWidth = 4
    +     -- Bale out at exprTreeCaseWidth
    +     -- See Note [Bale out on very wide case expressions]
    +   , exprTreeCaseWidth = 20
    +
    +     -- Don't record CaseOf beyond exprTreeCaseDepth
        , exprTreeCaseDepth = 4
        }
     
    @@ -602,23 +606,20 @@ exprTree opts args expr
     
         -- Record a CaseOf
         go_case remaining_case_depth vs@(avs,lvs) scrut b alts
    +      | alts `lengthExceeds` max_width
    +      = Nothing   -- See Note [Bale out on very wide case expressions]
    +
           | Just v <- interestingVarScrut vs scrut
           = go remaining_case_depth vs scrut `et_add`
    -        (if   record_case
    +        (if   remaining_case_depth > 0
              then do { alts' <- mapM (alt_alt_tree v) alts
                      ; etCaseOf bOMB_OUT_SIZE v b alts' }
              else Just (etScrutOf v caseElimDiscount) `et_add`
                   -- When this scrutinee has structure, we expect to eliminate the case
    -              go_alts rcd1 vs b alts)
    +              go_alts remaining_case_depth vs b alts)
           where
             rcd1 = remaining_case_depth - 1
     
    -        record_case :: Bool
    -        -- True  <=> record CaseOf: case is not too deep, nor too wide
    -        -- False <=> record ScrutOf
    -        record_case = (remaining_case_depth > 0) &&
    -                      (alts `lengthAtMost` max_width)
    -
             alt_alt_tree :: Id -> Alt Var -> Maybe AltTree
             alt_alt_tree v (Alt con bs rhs)
               = do { rhs <- go rcd1 (add_alt_bndrs v val_bs) rhs
    @@ -635,17 +636,18 @@ exprTree opts args expr
         go_case rcd vs scrut b alts    -- alts is non-empty
           = caseSize scrut alts     `metAddN`   -- A bit odd that this is only in one branch
             (altSize * length alts) `metAddN`
    -            -- IMPORTANT: charge `altSize` for each alternative, else we
    -            -- find that giant case nests are treated as practically free
    -            -- A good example is Foreign.C.Error.errnoToIOError
             go rcd vs scrut `et_add` go_alts (rcd-1) vs b alts
     
         go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> Maybe ExprTree
    -    -- Add up the sizes of all RHSs
    +    -- Add up the sizes of all RHSs.
    +    -- IMPORTANT: charge `altSize` for each alternative, else we
    +    -- find that giant case nests are treated as practically free
    +    -- A good example is Foreign.C.Error.errnoToIOError
         go_alts rcd vs b alts = foldr1 et_add_alt (map alt_expr_tree alts)
           where
             alt_expr_tree :: Alt Var -> Maybe ExprTree
    -        alt_expr_tree (Alt _con bs rhs) = go rcd (vs `add_lvs` (b:bs)) rhs
    +        alt_expr_tree (Alt _con bs rhs) = altSize `metAddN`
    +                                          go rcd (vs `add_lvs` (b:bs)) rhs
                 -- Don't charge for bndrs, so that wrappers look cheap
                 -- (See comments about wrappers with Case)
                 -- Don't forget to add the case binder, b, to lvs.
    @@ -768,7 +770,7 @@ classOpSize opts vs fn val_args voids
                -- If the class op is scrutinising a lambda bound dictionary then
                -- give it a discount, to encourage the inlining of this function
                -- The actual discount is rather arbitrarily chosen
    -  | otherwise
    +n  | otherwise
       = exprTreeN (vanillaCallSize (length val_args) voids)
     
     funSize :: UnfoldingOpts -> ETVars -> Id -> Int -> Int -> ExprTree
    @@ -830,8 +832,28 @@ caseElimDiscount :: Discount
     -- Bonus for eliminating a case
     caseElimDiscount = 10
     
    -{- Note [Constructor size and result discount]
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +{- Note [Bale out on very wide case expressions]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +With very wide case trees (say N) we get a size N*altSize, which usually
    +prevents inlining (e.g. 20*altSize = 200 currently, which is way above the
    +inlining thresold of 90-ish).  Plus, we risk getting big CaseOf trees in the
    +ExprTree.
    +
    +If we aren't going to inline it anyway, then retaining the unfolding in an
    +interface file is plain silly; T5642 (involving Generics) is a good example.
    +We had a very wide case whose branches mentioned dozens of data structures,
    +each of which had very large types.
    +
    +Of course, if we apply such a function to a data constructor, we could in
    +principle get a huge discount (because all but one branches fall away).
    +So perhaps we could use a different setting
    +* when generating an unfolding /within a module/
    +* when generating an unfoldign /for an interface file/
    +
    +Currently we aren't doing this, but we could consider it.
    +
    +Note [Constructor size and result discount]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Treat a constructors application as size 10, regardless of how many
     arguments it has; we are keen to expose them (and we charge separately
     for their args).  We can't treat them as size zero, else we find that
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0cdbe6583a189d57ba6290253ef345ecb307c44
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0cdbe6583a189d57ba6290253ef345ecb307c44
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 12:33:01 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Mon, 30 Oct 2023 08:33:01 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Stupid typo
    Message-ID: <653fa27d81243_1baa28f717e6010814@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    2000ee1a by Simon Peyton Jones at 2023-10-30T12:30:58+00:00
    Stupid typo
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -770,7 +770,7 @@ classOpSize opts vs fn val_args voids
                -- If the class op is scrutinising a lambda bound dictionary then
                -- give it a discount, to encourage the inlining of this function
                -- The actual discount is rather arbitrarily chosen
    -n  | otherwise
    +  | otherwise
       = exprTreeN (vanillaCallSize (length val_args) voids)
     
     funSize :: UnfoldingOpts -> ETVars -> Id -> Int -> Int -> ExprTree
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2000ee1a9c0758751f2dde90dbae44aa26b3beb7
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2000ee1a9c0758751f2dde90dbae44aa26b3beb7
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 14:06:07 2023
    From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index))
    Date: Mon, 30 Oct 2023 10:06:07 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/t2t-expr-no-puns
    Message-ID: <653fb84f881bb_1baa2811dbc6c41162f9@gitlab.mail>
    
    
    
    Vladislav Zavialov pushed new branch wip/int-index/t2t-expr-no-puns at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/t2t-expr-no-puns
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 14:26:48 2023
    From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index))
    Date: Mon, 30 Oct 2023 10:26:48 -0400
    Subject: [Git][ghc/ghc][wip/int-index/t2t-expr] 6 commits: js: add JStg IR,
     remove unsaturated constructor
    Message-ID: <653fbd281097e_1baa281259332012586e@gitlab.mail>
    
    
    
    Vladislav Zavialov pushed to branch wip/int-index/t2t-expr at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    bcc88161 by Vladislav Zavialov at 2023-10-30T17:21:10+03:00
    T2T in Expressions (#23738)
    
    This patch implements the T2T (term-to-type) transformation in
    expressions. Given a function with a required type argument
    	vfun :: forall a -> ...
    
    the user can now call it as
    	vfun (Maybe Int)
    
    instead of
    	vfun (type (Maybe Int))
    
    The Maybe Int argument is parsed and renamed as a term (HsExpr), but then
    undergoes a conversion to a type (HsType).
    See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs
    and Note [RequiredTypeArguments and the T2T mapping]
    
    Left as future work: checking for puns.
    
    - - - - -
    
    
    17 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/Hs/Expr.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - compiler/GHC/StgToJS/Apply.hs
    - compiler/GHC/StgToJS/Arg.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e4e3837ad3f39437368fdf1aa195534b0198b90b...bcc88161d7ebdfc42fe5173c7e8c6e88347f7054
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e4e3837ad3f39437368fdf1aa195534b0198b90b...bcc88161d7ebdfc42fe5173c7e8c6e88347f7054
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Mon Oct 30 15:47:10 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Mon, 30 Oct 2023 11:47:10 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Teach
     tag-inference about SeqOp/seq#
    Message-ID: <653fcffe3a51a_1baa2814b67a881535db@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    201a9f92 by Alan Zimmerman at 2023-10-30T11:46:31-04:00
    EPA: print doc comments as normal comments
    
    And ignore the ones allocated in haddock processing.
    
    It does not guarantee that every original haddock-like comment appears
    in the output, as it discards ones that have no legal attachment point.
    
    closes #23459
    
    - - - - -
    67c76540 by Simon Peyton Jones at 2023-10-30T11:46:31-04:00
    Fix non-termination bug in equality solver
    
    constraint left-to-right then right to left, forever.
    
    Easily fixed.
    
    - - - - -
    78060ce1 by Sebastian Graf at 2023-10-30T11:46:31-04:00
    ghc-toolchain: build with `-package-env=-` (#24131)
    
    Otherwise globally installed libraries (via `cabal install --lib`)
    break the build.
    
    Fixes #24131.
    
    - - - - -
    
    
    26 changed files:
    
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Hs/DocString.hs
    - compiler/GHC/Stg/InferTags.hs
    - compiler/GHC/Stg/InferTags/Rewrite.hs
    - compiler/GHC/Stg/InferTags/TagSig.hs
    - compiler/GHC/StgToCmm/Prim.hs
    - compiler/GHC/Tc/Solver/Equality.hs
    - libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    - m4/ghc_toolchain.m4
    - rts/linker/PEi386.c
    - + testsuite/tests/indexed-types/should_compile/T24134.hs
    - testsuite/tests/indexed-types/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/T15226b.hs
    - + testsuite/tests/simplStg/should_compile/T15226b.stderr
    - testsuite/tests/simplStg/should_compile/all.T
    - + testsuite/tests/simplStg/should_compile/inferTags003.hs
    - + testsuite/tests/simplStg/should_compile/inferTags003.stderr
    - + testsuite/tests/simplStg/should_compile/inferTags004.hs
    - + testsuite/tests/simplStg/should_compile/inferTags004.stderr
    - + testsuite/tests/th/T24111.hs
    - + testsuite/tests/th/T24111.stdout
    - testsuite/tests/th/all.T
    - utils/check-exact/ExactPrint.hs
    - utils/check-exact/Preprocess.hs
    - utils/check-exact/Utils.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Builtin/primops.txt.pp
    =====================================
    @@ -3640,7 +3640,7 @@ primop SparkOp "spark#" GenPrimOp
        with effect = ReadWriteEffect
        code_size = { primOpCodeSizeForeignCall }
     
    --- See Note [seq# magic] in GHC.Core.Op.ConstantFold
    +-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
     primop SeqOp "seq#" GenPrimOp
        a -> State# s -> (# State# s, a #)
        with
    
    
    =====================================
    compiler/GHC/Core/Opt/ConstantFold.hs
    =====================================
    @@ -2108,6 +2108,9 @@ Implementing seq#.  The compiler has magic for SeqOp in
     - Simplify.addEvals records evaluated-ness for the result; see
       Note [Adding evaluatedness info to pattern-bound variables]
       in GHC.Core.Opt.Simplify.Iteration
    +
    +- Likewise, GHC.Stg.InferTags.inferTagExpr knows that seq# returns a
    +  properly-tagged pointer inside of its unboxed-tuple result.
     -}
     
     seqRule :: RuleM CoreExpr
    
    
    =====================================
    compiler/GHC/Hs/DocString.hs
    =====================================
    @@ -21,6 +21,7 @@ module GHC.Hs.DocString
       , renderHsDocStrings
       , exactPrintHsDocString
       , pprWithDocString
    +  , printDecorator
       ) where
     
     import GHC.Prelude
    
    
    =====================================
    compiler/GHC/Stg/InferTags.hs
    =====================================
    @@ -19,6 +19,7 @@ import GHC.Types.Basic ( CbvMark (..) )
     import GHC.Types.Unique.Supply (mkSplitUniqSupply)
     import GHC.Types.RepType (dataConRuntimeRepStrictness)
     import GHC.Core (AltCon(..))
    +import GHC.Builtin.PrimOps ( PrimOp(..) )
     import Data.List (mapAccumL)
     import GHC.Utils.Outputable
     import GHC.Utils.Misc( zipWithEqual, zipEqual, notNull )
    @@ -319,14 +320,6 @@ inferTagExpr env (StgApp fun args)
              | otherwise
              = --pprTrace "inferAppUnknown" (ppr fun) $
                TagDunno
    --- TODO:
    --- If we have something like:
    ---   let x = thunk in
    ---   f g = case g of g' -> (# x, g' #)
    --- then we *do* know that g' will be properly tagged,
    --- so we should return TagTagged [TagDunno,TagProper] but currently we infer
    --- TagTagged [TagDunno,TagDunno] because of the unknown arity case in inferTagExpr.
    --- Seems not to matter much but should be changed eventually.
     
     inferTagExpr env (StgConApp con cn args tys)
       = (inferConTag env con args, StgConApp con cn args tys)
    @@ -340,9 +333,21 @@ inferTagExpr env (StgTick tick body)
         (info, body') = inferTagExpr env body
     
     inferTagExpr _ (StgOpApp op args ty)
    -  = -- Do any primops guarantee to return a properly tagged value?
    -    -- I think not.  Ditto foreign calls.
    -    (TagDunno, StgOpApp op args ty)
    +  | StgPrimOp SeqOp <- op
    +  -- Recall seq# :: a -> State# s -> (# State# s, a #)
    +  -- However the output State# token has been unarised away,
    +  -- so we now effectively have
    +  --    seq# :: a -> State# s -> (# a #)
    +  -- The key point is the result of `seq#` is guaranteed evaluated and properly
    +  -- tagged (because that result comes directly from evaluating the arg),
    +  -- and we want tag inference to reflect that knowledge (#15226).
    +  -- Hence `TagTuple [TagProper]`.
    +  -- See Note [seq# magic] in GHC.Core.Opt.ConstantFold
    +  = (TagTuple [TagProper], StgOpApp op args ty)
    +  -- Do any other primops guarantee to return a properly tagged value?
    +  -- Probably not, and that is the conservative assumption anyway.
    +  -- (And foreign calls definitely need not make promises.)
    +  | otherwise = (TagDunno, StgOpApp op args ty)
     
     inferTagExpr env (StgLet ext bind body)
       = (info, StgLet ext bind' body')
    
    
    =====================================
    compiler/GHC/Stg/InferTags/Rewrite.hs
    =====================================
    @@ -217,7 +217,7 @@ withLcl fv act = do
     When compiling bytecode we call myCoreToStg to get STG code first.
     myCoreToStg in turn calls out to stg2stg which runs the STG to STG
     passes followed by free variables analysis and the tag inference pass including
    -it's rewriting phase at the end.
    +its rewriting phase at the end.
     Running tag inference is important as it upholds Note [Strict Field Invariant].
     While code executed by GHCi doesn't take advantage of the SFI it can call into
     compiled code which does. So it must still make sure that the SFI is upheld.
    @@ -400,13 +400,11 @@ rewriteExpr :: InferStgExpr -> RM TgStgExpr
     rewriteExpr (e at StgCase {})          = rewriteCase e
     rewriteExpr (e at StgLet {})           = rewriteLet e
     rewriteExpr (e at StgLetNoEscape {})   = rewriteLetNoEscape e
    -rewriteExpr (StgTick t e)     = StgTick t <$!> rewriteExpr e
    +rewriteExpr (StgTick t e)           = StgTick t <$!> rewriteExpr e
     rewriteExpr e@(StgConApp {})        = rewriteConApp e
    -rewriteExpr e@(StgApp {})     = rewriteApp e
    -rewriteExpr (StgLit lit)           = return $! (StgLit lit)
    -rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do
    -        (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    -rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty)
    +rewriteExpr e@(StgOpApp {})         = rewriteOpApp e
    +rewriteExpr e@(StgApp {})           = rewriteApp e
    +rewriteExpr (StgLit lit)            = return $! (StgLit lit)
     
     
     rewriteCase :: InferStgExpr -> RM TgStgExpr
    @@ -488,6 +486,33 @@ rewriteApp (StgApp f args)
     rewriteApp (StgApp f args) = return $ StgApp f args
     rewriteApp _ = panic "Impossible"
     
    +{-
    +Note [Rewriting primop arguments]
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    +Given an application `op# x y`, is it worth applying `rewriteArg` to
    +`x` and `y`?  All that will do will be to set the `tagSig` for that
    +occurrence of `x` and `y` to record whether it is evaluated and
    +properly tagged. For the vast majority of primops that's a waste of
    +time: the argument is an `Int#` or something.
    +
    +But code generation for `seq#` and `dataToTag#` /does/ consult that
    +tag, to statically avoid generating an eval:
    +* `seq#`: uses `getCallMethod` on its first argument, which looks at the `tagSig`
    +* `dataToTag#`: checks `tagSig` directly in the `DataToTagOp` case of `cgExpr`.
    +
    +So for these we should call `rewriteArgs`.
    +
    +-}
    +
    +rewriteOpApp :: InferStgExpr -> RM TgStgExpr
    +rewriteOpApp (StgOpApp op args res_ty) = case op of
    +  op@(StgPrimOp primOp)
    +    | primOp == SeqOp || primOp == DataToTagOp
    +    -- see Note [Rewriting primop arguments]
    +    -> (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty
    +  _ -> pure $! StgOpApp op args res_ty
    +rewriteOpApp _ = panic "Impossible"
    +
     -- `mkSeq` x x' e generates `case x of x' -> e`
     -- We could also substitute x' for x in e but that's so rarely beneficial
     -- that we don't bother.
    
    
    =====================================
    compiler/GHC/Stg/InferTags/TagSig.hs
    =====================================
    @@ -5,7 +5,7 @@
     -- We export this type from this module instead of GHC.Stg.InferTags.Types
     -- because it's used by more than the analysis itself. For example in interface
     -- files where we record a tag signature for bindings.
    --- By putting the sig into it's own module we can avoid module loops.
    +-- By putting the sig into its own module we can avoid module loops.
     module GHC.Stg.InferTags.TagSig
     
     where
    @@ -78,4 +78,4 @@ seqTagInfo :: TagInfo -> ()
     seqTagInfo TagTagged      = ()
     seqTagInfo TagDunno       = ()
     seqTagInfo TagProper      = ()
    -seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    \ No newline at end of file
    +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis
    
    
    =====================================
    compiler/GHC/StgToCmm/Prim.hs
    =====================================
    @@ -140,7 +140,7 @@ shouldInlinePrimOp cfg op args = case emitPrimOp cfg op args of
     --
     -- In more complex cases, there is a foreign call (out of line) fallback. This
     -- might happen e.g. if there's enough static information, such as statically
    --- know arguments.
    +-- known arguments.
     emitPrimOp
       :: StgToCmmConfig
       -> PrimOp            -- ^ The primop
    
    
    =====================================
    compiler/GHC/Tc/Solver/Equality.hs
    =====================================
    @@ -1721,12 +1721,16 @@ canEqCanLHS2 ev eq_rel swapped lhs1 ps_xi1 lhs2 ps_xi2 mco
                  swap_for_size = typesSize fun_args2 > typesSize fun_args1
     
                  -- See Note [Orienting TyFamLHS/TyFamLHS]
    -             swap_for_rewriting = anyVarSet (isTouchableMetaTyVar tclvl) tvs2 &&
    +             meta_tv_lhs = anyVarSet (isTouchableMetaTyVar tclvl) tvs1
    +             meta_tv_rhs = anyVarSet (isTouchableMetaTyVar tclvl) tvs2
    +             swap_for_rewriting = meta_tv_rhs && not meta_tv_lhs
                                       -- See Note [Put touchable variables on the left]
    -                                  not (anyVarSet (isTouchableMetaTyVar tclvl) tvs1)
                                       -- This second check is just to avoid unfruitful swapping
     
    -       ; if swap_for_rewriting || swap_for_size
    +         -- It's important that we don't flip-flop (#T24134)
    +         -- So swap_for_rewriting "wins", and we only try swap_for_size
    +         -- if swap_for_rewriting doesn't care either way
    +       ; if swap_for_rewriting || (meta_tv_lhs == meta_tv_rhs && swap_for_size)
              then finish_with_swapping
              else finish_without_swapping } }
       where
    @@ -1945,7 +1949,9 @@ canEqCanLHSFinish_no_unification ev eq_rel swapped lhs rhs
                   -- If we had F a ~ G (F a), which gives an occurs check,
                   -- then swap it to G (F a) ~ F a, which does not
                   -- However `swap_for_size` above will orient it with (G (F a)) on
    -              -- the left anwyway, so the next four lines of code are redundant
    +              -- the left anwyway.  `swap_for_rewriting` "wins", but that doesn't
    +              -- matter: in the occurs check case swap_for_rewriting will be moot.
    +              -- TL;DR: the next four lines of code are redundant
                   -- I'm leaving them here in case they become relevant again
     --              | TyFamLHS {} <- lhs
     --              , Just can_rhs <- canTyFamEqLHS_maybe rhs
    
    
    =====================================
    libraries/template-haskell/Language/Haskell/TH/Ppr.hs
    =====================================
    @@ -14,7 +14,7 @@ import Language.Haskell.TH.Syntax
     import Data.Word ( Word8 )
     import Data.Char ( toLower, chr)
     import GHC.Show  ( showMultiLineString )
    -import GHC.Lexeme( startsVarSym )
    +import GHC.Lexeme( isVarSymChar )
     import Data.Ratio ( numerator, denominator )
     import Data.Foldable ( toList )
     import Prelude hiding ((<>))
    @@ -122,8 +122,8 @@ isSymOcc :: Name -> Bool
     isSymOcc n
       = case nameBase n of
           []    -> True  -- Empty name; weird
    -      (c:_) -> startsVarSym c
    -                   -- c.f. OccName.startsVarSym in GHC itself
    +      (c:_) -> isVarSymChar c
    +                   -- c.f. isVarSymChar in GHC itself
     
     pprInfixExp :: Exp -> Doc
     pprInfixExp (VarE v) = pprName' Infix v
    @@ -471,7 +471,8 @@ ppr_dec _ (PatSynD name args dir pat)
         pprNameArgs | InfixPatSyn a1 a2 <- args = ppr a1 <+> pprName' Infix name <+> ppr a2
                     | otherwise                 = pprName' Applied name <+> ppr args
         pprPatRHS   | ExplBidir cls <- dir = hang (ppr pat <+> text "where")
    -                                           nestDepth (pprName' Applied name <+> ppr cls)
    +                                              nestDepth
    +                                              (vcat $ (pprName' Applied name <+>) . ppr <$> cls)
                     | otherwise            = ppr pat
     ppr_dec _ (PatSynSigD name ty)
       = pprPatSynSig name ty
    
    
    =====================================
    m4/ghc_toolchain.m4
    =====================================
    @@ -148,6 +148,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN_BIN],[
                     -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \
                     -XNoImplicitPrelude \
                     -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
    +                -package-env=- \
                     utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain || AC_MSG_ERROR([Could not compile ghc-toolchain])
                 GHC_TOOLCHAIN_BIN="./acghc-toolchain"
                 ;;
    
    
    =====================================
    rts/linker/PEi386.c
    =====================================
    @@ -1939,29 +1939,32 @@ static size_t
     makeSymbolExtra_PEi386( ObjectCode* oc, uint64_t index STG_UNUSED, size_t s, char* symbol STG_UNUSED, SymType type )
     {
         SymbolExtra *extra;
    -
    -    if (type == SYM_TYPE_CODE) {
    -        // jmp *-14(%rip)
    -        extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    -        memcpy(extra->jumpIsland, jmp, 6);
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    -        return (size_t)&extra->jumpIsland;
    -    } else if (type == SYM_TYPE_INDIRECT_DATA) {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        void *v = *(void**) s;
    -        extra->addr = (uint64_t)v;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    -    } else {
    -        extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    -        CHECK(extra);
    -        extra->addr = (uint64_t)s;
    -        IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    -        return (size_t)&extra->addr;
    +    switch(type & ~SYM_TYPE_DUP_DISCARD) {
    +        case SYM_TYPE_CODE: {
    +            // jmp *-14(%rip)
    +            extra = m32_alloc(oc->rx_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            static uint8_t jmp[] = { 0xFF, 0x25, 0xF2, 0xFF, 0xFF, 0xFF };
    +            memcpy(extra->jumpIsland, jmp, 6);
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(code): %s -> %p\n", symbol, &extra->jumpIsland));
    +            return (size_t)&extra->jumpIsland;
    +        }
    +        case SYM_TYPE_INDIRECT_DATA: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            void *v = *(void**) s;
    +            extra->addr = (uint64_t)v;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
    +        default: {
    +            extra = m32_alloc(oc->rw_m32, sizeof(SymbolExtra), 8);
    +            CHECK(extra);
    +            extra->addr = (uint64_t)s;
    +            IF_DEBUG(linker_verbose, debugBelch("makeSymbolExtra(indirect-data): %s -> %p\n", symbol, &extra->addr));
    +            return (size_t)&extra->addr;
    +        }
         }
     }
     
    
    
    =====================================
    testsuite/tests/indexed-types/should_compile/T24134.hs
    =====================================
    @@ -0,0 +1,54 @@
    +{-# LANGUAGE GHC2021 #-}
    +{-# LANGUAGE TypeFamilies #-}
    +
    +module M where
    +import Data.Kind (Type)
    +
    +type F :: Type -> Type
    +type family F
    +
    +type Prod :: Type -> Type -> Type
    +type family Prod (a :: Type) (b :: Type) :: Type
    +
    +und :: F Int
    +und = und
    +
    +f :: a -> Prod (F Int) a -> Prod a a
    +f = f
    +
    +repMap :: Prod (F Int) (F Int) -> Prod (F Int) (F Int)
    +repMap = f und
    +
    +
    +{- This is what went wrong in GHC 9.8
    +
    +Inert: [W] Prod (F Int) a ~ Prod a a
    +Work: [W] Prod (F Int) (F Int) ~ Prof (F Int) a
    +
    +---> rewrite with inert
    +  [W] Prod (F Int) (F Int) ~ Prod a a
    +---> swap (meta-var to left)
    +  [W] Prod a a ~ Prod (F Int) (F Int)
    +
    +Kick out the inert
    +
    +Inert: [W] Prod a a ~ Prod (F Int) (F Int)
    +Work: [W] Prod (F Int) a ~ Prod a a
    +
    +--> rewrite with inert
    +    [W] Prod (F Int) a ~ Prod (F Int) (F Int)
    +--> swap (size)
    +    [W] Prod (F Int) (F Int) ~ Prod (F Int) a
    +
    +Kick out the inert
    +
    +Inert: [W] Prod (F Int) (F Int) ~ Prod (F Int) a
    +Work: [W] Prod a a ~ Prod (F Int) (F Int)
    +
    +--> rewrite with inert
    +    [W] Prod a a ~ Prod (F Int) a
    +--> swap (size)
    +    [W] Prof (F Int) a ~ Prod a a
    +
    +
    +-}
    
    
    =====================================
    testsuite/tests/indexed-types/should_compile/all.T
    =====================================
    @@ -309,3 +309,4 @@ test('T22547', normal, compile, [''])
     test('T22717', normal, makefile_test, ['T22717'])
     test('T22717_fam_orph', normal, multimod_compile, ['T22717_fam_orph', '-v0'])
     test('T23408', normal, compile, [''])
    +test('T24134', normal, compile, [''])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.hs
    =====================================
    @@ -0,0 +1,11 @@
    +module T15226b where
    +
    +import Control.Exception
    +
    +data StrictPair a b = MkStrictPair !a !b
    +
    +testFun :: a -> b -> IO (StrictPair a b)
    +testFun x y = do
    +  x' <- evaluate x
    +  evaluate (MkStrictPair x' y)
    +  -- tag inference should not insert an eval for x' in making the strict pair
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/T15226b.stderr
    =====================================
    @@ -0,0 +1,48 @@
    +
    +==================== Final STG: ====================
    +T15226b.$WMkStrictPair [InlPrag=INLINE[final] CONLIKE]
    +  :: forall a b. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataConWrapper], Arity=2, Str=, Unf=OtherCon []] =
    +    {} \r [conrep conrep1]
    +        case conrep of conrep2 [Occ=Once1] {
    +        __DEFAULT ->
    +        case conrep1 of conrep3 [Occ=Once1] {
    +        __DEFAULT -> T15226b.MkStrictPair [conrep2 conrep3];
    +        };
    +        };
    +
    +T15226b.testFun1
    +  :: forall a b.
    +     a
    +     -> b
    +     -> GHC.Prim.State# GHC.Prim.RealWorld
    +     -> (# GHC.Prim.State# GHC.Prim.RealWorld, T15226b.StrictPair a b #)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [x y void]
    +        case seq# [x GHC.Prim.void#] of {
    +        Solo# ipv1 [Occ=Once1] ->
    +        let {
    +          sat [Occ=Once1] :: T15226b.StrictPair a b
    +          [LclId] =
    +              {ipv1, y} \u []
    +                  case y of conrep [Occ=Once1] {
    +                  __DEFAULT -> T15226b.MkStrictPair [ipv1 conrep];
    +                  };
    +        } in  seq# [sat GHC.Prim.void#];
    +        };
    +
    +T15226b.testFun
    +  :: forall a b. a -> b -> GHC.Types.IO (T15226b.StrictPair a b)
    +[GblId, Arity=3, Str=, Unf=OtherCon []] =
    +    {} \r [eta eta void] T15226b.testFun1 eta eta GHC.Prim.void#;
    +
    +T15226b.MkStrictPair [InlPrag=CONLIKE]
    +  :: forall {a} {b}. a %1 -> b %1 -> T15226b.StrictPair a b
    +[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
    +    {} \r [eta eta]
    +        case eta of eta {
    +        __DEFAULT ->
    +        case eta of eta { __DEFAULT -> T15226b.MkStrictPair [eta eta]; };
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/all.T
    =====================================
    @@ -18,3 +18,8 @@ test('T22840', [extra_files(
             [ 'T22840A.hs'
             , 'T22840B.hs'
             ]), when(not(have_dynamic()),skip)], multimod_compile, ['T22840', '-dynamic-too -dtag-inference-checks'])
    +test('T15226b', normal, compile, ['-O -ddump-stg-final -dsuppress-uniques -dno-typeable-binds'])
    +test('inferTags003', [ only_ways(['optasm']),
    +                       grep_errmsg(r'(call stg\_ap\_0)', [1])
    +                     ], compile, ['-ddump-cmm -dno-typeable-binds -O'])
    +test('inferTags004', normal, compile, ['-O -ddump-stg-tags -dno-typeable-binds -dsuppress-uniques'])
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.hs
    =====================================
    @@ -0,0 +1,15 @@
    +{-# LANGUAGE MagicHash #-}
    +module M where
    +
    +import GHC.Exts
    +import GHC.IO
    +
    +data T a = MkT !Bool !a
    +
    +fun :: T a -> IO a
    +{-# OPAQUE fun #-}
    +fun (MkT _ x) = IO $ \s -> noinline seq# x s
    +-- evaluate/seq# should not produce its own eval for x
    +-- since it is properly tagged (from a strict field)
    +
    +-- uses noinline to prevent caseRules from eliding the seq# in Core
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags003.stderr
    =====================================
    @@ -0,0 +1,177 @@
    +
    +==================== Output Cmm ====================
    +[M.$WMkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cEx,
    +                        label: block_cEx_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cEA,
    +                        label: M.$WMkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cED,
    +                        label: block_cED_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEA: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cEG; else goto cEH;   // CmmCondBranch
    +       cEG: // global
    +           R1 = M.$WMkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cEH: // global
    +           I64[Sp - 16] = cEx;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEx; else goto cEy;   // CmmCondBranch
    +       cEy: // global
    +           call (I64[R1])(R1) returns to cEx, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEx: // global
    +           // slowCall
    +           I64[Sp] = cED;   // CmmStore
    +           _sEi::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _sEi::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cED: // global
    +           // slow_call for _sEh::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cEL; else goto cEK;   // CmmCondBranch
    +       cEL: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cED, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEK: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.$WMkT_closure" {
    +     M.$WMkT_closure:
    +         const M.$WMkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.fun_entry() { //  [R2]
    +         { info_tbls: [(cEV,
    +                        label: block_cEV_info
    +                        rep: StackRep []
    +                        srt: Nothing),
    +                       (cEY,
    +                        label: M.fun_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 5} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cEY: // global
    +           if ((Sp + -8) < SpLim) (likely: False) goto cEZ; else goto cF0;   // CmmCondBranch
    +       cEZ: // global
    +           R1 = M.fun_closure;   // CmmAssign
    +           call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cF0: // global
    +           I64[Sp - 8] = cEV;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           Sp = Sp - 8;   // CmmAssign
    +           if (R1 & 7 != 0) goto cEV; else goto cEW;   // CmmCondBranch
    +       cEW: // global
    +           call (I64[R1])(R1) returns to cEV, args: 8, res: 8, upd: 8;   // CmmCall
    +       cEV: // global
    +           R1 = P64[R1 + 15];   // CmmAssign
    +           Sp = Sp + 8;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.fun_closure" {
    +     M.fun_closure:
    +         const M.fun_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_entry() { //  [R3, R2]
    +         { info_tbls: [(cFc,
    +                        label: block_cFc_info
    +                        rep: StackRep [False]
    +                        srt: Nothing),
    +                       (cFf,
    +                        label: M.MkT_info
    +                        rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} }
    +                        srt: Nothing),
    +                       (cFi,
    +                        label: block_cFi_info
    +                        rep: StackRep [False]
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFf: // global
    +           if ((Sp + -16) < SpLim) (likely: False) goto cFl; else goto cFm;   // CmmCondBranch
    +       cFl: // global
    +           R1 = M.MkT_closure;   // CmmAssign
    +           call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8;   // CmmCall
    +       cFm: // global
    +           I64[Sp - 16] = cFc;   // CmmStore
    +           R1 = R2;   // CmmAssign
    +           P64[Sp - 8] = R3;   // CmmStore
    +           Sp = Sp - 16;   // CmmAssign
    +           if (R1 & 7 != 0) goto cFc; else goto cFd;   // CmmCondBranch
    +       cFd: // global
    +           call (I64[R1])(R1) returns to cFc, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFc: // global
    +           // slowCall
    +           I64[Sp] = cFi;   // CmmStore
    +           _tEq::P64 = R1;   // CmmAssign
    +           R1 = P64[Sp + 8];   // CmmAssign
    +           P64[Sp + 8] = _tEq::P64;   // CmmStore
    +           call stg_ap_0_fast(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFi: // global
    +           // slow_call for _B1::P64 with pat stg_ap_0
    +           Hp = Hp + 24;   // CmmAssign
    +           if (Hp > HpLim) (likely: False) goto cFq; else goto cFp;   // CmmCondBranch
    +       cFq: // global
    +           HpAlloc = 24;   // CmmAssign
    +           call stg_gc_unpt_r1(R1) returns to cFi, args: 8, res: 8, upd: 8;   // CmmCall
    +       cFp: // global
    +           // allocHeapClosure
    +           I64[Hp - 16] = M.MkT_con_info;   // CmmStore
    +           P64[Hp - 8] = P64[Sp + 8];   // CmmStore
    +           P64[Hp] = R1;   // CmmStore
    +           R1 = Hp - 15;   // CmmAssign
    +           Sp = Sp + 16;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + },
    + section ""data" . M.MkT_closure" {
    +     M.MkT_closure:
    +         const M.MkT_info;
    + }]
    +
    +
    +
    +==================== Output Cmm ====================
    +[M.MkT_con_entry() { //  []
    +         { info_tbls: [(cFw,
    +                        label: M.MkT_con_info
    +                        rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} }
    +                        srt: Nothing)]
    +           stack_info: arg_space: 8
    +         }
    +     {offset
    +       cFw: // global
    +           R1 = R1 + 1;   // CmmAssign
    +           call (P64[Sp])(R1) args: 8, res: 0, upd: 8;   // CmmCall
    +     }
    + }]
    +
    +
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.hs
    =====================================
    @@ -0,0 +1,11 @@
    +{-# LANGUAGE BangPatterns, UnboxedTuples #-}
    +module InferTags004 where
    +
    +x :: Int
    +x = x
    +
    +f :: a -> (# Int, a #)
    +-- Adapted from a TODO in InferTags.
    +-- f's tag signature should indicate that the second component
    +-- of its result is properly tagged: TagTuple[TagDunno,TagProper]
    +f g = case g of !g' -> (# x, g' #)
    
    
    =====================================
    testsuite/tests/simplStg/should_compile/inferTags004.stderr
    =====================================
    @@ -0,0 +1,13 @@
    +
    +==================== CodeGenAnal STG: ====================
    +Rec {
    +(InferTags004.x, ) = {} \u [] InferTags004.x;
    +end Rec }
    +
    +(InferTags004.f, ) =
    +    {} \r [(g, )]
    +        case g of (g', ) {
    +        __DEFAULT -> (#,#) [InferTags004.x g'];
    +        };
    +
    +
    
    
    =====================================
    testsuite/tests/th/T24111.hs
    =====================================
    @@ -0,0 +1,12 @@
    +{-# LANGUAGE Haskell2010, PatternSynonyms, TemplateHaskell, ViewPatterns #-}
    +
    +import Language.Haskell.TH (runQ)
    +import Language.Haskell.TH.Ppr (pprint)
    +
    +main = do
    +  runQ [d|pattern (:+) :: Int -> Int -> (Int, Int);
    +          pattern x :+ y = (x, y)|] >>= putStrLn . pprint
    +  runQ [d|pattern A :: Int -> String;
    +          pattern A n <- (read -> n) where {
    +            A 0 = "hi";
    +            A 1 = "bye"}|] >>= putStrLn . pprint
    
    
    =====================================
    testsuite/tests/th/T24111.stdout
    =====================================
    @@ -0,0 +1,7 @@
    +pattern (:+_0) :: GHC.Types.Int ->
    +                  GHC.Types.Int -> (GHC.Types.Int, GHC.Types.Int)
    +pattern x_1 :+_0 y_2 = (x_1, y_2)
    +pattern A_0 :: GHC.Types.Int -> GHC.Base.String
    +pattern A_0 n_1 <- (Text.Read.read -> n_1) where
    +                       A_0 0 = "hi"
    +                       A_0 1 = "bye"
    
    
    =====================================
    testsuite/tests/th/all.T
    =====================================
    @@ -597,3 +597,4 @@ test('T23962', normal, compile_and_run, [''])
     test('T23968', normal, compile_and_run, [''])
     test('T23971', normal, compile_and_run, [''])
     test('T23986', normal, compile_and_run, [''])
    +test('T24111', normal, compile_and_run, [''])
    
    
    =====================================
    utils/check-exact/ExactPrint.hs
    =====================================
    @@ -32,6 +32,7 @@ module ExactPrint
       ) where
     
     import GHC
    +import GHC.Base (NonEmpty(..))
     import GHC.Core.Coercion.Axiom (Role(..))
     import GHC.Data.Bag
     import qualified GHC.Data.BooleanFormula as BF
    @@ -366,7 +367,7 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do
       when (flush == NoFlushComments) $ do
         when ((getFollowingComments cs) /= []) $ do
           debugM $ "starting trailing comments:" ++ showAst (getFollowingComments cs)
    -      mapM_ printOneComment (map tokComment $ getFollowingComments cs)
    +      mapM_ printOneComment (concatMap tokComment $ getFollowingComments cs)
           debugM $ "ending trailing comments"
     
       eof <- getEofPos
    @@ -393,7 +394,7 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do
     -- ---------------------------------------------------------------------
     
     addCommentsA :: (Monad m, Monoid w) => [LEpaComment] -> EP w m ()
    -addCommentsA csNew = addComments (map tokComment csNew)
    +addCommentsA csNew = addComments (concatMap tokComment csNew)
     
     {-
     TODO: When we addComments, some may have an anchor that is no longer
    @@ -547,7 +548,7 @@ printStringAtAAC :: (Monad m, Monoid w)
       => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
     printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s
     printStringAtAAC capture (EpaDelta d cs) s = do
    -  mapM_ (printOneComment . tokComment) cs
    +  mapM_  printOneComment $ concatMap tokComment cs
       pe1 <- getPriorEndD
       p1 <- getPosP
       printStringAtLsDelta d s
    @@ -1357,7 +1358,7 @@ instance ExactPrint (HsModule GhcPs) where
       exact hsmod@(HsModule {hsmodExt = XModulePs { hsmodAnn = EpAnnNotUsed }}) = withPpr hsmod >> return hsmod
       exact (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports imports decls) = do
     
    -    mbDoc' <- markAnnotated mbDoc
    +    let mbDoc' = mbDoc
     
         (an0, mmn' , mdeprec', mexports') <-
           case mmn of
    @@ -1382,7 +1383,7 @@ instance ExactPrint (HsModule GhcPs) where
     
         am_decls' <- markTrailing (am_decls $ anns an0)
         imports' <- markTopLevelList imports
    -    decls' <- markTopLevelList decls
    +    decls' <- markTopLevelList (filter removeDocDecl decls)
     
         lo1 <- case lo0 of
             ExplicitBraces open close -> do
    @@ -1402,6 +1403,11 @@ instance ExactPrint (HsModule GhcPs) where
     
         return (HsModule (XModulePs anf lo1 mdeprec' mbDoc') mmn' mexports' imports' decls')
     
    +
    +removeDocDecl :: LHsDecl GhcPs -> Bool
    +removeDocDecl (L _ DocD{}) = False
    +removeDocDecl _ = True
    +
     -- ---------------------------------------------------------------------
     
     instance ExactPrint ModuleName where
    @@ -1533,9 +1539,27 @@ instance ExactPrint (ImportDecl GhcPs) where
     instance ExactPrint HsDocString where
       getAnnotationEntry _ = NoEntryVal
       setAnnotationAnchor a _ _ = a
    -  exact ds = do
    -    (printStringAdvance . exactPrintHsDocString) ds
    -    return ds
    +
    +  exact (MultiLineDocString decorator (x :| xs)) = do
    +    printStringAdvance ("-- " ++ printDecorator decorator)
    +    pe <- getPriorEndD
    +    debugM $ "MultiLineDocString: (pe,x)=" ++ showAst (pe,x)
    +    x' <- markAnnotated x
    +    xs' <- markAnnotated (map dedentDocChunk xs)
    +    return (MultiLineDocString decorator (x' :| xs'))
    +  exact x = do
    +    -- TODO: can this happen?
    +    debugM $ "Not exact printing:" ++ showAst x
    +    return x
    +
    +
    +instance ExactPrint HsDocStringChunk where
    +  getAnnotationEntry _ = NoEntryVal
    +  setAnnotationAnchor a _ _ = a
    +  exact chunk = do
    +    printStringAdvance ("--" ++ unpackHDSC chunk)
    +    return chunk
    +
     
     instance ExactPrint a => ExactPrint (WithHsDocIdentifiers a GhcPs) where
       getAnnotationEntry _ = NoEntryVal
    @@ -1895,11 +1919,8 @@ instance ExactPrint (DocDecl GhcPs) where
       getAnnotationEntry = const NoEntryVal
       setAnnotationAnchor a _ _ = a
     
    -  exact v = case v of
    -    (DocCommentNext ds)    -> DocCommentNext <$> exact ds
    -    (DocCommentPrev ds)    -> DocCommentPrev <$> exact ds
    -    (DocCommentNamed s ds) -> DocCommentNamed s <$> exact ds
    -    (DocGroup i ds)        -> DocGroup i <$> exact ds
    +  -- We print these as plain comments instead, do a NOP here.
    +  exact v = return v
     
     -- ---------------------------------------------------------------------
     
    @@ -3936,8 +3957,7 @@ instance ExactPrint (HsType GhcPs) where
         return (HsSpliceTy a splice')
       exact (HsDocTy an ty doc) = do
         ty' <- markAnnotated ty
    -    doc' <- markAnnotated doc
    -    return (HsDocTy an ty' doc')
    +    return (HsDocTy an ty' doc)
       exact (HsBangTy an (HsSrcBang mt up str) ty) = do
         an0 <-
           case mt of
    @@ -4246,7 +4266,6 @@ instance ExactPrint (ConDecl GhcPs) where
                         , con_mb_cxt = mcxt
                         , con_args = args
                         , con_doc = doc }) = do
    -    doc' <- mapM markAnnotated doc
         an0 <- if has_forall
           then markEpAnnL an lidl AnnForall
           else return an
    @@ -4266,11 +4285,11 @@ instance ExactPrint (ConDecl GhcPs) where
                            , con_ex_tvs = ex_tvs'
                            , con_mb_cxt = mcxt'
                            , con_args = args'
    -                       , con_doc = doc' })
    +                       , con_doc = doc })
     
         where
    -    --   -- In ppr_details: let's not print the multiplicities (they are always 1, by
    -    --   -- definition) as they do not appear in an actual declaration.
    +    -- In ppr_details: let's not print the multiplicities (they are always 1, by
    +    -- definition) as they do not appear in an actual declaration.
           exact_details (InfixCon t1 t2) = do
             t1' <- markAnnotated t1
             con' <- markAnnotated con
    @@ -4294,7 +4313,6 @@ instance ExactPrint (ConDecl GhcPs) where
                          , con_bndrs = bndrs
                          , con_mb_cxt = mcxt, con_g_args = args
                          , con_res_ty = res_ty, con_doc = doc }) = do
    -    doc' <- mapM markAnnotated doc
         cons' <- mapM markAnnotated cons
         dcol' <- markUniToken dcol
         an1 <- annotationsToComments an lidl  [AnnOpenP, AnnCloseP]
    @@ -4323,7 +4341,7 @@ instance ExactPrint (ConDecl GhcPs) where
                             , con_dcolon = dcol'
                             , con_bndrs = bndrs'
                             , con_mb_cxt = mcxt', con_g_args = args'
    -                        , con_res_ty = res_ty', con_doc = doc' })
    +                        , con_res_ty = res_ty', con_doc = doc })
     
     -- ---------------------------------------------------------------------
     
    @@ -4359,8 +4377,8 @@ instance ExactPrint (ConDeclField GhcPs) where
         names' <- markAnnotated names
         an0 <- markEpAnnL an lidl AnnDcolon
         ftype' <- markAnnotated ftype
    -    mdoc' <- mapM markAnnotated mdoc
    -    return (ConDeclField an0 names' ftype' mdoc')
    +    -- mdoc' <- mapM markAnnotated mdoc
    +    return (ConDeclField an0 names' ftype' mdoc)
     
     -- ---------------------------------------------------------------------
     
    @@ -4563,7 +4581,14 @@ instance ExactPrint (IE GhcPs) where
         m' <- markAnnotated m
         return (IEModuleContents (depr', an0) m')
     
    -  exact x = error $ "missing match for IE:" ++ showAst x
    +  -- These three exist to not error out, but are no-ops The contents
    +  -- appear as "normal" comments too, which we process instead.
    +  exact (IEGroup x lev doc) = do
    +    return (IEGroup x lev doc)
    +  exact (IEDoc x doc) = do
    +    return (IEDoc x doc)
    +  exact (IEDocNamed x str) = do
    +    return (IEDocNamed x str)
     
     -- ---------------------------------------------------------------------
     
    
    
    =====================================
    utils/check-exact/Preprocess.hs
    =====================================
    @@ -124,8 +124,9 @@ getCppTokensAsComments cppOptions sourceFile = do
     goodComment :: GHC.LEpaComment -> Bool
     goodComment c = isGoodComment (tokComment c)
       where
    -    isGoodComment :: Comment -> Bool
    -    isGoodComment (Comment "" _ _ _) = False
    +    isGoodComment :: [Comment] -> Bool
    +    isGoodComment []                 = False
    +    isGoodComment [Comment "" _ _ _] = False
         isGoodComment _                  = True
     
     
    
    
    =====================================
    utils/check-exact/Utils.hs
    =====================================
    @@ -36,6 +36,7 @@ import GHC.Types.SrcLoc
     import GHC.Driver.Ppr
     import GHC.Data.FastString
     import qualified GHC.Data.Strict as Strict
    +import GHC.Base (NonEmpty(..))
     
     import Data.Data hiding ( Fixity )
     import Data.List (sortBy, elemIndex)
    @@ -236,8 +237,47 @@ ghcCommentText (L _ (GHC.EpaComment (EpaLineComment s) _))     = s
     ghcCommentText (L _ (GHC.EpaComment (EpaBlockComment s) _))    = s
     ghcCommentText (L _ (GHC.EpaComment (EpaEofComment) _))        = ""
     
    -tokComment :: LEpaComment -> Comment
    -tokComment t@(L lt c) = mkComment (normaliseCommentText $ ghcCommentText t) lt (ac_prior_tok c)
    +tokComment :: LEpaComment -> [Comment]
    +tokComment t@(L lt c) =
    +  case c of
    +    (GHC.EpaComment (EpaDocComment dc) pt) -> hsDocStringComments lt pt dc
    +    _ -> [mkComment (normaliseCommentText (ghcCommentText t)) lt (ac_prior_tok c)]
    +
    +hsDocStringComments :: Anchor -> RealSrcSpan -> GHC.HsDocString -> [Comment]
    +hsDocStringComments _ pt (MultiLineDocString dec (x :| xs)) =
    +  let
    +    decStr = printDecorator dec
    +    L lx x' = dedentDocChunkBy (3 + length decStr) x
    +    str = "-- " ++ decStr ++ unpackHDSC x'
    +    docChunk _ [] = []
    +    docChunk pt' (L l chunk:cs)
    +      = Comment ("--" ++ unpackHDSC chunk) (spanAsAnchor l) pt' Nothing : docChunk (rs l) cs
    +  in
    +    (Comment str (spanAsAnchor lx) pt Nothing : docChunk (rs lx) (map dedentDocChunk xs))
    +hsDocStringComments anc pt (NestedDocString dec@(HsDocStringNamed _) (L _ chunk))
    +  = [Comment ("{- " ++ printDecorator dec ++ unpackHDSC chunk ++ "-}") anc pt Nothing ]
    +hsDocStringComments anc pt (NestedDocString dec (L _ chunk))
    +  = [Comment ("{-" ++ printDecorator dec ++ unpackHDSC chunk ++ "-}") anc pt Nothing ]
    +
    +hsDocStringComments _ _ (GeneratedDocString _) = [] -- Should not appear in user-written code
    +
    +-- At the moment the locations of the 'HsDocStringChunk's are from the start of
    +-- the string part, leaving aside the "--". So we need to subtract 2 columns from it
    +dedentDocChunk :: LHsDocStringChunk -> LHsDocStringChunk
    +dedentDocChunk chunk = dedentDocChunkBy 2 chunk
    +
    +dedentDocChunkBy :: Int -> LHsDocStringChunk -> LHsDocStringChunk
    +dedentDocChunkBy  dedent (L (RealSrcSpan l mb) c) = L (RealSrcSpan l' mb) c
    +  where
    +    f = srcSpanFile l
    +    sl = srcSpanStartLine l
    +    sc = srcSpanStartCol l
    +    el = srcSpanEndLine l
    +    ec = srcSpanEndCol l
    +    l' = mkRealSrcSpan (mkRealSrcLoc f sl (sc - dedent))
    +                       (mkRealSrcLoc f el (ec - dedent))
    +
    +dedentDocChunkBy _ x = x
     
     mkEpaComments :: [Comment] -> [Comment] -> EpAnnComments
     mkEpaComments priorCs []
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f6930dc9193ed6916815c9597a693a5379b2563a...78060ce1fbfbda1ac76b3095f1f9e9bf6d95e8e5
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f6930dc9193ed6916815c9597a693a5379b2563a...78060ce1fbfbda1ac76b3095f1f9e9bf6d95e8e5
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 00:37:12 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Mon, 30 Oct 2023 20:37:12 -0400
    Subject: [Git][ghc/ghc][master] EPA: print doc comments as normal comments
    Message-ID: <65404c38125_1baa2821849de421705@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00
    EPA: print doc comments as normal comments
    
    And ignore the ones allocated in haddock processing.
    
    It does not guarantee that every original haddock-like comment appears
    in the output, as it discards ones that have no legal attachment point.
    
    closes #23459
    
    - - - - -
    
    
    4 changed files:
    
    - compiler/GHC/Hs/DocString.hs
    - utils/check-exact/ExactPrint.hs
    - utils/check-exact/Preprocess.hs
    - utils/check-exact/Utils.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Hs/DocString.hs
    =====================================
    @@ -21,6 +21,7 @@ module GHC.Hs.DocString
       , renderHsDocStrings
       , exactPrintHsDocString
       , pprWithDocString
    +  , printDecorator
       ) where
     
     import GHC.Prelude
    
    
    =====================================
    utils/check-exact/ExactPrint.hs
    =====================================
    @@ -32,6 +32,7 @@ module ExactPrint
       ) where
     
     import GHC
    +import GHC.Base (NonEmpty(..))
     import GHC.Core.Coercion.Axiom (Role(..))
     import GHC.Data.Bag
     import qualified GHC.Data.BooleanFormula as BF
    @@ -366,7 +367,7 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do
       when (flush == NoFlushComments) $ do
         when ((getFollowingComments cs) /= []) $ do
           debugM $ "starting trailing comments:" ++ showAst (getFollowingComments cs)
    -      mapM_ printOneComment (map tokComment $ getFollowingComments cs)
    +      mapM_ printOneComment (concatMap tokComment $ getFollowingComments cs)
           debugM $ "ending trailing comments"
     
       eof <- getEofPos
    @@ -393,7 +394,7 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do
     -- ---------------------------------------------------------------------
     
     addCommentsA :: (Monad m, Monoid w) => [LEpaComment] -> EP w m ()
    -addCommentsA csNew = addComments (map tokComment csNew)
    +addCommentsA csNew = addComments (concatMap tokComment csNew)
     
     {-
     TODO: When we addComments, some may have an anchor that is no longer
    @@ -547,7 +548,7 @@ printStringAtAAC :: (Monad m, Monoid w)
       => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
     printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s
     printStringAtAAC capture (EpaDelta d cs) s = do
    -  mapM_ (printOneComment . tokComment) cs
    +  mapM_  printOneComment $ concatMap tokComment cs
       pe1 <- getPriorEndD
       p1 <- getPosP
       printStringAtLsDelta d s
    @@ -1357,7 +1358,7 @@ instance ExactPrint (HsModule GhcPs) where
       exact hsmod@(HsModule {hsmodExt = XModulePs { hsmodAnn = EpAnnNotUsed }}) = withPpr hsmod >> return hsmod
       exact (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports imports decls) = do
     
    -    mbDoc' <- markAnnotated mbDoc
    +    let mbDoc' = mbDoc
     
         (an0, mmn' , mdeprec', mexports') <-
           case mmn of
    @@ -1382,7 +1383,7 @@ instance ExactPrint (HsModule GhcPs) where
     
         am_decls' <- markTrailing (am_decls $ anns an0)
         imports' <- markTopLevelList imports
    -    decls' <- markTopLevelList decls
    +    decls' <- markTopLevelList (filter removeDocDecl decls)
     
         lo1 <- case lo0 of
             ExplicitBraces open close -> do
    @@ -1402,6 +1403,11 @@ instance ExactPrint (HsModule GhcPs) where
     
         return (HsModule (XModulePs anf lo1 mdeprec' mbDoc') mmn' mexports' imports' decls')
     
    +
    +removeDocDecl :: LHsDecl GhcPs -> Bool
    +removeDocDecl (L _ DocD{}) = False
    +removeDocDecl _ = True
    +
     -- ---------------------------------------------------------------------
     
     instance ExactPrint ModuleName where
    @@ -1533,9 +1539,27 @@ instance ExactPrint (ImportDecl GhcPs) where
     instance ExactPrint HsDocString where
       getAnnotationEntry _ = NoEntryVal
       setAnnotationAnchor a _ _ = a
    -  exact ds = do
    -    (printStringAdvance . exactPrintHsDocString) ds
    -    return ds
    +
    +  exact (MultiLineDocString decorator (x :| xs)) = do
    +    printStringAdvance ("-- " ++ printDecorator decorator)
    +    pe <- getPriorEndD
    +    debugM $ "MultiLineDocString: (pe,x)=" ++ showAst (pe,x)
    +    x' <- markAnnotated x
    +    xs' <- markAnnotated (map dedentDocChunk xs)
    +    return (MultiLineDocString decorator (x' :| xs'))
    +  exact x = do
    +    -- TODO: can this happen?
    +    debugM $ "Not exact printing:" ++ showAst x
    +    return x
    +
    +
    +instance ExactPrint HsDocStringChunk where
    +  getAnnotationEntry _ = NoEntryVal
    +  setAnnotationAnchor a _ _ = a
    +  exact chunk = do
    +    printStringAdvance ("--" ++ unpackHDSC chunk)
    +    return chunk
    +
     
     instance ExactPrint a => ExactPrint (WithHsDocIdentifiers a GhcPs) where
       getAnnotationEntry _ = NoEntryVal
    @@ -1895,11 +1919,8 @@ instance ExactPrint (DocDecl GhcPs) where
       getAnnotationEntry = const NoEntryVal
       setAnnotationAnchor a _ _ = a
     
    -  exact v = case v of
    -    (DocCommentNext ds)    -> DocCommentNext <$> exact ds
    -    (DocCommentPrev ds)    -> DocCommentPrev <$> exact ds
    -    (DocCommentNamed s ds) -> DocCommentNamed s <$> exact ds
    -    (DocGroup i ds)        -> DocGroup i <$> exact ds
    +  -- We print these as plain comments instead, do a NOP here.
    +  exact v = return v
     
     -- ---------------------------------------------------------------------
     
    @@ -3936,8 +3957,7 @@ instance ExactPrint (HsType GhcPs) where
         return (HsSpliceTy a splice')
       exact (HsDocTy an ty doc) = do
         ty' <- markAnnotated ty
    -    doc' <- markAnnotated doc
    -    return (HsDocTy an ty' doc')
    +    return (HsDocTy an ty' doc)
       exact (HsBangTy an (HsSrcBang mt up str) ty) = do
         an0 <-
           case mt of
    @@ -4246,7 +4266,6 @@ instance ExactPrint (ConDecl GhcPs) where
                         , con_mb_cxt = mcxt
                         , con_args = args
                         , con_doc = doc }) = do
    -    doc' <- mapM markAnnotated doc
         an0 <- if has_forall
           then markEpAnnL an lidl AnnForall
           else return an
    @@ -4266,11 +4285,11 @@ instance ExactPrint (ConDecl GhcPs) where
                            , con_ex_tvs = ex_tvs'
                            , con_mb_cxt = mcxt'
                            , con_args = args'
    -                       , con_doc = doc' })
    +                       , con_doc = doc })
     
         where
    -    --   -- In ppr_details: let's not print the multiplicities (they are always 1, by
    -    --   -- definition) as they do not appear in an actual declaration.
    +    -- In ppr_details: let's not print the multiplicities (they are always 1, by
    +    -- definition) as they do not appear in an actual declaration.
           exact_details (InfixCon t1 t2) = do
             t1' <- markAnnotated t1
             con' <- markAnnotated con
    @@ -4294,7 +4313,6 @@ instance ExactPrint (ConDecl GhcPs) where
                          , con_bndrs = bndrs
                          , con_mb_cxt = mcxt, con_g_args = args
                          , con_res_ty = res_ty, con_doc = doc }) = do
    -    doc' <- mapM markAnnotated doc
         cons' <- mapM markAnnotated cons
         dcol' <- markUniToken dcol
         an1 <- annotationsToComments an lidl  [AnnOpenP, AnnCloseP]
    @@ -4323,7 +4341,7 @@ instance ExactPrint (ConDecl GhcPs) where
                             , con_dcolon = dcol'
                             , con_bndrs = bndrs'
                             , con_mb_cxt = mcxt', con_g_args = args'
    -                        , con_res_ty = res_ty', con_doc = doc' })
    +                        , con_res_ty = res_ty', con_doc = doc })
     
     -- ---------------------------------------------------------------------
     
    @@ -4359,8 +4377,8 @@ instance ExactPrint (ConDeclField GhcPs) where
         names' <- markAnnotated names
         an0 <- markEpAnnL an lidl AnnDcolon
         ftype' <- markAnnotated ftype
    -    mdoc' <- mapM markAnnotated mdoc
    -    return (ConDeclField an0 names' ftype' mdoc')
    +    -- mdoc' <- mapM markAnnotated mdoc
    +    return (ConDeclField an0 names' ftype' mdoc)
     
     -- ---------------------------------------------------------------------
     
    @@ -4563,7 +4581,14 @@ instance ExactPrint (IE GhcPs) where
         m' <- markAnnotated m
         return (IEModuleContents (depr', an0) m')
     
    -  exact x = error $ "missing match for IE:" ++ showAst x
    +  -- These three exist to not error out, but are no-ops The contents
    +  -- appear as "normal" comments too, which we process instead.
    +  exact (IEGroup x lev doc) = do
    +    return (IEGroup x lev doc)
    +  exact (IEDoc x doc) = do
    +    return (IEDoc x doc)
    +  exact (IEDocNamed x str) = do
    +    return (IEDocNamed x str)
     
     -- ---------------------------------------------------------------------
     
    
    
    =====================================
    utils/check-exact/Preprocess.hs
    =====================================
    @@ -124,8 +124,9 @@ getCppTokensAsComments cppOptions sourceFile = do
     goodComment :: GHC.LEpaComment -> Bool
     goodComment c = isGoodComment (tokComment c)
       where
    -    isGoodComment :: Comment -> Bool
    -    isGoodComment (Comment "" _ _ _) = False
    +    isGoodComment :: [Comment] -> Bool
    +    isGoodComment []                 = False
    +    isGoodComment [Comment "" _ _ _] = False
         isGoodComment _                  = True
     
     
    
    
    =====================================
    utils/check-exact/Utils.hs
    =====================================
    @@ -36,6 +36,7 @@ import GHC.Types.SrcLoc
     import GHC.Driver.Ppr
     import GHC.Data.FastString
     import qualified GHC.Data.Strict as Strict
    +import GHC.Base (NonEmpty(..))
     
     import Data.Data hiding ( Fixity )
     import Data.List (sortBy, elemIndex)
    @@ -236,8 +237,47 @@ ghcCommentText (L _ (GHC.EpaComment (EpaLineComment s) _))     = s
     ghcCommentText (L _ (GHC.EpaComment (EpaBlockComment s) _))    = s
     ghcCommentText (L _ (GHC.EpaComment (EpaEofComment) _))        = ""
     
    -tokComment :: LEpaComment -> Comment
    -tokComment t@(L lt c) = mkComment (normaliseCommentText $ ghcCommentText t) lt (ac_prior_tok c)
    +tokComment :: LEpaComment -> [Comment]
    +tokComment t@(L lt c) =
    +  case c of
    +    (GHC.EpaComment (EpaDocComment dc) pt) -> hsDocStringComments lt pt dc
    +    _ -> [mkComment (normaliseCommentText (ghcCommentText t)) lt (ac_prior_tok c)]
    +
    +hsDocStringComments :: Anchor -> RealSrcSpan -> GHC.HsDocString -> [Comment]
    +hsDocStringComments _ pt (MultiLineDocString dec (x :| xs)) =
    +  let
    +    decStr = printDecorator dec
    +    L lx x' = dedentDocChunkBy (3 + length decStr) x
    +    str = "-- " ++ decStr ++ unpackHDSC x'
    +    docChunk _ [] = []
    +    docChunk pt' (L l chunk:cs)
    +      = Comment ("--" ++ unpackHDSC chunk) (spanAsAnchor l) pt' Nothing : docChunk (rs l) cs
    +  in
    +    (Comment str (spanAsAnchor lx) pt Nothing : docChunk (rs lx) (map dedentDocChunk xs))
    +hsDocStringComments anc pt (NestedDocString dec@(HsDocStringNamed _) (L _ chunk))
    +  = [Comment ("{- " ++ printDecorator dec ++ unpackHDSC chunk ++ "-}") anc pt Nothing ]
    +hsDocStringComments anc pt (NestedDocString dec (L _ chunk))
    +  = [Comment ("{-" ++ printDecorator dec ++ unpackHDSC chunk ++ "-}") anc pt Nothing ]
    +
    +hsDocStringComments _ _ (GeneratedDocString _) = [] -- Should not appear in user-written code
    +
    +-- At the moment the locations of the 'HsDocStringChunk's are from the start of
    +-- the string part, leaving aside the "--". So we need to subtract 2 columns from it
    +dedentDocChunk :: LHsDocStringChunk -> LHsDocStringChunk
    +dedentDocChunk chunk = dedentDocChunkBy 2 chunk
    +
    +dedentDocChunkBy :: Int -> LHsDocStringChunk -> LHsDocStringChunk
    +dedentDocChunkBy  dedent (L (RealSrcSpan l mb) c) = L (RealSrcSpan l' mb) c
    +  where
    +    f = srcSpanFile l
    +    sl = srcSpanStartLine l
    +    sc = srcSpanStartCol l
    +    el = srcSpanEndLine l
    +    ec = srcSpanEndCol l
    +    l' = mkRealSrcSpan (mkRealSrcLoc f sl (sc - dedent))
    +                       (mkRealSrcLoc f el (ec - dedent))
    +
    +dedentDocChunkBy _ x = x
     
     mkEpaComments :: [Comment] -> [Comment] -> EpAnnComments
     mkEpaComments priorCs []
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/723bc3523227ad505c92e16f11270bf9b524f4da
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/723bc3523227ad505c92e16f11270bf9b524f4da
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 00:37:43 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Mon, 30 Oct 2023 20:37:43 -0400
    Subject: [Git][ghc/ghc][master] Fix non-termination bug in equality solver
    Message-ID: <65404c57659f3_1baa28218416802203eb@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00
    Fix non-termination bug in equality solver
    
    constraint left-to-right then right to left, forever.
    
    Easily fixed.
    
    - - - - -
    
    
    3 changed files:
    
    - compiler/GHC/Tc/Solver/Equality.hs
    - + testsuite/tests/indexed-types/should_compile/T24134.hs
    - testsuite/tests/indexed-types/should_compile/all.T
    
    
    Changes:
    
    =====================================
    compiler/GHC/Tc/Solver/Equality.hs
    =====================================
    @@ -1721,12 +1721,16 @@ canEqCanLHS2 ev eq_rel swapped lhs1 ps_xi1 lhs2 ps_xi2 mco
                  swap_for_size = typesSize fun_args2 > typesSize fun_args1
     
                  -- See Note [Orienting TyFamLHS/TyFamLHS]
    -             swap_for_rewriting = anyVarSet (isTouchableMetaTyVar tclvl) tvs2 &&
    +             meta_tv_lhs = anyVarSet (isTouchableMetaTyVar tclvl) tvs1
    +             meta_tv_rhs = anyVarSet (isTouchableMetaTyVar tclvl) tvs2
    +             swap_for_rewriting = meta_tv_rhs && not meta_tv_lhs
                                       -- See Note [Put touchable variables on the left]
    -                                  not (anyVarSet (isTouchableMetaTyVar tclvl) tvs1)
                                       -- This second check is just to avoid unfruitful swapping
     
    -       ; if swap_for_rewriting || swap_for_size
    +         -- It's important that we don't flip-flop (#T24134)
    +         -- So swap_for_rewriting "wins", and we only try swap_for_size
    +         -- if swap_for_rewriting doesn't care either way
    +       ; if swap_for_rewriting || (meta_tv_lhs == meta_tv_rhs && swap_for_size)
              then finish_with_swapping
              else finish_without_swapping } }
       where
    @@ -1945,7 +1949,9 @@ canEqCanLHSFinish_no_unification ev eq_rel swapped lhs rhs
                   -- If we had F a ~ G (F a), which gives an occurs check,
                   -- then swap it to G (F a) ~ F a, which does not
                   -- However `swap_for_size` above will orient it with (G (F a)) on
    -              -- the left anwyway, so the next four lines of code are redundant
    +              -- the left anwyway.  `swap_for_rewriting` "wins", but that doesn't
    +              -- matter: in the occurs check case swap_for_rewriting will be moot.
    +              -- TL;DR: the next four lines of code are redundant
                   -- I'm leaving them here in case they become relevant again
     --              | TyFamLHS {} <- lhs
     --              , Just can_rhs <- canTyFamEqLHS_maybe rhs
    
    
    =====================================
    testsuite/tests/indexed-types/should_compile/T24134.hs
    =====================================
    @@ -0,0 +1,54 @@
    +{-# LANGUAGE GHC2021 #-}
    +{-# LANGUAGE TypeFamilies #-}
    +
    +module M where
    +import Data.Kind (Type)
    +
    +type F :: Type -> Type
    +type family F
    +
    +type Prod :: Type -> Type -> Type
    +type family Prod (a :: Type) (b :: Type) :: Type
    +
    +und :: F Int
    +und = und
    +
    +f :: a -> Prod (F Int) a -> Prod a a
    +f = f
    +
    +repMap :: Prod (F Int) (F Int) -> Prod (F Int) (F Int)
    +repMap = f und
    +
    +
    +{- This is what went wrong in GHC 9.8
    +
    +Inert: [W] Prod (F Int) a ~ Prod a a
    +Work: [W] Prod (F Int) (F Int) ~ Prof (F Int) a
    +
    +---> rewrite with inert
    +  [W] Prod (F Int) (F Int) ~ Prod a a
    +---> swap (meta-var to left)
    +  [W] Prod a a ~ Prod (F Int) (F Int)
    +
    +Kick out the inert
    +
    +Inert: [W] Prod a a ~ Prod (F Int) (F Int)
    +Work: [W] Prod (F Int) a ~ Prod a a
    +
    +--> rewrite with inert
    +    [W] Prod (F Int) a ~ Prod (F Int) (F Int)
    +--> swap (size)
    +    [W] Prod (F Int) (F Int) ~ Prod (F Int) a
    +
    +Kick out the inert
    +
    +Inert: [W] Prod (F Int) (F Int) ~ Prod (F Int) a
    +Work: [W] Prod a a ~ Prod (F Int) (F Int)
    +
    +--> rewrite with inert
    +    [W] Prod a a ~ Prod (F Int) a
    +--> swap (size)
    +    [W] Prof (F Int) a ~ Prod a a
    +
    +
    +-}
    
    
    =====================================
    testsuite/tests/indexed-types/should_compile/all.T
    =====================================
    @@ -309,3 +309,4 @@ test('T22547', normal, compile, [''])
     test('T22717', normal, makefile_test, ['T22717'])
     test('T22717_fam_orph', normal, multimod_compile, ['T22717_fam_orph', '-v0'])
     test('T23408', normal, compile, [''])
    +test('T24134', normal, compile, [''])
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21b76843e9b51cd27be32b8c595f29a784276229
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21b76843e9b51cd27be32b8c595f29a784276229
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 00:38:32 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Mon, 30 Oct 2023 20:38:32 -0400
    Subject: [Git][ghc/ghc][master] ghc-toolchain: build with `-package-env=-`
     (#24131)
    Message-ID: <65404c883f086_1baa2821849de42250f5@gitlab.mail>
    
    
    
    Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00
    ghc-toolchain: build with `-package-env=-` (#24131)
    
    Otherwise globally installed libraries (via `cabal install --lib`)
    break the build.
    
    Fixes #24131.
    
    - - - - -
    
    
    1 changed file:
    
    - m4/ghc_toolchain.m4
    
    
    Changes:
    
    =====================================
    m4/ghc_toolchain.m4
    =====================================
    @@ -148,6 +148,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN_BIN],[
                     -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \
                     -XNoImplicitPrelude \
                     -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
    +                -package-env=- \
                     utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain || AC_MSG_ERROR([Could not compile ghc-toolchain])
                 GHC_TOOLCHAIN_BIN="./acghc-toolchain"
                 ;;
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/270867ac8bfe353421870495f8fdd8651d0520cb
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/270867ac8bfe353421870495f8fdd8651d0520cb
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 11:12:57 2023
    From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering))
    Date: Tue, 31 Oct 2023 07:12:57 -0400
    Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] fix
    Message-ID: <6540e13978a59_1baa283096564c25820@gitlab.mail>
    
    
    
    Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    0a73e7d3 by GHC GitLab CI at 2023-10-31T11:09:52+00:00
    fix
    
    - - - - -
    
    
    2 changed files:
    
    - configure.ac
    - distrib/configure.ac.in
    
    
    Changes:
    
    =====================================
    configure.ac
    =====================================
    @@ -402,6 +402,20 @@ then
     else
       TargetPlatformFull="${target_alias}"
     fi
    +if test -z "${build_alias}"
    +then
    +  # --target wasn't given; use result from AC_CANONICAL_TARGET
    +  BuildPlatformFull="${build}"
    +else
    +  BuildPlatformFull="${build_alias}"
    +fi
    +if test -z "${host_alias}"
    +then
    +  # --target wasn't given; use result from AC_CANONICAL_TARGET
    +  HostPlatformFull="${host}"
    +else
    +  HostPlatformFull="${host_alias}"
    +fi
     if test "$CrossCompiling" = "YES"
     then
       # Use value passed by user from --target=
    @@ -412,6 +426,8 @@ fi
     AC_SUBST(CrossCompiling)
     AC_SUBST(CrossCompilePrefix)
     AC_SUBST(TargetPlatformFull)
    +AC_SUBST(BuildPlatformFull)
    +AC_SUBST(HostPlatformFull)
     
     dnl ** Which gcc to use?
     dnl --------------------------------------------------------------
    
    
    =====================================
    distrib/configure.ac.in
    =====================================
    @@ -11,14 +11,20 @@ AC_PREREQ([2.69])
     
     AC_CONFIG_MACRO_DIRS([../m4])
     
    +dnl--------------------------------------------------------------------
    +dnl * Deal with arguments telling us gmp is somewhere odd
    +dnl--------------------------------------------------------------------
    +
    +build_alias=@BuildPlatformFull@
    +host_alias=@HostPlatformFull@
    +target_alias=@TargetPlatformFull@
    +
     dnl this makes sure `./configure --target=`
     dnl works as expected, since we're slightly modifying how Autoconf
     dnl interprets build/host/target and how this interacts with $CC tests
     test -n "$target_alias" && ac_tool_prefix=$target_alias-
     
    -dnl--------------------------------------------------------------------
    -dnl * Deal with arguments telling us gmp is somewhere odd
    -dnl--------------------------------------------------------------------
    +
     
     dnl Various things from the source distribution configure
     bootstrap_build=@BuildPlatform@
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a73e7d35acc703a70e0d45e0ac8c30757ea5893
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a73e7d35acc703a70e0d45e0ac8c30757ea5893
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 11:42:41 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Tue, 31 Oct 2023 07:42:41 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: EPA: print
     doc comments as normal comments
    Message-ID: <6540e8302e0c7_1baa28315e9a5826862f@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00
    EPA: print doc comments as normal comments
    
    And ignore the ones allocated in haddock processing.
    
    It does not guarantee that every original haddock-like comment appears
    in the output, as it discards ones that have no legal attachment point.
    
    closes #23459
    
    - - - - -
    21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00
    Fix non-termination bug in equality solver
    
    constraint left-to-right then right to left, forever.
    
    Easily fixed.
    
    - - - - -
    270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00
    ghc-toolchain: build with `-package-env=-` (#24131)
    
    Otherwise globally installed libraries (via `cabal install --lib`)
    break the build.
    
    Fixes #24131.
    
    - - - - -
    5a759e85 by Krzysztof Gogolewski at 2023-10-31T07:42:27-04:00
    docs: fix ScopedTypeVariables example (#24101)
    
    The previous example didn't compile.
    
    Furthermore, it wasn't demonstrating the point properly.
    I have changed it to an example which shows that 'a' in the signature
    must be the same 'a' as in the instance head.
    
    - - - - -
    7b06e3b1 by Krzysztof Gogolewski at 2023-10-31T07:42:28-04:00
    Fix pretty-printing of type family dependencies
    
    "where" should be after the injectivity annotation.
    
    - - - - -
    
    
    14 changed files:
    
    - compiler/GHC/Hs/DocString.hs
    - compiler/GHC/Iface/Syntax.hs
    - compiler/GHC/Tc/Solver/Equality.hs
    - docs/users_guide/exts/scoped_type_variables.rst
    - m4/ghc_toolchain.m4
    - + testsuite/tests/indexed-types/should_compile/T24134.hs
    - testsuite/tests/indexed-types/should_compile/all.T
    - testsuite/tests/interface-stability/base-exports.stdout
    - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
    - testsuite/tests/interface-stability/base-exports.stdout-mingw32
    - testsuite/tests/interface-stability/base-exports.stdout-ws-32
    - utils/check-exact/ExactPrint.hs
    - utils/check-exact/Preprocess.hs
    - utils/check-exact/Utils.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Hs/DocString.hs
    =====================================
    @@ -21,6 +21,7 @@ module GHC.Hs.DocString
       , renderHsDocStrings
       , exactPrintHsDocString
       , pprWithDocString
    +  , printDecorator
       ) where
     
     import GHC.Prelude
    
    
    =====================================
    compiler/GHC/Iface/Syntax.hs
    =====================================
    @@ -1067,8 +1067,9 @@ pprIfaceDecl ss (IfaceFamily { ifName = tycon
       = vcat [ pprStandaloneKindSig name_doc (mkIfaceTyConKind binders res_kind)
              , hang (text "type family"
                        <+> pprIfaceDeclHead suppress_bndr_sig [] ss tycon binders
    +                   <+> pp_inj res_var inj
                        <+> ppShowRhs ss (pp_where rhs))
    -              2 (pp_inj res_var inj <+> ppShowRhs ss (pp_rhs rhs))
    +              2 (ppShowRhs ss (pp_rhs rhs))
                $$
                nest 2 (ppShowRhs ss (pp_branches rhs))
              ]
    
    
    =====================================
    compiler/GHC/Tc/Solver/Equality.hs
    =====================================
    @@ -1721,12 +1721,16 @@ canEqCanLHS2 ev eq_rel swapped lhs1 ps_xi1 lhs2 ps_xi2 mco
                  swap_for_size = typesSize fun_args2 > typesSize fun_args1
     
                  -- See Note [Orienting TyFamLHS/TyFamLHS]
    -             swap_for_rewriting = anyVarSet (isTouchableMetaTyVar tclvl) tvs2 &&
    +             meta_tv_lhs = anyVarSet (isTouchableMetaTyVar tclvl) tvs1
    +             meta_tv_rhs = anyVarSet (isTouchableMetaTyVar tclvl) tvs2
    +             swap_for_rewriting = meta_tv_rhs && not meta_tv_lhs
                                       -- See Note [Put touchable variables on the left]
    -                                  not (anyVarSet (isTouchableMetaTyVar tclvl) tvs1)
                                       -- This second check is just to avoid unfruitful swapping
     
    -       ; if swap_for_rewriting || swap_for_size
    +         -- It's important that we don't flip-flop (#T24134)
    +         -- So swap_for_rewriting "wins", and we only try swap_for_size
    +         -- if swap_for_rewriting doesn't care either way
    +       ; if swap_for_rewriting || (meta_tv_lhs == meta_tv_rhs && swap_for_size)
              then finish_with_swapping
              else finish_without_swapping } }
       where
    @@ -1945,7 +1949,9 @@ canEqCanLHSFinish_no_unification ev eq_rel swapped lhs rhs
                   -- If we had F a ~ G (F a), which gives an occurs check,
                   -- then swap it to G (F a) ~ F a, which does not
                   -- However `swap_for_size` above will orient it with (G (F a)) on
    -              -- the left anwyway, so the next four lines of code are redundant
    +              -- the left anwyway.  `swap_for_rewriting` "wins", but that doesn't
    +              -- matter: in the occurs check case swap_for_rewriting will be moot.
    +              -- TL;DR: the next four lines of code are redundant
                   -- I'm leaving them here in case they become relevant again
     --              | TyFamLHS {} <- lhs
     --              , Just can_rhs <- canTyFamEqLHS_maybe rhs
    
    
    =====================================
    docs/users_guide/exts/scoped_type_variables.rst
    =====================================
    @@ -293,11 +293,11 @@ signatures/ of the methods. For example, the following will be accepted without
     explicitly enabling :extension:`ScopedTypeVariables`: ::
     
           class D a where
    -        m :: [a] -> a
    +        m :: a -> a
     
    -      instance D [a] where
    +      instance Num a => D [a] where
             m :: [a] -> [a]
    -        m = reverse
    +        m x = map (*2) x
     
     Note that writing ``m :: [a] -> [a]`` requires the use of the
     :extension:`InstanceSigs` extension.
    
    
    =====================================
    m4/ghc_toolchain.m4
    =====================================
    @@ -148,6 +148,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN_BIN],[
                     -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \
                     -XNoImplicitPrelude \
                     -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
    +                -package-env=- \
                     utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain || AC_MSG_ERROR([Could not compile ghc-toolchain])
                 GHC_TOOLCHAIN_BIN="./acghc-toolchain"
                 ;;
    
    
    =====================================
    testsuite/tests/indexed-types/should_compile/T24134.hs
    =====================================
    @@ -0,0 +1,54 @@
    +{-# LANGUAGE GHC2021 #-}
    +{-# LANGUAGE TypeFamilies #-}
    +
    +module M where
    +import Data.Kind (Type)
    +
    +type F :: Type -> Type
    +type family F
    +
    +type Prod :: Type -> Type -> Type
    +type family Prod (a :: Type) (b :: Type) :: Type
    +
    +und :: F Int
    +und = und
    +
    +f :: a -> Prod (F Int) a -> Prod a a
    +f = f
    +
    +repMap :: Prod (F Int) (F Int) -> Prod (F Int) (F Int)
    +repMap = f und
    +
    +
    +{- This is what went wrong in GHC 9.8
    +
    +Inert: [W] Prod (F Int) a ~ Prod a a
    +Work: [W] Prod (F Int) (F Int) ~ Prof (F Int) a
    +
    +---> rewrite with inert
    +  [W] Prod (F Int) (F Int) ~ Prod a a
    +---> swap (meta-var to left)
    +  [W] Prod a a ~ Prod (F Int) (F Int)
    +
    +Kick out the inert
    +
    +Inert: [W] Prod a a ~ Prod (F Int) (F Int)
    +Work: [W] Prod (F Int) a ~ Prod a a
    +
    +--> rewrite with inert
    +    [W] Prod (F Int) a ~ Prod (F Int) (F Int)
    +--> swap (size)
    +    [W] Prod (F Int) (F Int) ~ Prod (F Int) a
    +
    +Kick out the inert
    +
    +Inert: [W] Prod (F Int) (F Int) ~ Prod (F Int) a
    +Work: [W] Prod a a ~ Prod (F Int) (F Int)
    +
    +--> rewrite with inert
    +    [W] Prod a a ~ Prod (F Int) a
    +--> swap (size)
    +    [W] Prof (F Int) a ~ Prod a a
    +
    +
    +-}
    
    
    =====================================
    testsuite/tests/indexed-types/should_compile/all.T
    =====================================
    @@ -309,3 +309,4 @@ test('T22547', normal, compile, [''])
     test('T22717', normal, makefile_test, ['T22717'])
     test('T22717_fam_orph', normal, multimod_compile, ['T22717_fam_orph', '-v0'])
     test('T23408', normal, compile, [''])
    +test('T24134', normal, compile, [''])
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-mingw32
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-ws-32
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    utils/check-exact/ExactPrint.hs
    =====================================
    @@ -32,6 +32,7 @@ module ExactPrint
       ) where
     
     import GHC
    +import GHC.Base (NonEmpty(..))
     import GHC.Core.Coercion.Axiom (Role(..))
     import GHC.Data.Bag
     import qualified GHC.Data.BooleanFormula as BF
    @@ -366,7 +367,7 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do
       when (flush == NoFlushComments) $ do
         when ((getFollowingComments cs) /= []) $ do
           debugM $ "starting trailing comments:" ++ showAst (getFollowingComments cs)
    -      mapM_ printOneComment (map tokComment $ getFollowingComments cs)
    +      mapM_ printOneComment (concatMap tokComment $ getFollowingComments cs)
           debugM $ "ending trailing comments"
     
       eof <- getEofPos
    @@ -393,7 +394,7 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do
     -- ---------------------------------------------------------------------
     
     addCommentsA :: (Monad m, Monoid w) => [LEpaComment] -> EP w m ()
    -addCommentsA csNew = addComments (map tokComment csNew)
    +addCommentsA csNew = addComments (concatMap tokComment csNew)
     
     {-
     TODO: When we addComments, some may have an anchor that is no longer
    @@ -547,7 +548,7 @@ printStringAtAAC :: (Monad m, Monoid w)
       => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
     printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s
     printStringAtAAC capture (EpaDelta d cs) s = do
    -  mapM_ (printOneComment . tokComment) cs
    +  mapM_  printOneComment $ concatMap tokComment cs
       pe1 <- getPriorEndD
       p1 <- getPosP
       printStringAtLsDelta d s
    @@ -1357,7 +1358,7 @@ instance ExactPrint (HsModule GhcPs) where
       exact hsmod@(HsModule {hsmodExt = XModulePs { hsmodAnn = EpAnnNotUsed }}) = withPpr hsmod >> return hsmod
       exact (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports imports decls) = do
     
    -    mbDoc' <- markAnnotated mbDoc
    +    let mbDoc' = mbDoc
     
         (an0, mmn' , mdeprec', mexports') <-
           case mmn of
    @@ -1382,7 +1383,7 @@ instance ExactPrint (HsModule GhcPs) where
     
         am_decls' <- markTrailing (am_decls $ anns an0)
         imports' <- markTopLevelList imports
    -    decls' <- markTopLevelList decls
    +    decls' <- markTopLevelList (filter removeDocDecl decls)
     
         lo1 <- case lo0 of
             ExplicitBraces open close -> do
    @@ -1402,6 +1403,11 @@ instance ExactPrint (HsModule GhcPs) where
     
         return (HsModule (XModulePs anf lo1 mdeprec' mbDoc') mmn' mexports' imports' decls')
     
    +
    +removeDocDecl :: LHsDecl GhcPs -> Bool
    +removeDocDecl (L _ DocD{}) = False
    +removeDocDecl _ = True
    +
     -- ---------------------------------------------------------------------
     
     instance ExactPrint ModuleName where
    @@ -1533,9 +1539,27 @@ instance ExactPrint (ImportDecl GhcPs) where
     instance ExactPrint HsDocString where
       getAnnotationEntry _ = NoEntryVal
       setAnnotationAnchor a _ _ = a
    -  exact ds = do
    -    (printStringAdvance . exactPrintHsDocString) ds
    -    return ds
    +
    +  exact (MultiLineDocString decorator (x :| xs)) = do
    +    printStringAdvance ("-- " ++ printDecorator decorator)
    +    pe <- getPriorEndD
    +    debugM $ "MultiLineDocString: (pe,x)=" ++ showAst (pe,x)
    +    x' <- markAnnotated x
    +    xs' <- markAnnotated (map dedentDocChunk xs)
    +    return (MultiLineDocString decorator (x' :| xs'))
    +  exact x = do
    +    -- TODO: can this happen?
    +    debugM $ "Not exact printing:" ++ showAst x
    +    return x
    +
    +
    +instance ExactPrint HsDocStringChunk where
    +  getAnnotationEntry _ = NoEntryVal
    +  setAnnotationAnchor a _ _ = a
    +  exact chunk = do
    +    printStringAdvance ("--" ++ unpackHDSC chunk)
    +    return chunk
    +
     
     instance ExactPrint a => ExactPrint (WithHsDocIdentifiers a GhcPs) where
       getAnnotationEntry _ = NoEntryVal
    @@ -1895,11 +1919,8 @@ instance ExactPrint (DocDecl GhcPs) where
       getAnnotationEntry = const NoEntryVal
       setAnnotationAnchor a _ _ = a
     
    -  exact v = case v of
    -    (DocCommentNext ds)    -> DocCommentNext <$> exact ds
    -    (DocCommentPrev ds)    -> DocCommentPrev <$> exact ds
    -    (DocCommentNamed s ds) -> DocCommentNamed s <$> exact ds
    -    (DocGroup i ds)        -> DocGroup i <$> exact ds
    +  -- We print these as plain comments instead, do a NOP here.
    +  exact v = return v
     
     -- ---------------------------------------------------------------------
     
    @@ -3936,8 +3957,7 @@ instance ExactPrint (HsType GhcPs) where
         return (HsSpliceTy a splice')
       exact (HsDocTy an ty doc) = do
         ty' <- markAnnotated ty
    -    doc' <- markAnnotated doc
    -    return (HsDocTy an ty' doc')
    +    return (HsDocTy an ty' doc)
       exact (HsBangTy an (HsSrcBang mt up str) ty) = do
         an0 <-
           case mt of
    @@ -4246,7 +4266,6 @@ instance ExactPrint (ConDecl GhcPs) where
                         , con_mb_cxt = mcxt
                         , con_args = args
                         , con_doc = doc }) = do
    -    doc' <- mapM markAnnotated doc
         an0 <- if has_forall
           then markEpAnnL an lidl AnnForall
           else return an
    @@ -4266,11 +4285,11 @@ instance ExactPrint (ConDecl GhcPs) where
                            , con_ex_tvs = ex_tvs'
                            , con_mb_cxt = mcxt'
                            , con_args = args'
    -                       , con_doc = doc' })
    +                       , con_doc = doc })
     
         where
    -    --   -- In ppr_details: let's not print the multiplicities (they are always 1, by
    -    --   -- definition) as they do not appear in an actual declaration.
    +    -- In ppr_details: let's not print the multiplicities (they are always 1, by
    +    -- definition) as they do not appear in an actual declaration.
           exact_details (InfixCon t1 t2) = do
             t1' <- markAnnotated t1
             con' <- markAnnotated con
    @@ -4294,7 +4313,6 @@ instance ExactPrint (ConDecl GhcPs) where
                          , con_bndrs = bndrs
                          , con_mb_cxt = mcxt, con_g_args = args
                          , con_res_ty = res_ty, con_doc = doc }) = do
    -    doc' <- mapM markAnnotated doc
         cons' <- mapM markAnnotated cons
         dcol' <- markUniToken dcol
         an1 <- annotationsToComments an lidl  [AnnOpenP, AnnCloseP]
    @@ -4323,7 +4341,7 @@ instance ExactPrint (ConDecl GhcPs) where
                             , con_dcolon = dcol'
                             , con_bndrs = bndrs'
                             , con_mb_cxt = mcxt', con_g_args = args'
    -                        , con_res_ty = res_ty', con_doc = doc' })
    +                        , con_res_ty = res_ty', con_doc = doc })
     
     -- ---------------------------------------------------------------------
     
    @@ -4359,8 +4377,8 @@ instance ExactPrint (ConDeclField GhcPs) where
         names' <- markAnnotated names
         an0 <- markEpAnnL an lidl AnnDcolon
         ftype' <- markAnnotated ftype
    -    mdoc' <- mapM markAnnotated mdoc
    -    return (ConDeclField an0 names' ftype' mdoc')
    +    -- mdoc' <- mapM markAnnotated mdoc
    +    return (ConDeclField an0 names' ftype' mdoc)
     
     -- ---------------------------------------------------------------------
     
    @@ -4563,7 +4581,14 @@ instance ExactPrint (IE GhcPs) where
         m' <- markAnnotated m
         return (IEModuleContents (depr', an0) m')
     
    -  exact x = error $ "missing match for IE:" ++ showAst x
    +  -- These three exist to not error out, but are no-ops The contents
    +  -- appear as "normal" comments too, which we process instead.
    +  exact (IEGroup x lev doc) = do
    +    return (IEGroup x lev doc)
    +  exact (IEDoc x doc) = do
    +    return (IEDoc x doc)
    +  exact (IEDocNamed x str) = do
    +    return (IEDocNamed x str)
     
     -- ---------------------------------------------------------------------
     
    
    
    =====================================
    utils/check-exact/Preprocess.hs
    =====================================
    @@ -124,8 +124,9 @@ getCppTokensAsComments cppOptions sourceFile = do
     goodComment :: GHC.LEpaComment -> Bool
     goodComment c = isGoodComment (tokComment c)
       where
    -    isGoodComment :: Comment -> Bool
    -    isGoodComment (Comment "" _ _ _) = False
    +    isGoodComment :: [Comment] -> Bool
    +    isGoodComment []                 = False
    +    isGoodComment [Comment "" _ _ _] = False
         isGoodComment _                  = True
     
     
    
    
    =====================================
    utils/check-exact/Utils.hs
    =====================================
    @@ -36,6 +36,7 @@ import GHC.Types.SrcLoc
     import GHC.Driver.Ppr
     import GHC.Data.FastString
     import qualified GHC.Data.Strict as Strict
    +import GHC.Base (NonEmpty(..))
     
     import Data.Data hiding ( Fixity )
     import Data.List (sortBy, elemIndex)
    @@ -236,8 +237,47 @@ ghcCommentText (L _ (GHC.EpaComment (EpaLineComment s) _))     = s
     ghcCommentText (L _ (GHC.EpaComment (EpaBlockComment s) _))    = s
     ghcCommentText (L _ (GHC.EpaComment (EpaEofComment) _))        = ""
     
    -tokComment :: LEpaComment -> Comment
    -tokComment t@(L lt c) = mkComment (normaliseCommentText $ ghcCommentText t) lt (ac_prior_tok c)
    +tokComment :: LEpaComment -> [Comment]
    +tokComment t@(L lt c) =
    +  case c of
    +    (GHC.EpaComment (EpaDocComment dc) pt) -> hsDocStringComments lt pt dc
    +    _ -> [mkComment (normaliseCommentText (ghcCommentText t)) lt (ac_prior_tok c)]
    +
    +hsDocStringComments :: Anchor -> RealSrcSpan -> GHC.HsDocString -> [Comment]
    +hsDocStringComments _ pt (MultiLineDocString dec (x :| xs)) =
    +  let
    +    decStr = printDecorator dec
    +    L lx x' = dedentDocChunkBy (3 + length decStr) x
    +    str = "-- " ++ decStr ++ unpackHDSC x'
    +    docChunk _ [] = []
    +    docChunk pt' (L l chunk:cs)
    +      = Comment ("--" ++ unpackHDSC chunk) (spanAsAnchor l) pt' Nothing : docChunk (rs l) cs
    +  in
    +    (Comment str (spanAsAnchor lx) pt Nothing : docChunk (rs lx) (map dedentDocChunk xs))
    +hsDocStringComments anc pt (NestedDocString dec@(HsDocStringNamed _) (L _ chunk))
    +  = [Comment ("{- " ++ printDecorator dec ++ unpackHDSC chunk ++ "-}") anc pt Nothing ]
    +hsDocStringComments anc pt (NestedDocString dec (L _ chunk))
    +  = [Comment ("{-" ++ printDecorator dec ++ unpackHDSC chunk ++ "-}") anc pt Nothing ]
    +
    +hsDocStringComments _ _ (GeneratedDocString _) = [] -- Should not appear in user-written code
    +
    +-- At the moment the locations of the 'HsDocStringChunk's are from the start of
    +-- the string part, leaving aside the "--". So we need to subtract 2 columns from it
    +dedentDocChunk :: LHsDocStringChunk -> LHsDocStringChunk
    +dedentDocChunk chunk = dedentDocChunkBy 2 chunk
    +
    +dedentDocChunkBy :: Int -> LHsDocStringChunk -> LHsDocStringChunk
    +dedentDocChunkBy  dedent (L (RealSrcSpan l mb) c) = L (RealSrcSpan l' mb) c
    +  where
    +    f = srcSpanFile l
    +    sl = srcSpanStartLine l
    +    sc = srcSpanStartCol l
    +    el = srcSpanEndLine l
    +    ec = srcSpanEndCol l
    +    l' = mkRealSrcSpan (mkRealSrcLoc f sl (sc - dedent))
    +                       (mkRealSrcLoc f el (ec - dedent))
    +
    +dedentDocChunkBy _ x = x
     
     mkEpaComments :: [Comment] -> [Comment] -> EpAnnComments
     mkEpaComments priorCs []
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78060ce1fbfbda1ac76b3095f1f9e9bf6d95e8e5...7b06e3b1571743d4b8b2d3fbb66143004310d2fe
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78060ce1fbfbda1ac76b3095f1f9e9bf6d95e8e5...7b06e3b1571743d4b8b2d3fbb66143004310d2fe
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 16:26:51 2023
    From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering))
    Date: Tue, 31 Oct 2023 12:26:51 -0400
    Subject: [Git][ghc/ghc][wip/T24056] 5 commits: EPA: print doc comments as
     normal comments
    Message-ID: <65412acb330fd_1baa2837e1ec7c3352ac@gitlab.mail>
    
    
    
    Matthew Pickering pushed to branch wip/T24056 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00
    EPA: print doc comments as normal comments
    
    And ignore the ones allocated in haddock processing.
    
    It does not guarantee that every original haddock-like comment appears
    in the output, as it discards ones that have no legal attachment point.
    
    closes #23459
    
    - - - - -
    21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00
    Fix non-termination bug in equality solver
    
    constraint left-to-right then right to left, forever.
    
    Easily fixed.
    
    - - - - -
    270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00
    ghc-toolchain: build with `-package-env=-` (#24131)
    
    Otherwise globally installed libraries (via `cabal install --lib`)
    break the build.
    
    Fixes #24131.
    
    - - - - -
    a87631d6 by Ben Gamari at 2023-10-31T16:26:33+00:00
    gitlab-ci: Bump LLVM bootstrap jobs to Debian 12
    
    As the Debian 10 images have too old an LLVM.
    
    Addresses #24056.
    
    - - - - -
    3e0a7dd1 by Matthew Pickering at 2023-10-31T16:26:33+00:00
    ci: Run aarch64 llvm backend job with "LLVM backend" label
    
    This brings it into line with the x86 LLVM backend job.
    
    - - - - -
    
    
    10 changed files:
    
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    - compiler/GHC/Hs/DocString.hs
    - compiler/GHC/Tc/Solver/Equality.hs
    - m4/ghc_toolchain.m4
    - + testsuite/tests/indexed-types/should_compile/T24134.hs
    - testsuite/tests/indexed-types/should_compile/all.T
    - utils/check-exact/ExactPrint.hs
    - utils/check-exact/Preprocess.hs
    - utils/check-exact/Utils.hs
    
    
    Changes:
    
    =====================================
    .gitlab/generate-ci/gen_ci.hs
    =====================================
    @@ -979,7 +979,7 @@ job_groups =
          , -- Nightly allowed to fail: #22343
            modifyNightlyJobs allowFailure
             (modifyValidateJobs manual (validateBuilds Amd64 (Linux Debian10) noTntc))
    -     , onlyRule LLVMBackend (validateBuilds Amd64 (Linux Debian10) llvm)
    +     , onlyRule LLVMBackend (validateBuilds Amd64 (Linux Debian12) llvm)
          , disableValidate (standardBuilds Amd64 (Linux Debian11))
          , disableValidate (standardBuilds Amd64 (Linux Debian12))
          -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
    @@ -1003,7 +1003,7 @@ job_groups =
          , fastCI (standardBuilds AArch64 Darwin)
          , fastCI (standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla))
          , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian11) (splitSectionsBroken vanilla))
    -     , disableValidate (validateBuilds AArch64 (Linux Debian10) llvm)
    +     , onlyRule LLVMBackend (validateBuilds AArch64 (Linux Debian12) llvm)
          , standardBuildsWithConfig I386 (Linux Debian10) (splitSectionsBroken vanilla)
          -- Fully static build, in theory usable on any linux distribution.
          , fullyStaticBrokenTests (standardBuildsWithConfig Amd64 (Linux Alpine312) (splitSectionsBroken static))
    @@ -1077,12 +1077,14 @@ platform_mapping = Map.map go combined_result
       where
         whitelist = [ "x86_64-linux-alpine3_12-validate"
                     , "x86_64-linux-deb11-validate"
    +                , "x86_64-linux-deb12-validate"
                     , "x86_64-linux-deb10-validate+debug_info"
                     , "x86_64-linux-fedora33-release"
                     , "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
                     , "x86_64-windows-validate"
                     , "nightly-x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static"
                     , "nightly-x86_64-linux-deb11-validate"
    +                , "nightly-x86_64-linux-deb12-validate"
                     , "x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static"
                     , "nightly-aarch64-linux-deb10-validate"
                     , "nightly-x86_64-linux-alpine3_12-validate"
    @@ -1092,6 +1094,7 @@ platform_mapping = Map.map go combined_result
                     , "release-x86_64-linux-alpine3_12-release+no_split_sections"
                     , "release-x86_64-linux-deb10-release"
                     , "release-x86_64-linux-deb11-release"
    +                , "release-x86_64-linux-deb12-release"
                     , "release-x86_64-linux-fedora33-release"
                     , "release-x86_64-windows-release"
                     ]
    
    
    =====================================
    .gitlab/jobs.yaml
    =====================================
    @@ -126,6 +126,67 @@
           "TEST_ENV": "aarch64-linux-deb10-validate"
         }
       },
    +  "aarch64-linux-deb12-validate+llvm": {
    +    "after_script": [
    +      ".gitlab/ci.sh save_cache",
    +      ".gitlab/ci.sh save_test_output",
    +      ".gitlab/ci.sh clean",
    +      "cat ci_timings"
    +    ],
    +    "allow_failure": false,
    +    "artifacts": {
    +      "expire_in": "2 weeks",
    +      "paths": [
    +        "ghc-aarch64-linux-deb12-validate+llvm.tar.xz",
    +        "junit.xml",
    +        "unexpected-test-output.tar.gz"
    +      ],
    +      "reports": {
    +        "junit": "junit.xml"
    +      },
    +      "when": "always"
    +    },
    +    "cache": {
    +      "key": "aarch64-linux-deb12-$CACHE_REV",
    +      "paths": [
    +        "cabal-cache",
    +        "toolchain"
    +      ]
    +    },
    +    "dependencies": [],
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12:$DOCKER_REV",
    +    "needs": [
    +      {
    +        "artifacts": false,
    +        "job": "hadrian-ghc-in-ghci"
    +      }
    +    ],
    +    "rules": [
    +      {
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "when": "on_success"
    +      }
    +    ],
    +    "script": [
    +      "sudo chown ghc:ghc -R .",
    +      ".gitlab/ci.sh setup",
    +      ".gitlab/ci.sh configure",
    +      ".gitlab/ci.sh build_hadrian",
    +      ".gitlab/ci.sh test_hadrian"
    +    ],
    +    "stage": "full-build",
    +    "tags": [
    +      "aarch64-linux"
    +    ],
    +    "variables": {
    +      "BIGNUM_BACKEND": "gmp",
    +      "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
    +      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "RUNTEST_ARGS": "",
    +      "TEST_ENV": "aarch64-linux-deb12-validate+llvm"
    +    }
    +  },
       "i386-linux-deb10-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
    @@ -380,7 +441,7 @@
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-aarch64-linux-deb10-validate+llvm": {
    +  "nightly-aarch64-linux-deb11-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -391,7 +452,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-aarch64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-aarch64-linux-deb11-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -401,14 +462,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "aarch64-linux-deb10-$CACHE_REV",
    +      "key": "aarch64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -434,15 +495,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-aarch64-linux-deb11-validate",
    +      "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "aarch64-linux-deb10-validate+llvm",
    +      "TEST_ENV": "aarch64-linux-deb11-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-aarch64-linux-deb11-validate": {
    +  "nightly-aarch64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -453,7 +514,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-aarch64-linux-deb11-validate.tar.xz",
    +        "ghc-aarch64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -463,14 +524,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "aarch64-linux-deb11-$CACHE_REV",
    +      "key": "aarch64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -496,11 +557,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-aarch64-linux-deb11-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "aarch64-linux-deb11-validate",
    +      "TEST_ENV": "aarch64-linux-deb12-validate+llvm",
           "XZ_OPT": "-9"
         }
       },
    @@ -1523,18 +1584,18 @@
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-validate+llvm": {
    +  "nightly-x86_64-linux-deb10-validate+thread_sanitizer": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
           ".gitlab/ci.sh clean",
           "cat ci_timings"
         ],
    -    "allow_failure": false,
    +    "allow_failure": true,
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1577,26 +1638,28 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    +      "BUILD_FLAVOUR": "validate+thread_sanitizer",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "HADRIAN_ARGS": "--docs=none",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+llvm",
    +      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    +      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-validate+thread_sanitizer": {
    +  "nightly-x86_64-linux-deb10-zstd-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
           ".gitlab/ci.sh clean",
           "cat ci_timings"
         ],
    -    "allow_failure": true,
    +    "allow_failure": false,
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
    +        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1639,17 +1702,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    -      "BUILD_FLAVOUR": "validate+thread_sanitizer",
    -      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "HADRIAN_ARGS": "--docs=none",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BUILD_FLAVOUR": "validate",
    +      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    -      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions",
    +      "TEST_ENV": "x86_64-linux-deb10-zstd-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-zstd-validate": {
    +  "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1660,7 +1721,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1670,14 +1731,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb10-$CACHE_REV",
    +      "key": "x86_64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -1703,15 +1764,17 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
    +      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    +      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    +      "CROSS_TARGET": "aarch64-linux-gnu",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-zstd-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
    +  "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1722,7 +1785,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1764,18 +1827,19 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "BIGNUM_BACKEND": "native",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    -      "CROSS_TARGET": "aarch64-linux-gnu",
    +      "CONFIGURE_WRAPPER": "emconfigure",
    +      "CROSS_EMULATOR": "js-emulator",
    +      "CROSS_TARGET": "javascript-unknown-ghcjs",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
    +  "nightly-x86_64-linux-deb11-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1786,7 +1850,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1828,19 +1892,16 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "native",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    +      "BIGNUM_BACKEND": "gmp",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CONFIGURE_WRAPPER": "emconfigure",
    -      "CROSS_EMULATOR": "js-emulator",
    -      "CROSS_TARGET": "javascript-unknown-ghcjs",
    +      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-validate": {
    +  "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1851,7 +1912,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1894,15 +1955,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-validate",
    +      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    +      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": {
    +  "nightly-x86_64-linux-deb12-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1913,7 +1974,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1923,14 +1984,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb11-$CACHE_REV",
    +      "key": "x86_64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -1956,15 +2017,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    -      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate",
    +      "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    -      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "RUNTEST_ARGS": "",
    +      "TEST_ENV": "x86_64-linux-deb12-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb12-validate": {
    +  "nightly-x86_64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1975,7 +2036,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb12-validate.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -2018,11 +2079,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb12-validate",
    +      "TEST_ENV": "x86_64-linux-deb12-validate+llvm",
           "XZ_OPT": "-9"
         }
       },
    @@ -4969,7 +5030,7 @@
           "TEST_ENV": "x86_64-linux-deb10-validate+debug_info"
         }
       },
    -  "x86_64-linux-deb10-validate+llvm": {
    +  "x86_64-linux-deb10-validate+thread_sanitizer": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -4980,7 +5041,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5006,8 +5067,9 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    -        "when": "on_success"
    +        "allow_failure": true,
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "when": "manual"
           }
         ],
         "script": [
    @@ -5023,14 +5085,16 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    +      "BUILD_FLAVOUR": "validate+thread_sanitizer",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "HADRIAN_ARGS": "--docs=none",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+llvm"
    +      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    +      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
         }
       },
    -  "x86_64-linux-deb10-validate+thread_sanitizer": {
    +  "x86_64-linux-deb10-zstd-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5041,7 +5105,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
    +        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5067,9 +5131,8 @@
         ],
         "rules": [
           {
    -        "allow_failure": true,
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    -        "when": "manual"
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "when": "on_success"
           }
         ],
         "script": [
    @@ -5085,16 +5148,14 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    -      "BUILD_FLAVOUR": "validate+thread_sanitizer",
    -      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "HADRIAN_ARGS": "--docs=none",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BUILD_FLAVOUR": "validate",
    +      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    -      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
    +      "TEST_ENV": "x86_64-linux-deb10-zstd-validate"
         }
       },
    -  "x86_64-linux-deb10-zstd-validate": {
    +  "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5105,7 +5166,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5115,14 +5176,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb10-$CACHE_REV",
    +      "key": "x86_64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -5131,7 +5192,7 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5148,14 +5209,16 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
    +      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    +      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    +      "CROSS_TARGET": "aarch64-linux-gnu",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-zstd-validate"
    +      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
         }
       },
    -  "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
    +  "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5166,7 +5229,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5192,7 +5255,7 @@
         ],
         "rules": [
           {
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5208,17 +5271,18 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "BIGNUM_BACKEND": "native",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    -      "CROSS_TARGET": "aarch64-linux-gnu",
    +      "CONFIGURE_WRAPPER": "emconfigure",
    +      "CROSS_EMULATOR": "js-emulator",
    +      "CROSS_TARGET": "javascript-unknown-ghcjs",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
    +      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate"
         }
       },
    -  "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
    +  "x86_64-linux-deb11-validate+boot_nonmoving_gc": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5229,7 +5293,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5255,7 +5319,7 @@
         ],
         "rules": [
           {
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5271,18 +5335,15 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "native",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    -      "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CONFIGURE_WRAPPER": "emconfigure",
    -      "CROSS_EMULATOR": "js-emulator",
    -      "CROSS_TARGET": "javascript-unknown-ghcjs",
    -      "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate"
    +      "BIGNUM_BACKEND": "gmp",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    +      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc"
         }
       },
    -  "x86_64-linux-deb11-validate+boot_nonmoving_gc": {
    +  "x86_64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5293,7 +5354,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5303,14 +5364,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb11-$CACHE_REV",
    +      "key": "x86_64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -5319,7 +5380,7 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5336,11 +5397,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    -      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    -      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc"
    +      "RUNTEST_ARGS": "",
    +      "TEST_ENV": "x86_64-linux-deb12-validate+llvm"
         }
       },
       "x86_64-linux-fedora33-release": {
    
    
    =====================================
    compiler/GHC/Hs/DocString.hs
    =====================================
    @@ -21,6 +21,7 @@ module GHC.Hs.DocString
       , renderHsDocStrings
       , exactPrintHsDocString
       , pprWithDocString
    +  , printDecorator
       ) where
     
     import GHC.Prelude
    
    
    =====================================
    compiler/GHC/Tc/Solver/Equality.hs
    =====================================
    @@ -1721,12 +1721,16 @@ canEqCanLHS2 ev eq_rel swapped lhs1 ps_xi1 lhs2 ps_xi2 mco
                  swap_for_size = typesSize fun_args2 > typesSize fun_args1
     
                  -- See Note [Orienting TyFamLHS/TyFamLHS]
    -             swap_for_rewriting = anyVarSet (isTouchableMetaTyVar tclvl) tvs2 &&
    +             meta_tv_lhs = anyVarSet (isTouchableMetaTyVar tclvl) tvs1
    +             meta_tv_rhs = anyVarSet (isTouchableMetaTyVar tclvl) tvs2
    +             swap_for_rewriting = meta_tv_rhs && not meta_tv_lhs
                                       -- See Note [Put touchable variables on the left]
    -                                  not (anyVarSet (isTouchableMetaTyVar tclvl) tvs1)
                                       -- This second check is just to avoid unfruitful swapping
     
    -       ; if swap_for_rewriting || swap_for_size
    +         -- It's important that we don't flip-flop (#T24134)
    +         -- So swap_for_rewriting "wins", and we only try swap_for_size
    +         -- if swap_for_rewriting doesn't care either way
    +       ; if swap_for_rewriting || (meta_tv_lhs == meta_tv_rhs && swap_for_size)
              then finish_with_swapping
              else finish_without_swapping } }
       where
    @@ -1945,7 +1949,9 @@ canEqCanLHSFinish_no_unification ev eq_rel swapped lhs rhs
                   -- If we had F a ~ G (F a), which gives an occurs check,
                   -- then swap it to G (F a) ~ F a, which does not
                   -- However `swap_for_size` above will orient it with (G (F a)) on
    -              -- the left anwyway, so the next four lines of code are redundant
    +              -- the left anwyway.  `swap_for_rewriting` "wins", but that doesn't
    +              -- matter: in the occurs check case swap_for_rewriting will be moot.
    +              -- TL;DR: the next four lines of code are redundant
                   -- I'm leaving them here in case they become relevant again
     --              | TyFamLHS {} <- lhs
     --              , Just can_rhs <- canTyFamEqLHS_maybe rhs
    
    
    =====================================
    m4/ghc_toolchain.m4
    =====================================
    @@ -148,6 +148,7 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN_BIN],[
                     -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \
                     -XNoImplicitPrelude \
                     -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
    +                -package-env=- \
                     utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain || AC_MSG_ERROR([Could not compile ghc-toolchain])
                 GHC_TOOLCHAIN_BIN="./acghc-toolchain"
                 ;;
    
    
    =====================================
    testsuite/tests/indexed-types/should_compile/T24134.hs
    =====================================
    @@ -0,0 +1,54 @@
    +{-# LANGUAGE GHC2021 #-}
    +{-# LANGUAGE TypeFamilies #-}
    +
    +module M where
    +import Data.Kind (Type)
    +
    +type F :: Type -> Type
    +type family F
    +
    +type Prod :: Type -> Type -> Type
    +type family Prod (a :: Type) (b :: Type) :: Type
    +
    +und :: F Int
    +und = und
    +
    +f :: a -> Prod (F Int) a -> Prod a a
    +f = f
    +
    +repMap :: Prod (F Int) (F Int) -> Prod (F Int) (F Int)
    +repMap = f und
    +
    +
    +{- This is what went wrong in GHC 9.8
    +
    +Inert: [W] Prod (F Int) a ~ Prod a a
    +Work: [W] Prod (F Int) (F Int) ~ Prof (F Int) a
    +
    +---> rewrite with inert
    +  [W] Prod (F Int) (F Int) ~ Prod a a
    +---> swap (meta-var to left)
    +  [W] Prod a a ~ Prod (F Int) (F Int)
    +
    +Kick out the inert
    +
    +Inert: [W] Prod a a ~ Prod (F Int) (F Int)
    +Work: [W] Prod (F Int) a ~ Prod a a
    +
    +--> rewrite with inert
    +    [W] Prod (F Int) a ~ Prod (F Int) (F Int)
    +--> swap (size)
    +    [W] Prod (F Int) (F Int) ~ Prod (F Int) a
    +
    +Kick out the inert
    +
    +Inert: [W] Prod (F Int) (F Int) ~ Prod (F Int) a
    +Work: [W] Prod a a ~ Prod (F Int) (F Int)
    +
    +--> rewrite with inert
    +    [W] Prod a a ~ Prod (F Int) a
    +--> swap (size)
    +    [W] Prof (F Int) a ~ Prod a a
    +
    +
    +-}
    
    
    =====================================
    testsuite/tests/indexed-types/should_compile/all.T
    =====================================
    @@ -309,3 +309,4 @@ test('T22547', normal, compile, [''])
     test('T22717', normal, makefile_test, ['T22717'])
     test('T22717_fam_orph', normal, multimod_compile, ['T22717_fam_orph', '-v0'])
     test('T23408', normal, compile, [''])
    +test('T24134', normal, compile, [''])
    
    
    =====================================
    utils/check-exact/ExactPrint.hs
    =====================================
    @@ -32,6 +32,7 @@ module ExactPrint
       ) where
     
     import GHC
    +import GHC.Base (NonEmpty(..))
     import GHC.Core.Coercion.Axiom (Role(..))
     import GHC.Data.Bag
     import qualified GHC.Data.BooleanFormula as BF
    @@ -366,7 +367,7 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do
       when (flush == NoFlushComments) $ do
         when ((getFollowingComments cs) /= []) $ do
           debugM $ "starting trailing comments:" ++ showAst (getFollowingComments cs)
    -      mapM_ printOneComment (map tokComment $ getFollowingComments cs)
    +      mapM_ printOneComment (concatMap tokComment $ getFollowingComments cs)
           debugM $ "ending trailing comments"
     
       eof <- getEofPos
    @@ -393,7 +394,7 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do
     -- ---------------------------------------------------------------------
     
     addCommentsA :: (Monad m, Monoid w) => [LEpaComment] -> EP w m ()
    -addCommentsA csNew = addComments (map tokComment csNew)
    +addCommentsA csNew = addComments (concatMap tokComment csNew)
     
     {-
     TODO: When we addComments, some may have an anchor that is no longer
    @@ -547,7 +548,7 @@ printStringAtAAC :: (Monad m, Monoid w)
       => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
     printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s
     printStringAtAAC capture (EpaDelta d cs) s = do
    -  mapM_ (printOneComment . tokComment) cs
    +  mapM_  printOneComment $ concatMap tokComment cs
       pe1 <- getPriorEndD
       p1 <- getPosP
       printStringAtLsDelta d s
    @@ -1357,7 +1358,7 @@ instance ExactPrint (HsModule GhcPs) where
       exact hsmod@(HsModule {hsmodExt = XModulePs { hsmodAnn = EpAnnNotUsed }}) = withPpr hsmod >> return hsmod
       exact (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports imports decls) = do
     
    -    mbDoc' <- markAnnotated mbDoc
    +    let mbDoc' = mbDoc
     
         (an0, mmn' , mdeprec', mexports') <-
           case mmn of
    @@ -1382,7 +1383,7 @@ instance ExactPrint (HsModule GhcPs) where
     
         am_decls' <- markTrailing (am_decls $ anns an0)
         imports' <- markTopLevelList imports
    -    decls' <- markTopLevelList decls
    +    decls' <- markTopLevelList (filter removeDocDecl decls)
     
         lo1 <- case lo0 of
             ExplicitBraces open close -> do
    @@ -1402,6 +1403,11 @@ instance ExactPrint (HsModule GhcPs) where
     
         return (HsModule (XModulePs anf lo1 mdeprec' mbDoc') mmn' mexports' imports' decls')
     
    +
    +removeDocDecl :: LHsDecl GhcPs -> Bool
    +removeDocDecl (L _ DocD{}) = False
    +removeDocDecl _ = True
    +
     -- ---------------------------------------------------------------------
     
     instance ExactPrint ModuleName where
    @@ -1533,9 +1539,27 @@ instance ExactPrint (ImportDecl GhcPs) where
     instance ExactPrint HsDocString where
       getAnnotationEntry _ = NoEntryVal
       setAnnotationAnchor a _ _ = a
    -  exact ds = do
    -    (printStringAdvance . exactPrintHsDocString) ds
    -    return ds
    +
    +  exact (MultiLineDocString decorator (x :| xs)) = do
    +    printStringAdvance ("-- " ++ printDecorator decorator)
    +    pe <- getPriorEndD
    +    debugM $ "MultiLineDocString: (pe,x)=" ++ showAst (pe,x)
    +    x' <- markAnnotated x
    +    xs' <- markAnnotated (map dedentDocChunk xs)
    +    return (MultiLineDocString decorator (x' :| xs'))
    +  exact x = do
    +    -- TODO: can this happen?
    +    debugM $ "Not exact printing:" ++ showAst x
    +    return x
    +
    +
    +instance ExactPrint HsDocStringChunk where
    +  getAnnotationEntry _ = NoEntryVal
    +  setAnnotationAnchor a _ _ = a
    +  exact chunk = do
    +    printStringAdvance ("--" ++ unpackHDSC chunk)
    +    return chunk
    +
     
     instance ExactPrint a => ExactPrint (WithHsDocIdentifiers a GhcPs) where
       getAnnotationEntry _ = NoEntryVal
    @@ -1895,11 +1919,8 @@ instance ExactPrint (DocDecl GhcPs) where
       getAnnotationEntry = const NoEntryVal
       setAnnotationAnchor a _ _ = a
     
    -  exact v = case v of
    -    (DocCommentNext ds)    -> DocCommentNext <$> exact ds
    -    (DocCommentPrev ds)    -> DocCommentPrev <$> exact ds
    -    (DocCommentNamed s ds) -> DocCommentNamed s <$> exact ds
    -    (DocGroup i ds)        -> DocGroup i <$> exact ds
    +  -- We print these as plain comments instead, do a NOP here.
    +  exact v = return v
     
     -- ---------------------------------------------------------------------
     
    @@ -3936,8 +3957,7 @@ instance ExactPrint (HsType GhcPs) where
         return (HsSpliceTy a splice')
       exact (HsDocTy an ty doc) = do
         ty' <- markAnnotated ty
    -    doc' <- markAnnotated doc
    -    return (HsDocTy an ty' doc')
    +    return (HsDocTy an ty' doc)
       exact (HsBangTy an (HsSrcBang mt up str) ty) = do
         an0 <-
           case mt of
    @@ -4246,7 +4266,6 @@ instance ExactPrint (ConDecl GhcPs) where
                         , con_mb_cxt = mcxt
                         , con_args = args
                         , con_doc = doc }) = do
    -    doc' <- mapM markAnnotated doc
         an0 <- if has_forall
           then markEpAnnL an lidl AnnForall
           else return an
    @@ -4266,11 +4285,11 @@ instance ExactPrint (ConDecl GhcPs) where
                            , con_ex_tvs = ex_tvs'
                            , con_mb_cxt = mcxt'
                            , con_args = args'
    -                       , con_doc = doc' })
    +                       , con_doc = doc })
     
         where
    -    --   -- In ppr_details: let's not print the multiplicities (they are always 1, by
    -    --   -- definition) as they do not appear in an actual declaration.
    +    -- In ppr_details: let's not print the multiplicities (they are always 1, by
    +    -- definition) as they do not appear in an actual declaration.
           exact_details (InfixCon t1 t2) = do
             t1' <- markAnnotated t1
             con' <- markAnnotated con
    @@ -4294,7 +4313,6 @@ instance ExactPrint (ConDecl GhcPs) where
                          , con_bndrs = bndrs
                          , con_mb_cxt = mcxt, con_g_args = args
                          , con_res_ty = res_ty, con_doc = doc }) = do
    -    doc' <- mapM markAnnotated doc
         cons' <- mapM markAnnotated cons
         dcol' <- markUniToken dcol
         an1 <- annotationsToComments an lidl  [AnnOpenP, AnnCloseP]
    @@ -4323,7 +4341,7 @@ instance ExactPrint (ConDecl GhcPs) where
                             , con_dcolon = dcol'
                             , con_bndrs = bndrs'
                             , con_mb_cxt = mcxt', con_g_args = args'
    -                        , con_res_ty = res_ty', con_doc = doc' })
    +                        , con_res_ty = res_ty', con_doc = doc })
     
     -- ---------------------------------------------------------------------
     
    @@ -4359,8 +4377,8 @@ instance ExactPrint (ConDeclField GhcPs) where
         names' <- markAnnotated names
         an0 <- markEpAnnL an lidl AnnDcolon
         ftype' <- markAnnotated ftype
    -    mdoc' <- mapM markAnnotated mdoc
    -    return (ConDeclField an0 names' ftype' mdoc')
    +    -- mdoc' <- mapM markAnnotated mdoc
    +    return (ConDeclField an0 names' ftype' mdoc)
     
     -- ---------------------------------------------------------------------
     
    @@ -4563,7 +4581,14 @@ instance ExactPrint (IE GhcPs) where
         m' <- markAnnotated m
         return (IEModuleContents (depr', an0) m')
     
    -  exact x = error $ "missing match for IE:" ++ showAst x
    +  -- These three exist to not error out, but are no-ops The contents
    +  -- appear as "normal" comments too, which we process instead.
    +  exact (IEGroup x lev doc) = do
    +    return (IEGroup x lev doc)
    +  exact (IEDoc x doc) = do
    +    return (IEDoc x doc)
    +  exact (IEDocNamed x str) = do
    +    return (IEDocNamed x str)
     
     -- ---------------------------------------------------------------------
     
    
    
    =====================================
    utils/check-exact/Preprocess.hs
    =====================================
    @@ -124,8 +124,9 @@ getCppTokensAsComments cppOptions sourceFile = do
     goodComment :: GHC.LEpaComment -> Bool
     goodComment c = isGoodComment (tokComment c)
       where
    -    isGoodComment :: Comment -> Bool
    -    isGoodComment (Comment "" _ _ _) = False
    +    isGoodComment :: [Comment] -> Bool
    +    isGoodComment []                 = False
    +    isGoodComment [Comment "" _ _ _] = False
         isGoodComment _                  = True
     
     
    
    
    =====================================
    utils/check-exact/Utils.hs
    =====================================
    @@ -36,6 +36,7 @@ import GHC.Types.SrcLoc
     import GHC.Driver.Ppr
     import GHC.Data.FastString
     import qualified GHC.Data.Strict as Strict
    +import GHC.Base (NonEmpty(..))
     
     import Data.Data hiding ( Fixity )
     import Data.List (sortBy, elemIndex)
    @@ -236,8 +237,47 @@ ghcCommentText (L _ (GHC.EpaComment (EpaLineComment s) _))     = s
     ghcCommentText (L _ (GHC.EpaComment (EpaBlockComment s) _))    = s
     ghcCommentText (L _ (GHC.EpaComment (EpaEofComment) _))        = ""
     
    -tokComment :: LEpaComment -> Comment
    -tokComment t@(L lt c) = mkComment (normaliseCommentText $ ghcCommentText t) lt (ac_prior_tok c)
    +tokComment :: LEpaComment -> [Comment]
    +tokComment t@(L lt c) =
    +  case c of
    +    (GHC.EpaComment (EpaDocComment dc) pt) -> hsDocStringComments lt pt dc
    +    _ -> [mkComment (normaliseCommentText (ghcCommentText t)) lt (ac_prior_tok c)]
    +
    +hsDocStringComments :: Anchor -> RealSrcSpan -> GHC.HsDocString -> [Comment]
    +hsDocStringComments _ pt (MultiLineDocString dec (x :| xs)) =
    +  let
    +    decStr = printDecorator dec
    +    L lx x' = dedentDocChunkBy (3 + length decStr) x
    +    str = "-- " ++ decStr ++ unpackHDSC x'
    +    docChunk _ [] = []
    +    docChunk pt' (L l chunk:cs)
    +      = Comment ("--" ++ unpackHDSC chunk) (spanAsAnchor l) pt' Nothing : docChunk (rs l) cs
    +  in
    +    (Comment str (spanAsAnchor lx) pt Nothing : docChunk (rs lx) (map dedentDocChunk xs))
    +hsDocStringComments anc pt (NestedDocString dec@(HsDocStringNamed _) (L _ chunk))
    +  = [Comment ("{- " ++ printDecorator dec ++ unpackHDSC chunk ++ "-}") anc pt Nothing ]
    +hsDocStringComments anc pt (NestedDocString dec (L _ chunk))
    +  = [Comment ("{-" ++ printDecorator dec ++ unpackHDSC chunk ++ "-}") anc pt Nothing ]
    +
    +hsDocStringComments _ _ (GeneratedDocString _) = [] -- Should not appear in user-written code
    +
    +-- At the moment the locations of the 'HsDocStringChunk's are from the start of
    +-- the string part, leaving aside the "--". So we need to subtract 2 columns from it
    +dedentDocChunk :: LHsDocStringChunk -> LHsDocStringChunk
    +dedentDocChunk chunk = dedentDocChunkBy 2 chunk
    +
    +dedentDocChunkBy :: Int -> LHsDocStringChunk -> LHsDocStringChunk
    +dedentDocChunkBy  dedent (L (RealSrcSpan l mb) c) = L (RealSrcSpan l' mb) c
    +  where
    +    f = srcSpanFile l
    +    sl = srcSpanStartLine l
    +    sc = srcSpanStartCol l
    +    el = srcSpanEndLine l
    +    ec = srcSpanEndCol l
    +    l' = mkRealSrcSpan (mkRealSrcLoc f sl (sc - dedent))
    +                       (mkRealSrcLoc f el (ec - dedent))
    +
    +dedentDocChunkBy _ x = x
     
     mkEpaComments :: [Comment] -> [Comment] -> EpAnnComments
     mkEpaComments priorCs []
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cfd18d3958008e1de9e06c91135c35f388dc6677...3e0a7dd19c1c823374d4d0441c3eb401c7b3b327
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cfd18d3958008e1de9e06c91135c35f388dc6677...3e0a7dd19c1c823374d4d0441c3eb401c7b3b327
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 16:27:39 2023
    From: gitlab at gitlab.haskell.org (Apoorv Ingle (@ani))
    Date: Tue, 31 Oct 2023 12:27:39 -0400
    Subject: [Git][ghc/ghc][wip/expand-do] 28 commits: rts: fix small argument
     passing on big-endian arch (fix #23387)
    Message-ID: <65412afbb6dfb_1baa2837fa0424335822@gitlab.mail>
    
    
    
    Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
    rts: fix small argument passing on big-endian arch (fix #23387)
    
    - - - - -
    b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
    Interpreter: fix literal alignment on big-endian architectures (fix #19261)
    
    Literals weren't correctly aligned on big-endian, despite what the
    comment said.
    
    - - - - -
    a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
    Testsuite: recomp011 and recomp015 are fixed on powerpc
    
    These tests have been fixed but not tested and re-enabled on big-endian
    powerpc (see comments in #11260 and #11323)
    
    - - - - -
    fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
    CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
    - - - - -
    02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
    Move function checks to RTS configure
    
    Some of these functions are used in `base` too, but we can copy the
    checks over to its configure if that's an issue.
    
    - - - - -
    5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
    Move over a number of C-style checks to RTS configure
    
    - - - - -
    5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
    Move/Copy more `AC_DEFINE` to RTS config
    
    Only exception is the LLVM version macros, which are used for GHC
    itself.
    
    - - - - -
    b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
    Define `TABLES_NEXT_TO_CODE` in the RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
    Configure scripts: `checkOS`: Make a bit more robust
    
    `mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
    allows us to cope with configs/triples that we haven't normalized extra
    being what GNU `config.sub` does.
    
    - - - - -
    16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
    Generate `ghcplatform.h` from RTS configure
    
    We create a new cabal flag to facilitate this.
    
    - - - - -
    7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
    Get rid of all mention of `mk/config.h`
    
    The RTS configure script is now solely responsible for managing its
    headers; the top level configure script does not help.
    
    - - - - -
    c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
    rts: drop stale mentions of MIN_UPD_SIZE
    
    We used to have MIN_UPD_SIZE macro that describes the minimum reserved
    size for thunks, so that the thunk can be overwritten in place as
    indirections or blackholes. However, this macro has not been actually
    defined or used anywhere since a long time ago; StgThunkHeader already
    reserves a padding word for this purpose. Hence this patch which drops
    stale mentions of MIN_UPD_SIZE.
    
    - - - - -
    d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
    base changelog: move non-backported entries from 4.19 section to 4.20
    
    Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
    nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
    were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.
    
    Also minor stylistic changes to other entries, bringing them to a uniform form.
    
    - - - - -
    de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
    EPA Some tweaks to annotations
    
    - Fix span for GRHS
    - Move TrailingAnns from last match to FunBind
    - Fix GADT 'where' clause span
    - Capture full range for a CaseAlt Match
    
    - - - - -
    d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
    Update primitives.rst
    - - - - -
    4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
    JS/userguide: add explanation of writing jsbits
    
    - - - - -
    07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
    testsuite: increase timeout of ghc-api tests for wasm32
    
    ghc-api tests for wasm32 are more likely to timeout due to the large
    wasm module sizes, especially when testing with wasm native tail
    calls, given wasmtime's handling of tail call opcodes are suboptimal
    at the moment. It makes sense to increase timeout specifically for
    these tests on wasm32. This doesn't affect other targets, and for
    wasm32 we don't increase timeout for all tests, so not to risk letting
    major performance regressions slip through the testsuite.
    
    - - - - -
    0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
    Explicitly require RLIMIT_AS before use in OSMem.c
    
    This is done elsewhere in the source tree. It also suddenly is
    required on OpenBSD.
    
    - - - - -
    9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
    Modularity: modularize external linker
    
    Decouple runLink from DynFlags to allow calling runLink more easily.
    This is preliminary work for calling Emscripten's linker (emcc) from
    our JavaScript linker.
    
    - - - - -
    e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
    js: add JStg IR, remove unsaturated constructor
    
    - Major step towards #22736 and adding the optimizer in #22261
    
    - - - - -
    35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
    Fix a bug in tail calls with ticks
    
    See #24078 for the diagnosis.  The change affects only
    the Tick case of occurrence analysis.
    
    It's a bit hard to test, so no regression test (yet anyway).
    
    - - - - -
    9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00
    Teach tag-inference about SeqOp/seq#
    
    Fixes the STG/tag-inference analogue of #15226.
    
    Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>
    
    - - - - -
    34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00
    [PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra
    
    48e391952c17ff7eab10b0b1456e3f2a2af28a9b
    introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.
    
    The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
    Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
    relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.
    
    - - - - -
    5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00
    Fix and test for issue #24111, TH.Ppr output of pattern synonyms
    
    - - - - -
    723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00
    EPA: print doc comments as normal comments
    
    And ignore the ones allocated in haddock processing.
    
    It does not guarantee that every original haddock-like comment appears
    in the output, as it discards ones that have no legal attachment point.
    
    closes #23459
    
    - - - - -
    21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00
    Fix non-termination bug in equality solver
    
    constraint left-to-right then right to left, forever.
    
    Easily fixed.
    
    - - - - -
    270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00
    ghc-toolchain: build with `-package-env=-` (#24131)
    
    Otherwise globally installed libraries (via `cabal install --lib`)
    break the build.
    
    Fixes #24131.
    
    - - - - -
    653af9dd by Apoorv Ingle at 2023-10-31T17:26:58+01:00
    Expand `do` blocks right before typechecking using the `HsExpansion` philosophy.
    
    - A step towards killing `tcSyntaxOp`
    
    - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206
    
    - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do` explains change in detail
    
    - Note Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr` expains the rational of doing expansions in type checker as opposed to in the renamer
    
    - New datatype to make this expansion work `GHC.Hs.Expr.XXExprGhcRn`:
        1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`)
        2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack
    - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc`
    
    - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated
      This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam`
    
    - Ensures warnings such as
      1. Pattern mach checks
      2. Failable patterns
      3. non-() return in body statements are preserved
    
    - Expansions inside Template haskell also work without issues.
    
    - Testcases:
      * T18324 T20020 T23147 T22788 T15598 T22086
      * T23147b (error message check),
      * DoubleMatch (match inside a match for pmc check)
      * pattern-fails (check pattern match with non-refutable pattern, eg. newtype)
      * Simple-rec (rec statements inside do statment)
      * T22788 (code snippet from #22788)
      * DoExpanion1 (Error messages for body statments)
      * DoExpansion2 (Error messages for bind statements)
      * DoExpansion3 (Error messages for let statements)
    
    - - - - -
    
    
    30 changed files:
    
    - .gitignore
    - compiler/GHC/Builtin/primops.txt.pp
    - compiler/GHC/ByteCode/Asm.hs
    - compiler/GHC/Core/Opt/ConstantFold.hs
    - compiler/GHC/Core/Opt/OccurAnal.hs
    - compiler/GHC/CoreToStg/Prep.hs
    - compiler/GHC/Driver/Config/Linker.hs
    - compiler/GHC/Hs/DocString.hs
    - compiler/GHC/Hs/Expr.hs
    - compiler/GHC/Hs/Instances.hs
    - compiler/GHC/Hs/Pat.hs
    - compiler/GHC/Hs/Syn/Type.hs
    - compiler/GHC/Hs/Utils.hs
    - compiler/GHC/HsToCore/Arrows.hs
    - compiler/GHC/HsToCore/Expr.hs
    - compiler/GHC/HsToCore/Match.hs
    - compiler/GHC/HsToCore/Pmc.hs
    - compiler/GHC/HsToCore/Quote.hs
    - compiler/GHC/HsToCore/Ticks.hs
    - compiler/GHC/Iface/Ext/Ast.hs
    - + compiler/GHC/JS/Ident.hs
    - + compiler/GHC/JS/JStg/Monad.hs
    - compiler/GHC/JS/Unsat/Syntax.hs → compiler/GHC/JS/JStg/Syntax.hs
    - compiler/GHC/JS/Make.hs
    - compiler/GHC/JS/Ppr.hs
    - compiler/GHC/JS/Syntax.hs
    - compiler/GHC/JS/Transform.hs
    - compiler/GHC/Linker/Config.hs
    - compiler/GHC/Linker/Dynamic.hs
    - + compiler/GHC/Linker/External.hs
    
    
    The diff was not included because it is too large.
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21cdbe23764d15fe132d499a95817bdbdb942ad6...653af9dd3bef4bbdc91b9d378452a0c4d61f4e6f
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21cdbe23764d15fe132d499a95817bdbdb942ad6...653af9dd3bef4bbdc91b9d378452a0c4d61f4e6f
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 17:03:38 2023
    From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering))
    Date: Tue, 31 Oct 2023 13:03:38 -0400
    Subject: [Git][ghc/ghc][wip/hadrian-cross-stage2] Build genapply per stage
    Message-ID: <6541336a6a708_1baa28391bc130348063@gitlab.mail>
    
    
    
    Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    0316274d by GHC GitLab CI at 2023-10-31T17:03:14+00:00
    Build genapply per stage
    
    - - - - -
    
    
    3 changed files:
    
    - hadrian/src/Builder.hs
    - hadrian/src/Rules/Generate.hs
    - hadrian/src/Settings/Default.hs
    
    
    Changes:
    
    =====================================
    hadrian/src/Builder.hs
    =====================================
    @@ -166,7 +166,7 @@ data Builder = Alex
                  | Cc CcMode Stage
                  | Configure FilePath
                  | DeriveConstants
    -             | GenApply
    +             | GenApply Stage
                  | GenPrimopCode
                  | Ghc GhcMode Stage
                  | GhcPkg GhcPkgMode Stage
    @@ -205,7 +205,7 @@ instance NFData   Builder
     builderProvenance :: Builder -> Maybe Context
     builderProvenance = \case
         DeriveConstants  -> context stage0Boot deriveConstants
    -    GenApply         -> context stage0Boot genapply
    +    GenApply stage   -> context (predStage stage) genapply
         GenPrimopCode    -> context stage0Boot genprimopcode
         Ghc _ (Stage0 {})-> Nothing
         Ghc _ stage      -> context (predStage stage) ghc
    @@ -330,7 +330,7 @@ instance H.Builder Builder where
                         let env = AddEnv "CONFIG_SHELL" bash
                         cmd' env [Cwd dir] ["sh", path] buildOptions buildArgs
     
    -                GenApply -> captureStdout
    +                GenApply {} -> captureStdout
     
                     GenPrimopCode -> do
                         stdin <- readFile' input
    
    
    =====================================
    hadrian/src/Rules/Generate.hs
    =====================================
    @@ -154,7 +154,7 @@ generatePackageCode context@(Context stage pkg _ _) = do
     
         when (pkg == rts) $ do
             root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file ->
    -            build $ target context GenApply [] [file]
    +            build $ target context (GenApply stage) [] [file]
             root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ ->
                 need . pure =<< pkgSetupConfigFile context
             root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ ->
    
    
    =====================================
    hadrian/src/Settings/Default.hs
    =====================================
    @@ -70,7 +70,6 @@ stageBootPackages = return
       , hsc2hs
       , compareSizes
       , deriveConstants
    -  , genapply
       , genprimopcode
       , unlit
       ]
    @@ -111,6 +110,7 @@ stage0Packages = do
                  , transformers
                  , unlit
                  , hp2ps
    +	     , genapply
                  , if windowsHost then win32 else unix
                  ]
               ++ [ terminfo | not windowsHost, not cross ]
    @@ -160,6 +160,7 @@ stage1Packages = do
             , xhtml
             , haddock
             , hpcBin
    +	, genapply
             , if winTarget then win32 else unix
             ] ++
             [ iserv
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0316274d1d4c0e2f9de55871781e9f399a48db6e
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0316274d1d4c0e2f9de55871781e9f399a48db6e
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 17:25:45 2023
    From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering))
    Date: Tue, 31 Oct 2023 13:25:45 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/wasm32-native-tests
    Message-ID: <65413899e1d8f_1baa28398a1db035267f@gitlab.mail>
    
    
    
    Matthew Pickering pushed new branch wip/wasm32-native-tests at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/wasm32-native-tests
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 17:33:16 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Tue, 31 Oct 2023 13:33:16 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: docs: fix
     ScopedTypeVariables example (#24101)
    Message-ID: <65413a5ce6717_1baa2839f8256c35585d@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    909f1ad0 by Krzysztof Gogolewski at 2023-10-31T13:33:09-04:00
    docs: fix ScopedTypeVariables example (#24101)
    
    The previous example didn't compile.
    
    Furthermore, it wasn't demonstrating the point properly.
    I have changed it to an example which shows that 'a' in the signature
    must be the same 'a' as in the instance head.
    
    - - - - -
    f5abb277 by Krzysztof Gogolewski at 2023-10-31T13:33:10-04:00
    Fix pretty-printing of type family dependencies
    
    "where" should be after the injectivity annotation.
    
    - - - - -
    
    
    6 changed files:
    
    - compiler/GHC/Iface/Syntax.hs
    - docs/users_guide/exts/scoped_type_variables.rst
    - testsuite/tests/interface-stability/base-exports.stdout
    - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
    - testsuite/tests/interface-stability/base-exports.stdout-mingw32
    - testsuite/tests/interface-stability/base-exports.stdout-ws-32
    
    
    Changes:
    
    =====================================
    compiler/GHC/Iface/Syntax.hs
    =====================================
    @@ -1067,8 +1067,9 @@ pprIfaceDecl ss (IfaceFamily { ifName = tycon
       = vcat [ pprStandaloneKindSig name_doc (mkIfaceTyConKind binders res_kind)
              , hang (text "type family"
                        <+> pprIfaceDeclHead suppress_bndr_sig [] ss tycon binders
    +                   <+> pp_inj res_var inj
                        <+> ppShowRhs ss (pp_where rhs))
    -              2 (pp_inj res_var inj <+> ppShowRhs ss (pp_rhs rhs))
    +              2 (ppShowRhs ss (pp_rhs rhs))
                $$
                nest 2 (ppShowRhs ss (pp_branches rhs))
              ]
    
    
    =====================================
    docs/users_guide/exts/scoped_type_variables.rst
    =====================================
    @@ -293,11 +293,11 @@ signatures/ of the methods. For example, the following will be accepted without
     explicitly enabling :extension:`ScopedTypeVariables`: ::
     
           class D a where
    -        m :: [a] -> a
    +        m :: a -> a
     
    -      instance D [a] where
    +      instance Num a => D [a] where
             m :: [a] -> [a]
    -        m = reverse
    +        m x = map (*2) x
     
     Note that writing ``m :: [a] -> [a]`` requires the use of the
     :extension:`InstanceSigs` extension.
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-mingw32
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-ws-32
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b06e3b1571743d4b8b2d3fbb66143004310d2fe...f5abb27792158f322a6addb367690b9d7f254fd6
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b06e3b1571743d4b8b2d3fbb66143004310d2fe...f5abb27792158f322a6addb367690b9d7f254fd6
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 17:37:45 2023
    From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj))
    Date: Tue, 31 Oct 2023 13:37:45 -0400
    Subject: [Git][ghc/ghc][wip/spj-unf-size] Wibble
    Message-ID: <65413b6960355_1baa283a09c36c3609f6@gitlab.mail>
    
    
    
    Simon Peyton Jones pushed to branch wip/spj-unf-size at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    22ebbcb3 by Simon Peyton Jones at 2023-10-31T17:37:31+00:00
    Wibble
    
    - - - - -
    
    
    1 changed file:
    
    - compiler/GHC/Core/Unfold.hs
    
    
    Changes:
    
    =====================================
    compiler/GHC/Core/Unfold.hs
    =====================================
    @@ -634,13 +634,13 @@ exprTree opts args expr
     
         -- Don't record a CaseOf
         go_case rcd vs scrut b alts    -- alts is non-empty
    -      = caseSize scrut alts     `metAddN`   -- A bit odd that this is only in one branch
    -        (altSize * length alts) `metAddN`
    -        go rcd vs scrut `et_add` go_alts (rcd-1) vs b alts
    +      = caseSize scrut alts  `metAddN`   -- A bit odd that this is only in one branch
    +        go rcd vs scrut      `et_add`
    +        go_alts (rcd-1) vs b alts
     
         go_alts :: Int -> ETVars -> Id -> [CoreAlt] -> Maybe ExprTree
         -- Add up the sizes of all RHSs.
    -    -- IMPORTANT: charge `altSize` for each alternative, else we
    +    -- IMPORTANT: include a charge `altSize` for each alternative, else we
         -- find that giant case nests are treated as practically free
         -- A good example is Foreign.C.Error.errnoToIOError
         go_alts rcd vs b alts = foldr1 et_add_alt (map alt_expr_tree alts)
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/22ebbcb3c8fb9f49a76493e4c7272769e66d9c3f
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/22ebbcb3c8fb9f49a76493e4c7272769e66d9c3f
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 20:21:35 2023
    From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz))
    Date: Tue, 31 Oct 2023 16:21:35 -0400
    Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-full-range-for-anchor
    Message-ID: <654161cf90f63_1baa283e07e2a037303e@gitlab.mail>
    
    
    
    Alan Zimmerman pushed new branch wip/az/epa-full-range-for-anchor at Glasgow Haskell Compiler / GHC
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-full-range-for-anchor
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: 
    
    From gitlab at gitlab.haskell.org  Tue Oct 31 21:13:56 2023
    From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot))
    Date: Tue, 31 Oct 2023 17:13:56 -0400
    Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: docs: fix
     ScopedTypeVariables example (#24101)
    Message-ID: <65416e14379bc_1baa283f29a0383873db@gitlab.mail>
    
    
    
    Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
    
    
    Commits:
    a2478302 by Krzysztof Gogolewski at 2023-10-31T17:13:30-04:00
    docs: fix ScopedTypeVariables example (#24101)
    
    The previous example didn't compile.
    
    Furthermore, it wasn't demonstrating the point properly.
    I have changed it to an example which shows that 'a' in the signature
    must be the same 'a' as in the instance head.
    
    - - - - -
    bf6919b5 by Krzysztof Gogolewski at 2023-10-31T17:13:31-04:00
    Fix pretty-printing of type family dependencies
    
    "where" should be after the injectivity annotation.
    
    - - - - -
    44c9b22f by Ben Gamari at 2023-10-31T17:13:31-04:00
    gitlab-ci: Bump LLVM bootstrap jobs to Debian 12
    
    As the Debian 10 images have too old an LLVM.
    
    Addresses #24056.
    
    - - - - -
    2488cbf2 by Matthew Pickering at 2023-10-31T17:13:31-04:00
    ci: Run aarch64 llvm backend job with "LLVM backend" label
    
    This brings it into line with the x86 LLVM backend job.
    
    - - - - -
    
    
    8 changed files:
    
    - .gitlab/generate-ci/gen_ci.hs
    - .gitlab/jobs.yaml
    - compiler/GHC/Iface/Syntax.hs
    - docs/users_guide/exts/scoped_type_variables.rst
    - testsuite/tests/interface-stability/base-exports.stdout
    - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
    - testsuite/tests/interface-stability/base-exports.stdout-mingw32
    - testsuite/tests/interface-stability/base-exports.stdout-ws-32
    
    
    Changes:
    
    =====================================
    .gitlab/generate-ci/gen_ci.hs
    =====================================
    @@ -979,7 +979,7 @@ job_groups =
          , -- Nightly allowed to fail: #22343
            modifyNightlyJobs allowFailure
             (modifyValidateJobs manual (validateBuilds Amd64 (Linux Debian10) noTntc))
    -     , onlyRule LLVMBackend (validateBuilds Amd64 (Linux Debian10) llvm)
    +     , onlyRule LLVMBackend (validateBuilds Amd64 (Linux Debian12) llvm)
          , disableValidate (standardBuilds Amd64 (Linux Debian11))
          , disableValidate (standardBuilds Amd64 (Linux Debian12))
          -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
    @@ -1003,7 +1003,7 @@ job_groups =
          , fastCI (standardBuilds AArch64 Darwin)
          , fastCI (standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla))
          , disableValidate (standardBuildsWithConfig AArch64 (Linux Debian11) (splitSectionsBroken vanilla))
    -     , disableValidate (validateBuilds AArch64 (Linux Debian10) llvm)
    +     , onlyRule LLVMBackend (validateBuilds AArch64 (Linux Debian12) llvm)
          , standardBuildsWithConfig I386 (Linux Debian10) (splitSectionsBroken vanilla)
          -- Fully static build, in theory usable on any linux distribution.
          , fullyStaticBrokenTests (standardBuildsWithConfig Amd64 (Linux Alpine312) (splitSectionsBroken static))
    @@ -1077,12 +1077,14 @@ platform_mapping = Map.map go combined_result
       where
         whitelist = [ "x86_64-linux-alpine3_12-validate"
                     , "x86_64-linux-deb11-validate"
    +                , "x86_64-linux-deb12-validate"
                     , "x86_64-linux-deb10-validate+debug_info"
                     , "x86_64-linux-fedora33-release"
                     , "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
                     , "x86_64-windows-validate"
                     , "nightly-x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static"
                     , "nightly-x86_64-linux-deb11-validate"
    +                , "nightly-x86_64-linux-deb12-validate"
                     , "x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static"
                     , "nightly-aarch64-linux-deb10-validate"
                     , "nightly-x86_64-linux-alpine3_12-validate"
    @@ -1092,6 +1094,7 @@ platform_mapping = Map.map go combined_result
                     , "release-x86_64-linux-alpine3_12-release+no_split_sections"
                     , "release-x86_64-linux-deb10-release"
                     , "release-x86_64-linux-deb11-release"
    +                , "release-x86_64-linux-deb12-release"
                     , "release-x86_64-linux-fedora33-release"
                     , "release-x86_64-windows-release"
                     ]
    
    
    =====================================
    .gitlab/jobs.yaml
    =====================================
    @@ -126,6 +126,67 @@
           "TEST_ENV": "aarch64-linux-deb10-validate"
         }
       },
    +  "aarch64-linux-deb12-validate+llvm": {
    +    "after_script": [
    +      ".gitlab/ci.sh save_cache",
    +      ".gitlab/ci.sh save_test_output",
    +      ".gitlab/ci.sh clean",
    +      "cat ci_timings"
    +    ],
    +    "allow_failure": false,
    +    "artifacts": {
    +      "expire_in": "2 weeks",
    +      "paths": [
    +        "ghc-aarch64-linux-deb12-validate+llvm.tar.xz",
    +        "junit.xml",
    +        "unexpected-test-output.tar.gz"
    +      ],
    +      "reports": {
    +        "junit": "junit.xml"
    +      },
    +      "when": "always"
    +    },
    +    "cache": {
    +      "key": "aarch64-linux-deb12-$CACHE_REV",
    +      "paths": [
    +        "cabal-cache",
    +        "toolchain"
    +      ]
    +    },
    +    "dependencies": [],
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12:$DOCKER_REV",
    +    "needs": [
    +      {
    +        "artifacts": false,
    +        "job": "hadrian-ghc-in-ghci"
    +      }
    +    ],
    +    "rules": [
    +      {
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "when": "on_success"
    +      }
    +    ],
    +    "script": [
    +      "sudo chown ghc:ghc -R .",
    +      ".gitlab/ci.sh setup",
    +      ".gitlab/ci.sh configure",
    +      ".gitlab/ci.sh build_hadrian",
    +      ".gitlab/ci.sh test_hadrian"
    +    ],
    +    "stage": "full-build",
    +    "tags": [
    +      "aarch64-linux"
    +    ],
    +    "variables": {
    +      "BIGNUM_BACKEND": "gmp",
    +      "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
    +      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "RUNTEST_ARGS": "",
    +      "TEST_ENV": "aarch64-linux-deb12-validate+llvm"
    +    }
    +  },
       "i386-linux-deb10-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
    @@ -380,7 +441,7 @@
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-aarch64-linux-deb10-validate+llvm": {
    +  "nightly-aarch64-linux-deb11-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -391,7 +452,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-aarch64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-aarch64-linux-deb11-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -401,14 +462,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "aarch64-linux-deb10-$CACHE_REV",
    +      "key": "aarch64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -434,15 +495,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-aarch64-linux-deb11-validate",
    +      "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "aarch64-linux-deb10-validate+llvm",
    +      "TEST_ENV": "aarch64-linux-deb11-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-aarch64-linux-deb11-validate": {
    +  "nightly-aarch64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -453,7 +514,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-aarch64-linux-deb11-validate.tar.xz",
    +        "ghc-aarch64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -463,14 +524,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "aarch64-linux-deb11-$CACHE_REV",
    +      "key": "aarch64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -496,11 +557,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-aarch64-linux-deb11-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-aarch64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "aarch64-linux-deb11-validate",
    +      "TEST_ENV": "aarch64-linux-deb12-validate+llvm",
           "XZ_OPT": "-9"
         }
       },
    @@ -1523,18 +1584,18 @@
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-validate+llvm": {
    +  "nightly-x86_64-linux-deb10-validate+thread_sanitizer": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
           ".gitlab/ci.sh clean",
           "cat ci_timings"
         ],
    -    "allow_failure": false,
    +    "allow_failure": true,
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1577,26 +1638,28 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    +      "BUILD_FLAVOUR": "validate+thread_sanitizer",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "HADRIAN_ARGS": "--docs=none",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+llvm",
    +      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    +      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-validate+thread_sanitizer": {
    +  "nightly-x86_64-linux-deb10-zstd-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
           ".gitlab/ci.sh clean",
           "cat ci_timings"
         ],
    -    "allow_failure": true,
    +    "allow_failure": false,
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
    +        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1639,17 +1702,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    -      "BUILD_FLAVOUR": "validate+thread_sanitizer",
    -      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "HADRIAN_ARGS": "--docs=none",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BUILD_FLAVOUR": "validate",
    +      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    -      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions",
    +      "TEST_ENV": "x86_64-linux-deb10-zstd-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb10-zstd-validate": {
    +  "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1660,7 +1721,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1670,14 +1731,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb10-$CACHE_REV",
    +      "key": "x86_64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -1703,15 +1764,17 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
    +      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    +      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    +      "CROSS_TARGET": "aarch64-linux-gnu",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-zstd-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
    +  "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1722,7 +1785,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1764,18 +1827,19 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "BIGNUM_BACKEND": "native",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    -      "CROSS_TARGET": "aarch64-linux-gnu",
    +      "CONFIGURE_WRAPPER": "emconfigure",
    +      "CROSS_EMULATOR": "js-emulator",
    +      "CROSS_TARGET": "javascript-unknown-ghcjs",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
    +  "nightly-x86_64-linux-deb11-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1786,7 +1850,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1828,19 +1892,16 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "native",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    +      "BIGNUM_BACKEND": "gmp",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CONFIGURE_WRAPPER": "emconfigure",
    -      "CROSS_EMULATOR": "js-emulator",
    -      "CROSS_TARGET": "javascript-unknown-ghcjs",
    +      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    +      "TEST_ENV": "x86_64-linux-deb11-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-validate": {
    +  "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1851,7 +1912,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1894,15 +1955,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-validate",
    +      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    +      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb11-validate+boot_nonmoving_gc": {
    +  "nightly-x86_64-linux-deb12-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1913,7 +1974,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -1923,14 +1984,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb11-$CACHE_REV",
    +      "key": "x86_64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -1956,15 +2017,15 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    -      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate",
    +      "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    -      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "RUNTEST_ARGS": "",
    +      "TEST_ENV": "x86_64-linux-deb12-validate",
           "XZ_OPT": "-9"
         }
       },
    -  "nightly-x86_64-linux-deb12-validate": {
    +  "nightly-x86_64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -1975,7 +2036,7 @@
         "artifacts": {
           "expire_in": "8 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb12-validate.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -2018,11 +2079,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate",
    -      "BUILD_FLAVOUR": "validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb12-validate",
    +      "TEST_ENV": "x86_64-linux-deb12-validate+llvm",
           "XZ_OPT": "-9"
         }
       },
    @@ -4969,7 +5030,7 @@
           "TEST_ENV": "x86_64-linux-deb10-validate+debug_info"
         }
       },
    -  "x86_64-linux-deb10-validate+llvm": {
    +  "x86_64-linux-deb10-validate+thread_sanitizer": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -4980,7 +5041,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+llvm.tar.xz",
    +        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5006,8 +5067,9 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    -        "when": "on_success"
    +        "allow_failure": true,
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "when": "manual"
           }
         ],
         "script": [
    @@ -5023,14 +5085,16 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm",
    -      "BUILD_FLAVOUR": "validate+llvm",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    +      "BUILD_FLAVOUR": "validate+thread_sanitizer",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "HADRIAN_ARGS": "--docs=none",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+llvm"
    +      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    +      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
         }
       },
    -  "x86_64-linux-deb10-validate+thread_sanitizer": {
    +  "x86_64-linux-deb10-zstd-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5041,7 +5105,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-validate+thread_sanitizer.tar.xz",
    +        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5067,9 +5131,8 @@
         ],
         "rules": [
           {
    -        "allow_failure": true,
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    -        "when": "manual"
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "when": "on_success"
           }
         ],
         "script": [
    @@ -5085,16 +5148,14 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
    -      "BUILD_FLAVOUR": "validate+thread_sanitizer",
    -      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "HADRIAN_ARGS": "--docs=none",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BUILD_FLAVOUR": "validate",
    +      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
    -      "TSAN_OPTIONS": "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
    +      "TEST_ENV": "x86_64-linux-deb10-zstd-validate"
         }
       },
    -  "x86_64-linux-deb10-zstd-validate": {
    +  "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5105,7 +5166,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb10-zstd-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5115,14 +5176,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb10-$CACHE_REV",
    +      "key": "x86_64-linux-deb11-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -5131,7 +5192,7 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*IPE.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5148,14 +5209,16 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-zstd-validate",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
           "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
    +      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    +      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    +      "CROSS_TARGET": "aarch64-linux-gnu",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb10-zstd-validate"
    +      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
         }
       },
    -  "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate": {
    +  "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5166,7 +5229,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5192,7 +5255,7 @@
         ],
         "rules": [
           {
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5208,17 +5271,18 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
    +      "BIGNUM_BACKEND": "native",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
           "BUILD_FLAVOUR": "validate",
           "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
    -      "CROSS_TARGET": "aarch64-linux-gnu",
    +      "CONFIGURE_WRAPPER": "emconfigure",
    +      "CROSS_EMULATOR": "js-emulator",
    +      "CROSS_TARGET": "javascript-unknown-ghcjs",
           "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
    +      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate"
         }
       },
    -  "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": {
    +  "x86_64-linux-deb11-validate+boot_nonmoving_gc": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5229,7 +5293,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz",
    +        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5255,7 +5319,7 @@
         ],
         "rules": [
           {
    -        "if": "((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*javascript.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5271,18 +5335,15 @@
           "x86_64-linux"
         ],
         "variables": {
    -      "BIGNUM_BACKEND": "native",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
    -      "BUILD_FLAVOUR": "validate",
    -      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
    -      "CONFIGURE_WRAPPER": "emconfigure",
    -      "CROSS_EMULATOR": "js-emulator",
    -      "CROSS_TARGET": "javascript-unknown-ghcjs",
    -      "RUNTEST_ARGS": "",
    -      "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate"
    +      "BIGNUM_BACKEND": "gmp",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    +      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    +      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    +      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc"
         }
       },
    -  "x86_64-linux-deb11-validate+boot_nonmoving_gc": {
    +  "x86_64-linux-deb12-validate+llvm": {
         "after_script": [
           ".gitlab/ci.sh save_cache",
           ".gitlab/ci.sh save_test_output",
    @@ -5293,7 +5354,7 @@
         "artifacts": {
           "expire_in": "2 weeks",
           "paths": [
    -        "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc.tar.xz",
    +        "ghc-x86_64-linux-deb12-validate+llvm.tar.xz",
             "junit.xml",
             "unexpected-test-output.tar.gz"
           ],
    @@ -5303,14 +5364,14 @@
           "when": "always"
         },
         "cache": {
    -      "key": "x86_64-linux-deb11-$CACHE_REV",
    +      "key": "x86_64-linux-deb12-$CACHE_REV",
           "paths": [
             "cabal-cache",
             "toolchain"
           ]
         },
         "dependencies": [],
    -    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb11:$DOCKER_REV",
    +    "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:$DOCKER_REV",
         "needs": [
           {
             "artifacts": false,
    @@ -5319,7 +5380,7 @@
         ],
         "rules": [
           {
    -        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*non-moving GC.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
    +        "if": "(($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/)) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
             "when": "on_success"
           }
         ],
    @@ -5336,11 +5397,11 @@
         ],
         "variables": {
           "BIGNUM_BACKEND": "gmp",
    -      "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
    -      "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
    +      "BIN_DIST_NAME": "ghc-x86_64-linux-deb12-validate+llvm",
    +      "BUILD_FLAVOUR": "validate+llvm",
           "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
    -      "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
    -      "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc"
    +      "RUNTEST_ARGS": "",
    +      "TEST_ENV": "x86_64-linux-deb12-validate+llvm"
         }
       },
       "x86_64-linux-fedora33-release": {
    
    
    =====================================
    compiler/GHC/Iface/Syntax.hs
    =====================================
    @@ -1067,8 +1067,9 @@ pprIfaceDecl ss (IfaceFamily { ifName = tycon
       = vcat [ pprStandaloneKindSig name_doc (mkIfaceTyConKind binders res_kind)
              , hang (text "type family"
                        <+> pprIfaceDeclHead suppress_bndr_sig [] ss tycon binders
    +                   <+> pp_inj res_var inj
                        <+> ppShowRhs ss (pp_where rhs))
    -              2 (pp_inj res_var inj <+> ppShowRhs ss (pp_rhs rhs))
    +              2 (ppShowRhs ss (pp_rhs rhs))
                $$
                nest 2 (ppShowRhs ss (pp_branches rhs))
              ]
    
    
    =====================================
    docs/users_guide/exts/scoped_type_variables.rst
    =====================================
    @@ -293,11 +293,11 @@ signatures/ of the methods. For example, the following will be accepted without
     explicitly enabling :extension:`ScopedTypeVariables`: ::
     
           class D a where
    -        m :: [a] -> a
    +        m :: a -> a
     
    -      instance D [a] where
    +      instance Num a => D [a] where
             m :: [a] -> [a]
    -        m = reverse
    +        m x = map (*2) x
     
     Note that writing ``m :: [a] -> [a]`` requires the use of the
     :extension:`InstanceSigs` extension.
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-mingw32
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    =====================================
    testsuite/tests/interface-stability/base-exports.stdout-ws-32
    =====================================
    @@ -1657,7 +1657,7 @@ module Data.Type.Bool where
         forall k (tru :: k) (fls :: k). If GHC.Types.True tru fls = tru
         forall k (tru :: k) (fls :: k). If GHC.Types.False tru fls = fls
       type Not :: GHC.Types.Bool -> GHC.Types.Bool
    -  type family Not a where = res | res -> a
    +  type family Not a = res | res -> a where
           Not GHC.Types.False = GHC.Types.True
           Not GHC.Types.True = GHC.Types.False
       type (||) :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool
    
    
    
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f5abb27792158f322a6addb367690b9d7f254fd6...2488cbf2a7db0d0554845fb96a8478376aa5fdae
    
    -- 
    View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f5abb27792158f322a6addb367690b9d7f254fd6...2488cbf2a7db0d0554845fb96a8478376aa5fdae
    You're receiving this email because of your account on gitlab.haskell.org.
    
    
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: